pcm990-baseboard.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. /*
  2. * arch/arm/mach-pxa/pcm990-baseboard.c
  3. * Support for the Phytec phyCORE-PXA270 Development Platform (PCM-990).
  4. *
  5. * Refer
  6. * http://www.phytec.com/products/rdk/ARM-XScale/phyCORE-XScale-PXA270.html
  7. * for additional hardware info
  8. *
  9. * Author: Juergen Kilb
  10. * Created: April 05, 2005
  11. * Copyright: Phytec Messtechnik GmbH
  12. * e-Mail: armlinux@phytec.de
  13. *
  14. * based on Intel Mainstone Board
  15. *
  16. * Copyright 2007 Juergen Beisert @ Pengutronix (j.beisert@pengutronix.de)
  17. *
  18. * This program is free software; you can redistribute it and/or modify
  19. * it under the terms of the GNU General Public License version 2 as
  20. * published by the Free Software Foundation.
  21. */
  22. #include <linux/irq.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/ide.h>
  25. #include <linux/i2c.h>
  26. #include <linux/pwm_backlight.h>
  27. #include <media/soc_camera.h>
  28. #include <asm/gpio.h>
  29. #include <asm/arch/i2c.h>
  30. #include <asm/arch/camera.h>
  31. #include <asm/mach/map.h>
  32. #include <asm/arch/pxa-regs.h>
  33. #include <asm/arch/pxa2xx-gpio.h>
  34. #include <asm/arch/mmc.h>
  35. #include <asm/arch/ohci.h>
  36. #include <asm/arch/pcm990_baseboard.h>
  37. #include <asm/arch/pxafb.h>
  38. #include "devices.h"
  39. /*
  40. * pcm990_lcd_power - control power supply to the LCD
  41. * @on: 0 = switch off, 1 = switch on
  42. *
  43. * Called by the pxafb driver
  44. */
  45. #ifndef CONFIG_PCM990_DISPLAY_NONE
  46. static void pcm990_lcd_power(int on, struct fb_var_screeninfo *var)
  47. {
  48. if (on) {
  49. /* enable LCD-Latches
  50. * power on LCD
  51. */
  52. __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG3) =
  53. PCM990_CTRL_LCDPWR + PCM990_CTRL_LCDON;
  54. } else {
  55. /* disable LCD-Latches
  56. * power off LCD
  57. */
  58. __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG3) = 0x00;
  59. }
  60. }
  61. #endif
  62. #if defined(CONFIG_PCM990_DISPLAY_SHARP)
  63. static struct pxafb_mode_info fb_info_sharp_lq084v1dg21 = {
  64. .pixclock = 28000,
  65. .xres = 640,
  66. .yres = 480,
  67. .bpp = 16,
  68. .hsync_len = 20,
  69. .left_margin = 103,
  70. .right_margin = 47,
  71. .vsync_len = 6,
  72. .upper_margin = 28,
  73. .lower_margin = 5,
  74. .sync = 0,
  75. .cmap_greyscale = 0,
  76. };
  77. static struct pxafb_mach_info pcm990_fbinfo __initdata = {
  78. .modes = &fb_info_sharp_lq084v1dg21,
  79. .num_modes = 1,
  80. .lccr0 = LCCR0_PAS,
  81. .lccr3 = LCCR3_PCP,
  82. .pxafb_lcd_power = pcm990_lcd_power,
  83. };
  84. #elif defined(CONFIG_PCM990_DISPLAY_NEC)
  85. struct pxafb_mode_info fb_info_nec_nl6448bc20_18d = {
  86. .pixclock = 39720,
  87. .xres = 640,
  88. .yres = 480,
  89. .bpp = 16,
  90. .hsync_len = 32,
  91. .left_margin = 16,
  92. .right_margin = 48,
  93. .vsync_len = 2,
  94. .upper_margin = 12,
  95. .lower_margin = 17,
  96. .sync = 0,
  97. .cmap_greyscale = 0,
  98. };
  99. static struct pxafb_mach_info pcm990_fbinfo __initdata = {
  100. .modes = &fb_info_nec_nl6448bc20_18d,
  101. .num_modes = 1,
  102. .lccr0 = LCCR0_Act,
  103. .lccr3 = LCCR3_PixFlEdg,
  104. .pxafb_lcd_power = pcm990_lcd_power,
  105. };
  106. #endif
  107. static struct platform_pwm_backlight_data pcm990_backlight_data = {
  108. .pwm_id = 0,
  109. .max_brightness = 1023,
  110. .dft_brightness = 1023,
  111. .pwm_period_ns = 78770,
  112. };
  113. static struct platform_device pcm990_backlight_device = {
  114. .name = "pwm-backlight",
  115. .dev = {
  116. .parent = &pxa27x_device_pwm0.dev,
  117. .platform_data = &pcm990_backlight_data,
  118. },
  119. };
  120. /*
  121. * The PCM-990 development baseboard uses PCM-027's hardware in the
  122. * following way:
  123. *
  124. * - LCD support is in use
  125. * - GPIO16 is output for back light on/off with PWM
  126. * - GPIO58 ... GPIO73 are outputs for display data
  127. * - GPIO74 is output output for LCDFCLK
  128. * - GPIO75 is output for LCDLCLK
  129. * - GPIO76 is output for LCDPCLK
  130. * - GPIO77 is output for LCDBIAS
  131. * - MMC support is in use
  132. * - GPIO32 is output for MMCCLK
  133. * - GPIO92 is MMDAT0
  134. * - GPIO109 is MMDAT1
  135. * - GPIO110 is MMCS0
  136. * - GPIO111 is MMCS1
  137. * - GPIO112 is MMCMD
  138. * - IDE/CF card is in use
  139. * - GPIO48 is output /POE
  140. * - GPIO49 is output /PWE
  141. * - GPIO50 is output /PIOR
  142. * - GPIO51 is output /PIOW
  143. * - GPIO54 is output /PCE2
  144. * - GPIO55 is output /PREG
  145. * - GPIO56 is input /PWAIT
  146. * - GPIO57 is output /PIOS16
  147. * - GPIO79 is output PSKTSEL
  148. * - GPIO85 is output /PCE1
  149. * - FFUART is in use
  150. * - GPIO34 is input FFRXD
  151. * - GPIO35 is input FFCTS
  152. * - GPIO36 is input FFDCD
  153. * - GPIO37 is input FFDSR
  154. * - GPIO38 is input FFRI
  155. * - GPIO39 is output FFTXD
  156. * - GPIO40 is output FFDTR
  157. * - GPIO41 is output FFRTS
  158. * - BTUART is in use
  159. * - GPIO42 is input BTRXD
  160. * - GPIO43 is output BTTXD
  161. * - GPIO44 is input BTCTS
  162. * - GPIO45 is output BTRTS
  163. * - IRUART is in use
  164. * - GPIO46 is input STDRXD
  165. * - GPIO47 is output STDTXD
  166. * - AC97 is in use*)
  167. * - GPIO28 is input AC97CLK
  168. * - GPIO29 is input AC97DatIn
  169. * - GPIO30 is output AC97DatO
  170. * - GPIO31 is output AC97SYNC
  171. * - GPIO113 is output AC97_RESET
  172. * - SSP is in use
  173. * - GPIO23 is output SSPSCLK
  174. * - GPIO24 is output chip select to Max7301
  175. * - GPIO25 is output SSPTXD
  176. * - GPIO26 is input SSPRXD
  177. * - GPIO27 is input for Max7301 IRQ
  178. * - GPIO53 is input SSPSYSCLK
  179. * - SSP3 is in use
  180. * - GPIO81 is output SSPTXD3
  181. * - GPIO82 is input SSPRXD3
  182. * - GPIO83 is output SSPSFRM
  183. * - GPIO84 is output SSPCLK3
  184. *
  185. * Otherwise claimed GPIOs:
  186. * GPIO1 -> IRQ from user switch
  187. * GPIO9 -> IRQ from power management
  188. * GPIO10 -> IRQ from WML9712 AC97 controller
  189. * GPIO11 -> IRQ from IDE controller
  190. * GPIO12 -> IRQ from CF controller
  191. * GPIO13 -> IRQ from CF controller
  192. * GPIO14 -> GPIO free
  193. * GPIO15 -> /CS1 selects baseboard's Control CPLD (U7, 16 bit wide data path)
  194. * GPIO19 -> GPIO free
  195. * GPIO20 -> /SDCS2
  196. * GPIO21 -> /CS3 PC card socket select
  197. * GPIO33 -> /CS5 network controller select
  198. * GPIO78 -> /CS2 (16 bit wide data path)
  199. * GPIO80 -> /CS4 (16 bit wide data path)
  200. * GPIO86 -> GPIO free
  201. * GPIO87 -> GPIO free
  202. * GPIO90 -> LED0 on CPU module
  203. * GPIO91 -> LED1 on CPI module
  204. * GPIO117 -> SCL
  205. * GPIO118 -> SDA
  206. */
  207. static unsigned long pcm990_irq_enabled;
  208. static void pcm990_mask_ack_irq(unsigned int irq)
  209. {
  210. int pcm990_irq = (irq - PCM027_IRQ(0));
  211. PCM990_INTMSKENA = (pcm990_irq_enabled &= ~(1 << pcm990_irq));
  212. }
  213. static void pcm990_unmask_irq(unsigned int irq)
  214. {
  215. int pcm990_irq = (irq - PCM027_IRQ(0));
  216. /* the irq can be acknowledged only if deasserted, so it's done here */
  217. PCM990_INTSETCLR |= 1 << pcm990_irq;
  218. PCM990_INTMSKENA = (pcm990_irq_enabled |= (1 << pcm990_irq));
  219. }
  220. static struct irq_chip pcm990_irq_chip = {
  221. .mask_ack = pcm990_mask_ack_irq,
  222. .unmask = pcm990_unmask_irq,
  223. };
  224. static void pcm990_irq_handler(unsigned int irq, struct irq_desc *desc)
  225. {
  226. unsigned long pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled;
  227. do {
  228. GEDR(PCM990_CTRL_INT_IRQ_GPIO) =
  229. GPIO_bit(PCM990_CTRL_INT_IRQ_GPIO);
  230. if (likely(pending)) {
  231. irq = PCM027_IRQ(0) + __ffs(pending);
  232. desc = irq_desc + irq;
  233. desc_handle_irq(irq, desc);
  234. }
  235. pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled;
  236. } while (pending);
  237. }
  238. static void __init pcm990_init_irq(void)
  239. {
  240. int irq;
  241. /* setup extra PCM990 irqs */
  242. for (irq = PCM027_IRQ(0); irq <= PCM027_IRQ(3); irq++) {
  243. set_irq_chip(irq, &pcm990_irq_chip);
  244. set_irq_handler(irq, handle_level_irq);
  245. set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  246. }
  247. PCM990_INTMSKENA = 0x00; /* disable all Interrupts */
  248. PCM990_INTSETCLR = 0xFF;
  249. set_irq_chained_handler(PCM990_CTRL_INT_IRQ, pcm990_irq_handler);
  250. set_irq_type(PCM990_CTRL_INT_IRQ, PCM990_CTRL_INT_IRQ_EDGE);
  251. }
  252. static int pcm990_mci_init(struct device *dev, irq_handler_t mci_detect_int,
  253. void *data)
  254. {
  255. int err;
  256. /*
  257. * enable GPIO for PXA27x MMC controller
  258. */
  259. pxa_gpio_mode(GPIO32_MMCCLK_MD);
  260. pxa_gpio_mode(GPIO112_MMCCMD_MD);
  261. pxa_gpio_mode(GPIO92_MMCDAT0_MD);
  262. pxa_gpio_mode(GPIO109_MMCDAT1_MD);
  263. pxa_gpio_mode(GPIO110_MMCDAT2_MD);
  264. pxa_gpio_mode(GPIO111_MMCDAT3_MD);
  265. err = request_irq(PCM027_MMCDET_IRQ, mci_detect_int, IRQF_DISABLED,
  266. "MMC card detect", data);
  267. if (err)
  268. printk(KERN_ERR "pcm990_mci_init: MMC/SD: can't request MMC "
  269. "card detect IRQ\n");
  270. return err;
  271. }
  272. static void pcm990_mci_setpower(struct device *dev, unsigned int vdd)
  273. {
  274. struct pxamci_platform_data *p_d = dev->platform_data;
  275. if ((1 << vdd) & p_d->ocr_mask)
  276. __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5) =
  277. PCM990_CTRL_MMC2PWR;
  278. else
  279. __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5) =
  280. ~PCM990_CTRL_MMC2PWR;
  281. }
  282. static void pcm990_mci_exit(struct device *dev, void *data)
  283. {
  284. free_irq(PCM027_MMCDET_IRQ, data);
  285. }
  286. #define MSECS_PER_JIFFY (1000/HZ)
  287. static struct pxamci_platform_data pcm990_mci_platform_data = {
  288. .detect_delay = 250 / MSECS_PER_JIFFY,
  289. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  290. .init = pcm990_mci_init,
  291. .setpower = pcm990_mci_setpower,
  292. .exit = pcm990_mci_exit,
  293. };
  294. /*
  295. * init OHCI hardware to work with
  296. *
  297. * Note: Only USB port 1 (host only) is connected
  298. *
  299. * GPIO88 (USBHPWR#1): overcurrent in, overcurrent when low
  300. * GPIO89 (USBHPEN#1): power-on out, on when low
  301. */
  302. static int pcm990_ohci_init(struct device *dev)
  303. {
  304. pxa_gpio_mode(PCM990_USB_OVERCURRENT);
  305. pxa_gpio_mode(PCM990_USB_PWR_EN);
  306. /*
  307. * disable USB port 2 and 3
  308. * power sense is active low
  309. */
  310. UHCHR = ((UHCHR) | UHCHR_PCPL | UHCHR_PSPL | UHCHR_SSEP2 |
  311. UHCHR_SSEP3) & ~(UHCHR_SSEP1 | UHCHR_SSE);
  312. /*
  313. * wait 10ms after Power on
  314. * overcurrent per port
  315. * power switch per port
  316. */
  317. UHCRHDA = (5<<24) | (1<<11) | (1<<8); /* FIXME: Required? */
  318. return 0;
  319. }
  320. static struct pxaohci_platform_data pcm990_ohci_platform_data = {
  321. .port_mode = PMM_PERPORT_MODE,
  322. .init = pcm990_ohci_init,
  323. .exit = NULL,
  324. };
  325. /*
  326. * PXA27x Camera specific stuff
  327. */
  328. #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
  329. static int pcm990_pxacamera_init(struct device *dev)
  330. {
  331. pxa_gpio_mode(GPIO98_CIF_DD_0_MD);
  332. pxa_gpio_mode(GPIO105_CIF_DD_1_MD);
  333. pxa_gpio_mode(GPIO104_CIF_DD_2_MD);
  334. pxa_gpio_mode(GPIO103_CIF_DD_3_MD);
  335. pxa_gpio_mode(GPIO95_CIF_DD_4_MD);
  336. pxa_gpio_mode(GPIO94_CIF_DD_5_MD);
  337. pxa_gpio_mode(GPIO93_CIF_DD_6_MD);
  338. pxa_gpio_mode(GPIO108_CIF_DD_7_MD);
  339. pxa_gpio_mode(GPIO107_CIF_DD_8_MD);
  340. pxa_gpio_mode(GPIO106_CIF_DD_9_MD);
  341. pxa_gpio_mode(GPIO42_CIF_MCLK_MD);
  342. pxa_gpio_mode(GPIO45_CIF_PCLK_MD);
  343. pxa_gpio_mode(GPIO43_CIF_FV_MD);
  344. pxa_gpio_mode(GPIO44_CIF_LV_MD);
  345. return 0;
  346. }
  347. /*
  348. * CICR4: PCLK_EN: Pixel clock is supplied by the sensor
  349. * MCLK_EN: Master clock is generated by PXA
  350. * PCP: Data sampled on the falling edge of pixel clock
  351. */
  352. struct pxacamera_platform_data pcm990_pxacamera_platform_data = {
  353. .init = pcm990_pxacamera_init,
  354. .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 | PXA_CAMERA_DATAWIDTH_10 |
  355. PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN/* | PXA_CAMERA_PCP*/,
  356. .mclk_10khz = 1000,
  357. };
  358. #include <linux/i2c/pca953x.h>
  359. static struct pca953x_platform_data pca9536_data = {
  360. .gpio_base = NR_BUILTIN_GPIO + 1,
  361. };
  362. static struct soc_camera_link iclink[] = {
  363. {
  364. .bus_id = 0, /* Must match with the camera ID above */
  365. .gpio = NR_BUILTIN_GPIO + 1,
  366. }, {
  367. .bus_id = 0, /* Must match with the camera ID above */
  368. }
  369. };
  370. /* Board I2C devices. */
  371. static struct i2c_board_info __initdata pcm990_i2c_devices[] = {
  372. {
  373. /* Must initialize before the camera(s) */
  374. I2C_BOARD_INFO("pca9536", 0x41),
  375. .platform_data = &pca9536_data,
  376. }, {
  377. I2C_BOARD_INFO("mt9v022", 0x48),
  378. .platform_data = &iclink[0], /* With extender */
  379. }, {
  380. I2C_BOARD_INFO("mt9m001", 0x5d),
  381. .platform_data = &iclink[0], /* With extender */
  382. },
  383. };
  384. #endif /* CONFIG_VIDEO_PXA27x ||CONFIG_VIDEO_PXA27x_MODULE */
  385. /*
  386. * AC97 support
  387. * Note: The connected AC97 mixer also reports interrupts at PCM990_AC97_IRQ
  388. */
  389. static struct resource pxa27x_ac97_resources[] = {
  390. [0] = {
  391. .start = 0x40500000,
  392. .end = 0x40500000 + 0xfff,
  393. .flags = IORESOURCE_MEM,
  394. },
  395. [1] = {
  396. .start = IRQ_AC97,
  397. .end = IRQ_AC97,
  398. .flags = IORESOURCE_IRQ,
  399. },
  400. };
  401. static u64 pxa_ac97_dmamask = 0xffffffffUL;
  402. static struct platform_device pxa27x_device_ac97 = {
  403. .name = "pxa2xx-ac97",
  404. .id = -1,
  405. .dev = {
  406. .dma_mask = &pxa_ac97_dmamask,
  407. .coherent_dma_mask = 0xffffffff,
  408. },
  409. .num_resources = ARRAY_SIZE(pxa27x_ac97_resources),
  410. .resource = pxa27x_ac97_resources,
  411. };
  412. /*
  413. * enable generic access to the base board control CPLDs U6 and U7
  414. */
  415. static struct map_desc pcm990_io_desc[] __initdata = {
  416. {
  417. .virtual = PCM990_CTRL_BASE,
  418. .pfn = __phys_to_pfn(PCM990_CTRL_PHYS),
  419. .length = PCM990_CTRL_SIZE,
  420. .type = MT_DEVICE /* CPLD */
  421. }, {
  422. .virtual = PCM990_CF_PLD_BASE,
  423. .pfn = __phys_to_pfn(PCM990_CF_PLD_PHYS),
  424. .length = PCM990_CF_PLD_SIZE,
  425. .type = MT_DEVICE /* CPLD */
  426. }
  427. };
  428. /*
  429. * system init for baseboard usage. Will be called by pcm027 init.
  430. *
  431. * Add platform devices present on this baseboard and init
  432. * them from CPU side as far as required to use them later on
  433. */
  434. void __init pcm990_baseboard_init(void)
  435. {
  436. /* register CPLD access */
  437. iotable_init(pcm990_io_desc, ARRAY_SIZE(pcm990_io_desc));
  438. /* register CPLD's IRQ controller */
  439. pcm990_init_irq();
  440. #ifndef CONFIG_PCM990_DISPLAY_NONE
  441. set_pxa_fb_info(&pcm990_fbinfo);
  442. #endif
  443. pxa_gpio_mode(GPIO16_PWM0_MD);
  444. platform_device_register(&pcm990_backlight_device);
  445. platform_device_register(&pxa27x_device_ac97);
  446. /* MMC */
  447. pxa_set_mci_info(&pcm990_mci_platform_data);
  448. /* USB host */
  449. pxa_set_ohci_info(&pcm990_ohci_platform_data);
  450. pxa_set_i2c_info(NULL);
  451. #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
  452. pxa_set_camera_info(&pcm990_pxacamera_platform_data);
  453. i2c_register_board_info(0, pcm990_i2c_devices,
  454. ARRAY_SIZE(pcm990_i2c_devices));
  455. #endif
  456. printk(KERN_INFO"PCM-990 Evaluation baseboard initialized\n");
  457. }