board-omap3beagle.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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 <mach/hardware.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/map.h>
  32. #include <asm/mach/flash.h>
  33. #include <mach/board.h>
  34. #include <mach/common.h>
  35. #include <mach/gpmc.h>
  36. #include <mach/nand.h>
  37. #define GPMC_CS0_BASE 0x60
  38. #define GPMC_CS_SIZE 0x30
  39. #define NAND_BLOCK_SIZE SZ_128K
  40. static struct mtd_partition omap3beagle_nand_partitions[] = {
  41. /* All the partition sizes are listed in terms of NAND block size */
  42. {
  43. .name = "X-Loader",
  44. .offset = 0,
  45. .size = 4 * NAND_BLOCK_SIZE,
  46. .mask_flags = MTD_WRITEABLE, /* force read-only */
  47. },
  48. {
  49. .name = "U-Boot",
  50. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  51. .size = 15 * NAND_BLOCK_SIZE,
  52. .mask_flags = MTD_WRITEABLE, /* force read-only */
  53. },
  54. {
  55. .name = "U-Boot Env",
  56. .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
  57. .size = 1 * NAND_BLOCK_SIZE,
  58. },
  59. {
  60. .name = "Kernel",
  61. .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
  62. .size = 32 * NAND_BLOCK_SIZE,
  63. },
  64. {
  65. .name = "File System",
  66. .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
  67. .size = MTDPART_SIZ_FULL,
  68. },
  69. };
  70. static struct omap_nand_platform_data omap3beagle_nand_data = {
  71. .options = NAND_BUSWIDTH_16,
  72. .parts = omap3beagle_nand_partitions,
  73. .nr_parts = ARRAY_SIZE(omap3beagle_nand_partitions),
  74. .dma_channel = -1, /* disable DMA in OMAP NAND driver */
  75. .nand_setup = NULL,
  76. .dev_ready = NULL,
  77. };
  78. static struct resource omap3beagle_nand_resource = {
  79. .flags = IORESOURCE_MEM,
  80. };
  81. static struct platform_device omap3beagle_nand_device = {
  82. .name = "omap2-nand",
  83. .id = -1,
  84. .dev = {
  85. .platform_data = &omap3beagle_nand_data,
  86. },
  87. .num_resources = 1,
  88. .resource = &omap3beagle_nand_resource,
  89. };
  90. static struct omap_uart_config omap3_beagle_uart_config __initdata = {
  91. .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
  92. };
  93. static void __init omap3_beagle_init_irq(void)
  94. {
  95. omap2_init_common_hw();
  96. omap_init_irq();
  97. omap_gpio_init();
  98. }
  99. static struct platform_device omap3_beagle_lcd_device = {
  100. .name = "omap3beagle_lcd",
  101. .id = -1,
  102. };
  103. static struct omap_lcd_config omap3_beagle_lcd_config __initdata = {
  104. .ctrl_name = "internal",
  105. };
  106. static struct gpio_led gpio_leds[] = {
  107. {
  108. .name = "beagleboard::usr0",
  109. .default_trigger = "heartbeat",
  110. .gpio = 150,
  111. },
  112. {
  113. .name = "beagleboard::usr1",
  114. .default_trigger = "mmc0",
  115. .gpio = 149,
  116. },
  117. };
  118. static struct gpio_led_platform_data gpio_led_info = {
  119. .leds = gpio_leds,
  120. .num_leds = ARRAY_SIZE(gpio_leds),
  121. };
  122. static struct platform_device leds_gpio = {
  123. .name = "leds-gpio",
  124. .id = -1,
  125. .dev = {
  126. .platform_data = &gpio_led_info,
  127. },
  128. };
  129. static struct gpio_keys_button gpio_buttons[] = {
  130. {
  131. .code = BTN_EXTRA,
  132. .gpio = 7,
  133. .desc = "user",
  134. .wakeup = 1,
  135. },
  136. };
  137. static struct gpio_keys_platform_data gpio_key_info = {
  138. .buttons = gpio_buttons,
  139. .nbuttons = ARRAY_SIZE(gpio_buttons),
  140. };
  141. static struct platform_device keys_gpio = {
  142. .name = "gpio-keys",
  143. .id = -1,
  144. .dev = {
  145. .platform_data = &gpio_key_info,
  146. },
  147. };
  148. static struct omap_board_config_kernel omap3_beagle_config[] __initdata = {
  149. { OMAP_TAG_UART, &omap3_beagle_uart_config },
  150. { OMAP_TAG_LCD, &omap3_beagle_lcd_config },
  151. };
  152. static struct platform_device *omap3_beagle_devices[] __initdata = {
  153. &omap3_beagle_lcd_device,
  154. &leds_gpio,
  155. &keys_gpio,
  156. };
  157. static void __init omap3beagle_flash_init(void)
  158. {
  159. u8 cs = 0;
  160. u8 nandcs = GPMC_CS_NUM + 1;
  161. u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
  162. /* find out the chip-select on which NAND exists */
  163. while (cs < GPMC_CS_NUM) {
  164. u32 ret = 0;
  165. ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
  166. if ((ret & 0xC00) == 0x800) {
  167. printk(KERN_INFO "Found NAND on CS%d\n", cs);
  168. if (nandcs > GPMC_CS_NUM)
  169. nandcs = cs;
  170. }
  171. cs++;
  172. }
  173. if (nandcs > GPMC_CS_NUM) {
  174. printk(KERN_INFO "NAND: Unable to find configuration "
  175. "in GPMC\n ");
  176. return;
  177. }
  178. if (nandcs < GPMC_CS_NUM) {
  179. omap3beagle_nand_data.cs = nandcs;
  180. omap3beagle_nand_data.gpmc_cs_baseaddr = (void *)
  181. (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
  182. omap3beagle_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
  183. printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
  184. if (platform_device_register(&omap3beagle_nand_device) < 0)
  185. printk(KERN_ERR "Unable to register NAND device\n");
  186. }
  187. }
  188. static void __init omap3_beagle_init(void)
  189. {
  190. platform_add_devices(omap3_beagle_devices,
  191. ARRAY_SIZE(omap3_beagle_devices));
  192. omap_board_config = omap3_beagle_config;
  193. omap_board_config_size = ARRAY_SIZE(omap3_beagle_config);
  194. omap_serial_init();
  195. omap3beagle_flash_init();
  196. }
  197. static void __init omap3_beagle_map_io(void)
  198. {
  199. omap2_set_globals_343x();
  200. omap2_map_common_io();
  201. }
  202. MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
  203. /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
  204. .phys_io = 0x48000000,
  205. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  206. .boot_params = 0x80000100,
  207. .map_io = omap3_beagle_map_io,
  208. .init_irq = omap3_beagle_init_irq,
  209. .init_machine = omap3_beagle_init,
  210. .timer = &omap_timer,
  211. MACHINE_END