2012-05-18 20:37:01

by Laxman Dewangan

[permalink] [raw]
Subject: [PATCH 0/3] mfd: tps65910: dt: cleanups in device node parsing

In this patch series organizing the processing of device node locally specific
to driver.
- The gpio specific processing is moved to gpio driver.
- Core will only process the non-subdevices information.
- Also keep the allocated pointer for device node in to global structure
so that sub devices can use this.

This patch series is generated on-top of Samuel's mfd subsystem tree.


Laxman Dewangan (3):
mfd: save device node parsed platform data for sub devices
mfd: remove the parsing of dt info for gpio
gpio: tps65910: dt: process gpio specific device node info

drivers/gpio/gpio-tps65910.c | 36 ++++++++++++++++++++++++++++++++++++
drivers/mfd/tps65910.c | 21 +++++----------------
include/linux/mfd/tps65910.h | 3 +++
3 files changed, 44 insertions(+), 16 deletions(-)


2012-05-18 20:37:14

by Laxman Dewangan

[permalink] [raw]
Subject: [PATCH 2/3] mfd: remove the parsing of dt info for gpio

Remove the parsing of device node information for sub devices
from core file.
The sub devices will parse the information as per the sub-devices
specific information.

Signed-off-by: Laxman Dewangan <[email protected]>
---
drivers/mfd/tps65910.c | 15 ---------------
1 files changed, 0 insertions(+), 15 deletions(-)

diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
index 05d449b..be9e07b 100644
--- a/drivers/mfd/tps65910.c
+++ b/drivers/mfd/tps65910.c
@@ -146,9 +146,7 @@ static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client,
struct tps65910_board *board_info;
unsigned int prop;
const struct of_device_id *match;
- unsigned int prop_array[TPS6591X_MAX_NUM_GPIO];
int ret = 0;
- int idx;

match = of_match_device(tps65910_of_match, &client->dev);
if (!match) {
@@ -177,21 +175,8 @@ static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client,
else if (*chip_id == TPS65911)
dev_warn(&client->dev, "VMBCH2-Threshold not specified");

- ret = of_property_read_u32_array(np, "ti,en-gpio-sleep",
- prop_array, TPS6591X_MAX_NUM_GPIO);
- if (!ret)
- for (idx = 0; idx < ARRAY_SIZE(prop_array); idx++)
- board_info->en_gpio_sleep[idx] = (prop_array[idx] != 0);
- else if (ret != -EINVAL) {
- dev_err(&client->dev,
- "error reading property ti,en-gpio-sleep: %d\n.", ret);
- return NULL;
- }
-
-
board_info->irq = client->irq;
board_info->irq_base = -1;
- board_info->gpio_base = -1;

return board_info;
}
--
1.7.1.1

2012-05-18 20:37:11

by Laxman Dewangan

[permalink] [raw]
Subject: [PATCH 1/3] mfd: save device node parsed platform data for sub devices

Save the allocated memory to store the parsed device node information
to the global device structure so that sub devices can directly use this
pointer.
In this way, the sub devices does not require to re-allocate the
memory for storing the sub-devices specific device node information.

Signed-off-by: Laxman Dewangan <[email protected]>
---
drivers/mfd/tps65910.c | 6 +++++-
include/linux/mfd/tps65910.h | 3 +++
2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
index 18b30cf..05d449b 100644
--- a/drivers/mfd/tps65910.c
+++ b/drivers/mfd/tps65910.c
@@ -209,14 +209,17 @@ static __devinit int tps65910_i2c_probe(struct i2c_client *i2c,
{
struct tps65910 *tps65910;
struct tps65910_board *pmic_plat_data;
+ struct tps65910_board *of_pmic_plat_data = NULL;
struct tps65910_platform_data *init_data;
int ret = 0;
int chip_id = id->driver_data;

pmic_plat_data = dev_get_platdata(&i2c->dev);

- if (!pmic_plat_data && i2c->dev.of_node)
+ if (!pmic_plat_data && i2c->dev.of_node) {
pmic_plat_data = tps65910_parse_dt(i2c, &chip_id);
+ of_pmic_plat_data = pmic_plat_data;
+ }

if (!pmic_plat_data)
return -EINVAL;
@@ -229,6 +232,7 @@ static __devinit int tps65910_i2c_probe(struct i2c_client *i2c,
if (tps65910 == NULL)
return -ENOMEM;

+ tps65910->of_plat_data = of_pmic_plat_data;
i2c_set_clientdata(i2c, tps65910);
tps65910->dev = &i2c->dev;
tps65910->i2c_client = i2c;
diff --git a/include/linux/mfd/tps65910.h b/include/linux/mfd/tps65910.h
index ab04e90..dd8dc0a 100644
--- a/include/linux/mfd/tps65910.h
+++ b/include/linux/mfd/tps65910.h
@@ -830,6 +830,9 @@ struct tps65910 {
struct tps65910_rtc *rtc;
struct tps65910_power *power;

+ /* Device node parsed board data */
+ struct tps65910_board *of_plat_data;
+
/* IRQ Handling */
struct mutex irq_lock;
int chip_irq;
--
1.7.1.1

2012-05-18 20:37:43

by Laxman Dewangan

[permalink] [raw]
Subject: [PATCH 3/3] gpio: tps65910: dt: process gpio specific device node info

Parse the gpio specific device node information locally.

Signed-off-by: Laxman Dewangan <[email protected]>
---
drivers/gpio/gpio-tps65910.c | 36 ++++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpio-tps65910.c b/drivers/gpio/gpio-tps65910.c
index af6dc83..c1ad288 100644
--- a/drivers/gpio/gpio-tps65910.c
+++ b/drivers/gpio/gpio-tps65910.c
@@ -20,6 +20,7 @@
#include <linux/i2c.h>
#include <linux/platform_device.h>
#include <linux/mfd/tps65910.h>
+#include <linux/of_device.h>

struct tps65910_gpio {
struct gpio_chip gpio_chip;
@@ -81,6 +82,37 @@ static int tps65910_gpio_input(struct gpio_chip *gc, unsigned offset)
GPIO_CFG_MASK);
}

+#ifdef CONFIG_OF
+static struct tps65910_board *tps65910_parse_dt_for_gpio(struct device *dev,
+ struct tps65910 *tps65910, int chip_ngpio)
+{
+ struct tps65910_board *tps65910_board = tps65910->of_plat_data;
+ unsigned int prop_array[TPS6591X_MAX_NUM_GPIO];
+ int ngpio = min(chip_ngpio, TPS6591X_MAX_NUM_GPIO);
+ int ret;
+ int idx;
+
+ tps65910_board->gpio_base = -1;
+ ret = of_property_read_u32_array(tps65910->dev->of_node,
+ "ti,en-gpio-sleep", prop_array, ngpio);
+ if (ret < 0) {
+ dev_dbg(dev, "ti,en-gpio-sleep not specified\n");
+ return tps65910_board;
+ }
+
+ for (idx = 0; idx < ngpio; idx++)
+ tps65910_board->en_gpio_sleep[idx] = (prop_array[idx] != 0);
+
+ return tps65910_board;
+}
+#else
+static struct tps65910_board *tps65910_parse_dt_for_gpio(struct device *dev,
+ struct tps65910 *tps65910, int chip_ngpio)
+{
+ return NULL;
+}
+#endif
+
static int __devinit tps65910_gpio_probe(struct platform_device *pdev)
{
struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent);
@@ -122,6 +154,10 @@ static int __devinit tps65910_gpio_probe(struct platform_device *pdev)
else
tps65910_gpio->gpio_chip.base = -1;

+ if (!pdata && tps65910->dev->of_node)
+ pdata = tps65910_parse_dt_for_gpio(&pdev->dev, tps65910,
+ tps65910_gpio->gpio_chip.ngpio);
+
if (!pdata)
goto skip_init;

--
1.7.1.1

2012-05-18 23:31:25

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH 3/3] gpio: tps65910: dt: process gpio specific device node info

On Sat, 19 May 2012 02:01:43 +0530, Laxman Dewangan <[email protected]> wrote:
> Parse the gpio specific device node information locally.
>
> Signed-off-by: Laxman Dewangan <[email protected]>

Acked-by: Grant Likely <[email protected]>

I expect this needs to go in via Samuel's tree with the mfd patches?

g.

> ---
> drivers/gpio/gpio-tps65910.c | 36 ++++++++++++++++++++++++++++++++++++
> 1 files changed, 36 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/gpio/gpio-tps65910.c b/drivers/gpio/gpio-tps65910.c
> index af6dc83..c1ad288 100644
> --- a/drivers/gpio/gpio-tps65910.c
> +++ b/drivers/gpio/gpio-tps65910.c
> @@ -20,6 +20,7 @@
> #include <linux/i2c.h>
> #include <linux/platform_device.h>
> #include <linux/mfd/tps65910.h>
> +#include <linux/of_device.h>
>
> struct tps65910_gpio {
> struct gpio_chip gpio_chip;
> @@ -81,6 +82,37 @@ static int tps65910_gpio_input(struct gpio_chip *gc, unsigned offset)
> GPIO_CFG_MASK);
> }
>
> +#ifdef CONFIG_OF
> +static struct tps65910_board *tps65910_parse_dt_for_gpio(struct device *dev,
> + struct tps65910 *tps65910, int chip_ngpio)
> +{
> + struct tps65910_board *tps65910_board = tps65910->of_plat_data;
> + unsigned int prop_array[TPS6591X_MAX_NUM_GPIO];
> + int ngpio = min(chip_ngpio, TPS6591X_MAX_NUM_GPIO);
> + int ret;
> + int idx;
> +
> + tps65910_board->gpio_base = -1;
> + ret = of_property_read_u32_array(tps65910->dev->of_node,
> + "ti,en-gpio-sleep", prop_array, ngpio);
> + if (ret < 0) {
> + dev_dbg(dev, "ti,en-gpio-sleep not specified\n");
> + return tps65910_board;
> + }
> +
> + for (idx = 0; idx < ngpio; idx++)
> + tps65910_board->en_gpio_sleep[idx] = (prop_array[idx] != 0);
> +
> + return tps65910_board;
> +}
> +#else
> +static struct tps65910_board *tps65910_parse_dt_for_gpio(struct device *dev,
> + struct tps65910 *tps65910, int chip_ngpio)
> +{
> + return NULL;
> +}
> +#endif
> +
> static int __devinit tps65910_gpio_probe(struct platform_device *pdev)
> {
> struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent);
> @@ -122,6 +154,10 @@ static int __devinit tps65910_gpio_probe(struct platform_device *pdev)
> else
> tps65910_gpio->gpio_chip.base = -1;
>
> + if (!pdata && tps65910->dev->of_node)
> + pdata = tps65910_parse_dt_for_gpio(&pdev->dev, tps65910,
> + tps65910_gpio->gpio_chip.ngpio);
> +
> if (!pdata)
> goto skip_init;
>
> --
> 1.7.1.1
>

--
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.

2012-05-22 21:41:12

by Samuel Ortiz

[permalink] [raw]
Subject: Re: [PATCH 0/3] mfd: tps65910: dt: cleanups in device node parsing

Hi Laxman,

On Sat, May 19, 2012 at 02:01:40AM +0530, Laxman Dewangan wrote:
> In this patch series organizing the processing of device node locally specific
> to driver.
> - The gpio specific processing is moved to gpio driver.
> - Core will only process the non-subdevices information.
> - Also keep the allocated pointer for device node in to global structure
> so that sub devices can use this.
>
> This patch series is generated on-top of Samuel's mfd subsystem tree.
Thanks, all 3 patches applied.

Cheers,
Samuel.

--
Intel Open Source Technology Centre
http://oss.intel.com/