board-2430sdp.c 6.7 KB

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