From nobody Sun Feb 8 18:14:12 2026 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 4A22A21147A; Mon, 31 Mar 2025 15:52:36 +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=1743436360; cv=none; b=ZVO4sRAot6Guohr4/T5siRe676Uf4b6ULsNx+frKrStjjSK7uOH47U8WfwTmsY6PQcXoD0ItxxU23ssNE6Ei4Faz/nvC7D4fde7sXOxrmdwwaP2qqKBnr7aemqZYRU6sW38p3KZGOecGfvPl3TPwFv2L8seZsxxIxDMWDK1ZDdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743436360; c=relaxed/simple; bh=z+OhnofA166k/30CaNloxYejPREjsHP463osLIA9kh0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IXCJC9XlbXM61bNdVdNb5QgzwvBAexGlH8OUuCkjhXZluV46UfkA7xckhmq/635k8KrnXSEdKm0GIv6DvHRgaPKDVF53H4UDIYKYna3vNmooAnzsqFkqVDbi9qs/LKE+wMg10oMvk0wqZlMbLIDZkEmcGs4PsndErHcC72TLUlQ= 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=kYos5sKB; 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="kYos5sKB" Received: from francesco-nb.corp.toradex.com (31-10-206-125.static.upc.ch [31.10.206.125]) by mail11.truemail.it (Postfix) with ESMTPA id CEA8B1F9F4; Mon, 31 Mar 2025 17:52:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dolcini.it; s=default; t=1743436355; bh=SJgfb8TQpY0ee2eKfxl66K4dUcxi4hrZyAmL4y/2lB0=; h=From:To:Subject; b=kYos5sKBC0NrQtVXC3EiRbd8lHaI/hsFeJmDyIbMMpHbf9B27JE9j/fcLfIqxuYxx 45Kz7RTTfDoDVrRwa8+HRkiMMyH/z6vtC4jgdXcbUi/Cg7Z9Egs0HEVqHkHs6EPKXo +S+3NFVJaxW6ON1kP/JV/5sl+uQuwKlZw0Lh74E5n9z6oWYmyqlyWUQDgjSyZ5AjgY zhy8+trvBabbKNfUb1pGIBumsSDl2hsv+4OFnwr6YgLXgVfH4//IOXNP/wLdW3wRXg WwlKMOCrBmBqn5WidZgNzNIni3C8qzGnutqfZYrLw4Rfix+GcJ3bKbOruN3a3FlS0J iaGlyf9AHB8DA== 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 v3 1/2] dt-bindings: hwmon: amc6821: add fan and PWM output Date: Mon, 31 Mar 2025 17:52:28 +0200 Message-Id: <20250331155229.147879-2-francesco@dolcini.it> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250331155229.147879-1-francesco@dolcini.it> References: <20250331155229.147879-1-francesco@dolcini.it> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Francesco Dolcini Add properties to describe the fan and the PWM controller output. Link: https://www.ti.com/lit/gpn/amc6821 Signed-off-by: Francesco Dolcini --- v3: - explicitly describe the fan, use standard PWM and FAN bindings - pwm.yaml cannot be referenced, because of the $nodename pattern that is enforced there v2: https://lore.kernel.org/all/20250224180801.128685-2-francesco@dolcini.i= t/ - no changes v1: https://lore.kernel.org/all/20250218165633.106867-2-francesco@dolcini.i= t/ --- .../devicetree/bindings/hwmon/ti,amc6821.yaml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/hwmon/ti,amc6821.yaml b/Docu= mentation/devicetree/bindings/hwmon/ti,amc6821.yaml index 5d33f1a23d03..94aca9c378e6 100644 --- a/Documentation/devicetree/bindings/hwmon/ti,amc6821.yaml +++ b/Documentation/devicetree/bindings/hwmon/ti,amc6821.yaml @@ -28,6 +28,13 @@ properties: i2c-mux: type: object =20 + fan: + $ref: fan-common.yaml# + unevaluatedProperties: false + + "#pwm-cells": + const: 3 + required: - compatible - reg @@ -50,9 +57,14 @@ examples: #address-cells =3D <1>; #size-cells =3D <0>; =20 - fan@18 { + fan_controller: fan@18 { compatible =3D "ti,amc6821"; reg =3D <0x18>; + #pwm-cells =3D <3>; + + fan { + pwms =3D <&fan_controller 0 40000 0>; + }; }; }; =20 --=20 2.39.5 From nobody Sun Feb 8 18:14:12 2026 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 87AF6214204; Mon, 31 Mar 2025 15:52:37 +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=1743436359; cv=none; b=TuUk3A1EjYZsFOmsIqV0SAAkza7cReLXaXQlBq4jANdUgKWln2n7DiJ0F90c5LtS9TSRlhzwDz4YQZj95yY+KhLSDI7AJSKPHlDorOQugb9sf8OUwrGp4IuJsCRa7dOBIc8CxWysM4/G3giiRQG9KASHOGUYCZdUm8zHyt/w4zQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743436359; c=relaxed/simple; bh=X+4YTOgaKia4SBm9JwbRZaGKwlEx4yxWYQVOlNN65Og=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gq5fzNcP8llC1jn9S/LN3WwpHkcQbmQN+hdQq9Xkuox+NE7MInI5pSAxSMS2PR9BC9LWMo+dxGzI77eoROTFboG/mu7FKTprMMp6oMkbB32bnwNsBM0fuafeje1ucelws8thrJByJ+Pw9V+QKeob/f9e5BMjo33J9CEDvpBz6jM= 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=y3aLtGlk; 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="y3aLtGlk" Received: from francesco-nb.corp.toradex.com (31-10-206-125.static.upc.ch [31.10.206.125]) by mail11.truemail.it (Postfix) with ESMTPA id 5D3211FADE; Mon, 31 Mar 2025 17:52:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dolcini.it; s=default; t=1743436355; bh=M6Ms59MEu3FxpbZy5ys+yd+g+93FyYw+L8eXiLUaqfM=; h=From:To:Subject; b=y3aLtGlkbDHkJ3EsyceO7xgnNME9wiWzFkgVZlAoANLweTOGa31z84gAZTb4xWKAm huJ6kfZ4orhXPxA0mfEmF7oFvOMzRCCDLPKpF8JO9OIA6FjHrifzBWXJ/pUvZ5kil0 tjnWbOOsS+l4rWCfVbIeaxpDuLg8HOhHSFTAODl3QfW6ZoPYSdr0/v36J2JjvClaXm O1dZj00iN0nW+DZkk6ZaOrk5uNyoGzyHyKhmMhfU5hDPHCM8DmxCyhB64yc6O4Lo2O NnFtO7KR10i5KdWdB2VndOxAl/tP2LxmlkETpHWzv1IrC190zikgrN4tA6OPLRGKsW rgmzqXPJFV4cw== 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 v3 2/2] hwmon: (amc6821) Add PWM polarity configuration with OF Date: Mon, 31 Mar 2025 17:52:29 +0200 Message-Id: <20250331155229.147879-3-francesco@dolcini.it> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250331155229.147879-1-francesco@dolcini.it> References: <20250331155229.147879-1-francesco@dolcini.it> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Francesco Dolcini Add support to configure the PWM-Out pin polarity based on the device tree. The binding would allow also to configure the PWM period, this is currently not implemented by the driver. The driver has a module option to set the PWM polarity (normal=3D0, inverted=3D1), when specified it always takes the precedence over the DT. Signed-off-by: Francesco Dolcini --- v3: - configure PWM polarity using standard PWM DT properties v2: https://lore.kernel.org/lkml/20250224180801.128685-3-francesco@dolcini.= it/ - pwminv module parameter takes always the precedence over the DT property v1: https://lore.kernel.org/all/20250218165633.106867-3-francesco@dolcini.i= t/ --- drivers/hwmon/amc6821.c | 50 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c index 1e3c6acd8974..9ad4e9b63138 100644 --- a/drivers/hwmon/amc6821.c +++ b/drivers/hwmon/amc6821.c @@ -23,9 +23,12 @@ #include #include #include +#include #include #include =20 +#include + /* * Addresses to scan. */ @@ -37,7 +40,7 @@ static const unsigned short normal_i2c[] =3D {0x18, 0x19,= 0x1a, 0x2c, 0x2d, 0x2e, * Insmod parameters */ =20 -static int pwminv; /*Inverted PWM output. */ +static int pwminv =3D -1; /*Inverted PWM output. */ module_param(pwminv, int, 0444); =20 static int init =3D 1; /*Power-on initialization.*/ @@ -845,9 +848,43 @@ static int amc6821_detect(struct i2c_client *client, s= truct i2c_board_info *info return 0; } =20 -static int amc6821_init_client(struct amc6821_data *data) +static enum pwm_polarity amc6821_pwm_polarity(struct i2c_client *client) +{ + enum pwm_polarity polarity =3D PWM_POLARITY_NORMAL; + struct of_phandle_args args; + struct device_node *fan_np; + + /* + * For backward compatibility, the pwminv module parameter takes + * always the precedence over any other device description + */ + if (pwminv =3D=3D 0) + return PWM_POLARITY_NORMAL; + if (pwminv > 0) + return PWM_POLARITY_INVERSED; + + fan_np =3D of_get_child_by_name(client->dev.of_node, "fan"); + if (!fan_np) + return PWM_POLARITY_NORMAL; + + if (of_parse_phandle_with_args(fan_np, "pwms", "#pwm-cells", 0, &args)) + goto out; + of_node_put(args.np); + + if (args.args_count !=3D 3) + goto out; + + if (args.args[2] & PWM_POLARITY_INVERTED) + polarity =3D PWM_POLARITY_INVERSED; +out: + of_node_put(fan_np); + return polarity; +} + +static int amc6821_init_client(struct i2c_client *client, struct amc6821_d= ata *data) { struct regmap *regmap =3D data->regmap; + u32 regval; int err; =20 if (init) { @@ -864,11 +901,14 @@ static int amc6821_init_client(struct amc6821_data *d= ata) if (err) return err; =20 + regval =3D AMC6821_CONF1_START; + if (amc6821_pwm_polarity(client) =3D=3D PWM_POLARITY_INVERSED) + regval |=3D AMC6821_CONF1_PWMINV; + err =3D 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 +956,7 @@ static int amc6821_probe(struct i2c_client *client) "Failed to initialize regmap\n"); data->regmap =3D regmap; =20 - err =3D amc6821_init_client(data); + err =3D amc6821_init_client(client, data); if (err) return err; =20 --=20 2.39.5