board-apollon.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. /*
  2. * linux/arch/arm/mach-omap2/board-apollon.c
  3. *
  4. * Copyright (C) 2005,2006 Samsung Electronics
  5. * Author: Kyungmin Park <kyungmin.park@samsung.com>
  6. *
  7. * Modified from mach-omap/omap2/board-h4.c
  8. *
  9. * Code for apollon OMAP2 board. Should work on many OMAP2 systems where
  10. * the bootloader passes the board-specific data to the kernel.
  11. * Do not put any board specific code to this file; create a new machine
  12. * type if you need custom low-level initializations.
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License version 2 as
  16. * published by the Free Software Foundation.
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/mtd/mtd.h>
  22. #include <linux/mtd/partitions.h>
  23. #include <linux/mtd/onenand.h>
  24. #include <linux/irq.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/delay.h>
  27. #include <linux/leds.h>
  28. #include <linux/irq.h>
  29. #include <asm/hardware.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/flash.h>
  33. #include <asm/arch/gpio.h>
  34. #include <asm/arch/led.h>
  35. #include <asm/arch/mux.h>
  36. #include <asm/arch/usb.h>
  37. #include <asm/arch/board.h>
  38. #include <asm/arch/common.h>
  39. #include <asm/arch/gpmc.h>
  40. #include "prcm-regs.h"
  41. /* LED & Switch macros */
  42. #define LED0_GPIO13 13
  43. #define LED1_GPIO14 14
  44. #define LED2_GPIO15 15
  45. #define SW_ENTER_GPIO16 16
  46. #define SW_UP_GPIO17 17
  47. #define SW_DOWN_GPIO58 58
  48. #define APOLLON_FLASH_CS 0
  49. #define APOLLON_ETH_CS 1
  50. static struct mtd_partition apollon_partitions[] = {
  51. {
  52. .name = "X-Loader + U-Boot",
  53. .offset = 0,
  54. .size = SZ_128K,
  55. .mask_flags = MTD_WRITEABLE,
  56. },
  57. {
  58. .name = "params",
  59. .offset = MTDPART_OFS_APPEND,
  60. .size = SZ_128K,
  61. },
  62. {
  63. .name = "kernel",
  64. .offset = MTDPART_OFS_APPEND,
  65. .size = SZ_2M,
  66. },
  67. {
  68. .name = "rootfs",
  69. .offset = MTDPART_OFS_APPEND,
  70. .size = SZ_16M,
  71. },
  72. {
  73. .name = "filesystem00",
  74. .offset = MTDPART_OFS_APPEND,
  75. .size = SZ_32M,
  76. },
  77. {
  78. .name = "filesystem01",
  79. .offset = MTDPART_OFS_APPEND,
  80. .size = MTDPART_SIZ_FULL,
  81. },
  82. };
  83. static struct flash_platform_data apollon_flash_data = {
  84. .parts = apollon_partitions,
  85. .nr_parts = ARRAY_SIZE(apollon_partitions),
  86. };
  87. static struct resource apollon_flash_resource[] = {
  88. [0] = {
  89. .flags = IORESOURCE_MEM,
  90. },
  91. };
  92. static struct platform_device apollon_onenand_device = {
  93. .name = "onenand",
  94. .id = -1,
  95. .dev = {
  96. .platform_data = &apollon_flash_data,
  97. },
  98. .num_resources = ARRAY_SIZE(apollon_flash_resource),
  99. .resource = apollon_flash_resource,
  100. };
  101. static void __init apollon_flash_init(void)
  102. {
  103. unsigned long base;
  104. if (gpmc_cs_request(APOLLON_FLASH_CS, SZ_128K, &base) < 0) {
  105. printk(KERN_ERR "Cannot request OneNAND GPMC CS\n");
  106. return;
  107. }
  108. apollon_flash_resource[0].start = base;
  109. apollon_flash_resource[0].end = base + SZ_128K - 1;
  110. }
  111. static struct resource apollon_smc91x_resources[] = {
  112. [0] = {
  113. .flags = IORESOURCE_MEM,
  114. },
  115. [1] = {
  116. .start = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
  117. .end = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
  118. .flags = IORESOURCE_IRQ,
  119. },
  120. };
  121. static struct platform_device apollon_smc91x_device = {
  122. .name = "smc91x",
  123. .id = -1,
  124. .num_resources = ARRAY_SIZE(apollon_smc91x_resources),
  125. .resource = apollon_smc91x_resources,
  126. };
  127. static struct platform_device apollon_lcd_device = {
  128. .name = "apollon_lcd",
  129. .id = -1,
  130. };
  131. static struct omap_led_config apollon_led_config[] = {
  132. {
  133. .cdev = {
  134. .name = "apollon:led0",
  135. },
  136. .gpio = LED0_GPIO13,
  137. },
  138. {
  139. .cdev = {
  140. .name = "apollon:led1",
  141. },
  142. .gpio = LED1_GPIO14,
  143. },
  144. {
  145. .cdev = {
  146. .name = "apollon:led2",
  147. },
  148. .gpio = LED2_GPIO15,
  149. },
  150. };
  151. static struct omap_led_platform_data apollon_led_data = {
  152. .nr_leds = ARRAY_SIZE(apollon_led_config),
  153. .leds = apollon_led_config,
  154. };
  155. static struct platform_device apollon_led_device = {
  156. .name = "omap-led",
  157. .id = -1,
  158. .dev = {
  159. .platform_data = &apollon_led_data,
  160. },
  161. };
  162. static struct platform_device *apollon_devices[] __initdata = {
  163. &apollon_onenand_device,
  164. &apollon_smc91x_device,
  165. &apollon_lcd_device,
  166. &apollon_led_device,
  167. };
  168. static inline void __init apollon_init_smc91x(void)
  169. {
  170. unsigned long base;
  171. /* Make sure CS1 timings are correct */
  172. GPMC_CONFIG1_1 = 0x00011203;
  173. GPMC_CONFIG2_1 = 0x001f1f01;
  174. GPMC_CONFIG3_1 = 0x00080803;
  175. GPMC_CONFIG4_1 = 0x1c091c09;
  176. GPMC_CONFIG5_1 = 0x041f1f1f;
  177. GPMC_CONFIG6_1 = 0x000004c4;
  178. if (gpmc_cs_request(APOLLON_ETH_CS, SZ_16M, &base) < 0) {
  179. printk(KERN_ERR "Failed to request GPMC CS for smc91x\n");
  180. return;
  181. }
  182. apollon_smc91x_resources[0].start = base + 0x300;
  183. apollon_smc91x_resources[0].end = base + 0x30f;
  184. udelay(100);
  185. omap_cfg_reg(W4__24XX_GPIO74);
  186. if (omap_request_gpio(APOLLON_ETHR_GPIO_IRQ) < 0) {
  187. printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
  188. APOLLON_ETHR_GPIO_IRQ);
  189. gpmc_cs_free(APOLLON_ETH_CS);
  190. return;
  191. }
  192. omap_set_gpio_direction(APOLLON_ETHR_GPIO_IRQ, 1);
  193. }
  194. static void __init omap_apollon_init_irq(void)
  195. {
  196. omap2_init_common_hw();
  197. omap_init_irq();
  198. omap_gpio_init();
  199. apollon_init_smc91x();
  200. }
  201. static struct omap_uart_config apollon_uart_config __initdata = {
  202. .enabled_uarts = (1 << 0) | (0 << 1) | (0 << 2),
  203. };
  204. static struct omap_mmc_config apollon_mmc_config __initdata = {
  205. .mmc [0] = {
  206. .enabled = 1,
  207. .wire4 = 1,
  208. .wp_pin = -1,
  209. .power_pin = -1,
  210. .switch_pin = -1,
  211. },
  212. };
  213. static struct omap_usb_config apollon_usb_config __initdata = {
  214. .register_dev = 1,
  215. .hmc_mode = 0x14, /* 0:dev 1:host1 2:disable */
  216. .pins[0] = 6,
  217. };
  218. static struct omap_lcd_config apollon_lcd_config __initdata = {
  219. .ctrl_name = "internal",
  220. };
  221. static struct omap_board_config_kernel apollon_config[] = {
  222. { OMAP_TAG_UART, &apollon_uart_config },
  223. { OMAP_TAG_MMC, &apollon_mmc_config },
  224. { OMAP_TAG_USB, &apollon_usb_config },
  225. { OMAP_TAG_LCD, &apollon_lcd_config },
  226. };
  227. static void __init apollon_led_init(void)
  228. {
  229. /* LED0 - AA10 */
  230. omap_cfg_reg(AA10_242X_GPIO13);
  231. omap_request_gpio(LED0_GPIO13);
  232. omap_set_gpio_direction(LED0_GPIO13, 0);
  233. omap_set_gpio_dataout(LED0_GPIO13, 0);
  234. /* LED1 - AA6 */
  235. omap_cfg_reg(AA6_242X_GPIO14);
  236. omap_request_gpio(LED1_GPIO14);
  237. omap_set_gpio_direction(LED1_GPIO14, 0);
  238. omap_set_gpio_dataout(LED1_GPIO14, 0);
  239. /* LED2 - AA4 */
  240. omap_cfg_reg(AA4_242X_GPIO15);
  241. omap_request_gpio(LED2_GPIO15);
  242. omap_set_gpio_direction(LED2_GPIO15, 0);
  243. omap_set_gpio_dataout(LED2_GPIO15, 0);
  244. }
  245. static irqreturn_t apollon_sw_interrupt(int irq, void *ignored)
  246. {
  247. static unsigned int led0, led1, led2;
  248. if (irq == OMAP_GPIO_IRQ(SW_ENTER_GPIO16))
  249. omap_set_gpio_dataout(LED0_GPIO13, led0 ^= 1);
  250. else if (irq == OMAP_GPIO_IRQ(SW_UP_GPIO17))
  251. omap_set_gpio_dataout(LED1_GPIO14, led1 ^= 1);
  252. else if (irq == OMAP_GPIO_IRQ(SW_DOWN_GPIO58))
  253. omap_set_gpio_dataout(LED2_GPIO15, led2 ^= 1);
  254. return IRQ_HANDLED;
  255. }
  256. static void __init apollon_sw_init(void)
  257. {
  258. /* Enter SW - Y11 */
  259. omap_cfg_reg(Y11_242X_GPIO16);
  260. omap_request_gpio(SW_ENTER_GPIO16);
  261. omap_set_gpio_direction(SW_ENTER_GPIO16, 1);
  262. /* Up SW - AA12 */
  263. omap_cfg_reg(AA12_242X_GPIO17);
  264. omap_request_gpio(SW_UP_GPIO17);
  265. omap_set_gpio_direction(SW_UP_GPIO17, 1);
  266. /* Down SW - AA8 */
  267. omap_cfg_reg(AA8_242X_GPIO58);
  268. omap_request_gpio(SW_DOWN_GPIO58);
  269. omap_set_gpio_direction(SW_DOWN_GPIO58, 1);
  270. set_irq_type(OMAP_GPIO_IRQ(SW_ENTER_GPIO16), IRQT_RISING);
  271. if (request_irq(OMAP_GPIO_IRQ(SW_ENTER_GPIO16), &apollon_sw_interrupt,
  272. IRQF_SHARED, "enter sw",
  273. &apollon_sw_interrupt))
  274. return;
  275. set_irq_type(OMAP_GPIO_IRQ(SW_UP_GPIO17), IRQT_RISING);
  276. if (request_irq(OMAP_GPIO_IRQ(SW_UP_GPIO17), &apollon_sw_interrupt,
  277. IRQF_SHARED, "up sw",
  278. &apollon_sw_interrupt))
  279. return;
  280. set_irq_type(OMAP_GPIO_IRQ(SW_DOWN_GPIO58), IRQT_RISING);
  281. if (request_irq(OMAP_GPIO_IRQ(SW_DOWN_GPIO58), &apollon_sw_interrupt,
  282. IRQF_SHARED, "down sw",
  283. &apollon_sw_interrupt))
  284. return;
  285. }
  286. static void __init apollon_usb_init(void)
  287. {
  288. /* USB device */
  289. /* DEVICE_SUSPEND */
  290. omap_cfg_reg(P21_242X_GPIO12);
  291. omap_request_gpio(12);
  292. omap_set_gpio_direction(12, 0); /* OUT */
  293. omap_set_gpio_dataout(12, 0);
  294. }
  295. static void __init omap_apollon_init(void)
  296. {
  297. apollon_led_init();
  298. apollon_sw_init();
  299. apollon_flash_init();
  300. apollon_usb_init();
  301. /* REVISIT: where's the correct place */
  302. omap_cfg_reg(W19_24XX_SYS_NIRQ);
  303. /* Use Interal loop-back in MMC/SDIO Module Input Clock selection */
  304. CONTROL_DEVCONF |= (1 << 24);
  305. /*
  306. * Make sure the serial ports are muxed on at this point.
  307. * You have to mux them off in device drivers later on
  308. * if not needed.
  309. */
  310. platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices));
  311. omap_board_config = apollon_config;
  312. omap_board_config_size = ARRAY_SIZE(apollon_config);
  313. omap_serial_init();
  314. }
  315. static void __init omap_apollon_map_io(void)
  316. {
  317. omap2_map_common_io();
  318. }
  319. MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon")
  320. /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
  321. .phys_io = 0x48000000,
  322. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  323. .boot_params = 0x80000100,
  324. .map_io = omap_apollon_map_io,
  325. .init_irq = omap_apollon_init_irq,
  326. .init_machine = omap_apollon_init,
  327. .timer = &omap_timer,
  328. MACHINE_END