board-overo.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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/mtd/mtd.h>
  30. #include <linux/mtd/nand.h>
  31. #include <linux/mtd/partitions.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/flash.h>
  35. #include <asm/mach/map.h>
  36. #include <mach/board-overo.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 "mmc-twl4030.h"
  44. #define NAND_BLOCK_SIZE SZ_128K
  45. #define GPMC_CS0_BASE 0x60
  46. #define GPMC_CS_SIZE 0x30
  47. static struct mtd_partition overo_nand_partitions[] = {
  48. {
  49. .name = "xloader",
  50. .offset = 0, /* Offset = 0x00000 */
  51. .size = 4 * NAND_BLOCK_SIZE,
  52. .mask_flags = MTD_WRITEABLE
  53. },
  54. {
  55. .name = "uboot",
  56. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  57. .size = 14 * NAND_BLOCK_SIZE,
  58. },
  59. {
  60. .name = "uboot environment",
  61. .offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */
  62. .size = 2 * NAND_BLOCK_SIZE,
  63. },
  64. {
  65. .name = "linux",
  66. .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
  67. .size = 32 * NAND_BLOCK_SIZE,
  68. },
  69. {
  70. .name = "rootfs",
  71. .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
  72. .size = MTDPART_SIZ_FULL,
  73. },
  74. };
  75. static struct omap_nand_platform_data overo_nand_data = {
  76. .parts = overo_nand_partitions,
  77. .nr_parts = ARRAY_SIZE(overo_nand_partitions),
  78. .dma_channel = -1, /* disable DMA in OMAP NAND driver */
  79. };
  80. static struct resource overo_nand_resource = {
  81. .flags = IORESOURCE_MEM,
  82. };
  83. static struct platform_device overo_nand_device = {
  84. .name = "omap2-nand",
  85. .id = -1,
  86. .dev = {
  87. .platform_data = &overo_nand_data,
  88. },
  89. .num_resources = 1,
  90. .resource = &overo_nand_resource,
  91. };
  92. static void __init overo_flash_init(void)
  93. {
  94. u8 cs = 0;
  95. u8 nandcs = GPMC_CS_NUM + 1;
  96. u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
  97. /* find out the chip-select on which NAND exists */
  98. while (cs < GPMC_CS_NUM) {
  99. u32 ret = 0;
  100. ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
  101. if ((ret & 0xC00) == 0x800) {
  102. printk(KERN_INFO "Found NAND on CS%d\n", cs);
  103. if (nandcs > GPMC_CS_NUM)
  104. nandcs = cs;
  105. }
  106. cs++;
  107. }
  108. if (nandcs > GPMC_CS_NUM) {
  109. printk(KERN_INFO "NAND: Unable to find configuration "
  110. "in GPMC\n ");
  111. return;
  112. }
  113. if (nandcs < GPMC_CS_NUM) {
  114. overo_nand_data.cs = nandcs;
  115. overo_nand_data.gpmc_cs_baseaddr = (void *)
  116. (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
  117. overo_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
  118. printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
  119. if (platform_device_register(&overo_nand_device) < 0)
  120. printk(KERN_ERR "Unable to register NAND device\n");
  121. }
  122. }
  123. static struct omap_uart_config overo_uart_config __initdata = {
  124. .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
  125. };
  126. static struct twl4030_gpio_platform_data overo_gpio_data = {
  127. .gpio_base = OMAP_MAX_GPIO_LINES,
  128. .irq_base = TWL4030_GPIO_IRQ_BASE,
  129. .irq_end = TWL4030_GPIO_IRQ_END,
  130. };
  131. static struct twl4030_platform_data overo_twldata = {
  132. .irq_base = TWL4030_IRQ_BASE,
  133. .irq_end = TWL4030_IRQ_END,
  134. .gpio = &overo_gpio_data,
  135. };
  136. static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
  137. {
  138. I2C_BOARD_INFO("twl4030", 0x48),
  139. .flags = I2C_CLIENT_WAKE,
  140. .irq = INT_34XX_SYS_NIRQ,
  141. .platform_data = &overo_twldata,
  142. },
  143. };
  144. static int __init overo_i2c_init(void)
  145. {
  146. omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo,
  147. ARRAY_SIZE(overo_i2c_boardinfo));
  148. /* i2c2 pins are used for gpio */
  149. omap_register_i2c_bus(3, 400, NULL, 0);
  150. return 0;
  151. }
  152. static void __init overo_init_irq(void)
  153. {
  154. omap2_init_common_hw();
  155. omap_init_irq();
  156. omap_gpio_init();
  157. }
  158. static struct platform_device overo_lcd_device = {
  159. .name = "overo_lcd",
  160. .id = -1,
  161. };
  162. static struct omap_lcd_config overo_lcd_config __initdata = {
  163. .ctrl_name = "internal",
  164. };
  165. static struct omap_board_config_kernel overo_config[] __initdata = {
  166. { OMAP_TAG_UART, &overo_uart_config },
  167. { OMAP_TAG_LCD, &overo_lcd_config },
  168. };
  169. static struct platform_device *overo_devices[] __initdata = {
  170. &overo_lcd_device,
  171. };
  172. static struct twl4030_hsmmc_info mmc[] __initdata = {
  173. {
  174. .mmc = 1,
  175. .wires = 4,
  176. .gpio_cd = -EINVAL,
  177. .gpio_wp = -EINVAL,
  178. },
  179. {
  180. .mmc = 2,
  181. .wires = 4,
  182. .gpio_cd = -EINVAL,
  183. .gpio_wp = -EINVAL,
  184. },
  185. {} /* Terminator */
  186. };
  187. static void __init overo_init(void)
  188. {
  189. overo_i2c_init();
  190. platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices));
  191. omap_board_config = overo_config;
  192. omap_board_config_size = ARRAY_SIZE(overo_config);
  193. omap_serial_init();
  194. twl4030_mmc_init(mmc);
  195. overo_flash_init();
  196. if ((gpio_request(OVERO_GPIO_W2W_NRESET,
  197. "OVERO_GPIO_W2W_NRESET") == 0) &&
  198. (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) {
  199. gpio_export(OVERO_GPIO_W2W_NRESET, 0);
  200. gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);
  201. udelay(10);
  202. gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
  203. } else {
  204. printk(KERN_ERR "could not obtain gpio for "
  205. "OVERO_GPIO_W2W_NRESET\n");
  206. }
  207. if ((gpio_request(OVERO_GPIO_BT_XGATE, "OVERO_GPIO_BT_XGATE") == 0) &&
  208. (gpio_direction_output(OVERO_GPIO_BT_XGATE, 0) == 0))
  209. gpio_export(OVERO_GPIO_BT_XGATE, 0);
  210. else
  211. printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
  212. if ((gpio_request(OVERO_GPIO_BT_NRESET, "OVERO_GPIO_BT_NRESET") == 0) &&
  213. (gpio_direction_output(OVERO_GPIO_BT_NRESET, 1) == 0)) {
  214. gpio_export(OVERO_GPIO_BT_NRESET, 0);
  215. gpio_set_value(OVERO_GPIO_BT_NRESET, 0);
  216. mdelay(6);
  217. gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
  218. } else {
  219. printk(KERN_ERR "could not obtain gpio for "
  220. "OVERO_GPIO_BT_NRESET\n");
  221. }
  222. if ((gpio_request(OVERO_GPIO_USBH_CPEN, "OVERO_GPIO_USBH_CPEN") == 0) &&
  223. (gpio_direction_output(OVERO_GPIO_USBH_CPEN, 1) == 0))
  224. gpio_export(OVERO_GPIO_USBH_CPEN, 0);
  225. else
  226. printk(KERN_ERR "could not obtain gpio for "
  227. "OVERO_GPIO_USBH_CPEN\n");
  228. if ((gpio_request(OVERO_GPIO_USBH_NRESET,
  229. "OVERO_GPIO_USBH_NRESET") == 0) &&
  230. (gpio_direction_output(OVERO_GPIO_USBH_NRESET, 1) == 0))
  231. gpio_export(OVERO_GPIO_USBH_NRESET, 0);
  232. else
  233. printk(KERN_ERR "could not obtain gpio for "
  234. "OVERO_GPIO_USBH_NRESET\n");
  235. }
  236. static void __init overo_map_io(void)
  237. {
  238. omap2_set_globals_343x();
  239. omap2_map_common_io();
  240. }
  241. MACHINE_START(OVERO, "Gumstix Overo")
  242. .phys_io = 0x48000000,
  243. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  244. .boot_params = 0x80000100,
  245. .map_io = overo_map_io,
  246. .init_irq = overo_init_irq,
  247. .init_machine = overo_init,
  248. .timer = &omap_timer,
  249. MACHINE_END