board-omap3beagle.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  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/regulator/machine.h>
  29. #include <linux/i2c/twl4030.h>
  30. #include <mach/hardware.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/map.h>
  34. #include <asm/mach/flash.h>
  35. #include <plat/board.h>
  36. #include <plat/common.h>
  37. #include <plat/gpmc.h>
  38. #include <plat/nand.h>
  39. #include <plat/mux.h>
  40. #include <plat/usb.h>
  41. #include <plat/timer-gp.h>
  42. #include "mux.h"
  43. #include "mmc-twl4030.h"
  44. #define GPMC_CS0_BASE 0x60
  45. #define GPMC_CS_SIZE 0x30
  46. #define NAND_BLOCK_SIZE SZ_128K
  47. static struct mtd_partition omap3beagle_nand_partitions[] = {
  48. /* All the partition sizes are listed in terms of NAND block size */
  49. {
  50. .name = "X-Loader",
  51. .offset = 0,
  52. .size = 4 * NAND_BLOCK_SIZE,
  53. .mask_flags = MTD_WRITEABLE, /* force read-only */
  54. },
  55. {
  56. .name = "U-Boot",
  57. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  58. .size = 15 * NAND_BLOCK_SIZE,
  59. .mask_flags = MTD_WRITEABLE, /* force read-only */
  60. },
  61. {
  62. .name = "U-Boot Env",
  63. .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
  64. .size = 1 * NAND_BLOCK_SIZE,
  65. },
  66. {
  67. .name = "Kernel",
  68. .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
  69. .size = 32 * NAND_BLOCK_SIZE,
  70. },
  71. {
  72. .name = "File System",
  73. .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
  74. .size = MTDPART_SIZ_FULL,
  75. },
  76. };
  77. static struct omap_nand_platform_data omap3beagle_nand_data = {
  78. .options = NAND_BUSWIDTH_16,
  79. .parts = omap3beagle_nand_partitions,
  80. .nr_parts = ARRAY_SIZE(omap3beagle_nand_partitions),
  81. .dma_channel = -1, /* disable DMA in OMAP NAND driver */
  82. .nand_setup = NULL,
  83. .dev_ready = NULL,
  84. };
  85. static struct resource omap3beagle_nand_resource = {
  86. .flags = IORESOURCE_MEM,
  87. };
  88. static struct platform_device omap3beagle_nand_device = {
  89. .name = "omap2-nand",
  90. .id = -1,
  91. .dev = {
  92. .platform_data = &omap3beagle_nand_data,
  93. },
  94. .num_resources = 1,
  95. .resource = &omap3beagle_nand_resource,
  96. };
  97. #include "sdram-micron-mt46h32m32lf-6.h"
  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 platform_device omap3_beagle_lcd_device = {
  107. .name = "omap3beagle_lcd",
  108. .id = -1,
  109. };
  110. static struct omap_lcd_config omap3_beagle_lcd_config __initdata = {
  111. .ctrl_name = "internal",
  112. };
  113. static struct regulator_consumer_supply beagle_vmmc1_supply = {
  114. .supply = "vmmc",
  115. };
  116. static struct regulator_consumer_supply beagle_vsim_supply = {
  117. .supply = "vmmc_aux",
  118. };
  119. static struct gpio_led gpio_leds[];
  120. static int beagle_twl_gpio_setup(struct device *dev,
  121. unsigned gpio, unsigned ngpio)
  122. {
  123. if (system_rev >= 0x20 && system_rev <= 0x34301000) {
  124. omap_mux_init_gpio(23, OMAP_PIN_INPUT);
  125. mmc[0].gpio_wp = 23;
  126. } else {
  127. omap_mux_init_gpio(29, OMAP_PIN_INPUT);
  128. }
  129. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  130. mmc[0].gpio_cd = gpio + 0;
  131. twl4030_mmc_init(mmc);
  132. /* link regulators to MMC adapters */
  133. beagle_vmmc1_supply.dev = mmc[0].dev;
  134. beagle_vsim_supply.dev = mmc[0].dev;
  135. /* REVISIT: need ehci-omap hooks for external VBUS
  136. * power switch and overcurrent detect
  137. */
  138. gpio_request(gpio + 1, "EHCI_nOC");
  139. gpio_direction_input(gpio + 1);
  140. /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
  141. gpio_request(gpio + TWL4030_GPIO_MAX, "nEN_USB_PWR");
  142. gpio_direction_output(gpio + TWL4030_GPIO_MAX, 0);
  143. /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
  144. gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
  145. return 0;
  146. }
  147. static struct twl4030_gpio_platform_data beagle_gpio_data = {
  148. .gpio_base = OMAP_MAX_GPIO_LINES,
  149. .irq_base = TWL4030_GPIO_IRQ_BASE,
  150. .irq_end = TWL4030_GPIO_IRQ_END,
  151. .use_leds = true,
  152. .pullups = BIT(1),
  153. .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
  154. | BIT(15) | BIT(16) | BIT(17),
  155. .setup = beagle_twl_gpio_setup,
  156. };
  157. static struct regulator_consumer_supply beagle_vdac_supply = {
  158. .supply = "vdac",
  159. .dev = &omap3_beagle_lcd_device.dev,
  160. };
  161. static struct regulator_consumer_supply beagle_vdvi_supply = {
  162. .supply = "vdvi",
  163. .dev = &omap3_beagle_lcd_device.dev,
  164. };
  165. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  166. static struct regulator_init_data beagle_vmmc1 = {
  167. .constraints = {
  168. .min_uV = 1850000,
  169. .max_uV = 3150000,
  170. .valid_modes_mask = REGULATOR_MODE_NORMAL
  171. | REGULATOR_MODE_STANDBY,
  172. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  173. | REGULATOR_CHANGE_MODE
  174. | REGULATOR_CHANGE_STATUS,
  175. },
  176. .num_consumer_supplies = 1,
  177. .consumer_supplies = &beagle_vmmc1_supply,
  178. };
  179. /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
  180. static struct regulator_init_data beagle_vsim = {
  181. .constraints = {
  182. .min_uV = 1800000,
  183. .max_uV = 3000000,
  184. .valid_modes_mask = REGULATOR_MODE_NORMAL
  185. | REGULATOR_MODE_STANDBY,
  186. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  187. | REGULATOR_CHANGE_MODE
  188. | REGULATOR_CHANGE_STATUS,
  189. },
  190. .num_consumer_supplies = 1,
  191. .consumer_supplies = &beagle_vsim_supply,
  192. };
  193. /* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */
  194. static struct regulator_init_data beagle_vdac = {
  195. .constraints = {
  196. .min_uV = 1800000,
  197. .max_uV = 1800000,
  198. .valid_modes_mask = REGULATOR_MODE_NORMAL
  199. | REGULATOR_MODE_STANDBY,
  200. .valid_ops_mask = REGULATOR_CHANGE_MODE
  201. | REGULATOR_CHANGE_STATUS,
  202. },
  203. .num_consumer_supplies = 1,
  204. .consumer_supplies = &beagle_vdac_supply,
  205. };
  206. /* VPLL2 for digital video outputs */
  207. static struct regulator_init_data beagle_vpll2 = {
  208. .constraints = {
  209. .name = "VDVI",
  210. .min_uV = 1800000,
  211. .max_uV = 1800000,
  212. .valid_modes_mask = REGULATOR_MODE_NORMAL
  213. | REGULATOR_MODE_STANDBY,
  214. .valid_ops_mask = REGULATOR_CHANGE_MODE
  215. | REGULATOR_CHANGE_STATUS,
  216. },
  217. .num_consumer_supplies = 1,
  218. .consumer_supplies = &beagle_vdvi_supply,
  219. };
  220. static struct twl4030_usb_data beagle_usb_data = {
  221. .usb_mode = T2_USB_MODE_ULPI,
  222. };
  223. static struct twl4030_codec_audio_data beagle_audio_data = {
  224. .audio_mclk = 26000000,
  225. };
  226. static struct twl4030_codec_data beagle_codec_data = {
  227. .audio_mclk = 26000000,
  228. .audio = &beagle_audio_data,
  229. };
  230. static struct twl4030_platform_data beagle_twldata = {
  231. .irq_base = TWL4030_IRQ_BASE,
  232. .irq_end = TWL4030_IRQ_END,
  233. /* platform_data for children goes here */
  234. .usb = &beagle_usb_data,
  235. .gpio = &beagle_gpio_data,
  236. .codec = &beagle_codec_data,
  237. .vmmc1 = &beagle_vmmc1,
  238. .vsim = &beagle_vsim,
  239. .vdac = &beagle_vdac,
  240. .vpll2 = &beagle_vpll2,
  241. };
  242. static struct i2c_board_info __initdata beagle_i2c_boardinfo[] = {
  243. {
  244. I2C_BOARD_INFO("twl4030", 0x48),
  245. .flags = I2C_CLIENT_WAKE,
  246. .irq = INT_34XX_SYS_NIRQ,
  247. .platform_data = &beagle_twldata,
  248. },
  249. };
  250. static int __init omap3_beagle_i2c_init(void)
  251. {
  252. omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo,
  253. ARRAY_SIZE(beagle_i2c_boardinfo));
  254. /* Bus 3 is attached to the DVI port where devices like the pico DLP
  255. * projector don't work reliably with 400kHz */
  256. omap_register_i2c_bus(3, 100, NULL, 0);
  257. return 0;
  258. }
  259. static struct gpio_led gpio_leds[] = {
  260. {
  261. .name = "beagleboard::usr0",
  262. .default_trigger = "heartbeat",
  263. .gpio = 150,
  264. },
  265. {
  266. .name = "beagleboard::usr1",
  267. .default_trigger = "mmc0",
  268. .gpio = 149,
  269. },
  270. {
  271. .name = "beagleboard::pmu_stat",
  272. .gpio = -EINVAL, /* gets replaced */
  273. .active_low = true,
  274. },
  275. };
  276. static struct gpio_led_platform_data gpio_led_info = {
  277. .leds = gpio_leds,
  278. .num_leds = ARRAY_SIZE(gpio_leds),
  279. };
  280. static struct platform_device leds_gpio = {
  281. .name = "leds-gpio",
  282. .id = -1,
  283. .dev = {
  284. .platform_data = &gpio_led_info,
  285. },
  286. };
  287. static struct gpio_keys_button gpio_buttons[] = {
  288. {
  289. .code = BTN_EXTRA,
  290. .gpio = 7,
  291. .desc = "user",
  292. .wakeup = 1,
  293. },
  294. };
  295. static struct gpio_keys_platform_data gpio_key_info = {
  296. .buttons = gpio_buttons,
  297. .nbuttons = ARRAY_SIZE(gpio_buttons),
  298. };
  299. static struct platform_device keys_gpio = {
  300. .name = "gpio-keys",
  301. .id = -1,
  302. .dev = {
  303. .platform_data = &gpio_key_info,
  304. },
  305. };
  306. static struct omap_board_config_kernel omap3_beagle_config[] __initdata = {
  307. { OMAP_TAG_LCD, &omap3_beagle_lcd_config },
  308. };
  309. static void __init omap3_beagle_init_irq(void)
  310. {
  311. omap_board_config = omap3_beagle_config;
  312. omap_board_config_size = ARRAY_SIZE(omap3_beagle_config);
  313. omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
  314. mt46h32m32lf6_sdrc_params);
  315. omap_init_irq();
  316. #ifdef CONFIG_OMAP_32K_TIMER
  317. omap2_gp_clockevent_set_gptimer(12);
  318. #endif
  319. omap_gpio_init();
  320. }
  321. static struct platform_device *omap3_beagle_devices[] __initdata = {
  322. &omap3_beagle_lcd_device,
  323. &leds_gpio,
  324. &keys_gpio,
  325. };
  326. static void __init omap3beagle_flash_init(void)
  327. {
  328. u8 cs = 0;
  329. u8 nandcs = GPMC_CS_NUM + 1;
  330. u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
  331. /* find out the chip-select on which NAND exists */
  332. while (cs < GPMC_CS_NUM) {
  333. u32 ret = 0;
  334. ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
  335. if ((ret & 0xC00) == 0x800) {
  336. printk(KERN_INFO "Found NAND on CS%d\n", cs);
  337. if (nandcs > GPMC_CS_NUM)
  338. nandcs = cs;
  339. }
  340. cs++;
  341. }
  342. if (nandcs > GPMC_CS_NUM) {
  343. printk(KERN_INFO "NAND: Unable to find configuration "
  344. "in GPMC\n ");
  345. return;
  346. }
  347. if (nandcs < GPMC_CS_NUM) {
  348. omap3beagle_nand_data.cs = nandcs;
  349. omap3beagle_nand_data.gpmc_cs_baseaddr = (void *)
  350. (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
  351. omap3beagle_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
  352. printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
  353. if (platform_device_register(&omap3beagle_nand_device) < 0)
  354. printk(KERN_ERR "Unable to register NAND device\n");
  355. }
  356. }
  357. static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
  358. .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
  359. .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
  360. .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  361. .phy_reset = true,
  362. .reset_gpio_port[0] = -EINVAL,
  363. .reset_gpio_port[1] = 147,
  364. .reset_gpio_port[2] = -EINVAL
  365. };
  366. #ifdef CONFIG_OMAP_MUX
  367. static struct omap_board_mux board_mux[] __initdata = {
  368. { .reg_offset = OMAP_MUX_TERMINATOR },
  369. };
  370. #else
  371. #define board_mux NULL
  372. #endif
  373. static void __init omap3_beagle_init(void)
  374. {
  375. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  376. omap3_beagle_i2c_init();
  377. platform_add_devices(omap3_beagle_devices,
  378. ARRAY_SIZE(omap3_beagle_devices));
  379. omap_serial_init();
  380. omap_mux_init_gpio(170, OMAP_PIN_INPUT);
  381. gpio_request(170, "DVI_nPD");
  382. /* REVISIT leave DVI powered down until it's needed ... */
  383. gpio_direction_output(170, true);
  384. usb_musb_init();
  385. usb_ehci_init(&ehci_pdata);
  386. omap3beagle_flash_init();
  387. /* Ensure SDRC pins are mux'd for self-refresh */
  388. omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
  389. omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
  390. }
  391. static void __init omap3_beagle_map_io(void)
  392. {
  393. omap2_set_globals_343x();
  394. omap2_map_common_io();
  395. }
  396. MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
  397. /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
  398. .phys_io = 0x48000000,
  399. .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
  400. .boot_params = 0x80000100,
  401. .map_io = omap3_beagle_map_io,
  402. .init_irq = omap3_beagle_init_irq,
  403. .init_machine = omap3_beagle_init,
  404. .timer = &omap_timer,
  405. MACHINE_END