board-overo.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. /*
  2. * board-overo.c (Gumstix Overo)
  3. *
  4. * Initial code: Steve Sakoman <steve@sakoman.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  18. * 02110-1301 USA
  19. *
  20. */
  21. #include <linux/clk.h>
  22. #include <linux/delay.h>
  23. #include <linux/err.h>
  24. #include <linux/init.h>
  25. #include <linux/io.h>
  26. #include <linux/kernel.h>
  27. #include <linux/platform_device.h>
  28. #include <linux/i2c/twl4030.h>
  29. #include <linux/regulator/machine.h>
  30. #include <linux/mtd/mtd.h>
  31. #include <linux/mtd/nand.h>
  32. #include <linux/mtd/partitions.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/flash.h>
  36. #include <asm/mach/map.h>
  37. #include <mach/board.h>
  38. #include <mach/common.h>
  39. #include <mach/gpio.h>
  40. #include <mach/gpmc.h>
  41. #include <mach/hardware.h>
  42. #include <mach/nand.h>
  43. #include <mach/usb.h>
  44. #include "sdram-micron-mt46h32m32lf-6.h"
  45. #include "mmc-twl4030.h"
  46. #define OVERO_GPIO_BT_XGATE 15
  47. #define OVERO_GPIO_W2W_NRESET 16
  48. #define OVERO_GPIO_BT_NRESET 164
  49. #define OVERO_GPIO_USBH_CPEN 168
  50. #define OVERO_GPIO_USBH_NRESET 183
  51. #define NAND_BLOCK_SIZE SZ_128K
  52. #define GPMC_CS0_BASE 0x60
  53. #define GPMC_CS_SIZE 0x30
  54. #define OVERO_SMSC911X_CS 5
  55. #define OVERO_SMSC911X_GPIO 176
  56. #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
  57. defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
  58. #include <mach/mcspi.h>
  59. #include <linux/spi/spi.h>
  60. #include <linux/spi/ads7846.h>
  61. static struct omap2_mcspi_device_config ads7846_mcspi_config = {
  62. .turbo_mode = 0,
  63. .single_channel = 1, /* 0: slave, 1: master */
  64. };
  65. static int ads7846_get_pendown_state(void)
  66. {
  67. return !gpio_get_value(OVERO_GPIO_PENDOWN);
  68. }
  69. static struct ads7846_platform_data ads7846_config = {
  70. .x_max = 0x0fff,
  71. .y_max = 0x0fff,
  72. .x_plate_ohms = 180,
  73. .pressure_max = 255,
  74. .debounce_max = 10,
  75. .debounce_tol = 3,
  76. .debounce_rep = 1,
  77. .get_pendown_state = ads7846_get_pendown_state,
  78. .keep_vref_on = 1,
  79. };
  80. static struct spi_board_info overo_spi_board_info[] __initdata = {
  81. {
  82. .modalias = "ads7846",
  83. .bus_num = 1,
  84. .chip_select = 0,
  85. .max_speed_hz = 1500000,
  86. .controller_data = &ads7846_mcspi_config,
  87. .irq = OMAP_GPIO_IRQ(OVERO_GPIO_PENDOWN),
  88. .platform_data = &ads7846_config,
  89. }
  90. };
  91. static void __init overo_ads7846_init(void)
  92. {
  93. if ((gpio_request(OVERO_GPIO_PENDOWN, "ADS7846_PENDOWN") == 0) &&
  94. (gpio_direction_input(OVERO_GPIO_PENDOWN) == 0)) {
  95. gpio_export(OVERO_GPIO_PENDOWN, 0);
  96. } else {
  97. printk(KERN_ERR "could not obtain gpio for ADS7846_PENDOWN\n");
  98. return;
  99. }
  100. spi_register_board_info(overo_spi_board_info,
  101. ARRAY_SIZE(overo_spi_board_info));
  102. }
  103. #else
  104. static inline void __init overo_ads7846_init(void) { return; }
  105. #endif
  106. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  107. #include <linux/smsc911x.h>
  108. static struct resource overo_smsc911x_resources[] = {
  109. {
  110. .name = "smsc911x-memory",
  111. .flags = IORESOURCE_MEM,
  112. },
  113. {
  114. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  115. },
  116. };
  117. static struct smsc911x_platform_config overo_smsc911x_config = {
  118. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  119. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  120. .flags = SMSC911X_USE_32BIT ,
  121. .phy_interface = PHY_INTERFACE_MODE_MII,
  122. };
  123. static struct platform_device overo_smsc911x_device = {
  124. .name = "smsc911x",
  125. .id = -1,
  126. .num_resources = ARRAY_SIZE(overo_smsc911x_resources),
  127. .resource = &overo_smsc911x_resources,
  128. .dev = {
  129. .platform_data = &overo_smsc911x_config,
  130. },
  131. };
  132. static inline void __init overo_init_smsc911x(void)
  133. {
  134. unsigned long cs_mem_base;
  135. if (gpmc_cs_request(OVERO_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) {
  136. printk(KERN_ERR "Failed request for GPMC mem for smsc911x\n");
  137. return;
  138. }
  139. overo_smsc911x_resources[0].start = cs_mem_base + 0x0;
  140. overo_smsc911x_resources[0].end = cs_mem_base + 0xff;
  141. if ((gpio_request(OVERO_SMSC911X_GPIO, "SMSC911X IRQ") == 0) &&
  142. (gpio_direction_input(OVERO_SMSC911X_GPIO) == 0)) {
  143. gpio_export(OVERO_SMSC911X_GPIO, 0);
  144. } else {
  145. printk(KERN_ERR "could not obtain gpio for SMSC911X IRQ\n");
  146. return;
  147. }
  148. overo_smsc911x_resources[1].start = OMAP_GPIO_IRQ(OVERO_SMSC911X_GPIO);
  149. overo_smsc911x_resources[1].end = 0;
  150. platform_device_register(&overo_smsc911x_device);
  151. }
  152. #else
  153. static inline void __init overo_init_smsc911x(void) { return; }
  154. #endif
  155. static struct mtd_partition overo_nand_partitions[] = {
  156. {
  157. .name = "xloader",
  158. .offset = 0, /* Offset = 0x00000 */
  159. .size = 4 * NAND_BLOCK_SIZE,
  160. .mask_flags = MTD_WRITEABLE
  161. },
  162. {
  163. .name = "uboot",
  164. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  165. .size = 14 * NAND_BLOCK_SIZE,
  166. },
  167. {
  168. .name = "uboot environment",
  169. .offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */
  170. .size = 2 * NAND_BLOCK_SIZE,
  171. },
  172. {
  173. .name = "linux",
  174. .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
  175. .size = 32 * NAND_BLOCK_SIZE,
  176. },
  177. {
  178. .name = "rootfs",
  179. .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
  180. .size = MTDPART_SIZ_FULL,
  181. },
  182. };
  183. static struct omap_nand_platform_data overo_nand_data = {
  184. .parts = overo_nand_partitions,
  185. .nr_parts = ARRAY_SIZE(overo_nand_partitions),
  186. .dma_channel = -1, /* disable DMA in OMAP NAND driver */
  187. };
  188. static struct resource overo_nand_resource = {
  189. .flags = IORESOURCE_MEM,
  190. };
  191. static struct platform_device overo_nand_device = {
  192. .name = "omap2-nand",
  193. .id = -1,
  194. .dev = {
  195. .platform_data = &overo_nand_data,
  196. },
  197. .num_resources = 1,
  198. .resource = &overo_nand_resource,
  199. };
  200. static void __init overo_flash_init(void)
  201. {
  202. u8 cs = 0;
  203. u8 nandcs = GPMC_CS_NUM + 1;
  204. u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
  205. /* find out the chip-select on which NAND exists */
  206. while (cs < GPMC_CS_NUM) {
  207. u32 ret = 0;
  208. ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
  209. if ((ret & 0xC00) == 0x800) {
  210. printk(KERN_INFO "Found NAND on CS%d\n", cs);
  211. if (nandcs > GPMC_CS_NUM)
  212. nandcs = cs;
  213. }
  214. cs++;
  215. }
  216. if (nandcs > GPMC_CS_NUM) {
  217. printk(KERN_INFO "NAND: Unable to find configuration "
  218. "in GPMC\n ");
  219. return;
  220. }
  221. if (nandcs < GPMC_CS_NUM) {
  222. overo_nand_data.cs = nandcs;
  223. overo_nand_data.gpmc_cs_baseaddr = (void *)
  224. (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
  225. overo_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
  226. printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
  227. if (platform_device_register(&overo_nand_device) < 0)
  228. printk(KERN_ERR "Unable to register NAND device\n");
  229. }
  230. }
  231. static struct omap_uart_config overo_uart_config __initdata = {
  232. .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
  233. };
  234. static struct twl4030_hsmmc_info mmc[] = {
  235. {
  236. .mmc = 1,
  237. .wires = 4,
  238. .gpio_cd = -EINVAL,
  239. .gpio_wp = -EINVAL,
  240. },
  241. {
  242. .mmc = 2,
  243. .wires = 4,
  244. .gpio_cd = -EINVAL,
  245. .gpio_wp = -EINVAL,
  246. .transceiver = true,
  247. .ocr_mask = 0x00100000, /* 3.3V */
  248. },
  249. {} /* Terminator */
  250. };
  251. static struct regulator_consumer_supply overo_vmmc1_supply = {
  252. .supply = "vmmc",
  253. };
  254. static int overo_twl_gpio_setup(struct device *dev,
  255. unsigned gpio, unsigned ngpio)
  256. {
  257. twl4030_mmc_init(mmc);
  258. overo_vmmc1_supply.dev = mmc[0].dev;
  259. return 0;
  260. }
  261. static struct twl4030_gpio_platform_data overo_gpio_data = {
  262. .gpio_base = OMAP_MAX_GPIO_LINES,
  263. .irq_base = TWL4030_GPIO_IRQ_BASE,
  264. .irq_end = TWL4030_GPIO_IRQ_END,
  265. .setup = overo_twl_gpio_setup,
  266. };
  267. static struct twl4030_usb_data overo_usb_data = {
  268. .usb_mode = T2_USB_MODE_ULPI,
  269. };
  270. static struct regulator_init_data overo_vmmc1 = {
  271. .constraints = {
  272. .min_uV = 1850000,
  273. .max_uV = 3150000,
  274. .valid_modes_mask = REGULATOR_MODE_NORMAL
  275. | REGULATOR_MODE_STANDBY,
  276. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  277. | REGULATOR_CHANGE_MODE
  278. | REGULATOR_CHANGE_STATUS,
  279. },
  280. .num_consumer_supplies = 1,
  281. .consumer_supplies = &overo_vmmc1_supply,
  282. };
  283. /* mmc2 (WLAN) and Bluetooth don't use twl4030 regulators */
  284. static struct twl4030_platform_data overo_twldata = {
  285. .irq_base = TWL4030_IRQ_BASE,
  286. .irq_end = TWL4030_IRQ_END,
  287. .gpio = &overo_gpio_data,
  288. .usb = &overo_usb_data,
  289. .vmmc1 = &overo_vmmc1,
  290. };
  291. static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
  292. {
  293. I2C_BOARD_INFO("tps65950", 0x48),
  294. .flags = I2C_CLIENT_WAKE,
  295. .irq = INT_34XX_SYS_NIRQ,
  296. .platform_data = &overo_twldata,
  297. },
  298. };
  299. static int __init overo_i2c_init(void)
  300. {
  301. omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo,
  302. ARRAY_SIZE(overo_i2c_boardinfo));
  303. /* i2c2 pins are used for gpio */
  304. omap_register_i2c_bus(3, 400, NULL, 0);
  305. return 0;
  306. }
  307. static void __init overo_init_irq(void)
  308. {
  309. omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
  310. omap_init_irq();
  311. omap_gpio_init();
  312. }
  313. static struct platform_device overo_lcd_device = {
  314. .name = "overo_lcd",
  315. .id = -1,
  316. };
  317. static struct omap_lcd_config overo_lcd_config __initdata = {
  318. .ctrl_name = "internal",
  319. };
  320. static struct omap_board_config_kernel overo_config[] __initdata = {
  321. { OMAP_TAG_UART, &overo_uart_config },
  322. { OMAP_TAG_LCD, &overo_lcd_config },
  323. };
  324. static struct platform_device *overo_devices[] __initdata = {
  325. &overo_lcd_device,
  326. };
  327. static void __init overo_init(void)
  328. {
  329. overo_i2c_init();
  330. platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices));
  331. omap_board_config = overo_config;
  332. omap_board_config_size = ARRAY_SIZE(overo_config);
  333. omap_serial_init();
  334. overo_flash_init();
  335. usb_musb_init();
  336. overo_ads7846_init();
  337. overo_init_smsc911x();
  338. if ((gpio_request(OVERO_GPIO_W2W_NRESET,
  339. "OVERO_GPIO_W2W_NRESET") == 0) &&
  340. (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) {
  341. gpio_export(OVERO_GPIO_W2W_NRESET, 0);
  342. gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);
  343. udelay(10);
  344. gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
  345. } else {
  346. printk(KERN_ERR "could not obtain gpio for "
  347. "OVERO_GPIO_W2W_NRESET\n");
  348. }
  349. if ((gpio_request(OVERO_GPIO_BT_XGATE, "OVERO_GPIO_BT_XGATE") == 0) &&
  350. (gpio_direction_output(OVERO_GPIO_BT_XGATE, 0) == 0))
  351. gpio_export(OVERO_GPIO_BT_XGATE, 0);
  352. else
  353. printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
  354. if ((gpio_request(OVERO_GPIO_BT_NRESET, "OVERO_GPIO_BT_NRESET") == 0) &&
  355. (gpio_direction_output(OVERO_GPIO_BT_NRESET, 1) == 0)) {
  356. gpio_export(OVERO_GPIO_BT_NRESET, 0);
  357. gpio_set_value(OVERO_GPIO_BT_NRESET, 0);
  358. mdelay(6);
  359. gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
  360. } else {
  361. printk(KERN_ERR "could not obtain gpio for "
  362. "OVERO_GPIO_BT_NRESET\n");
  363. }
  364. if ((gpio_request(OVERO_GPIO_USBH_CPEN, "OVERO_GPIO_USBH_CPEN") == 0) &&
  365. (gpio_direction_output(OVERO_GPIO_USBH_CPEN, 1) == 0))
  366. gpio_export(OVERO_GPIO_USBH_CPEN, 0);
  367. else
  368. printk(KERN_ERR "could not obtain gpio for "
  369. "OVERO_GPIO_USBH_CPEN\n");
  370. if ((gpio_request(OVERO_GPIO_USBH_NRESET,
  371. "OVERO_GPIO_USBH_NRESET") == 0) &&
  372. (gpio_direction_output(OVERO_GPIO_USBH_NRESET, 1) == 0))
  373. gpio_export(OVERO_GPIO_USBH_NRESET, 0);
  374. else
  375. printk(KERN_ERR "could not obtain gpio for "
  376. "OVERO_GPIO_USBH_NRESET\n");
  377. }
  378. static void __init overo_map_io(void)
  379. {
  380. omap2_set_globals_343x();
  381. omap2_map_common_io();
  382. }
  383. MACHINE_START(OVERO, "Gumstix Overo")
  384. .phys_io = 0x48000000,
  385. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  386. .boot_params = 0x80000100,
  387. .map_io = overo_map_io,
  388. .init_irq = overo_init_irq,
  389. .init_machine = overo_init,
  390. .timer = &omap_timer,
  391. MACHINE_END