board-omap3beagle.c 11 KB

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