2014-04-14 22:00:15

by Alexandre Belloni

[permalink] [raw]
Subject: [PATCHv2 00/11] improve PWM lookup support without device tree

Hi,

A patch set as suggested by Thierry to make lookup with the lookup table
instead of device tree behave more like when using device tree.

The first patch adds a period and a polarity member to the lookup table and use
those to set period and polarity.

Patch 2, 4 and 5 are making use of those new members from the board files.
Patch 3 removes useless code since setting the polarity is now handled by the
PWM core.

I couldn't decide on a good name for the extended PWM_LOOKUP macro and I believe
we won't have to add members to that structure soon so:
Patch 6 modifies the PWM_LOOKUP macro to also initialize period and polarity
and
Patch 7-9 are making use of the new PWM_LOOKUP macro in the board files

Patch 10 and 11 are making the leds-pwm and pwm_bl drivers get the period from
the PWM before using pwm_period_ns if it is not already set.

Patch 10 will obviously conflict with the series of Russell reworking the
leds-pwm probing. I can rebase if necessary

The final goal would be to get rid of .pwm_period_ns in leds-pwm and pwm_bl
after moving all the remaining users (still around 25) to pwm_lookup.

Changes in v2:
- correctly unlock the pwm_lookup_lock mutex before returning.
- don't change PWM_LOOKUP atomically
- remove tpu_pwm_platform_data and the associated header file
- make the leds-pwm and pwm_bl drivers get the period from the PWM

Alexandre Belloni (11):
pwm: add period and polarity to struct pwm_lookup
ARM: shmobile: Armadillo 800 EVA: initialize all struct pwm_lookup
members
pwm: renesas-tpu: remove useless struct tpu_pwm_platform_data
ARM: OMAP3: Beagle: initialize all the struct pwm_lookup members
ARM: pxa: hx4700: initialize all the struct pwm_lookup members
pwm: modify PWM_LOOKUP to initialize all struct pwm_lookup members
ARM: OMAP3: Beagle: use PWM_LOOKUP to initialize struct pwm_lookup
ARM: shmobile: Armadillo 800 EVA: use PWM_LOOKUP to initialize struct
pwm_lookup
ARM: pxa: hx4700: use PWM_LOOKUP to initialize struct pwm_lookup
leds: leds-pwm: retrieve configured pwm period
backlight: pwm_bl: retrieve configured pwm period

Documentation/pwm.txt | 3 ++-
arch/arm/mach-omap2/board-omap3beagle.c | 3 ++-
arch/arm/mach-pxa/hx4700.c | 3 ++-
arch/arm/mach-shmobile/board-armadillo800eva.c | 14 +++-----------
drivers/leds/leds-pwm.c | 5 ++++-
drivers/pwm/core.c | 8 +++++++-
drivers/pwm/pwm-renesas-tpu.c | 19 +++----------------
drivers/video/backlight/pwm_bl.c | 8 +++++---
include/linux/platform_data/pwm-renesas-tpu.h | 16 ----------------
include/linux/pwm.h | 6 +++++-
10 files changed, 33 insertions(+), 52 deletions(-)
delete mode 100644 include/linux/platform_data/pwm-renesas-tpu.h

--
1.8.3.2


2014-04-14 22:00:17

by Alexandre Belloni

[permalink] [raw]
Subject: [PATCHv2 01/11] pwm: add period and polarity to struct pwm_lookup

Adds a period and a polarity member to struct pwm_lookup so that when performing
a lookup using the lookup table instead of device tree, we are able to set the
period and the polarity accordingly like what is done in
of_pwm_xlate_with_flags.

The period and polarity can be set unconditionally as the default is 0 anyway.

Signed-off-by: Alexandre Belloni <[email protected]>
---
drivers/pwm/core.c | 8 +++++++-
include/linux/pwm.h | 2 ++
2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index a80471399c20..4b66bf09ee55 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -661,10 +661,16 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
}
}

+ mutex_unlock(&pwm_lookup_lock);
+
if (chip)
pwm = pwm_request_from_chip(chip, index, con_id ?: dev_id);
+ if (IS_ERR(pwm))
+ return pwm;
+
+ pwm_set_period(pwm, p->period);
+ pwm_set_polarity(pwm, p->polarity);

- mutex_unlock(&pwm_lookup_lock);

return pwm;
}
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index 4717f54051cb..2f45e2fe5b93 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -274,6 +274,8 @@ struct pwm_lookup {
unsigned int index;
const char *dev_id;
const char *con_id;
+ unsigned int period;
+ enum pwm_polarity polarity;
};

#define PWM_LOOKUP(_provider, _index, _dev_id, _con_id) \
--
1.8.3.2

2014-04-14 22:00:45

by Alexandre Belloni

[permalink] [raw]
Subject: [PATCHv2 11/11] backlight: pwm_bl: retrieve configured pwm period

The PWM core is now able to initialize the PWM period from platform_data. Use it
and if it is not configured, use the supplied pwm_period_ns.

Signed-off-by: Alexandre Belloni <[email protected]>
---
drivers/video/backlight/pwm_bl.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index b75201ff46f6..1bb8a69062c5 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -304,12 +304,14 @@ static int pwm_backlight_probe(struct platform_device *pdev)
/*
* The DT case will set the pwm_period_ns field to 0 and store the
* period, parsed from the DT, in the PWM device. For the non-DT case,
- * set the period from platform data.
+ * set the period from platform data if it is not already set.
*/
- if (data->pwm_period_ns > 0)
+ pb->period = pwm_get_period(pb->pwm);
+ if (!pb->period && (data->pwm_period_ns > 0)) {
+ pb->period = data->pwm_period_ns;
pwm_set_period(pb->pwm, data->pwm_period_ns);
+ }

- pb->period = pwm_get_period(pb->pwm);
pb->lth_brightness = data->lth_brightness * (pb->period / pb->scale);

memset(&props, 0, sizeof(struct backlight_properties));
--
1.8.3.2

2014-04-14 22:00:43

by Alexandre Belloni

[permalink] [raw]
Subject: [PATCHv2 07/11] ARM: OMAP3: Beagle: use PWM_LOOKUP to initialize struct pwm_lookup

Signed-off-by: Alexandre Belloni <[email protected]>
---
arch/arm/mach-omap2/board-omap3beagle.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index f27e1ec90b5e..54c135a5b4f7 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -61,14 +61,8 @@

static struct pwm_lookup pwm_lookup[] = {
/* LEDB -> PMU_STAT */
- {
- .provider = "twl-pwmled",
- .index = 1,
- .dev_id = "leds_pwm",
- .con_id = "beagleboard::pmu_stat",
- .period = 7812500,
- .polarity = PWM_POLARITY_NORMAL,
- },
+ PWM_LOOKUP("twl-pwmled", 1, "leds_pwm", "beagleboard::pmu_stat",
+ 7812500, PWM_POLARITY_NORMAL),
};

static struct led_pwm pwm_leds[] = {
--
1.8.3.2

2014-04-14 22:00:41

by Alexandre Belloni

[permalink] [raw]
Subject: [PATCHv2 09/11] ARM: pxa: hx4700: use PWM_LOOKUP to initialize struct pwm_lookup

Signed-off-by: Alexandre Belloni <[email protected]>
---
arch/arm/mach-pxa/hx4700.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c
index 0788a1f171fe..c66ad4edc5e3 100644
--- a/arch/arm/mach-pxa/hx4700.c
+++ b/arch/arm/mach-pxa/hx4700.c
@@ -574,14 +574,8 @@ static struct platform_device backlight = {
};

static struct pwm_lookup hx4700_pwm_lookup[] = {
- {
- .provider = "pxa27x-pwm.1",
- .index = 0,
- .dev_id = "pwm-backlight",
- .con_id = NULL,
- .period = 30923,
- .polarity = PWM_POLARITY_NORMAL,
- },
+ PWM_LOOKUP("pxa27x-pwm.1", 0, "pwm-backlight", NULL,
+ 30923, PWM_POLARITY_NORMAL),
};

/*
--
1.8.3.2

2014-04-14 22:00:40

by Alexandre Belloni

[permalink] [raw]
Subject: [PATCHv2 08/11] ARM: shmobile: Armadillo 800 EVA: use PWM_LOOKUP to initialize struct pwm_lookup

Signed-off-by: Alexandre Belloni <[email protected]>
---
arch/arm/mach-shmobile/board-armadillo800eva.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c
index 1bf61dad9a35..ca82b1e2ebab 100644
--- a/arch/arm/mach-shmobile/board-armadillo800eva.c
+++ b/arch/arm/mach-shmobile/board-armadillo800eva.c
@@ -407,14 +407,8 @@ static struct platform_device pwm_device = {
};

static struct pwm_lookup pwm_lookup[] = {
- {
- .provider = "renesas-tpu-pwm",
- .index = 2,
- .dev_id = "pwm-backlight.0",
- .con_id = NULL,
- .period = 33333,
- .polarity = PWM_POLARITY_INVERSED,
- },
+ PWM_LOOKUP("renesas-tpu-pwm", 2, "pwm-backlight.0", NULL,
+ 33333, PWM_POLARITY_INVERSED),
};

/* LCDC and backlight */
--
1.8.3.2

2014-04-14 22:00:37

by Alexandre Belloni

[permalink] [raw]
Subject: [PATCHv2 05/11] ARM: pxa: hx4700: initialize all the struct pwm_lookup members

This will allow to get rid of the .pwm_period_ns member of struct
platform_pwm_backlight_data as the period will be set by the PWM core.

Signed-off-by: Alexandre Belloni <[email protected]>
---
arch/arm/mach-pxa/hx4700.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c
index a7c30eb0c8db..0788a1f171fe 100644
--- a/arch/arm/mach-pxa/hx4700.c
+++ b/arch/arm/mach-pxa/hx4700.c
@@ -574,7 +574,14 @@ static struct platform_device backlight = {
};

static struct pwm_lookup hx4700_pwm_lookup[] = {
- PWM_LOOKUP("pxa27x-pwm.1", 0, "pwm-backlight", NULL),
+ {
+ .provider = "pxa27x-pwm.1",
+ .index = 0,
+ .dev_id = "pwm-backlight",
+ .con_id = NULL,
+ .period = 30923,
+ .polarity = PWM_POLARITY_NORMAL,
+ },
};

/*
--
1.8.3.2

2014-04-14 22:03:32

by Alexandre Belloni

[permalink] [raw]
Subject: [PATCHv2 10/11] leds: leds-pwm: retrieve configured pwm period

The PWM core is now able to initialize the PWM period. Use it and if it is not
configured, use the supplied pwm_period_ns.

Signed-off-by: Alexandre Belloni <[email protected]>
---
drivers/leds/leds-pwm.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index 7d0aaed1e23a..aa770ec1e892 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -181,7 +181,6 @@ static int led_pwm_probe(struct platform_device *pdev)
led_dat->cdev.name = cur_led->name;
led_dat->cdev.default_trigger = cur_led->default_trigger;
led_dat->active_low = cur_led->active_low;
- led_dat->period = cur_led->pwm_period_ns;
led_dat->cdev.brightness_set = led_pwm_set;
led_dat->cdev.brightness = LED_OFF;
led_dat->cdev.max_brightness = cur_led->max_brightness;
@@ -191,6 +190,10 @@ static int led_pwm_probe(struct platform_device *pdev)
if (led_dat->can_sleep)
INIT_WORK(&led_dat->work, led_pwm_work);

+ led_dat->period = pwm_get_period(led_dat->pwm);
+ if (!led_dat->period && (cur_led->pwm_period_ns > 0))
+ led_dat->period = cur_led->pwm_period_ns;
+
ret = led_classdev_register(&pdev->dev, &led_dat->cdev);
if (ret < 0)
goto err;
--
1.8.3.2

2014-04-14 22:00:29

by Alexandre Belloni

[permalink] [raw]
Subject: [PATCHv2 06/11] pwm: modify PWM_LOOKUP to initialize all struct pwm_lookup members

Now that PWM_LOOKUP is not used anymore, modify it to initialize all the
members of struct pwm_lookup.

Signed-off-by: Alexandre Belloni <[email protected]>
---
Documentation/pwm.txt | 3 ++-
include/linux/pwm.h | 4 +++-
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/Documentation/pwm.txt b/Documentation/pwm.txt
index 93cb97974986..f38f99cda64f 100644
--- a/Documentation/pwm.txt
+++ b/Documentation/pwm.txt
@@ -19,7 +19,8 @@ should instead register a static mapping that can be used to match PWM
consumers to providers, as given in the following example:

static struct pwm_lookup board_pwm_lookup[] = {
- PWM_LOOKUP("tegra-pwm", 0, "pwm-backlight", NULL),
+ PWM_LOOKUP("tegra-pwm", 0, "pwm-backlight", NULL,
+ 50000, PWM_POLARITY_NORMAL),
};

static void __init board_init(void)
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index 2f45e2fe5b93..e90628cac8fa 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -278,12 +278,14 @@ struct pwm_lookup {
enum pwm_polarity polarity;
};

-#define PWM_LOOKUP(_provider, _index, _dev_id, _con_id) \
+#define PWM_LOOKUP(_provider, _index, _dev_id, _con_id, _period, _polarity) \
{ \
.provider = _provider, \
.index = _index, \
.dev_id = _dev_id, \
.con_id = _con_id, \
+ .period = _period, \
+ .polarity = _polarity \
}

#if IS_ENABLED(CONFIG_PWM)
--
1.8.3.2

2014-04-14 22:05:04

by Alexandre Belloni

[permalink] [raw]
Subject: [PATCHv2 03/11] pwm: renesas-tpu: remove useless struct tpu_pwm_platform_data

The struct tpu_pwm_platform_data is not used anymore and the polarity
initialization will be taken care of by the PWM core.

Signed-off-by: Alexandre Belloni <[email protected]>
---
drivers/pwm/pwm-renesas-tpu.c | 19 +++----------------
include/linux/platform_data/pwm-renesas-tpu.h | 16 ----------------
2 files changed, 3 insertions(+), 32 deletions(-)
delete mode 100644 include/linux/platform_data/pwm-renesas-tpu.h

diff --git a/drivers/pwm/pwm-renesas-tpu.c b/drivers/pwm/pwm-renesas-tpu.c
index aff6ba9b49e7..9dbcf82b3e6c 100644
--- a/drivers/pwm/pwm-renesas-tpu.c
+++ b/drivers/pwm/pwm-renesas-tpu.c
@@ -21,13 +21,14 @@
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
-#include <linux/platform_data/pwm-renesas-tpu.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/pwm.h>
#include <linux/slab.h>
#include <linux/spinlock.h>

+#define TPU_CHANNEL_MAX 4
+
#define TPU_TSTR 0x00 /* Timer start register (shared) */

#define TPU_TCRn 0x00 /* Timer control register */
@@ -87,7 +88,6 @@ struct tpu_pwm_device {

struct tpu_device {
struct platform_device *pdev;
- enum pwm_polarity polarities[TPU_CHANNEL_MAX];
struct pwm_chip chip;
spinlock_t lock;

@@ -229,7 +229,7 @@ static int tpu_pwm_request(struct pwm_chip *chip, struct pwm_device *_pwm)

pwm->tpu = tpu;
pwm->channel = _pwm->hwpwm;
- pwm->polarity = tpu->polarities[pwm->channel];
+ pwm->polarity = PWM_POLARITY_NORMAL;
pwm->prescaler = 0;
pwm->period = 0;
pwm->duty = 0;
@@ -388,16 +388,6 @@ static const struct pwm_ops tpu_pwm_ops = {
* Probe and remove
*/

-static void tpu_parse_pdata(struct tpu_device *tpu)
-{
- struct tpu_pwm_platform_data *pdata = tpu->pdev->dev.platform_data;
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(tpu->polarities); ++i)
- tpu->polarities[i] = pdata ? pdata->channels[i].polarity
- : PWM_POLARITY_NORMAL;
-}
-
static int tpu_probe(struct platform_device *pdev)
{
struct tpu_device *tpu;
@@ -413,9 +403,6 @@ static int tpu_probe(struct platform_device *pdev)
spin_lock_init(&tpu->lock);
tpu->pdev = pdev;

- /* Initialize device configuration from platform data. */
- tpu_parse_pdata(tpu);
-
/* Map memory, get clock and pin control. */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
tpu->base = devm_ioremap_resource(&pdev->dev, res);
diff --git a/include/linux/platform_data/pwm-renesas-tpu.h b/include/linux/platform_data/pwm-renesas-tpu.h
deleted file mode 100644
index a7220b10ddab..000000000000
--- a/include/linux/platform_data/pwm-renesas-tpu.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __PWM_RENESAS_TPU_H__
-#define __PWM_RENESAS_TPU_H__
-
-#include <linux/pwm.h>
-
-#define TPU_CHANNEL_MAX 4
-
-struct tpu_pwm_channel_data {
- enum pwm_polarity polarity;
-};
-
-struct tpu_pwm_platform_data {
- struct tpu_pwm_channel_data channels[TPU_CHANNEL_MAX];
-};
-
-#endif /* __PWM_RENESAS_TPU_H__ */
--
1.8.3.2

2014-04-14 22:05:01

by Alexandre Belloni

[permalink] [raw]
Subject: [PATCHv2 04/11] ARM: OMAP3: Beagle: initialize all the struct pwm_lookup members

This will allow to get rid of the .pwm_period_ns member of struct led_pwm as the
period will be set by the PWM core.

Signed-off-by: Alexandre Belloni <[email protected]>
---
arch/arm/mach-omap2/board-omap3beagle.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index d6ed819ff15c..f27e1ec90b5e 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -61,7 +61,14 @@

static struct pwm_lookup pwm_lookup[] = {
/* LEDB -> PMU_STAT */
- PWM_LOOKUP("twl-pwmled", 1, "leds_pwm", "beagleboard::pmu_stat"),
+ {
+ .provider = "twl-pwmled",
+ .index = 1,
+ .dev_id = "leds_pwm",
+ .con_id = "beagleboard::pmu_stat",
+ .period = 7812500,
+ .polarity = PWM_POLARITY_NORMAL,
+ },
};

static struct led_pwm pwm_leds[] = {
--
1.8.3.2

2014-04-14 22:06:15

by Alexandre Belloni

[permalink] [raw]
Subject: [PATCHv2 02/11] ARM: shmobile: Armadillo 800 EVA: initialize all struct pwm_lookup members

Initializing all the struct pwm_lookup members allows to get rid of the struct
tpu_pwm_platform_data as the polarity initialization will be taken care of by
the PWM core.

Signed-off-by: Alexandre Belloni <[email protected]>
---
arch/arm/mach-shmobile/board-armadillo800eva.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c
index 2858f380beae..1bf61dad9a35 100644
--- a/arch/arm/mach-shmobile/board-armadillo800eva.c
+++ b/arch/arm/mach-shmobile/board-armadillo800eva.c
@@ -31,7 +31,7 @@
#include <linux/gpio_keys.h>
#include <linux/regulator/driver.h>
#include <linux/pinctrl/machine.h>
-#include <linux/platform_data/pwm-renesas-tpu.h>
+#include <linux/pwm.h>
#include <linux/pwm_backlight.h>
#include <linux/regulator/fixed.h>
#include <linux/regulator/gpio-regulator.h>
@@ -399,24 +399,22 @@ static struct resource pwm_resources[] = {
},
};

-static struct tpu_pwm_platform_data pwm_device_data = {
- .channels[2] = {
- .polarity = PWM_POLARITY_INVERSED,
- }
-};
-
static struct platform_device pwm_device = {
.name = "renesas-tpu-pwm",
.id = -1,
- .dev = {
- .platform_data = &pwm_device_data,
- },
.num_resources = ARRAY_SIZE(pwm_resources),
.resource = pwm_resources,
};

static struct pwm_lookup pwm_lookup[] = {
- PWM_LOOKUP("renesas-tpu-pwm", 2, "pwm-backlight.0", NULL),
+ {
+ .provider = "renesas-tpu-pwm",
+ .index = 2,
+ .dev_id = "pwm-backlight.0",
+ .con_id = NULL,
+ .period = 33333,
+ .polarity = PWM_POLARITY_INVERSED,
+ },
};

/* LCDC and backlight */
--
1.8.3.2

2014-04-14 22:58:29

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCHv2 02/11] ARM: shmobile: Armadillo 800 EVA: initialize all struct pwm_lookup members

On Mon, Apr 14, 2014 at 11:59:44PM +0200, Alexandre Belloni wrote:
> Initializing all the struct pwm_lookup members allows to get rid of the struct
> tpu_pwm_platform_data as the polarity initialization will be taken care of by
> the PWM core.
>
> Signed-off-by: Alexandre Belloni <[email protected]>


This looks good to me.
Please let me know when the driver code has been merged and
I'll take this patch. Likewise for the other shmobile patch in this series.

> ---
> arch/arm/mach-shmobile/board-armadillo800eva.c | 20 +++++++++-----------
> 1 file changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c
> index 2858f380beae..1bf61dad9a35 100644
> --- a/arch/arm/mach-shmobile/board-armadillo800eva.c
> +++ b/arch/arm/mach-shmobile/board-armadillo800eva.c
> @@ -31,7 +31,7 @@
> #include <linux/gpio_keys.h>
> #include <linux/regulator/driver.h>
> #include <linux/pinctrl/machine.h>
> -#include <linux/platform_data/pwm-renesas-tpu.h>
> +#include <linux/pwm.h>
> #include <linux/pwm_backlight.h>
> #include <linux/regulator/fixed.h>
> #include <linux/regulator/gpio-regulator.h>
> @@ -399,24 +399,22 @@ static struct resource pwm_resources[] = {
> },
> };
>
> -static struct tpu_pwm_platform_data pwm_device_data = {
> - .channels[2] = {
> - .polarity = PWM_POLARITY_INVERSED,
> - }
> -};
> -
> static struct platform_device pwm_device = {
> .name = "renesas-tpu-pwm",
> .id = -1,
> - .dev = {
> - .platform_data = &pwm_device_data,
> - },
> .num_resources = ARRAY_SIZE(pwm_resources),
> .resource = pwm_resources,
> };
>
> static struct pwm_lookup pwm_lookup[] = {
> - PWM_LOOKUP("renesas-tpu-pwm", 2, "pwm-backlight.0", NULL),
> + {
> + .provider = "renesas-tpu-pwm",
> + .index = 2,
> + .dev_id = "pwm-backlight.0",
> + .con_id = NULL,
> + .period = 33333,
> + .polarity = PWM_POLARITY_INVERSED,
> + },
> };
>
> /* LCDC and backlight */
> --
> 1.8.3.2
>

2014-04-15 07:02:41

by Peter Ujfalusi

[permalink] [raw]
Subject: Re: [PATCHv2 07/11] ARM: OMAP3: Beagle: use PWM_LOOKUP to initialize struct pwm_lookup

On 04/15/2014 12:59 AM, Alexandre Belloni wrote:
> Signed-off-by: Alexandre Belloni <[email protected]>
> ---
> arch/arm/mach-omap2/board-omap3beagle.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
> index f27e1ec90b5e..54c135a5b4f7 100644
> --- a/arch/arm/mach-omap2/board-omap3beagle.c
> +++ b/arch/arm/mach-omap2/board-omap3beagle.c
> @@ -61,14 +61,8 @@
>
> static struct pwm_lookup pwm_lookup[] = {
> /* LEDB -> PMU_STAT */
> - {
> - .provider = "twl-pwmled",
> - .index = 1,
> - .dev_id = "leds_pwm",
> - .con_id = "beagleboard::pmu_stat",
> - .period = 7812500,
> - .polarity = PWM_POLARITY_NORMAL,
> - },
> + PWM_LOOKUP("twl-pwmled", 1, "leds_pwm", "beagleboard::pmu_stat",
> + 7812500, PWM_POLARITY_NORMAL),

Why do you need to do this in two steps?
In patch 4 you removed the existing PWM_LOOKUP() and now you are adding it back.
Would not be simpler if you just add the two new parameters in patch 4 (the
812500, PWM_POLARITY_NORMAL)?

> };
>
> static struct led_pwm pwm_leds[] = {
>


--
P?ter

2014-04-15 07:14:36

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCHv2 07/11] ARM: OMAP3: Beagle: use PWM_LOOKUP to initialize struct pwm_lookup

On Tue, Apr 15, 2014 at 10:01:44AM +0300, Peter Ujfalusi wrote:
> On 04/15/2014 12:59 AM, Alexandre Belloni wrote:
> > Signed-off-by: Alexandre Belloni <[email protected]>
> > ---
> > arch/arm/mach-omap2/board-omap3beagle.c | 10 ++--------
> > 1 file changed, 2 insertions(+), 8 deletions(-)
> >
> > diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
> > index f27e1ec90b5e..54c135a5b4f7 100644
> > --- a/arch/arm/mach-omap2/board-omap3beagle.c
> > +++ b/arch/arm/mach-omap2/board-omap3beagle.c
> > @@ -61,14 +61,8 @@
> >
> > static struct pwm_lookup pwm_lookup[] = {
> > /* LEDB -> PMU_STAT */
> > - {
> > - .provider = "twl-pwmled",
> > - .index = 1,
> > - .dev_id = "leds_pwm",
> > - .con_id = "beagleboard::pmu_stat",
> > - .period = 7812500,
> > - .polarity = PWM_POLARITY_NORMAL,
> > - },
> > + PWM_LOOKUP("twl-pwmled", 1, "leds_pwm", "beagleboard::pmu_stat",
> > + 7812500, PWM_POLARITY_NORMAL),
>
> Why do you need to do this in two steps?
> In patch 4 you removed the existing PWM_LOOKUP() and now you are adding it back.
> Would not be simpler if you just add the two new parameters in patch 4 (the
> 812500, PWM_POLARITY_NORMAL)?

Such an approach would apply an atomic change to both the infrastructure
and the users.

2014-04-15 07:42:44

by Peter Ujfalusi

[permalink] [raw]
Subject: Re: [PATCHv2 07/11] ARM: OMAP3: Beagle: use PWM_LOOKUP to initialize struct pwm_lookup

On 04/15/2014 10:14 AM, Simon Horman wrote:
> On Tue, Apr 15, 2014 at 10:01:44AM +0300, Peter Ujfalusi wrote:
>> On 04/15/2014 12:59 AM, Alexandre Belloni wrote:
>>> Signed-off-by: Alexandre Belloni <[email protected]>
>>> ---
>>> arch/arm/mach-omap2/board-omap3beagle.c | 10 ++--------
>>> 1 file changed, 2 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
>>> index f27e1ec90b5e..54c135a5b4f7 100644
>>> --- a/arch/arm/mach-omap2/board-omap3beagle.c
>>> +++ b/arch/arm/mach-omap2/board-omap3beagle.c
>>> @@ -61,14 +61,8 @@
>>>
>>> static struct pwm_lookup pwm_lookup[] = {
>>> /* LEDB -> PMU_STAT */
>>> - {
>>> - .provider = "twl-pwmled",
>>> - .index = 1,
>>> - .dev_id = "leds_pwm",
>>> - .con_id = "beagleboard::pmu_stat",
>>> - .period = 7812500,
>>> - .polarity = PWM_POLARITY_NORMAL,
>>> - },
>>> + PWM_LOOKUP("twl-pwmled", 1, "leds_pwm", "beagleboard::pmu_stat",
>>> + 7812500, PWM_POLARITY_NORMAL),
>>
>> Why do you need to do this in two steps?
>> In patch 4 you removed the existing PWM_LOOKUP() and now you are adding it back.
>> Would not be simpler if you just add the two new parameters in patch 4 (the
>> 812500, PWM_POLARITY_NORMAL)?
>
> Such an approach would apply an atomic change to both the infrastructure
> and the users.

Yes, I overlooked patch 6...
Just ignore my comment.

--
P?ter