trizeps4.c 12 KB

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