diff options
author | Marek Vasut <marex@denx.de> | 2013-04-14 14:35:48 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-04-18 18:40:07 -0400 |
commit | 360e64d8bbe7c78784d769a60d152804f5079577 (patch) | |
tree | 44a1e15f1551d348a6492d997c310a114d78e943 | |
parent | 20fb277250816d6c3ff326552be0fea4173fd8ca (diff) |
mfd: ucb1400: Pass ucb1400-gpio data through ac97 bus
Cc: Jean Delvare <jdelvare@suse.de>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r-- | drivers/gpio/gpio-ucb1400.c | 19 | ||||
-rw-r--r-- | drivers/mfd/ucb1400_core.c | 5 | ||||
-rw-r--r-- | include/linux/ucb1400.h | 18 |
3 files changed, 17 insertions, 25 deletions
diff --git a/drivers/gpio/gpio-ucb1400.c b/drivers/gpio/gpio-ucb1400.c index 26405efe0f9f..6d0feb234d3c 100644 --- a/drivers/gpio/gpio-ucb1400.c +++ b/drivers/gpio/gpio-ucb1400.c | |||
@@ -12,8 +12,6 @@ | |||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/ucb1400.h> | 13 | #include <linux/ucb1400.h> |
14 | 14 | ||
15 | struct ucb1400_gpio_data *ucbdata; | ||
16 | |||
17 | static int ucb1400_gpio_dir_in(struct gpio_chip *gc, unsigned off) | 15 | static int ucb1400_gpio_dir_in(struct gpio_chip *gc, unsigned off) |
18 | { | 16 | { |
19 | struct ucb1400_gpio *gpio; | 17 | struct ucb1400_gpio *gpio; |
@@ -50,7 +48,7 @@ static int ucb1400_gpio_probe(struct platform_device *dev) | |||
50 | struct ucb1400_gpio *ucb = dev->dev.platform_data; | 48 | struct ucb1400_gpio *ucb = dev->dev.platform_data; |
51 | int err = 0; | 49 | int err = 0; |
52 | 50 | ||
53 | if (!(ucbdata && ucbdata->gpio_offset)) { | 51 | if (!(ucb && ucb->gpio_offset)) { |
54 | err = -EINVAL; | 52 | err = -EINVAL; |
55 | goto err; | 53 | goto err; |
56 | } | 54 | } |
@@ -58,7 +56,7 @@ static int ucb1400_gpio_probe(struct platform_device *dev) | |||
58 | platform_set_drvdata(dev, ucb); | 56 | platform_set_drvdata(dev, ucb); |
59 | 57 | ||
60 | ucb->gc.label = "ucb1400_gpio"; | 58 | ucb->gc.label = "ucb1400_gpio"; |
61 | ucb->gc.base = ucbdata->gpio_offset; | 59 | ucb->gc.base = ucb->gpio_offset; |
62 | ucb->gc.ngpio = 10; | 60 | ucb->gc.ngpio = 10; |
63 | ucb->gc.owner = THIS_MODULE; | 61 | ucb->gc.owner = THIS_MODULE; |
64 | 62 | ||
@@ -72,8 +70,8 @@ static int ucb1400_gpio_probe(struct platform_device *dev) | |||
72 | if (err) | 70 | if (err) |
73 | goto err; | 71 | goto err; |
74 | 72 | ||
75 | if (ucbdata && ucbdata->gpio_setup) | 73 | if (ucb && ucb->gpio_setup) |
76 | err = ucbdata->gpio_setup(&dev->dev, ucb->gc.ngpio); | 74 | err = ucb->gpio_setup(&dev->dev, ucb->gc.ngpio); |
77 | 75 | ||
78 | err: | 76 | err: |
79 | return err; | 77 | return err; |
@@ -85,8 +83,8 @@ static int ucb1400_gpio_remove(struct platform_device *dev) | |||
85 | int err = 0; | 83 | int err = 0; |
86 | struct ucb1400_gpio *ucb = platform_get_drvdata(dev); | 84 | struct ucb1400_gpio *ucb = platform_get_drvdata(dev); |
87 | 85 | ||
88 | if (ucbdata && ucbdata->gpio_teardown) { | 86 | if (ucb && ucb->gpio_teardown) { |
89 | err = ucbdata->gpio_teardown(&dev->dev, ucb->gc.ngpio); | 87 | err = ucb->gpio_teardown(&dev->dev, ucb->gc.ngpio); |
90 | if (err) | 88 | if (err) |
91 | return err; | 89 | return err; |
92 | } | 90 | } |
@@ -103,11 +101,6 @@ static struct platform_driver ucb1400_gpio_driver = { | |||
103 | }, | 101 | }, |
104 | }; | 102 | }; |
105 | 103 | ||
106 | void __init ucb1400_gpio_set_data(struct ucb1400_gpio_data *data) | ||
107 | { | ||
108 | ucbdata = data; | ||
109 | } | ||
110 | |||
111 | module_platform_driver(ucb1400_gpio_driver); | 104 | module_platform_driver(ucb1400_gpio_driver); |
112 | 105 | ||
113 | MODULE_DESCRIPTION("Philips UCB1400 GPIO driver"); | 106 | MODULE_DESCRIPTION("Philips UCB1400 GPIO driver"); |
diff --git a/drivers/mfd/ucb1400_core.c b/drivers/mfd/ucb1400_core.c index daf69527ed83..e9031fa9d53d 100644 --- a/drivers/mfd/ucb1400_core.c +++ b/drivers/mfd/ucb1400_core.c | |||
@@ -75,6 +75,11 @@ static int ucb1400_core_probe(struct device *dev) | |||
75 | 75 | ||
76 | /* GPIO */ | 76 | /* GPIO */ |
77 | ucb_gpio.ac97 = ac97; | 77 | ucb_gpio.ac97 = ac97; |
78 | if (pdata) { | ||
79 | ucb_gpio.gpio_setup = pdata->gpio_setup; | ||
80 | ucb_gpio.gpio_teardown = pdata->gpio_teardown; | ||
81 | ucb_gpio.gpio_offset = pdata->gpio_offset; | ||
82 | } | ||
78 | ucb->ucb1400_gpio = platform_device_alloc("ucb1400_gpio", -1); | 83 | ucb->ucb1400_gpio = platform_device_alloc("ucb1400_gpio", -1); |
79 | if (!ucb->ucb1400_gpio) { | 84 | if (!ucb->ucb1400_gpio) { |
80 | err = -ENOMEM; | 85 | err = -ENOMEM; |
diff --git a/include/linux/ucb1400.h b/include/linux/ucb1400.h index d21b33c4c6ca..2e9ee4d1c676 100644 --- a/include/linux/ucb1400.h +++ b/include/linux/ucb1400.h | |||
@@ -83,15 +83,12 @@ | |||
83 | #define UCB_ID 0x7e | 83 | #define UCB_ID 0x7e |
84 | #define UCB_ID_1400 0x4304 | 84 | #define UCB_ID_1400 0x4304 |
85 | 85 | ||
86 | struct ucb1400_gpio_data { | ||
87 | int gpio_offset; | ||
88 | int (*gpio_setup)(struct device *dev, int ngpio); | ||
89 | int (*gpio_teardown)(struct device *dev, int ngpio); | ||
90 | }; | ||
91 | |||
92 | struct ucb1400_gpio { | 86 | struct ucb1400_gpio { |
93 | struct gpio_chip gc; | 87 | struct gpio_chip gc; |
94 | struct snd_ac97 *ac97; | 88 | struct snd_ac97 *ac97; |
89 | int gpio_offset; | ||
90 | int (*gpio_setup)(struct device *dev, int ngpio); | ||
91 | int (*gpio_teardown)(struct device *dev, int ngpio); | ||
95 | }; | 92 | }; |
96 | 93 | ||
97 | struct ucb1400_ts { | 94 | struct ucb1400_ts { |
@@ -110,6 +107,9 @@ struct ucb1400 { | |||
110 | 107 | ||
111 | struct ucb1400_pdata { | 108 | struct ucb1400_pdata { |
112 | int irq; | 109 | int irq; |
110 | int gpio_offset; | ||
111 | int (*gpio_setup)(struct device *dev, int ngpio); | ||
112 | int (*gpio_teardown)(struct device *dev, int ngpio); | ||
113 | }; | 113 | }; |
114 | 114 | ||
115 | static inline u16 ucb1400_reg_read(struct snd_ac97 *ac97, u16 reg) | 115 | static inline u16 ucb1400_reg_read(struct snd_ac97 *ac97, u16 reg) |
@@ -162,10 +162,4 @@ static inline void ucb1400_adc_disable(struct snd_ac97 *ac97) | |||
162 | unsigned int ucb1400_adc_read(struct snd_ac97 *ac97, u16 adc_channel, | 162 | unsigned int ucb1400_adc_read(struct snd_ac97 *ac97, u16 adc_channel, |
163 | int adcsync); | 163 | int adcsync); |
164 | 164 | ||
165 | #ifdef CONFIG_GPIO_UCB1400 | ||
166 | void __init ucb1400_gpio_set_data(struct ucb1400_gpio_data *data); | ||
167 | #else | ||
168 | static inline void ucb1400_gpio_set_data(struct ucb1400_gpio_data *data) {} | ||
169 | #endif | ||
170 | |||
171 | #endif | 165 | #endif |