From patchwork Mon Feb 24 18:08:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francesco Dolcini X-Patchwork-Id: 13988729 Received: from mail11.truemail.it (mail11.truemail.it [217.194.8.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A260BCA64; Mon, 24 Feb 2025 18:26:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.194.8.81 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740421575; cv=none; b=dXKOhTI87h0JCvuegcVhTgzyvuniga9YHwXJUTMbiLFuwpEtqux4zwksH0JlX0BcogydHvXHmX2ZPG99gv+eIERRLd9vhtUOQuo9pRzQ+9LEO5GTGcRYLOxJ8n0mu/MgHC1JdB4JDHfIUd4e/FuH/q5O8GPQt1i7ZQFzMe2/tQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740421575; c=relaxed/simple; bh=fPLzH7LE8mpU0lpFBxI6bTtDCg+LS4q5KJKW0NDcF+Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WYagX99A/035o07EKVIlEKe3vuE8akIME78hykB0tZTRiT5Qx4WF1caF8s0HSXfbS448lP23bK7uDZgnZ1jStB6f3hdxIqMqifYsZnMure7PZqFq7gaXjeG2oLGLU11dpkVWf/DuriJCyVM/ckhhDqXmwHs38H+eg1rluYP1G9I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=dolcini.it; spf=pass smtp.mailfrom=dolcini.it; dkim=pass (2048-bit key) header.d=dolcini.it header.i=@dolcini.it header.b=VVrHpcAs; arc=none smtp.client-ip=217.194.8.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=dolcini.it Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dolcini.it Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dolcini.it header.i=@dolcini.it header.b="VVrHpcAs" Received: from francesco-nb.pivistrello.it (93-49-2-63.ip317.fastwebnet.it [93.49.2.63]) by mail11.truemail.it (Postfix) with ESMTPA id 923481F989; Mon, 24 Feb 2025 19:08:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dolcini.it; s=default; t=1740420486; bh=mWS9c2cfDFeU9QDimntm/gZ5WTWvS8Fqw7BP//0uZ2w=; h=From:To:Subject; b=VVrHpcAsvGj7xi9g1Uubcuetnf5Nm8V36W/ScEMseQRU7h6ar7ZPloeyOjfzqPD1w vaLXkLAXVxsVsT4yztRfAl04FtfUw4PAGQM33HNpSKgqOONwMrXC5WnVEnZFXWyfsj a7uZXqrnknLQ/MSp+VENoHHix8kGOcvZNou0TPCg63l2KdY+0CdJMufCAVNFlH+4Sb +Ma4we4fVfMlnG8ZHc9YhrW0t9HpVX202yiLV6YXgutaK6tbwIIp4R7W11EVz+clsR VK1AZM2v9UOBGbqPZSV2G5DVu1koXPZLI0S+4ZvPrHUWRG59fYAQIJzp/kNIffJaLV otz4Of0mqz3ig== From: Francesco Dolcini To: Jean Delvare , Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Farouk Bouabid , Quentin Schulz Cc: Francesco Dolcini , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] dt-bindings: hwmon: amc6821: add PWM polarity Date: Mon, 24 Feb 2025 19:08:00 +0100 Message-Id: <20250224180801.128685-2-francesco@dolcini.it> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250224180801.128685-1-francesco@dolcini.it> References: <20250224180801.128685-1-francesco@dolcini.it> Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Francesco Dolcini Add property to describe the PWM-Out pin polarity. Link: https://www.ti.com/lit/gpn/amc6821 Signed-off-by: Francesco Dolcini --- v2: no changes v1: https://lore.kernel.org/all/20250218165633.106867-2-francesco@dolcini.it/ --- Documentation/devicetree/bindings/hwmon/ti,amc6821.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/ti,amc6821.yaml b/Documentation/devicetree/bindings/hwmon/ti,amc6821.yaml index 5d33f1a23d03..11604aa41b3e 100644 --- a/Documentation/devicetree/bindings/hwmon/ti,amc6821.yaml +++ b/Documentation/devicetree/bindings/hwmon/ti,amc6821.yaml @@ -28,6 +28,14 @@ properties: i2c-mux: type: object + ti,pwm-inverted: + type: boolean + description: + Set to make the PWM-Out pin go high (with an external pull-up resistor) + for 100% duty cycle (suitable for driving the fan using a NMOS device), + when not set the PWM-Out pin goes low for 100% duty cycle (suitable for + driving the fan using a PMOS device). + required: - compatible - reg From patchwork Mon Feb 24 18:08:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francesco Dolcini X-Patchwork-Id: 13988709 Received: from mail11.truemail.it (mail11.truemail.it [217.194.8.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE9E1265CBF; Mon, 24 Feb 2025 18:21:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.194.8.81 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740421276; cv=none; b=p3I+MxbEmGDvHSKmizrZuwckSQy8FqKac3/ZU82X/ZrSJfkDcj8dXQj6UqIV8KgugfkC6o56nxALFKUvbK4oyn0lIrpZyAZZ5ADkdCEDeLXrveSqrkL3JXBJTl3FdtzNlorJ26j9OpVaDHgguWVohEhhtBBsJ5VQe1q7Z3zIlco= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740421276; c=relaxed/simple; bh=DCXTAXYVaCDoehjsFSI9JGthYW2HgxuvBibu7CR934I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=h2pl3u0eB+giEQBTfXA5FzoxhXoLmG8VKyRYvHQsyt8yyRtahZH1GybXJXPxpNTjzZOeORdwaus63AslWN0ht7h56OdWOScI3WHUQhpzr0Kk5TMrEn5/vI7UDJn8tvs6o+IFpjlW7Ooe/X3eEDOwHfxs77APyA60Yz2J82PsrEg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=dolcini.it; spf=pass smtp.mailfrom=dolcini.it; dkim=pass (2048-bit key) header.d=dolcini.it header.i=@dolcini.it header.b=BQR8h4qZ; arc=none smtp.client-ip=217.194.8.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=dolcini.it Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dolcini.it Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dolcini.it header.i=@dolcini.it header.b="BQR8h4qZ" Received: from francesco-nb.pivistrello.it (93-49-2-63.ip317.fastwebnet.it [93.49.2.63]) by mail11.truemail.it (Postfix) with ESMTPA id 31F111FBD4; Mon, 24 Feb 2025 19:08:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dolcini.it; s=default; t=1740420486; bh=C7U4HwlepaLvGf1mVinelge72wt+sVgO2WNDILODsR0=; h=From:To:Subject; b=BQR8h4qZ9ROPMhDIlNvrQ+RrB3mQKBzFKlMUHECmKM6plkdai1b9GBE+P333oXAxE SNH+uN+MRoHMHQlB1hA3gDj+vrAMN0l9G4uQhLlKOoaFoPCLE/+PBGO/1wFFnMGwMA p3pV/0uLeD6vLcCtdeJcajDtcCOV00tu6agYAlx0BlGV8QUsKA5vjvyiWyOp/ZDClO 9cwmuGjrXOmoP0zK1s3qaft9B7HZAzNqKB24Be5kYpzU70lEqGSJ84fOoJP0Fbp0xG fDBKVa+PXfwGw6994eXRqE/xiP1S6pMUbsFVztX7A6o7x9HW4eBHftub1Z5PbSZjya 8PpAoDm8pkI6A== From: Francesco Dolcini To: Jean Delvare , Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Farouk Bouabid , Quentin Schulz Cc: Francesco Dolcini , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] hwmon: (amc6821) Add PWM polarity configuration with OF Date: Mon, 24 Feb 2025 19:08:01 +0100 Message-Id: <20250224180801.128685-3-francesco@dolcini.it> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250224180801.128685-1-francesco@dolcini.it> References: <20250224180801.128685-1-francesco@dolcini.it> Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Francesco Dolcini Add support to configure the PWM-Out pin polarity based on a device tree property. The driver has a module option to set the PWM polarity (normal=0, inverted=1), when specified it always takes the precedence over the DT configuration. Signed-off-by: Francesco Dolcini --- v2: pwminv module parameter takes always the precedence over the DT property v1: https://lore.kernel.org/all/20250218165633.106867-3-francesco@dolcini.it/ --- drivers/hwmon/amc6821.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c index 1e3c6acd8974..317741995df2 100644 --- a/drivers/hwmon/amc6821.c +++ b/drivers/hwmon/amc6821.c @@ -37,7 +37,7 @@ static const unsigned short normal_i2c[] = {0x18, 0x19, 0x1a, 0x2c, 0x2d, 0x2e, * Insmod parameters */ -static int pwminv; /*Inverted PWM output. */ +static int pwminv = -1; /*Inverted PWM output. */ module_param(pwminv, int, 0444); static int init = 1; /*Power-on initialization.*/ @@ -845,9 +845,10 @@ static int amc6821_detect(struct i2c_client *client, struct i2c_board_info *info return 0; } -static int amc6821_init_client(struct amc6821_data *data) +static int amc6821_init_client(struct i2c_client *client, struct amc6821_data *data) { struct regmap *regmap = data->regmap; + u32 regval; int err; if (init) { @@ -864,11 +865,15 @@ static int amc6821_init_client(struct amc6821_data *data) if (err) return err; + regval = AMC6821_CONF1_START; + if ((pwminv < 0 && of_property_read_bool(client->dev.of_node, "ti,pwm-inverted")) || + pwminv > 0) + regval |= AMC6821_CONF1_PWMINV; + err = regmap_update_bits(regmap, AMC6821_REG_CONF1, AMC6821_CONF1_THERMOVIE | AMC6821_CONF1_FANIE | AMC6821_CONF1_START | AMC6821_CONF1_PWMINV, - AMC6821_CONF1_START | - (pwminv ? AMC6821_CONF1_PWMINV : 0)); + regval); if (err) return err; } @@ -916,7 +921,7 @@ static int amc6821_probe(struct i2c_client *client) "Failed to initialize regmap\n"); data->regmap = regmap; - err = amc6821_init_client(data); + err = amc6821_init_client(client, data); if (err) return err;