board-apollon.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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 <linux/smc91x.h>
  29. #include <linux/gpio.h>
  30. #include <linux/platform_data/leds-omap.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/flash.h>
  34. #include "common.h"
  35. #include "gpmc.h"
  36. #include <video/omapdss.h>
  37. #include <video/omap-panel-generic-dpi.h>
  38. #include "mux.h"
  39. #include "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. #define APOLLON_ETHR_GPIO_IRQ 74
  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 onenand_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-flash",
  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 smc91x_platdata appolon_smc91x_info = {
  112. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  113. .leda = RPC_LED_100_10,
  114. .ledb = RPC_LED_TX_RX,
  115. };
  116. static struct resource apollon_smc91x_resources[] = {
  117. [0] = {
  118. .flags = IORESOURCE_MEM,
  119. },
  120. [1] = {
  121. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  122. },
  123. };
  124. static struct platform_device apollon_smc91x_device = {
  125. .name = "smc91x",
  126. .id = -1,
  127. .dev = {
  128. .platform_data = &appolon_smc91x_info,
  129. },
  130. .num_resources = ARRAY_SIZE(apollon_smc91x_resources),
  131. .resource = apollon_smc91x_resources,
  132. };
  133. static struct omap_led_config apollon_led_config[] = {
  134. {
  135. .cdev = {
  136. .name = "apollon:led0",
  137. },
  138. .gpio = LED0_GPIO13,
  139. },
  140. {
  141. .cdev = {
  142. .name = "apollon:led1",
  143. },
  144. .gpio = LED1_GPIO14,
  145. },
  146. {
  147. .cdev = {
  148. .name = "apollon:led2",
  149. },
  150. .gpio = LED2_GPIO15,
  151. },
  152. };
  153. static struct omap_led_platform_data apollon_led_data = {
  154. .nr_leds = ARRAY_SIZE(apollon_led_config),
  155. .leds = apollon_led_config,
  156. };
  157. static struct platform_device apollon_led_device = {
  158. .name = "omap-led",
  159. .id = -1,
  160. .dev = {
  161. .platform_data = &apollon_led_data,
  162. },
  163. };
  164. static struct platform_device *apollon_devices[] __initdata = {
  165. &apollon_onenand_device,
  166. &apollon_smc91x_device,
  167. &apollon_led_device,
  168. };
  169. static inline void __init apollon_init_smc91x(void)
  170. {
  171. unsigned long base;
  172. unsigned int rate;
  173. struct clk *gpmc_fck;
  174. int eth_cs;
  175. int err;
  176. gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
  177. if (IS_ERR(gpmc_fck)) {
  178. WARN_ON(1);
  179. return;
  180. }
  181. clk_prepare_enable(gpmc_fck);
  182. rate = clk_get_rate(gpmc_fck);
  183. eth_cs = APOLLON_ETH_CS;
  184. /* Make sure CS1 timings are correct */
  185. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
  186. if (rate >= 160000000) {
  187. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
  188. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
  189. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
  190. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
  191. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
  192. } else if (rate >= 130000000) {
  193. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
  194. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
  195. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
  196. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
  197. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
  198. } else {/* rate = 100000000 */
  199. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
  200. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
  201. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
  202. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
  203. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
  204. }
  205. if (gpmc_cs_request(APOLLON_ETH_CS, SZ_16M, &base) < 0) {
  206. printk(KERN_ERR "Failed to request GPMC CS for smc91x\n");
  207. goto out;
  208. }
  209. apollon_smc91x_resources[0].start = base + 0x300;
  210. apollon_smc91x_resources[0].end = base + 0x30f;
  211. udelay(100);
  212. omap_mux_init_gpio(APOLLON_ETHR_GPIO_IRQ, 0);
  213. err = gpio_request_one(APOLLON_ETHR_GPIO_IRQ, GPIOF_IN, "SMC91x irq");
  214. if (err) {
  215. printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
  216. APOLLON_ETHR_GPIO_IRQ);
  217. gpmc_cs_free(APOLLON_ETH_CS);
  218. }
  219. out:
  220. clk_disable_unprepare(gpmc_fck);
  221. clk_put(gpmc_fck);
  222. }
  223. static struct panel_generic_dpi_data apollon_panel_data = {
  224. .name = "apollon",
  225. };
  226. static struct omap_dss_device apollon_lcd_device = {
  227. .name = "lcd",
  228. .driver_name = "generic_dpi_panel",
  229. .type = OMAP_DISPLAY_TYPE_DPI,
  230. .phy.dpi.data_lines = 18,
  231. .data = &apollon_panel_data,
  232. };
  233. static struct omap_dss_device *apollon_dss_devices[] = {
  234. &apollon_lcd_device,
  235. };
  236. static struct omap_dss_board_info apollon_dss_data = {
  237. .num_devices = ARRAY_SIZE(apollon_dss_devices),
  238. .devices = apollon_dss_devices,
  239. .default_device = &apollon_lcd_device,
  240. };
  241. static struct gpio apollon_gpio_leds[] __initdata = {
  242. { LED0_GPIO13, GPIOF_OUT_INIT_LOW, "LED0" }, /* LED0 - AA10 */
  243. { LED1_GPIO14, GPIOF_OUT_INIT_LOW, "LED1" }, /* LED1 - AA6 */
  244. { LED2_GPIO15, GPIOF_OUT_INIT_LOW, "LED2" }, /* LED2 - AA4 */
  245. };
  246. static void __init apollon_led_init(void)
  247. {
  248. omap_mux_init_signal("vlynq_clk.gpio_13", 0);
  249. omap_mux_init_signal("vlynq_rx1.gpio_14", 0);
  250. omap_mux_init_signal("vlynq_rx0.gpio_15", 0);
  251. gpio_request_array(apollon_gpio_leds, ARRAY_SIZE(apollon_gpio_leds));
  252. }
  253. #ifdef CONFIG_OMAP_MUX
  254. static struct omap_board_mux board_mux[] __initdata = {
  255. { .reg_offset = OMAP_MUX_TERMINATOR },
  256. };
  257. #endif
  258. static void __init omap_apollon_init(void)
  259. {
  260. u32 v;
  261. omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAC);
  262. apollon_init_smc91x();
  263. apollon_led_init();
  264. apollon_flash_init();
  265. /* REVISIT: where's the correct place */
  266. omap_mux_init_signal("sys_nirq", OMAP_PULL_ENA | OMAP_PULL_UP);
  267. /* LCD PWR_EN */
  268. omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP);
  269. /* Use Internal loop-back in MMC/SDIO Module Input Clock selection */
  270. v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
  271. v |= (1 << 24);
  272. omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
  273. /*
  274. * Make sure the serial ports are muxed on at this point.
  275. * You have to mux them off in device drivers later on
  276. * if not needed.
  277. */
  278. apollon_smc91x_resources[1].start = gpio_to_irq(APOLLON_ETHR_GPIO_IRQ);
  279. apollon_smc91x_resources[1].end = gpio_to_irq(APOLLON_ETHR_GPIO_IRQ);
  280. platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices));
  281. omap_serial_init();
  282. omap_sdrc_init(NULL, NULL);
  283. omap_display_init(&apollon_dss_data);
  284. }
  285. MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon")
  286. /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
  287. .atag_offset = 0x100,
  288. .reserve = omap_reserve,
  289. .map_io = omap242x_map_io,
  290. .init_early = omap2420_init_early,
  291. .init_irq = omap2_init_irq,
  292. .handle_irq = omap2_intc_handle_irq,
  293. .init_machine = omap_apollon_init,
  294. .init_late = omap2420_init_late,
  295. .timer = &omap2_timer,
  296. .restart = omap2xxx_restart,
  297. MACHINE_END