trizeps4.c 12 KB

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