lpd270.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. /*
  2. * linux/arch/arm/mach-pxa/lpd270.c
  3. *
  4. * Support for the LogicPD PXA270 Card Engine.
  5. * Derived from the mainstone code, which carries these notices:
  6. *
  7. * Author: Nicolas Pitre
  8. * Created: Nov 05, 2002
  9. * Copyright: MontaVista Software Inc.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/gpio.h>
  16. #include <linux/init.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/syscore_ops.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/sched.h>
  21. #include <linux/bitops.h>
  22. #include <linux/fb.h>
  23. #include <linux/ioport.h>
  24. #include <linux/mtd/mtd.h>
  25. #include <linux/mtd/partitions.h>
  26. #include <linux/pwm.h>
  27. #include <linux/pwm_backlight.h>
  28. #include <linux/smc91x.h>
  29. #include <asm/types.h>
  30. #include <asm/setup.h>
  31. #include <asm/memory.h>
  32. #include <asm/mach-types.h>
  33. #include <mach/hardware.h>
  34. #include <asm/irq.h>
  35. #include <asm/sizes.h>
  36. #include <asm/mach/arch.h>
  37. #include <asm/mach/map.h>
  38. #include <asm/mach/irq.h>
  39. #include <asm/mach/flash.h>
  40. #include "pxa27x.h"
  41. #include "lpd270.h"
  42. #include <mach/audio.h>
  43. #include <linux/platform_data/video-pxafb.h>
  44. #include <linux/platform_data/mmc-pxamci.h>
  45. #include <linux/platform_data/irda-pxaficp.h>
  46. #include <linux/platform_data/usb-ohci-pxa27x.h>
  47. #include <mach/smemc.h>
  48. #include "generic.h"
  49. #include "devices.h"
  50. static unsigned long lpd270_pin_config[] __initdata = {
  51. /* Chip Selects */
  52. GPIO15_nCS_1, /* Mainboard Flash */
  53. GPIO78_nCS_2, /* CPLD + Ethernet */
  54. /* LCD - 16bpp Active TFT */
  55. GPIO58_LCD_LDD_0,
  56. GPIO59_LCD_LDD_1,
  57. GPIO60_LCD_LDD_2,
  58. GPIO61_LCD_LDD_3,
  59. GPIO62_LCD_LDD_4,
  60. GPIO63_LCD_LDD_5,
  61. GPIO64_LCD_LDD_6,
  62. GPIO65_LCD_LDD_7,
  63. GPIO66_LCD_LDD_8,
  64. GPIO67_LCD_LDD_9,
  65. GPIO68_LCD_LDD_10,
  66. GPIO69_LCD_LDD_11,
  67. GPIO70_LCD_LDD_12,
  68. GPIO71_LCD_LDD_13,
  69. GPIO72_LCD_LDD_14,
  70. GPIO73_LCD_LDD_15,
  71. GPIO74_LCD_FCLK,
  72. GPIO75_LCD_LCLK,
  73. GPIO76_LCD_PCLK,
  74. GPIO77_LCD_BIAS,
  75. GPIO16_PWM0_OUT, /* Backlight */
  76. /* USB Host */
  77. GPIO88_USBH1_PWR,
  78. GPIO89_USBH1_PEN,
  79. /* AC97 */
  80. GPIO28_AC97_BITCLK,
  81. GPIO29_AC97_SDATA_IN_0,
  82. GPIO30_AC97_SDATA_OUT,
  83. GPIO31_AC97_SYNC,
  84. GPIO45_AC97_SYSCLK,
  85. GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
  86. };
  87. static unsigned int lpd270_irq_enabled;
  88. static void lpd270_mask_irq(struct irq_data *d)
  89. {
  90. int lpd270_irq = d->irq - LPD270_IRQ(0);
  91. __raw_writew(~(1 << lpd270_irq), LPD270_INT_STATUS);
  92. lpd270_irq_enabled &= ~(1 << lpd270_irq);
  93. __raw_writew(lpd270_irq_enabled, LPD270_INT_MASK);
  94. }
  95. static void lpd270_unmask_irq(struct irq_data *d)
  96. {
  97. int lpd270_irq = d->irq - LPD270_IRQ(0);
  98. lpd270_irq_enabled |= 1 << lpd270_irq;
  99. __raw_writew(lpd270_irq_enabled, LPD270_INT_MASK);
  100. }
  101. static struct irq_chip lpd270_irq_chip = {
  102. .name = "CPLD",
  103. .irq_ack = lpd270_mask_irq,
  104. .irq_mask = lpd270_mask_irq,
  105. .irq_unmask = lpd270_unmask_irq,
  106. };
  107. static void lpd270_irq_handler(struct irq_desc *desc)
  108. {
  109. unsigned int irq;
  110. unsigned long pending;
  111. pending = __raw_readw(LPD270_INT_STATUS) & lpd270_irq_enabled;
  112. do {
  113. /* clear useless edge notification */
  114. desc->irq_data.chip->irq_ack(&desc->irq_data);
  115. if (likely(pending)) {
  116. irq = LPD270_IRQ(0) + __ffs(pending);
  117. generic_handle_irq(irq);
  118. pending = __raw_readw(LPD270_INT_STATUS) &
  119. lpd270_irq_enabled;
  120. }
  121. } while (pending);
  122. }
  123. static void __init lpd270_init_irq(void)
  124. {
  125. int irq;
  126. pxa27x_init_irq();
  127. __raw_writew(0, LPD270_INT_MASK);
  128. __raw_writew(0, LPD270_INT_STATUS);
  129. /* setup extra LogicPD PXA270 irqs */
  130. for (irq = LPD270_IRQ(2); irq <= LPD270_IRQ(4); irq++) {
  131. irq_set_chip_and_handler(irq, &lpd270_irq_chip,
  132. handle_level_irq);
  133. irq_clear_status_flags(irq, IRQ_NOREQUEST | IRQ_NOPROBE);
  134. }
  135. irq_set_chained_handler(PXA_GPIO_TO_IRQ(0), lpd270_irq_handler);
  136. irq_set_irq_type(PXA_GPIO_TO_IRQ(0), IRQ_TYPE_EDGE_FALLING);
  137. }
  138. #ifdef CONFIG_PM
  139. static void lpd270_irq_resume(void)
  140. {
  141. __raw_writew(lpd270_irq_enabled, LPD270_INT_MASK);
  142. }
  143. static struct syscore_ops lpd270_irq_syscore_ops = {
  144. .resume = lpd270_irq_resume,
  145. };
  146. static int __init lpd270_irq_device_init(void)
  147. {
  148. if (machine_is_logicpd_pxa270()) {
  149. register_syscore_ops(&lpd270_irq_syscore_ops);
  150. return 0;
  151. }
  152. return -ENODEV;
  153. }
  154. device_initcall(lpd270_irq_device_init);
  155. #endif
  156. static struct resource smc91x_resources[] = {
  157. [0] = {
  158. .start = LPD270_ETH_PHYS,
  159. .end = (LPD270_ETH_PHYS + 0xfffff),
  160. .flags = IORESOURCE_MEM,
  161. },
  162. [1] = {
  163. .start = LPD270_ETHERNET_IRQ,
  164. .end = LPD270_ETHERNET_IRQ,
  165. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  166. },
  167. };
  168. struct smc91x_platdata smc91x_platdata = {
  169. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  170. };
  171. static struct platform_device smc91x_device = {
  172. .name = "smc91x",
  173. .id = 0,
  174. .num_resources = ARRAY_SIZE(smc91x_resources),
  175. .resource = smc91x_resources,
  176. .dev.platform_data = &smc91x_platdata,
  177. };
  178. static struct resource lpd270_flash_resources[] = {
  179. [0] = {
  180. .start = PXA_CS0_PHYS,
  181. .end = PXA_CS0_PHYS + SZ_64M - 1,
  182. .flags = IORESOURCE_MEM,
  183. },
  184. [1] = {
  185. .start = PXA_CS1_PHYS,
  186. .end = PXA_CS1_PHYS + SZ_64M - 1,
  187. .flags = IORESOURCE_MEM,
  188. },
  189. };
  190. static struct mtd_partition lpd270_flash0_partitions[] = {
  191. {
  192. .name = "Bootloader",
  193. .size = 0x00040000,
  194. .offset = 0,
  195. .mask_flags = MTD_WRITEABLE /* force read-only */
  196. }, {
  197. .name = "Kernel",
  198. .size = 0x00400000,
  199. .offset = 0x00040000,
  200. }, {
  201. .name = "Filesystem",
  202. .size = MTDPART_SIZ_FULL,
  203. .offset = 0x00440000
  204. },
  205. };
  206. static struct flash_platform_data lpd270_flash_data[2] = {
  207. {
  208. .name = "processor-flash",
  209. .map_name = "cfi_probe",
  210. .parts = lpd270_flash0_partitions,
  211. .nr_parts = ARRAY_SIZE(lpd270_flash0_partitions),
  212. }, {
  213. .name = "mainboard-flash",
  214. .map_name = "cfi_probe",
  215. .parts = NULL,
  216. .nr_parts = 0,
  217. }
  218. };
  219. static struct platform_device lpd270_flash_device[2] = {
  220. {
  221. .name = "pxa2xx-flash",
  222. .id = 0,
  223. .dev = {
  224. .platform_data = &lpd270_flash_data[0],
  225. },
  226. .resource = &lpd270_flash_resources[0],
  227. .num_resources = 1,
  228. }, {
  229. .name = "pxa2xx-flash",
  230. .id = 1,
  231. .dev = {
  232. .platform_data = &lpd270_flash_data[1],
  233. },
  234. .resource = &lpd270_flash_resources[1],
  235. .num_resources = 1,
  236. },
  237. };
  238. static struct pwm_lookup lpd270_pwm_lookup[] = {
  239. PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight.0", NULL, 78770,
  240. PWM_POLARITY_NORMAL),
  241. };
  242. static struct platform_pwm_backlight_data lpd270_backlight_data = {
  243. .max_brightness = 1,
  244. .dft_brightness = 1,
  245. .enable_gpio = -1,
  246. };
  247. static struct platform_device lpd270_backlight_device = {
  248. .name = "pwm-backlight",
  249. .dev = {
  250. .parent = &pxa27x_device_pwm0.dev,
  251. .platform_data = &lpd270_backlight_data,
  252. },
  253. };
  254. /* 5.7" TFT QVGA (LoLo display number 1) */
  255. static struct pxafb_mode_info sharp_lq057q3dc02_mode = {
  256. .pixclock = 150000,
  257. .xres = 320,
  258. .yres = 240,
  259. .bpp = 16,
  260. .hsync_len = 0x14,
  261. .left_margin = 0x28,
  262. .right_margin = 0x0a,
  263. .vsync_len = 0x02,
  264. .upper_margin = 0x08,
  265. .lower_margin = 0x14,
  266. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  267. };
  268. static struct pxafb_mach_info sharp_lq057q3dc02 = {
  269. .modes = &sharp_lq057q3dc02_mode,
  270. .num_modes = 1,
  271. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
  272. LCD_ALTERNATE_MAPPING,
  273. };
  274. /* 12.1" TFT SVGA (LoLo display number 2) */
  275. static struct pxafb_mode_info sharp_lq121s1dg31_mode = {
  276. .pixclock = 50000,
  277. .xres = 800,
  278. .yres = 600,
  279. .bpp = 16,
  280. .hsync_len = 0x05,
  281. .left_margin = 0x52,
  282. .right_margin = 0x05,
  283. .vsync_len = 0x04,
  284. .upper_margin = 0x14,
  285. .lower_margin = 0x0a,
  286. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  287. };
  288. static struct pxafb_mach_info sharp_lq121s1dg31 = {
  289. .modes = &sharp_lq121s1dg31_mode,
  290. .num_modes = 1,
  291. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
  292. LCD_ALTERNATE_MAPPING,
  293. };
  294. /* 3.6" TFT QVGA (LoLo display number 3) */
  295. static struct pxafb_mode_info sharp_lq036q1da01_mode = {
  296. .pixclock = 150000,
  297. .xres = 320,
  298. .yres = 240,
  299. .bpp = 16,
  300. .hsync_len = 0x0e,
  301. .left_margin = 0x04,
  302. .right_margin = 0x0a,
  303. .vsync_len = 0x03,
  304. .upper_margin = 0x03,
  305. .lower_margin = 0x03,
  306. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  307. };
  308. static struct pxafb_mach_info sharp_lq036q1da01 = {
  309. .modes = &sharp_lq036q1da01_mode,
  310. .num_modes = 1,
  311. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
  312. LCD_ALTERNATE_MAPPING,
  313. };
  314. /* 6.4" TFT VGA (LoLo display number 5) */
  315. static struct pxafb_mode_info sharp_lq64d343_mode = {
  316. .pixclock = 25000,
  317. .xres = 640,
  318. .yres = 480,
  319. .bpp = 16,
  320. .hsync_len = 0x31,
  321. .left_margin = 0x89,
  322. .right_margin = 0x19,
  323. .vsync_len = 0x12,
  324. .upper_margin = 0x22,
  325. .lower_margin = 0x00,
  326. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  327. };
  328. static struct pxafb_mach_info sharp_lq64d343 = {
  329. .modes = &sharp_lq64d343_mode,
  330. .num_modes = 1,
  331. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
  332. LCD_ALTERNATE_MAPPING,
  333. };
  334. /* 10.4" TFT VGA (LoLo display number 7) */
  335. static struct pxafb_mode_info sharp_lq10d368_mode = {
  336. .pixclock = 25000,
  337. .xres = 640,
  338. .yres = 480,
  339. .bpp = 16,
  340. .hsync_len = 0x31,
  341. .left_margin = 0x89,
  342. .right_margin = 0x19,
  343. .vsync_len = 0x12,
  344. .upper_margin = 0x22,
  345. .lower_margin = 0x00,
  346. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  347. };
  348. static struct pxafb_mach_info sharp_lq10d368 = {
  349. .modes = &sharp_lq10d368_mode,
  350. .num_modes = 1,
  351. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
  352. LCD_ALTERNATE_MAPPING,
  353. };
  354. /* 3.5" TFT QVGA (LoLo display number 8) */
  355. static struct pxafb_mode_info sharp_lq035q7db02_20_mode = {
  356. .pixclock = 150000,
  357. .xres = 240,
  358. .yres = 320,
  359. .bpp = 16,
  360. .hsync_len = 0x0e,
  361. .left_margin = 0x0a,
  362. .right_margin = 0x0a,
  363. .vsync_len = 0x03,
  364. .upper_margin = 0x05,
  365. .lower_margin = 0x14,
  366. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  367. };
  368. static struct pxafb_mach_info sharp_lq035q7db02_20 = {
  369. .modes = &sharp_lq035q7db02_20_mode,
  370. .num_modes = 1,
  371. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
  372. LCD_ALTERNATE_MAPPING,
  373. };
  374. static struct pxafb_mach_info *lpd270_lcd_to_use;
  375. static int __init lpd270_set_lcd(char *str)
  376. {
  377. if (!strncasecmp(str, "lq057q3dc02", 11)) {
  378. lpd270_lcd_to_use = &sharp_lq057q3dc02;
  379. } else if (!strncasecmp(str, "lq121s1dg31", 11)) {
  380. lpd270_lcd_to_use = &sharp_lq121s1dg31;
  381. } else if (!strncasecmp(str, "lq036q1da01", 11)) {
  382. lpd270_lcd_to_use = &sharp_lq036q1da01;
  383. } else if (!strncasecmp(str, "lq64d343", 8)) {
  384. lpd270_lcd_to_use = &sharp_lq64d343;
  385. } else if (!strncasecmp(str, "lq10d368", 8)) {
  386. lpd270_lcd_to_use = &sharp_lq10d368;
  387. } else if (!strncasecmp(str, "lq035q7db02-20", 14)) {
  388. lpd270_lcd_to_use = &sharp_lq035q7db02_20;
  389. } else {
  390. printk(KERN_INFO "lpd270: unknown lcd panel [%s]\n", str);
  391. }
  392. return 1;
  393. }
  394. __setup("lcd=", lpd270_set_lcd);
  395. static struct platform_device *platform_devices[] __initdata = {
  396. &smc91x_device,
  397. &lpd270_backlight_device,
  398. &lpd270_flash_device[0],
  399. &lpd270_flash_device[1],
  400. };
  401. static struct pxaohci_platform_data lpd270_ohci_platform_data = {
  402. .port_mode = PMM_PERPORT_MODE,
  403. .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
  404. };
  405. static void __init lpd270_init(void)
  406. {
  407. pxa2xx_mfp_config(ARRAY_AND_SIZE(lpd270_pin_config));
  408. pxa_set_ffuart_info(NULL);
  409. pxa_set_btuart_info(NULL);
  410. pxa_set_stuart_info(NULL);
  411. lpd270_flash_data[0].width = (__raw_readl(BOOT_DEF) & 1) ? 2 : 4;
  412. lpd270_flash_data[1].width = 4;
  413. /*
  414. * System bus arbiter setting:
  415. * - Core_Park
  416. * - LCD_wt:DMA_wt:CORE_Wt = 2:3:4
  417. */
  418. ARB_CNTRL = ARB_CORE_PARK | 0x234;
  419. pwm_add_table(lpd270_pwm_lookup, ARRAY_SIZE(lpd270_pwm_lookup));
  420. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  421. pxa_set_ac97_info(NULL);
  422. if (lpd270_lcd_to_use != NULL)
  423. pxa_set_fb_info(NULL, lpd270_lcd_to_use);
  424. pxa_set_ohci_info(&lpd270_ohci_platform_data);
  425. }
  426. static struct map_desc lpd270_io_desc[] __initdata = {
  427. {
  428. .virtual = (unsigned long)LPD270_CPLD_VIRT,
  429. .pfn = __phys_to_pfn(LPD270_CPLD_PHYS),
  430. .length = LPD270_CPLD_SIZE,
  431. .type = MT_DEVICE,
  432. },
  433. };
  434. static void __init lpd270_map_io(void)
  435. {
  436. pxa27x_map_io();
  437. iotable_init(lpd270_io_desc, ARRAY_SIZE(lpd270_io_desc));
  438. /* for use I SRAM as framebuffer. */
  439. PSLR |= 0x00000F04;
  440. PCFR = 0x00000066;
  441. }
  442. MACHINE_START(LOGICPD_PXA270, "LogicPD PXA270 Card Engine")
  443. /* Maintainer: Peter Barada */
  444. .atag_offset = 0x100,
  445. .map_io = lpd270_map_io,
  446. .nr_irqs = LPD270_NR_IRQS,
  447. .init_irq = lpd270_init_irq,
  448. .handle_irq = pxa27x_handle_irq,
  449. .init_time = pxa_timer_init,
  450. .init_machine = lpd270_init,
  451. .restart = pxa_restart,
  452. MACHINE_END