linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: lis8215@gmail.com
To: linux-sunxi@googlegroups.com
Cc: thierry.reding@gmail.com, robh+dt@kernel.org,
	mark.rutland@arm.com, maxime.ripard@free-electrons.com,
	wens@csie.org, linux-pwm@vger.kernel.org,
	Siarhei Volkau <lis8215@gmail.com>
Subject: [PATCH v4 3/9] pwm: sunxi: Selectable prescaler table.
Date: Fri, 24 Feb 2017 08:41:10 +0300	[thread overview]
Message-ID: <1487914876-8594-4-git-send-email-lis8215@gmail.com> (raw)
In-Reply-To: <1487914876-8594-1-git-send-email-lis8215@gmail.com>

From: Siarhei Volkau <lis8215@gmail.com>

A31 SoC have a different set of prescalers than sun4i
compatible ASoCs, but its position and count in the control
register are the same.

This patch make the table of prescalers customizable.

Signed-off-by: Siarhei Volkau <lis8215@gmail.com>
---
 drivers/pwm/pwm-sun4i.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
index 7af6bd8..418a625 100644
--- a/drivers/pwm/pwm-sun4i.c
+++ b/drivers/pwm/pwm-sun4i.c
@@ -60,7 +60,7 @@ enum {
 	NUM_FIELDS,
 };
 
-static const u32 prescaler_table[] = {
+static const u32 sun4i_prescaler_table[] = {
 	120,
 	180,
 	240,
@@ -83,6 +83,7 @@ struct sun4i_pwm_data {
 	bool has_prescaler_bypass;
 	bool has_rdy;
 	unsigned int npwm;
+	const u32 *prescaler_table;
 };
 
 struct sun4i_pwm_chip {
@@ -104,6 +105,7 @@ static int sun4i_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 {
 	struct sun4i_pwm_chip *sun4i_pwm = to_sun4i_pwm_chip(chip);
 	struct regmap_field **chan_fields = sun4i_pwm->fields[pwm->hwpwm];
+	const u32 *prescaler_table = sun4i_pwm->data->prescaler_table;
 	u32 prd, dty, val, clk_gate;
 	u64 clk_rate, div = 0;
 	unsigned int prescaler = 0;
@@ -310,30 +312,35 @@ static const struct sun4i_pwm_data sun4i_pwm_data_a10 = {
 	.has_prescaler_bypass = false,
 	.has_rdy = false,
 	.npwm = 2,
+	.prescaler_table = sun4i_prescaler_table,
 };
 
 static const struct sun4i_pwm_data sun4i_pwm_data_a10s = {
 	.has_prescaler_bypass = true,
 	.has_rdy = true,
 	.npwm = 2,
+	.prescaler_table = sun4i_prescaler_table,
 };
 
 static const struct sun4i_pwm_data sun4i_pwm_data_a13 = {
 	.has_prescaler_bypass = true,
 	.has_rdy = true,
 	.npwm = 1,
+	.prescaler_table = sun4i_prescaler_table,
 };
 
 static const struct sun4i_pwm_data sun4i_pwm_data_a20 = {
 	.has_prescaler_bypass = true,
 	.has_rdy = true,
 	.npwm = 2,
+	.prescaler_table = sun4i_prescaler_table,
 };
 
 static const struct sun4i_pwm_data sun4i_pwm_data_h3 = {
 	.has_prescaler_bypass = true,
 	.has_rdy = true,
 	.npwm = 1,
+	.prescaler_table = sun4i_prescaler_table,
 };
 
 static const struct of_device_id sun4i_pwm_dt_ids[] = {
-- 
2.4.11

  parent reply	other threads:[~2017-02-24  5:41 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-24  5:41 [PATCH v4 0/9] Add the Allwinner A31/A31s PWM driver lis8215-Re5JQEeQqe8AvxtiuMwx3w
2017-02-24  5:41 ` [PATCH v4 1/9] pwm: sunxi: Use regmap API for register access lis8215
     [not found]   ` <1487914876-8594-2-git-send-email-lis8215-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-27  9:17     ` Maxime Ripard
2017-02-27 11:22       ` Siarhei Volkau
     [not found]         ` <CAKNVLfYLfiTKu1CWcR5JiYepgfy-AO4CZ6ZKLaijmj+rmpxWAg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-28 15:53           ` Maxime Ripard
2017-02-24  5:41 ` lis8215 [this message]
     [not found]   ` <1487914876-8594-4-git-send-email-lis8215-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-27  9:28     ` [PATCH v4 3/9] pwm: sunxi: Selectable prescaler table Maxime Ripard
     [not found] ` <1487914876-8594-1-git-send-email-lis8215-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-24  5:41   ` [PATCH v4 2/9] pwm: sunxi: Use regmap fields for bit operations lis8215-Re5JQEeQqe8AvxtiuMwx3w
     [not found]     ` <1487914876-8594-3-git-send-email-lis8215-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-27  9:28       ` Maxime Ripard
2017-02-27 11:41         ` Siarhei Volkau
     [not found]           ` <CAKNVLfYVfMDDeBB0cOb-_d5EytCWG8DDssnUH573_yOfJdJ8uA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-28 15:56             ` Maxime Ripard
2017-02-24  5:41   ` [PATCH v4 4/9] pwm: sunxi: Customizable control and period register position lis8215-Re5JQEeQqe8AvxtiuMwx3w
     [not found]     ` <1487914876-8594-5-git-send-email-lis8215-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-27  9:30       ` Maxime Ripard
2017-02-27 12:35         ` Siarhei Volkau
     [not found]           ` <CAKNVLfa6NgRBSVZgOb5yp31Eq8nZYRSKQzgUzoXL5_QFfYVjeQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-28 15:48             ` Maxime Ripard
2017-02-24  5:41   ` [PATCH v4 5/9] pwm: sunxi: Customizable regmap fields and enable bit mask lis8215-Re5JQEeQqe8AvxtiuMwx3w
2017-02-24  5:41   ` [PATCH v4 6/9] pwm: sunxi: Increase max number of pwm channels lis8215-Re5JQEeQqe8AvxtiuMwx3w
2017-02-24  5:41   ` [PATCH v4 7/9] pwm: sunxi: Add support the Allwinner A31 PWM lis8215-Re5JQEeQqe8AvxtiuMwx3w
2017-02-24  5:41   ` [PATCH v4 9/9] ARM: dts: sun6i: Add the PWM block to the A31/A31s lis8215-Re5JQEeQqe8AvxtiuMwx3w
2017-02-24  5:41 ` [PATCH v4 8/9] pwm: sunxi: Code cleanup lis8215
     [not found]   ` <1487914876-8594-9-git-send-email-lis8215-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-27  9:32     ` Maxime Ripard
2017-02-27 13:21       ` Siarhei Volkau
2017-02-28 15:49         ` Maxime Ripard

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=1487914876-8594-4-git-send-email-lis8215@gmail.com \
    --to=lis8215@gmail.com \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=mark.rutland@arm.com \
    --cc=maxime.ripard@free-electrons.com \
    --cc=robh+dt@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=wens@csie.org \
    /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;
as well as URLs for NNTP newsgroup(s).