From: George Stark <gnstark@sberdevices.ru>
To: <thierry.reding@gmail.com>, <u.kleine-koenig@pengutronix.de>,
<neil.armstrong@linaro.org>, <khilman@baylibre.com>,
<jbrunet@baylibre.com>, <martin.blumenstingl@googlemail.com>,
<hkallweit1@gmail.com>
Cc: <linux-iio@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
<linux-amlogic@lists.infradead.org>, <kernel@sberdevices.ru>,
George Stark <GNStark@sberdevices.ru>,
Dmitry Rokosov <ddrokosov@sberdevices.ru>
Subject: [PATCH] pwm: meson: compute cnt register value in proper way
Date: Fri, 2 Jun 2023 13:32:11 +0300 [thread overview]
Message-ID: <20230602103211.2199283-1-gnstark@sberdevices.ru> (raw)
According to the datasheet, the PWM high and low clock count values
should be set to at least one. Therefore, setting the clock count
register to 0 actually means 1 clock count.
Signed-off-by: George Stark <GNStark@sberdevices.ru>
Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru>
---
This patch is based on currently unmerged patch by Heiner Kallweit
https://lore.kernel.org/linux-amlogic/23fe625e-dc23-4db8-3dce-83167cd3b206@gmail.com
---
diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index 834acd7..57e7d9c 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -206,6 +206,11 @@
channel->pre_div = pre_div;
channel->hi = duty_cnt;
channel->lo = cnt - duty_cnt;
+
+ if (channel->hi)
+ channel->hi--;
+ if (channel->lo)
+ channel->lo--;
}
return 0;
@@ -340,7 +345,8 @@
channel->lo = FIELD_GET(PWM_LOW_MASK, value);
channel->hi = FIELD_GET(PWM_HIGH_MASK, value);
- state->period = meson_pwm_cnt_to_ns(chip, pwm, channel->lo + channel->hi);
+ state->period = meson_pwm_cnt_to_ns(chip, pwm,
+ channel->lo + 1 + channel->hi + 1);
state->duty_cycle = meson_pwm_cnt_to_ns(chip, pwm, channel->hi);
return 0;
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: George Stark <gnstark@sberdevices.ru>
To: <thierry.reding@gmail.com>, <u.kleine-koenig@pengutronix.de>,
<neil.armstrong@linaro.org>, <khilman@baylibre.com>,
<jbrunet@baylibre.com>, <martin.blumenstingl@googlemail.com>,
<hkallweit1@gmail.com>
Cc: <linux-iio@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
<linux-amlogic@lists.infradead.org>, <kernel@sberdevices.ru>,
George Stark <GNStark@sberdevices.ru>,
Dmitry Rokosov <ddrokosov@sberdevices.ru>
Subject: [PATCH] pwm: meson: compute cnt register value in proper way
Date: Fri, 2 Jun 2023 13:32:11 +0300 [thread overview]
Message-ID: <20230602103211.2199283-1-gnstark@sberdevices.ru> (raw)
According to the datasheet, the PWM high and low clock count values
should be set to at least one. Therefore, setting the clock count
register to 0 actually means 1 clock count.
Signed-off-by: George Stark <GNStark@sberdevices.ru>
Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru>
---
This patch is based on currently unmerged patch by Heiner Kallweit
https://lore.kernel.org/linux-amlogic/23fe625e-dc23-4db8-3dce-83167cd3b206@gmail.com
---
diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index 834acd7..57e7d9c 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -206,6 +206,11 @@
channel->pre_div = pre_div;
channel->hi = duty_cnt;
channel->lo = cnt - duty_cnt;
+
+ if (channel->hi)
+ channel->hi--;
+ if (channel->lo)
+ channel->lo--;
}
return 0;
@@ -340,7 +345,8 @@
channel->lo = FIELD_GET(PWM_LOW_MASK, value);
channel->hi = FIELD_GET(PWM_HIGH_MASK, value);
- state->period = meson_pwm_cnt_to_ns(chip, pwm, channel->lo + channel->hi);
+ state->period = meson_pwm_cnt_to_ns(chip, pwm,
+ channel->lo + 1 + channel->hi + 1);
state->duty_cycle = meson_pwm_cnt_to_ns(chip, pwm, channel->hi);
return 0;
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
WARNING: multiple messages have this Message-ID (diff)
From: George Stark <gnstark@sberdevices.ru>
To: <thierry.reding@gmail.com>, <u.kleine-koenig@pengutronix.de>,
<neil.armstrong@linaro.org>, <khilman@baylibre.com>,
<jbrunet@baylibre.com>, <martin.blumenstingl@googlemail.com>,
<hkallweit1@gmail.com>
Cc: <linux-iio@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
<linux-amlogic@lists.infradead.org>, <kernel@sberdevices.ru>,
George Stark <GNStark@sberdevices.ru>,
Dmitry Rokosov <ddrokosov@sberdevices.ru>
Subject: [PATCH] pwm: meson: compute cnt register value in proper way
Date: Fri, 2 Jun 2023 13:32:11 +0300 [thread overview]
Message-ID: <20230602103211.2199283-1-gnstark@sberdevices.ru> (raw)
According to the datasheet, the PWM high and low clock count values
should be set to at least one. Therefore, setting the clock count
register to 0 actually means 1 clock count.
Signed-off-by: George Stark <GNStark@sberdevices.ru>
Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru>
---
This patch is based on currently unmerged patch by Heiner Kallweit
https://lore.kernel.org/linux-amlogic/23fe625e-dc23-4db8-3dce-83167cd3b206@gmail.com
---
diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index 834acd7..57e7d9c 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -206,6 +206,11 @@
channel->pre_div = pre_div;
channel->hi = duty_cnt;
channel->lo = cnt - duty_cnt;
+
+ if (channel->hi)
+ channel->hi--;
+ if (channel->lo)
+ channel->lo--;
}
return 0;
@@ -340,7 +345,8 @@
channel->lo = FIELD_GET(PWM_LOW_MASK, value);
channel->hi = FIELD_GET(PWM_HIGH_MASK, value);
- state->period = meson_pwm_cnt_to_ns(chip, pwm, channel->lo + channel->hi);
+ state->period = meson_pwm_cnt_to_ns(chip, pwm,
+ channel->lo + 1 + channel->hi + 1);
state->duty_cycle = meson_pwm_cnt_to_ns(chip, pwm, channel->hi);
return 0;
next reply other threads:[~2023-06-02 10:33 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-02 10:32 George Stark [this message]
2023-06-02 10:32 ` [PATCH] pwm: meson: compute cnt register value in proper way George Stark
2023-06-02 10:32 ` George Stark
2023-06-02 20:52 ` Heiner Kallweit
2023-06-02 20:52 ` Heiner Kallweit
2023-06-02 20:52 ` Heiner Kallweit
2023-06-05 7:11 ` George Stark
2023-06-05 7:11 ` George Stark
2023-06-05 7:11 ` George Stark
2023-06-05 21:01 ` Heiner Kallweit
2023-06-05 21:01 ` Heiner Kallweit
2023-06-05 21:01 ` Heiner Kallweit
2023-06-06 8:14 ` Uwe Kleine-König
2023-06-06 8:14 ` Uwe Kleine-König
2023-06-06 8:14 ` Uwe Kleine-König
2023-06-06 7:38 ` Uwe Kleine-König
2023-06-06 7:38 ` Uwe Kleine-König
2023-06-06 7:38 ` Uwe Kleine-König
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=20230602103211.2199283-1-gnstark@sberdevices.ru \
--to=gnstark@sberdevices.ru \
--cc=ddrokosov@sberdevices.ru \
--cc=hkallweit1@gmail.com \
--cc=jbrunet@baylibre.com \
--cc=kernel@sberdevices.ru \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.org \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.