mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: florin.leotescu@oss.nxp.com
To: Jean Delvare <jdelvare@suse.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Florin Leotescu <florin.leotescu@nxp.com>,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: viorel.suman@nxp.com, carlos.song@nxp.com, daniel.baluta@nxp.com,
	linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev,
	festevam@gmail.com
Subject: [PATCH 3/4] hwmon: emc2305: Enable PWM polarity and output configuration
Date: Tue,  3 Jun 2025 14:31:24 +0300	[thread overview]
Message-ID: <20250603113125.3175103-4-florin.leotescu@oss.nxp.com> (raw)
In-Reply-To: <20250603113125.3175103-1-florin.leotescu@oss.nxp.com>

From: Florin Leotescu <florin.leotescu@nxp.com>

Enable configuration of PWM polarity and PWM output config
based Device Tree properties.

Signed-off-by: Florin Leotescu <florin.leotescu@nxp.com>
---
 drivers/hwmon/emc2305.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/hwmon/emc2305.c b/drivers/hwmon/emc2305.c
index 0228511f4753..db65c3177f29 100644
--- a/drivers/hwmon/emc2305.c
+++ b/drivers/hwmon/emc2305.c
@@ -28,6 +28,10 @@
 #define EMC2305_TACH_RANGE_MIN		480
 #define EMC2305_DEFAULT_OUTPUT		0x0
 #define EMC2305_DEFAULT_POLARITY	0x0
+#define EMC2305_REG_POLARITY		0x2a
+#define EMC2305_REG_DRIVE_PWM_OUT	0x2b
+#define EMC2305_OPEN_DRAIN		0x0
+#define EMC2305_PUSH_PULL		0x1
 
 #define EMC2305_PWM_DUTY2STATE(duty, max_state, pwm_max) \
 	DIV_ROUND_CLOSEST((duty) * (max_state), (pwm_max))
@@ -686,6 +690,16 @@ static int emc2305_probe(struct i2c_client *client)
 		}
 	}
 
+	ret = i2c_smbus_write_byte_data(client, EMC2305_REG_DRIVE_PWM_OUT,
+					data->pwm_output_mask);
+	if (ret < 0)
+		dev_err(dev, "Failed to configure pwm output, using default\n");
+
+	ret = i2c_smbus_write_byte_data(client, EMC2305_REG_POLARITY,
+					data->pwm_polarity_mask);
+	if (ret < 0)
+		dev_err(dev, "Failed to configure pwm polarity, using default\n");
+
 	for (i = 0; i < data->pwm_num; i++) {
 		ret = i2c_smbus_write_byte_data(client, EMC2305_REG_FAN_MIN_DRIVE(i),
 						data->pwm_min[i]);
-- 
2.34.1


  parent reply	other threads:[~2025-06-03 11:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-03 11:31 [PATCH 0/4] Add OF support for Microchip emc2305 fan controller florin.leotescu
2025-06-03 11:31 ` [PATCH 1/4] hwmon: emc2305: Add support for PWM frequency, polarity and output florin.leotescu
2025-06-16 22:16   ` Guenter Roeck
2025-06-03 11:31 ` [PATCH 2/4] hwmon: emc2305: Configure PWM channels based on DT properties florin.leotescu
2025-06-16 22:16   ` Guenter Roeck
2025-06-03 11:31 ` florin.leotescu [this message]
2025-06-16 22:17   ` [PATCH 3/4] hwmon: emc2305: Enable PWM polarity and output configuration Guenter Roeck
2025-06-03 11:31 ` [PATCH 4/4] hwmon: emc2305: Set initial PWM minimum value during probe based on thermal state florin.leotescu
2025-06-16 22:17   ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250603113125.3175103-4-florin.leotescu@oss.nxp.com \
    --to=florin.leotescu@oss.nxp.com \
    --cc=carlos.song@nxp.com \
    --cc=daniel.baluta@nxp.com \
    --cc=festevam@gmail.com \
    --cc=florin.leotescu@nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=jdelvare@suse.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=viorel.suman@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®