aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/treo680.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-pxa/treo680.c')
-rw-r--r--arch/arm/mach-pxa/treo680.c159
1 files changed, 33 insertions, 126 deletions
diff --git a/arch/arm/mach-pxa/treo680.c b/arch/arm/mach-pxa/treo680.c
index 753ec4df17b9..fe085076fbf2 100644
--- a/arch/arm/mach-pxa/treo680.c
+++ b/arch/arm/mach-pxa/treo680.c
@@ -153,87 +153,11 @@ static unsigned long treo680_pin_config[] __initdata = {
153/****************************************************************************** 153/******************************************************************************
154 * SD/MMC card controller 154 * SD/MMC card controller
155 ******************************************************************************/ 155 ******************************************************************************/
156static int treo680_mci_init(struct device *dev,
157 irq_handler_t treo680_detect_int, void *data)
158{
159 int err = 0;
160
161 /* Setup an interrupt for detecting card insert/remove events */
162 err = gpio_request(GPIO_NR_TREO680_SD_DETECT_N, "SD IRQ");
163
164 if (err)
165 goto err;
166
167 err = gpio_direction_input(GPIO_NR_TREO680_SD_DETECT_N);
168 if (err)
169 goto err2;
170
171 err = request_irq(gpio_to_irq(GPIO_NR_TREO680_SD_DETECT_N),
172 treo680_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
173 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
174 "SD/MMC card detect", data);
175
176 if (err) {
177 dev_err(dev, "%s: cannot request SD/MMC card detect IRQ\n",
178 __func__);
179 goto err2;
180 }
181
182 err = gpio_request(GPIO_NR_TREO680_SD_POWER, "SD_POWER");
183 if (err)
184 goto err3;
185
186 err = gpio_direction_output(GPIO_NR_TREO680_SD_POWER, 1);
187 if (err)
188 goto err4;
189
190 err = gpio_request(GPIO_NR_TREO680_SD_READONLY, "SD_READONLY");
191 if (err)
192 goto err4;
193
194 err = gpio_direction_input(GPIO_NR_TREO680_SD_READONLY);
195 if (err)
196 goto err5;
197
198 return 0;
199
200err5:
201 gpio_free(GPIO_NR_TREO680_SD_READONLY);
202err4:
203 gpio_free(GPIO_NR_TREO680_SD_POWER);
204err3:
205 free_irq(gpio_to_irq(GPIO_NR_TREO680_SD_DETECT_N), data);
206err2:
207 gpio_free(GPIO_NR_TREO680_SD_DETECT_N);
208err:
209 return err;
210}
211
212static void treo680_mci_exit(struct device *dev, void *data)
213{
214 gpio_free(GPIO_NR_TREO680_SD_READONLY);
215 gpio_free(GPIO_NR_TREO680_SD_POWER);
216 free_irq(gpio_to_irq(GPIO_NR_TREO680_SD_DETECT_N), data);
217 gpio_free(GPIO_NR_TREO680_SD_DETECT_N);
218}
219
220static void treo680_mci_power(struct device *dev, unsigned int vdd)
221{
222 struct pxamci_platform_data *p_d = dev->platform_data;
223 gpio_set_value(GPIO_NR_TREO680_SD_POWER, p_d->ocr_mask & (1 << vdd));
224}
225
226static int treo680_mci_get_ro(struct device *dev)
227{
228 return gpio_get_value(GPIO_NR_TREO680_SD_READONLY);
229}
230
231static struct pxamci_platform_data treo680_mci_platform_data = { 156static struct pxamci_platform_data treo680_mci_platform_data = {
232 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 157 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
233 .setpower = treo680_mci_power, 158 .gpio_card_detect = GPIO_NR_TREO680_SD_DETECT_N,
234 .get_ro = treo680_mci_get_ro, 159 .gpio_card_ro = GPIO_NR_TREO680_SD_READONLY,
235 .init = treo680_mci_init, 160 .gpio_power = GPIO_NR_TREO680_SD_POWER,
236 .exit = treo680_mci_exit,
237}; 161};
238 162
239/****************************************************************************** 163/******************************************************************************
@@ -330,16 +254,9 @@ static int treo680_backlight_init(struct device *dev)
330 ret = gpio_direction_output(GPIO_NR_TREO680_BL_POWER, 0); 254 ret = gpio_direction_output(GPIO_NR_TREO680_BL_POWER, 0);
331 if (ret) 255 if (ret)
332 goto err2; 256 goto err2;
333 ret = gpio_request(GPIO_NR_TREO680_LCD_POWER, "LCD POWER");
334 if (ret)
335 goto err2;
336 ret = gpio_direction_output(GPIO_NR_TREO680_LCD_POWER, 0);
337 if (ret)
338 goto err3;
339 257
340 return 0; 258 return 0;
341err3: 259
342 gpio_free(GPIO_NR_TREO680_LCD_POWER);
343err2: 260err2:
344 gpio_free(GPIO_NR_TREO680_BL_POWER); 261 gpio_free(GPIO_NR_TREO680_BL_POWER);
345err: 262err:
@@ -355,7 +272,6 @@ static int treo680_backlight_notify(int brightness)
355static void treo680_backlight_exit(struct device *dev) 272static void treo680_backlight_exit(struct device *dev)
356{ 273{
357 gpio_free(GPIO_NR_TREO680_BL_POWER); 274 gpio_free(GPIO_NR_TREO680_BL_POWER);
358 gpio_free(GPIO_NR_TREO680_LCD_POWER);
359} 275}
360 276
361static struct platform_pwm_backlight_data treo680_backlight_data = { 277static struct platform_pwm_backlight_data treo680_backlight_data = {
@@ -379,44 +295,9 @@ static struct platform_device treo680_backlight = {
379/****************************************************************************** 295/******************************************************************************
380 * IrDA 296 * IrDA
381 ******************************************************************************/ 297 ******************************************************************************/
382static void treo680_transceiver_mode(struct device *dev, int mode)
383{
384 gpio_set_value(GPIO_NR_TREO680_IR_EN, mode & IR_OFF);
385 pxa2xx_transceiver_mode(dev, mode);
386}
387
388static int treo680_irda_startup(struct device *dev)
389{
390 int err;
391
392 err = gpio_request(GPIO_NR_TREO680_IR_EN, "Ir port disable");
393 if (err)
394 goto err1;
395
396 err = gpio_direction_output(GPIO_NR_TREO680_IR_EN, 1);
397 if (err)
398 goto err2;
399
400 return 0;
401
402err2:
403 dev_err(dev, "treo680_irda: cannot change IR gpio direction\n");
404 gpio_free(GPIO_NR_TREO680_IR_EN);
405err1:
406 dev_err(dev, "treo680_irda: cannot allocate IR gpio\n");
407 return err;
408}
409
410static void treo680_irda_shutdown(struct device *dev)
411{
412 gpio_free(GPIO_NR_TREO680_IR_EN);
413}
414
415static struct pxaficp_platform_data treo680_ficp_info = { 298static struct pxaficp_platform_data treo680_ficp_info = {
416 .transceiver_cap = IR_FIRMODE | IR_SIRMODE | IR_OFF, 299 .gpio_pwdown = GPIO_NR_TREO680_IR_EN,
417 .startup = treo680_irda_startup, 300 .transceiver_cap = IR_SIRMODE | IR_OFF,
418 .shutdown = treo680_irda_shutdown,
419 .transceiver_mode = treo680_transceiver_mode,
420}; 301};
421 302
422/****************************************************************************** 303/******************************************************************************
@@ -546,6 +427,11 @@ static struct pxafb_mode_info treo680_lcd_modes[] = {
546}, 427},
547}; 428};
548 429
430static void treo680_lcd_power(int on, struct fb_var_screeninfo *info)
431{
432 gpio_set_value(GPIO_NR_TREO680_BL_POWER, on);
433}
434
549static struct pxafb_mach_info treo680_lcd_screen = { 435static struct pxafb_mach_info treo680_lcd_screen = {
550 .modes = treo680_lcd_modes, 436 .modes = treo680_lcd_modes,
551 .num_modes = ARRAY_SIZE(treo680_lcd_modes), 437 .num_modes = ARRAY_SIZE(treo680_lcd_modes),
@@ -585,11 +471,32 @@ static void __init treo680_udc_init(void)
585 } 471 }
586} 472}
587 473
474static void __init treo680_lcd_power_init(void)
475{
476 int ret;
477
478 ret = gpio_request(GPIO_NR_TREO680_LCD_POWER, "LCD POWER");
479 if (ret) {
480 pr_err("Treo680: LCD power GPIO request failed!\n");
481 return;
482 }
483
484 ret = gpio_direction_output(GPIO_NR_TREO680_LCD_POWER, 0);
485 if (ret) {
486 pr_err("Treo680: setting LCD power GPIO direction failed!\n");
487 gpio_free(GPIO_NR_TREO680_LCD_POWER);
488 return;
489 }
490
491 treo680_lcd_screen.pxafb_lcd_power = treo680_lcd_power;
492}
493
588static void __init treo680_init(void) 494static void __init treo680_init(void)
589{ 495{
590 treo680_pm_init(); 496 treo680_pm_init();
591 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config)); 497 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
592 pxa_set_keypad_info(&treo680_keypad_platform_data); 498 pxa_set_keypad_info(&treo680_keypad_platform_data);
499 treo680_lcd_power_init();
593 set_pxa_fb_info(&treo680_lcd_screen); 500 set_pxa_fb_info(&treo680_lcd_screen);
594 pxa_set_mci_info(&treo680_mci_platform_data); 501 pxa_set_mci_info(&treo680_mci_platform_data);
595 treo680_udc_init(); 502 treo680_udc_init();