trizeps4.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. /*
  2. * linux/arch/arm/mach-pxa/trizeps4.c
  3. *
  4. * Support for the Keith und Koep Trizeps4 Module Platform.
  5. *
  6. * Author: Jürgen Schindele
  7. * Created: 20 02, 2006
  8. * Copyright: Jürgen Schindele
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/kernel.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/sysdev.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/sched.h>
  20. #include <linux/bitops.h>
  21. #include <linux/fb.h>
  22. #include <linux/ioport.h>
  23. #include <linux/delay.h>
  24. #include <linux/serial_8250.h>
  25. #include <linux/mtd/mtd.h>
  26. #include <linux/mtd/physmap.h>
  27. #include <linux/mtd/partitions.h>
  28. #include <asm/types.h>
  29. #include <asm/setup.h>
  30. #include <asm/memory.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/hardware.h>
  33. #include <asm/irq.h>
  34. #include <asm/sizes.h>
  35. #include <asm/mach/arch.h>
  36. #include <asm/mach/map.h>
  37. #include <asm/mach/irq.h>
  38. #include <asm/mach/flash.h>
  39. #include <asm/arch/pxa-regs.h>
  40. #include <asm/arch/pxa2xx-regs.h>
  41. #include <asm/arch/pxa2xx-gpio.h>
  42. #include <asm/arch/trizeps4.h>
  43. #include <asm/arch/audio.h>
  44. #include <asm/arch/pxafb.h>
  45. #include <asm/arch/mmc.h>
  46. #include <asm/arch/irda.h>
  47. #include <asm/arch/ohci.h>
  48. #include "generic.h"
  49. #include "devices.h"
  50. /********************************************************************************************
  51. * ONBOARD FLASH
  52. ********************************************************************************************/
  53. static struct mtd_partition trizeps4_partitions[] = {
  54. {
  55. .name = "Bootloader",
  56. .offset = 0x00000000,
  57. .size = 0x00040000,
  58. .mask_flags = MTD_WRITEABLE /* force read-only */
  59. },{
  60. .name = "Backup",
  61. .offset = 0x00040000,
  62. .size = 0x00040000,
  63. },{
  64. .name = "Image",
  65. .offset = 0x00080000,
  66. .size = 0x01080000,
  67. },{
  68. .name = "IPSM",
  69. .offset = 0x01100000,
  70. .size = 0x00e00000,
  71. },{
  72. .name = "Registry",
  73. .offset = 0x01f00000,
  74. .size = MTDPART_SIZ_FULL,
  75. }
  76. };
  77. static struct physmap_flash_data trizeps4_flash_data[] = {
  78. {
  79. .width = 4, /* bankwidth in bytes */
  80. .parts = trizeps4_partitions,
  81. .nr_parts = ARRAY_SIZE(trizeps4_partitions)
  82. }
  83. };
  84. static struct resource flash_resource = {
  85. .start = PXA_CS0_PHYS,
  86. .end = PXA_CS0_PHYS + SZ_32M - 1,
  87. .flags = IORESOURCE_MEM,
  88. };
  89. static struct platform_device flash_device = {
  90. .name = "physmap-flash",
  91. .id = 0,
  92. .dev = {
  93. .platform_data = trizeps4_flash_data,
  94. },
  95. .resource = &flash_resource,
  96. .num_resources = 1,
  97. };
  98. /********************************************************************************************
  99. * DAVICOM DM9000 Ethernet
  100. ********************************************************************************************/
  101. static struct resource dm9000_resources[] = {
  102. [0] = {
  103. .start = TRIZEPS4_ETH_PHYS+0x300,
  104. .end = TRIZEPS4_ETH_PHYS+0x400-1,
  105. .flags = IORESOURCE_MEM,
  106. },
  107. [1] = {
  108. .start = TRIZEPS4_ETH_PHYS+0x8300,
  109. .end = TRIZEPS4_ETH_PHYS+0x8400-1,
  110. .flags = IORESOURCE_MEM,
  111. },
  112. [2] = {
  113. .start = TRIZEPS4_ETH_IRQ,
  114. .end = TRIZEPS4_ETH_IRQ,
  115. .flags = (IORESOURCE_IRQ | IRQT_RISING),
  116. },
  117. };
  118. static struct platform_device dm9000_device = {
  119. .name = "dm9000",
  120. .id = -1,
  121. .num_resources = ARRAY_SIZE(dm9000_resources),
  122. .resource = dm9000_resources,
  123. };
  124. /********************************************************************************************
  125. * PXA270 serial ports
  126. ********************************************************************************************/
  127. static struct plat_serial8250_port tri_serial_ports[] = {
  128. #ifdef CONFIG_SERIAL_PXA
  129. /* this uses the own PXA driver */
  130. {
  131. 0,
  132. },
  133. #else
  134. /* this uses the generic 8520 driver */
  135. [0] = {
  136. .membase = (void *)&FFUART,
  137. .irq = IRQ_FFUART,
  138. .flags = UPF_BOOT_AUTOCONF,
  139. .iotype = UPIO_MEM32,
  140. .regshift = 2,
  141. .uartclk = (921600*16),
  142. },
  143. [1] = {
  144. .membase = (void *)&BTUART,
  145. .irq = IRQ_BTUART,
  146. .flags = UPF_BOOT_AUTOCONF,
  147. .iotype = UPIO_MEM32,
  148. .regshift = 2,
  149. .uartclk = (921600*16),
  150. },
  151. {
  152. 0,
  153. },
  154. #endif
  155. };
  156. static struct platform_device uart_devices = {
  157. .name = "serial8250",
  158. .id = 0,
  159. .dev = {
  160. .platform_data = tri_serial_ports,
  161. },
  162. .num_resources = 0,
  163. .resource = NULL,
  164. };
  165. static struct platform_device * trizeps4_devices[] __initdata = {
  166. &flash_device,
  167. &uart_devices,
  168. &dm9000_device,
  169. };
  170. #ifdef CONFIG_MACH_TRIZEPS4_CONXS
  171. static short trizeps_conxs_bcr;
  172. /* PCCARD power switching supports only 3,3V */
  173. void board_pcmcia_power(int power)
  174. {
  175. if (power) {
  176. /* switch power on, put in reset and enable buffers */
  177. trizeps_conxs_bcr |= power;
  178. trizeps_conxs_bcr |= ConXS_BCR_CF_RESET;
  179. trizeps_conxs_bcr &= ~(ConXS_BCR_CF_BUF_EN);
  180. ConXS_BCR = trizeps_conxs_bcr;
  181. /* wait a little */
  182. udelay(2000);
  183. /* take reset away */
  184. trizeps_conxs_bcr &= ~(ConXS_BCR_CF_RESET);
  185. ConXS_BCR = trizeps_conxs_bcr;
  186. udelay(2000);
  187. } else {
  188. /* put in reset */
  189. trizeps_conxs_bcr |= ConXS_BCR_CF_RESET;
  190. ConXS_BCR = trizeps_conxs_bcr;
  191. udelay(1000);
  192. /* switch power off */
  193. trizeps_conxs_bcr &= ~(0xf);
  194. ConXS_BCR = trizeps_conxs_bcr;
  195. }
  196. pr_debug("%s: o%s 0x%x\n", __func__, power ? "n": "ff", trizeps_conxs_bcr);
  197. }
  198. /* backlight power switching for LCD panel */
  199. static void board_backlight_power(int on)
  200. {
  201. if (on) {
  202. trizeps_conxs_bcr |= ConXS_BCR_L_DISP;
  203. } else {
  204. trizeps_conxs_bcr &= ~ConXS_BCR_L_DISP;
  205. }
  206. pr_debug("%s: o%s 0x%x\n", __func__, on ? "n" : "ff", trizeps_conxs_bcr);
  207. ConXS_BCR = trizeps_conxs_bcr;
  208. }
  209. /* Powersupply for MMC/SD cardslot */
  210. static void board_mci_power(struct device *dev, unsigned int vdd)
  211. {
  212. struct pxamci_platform_data* p_d = dev->platform_data;
  213. if (( 1 << vdd) & p_d->ocr_mask) {
  214. pr_debug("%s: on\n", __func__);
  215. /* FIXME fill in values here */
  216. } else {
  217. pr_debug("%s: off\n", __func__);
  218. /* FIXME fill in values here */
  219. }
  220. }
  221. static short trizeps_conxs_ircr;
  222. /* Switch modes and Power for IRDA receiver */
  223. static void board_irda_mode(struct device *dev, int mode)
  224. {
  225. unsigned long flags;
  226. local_irq_save(flags);
  227. if (mode & IR_SIRMODE) {
  228. /* Slow mode */
  229. trizeps_conxs_ircr &= ~ConXS_IRCR_MODE;
  230. } else if (mode & IR_FIRMODE) {
  231. /* Fast mode */
  232. trizeps_conxs_ircr |= ConXS_IRCR_MODE;
  233. }
  234. if (mode & IR_OFF) {
  235. trizeps_conxs_ircr |= ConXS_IRCR_SD;
  236. } else {
  237. trizeps_conxs_ircr &= ~ConXS_IRCR_SD;
  238. }
  239. /* FIXME write values to register */
  240. local_irq_restore(flags);
  241. }
  242. #else
  243. /* for other baseboards define dummies */
  244. void board_pcmcia_power(int power) {;}
  245. #define board_backlight_power NULL
  246. #define board_mci_power NULL
  247. #define board_irda_mode NULL
  248. #endif /* CONFIG_MACH_TRIZEPS4_CONXS */
  249. EXPORT_SYMBOL(board_pcmcia_power);
  250. static int trizeps4_mci_init(struct device *dev, irq_handler_t mci_detect_int, void *data)
  251. {
  252. int err;
  253. /* setup GPIO for PXA27x MMC controller */
  254. pxa_gpio_mode(GPIO32_MMCCLK_MD);
  255. pxa_gpio_mode(GPIO112_MMCCMD_MD);
  256. pxa_gpio_mode(GPIO92_MMCDAT0_MD);
  257. pxa_gpio_mode(GPIO109_MMCDAT1_MD);
  258. pxa_gpio_mode(GPIO110_MMCDAT2_MD);
  259. pxa_gpio_mode(GPIO111_MMCDAT3_MD);
  260. pxa_gpio_mode(GPIO_MMC_DET | GPIO_IN);
  261. err = request_irq(TRIZEPS4_MMC_IRQ, mci_detect_int,
  262. IRQF_DISABLED | IRQF_TRIGGER_RISING,
  263. "MMC card detect", data);
  264. if (err)
  265. printk(KERN_ERR "trizeps4_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
  266. return err;
  267. }
  268. static void trizeps4_mci_exit(struct device *dev, void *data)
  269. {
  270. free_irq(TRIZEPS4_MMC_IRQ, data);
  271. }
  272. static struct pxamci_platform_data trizeps4_mci_platform_data = {
  273. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  274. .init = trizeps4_mci_init,
  275. .exit = trizeps4_mci_exit,
  276. .setpower = board_mci_power,
  277. };
  278. static struct pxaficp_platform_data trizeps4_ficp_platform_data = {
  279. .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
  280. .transceiver_mode = board_irda_mode,
  281. };
  282. static int trizeps4_ohci_init(struct device *dev)
  283. {
  284. /* setup Port1 GPIO pin. */
  285. pxa_gpio_mode( 88 | GPIO_ALT_FN_1_IN); /* USBHPWR1 */
  286. pxa_gpio_mode( 89 | GPIO_ALT_FN_2_OUT); /* USBHPEN1 */
  287. /* Set the Power Control Polarity Low and Power Sense
  288. Polarity Low to active low. */
  289. UHCHR = (UHCHR | UHCHR_PCPL | UHCHR_PSPL) &
  290. ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
  291. return 0;
  292. }
  293. static void trizeps4_ohci_exit(struct device *dev)
  294. {
  295. ;
  296. }
  297. static struct pxaohci_platform_data trizeps4_ohci_platform_data = {
  298. .port_mode = PMM_PERPORT_MODE,
  299. .init = trizeps4_ohci_init,
  300. .exit = trizeps4_ohci_exit,
  301. };
  302. static struct map_desc trizeps4_io_desc[] __initdata = {
  303. { /* ConXS CFSR */
  304. .virtual = TRIZEPS4_CFSR_VIRT,
  305. .pfn = __phys_to_pfn(TRIZEPS4_CFSR_PHYS),
  306. .length = 0x00001000,
  307. .type = MT_DEVICE
  308. },
  309. { /* ConXS BCR */
  310. .virtual = TRIZEPS4_BOCR_VIRT,
  311. .pfn = __phys_to_pfn(TRIZEPS4_BOCR_PHYS),
  312. .length = 0x00001000,
  313. .type = MT_DEVICE
  314. },
  315. { /* ConXS IRCR */
  316. .virtual = TRIZEPS4_IRCR_VIRT,
  317. .pfn = __phys_to_pfn(TRIZEPS4_IRCR_PHYS),
  318. .length = 0x00001000,
  319. .type = MT_DEVICE
  320. },
  321. { /* ConXS DCR */
  322. .virtual = TRIZEPS4_DICR_VIRT,
  323. .pfn = __phys_to_pfn(TRIZEPS4_DICR_PHYS),
  324. .length = 0x00001000,
  325. .type = MT_DEVICE
  326. },
  327. { /* ConXS UPSR */
  328. .virtual = TRIZEPS4_UPSR_VIRT,
  329. .pfn = __phys_to_pfn(TRIZEPS4_UPSR_PHYS),
  330. .length = 0x00001000,
  331. .type = MT_DEVICE
  332. }
  333. };
  334. static struct pxafb_mode_info sharp_lcd_mode = {
  335. .pixclock = 78000,
  336. .xres = 640,
  337. .yres = 480,
  338. .bpp = 8,
  339. .hsync_len = 4,
  340. .left_margin = 4,
  341. .right_margin = 4,
  342. .vsync_len = 2,
  343. .upper_margin = 0,
  344. .lower_margin = 0,
  345. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  346. .cmap_greyscale = 0,
  347. };
  348. static struct pxafb_mach_info sharp_lcd = {
  349. .modes = &sharp_lcd_mode,
  350. .num_modes = 1,
  351. .cmap_inverse = 0,
  352. .cmap_static = 0,
  353. .lccr0 = LCCR0_Color | LCCR0_Pas | LCCR0_Dual,
  354. .lccr3 = 0x0340ff02,
  355. .pxafb_backlight_power = board_backlight_power,
  356. };
  357. static struct pxafb_mode_info toshiba_lcd_mode = {
  358. .pixclock = 39720,
  359. .xres = 640,
  360. .yres = 480,
  361. .bpp = 8,
  362. .hsync_len = 63,
  363. .left_margin = 12,
  364. .right_margin = 12,
  365. .vsync_len = 4,
  366. .upper_margin = 32,
  367. .lower_margin = 10,
  368. .sync = 0,
  369. .cmap_greyscale = 0,
  370. };
  371. static struct pxafb_mach_info toshiba_lcd = {
  372. .modes = &toshiba_lcd_mode,
  373. .num_modes = 1,
  374. .cmap_inverse = 0,
  375. .cmap_static = 0,
  376. .lccr0 = LCCR0_Color | LCCR0_Act,
  377. .lccr3 = 0x03400002,
  378. .pxafb_backlight_power = board_backlight_power,
  379. };
  380. static void __init trizeps4_init(void)
  381. {
  382. platform_add_devices(trizeps4_devices, ARRAY_SIZE(trizeps4_devices));
  383. /* set_pxa_fb_info(&sharp_lcd); */
  384. set_pxa_fb_info(&toshiba_lcd);
  385. pxa_set_mci_info(&trizeps4_mci_platform_data);
  386. pxa_set_ficp_info(&trizeps4_ficp_platform_data);
  387. pxa_set_ohci_info(&trizeps4_ohci_platform_data);
  388. pxa_set_ac97_info(NULL);
  389. }
  390. static void __init trizeps4_map_io(void)
  391. {
  392. pxa_map_io();
  393. iotable_init(trizeps4_io_desc, ARRAY_SIZE(trizeps4_io_desc));
  394. /* for DiskOnChip */
  395. pxa_gpio_mode(GPIO15_nCS_1_MD);
  396. /* for off-module PIC on ConXS board */
  397. pxa_gpio_mode(GPIO_PIC | GPIO_IN);
  398. /* UCB1400 irq */
  399. pxa_gpio_mode(GPIO_UCB1400 | GPIO_IN);
  400. /* for DM9000 LAN */
  401. pxa_gpio_mode(GPIO78_nCS_2_MD);
  402. pxa_gpio_mode(GPIO_DM9000 | GPIO_IN);
  403. /* for PCMCIA device */
  404. pxa_gpio_mode(GPIO_PCD | GPIO_IN);
  405. pxa_gpio_mode(GPIO_PRDY | GPIO_IN);
  406. /* for I2C adapter */
  407. pxa_gpio_mode(GPIO117_I2CSCL_MD);
  408. pxa_gpio_mode(GPIO118_I2CSDA_MD);
  409. /* MMC_DET s.o. */
  410. pxa_gpio_mode(GPIO_MMC_DET | GPIO_IN);
  411. /* whats that for ??? */
  412. pxa_gpio_mode(GPIO79_nCS_3_MD);
  413. #ifdef CONFIG_LEDS
  414. pxa_gpio_mode( GPIO_SYS_BUSY_LED | GPIO_OUT); /* LED1 */
  415. pxa_gpio_mode( GPIO_HEARTBEAT_LED | GPIO_OUT); /* LED2 */
  416. #endif
  417. #ifdef CONFIG_MACH_TRIZEPS4_CONXS
  418. #ifdef CONFIG_IDE_PXA_CF
  419. /* if boot direct from compact flash dont disable power */
  420. trizeps_conxs_bcr = 0x0009;
  421. #else
  422. /* this is the reset value */
  423. trizeps_conxs_bcr = 0x00A0;
  424. #endif
  425. ConXS_BCR = trizeps_conxs_bcr;
  426. #endif
  427. #warning FIXME - accessing PM registers directly is deprecated
  428. PWER = 0x00000002;
  429. PFER = 0x00000000;
  430. PRER = 0x00000002;
  431. PGSR0 = 0x0158C000;
  432. PGSR1 = 0x00FF0080;
  433. PGSR2 = 0x0001C004;
  434. /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
  435. PCFR |= PCFR_OPDE;
  436. }
  437. MACHINE_START(TRIZEPS4, "Keith und Koep Trizeps IV module")
  438. /* MAINTAINER("Jürgen Schindele") */
  439. .phys_io = 0x40000000,
  440. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  441. .boot_params = TRIZEPS4_SDRAM_BASE + 0x100,
  442. .init_machine = trizeps4_init,
  443. .map_io = trizeps4_map_io,
  444. .init_irq = pxa27x_init_irq,
  445. .timer = &pxa_timer,
  446. MACHINE_END