board-2430sdp.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /*
  2. * linux/arch/arm/mach-omap2/board-2430sdp.c
  3. *
  4. * Copyright (C) 2006 Texas Instruments
  5. *
  6. * Modified from mach-omap2/board-generic.c
  7. *
  8. * Initial Code : Based on a patch from Komal Shah and Richard Woodruff
  9. * Updated the Code for 2430 SDP : Syed Mohammed Khasim
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/mtd/mtd.h>
  19. #include <linux/mtd/partitions.h>
  20. #include <linux/delay.h>
  21. #include <linux/i2c/twl4030.h>
  22. #include <linux/err.h>
  23. #include <linux/clk.h>
  24. #include <linux/io.h>
  25. #include <mach/hardware.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <asm/mach/flash.h>
  30. #include <mach/gpio.h>
  31. #include <mach/mux.h>
  32. #include <mach/board.h>
  33. #include <mach/common.h>
  34. #include <mach/gpmc.h>
  35. #include <mach/usb.h>
  36. #include "mmc-twl4030.h"
  37. #define SDP2430_CS0_BASE 0x04000000
  38. #define SDP2430_FLASH_CS 0
  39. #define SDP2430_SMC91X_CS 5
  40. #define SDP2430_ETHR_GPIO_IRQ 149
  41. static struct mtd_partition sdp2430_partitions[] = {
  42. /* bootloader (U-Boot, etc) in first sector */
  43. {
  44. .name = "bootloader",
  45. .offset = 0,
  46. .size = SZ_256K,
  47. .mask_flags = MTD_WRITEABLE, /* force read-only */
  48. },
  49. /* bootloader params in the next sector */
  50. {
  51. .name = "params",
  52. .offset = MTDPART_OFS_APPEND,
  53. .size = SZ_128K,
  54. .mask_flags = 0,
  55. },
  56. /* kernel */
  57. {
  58. .name = "kernel",
  59. .offset = MTDPART_OFS_APPEND,
  60. .size = SZ_2M,
  61. .mask_flags = 0
  62. },
  63. /* file system */
  64. {
  65. .name = "filesystem",
  66. .offset = MTDPART_OFS_APPEND,
  67. .size = MTDPART_SIZ_FULL,
  68. .mask_flags = 0
  69. }
  70. };
  71. static struct flash_platform_data sdp2430_flash_data = {
  72. .map_name = "cfi_probe",
  73. .width = 2,
  74. .parts = sdp2430_partitions,
  75. .nr_parts = ARRAY_SIZE(sdp2430_partitions),
  76. };
  77. static struct resource sdp2430_flash_resource = {
  78. .start = SDP2430_CS0_BASE,
  79. .end = SDP2430_CS0_BASE + SZ_64M - 1,
  80. .flags = IORESOURCE_MEM,
  81. };
  82. static struct platform_device sdp2430_flash_device = {
  83. .name = "omapflash",
  84. .id = 0,
  85. .dev = {
  86. .platform_data = &sdp2430_flash_data,
  87. },
  88. .num_resources = 1,
  89. .resource = &sdp2430_flash_resource,
  90. };
  91. static struct resource sdp2430_smc91x_resources[] = {
  92. [0] = {
  93. .start = SDP2430_CS0_BASE,
  94. .end = SDP2430_CS0_BASE + SZ_64M - 1,
  95. .flags = IORESOURCE_MEM,
  96. },
  97. [1] = {
  98. .start = OMAP_GPIO_IRQ(SDP2430_ETHR_GPIO_IRQ),
  99. .end = OMAP_GPIO_IRQ(SDP2430_ETHR_GPIO_IRQ),
  100. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  101. },
  102. };
  103. static struct platform_device sdp2430_smc91x_device = {
  104. .name = "smc91x",
  105. .id = -1,
  106. .num_resources = ARRAY_SIZE(sdp2430_smc91x_resources),
  107. .resource = sdp2430_smc91x_resources,
  108. };
  109. static struct platform_device *sdp2430_devices[] __initdata = {
  110. &sdp2430_smc91x_device,
  111. &sdp2430_flash_device,
  112. };
  113. static inline void __init sdp2430_init_smc91x(void)
  114. {
  115. int eth_cs;
  116. unsigned long cs_mem_base;
  117. unsigned int rate;
  118. struct clk *gpmc_fck;
  119. eth_cs = SDP2430_SMC91X_CS;
  120. gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
  121. if (IS_ERR(gpmc_fck)) {
  122. WARN_ON(1);
  123. return;
  124. }
  125. clk_enable(gpmc_fck);
  126. rate = clk_get_rate(gpmc_fck);
  127. /* Make sure CS1 timings are correct, for 2430 always muxed */
  128. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
  129. if (rate >= 160000000) {
  130. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
  131. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
  132. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
  133. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
  134. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
  135. } else if (rate >= 130000000) {
  136. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
  137. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
  138. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
  139. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
  140. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
  141. } else { /* rate = 100000000 */
  142. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
  143. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
  144. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
  145. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
  146. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
  147. }
  148. if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
  149. printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
  150. goto out;
  151. }
  152. sdp2430_smc91x_resources[0].start = cs_mem_base + 0x300;
  153. sdp2430_smc91x_resources[0].end = cs_mem_base + 0x30f;
  154. udelay(100);
  155. if (gpio_request(SDP2430_ETHR_GPIO_IRQ, "SMC91x irq") < 0) {
  156. printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
  157. SDP2430_ETHR_GPIO_IRQ);
  158. gpmc_cs_free(eth_cs);
  159. goto out;
  160. }
  161. gpio_direction_input(SDP2430_ETHR_GPIO_IRQ);
  162. out:
  163. clk_disable(gpmc_fck);
  164. clk_put(gpmc_fck);
  165. }
  166. static void __init omap_2430sdp_init_irq(void)
  167. {
  168. omap2_init_common_hw(NULL);
  169. omap_init_irq();
  170. omap_gpio_init();
  171. sdp2430_init_smc91x();
  172. }
  173. static struct omap_uart_config sdp2430_uart_config __initdata = {
  174. .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
  175. };
  176. static struct omap_board_config_kernel sdp2430_config[] = {
  177. {OMAP_TAG_UART, &sdp2430_uart_config},
  178. };
  179. static struct twl4030_gpio_platform_data sdp2430_gpio_data = {
  180. .gpio_base = OMAP_MAX_GPIO_LINES,
  181. .irq_base = TWL4030_GPIO_IRQ_BASE,
  182. .irq_end = TWL4030_GPIO_IRQ_END,
  183. };
  184. static struct twl4030_platform_data sdp2430_twldata = {
  185. .irq_base = TWL4030_IRQ_BASE,
  186. .irq_end = TWL4030_IRQ_END,
  187. /* platform_data for children goes here */
  188. .gpio = &sdp2430_gpio_data,
  189. };
  190. static struct i2c_board_info __initdata sdp2430_i2c_boardinfo[] = {
  191. {
  192. I2C_BOARD_INFO("twl4030", 0x48),
  193. .flags = I2C_CLIENT_WAKE,
  194. .irq = INT_24XX_SYS_NIRQ,
  195. .platform_data = &sdp2430_twldata,
  196. },
  197. };
  198. static int __init omap2430_i2c_init(void)
  199. {
  200. omap_register_i2c_bus(1, 400, NULL, 0);
  201. omap_register_i2c_bus(2, 2600, sdp2430_i2c_boardinfo,
  202. ARRAY_SIZE(sdp2430_i2c_boardinfo));
  203. return 0;
  204. }
  205. static struct twl4030_hsmmc_info mmc[] __initdata = {
  206. {
  207. .mmc = 1,
  208. .wires = 4,
  209. .gpio_cd = -EINVAL,
  210. .gpio_wp = -EINVAL,
  211. .ext_clock = 1,
  212. },
  213. {} /* Terminator */
  214. };
  215. static void __init omap_2430sdp_init(void)
  216. {
  217. omap2430_i2c_init();
  218. platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices));
  219. omap_board_config = sdp2430_config;
  220. omap_board_config_size = ARRAY_SIZE(sdp2430_config);
  221. omap_serial_init();
  222. twl4030_mmc_init(mmc);
  223. usb_musb_init();
  224. }
  225. static void __init omap_2430sdp_map_io(void)
  226. {
  227. omap2_set_globals_243x();
  228. omap2_map_common_io();
  229. }
  230. MACHINE_START(OMAP_2430SDP, "OMAP2430 sdp2430 board")
  231. /* Maintainer: Syed Khasim - Texas Instruments Inc */
  232. .phys_io = 0x48000000,
  233. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  234. .boot_params = 0x80000100,
  235. .map_io = omap_2430sdp_map_io,
  236. .init_irq = omap_2430sdp_init_irq,
  237. .init_machine = omap_2430sdp_init,
  238. .timer = &omap_timer,
  239. MACHINE_END