board-omap3beagle.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. /*
  2. * linux/arch/arm/mach-omap2/board-omap3beagle.c
  3. *
  4. * Copyright (C) 2008 Texas Instruments
  5. *
  6. * Modified from mach-omap2/board-3430sdp.c
  7. *
  8. * Initial code: Syed Mohammed Khasim
  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/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/delay.h>
  18. #include <linux/err.h>
  19. #include <linux/clk.h>
  20. #include <linux/io.h>
  21. #include <linux/leds.h>
  22. #include <linux/gpio.h>
  23. #include <linux/input.h>
  24. #include <linux/gpio_keys.h>
  25. #include <linux/mtd/mtd.h>
  26. #include <linux/mtd/partitions.h>
  27. #include <linux/mtd/nand.h>
  28. #include <linux/i2c/twl4030.h>
  29. #include <mach/hardware.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/map.h>
  33. #include <asm/mach/flash.h>
  34. #include <mach/board.h>
  35. #include <mach/common.h>
  36. #include <mach/gpmc.h>
  37. #include <mach/nand.h>
  38. #include <mach/mux.h>
  39. #include <mach/usb.h>
  40. #include <mach/timer-gp.h>
  41. #include "mmc-twl4030.h"
  42. #define GPMC_CS0_BASE 0x60
  43. #define GPMC_CS_SIZE 0x30
  44. #define NAND_BLOCK_SIZE SZ_128K
  45. static struct mtd_partition omap3beagle_nand_partitions[] = {
  46. /* All the partition sizes are listed in terms of NAND block size */
  47. {
  48. .name = "X-Loader",
  49. .offset = 0,
  50. .size = 4 * NAND_BLOCK_SIZE,
  51. .mask_flags = MTD_WRITEABLE, /* force read-only */
  52. },
  53. {
  54. .name = "U-Boot",
  55. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  56. .size = 15 * NAND_BLOCK_SIZE,
  57. .mask_flags = MTD_WRITEABLE, /* force read-only */
  58. },
  59. {
  60. .name = "U-Boot Env",
  61. .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
  62. .size = 1 * NAND_BLOCK_SIZE,
  63. },
  64. {
  65. .name = "Kernel",
  66. .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
  67. .size = 32 * NAND_BLOCK_SIZE,
  68. },
  69. {
  70. .name = "File System",
  71. .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
  72. .size = MTDPART_SIZ_FULL,
  73. },
  74. };
  75. static struct omap_nand_platform_data omap3beagle_nand_data = {
  76. .options = NAND_BUSWIDTH_16,
  77. .parts = omap3beagle_nand_partitions,
  78. .nr_parts = ARRAY_SIZE(omap3beagle_nand_partitions),
  79. .dma_channel = -1, /* disable DMA in OMAP NAND driver */
  80. .nand_setup = NULL,
  81. .dev_ready = NULL,
  82. };
  83. static struct resource omap3beagle_nand_resource = {
  84. .flags = IORESOURCE_MEM,
  85. };
  86. static struct platform_device omap3beagle_nand_device = {
  87. .name = "omap2-nand",
  88. .id = -1,
  89. .dev = {
  90. .platform_data = &omap3beagle_nand_data,
  91. },
  92. .num_resources = 1,
  93. .resource = &omap3beagle_nand_resource,
  94. };
  95. static struct omap_uart_config omap3_beagle_uart_config __initdata = {
  96. .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
  97. };
  98. static struct twl4030_hsmmc_info mmc[] = {
  99. {
  100. .mmc = 1,
  101. .wires = 8,
  102. .gpio_wp = 29,
  103. },
  104. {} /* Terminator */
  105. };
  106. static struct gpio_led gpio_leds[];
  107. static int beagle_twl_gpio_setup(struct device *dev,
  108. unsigned gpio, unsigned ngpio)
  109. {
  110. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  111. omap_cfg_reg(AH8_34XX_GPIO29);
  112. mmc[0].gpio_cd = gpio + 0;
  113. twl4030_mmc_init(mmc);
  114. /* REVISIT: need ehci-omap hooks for external VBUS
  115. * power switch and overcurrent detect
  116. */
  117. gpio_request(gpio + 1, "EHCI_nOC");
  118. gpio_direction_input(gpio + 1);
  119. /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
  120. gpio_request(gpio + TWL4030_GPIO_MAX, "nEN_USB_PWR");
  121. gpio_direction_output(gpio + TWL4030_GPIO_MAX, 1);
  122. /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
  123. gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
  124. return 0;
  125. }
  126. static struct twl4030_gpio_platform_data beagle_gpio_data = {
  127. .gpio_base = OMAP_MAX_GPIO_LINES,
  128. .irq_base = TWL4030_GPIO_IRQ_BASE,
  129. .irq_end = TWL4030_GPIO_IRQ_END,
  130. .use_leds = true,
  131. .pullups = BIT(1),
  132. .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
  133. | BIT(15) | BIT(16) | BIT(17),
  134. .setup = beagle_twl_gpio_setup,
  135. };
  136. static struct twl4030_platform_data beagle_twldata = {
  137. .irq_base = TWL4030_IRQ_BASE,
  138. .irq_end = TWL4030_IRQ_END,
  139. /* platform_data for children goes here */
  140. .gpio = &beagle_gpio_data,
  141. };
  142. static struct i2c_board_info __initdata beagle_i2c_boardinfo[] = {
  143. {
  144. I2C_BOARD_INFO("twl4030", 0x48),
  145. .flags = I2C_CLIENT_WAKE,
  146. .irq = INT_34XX_SYS_NIRQ,
  147. .platform_data = &beagle_twldata,
  148. },
  149. };
  150. static int __init omap3_beagle_i2c_init(void)
  151. {
  152. omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo,
  153. ARRAY_SIZE(beagle_i2c_boardinfo));
  154. /* Bus 3 is attached to the DVI port where devices like the pico DLP
  155. * projector don't work reliably with 400kHz */
  156. omap_register_i2c_bus(3, 100, NULL, 0);
  157. return 0;
  158. }
  159. static void __init omap3_beagle_init_irq(void)
  160. {
  161. omap2_init_common_hw(NULL);
  162. omap_init_irq();
  163. #ifdef CONFIG_OMAP_32K_TIMER
  164. omap2_gp_clockevent_set_gptimer(12);
  165. #endif
  166. omap_gpio_init();
  167. }
  168. static struct platform_device omap3_beagle_lcd_device = {
  169. .name = "omap3beagle_lcd",
  170. .id = -1,
  171. };
  172. static struct omap_lcd_config omap3_beagle_lcd_config __initdata = {
  173. .ctrl_name = "internal",
  174. };
  175. static struct gpio_led gpio_leds[] = {
  176. {
  177. .name = "beagleboard::usr0",
  178. .default_trigger = "heartbeat",
  179. .gpio = 150,
  180. },
  181. {
  182. .name = "beagleboard::usr1",
  183. .default_trigger = "mmc0",
  184. .gpio = 149,
  185. },
  186. {
  187. .name = "beagleboard::pmu_stat",
  188. .gpio = -EINVAL, /* gets replaced */
  189. .active_low = true,
  190. },
  191. };
  192. static struct gpio_led_platform_data gpio_led_info = {
  193. .leds = gpio_leds,
  194. .num_leds = ARRAY_SIZE(gpio_leds),
  195. };
  196. static struct platform_device leds_gpio = {
  197. .name = "leds-gpio",
  198. .id = -1,
  199. .dev = {
  200. .platform_data = &gpio_led_info,
  201. },
  202. };
  203. static struct gpio_keys_button gpio_buttons[] = {
  204. {
  205. .code = BTN_EXTRA,
  206. .gpio = 7,
  207. .desc = "user",
  208. .wakeup = 1,
  209. },
  210. };
  211. static struct gpio_keys_platform_data gpio_key_info = {
  212. .buttons = gpio_buttons,
  213. .nbuttons = ARRAY_SIZE(gpio_buttons),
  214. };
  215. static struct platform_device keys_gpio = {
  216. .name = "gpio-keys",
  217. .id = -1,
  218. .dev = {
  219. .platform_data = &gpio_key_info,
  220. },
  221. };
  222. static struct omap_board_config_kernel omap3_beagle_config[] __initdata = {
  223. { OMAP_TAG_UART, &omap3_beagle_uart_config },
  224. { OMAP_TAG_LCD, &omap3_beagle_lcd_config },
  225. };
  226. static struct platform_device *omap3_beagle_devices[] __initdata = {
  227. &omap3_beagle_lcd_device,
  228. &leds_gpio,
  229. &keys_gpio,
  230. };
  231. static void __init omap3beagle_flash_init(void)
  232. {
  233. u8 cs = 0;
  234. u8 nandcs = GPMC_CS_NUM + 1;
  235. u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
  236. /* find out the chip-select on which NAND exists */
  237. while (cs < GPMC_CS_NUM) {
  238. u32 ret = 0;
  239. ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
  240. if ((ret & 0xC00) == 0x800) {
  241. printk(KERN_INFO "Found NAND on CS%d\n", cs);
  242. if (nandcs > GPMC_CS_NUM)
  243. nandcs = cs;
  244. }
  245. cs++;
  246. }
  247. if (nandcs > GPMC_CS_NUM) {
  248. printk(KERN_INFO "NAND: Unable to find configuration "
  249. "in GPMC\n ");
  250. return;
  251. }
  252. if (nandcs < GPMC_CS_NUM) {
  253. omap3beagle_nand_data.cs = nandcs;
  254. omap3beagle_nand_data.gpmc_cs_baseaddr = (void *)
  255. (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
  256. omap3beagle_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
  257. printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
  258. if (platform_device_register(&omap3beagle_nand_device) < 0)
  259. printk(KERN_ERR "Unable to register NAND device\n");
  260. }
  261. }
  262. static void __init omap3_beagle_init(void)
  263. {
  264. omap3_beagle_i2c_init();
  265. platform_add_devices(omap3_beagle_devices,
  266. ARRAY_SIZE(omap3_beagle_devices));
  267. omap_board_config = omap3_beagle_config;
  268. omap_board_config_size = ARRAY_SIZE(omap3_beagle_config);
  269. omap_serial_init();
  270. omap_cfg_reg(J25_34XX_GPIO170);
  271. gpio_request(170, "DVI_nPD");
  272. /* REVISIT leave DVI powered down until it's needed ... */
  273. gpio_direction_output(170, true);
  274. usb_musb_init();
  275. omap3beagle_flash_init();
  276. }
  277. static void __init omap3_beagle_map_io(void)
  278. {
  279. omap2_set_globals_343x();
  280. omap2_map_common_io();
  281. }
  282. MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
  283. /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
  284. .phys_io = 0x48000000,
  285. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  286. .boot_params = 0x80000100,
  287. .map_io = omap3_beagle_map_io,
  288. .init_irq = omap3_beagle_init_irq,
  289. .init_machine = omap3_beagle_init,
  290. .timer = &omap_timer,
  291. MACHINE_END