diff options
author | Robert Jarzmik <robert.jarzmik@free.fr> | 2009-07-06 16:16:42 -0400 |
---|---|---|
committer | Eric Miao <eric.y.miao@gmail.com> | 2009-09-10 06:49:30 -0400 |
commit | 7a648256b20c493c99757fe1d248daf7954647bc (patch) | |
tree | 82aa6566accc96ea07a89121cb9779090a6dab40 /arch/arm/mach-pxa/palmld.c | |
parent | b405db6c015fe8e4c9d8199a0355bb16d95d7049 (diff) |
[ARM] pxa: factor pxamci gpio handling
Several boards use always the same pattern with pxamci :
request gpio, request irq for that gpio to detect MMC card
insertion, request gpio for read-only mode detection, etc
...
Now that pxamci provides platform_data to describe simple
gpio management of the MMC external controls, use it.
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: Mike Rapoport <mike@compulab.co.il>
Acked-by: Philipp Zabel <philipp.zabel@gmail.com>
Acked-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: rpurdie@rpsys.net
Cc: drwyrm@gmail.com
Cc: sakoman@gmail.com
Cc: marek.vasut@gmail.com
Cc: s.hauer@pengutronix.de
Signed-off-by: Eric Miao <eric.y.miao@gmail.com>
Diffstat (limited to 'arch/arm/mach-pxa/palmld.c')
-rw-r--r-- | arch/arm/mach-pxa/palmld.c | 80 |
1 files changed, 4 insertions, 76 deletions
diff --git a/arch/arm/mach-pxa/palmld.c b/arch/arm/mach-pxa/palmld.c index 169fcc18154e..445749198cd8 100644 --- a/arch/arm/mach-pxa/palmld.c +++ b/arch/arm/mach-pxa/palmld.c | |||
@@ -143,83 +143,11 @@ static unsigned long palmld_pin_config[] __initdata = { | |||
143 | /****************************************************************************** | 143 | /****************************************************************************** |
144 | * SD/MMC card controller | 144 | * SD/MMC card controller |
145 | ******************************************************************************/ | 145 | ******************************************************************************/ |
146 | static int palmld_mci_init(struct device *dev, irq_handler_t palmld_detect_int, | ||
147 | void *data) | ||
148 | { | ||
149 | int err = 0; | ||
150 | |||
151 | /* Setup an interrupt for detecting card insert/remove events */ | ||
152 | err = gpio_request(GPIO_NR_PALMLD_SD_DETECT_N, "SD IRQ"); | ||
153 | if (err) | ||
154 | goto err; | ||
155 | err = gpio_direction_input(GPIO_NR_PALMLD_SD_DETECT_N); | ||
156 | if (err) | ||
157 | goto err2; | ||
158 | err = request_irq(gpio_to_irq(GPIO_NR_PALMLD_SD_DETECT_N), | ||
159 | palmld_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM | | ||
160 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, | ||
161 | "SD/MMC card detect", data); | ||
162 | if (err) { | ||
163 | printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n", | ||
164 | __func__); | ||
165 | goto err2; | ||
166 | } | ||
167 | |||
168 | err = gpio_request(GPIO_NR_PALMLD_SD_POWER, "SD_POWER"); | ||
169 | if (err) | ||
170 | goto err3; | ||
171 | err = gpio_direction_output(GPIO_NR_PALMLD_SD_POWER, 0); | ||
172 | if (err) | ||
173 | goto err4; | ||
174 | |||
175 | err = gpio_request(GPIO_NR_PALMLD_SD_READONLY, "SD_READONLY"); | ||
176 | if (err) | ||
177 | goto err4; | ||
178 | err = gpio_direction_input(GPIO_NR_PALMLD_SD_READONLY); | ||
179 | if (err) | ||
180 | goto err5; | ||
181 | |||
182 | printk(KERN_DEBUG "%s: irq registered\n", __func__); | ||
183 | |||
184 | return 0; | ||
185 | |||
186 | err5: | ||
187 | gpio_free(GPIO_NR_PALMLD_SD_READONLY); | ||
188 | err4: | ||
189 | gpio_free(GPIO_NR_PALMLD_SD_POWER); | ||
190 | err3: | ||
191 | free_irq(gpio_to_irq(GPIO_NR_PALMLD_SD_DETECT_N), data); | ||
192 | err2: | ||
193 | gpio_free(GPIO_NR_PALMLD_SD_DETECT_N); | ||
194 | err: | ||
195 | return err; | ||
196 | } | ||
197 | |||
198 | static void palmld_mci_exit(struct device *dev, void *data) | ||
199 | { | ||
200 | gpio_free(GPIO_NR_PALMLD_SD_READONLY); | ||
201 | gpio_free(GPIO_NR_PALMLD_SD_POWER); | ||
202 | free_irq(gpio_to_irq(GPIO_NR_PALMLD_SD_DETECT_N), data); | ||
203 | gpio_free(GPIO_NR_PALMLD_SD_DETECT_N); | ||
204 | } | ||
205 | |||
206 | static void palmld_mci_power(struct device *dev, unsigned int vdd) | ||
207 | { | ||
208 | struct pxamci_platform_data *p_d = dev->platform_data; | ||
209 | gpio_set_value(GPIO_NR_PALMLD_SD_POWER, p_d->ocr_mask & (1 << vdd)); | ||
210 | } | ||
211 | |||
212 | static int palmld_mci_get_ro(struct device *dev) | ||
213 | { | ||
214 | return gpio_get_value(GPIO_NR_PALMLD_SD_READONLY); | ||
215 | } | ||
216 | |||
217 | static struct pxamci_platform_data palmld_mci_platform_data = { | 146 | static struct pxamci_platform_data palmld_mci_platform_data = { |
218 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, | 147 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
219 | .setpower = palmld_mci_power, | 148 | .gpio_card_detect = GPIO_NR_PALMLD_SD_DETECT_N, |
220 | .get_ro = palmld_mci_get_ro, | 149 | .gpio_card_ro = GPIO_NR_PALMLD_SD_READONLY, |
221 | .init = palmld_mci_init, | 150 | .gpio_power = GPIO_NR_PALMLD_SD_POWER, |
222 | .exit = palmld_mci_exit, | ||
223 | }; | 151 | }; |
224 | 152 | ||
225 | /****************************************************************************** | 153 | /****************************************************************************** |