Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp775059lqp; Sat, 13 Apr 2024 21:24:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWQBJQKZ0geuOuH3mUYi7JOiYHMQ+48GLmVqUxXzJkIpu/3q1PJJqVV4b2wM9r1GZ/snRaF9S/1NQSbdKxO6xi/e6KBCEQsDUAuklZQpA== X-Google-Smtp-Source: AGHT+IEawr8W1FsMErPweMTi8rlFxBBNpUVFWrLXxvavt5EmGW3g3lyYNAn8sNFSNCxriG81BKE8 X-Received: by 2002:a05:6a00:198c:b0:6ea:86f2:24fb with SMTP id d12-20020a056a00198c00b006ea86f224fbmr9379273pfl.25.1713068645093; Sat, 13 Apr 2024 21:24:05 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c17-20020a056a000ad100b006e8985a0f24si6078513pfl.202.2024.04.13.21.24.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Apr 2024 21:24:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143977-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=uTsHLvvQ; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-143977-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143977-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amperecomputing.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C91E6B215A9 for ; Sun, 14 Apr 2024 04:24:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 45D771862C; Sun, 14 Apr 2024 04:23:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.b="uTsHLvvQ" Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2108.outbound.protection.outlook.com [40.107.101.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA1C71CAB0; Sun, 14 Apr 2024 04:23:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.108 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713068613; cv=fail; b=qnVdBAnR18TQxV+XUd0WiYrHrpjH/5PKLIYJ8Y6M/Tsv/mbq6O+F3fiwilZrEQEZ9UTl/5h85cybR53ryZ6p2RWZJLpr1QCjbB1hA7sdsaZQARvxmgi9aoJhqR66BSLLl4zorgO/fAvc46uvUM9z5tFpbVX1uHc1heyp+PnsJ1w= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713068613; c=relaxed/simple; bh=rnBYhSdaF7BlR00cTMiCvXxq/Cdx98bwGr+O35rnL+Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=szzxVMaSVAzugDqedwenc3WiTdMDGiYjbwzrawr1d0ijzhIPLYslEq3r/rDUtX/5n3BNqYtL5tSGLGEf9hfTAPr51UDqzR4X07qIaObfad54+e0TJff8Cq/cUTbZt0h/KOL5maqZdePJshsGrOdI5iNaK4uTvRrH3BCafRE656o= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=os.amperecomputing.com; spf=pass smtp.mailfrom=os.amperecomputing.com; dkim=pass (1024-bit key) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.b=uTsHLvvQ; arc=fail smtp.client-ip=40.107.101.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=os.amperecomputing.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=os.amperecomputing.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oPv33cmLkf6q2QM6GmExvL/ChMMHtkSqTMRUNc22ccZHQrfYw3tTJnFszs9W6o9Ili0e279GUadXZ9jcUvuI2bl9pyhSmtqI9mF+k7S+AB3kuODEFSNDltkxR6+Q9H+R0iQnaphpfj838bYhd0SE+0O+JrgYId+ImwCDqyAAaWF2lAq1VbIrg44yFp4ZtWFephVECOit+IKvYfe+rU8PZKZPBrBuJE3f+e/gA1zZ75hPOfva/4nBBmwzaOpe168eZwrbKXeoPaSP7WBAjNZTz9jWciYN1HqYV8B7DqwzoPRC+RUAI5wyQN6ZWBRe6XU1MIosgeOCn81KHKwQFcK0Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=g0A3PMx2vCjWaPeHst/bpAAfcashDP8/cgpPZ752WYY=; b=X2vxxIh0Z8c7U2o+w/DWnbRHlxQf8jk1fFGwiIwiw7gSgahb67VzWwUaTijBii2BInpzWPTQNwCNZw6hnXN3AI5l+ngoO/hbW+tblbugIRoW9G5gFqQcDX/02ppyIaRRF4+a967rs4X7vmv6HjNgLZ8rjqWCmwovey7SmecKbAO9axtw1oCSDJhMmOOyt/9az+toKzyLtCgMuDb8ekkXkgfqpzfbFMaN5Mx7plC9u+dY0O4h19R2bpUzgR//obCr6HddsHZNRpwx/uULnIGDR0+gYoplF4fCGpGMxvbb20X7dg0Sfw39PfrMUarOscljhguonBOFydNsw1PSZALqXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g0A3PMx2vCjWaPeHst/bpAAfcashDP8/cgpPZ752WYY=; b=uTsHLvvQ7t+GhhjrdFOey68/3hlxQlTTgrBPCrHliOYOolJsPFX2tRewZp7C9benPC57/lCsLr5rjLuV7j3ikMpiHMlOiUqikyFOZ8TsK5TG3d2DB+N1dwsorF7ngJ/et9Zku3QQ7ozaITu4DzbleJq0XXnvFUHoAv2vbR7RMYE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM6PR01MB5947.prod.exchangelabs.com (2603:10b6:5:1dd::12) by PH0PR01MB6715.prod.exchangelabs.com (2603:10b6:510:97::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.50; Sun, 14 Apr 2024 04:23:29 +0000 Received: from DM6PR01MB5947.prod.exchangelabs.com ([fe80::b557:13cd:8a29:ae08]) by DM6PR01MB5947.prod.exchangelabs.com ([fe80::b557:13cd:8a29:ae08%4]) with mapi id 15.20.7452.046; Sun, 14 Apr 2024 04:23:29 +0000 From: Chanh Nguyen To: Jean Delvare , Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Justin Ledford , devicetree@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, OpenBMC Maillist , Open Source Submission Cc: Phong Vo , Thang Nguyen , Quan Nguyen , Chanh Nguyen Subject: [PATCH v2 2/3] hwmon: (max31790): Support config PWM output becomes TACH Date: Sun, 14 Apr 2024 11:22:45 +0700 Message-Id: <20240414042246.8681-3-chanh@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240414042246.8681-1-chanh@os.amperecomputing.com> References: <20240414042246.8681-1-chanh@os.amperecomputing.com> Content-Type: text/plain X-ClientProxiedBy: SG2PR06CA0216.apcprd06.prod.outlook.com (2603:1096:4:68::24) To DM6PR01MB5947.prod.exchangelabs.com (2603:10b6:5:1dd::12) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR01MB5947:EE_|PH0PR01MB6715:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a6fd5e7-01fd-465e-fd05-08dc5c3aa2d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?vyzG0OOFMUywiFxMZzDhb5c3o4e/bs7PESlVXtMM8crLyk4gSlxKa7NXPt0Q?= =?us-ascii?Q?0QdLEoK1jFQVoMaNhK8pUAbb+IAC3pmGfptcTKC04Ar10b0C52mkri5xPXe1?= =?us-ascii?Q?9L0Tfttr1tgLoyzYjq+FHJ5jpON3xRjKNrGWb9lMOLFdHTLULBoUQ3Bc0DW5?= =?us-ascii?Q?sy8kEijCdGoKsj+jY1KpMf41YGHgrVTG4AvPzQexDLDdaN++lr6bXhsnJUPv?= =?us-ascii?Q?A8qpLySYL4KsAaGRlHlgPCcV4CeL0MBNS3gZ8k9bzHzvq+LYyoX+k7UDDIuc?= =?us-ascii?Q?ciCceCIWw/CdcCshIT//AmbiBsuSH8KiRW2umiI32st1YHMkYfRnGSVykugl?= =?us-ascii?Q?gDBO2rAA9BgDcuVloeCm0FCfB5KmmKd66zsRpk5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m9QD7pZZopeJESqU4eB9gsEuK3RSPfumoXoTxWSCIih8yDdjVLJH+?= =?us-ascii?Q?upzVOqYEAebA0cyr4/0K5RbgzCM+6UAioUMorZIQlnwtulRR5XwKOvYf1wNe?= =?us-ascii?Q?uckbApA=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR01MB5947.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(52116005)(7416005)(376005)(366007)(921011)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?m/eEWkSNbj5vSGMvdItkIXI7diJHoNCMVDLAbkZ1Iv4ik4PxM4O4Pp7rUlP6?= =?us-ascii?Q?WPOJiorXugHCW7ewibfjuosRyCq4LVY0Lqt93hhMsGMTmIAGic5+dbLn73PG?= =?us-ascii?Q?bSCwOyHESZSJYVoU6U7P0hrXNOGKtIuOmMznANehHxrSgBzy47j5Q4Hluzti?= =?us-ascii?Q?OKATxXtKzu4zImJFjzYtpj9vGsLEMMfqQjdp2VPUztUBL97scE6INiNxFeoz?= =?us-ascii?Q?T2ZY+TuLaz/PnL5kj+dJ7wm2Q0QE6Ua0zT5LYgE1s/sp73uk2RWUHL+zRYTc?= =?us-ascii?Q?eLs3ag52PLDRCLGQTdNPUnLeDHT2Kl6muZgT07yh+WNyUkJElOzK87vfsauO?= =?us-ascii?Q?o6xvs4LWYwJewXtyvHc/xtg4bW1e9kv3b3ITlULCJYj2omeBkj36+bBmXqhB?= =?us-ascii?Q?PAHNEeHtDZvyWK2tIthkSTGnzx7nqTkI7KZGJswBFOWiC3HL/mlqPFXI70tT?= =?us-ascii?Q?fmyOJjGo4bvDlUzH0O5IXpQhfHnH5Czsx1RphzvZEiORPU7dG1PzvuB/V1G4?= =?us-ascii?Q?XCg8k7fZxNmr9gwFQ42RfftEI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q?c/hhCC5D+cL+9YCP0goxB95BVVXFjvISa99BkE5khq9UYk/b3w8ISJZHdj2s?= =?us-ascii?Q?JCBG/zjeyP0PqclmNDB6BdY6rwVN7nKmrliG40M/GBZssowl8troU8ljIEeC?= =?us-ascii?Q?TyIDjcnFi6+wAEcC8AfVEnhEWftjyLMaDXix09CCtfusOidNXIaR1PZMY1fa?= =?us-ascii?Q?2sHXXSoEeQl1F4AA6O5CYi0=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a6fd5e7-01fd-465e-fd05-08dc5c3aa2d0 X-MS-Exchange-CrossTenant-AuthSource: DM6PR01MB5947.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2024 04:23:29.2660 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yzgazkQh7wScBrLsoNpg7FZl+tE74KBfOIPvd1feegXceDkabZ/65Etzx/cQ+yCKbvo3hnId6dwL1MA7zdytVaWCmEZSkjzFKdV8n0gKsqMlT/EKVjrKfk4xQxtEAxVR X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR01MB6715 PWMOUT pins on MAX31790 can be configured as a tachometer input pin by setting bit[0] in the Configuration Register. When the bit[0] of a channel is set, the PWMOUT pin becomes the tach input pin for the channel plus six. This commit allows the kernel to set those pins when necessary if the maxim,pwmout-pin-as-tach-input DT property exists. Signed-off-by: Chanh Nguyen --- Changes in v2: - Update the vendor property name to "maxim,pwmout-pin-as-tach-input" [Rob] --- drivers/hwmon/max31790.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/hwmon/max31790.c b/drivers/hwmon/max31790.c index 3dc95196b229..ac0a8099acf6 100644 --- a/drivers/hwmon/max31790.c +++ b/drivers/hwmon/max31790.c @@ -12,6 +12,7 @@ #include #include #include +#include #include /* MAX31790 registers */ @@ -506,9 +507,12 @@ static int max31790_probe(struct i2c_client *client) { struct i2c_adapter *adapter = client->adapter; struct device *dev = &client->dev; + u8 pwmout_to_tach[NR_CHANNEL]; struct max31790_data *data; struct device *hwmon_dev; int err; + u8 tmp; + int i; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) @@ -528,6 +532,33 @@ static int max31790_probe(struct i2c_client *client) if (err) return err; + if (device_property_present(dev, "maxim,pwmout-pin-as-tach-input")) { + err = device_property_read_u8_array(dev, "maxim,pwmout-pin-as-tach-input", + pwmout_to_tach, NR_CHANNEL); + if (err) { + /* The maxim,pwmout-pin-as-tach-input is an array of six values */ + dev_warn(dev, "The maxim,pwmout-pin-as-tach-input property exist but malform"); + } else { + for (i = 0; i < NR_CHANNEL; i++) { + tmp = data->fan_config[i]; + if (pwmout_to_tach[i]) + data->fan_config[i] |= MAX31790_FAN_CFG_TACH_INPUT; + else + data->fan_config[i] &= ~(MAX31790_FAN_CFG_TACH_INPUT); + + if (tmp != data->fan_config[i]) { + err = i2c_smbus_write_byte_data(client, + MAX31790_REG_FAN_CONFIG(i), + data->fan_config[i]); + if (err < 0) + dev_warn(dev, + "Fail to apply fan configuration at channel %d", + i); + } + } + } + } + hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, data, &max31790_chip_info, -- 2.17.1