aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/palmtx.c
diff options
context:
space:
mode:
authorRobert Jarzmik <robert.jarzmik@free.fr>2009-07-06 16:16:42 -0400
committerEric Miao <eric.y.miao@gmail.com>2009-09-10 06:49:30 -0400
commit7a648256b20c493c99757fe1d248daf7954647bc (patch)
tree82aa6566accc96ea07a89121cb9779090a6dab40 /arch/arm/mach-pxa/palmtx.c
parentb405db6c015fe8e4c9d8199a0355bb16d95d7049 (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/palmtx.c')
-rw-r--r--arch/arm/mach-pxa/palmtx.c80
1 files changed, 4 insertions, 76 deletions
diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c
index 83d020879581..4a9ca718962f 100644
--- a/arch/arm/mach-pxa/palmtx.c
+++ b/arch/arm/mach-pxa/palmtx.c
@@ -140,83 +140,11 @@ static unsigned long palmtx_pin_config[] __initdata = {
140/****************************************************************************** 140/******************************************************************************
141 * SD/MMC card controller 141 * SD/MMC card controller
142 ******************************************************************************/ 142 ******************************************************************************/
143static int palmtx_mci_init(struct device *dev, irq_handler_t palmtx_detect_int,
144 void *data)
145{
146 int err = 0;
147
148 /* Setup an interrupt for detecting card insert/remove events */
149 err = gpio_request(GPIO_NR_PALMTX_SD_DETECT_N, "SD IRQ");
150 if (err)
151 goto err;
152 err = gpio_direction_input(GPIO_NR_PALMTX_SD_DETECT_N);
153 if (err)
154 goto err2;
155 err = request_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N),
156 palmtx_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
157 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
158 "SD/MMC card detect", data);
159 if (err) {
160 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
161 __func__);
162 goto err2;
163 }
164
165 err = gpio_request(GPIO_NR_PALMTX_SD_POWER, "SD_POWER");
166 if (err)
167 goto err3;
168 err = gpio_direction_output(GPIO_NR_PALMTX_SD_POWER, 0);
169 if (err)
170 goto err4;
171
172 err = gpio_request(GPIO_NR_PALMTX_SD_READONLY, "SD_READONLY");
173 if (err)
174 goto err4;
175 err = gpio_direction_input(GPIO_NR_PALMTX_SD_READONLY);
176 if (err)
177 goto err5;
178
179 printk(KERN_DEBUG "%s: irq registered\n", __func__);
180
181 return 0;
182
183err5:
184 gpio_free(GPIO_NR_PALMTX_SD_READONLY);
185err4:
186 gpio_free(GPIO_NR_PALMTX_SD_POWER);
187err3:
188 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data);
189err2:
190 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N);
191err:
192 return err;
193}
194
195static void palmtx_mci_exit(struct device *dev, void *data)
196{
197 gpio_free(GPIO_NR_PALMTX_SD_READONLY);
198 gpio_free(GPIO_NR_PALMTX_SD_POWER);
199 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data);
200 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N);
201}
202
203static void palmtx_mci_power(struct device *dev, unsigned int vdd)
204{
205 struct pxamci_platform_data *p_d = dev->platform_data;
206 gpio_set_value(GPIO_NR_PALMTX_SD_POWER, p_d->ocr_mask & (1 << vdd));
207}
208
209static int palmtx_mci_get_ro(struct device *dev)
210{
211 return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY);
212}
213
214static struct pxamci_platform_data palmtx_mci_platform_data = { 143static struct pxamci_platform_data palmtx_mci_platform_data = {
215 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 144 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
216 .setpower = palmtx_mci_power, 145 .gpio_card_detect = GPIO_NR_PALMTX_SD_DETECT_N,
217 .get_ro = palmtx_mci_get_ro, 146 .gpio_card_ro = GPIO_NR_PALMTX_SD_READONLY,
218 .init = palmtx_mci_init, 147 .gpio_power = GPIO_NR_PALMTX_SD_POWER,
219 .exit = palmtx_mci_exit,
220}; 148};
221 149
222/****************************************************************************** 150/******************************************************************************