board-2430sdp.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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/err.h>
  22. #include <linux/clk.h>
  23. #include <linux/io.h>
  24. #include <mach/hardware.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach/map.h>
  28. #include <asm/mach/flash.h>
  29. #include <mach/gpio.h>
  30. #include <mach/mux.h>
  31. #include <mach/board.h>
  32. #include <mach/common.h>
  33. #include <mach/gpmc.h>
  34. #define SDP2430_FLASH_CS 0
  35. #define SDP2430_SMC91X_CS 5
  36. static struct mtd_partition sdp2430_partitions[] = {
  37. /* bootloader (U-Boot, etc) in first sector */
  38. {
  39. .name = "bootloader",
  40. .offset = 0,
  41. .size = SZ_256K,
  42. .mask_flags = MTD_WRITEABLE, /* force read-only */
  43. },
  44. /* bootloader params in the next sector */
  45. {
  46. .name = "params",
  47. .offset = MTDPART_OFS_APPEND,
  48. .size = SZ_128K,
  49. .mask_flags = 0,
  50. },
  51. /* kernel */
  52. {
  53. .name = "kernel",
  54. .offset = MTDPART_OFS_APPEND,
  55. .size = SZ_2M,
  56. .mask_flags = 0
  57. },
  58. /* file system */
  59. {
  60. .name = "filesystem",
  61. .offset = MTDPART_OFS_APPEND,
  62. .size = MTDPART_SIZ_FULL,
  63. .mask_flags = 0
  64. }
  65. };
  66. static struct flash_platform_data sdp2430_flash_data = {
  67. .map_name = "cfi_probe",
  68. .width = 2,
  69. .parts = sdp2430_partitions,
  70. .nr_parts = ARRAY_SIZE(sdp2430_partitions),
  71. };
  72. static struct resource sdp2430_flash_resource = {
  73. .start = SDP2430_CS0_BASE,
  74. .end = SDP2430_CS0_BASE + SZ_64M - 1,
  75. .flags = IORESOURCE_MEM,
  76. };
  77. static struct platform_device sdp2430_flash_device = {
  78. .name = "omapflash",
  79. .id = 0,
  80. .dev = {
  81. .platform_data = &sdp2430_flash_data,
  82. },
  83. .num_resources = 1,
  84. .resource = &sdp2430_flash_resource,
  85. };
  86. static struct resource sdp2430_smc91x_resources[] = {
  87. [0] = {
  88. .start = SDP2430_CS0_BASE,
  89. .end = SDP2430_CS0_BASE + SZ_64M - 1,
  90. .flags = IORESOURCE_MEM,
  91. },
  92. [1] = {
  93. .start = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
  94. .end = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
  95. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  96. },
  97. };
  98. static struct platform_device sdp2430_smc91x_device = {
  99. .name = "smc91x",
  100. .id = -1,
  101. .num_resources = ARRAY_SIZE(sdp2430_smc91x_resources),
  102. .resource = sdp2430_smc91x_resources,
  103. };
  104. static struct platform_device *sdp2430_devices[] __initdata = {
  105. &sdp2430_smc91x_device,
  106. &sdp2430_flash_device,
  107. };
  108. static inline void __init sdp2430_init_smc91x(void)
  109. {
  110. int eth_cs;
  111. unsigned long cs_mem_base;
  112. unsigned int rate;
  113. struct clk *gpmc_fck;
  114. eth_cs = SDP2430_SMC91X_CS;
  115. gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
  116. if (IS_ERR(gpmc_fck)) {
  117. WARN_ON(1);
  118. return;
  119. }
  120. clk_enable(gpmc_fck);
  121. rate = clk_get_rate(gpmc_fck);
  122. /* Make sure CS1 timings are correct, for 2430 always muxed */
  123. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
  124. if (rate >= 160000000) {
  125. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
  126. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
  127. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
  128. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
  129. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
  130. } else if (rate >= 130000000) {
  131. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
  132. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
  133. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
  134. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
  135. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
  136. } else { /* rate = 100000000 */
  137. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
  138. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
  139. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
  140. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
  141. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
  142. }
  143. if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
  144. printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
  145. goto out;
  146. }
  147. sdp2430_smc91x_resources[0].start = cs_mem_base + 0x300;
  148. sdp2430_smc91x_resources[0].end = cs_mem_base + 0x30f;
  149. udelay(100);
  150. if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ) < 0) {
  151. printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
  152. OMAP24XX_ETHR_GPIO_IRQ);
  153. gpmc_cs_free(eth_cs);
  154. goto out;
  155. }
  156. omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ, 1);
  157. out:
  158. clk_disable(gpmc_fck);
  159. clk_put(gpmc_fck);
  160. }
  161. static void __init omap_2430sdp_init_irq(void)
  162. {
  163. omap2_init_common_hw();
  164. omap_init_irq();
  165. omap_gpio_init();
  166. sdp2430_init_smc91x();
  167. }
  168. static struct omap_uart_config sdp2430_uart_config __initdata = {
  169. .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
  170. };
  171. static struct omap_board_config_kernel sdp2430_config[] = {
  172. {OMAP_TAG_UART, &sdp2430_uart_config},
  173. };
  174. static void __init omap_2430sdp_init(void)
  175. {
  176. platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices));
  177. omap_board_config = sdp2430_config;
  178. omap_board_config_size = ARRAY_SIZE(sdp2430_config);
  179. omap_serial_init();
  180. }
  181. static void __init omap_2430sdp_map_io(void)
  182. {
  183. omap2_set_globals_243x();
  184. omap2_map_common_io();
  185. }
  186. MACHINE_START(OMAP_2430SDP, "OMAP2430 sdp2430 board")
  187. /* Maintainer: Syed Khasim - Texas Instruments Inc */
  188. .phys_io = 0x48000000,
  189. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  190. .boot_params = 0x80000100,
  191. .map_io = omap_2430sdp_map_io,
  192. .init_irq = omap_2430sdp_init_irq,
  193. .init_machine = omap_2430sdp_init,
  194. .timer = &omap_timer,
  195. MACHINE_END