board-apollon.c 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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/delay.h>
  25. #include <linux/leds.h>
  26. #include <linux/err.h>
  27. #include <linux/clk.h>
  28. #include <mach/hardware.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/flash.h>
  32. #include <mach/gpio.h>
  33. #include <mach/led.h>
  34. #include <mach/mux.h>
  35. #include <mach/usb.h>
  36. #include <mach/board.h>
  37. #include <mach/common.h>
  38. #include <mach/gpmc.h>
  39. #include <mach/control.h>
  40. /* LED & Switch macros */
  41. #define LED0_GPIO13 13
  42. #define LED1_GPIO14 14
  43. #define LED2_GPIO15 15
  44. #define SW_ENTER_GPIO16 16
  45. #define SW_UP_GPIO17 17
  46. #define SW_DOWN_GPIO58 58
  47. #define APOLLON_FLASH_CS 0
  48. #define APOLLON_ETH_CS 1
  49. static struct mtd_partition apollon_partitions[] = {
  50. {
  51. .name = "X-Loader + U-Boot",
  52. .offset = 0,
  53. .size = SZ_128K,
  54. .mask_flags = MTD_WRITEABLE,
  55. },
  56. {
  57. .name = "params",
  58. .offset = MTDPART_OFS_APPEND,
  59. .size = SZ_128K,
  60. },
  61. {
  62. .name = "kernel",
  63. .offset = MTDPART_OFS_APPEND,
  64. .size = SZ_2M,
  65. },
  66. {
  67. .name = "rootfs",
  68. .offset = MTDPART_OFS_APPEND,
  69. .size = SZ_16M,
  70. },
  71. {
  72. .name = "filesystem00",
  73. .offset = MTDPART_OFS_APPEND,
  74. .size = SZ_32M,
  75. },
  76. {
  77. .name = "filesystem01",
  78. .offset = MTDPART_OFS_APPEND,
  79. .size = MTDPART_SIZ_FULL,
  80. },
  81. };
  82. static struct flash_platform_data apollon_flash_data = {
  83. .parts = apollon_partitions,
  84. .nr_parts = ARRAY_SIZE(apollon_partitions),
  85. };
  86. static struct resource apollon_flash_resource[] = {
  87. [0] = {
  88. .flags = IORESOURCE_MEM,
  89. },
  90. };
  91. static struct platform_device apollon_onenand_device = {
  92. .name = "onenand",
  93. .id = -1,
  94. .dev = {
  95. .platform_data = &apollon_flash_data,
  96. },
  97. .num_resources = ARRAY_SIZE(apollon_flash_resource),
  98. .resource = apollon_flash_resource,
  99. };
  100. static void __init apollon_flash_init(void)
  101. {
  102. unsigned long base;
  103. if (gpmc_cs_request(APOLLON_FLASH_CS, SZ_128K, &base) < 0) {
  104. printk(KERN_ERR "Cannot request OneNAND GPMC CS\n");
  105. return;
  106. }
  107. apollon_flash_resource[0].start = base;
  108. apollon_flash_resource[0].end = base + SZ_128K - 1;
  109. }
  110. static struct resource apollon_smc91x_resources[] = {
  111. [0] = {
  112. .flags = IORESOURCE_MEM,
  113. },
  114. [1] = {
  115. .start = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
  116. .end = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
  117. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  118. },
  119. };
  120. static struct platform_device apollon_smc91x_device = {
  121. .name = "smc91x",
  122. .id = -1,
  123. .num_resources = ARRAY_SIZE(apollon_smc91x_resources),
  124. .resource = apollon_smc91x_resources,
  125. };
  126. static struct platform_device apollon_lcd_device = {
  127. .name = "apollon_lcd",
  128. .id = -1,
  129. };
  130. static struct omap_led_config apollon_led_config[] = {
  131. {
  132. .cdev = {
  133. .name = "apollon:led0",
  134. },
  135. .gpio = LED0_GPIO13,
  136. },
  137. {
  138. .cdev = {
  139. .name = "apollon:led1",
  140. },
  141. .gpio = LED1_GPIO14,
  142. },
  143. {
  144. .cdev = {
  145. .name = "apollon:led2",
  146. },
  147. .gpio = LED2_GPIO15,
  148. },
  149. };
  150. static struct omap_led_platform_data apollon_led_data = {
  151. .nr_leds = ARRAY_SIZE(apollon_led_config),
  152. .leds = apollon_led_config,
  153. };
  154. static struct platform_device apollon_led_device = {
  155. .name = "omap-led",
  156. .id = -1,
  157. .dev = {
  158. .platform_data = &apollon_led_data,
  159. },
  160. };
  161. static struct platform_device *apollon_devices[] __initdata = {
  162. &apollon_onenand_device,
  163. &apollon_smc91x_device,
  164. &apollon_lcd_device,
  165. &apollon_led_device,
  166. };
  167. static inline void __init apollon_init_smc91x(void)
  168. {
  169. unsigned long base;
  170. unsigned int rate;
  171. struct clk *gpmc_fck;
  172. int eth_cs;
  173. gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
  174. if (IS_ERR(gpmc_fck)) {
  175. WARN_ON(1);
  176. return;
  177. }
  178. clk_enable(gpmc_fck);
  179. rate = clk_get_rate(gpmc_fck);
  180. eth_cs = APOLLON_ETH_CS;
  181. /* Make sure CS1 timings are correct */
  182. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
  183. if (rate >= 160000000) {
  184. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
  185. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
  186. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
  187. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
  188. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
  189. } else if (rate >= 130000000) {
  190. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
  191. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
  192. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
  193. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
  194. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
  195. } else {/* rate = 100000000 */
  196. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
  197. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
  198. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
  199. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
  200. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
  201. }
  202. if (gpmc_cs_request(APOLLON_ETH_CS, SZ_16M, &base) < 0) {
  203. printk(KERN_ERR "Failed to request GPMC CS for smc91x\n");
  204. goto out;
  205. }
  206. apollon_smc91x_resources[0].start = base + 0x300;
  207. apollon_smc91x_resources[0].end = base + 0x30f;
  208. udelay(100);
  209. omap_cfg_reg(W4__24XX_GPIO74);
  210. if (gpio_request(APOLLON_ETHR_GPIO_IRQ, "SMC91x irq") < 0) {
  211. printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
  212. APOLLON_ETHR_GPIO_IRQ);
  213. gpmc_cs_free(APOLLON_ETH_CS);
  214. goto out;
  215. }
  216. gpio_direction_input(APOLLON_ETHR_GPIO_IRQ);
  217. out:
  218. clk_disable(gpmc_fck);
  219. clk_put(gpmc_fck);
  220. }
  221. static void __init omap_apollon_init_irq(void)
  222. {
  223. omap2_init_common_hw();
  224. omap_init_irq();
  225. omap_gpio_init();
  226. apollon_init_smc91x();
  227. }
  228. static struct omap_uart_config apollon_uart_config __initdata = {
  229. .enabled_uarts = (1 << 0) | (0 << 1) | (0 << 2),
  230. };
  231. static struct omap_usb_config apollon_usb_config __initdata = {
  232. .register_dev = 1,
  233. .hmc_mode = 0x14, /* 0:dev 1:host1 2:disable */
  234. .pins[0] = 6,
  235. };
  236. static struct omap_lcd_config apollon_lcd_config __initdata = {
  237. .ctrl_name = "internal",
  238. };
  239. static struct omap_board_config_kernel apollon_config[] = {
  240. { OMAP_TAG_UART, &apollon_uart_config },
  241. { OMAP_TAG_USB, &apollon_usb_config },
  242. { OMAP_TAG_LCD, &apollon_lcd_config },
  243. };
  244. static void __init apollon_led_init(void)
  245. {
  246. /* LED0 - AA10 */
  247. omap_cfg_reg(AA10_242X_GPIO13);
  248. gpio_request(LED0_GPIO13, "LED0");
  249. gpio_direction_output(LED0_GPIO13, 0);
  250. /* LED1 - AA6 */
  251. omap_cfg_reg(AA6_242X_GPIO14);
  252. gpio_request(LED1_GPIO14, "LED1");
  253. gpio_direction_output(LED1_GPIO14, 0);
  254. /* LED2 - AA4 */
  255. omap_cfg_reg(AA4_242X_GPIO15);
  256. gpio_request(LED2_GPIO15, "LED2");
  257. gpio_direction_output(LED2_GPIO15, 0);
  258. }
  259. static void __init apollon_usb_init(void)
  260. {
  261. /* USB device */
  262. /* DEVICE_SUSPEND */
  263. omap_cfg_reg(P21_242X_GPIO12);
  264. gpio_request(12, "USB suspend");
  265. gpio_direction_output(12, 0);
  266. }
  267. static void __init omap_apollon_init(void)
  268. {
  269. u32 v;
  270. apollon_led_init();
  271. apollon_flash_init();
  272. apollon_usb_init();
  273. /* REVISIT: where's the correct place */
  274. omap_cfg_reg(W19_24XX_SYS_NIRQ);
  275. /* Use Interal loop-back in MMC/SDIO Module Input Clock selection */
  276. v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
  277. v |= (1 << 24);
  278. omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
  279. /*
  280. * Make sure the serial ports are muxed on at this point.
  281. * You have to mux them off in device drivers later on
  282. * if not needed.
  283. */
  284. platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices));
  285. omap_board_config = apollon_config;
  286. omap_board_config_size = ARRAY_SIZE(apollon_config);
  287. omap_serial_init();
  288. }
  289. static void __init omap_apollon_map_io(void)
  290. {
  291. omap2_set_globals_242x();
  292. omap2_map_common_io();
  293. }
  294. MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon")
  295. /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
  296. .phys_io = 0x48000000,
  297. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  298. .boot_params = 0x80000100,
  299. .map_io = omap_apollon_map_io,
  300. .init_irq = omap_apollon_init_irq,
  301. .init_machine = omap_apollon_init,
  302. .timer = &omap_timer,
  303. MACHINE_END