board-overo.c 6.4 KB

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