aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/palmtx.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-pxa/palmtx.c')
-rw-r--r--arch/arm/mach-pxa/palmtx.c225
1 files changed, 123 insertions, 102 deletions
diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c
index 83d020879581..76a2b37eaf30 100644
--- a/arch/arm/mach-pxa/palmtx.c
+++ b/arch/arm/mach-pxa/palmtx.c
@@ -28,6 +28,10 @@
28#include <linux/wm97xx_batt.h> 28#include <linux/wm97xx_batt.h>
29#include <linux/power_supply.h> 29#include <linux/power_supply.h>
30#include <linux/usb/gpio_vbus.h> 30#include <linux/usb/gpio_vbus.h>
31#include <linux/mtd/nand.h>
32#include <linux/mtd/partitions.h>
33#include <linux/mtd/mtd.h>
34#include <linux/mtd/physmap.h>
31 35
32#include <asm/mach-types.h> 36#include <asm/mach-types.h>
33#include <asm/mach/arch.h> 37#include <asm/mach/arch.h>
@@ -131,6 +135,10 @@ static unsigned long palmtx_pin_config[] __initdata = {
131 GPIO34_FFUART_RXD, 135 GPIO34_FFUART_RXD,
132 GPIO39_FFUART_TXD, 136 GPIO39_FFUART_TXD,
133 137
138 /* NAND */
139 GPIO15_nCS_1,
140 GPIO18_RDY,
141
134 /* MISC. */ 142 /* MISC. */
135 GPIO10_GPIO, /* hotsync button */ 143 GPIO10_GPIO, /* hotsync button */
136 GPIO12_GPIO, /* power detect */ 144 GPIO12_GPIO, /* power detect */
@@ -138,85 +146,50 @@ static unsigned long palmtx_pin_config[] __initdata = {
138}; 146};
139 147
140/****************************************************************************** 148/******************************************************************************
141 * SD/MMC card controller 149 * NOR Flash
142 ******************************************************************************/ 150 ******************************************************************************/
143static int palmtx_mci_init(struct device *dev, irq_handler_t palmtx_detect_int, 151static struct mtd_partition palmtx_partitions[] = {
144 void *data) 152 {
145{ 153 .name = "Flash",
146 int err = 0; 154 .offset = 0x00000000,
147 155 .size = MTDPART_SIZ_FULL,
148 /* Setup an interrupt for detecting card insert/remove events */ 156 .mask_flags = 0
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 } 157 }
158};
164 159
165 err = gpio_request(GPIO_NR_PALMTX_SD_POWER, "SD_POWER"); 160static struct physmap_flash_data palmtx_flash_data[] = {
166 if (err) 161 {
167 goto err3; 162 .width = 2, /* bankwidth in bytes */
168 err = gpio_direction_output(GPIO_NR_PALMTX_SD_POWER, 0); 163 .parts = palmtx_partitions,
169 if (err) 164 .nr_parts = ARRAY_SIZE(palmtx_partitions)
170 goto err4; 165 }
171 166};
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 167
203static void palmtx_mci_power(struct device *dev, unsigned int vdd) 168static struct resource palmtx_flash_resource = {
204{ 169 .start = PXA_CS0_PHYS,
205 struct pxamci_platform_data *p_d = dev->platform_data; 170 .end = PXA_CS0_PHYS + SZ_8M - 1,
206 gpio_set_value(GPIO_NR_PALMTX_SD_POWER, p_d->ocr_mask & (1 << vdd)); 171 .flags = IORESOURCE_MEM,
207} 172};
208 173
209static int palmtx_mci_get_ro(struct device *dev) 174static struct platform_device palmtx_flash = {
210{ 175 .name = "physmap-flash",
211 return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY); 176 .id = 0,
212} 177 .resource = &palmtx_flash_resource,
178 .num_resources = 1,
179 .dev = {
180 .platform_data = palmtx_flash_data,
181 },
182};
213 183
184/******************************************************************************
185 * SD/MMC card controller
186 ******************************************************************************/
214static struct pxamci_platform_data palmtx_mci_platform_data = { 187static struct pxamci_platform_data palmtx_mci_platform_data = {
215 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 188 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
216 .setpower = palmtx_mci_power, 189 .gpio_card_detect = GPIO_NR_PALMTX_SD_DETECT_N,
217 .get_ro = palmtx_mci_get_ro, 190 .gpio_card_ro = GPIO_NR_PALMTX_SD_READONLY,
218 .init = palmtx_mci_init, 191 .gpio_power = GPIO_NR_PALMTX_SD_POWER,
219 .exit = palmtx_mci_exit, 192 .detect_delay = 20,
220}; 193};
221 194
222/****************************************************************************** 195/******************************************************************************
@@ -330,35 +303,9 @@ static struct platform_device palmtx_backlight = {
330/****************************************************************************** 303/******************************************************************************
331 * IrDA 304 * IrDA
332 ******************************************************************************/ 305 ******************************************************************************/
333static int palmtx_irda_startup(struct device *dev)
334{
335 int err;
336 err = gpio_request(GPIO_NR_PALMTX_IR_DISABLE, "IR DISABLE");
337 if (err)
338 goto err;
339 err = gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE, 1);
340 if (err)
341 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
342err:
343 return err;
344}
345
346static void palmtx_irda_shutdown(struct device *dev)
347{
348 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
349}
350
351static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
352{
353 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
354 pxa2xx_transceiver_mode(dev, mode);
355}
356
357static struct pxaficp_platform_data palmtx_ficp_platform_data = { 306static struct pxaficp_platform_data palmtx_ficp_platform_data = {
358 .startup = palmtx_irda_startup, 307 .gpio_pwdown = GPIO_NR_PALMTX_IR_DISABLE,
359 .shutdown = palmtx_irda_shutdown, 308 .transceiver_cap = IR_SIRMODE | IR_OFF,
360 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
361 .transceiver_mode = palmtx_irda_transceiver_mode,
362}; 309};
363 310
364/****************************************************************************** 311/******************************************************************************
@@ -493,6 +440,68 @@ static struct pxafb_mach_info palmtx_lcd_screen = {
493}; 440};
494 441
495/****************************************************************************** 442/******************************************************************************
443 * NAND Flash
444 ******************************************************************************/
445static void palmtx_nand_cmd_ctl(struct mtd_info *mtd, int cmd,
446 unsigned int ctrl)
447{
448 struct nand_chip *this = mtd->priv;
449 unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
450
451 if (cmd == NAND_CMD_NONE)
452 return;
453
454 if (ctrl & NAND_CLE)
455 writeb(cmd, PALMTX_NAND_CLE_VIRT);
456 else if (ctrl & NAND_ALE)
457 writeb(cmd, PALMTX_NAND_ALE_VIRT);
458 else
459 writeb(cmd, nandaddr);
460}
461
462static struct mtd_partition palmtx_partition_info[] = {
463 [0] = {
464 .name = "palmtx-0",
465 .offset = 0,
466 .size = MTDPART_SIZ_FULL
467 },
468};
469
470static const char *palmtx_part_probes[] = { "cmdlinepart", NULL };
471
472struct platform_nand_data palmtx_nand_platdata = {
473 .chip = {
474 .nr_chips = 1,
475 .chip_offset = 0,
476 .nr_partitions = ARRAY_SIZE(palmtx_partition_info),
477 .partitions = palmtx_partition_info,
478 .chip_delay = 20,
479 .part_probe_types = palmtx_part_probes,
480 },
481 .ctrl = {
482 .cmd_ctrl = palmtx_nand_cmd_ctl,
483 },
484};
485
486static struct resource palmtx_nand_resource[] = {
487 [0] = {
488 .start = PXA_CS1_PHYS,
489 .end = PXA_CS1_PHYS + SZ_1M - 1,
490 .flags = IORESOURCE_MEM,
491 },
492};
493
494static struct platform_device palmtx_nand = {
495 .name = "gen_nand",
496 .num_resources = ARRAY_SIZE(palmtx_nand_resource),
497 .resource = palmtx_nand_resource,
498 .id = -1,
499 .dev = {
500 .platform_data = &palmtx_nand_platdata,
501 }
502};
503
504/******************************************************************************
496 * Power management - standby 505 * Power management - standby
497 ******************************************************************************/ 506 ******************************************************************************/
498static void __init palmtx_pm_init(void) 507static void __init palmtx_pm_init(void)
@@ -518,6 +527,8 @@ static struct platform_device *devices[] __initdata = {
518 &power_supply, 527 &power_supply,
519 &palmtx_asoc, 528 &palmtx_asoc,
520 &palmtx_gpio_vbus, 529 &palmtx_gpio_vbus,
530 &palmtx_flash,
531 &palmtx_nand,
521}; 532};
522 533
523static struct map_desc palmtx_io_desc[] __initdata = { 534static struct map_desc palmtx_io_desc[] __initdata = {
@@ -525,8 +536,18 @@ static struct map_desc palmtx_io_desc[] __initdata = {
525 .virtual = PALMTX_PCMCIA_VIRT, 536 .virtual = PALMTX_PCMCIA_VIRT,
526 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS), 537 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
527 .length = PALMTX_PCMCIA_SIZE, 538 .length = PALMTX_PCMCIA_SIZE,
528 .type = MT_DEVICE 539 .type = MT_DEVICE,
529}, 540}, {
541 .virtual = PALMTX_NAND_ALE_VIRT,
542 .pfn = __phys_to_pfn(PALMTX_NAND_ALE_PHYS),
543 .length = SZ_1M,
544 .type = MT_DEVICE,
545}, {
546 .virtual = PALMTX_NAND_CLE_VIRT,
547 .pfn = __phys_to_pfn(PALMTX_NAND_CLE_PHYS),
548 .length = SZ_1M,
549 .type = MT_DEVICE,
550}
530}; 551};
531 552
532static void __init palmtx_map_io(void) 553static void __init palmtx_map_io(void)