ts78xx-setup.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /*
  2. * arch/arm/mach-orion5x/ts78xx-setup.c
  3. *
  4. * Maintainer: Alexander Clouter <alex@digriz.org.uk>
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/mtd/physmap.h>
  14. #include <linux/mv643xx_eth.h>
  15. #include <linux/ata_platform.h>
  16. #include <linux/m48t86.h>
  17. #include <asm/mach-types.h>
  18. #include <asm/mach/arch.h>
  19. #include <asm/mach/map.h>
  20. #include <mach/orion5x.h>
  21. #include "common.h"
  22. #include "mpp.h"
  23. /*****************************************************************************
  24. * TS-78xx Info
  25. ****************************************************************************/
  26. /*
  27. * FPGA - lives where the PCI bus would be at ORION5X_PCI_MEM_PHYS_BASE
  28. */
  29. #define TS78XX_FPGA_REGS_PHYS_BASE 0xe8000000
  30. #define TS78XX_FPGA_REGS_VIRT_BASE 0xff900000
  31. #define TS78XX_FPGA_REGS_SIZE SZ_1M
  32. #define TS78XX_FPGA_REGS_SYSCON_ID (TS78XX_FPGA_REGS_VIRT_BASE | 0x000)
  33. #define TS78XX_FPGA_REGS_SYSCON_LCDI (TS78XX_FPGA_REGS_VIRT_BASE | 0x004)
  34. #define TS78XX_FPGA_REGS_SYSCON_LCDO (TS78XX_FPGA_REGS_VIRT_BASE | 0x008)
  35. #define TS78XX_FPGA_REGS_RTC_CTRL (TS78XX_FPGA_REGS_VIRT_BASE | 0x808)
  36. #define TS78XX_FPGA_REGS_RTC_DATA (TS78XX_FPGA_REGS_VIRT_BASE | 0x80c)
  37. /*
  38. * 512kB NOR flash Device
  39. */
  40. #define TS78XX_NOR_BOOT_BASE 0xff800000
  41. #define TS78XX_NOR_BOOT_SIZE SZ_512K
  42. /*****************************************************************************
  43. * I/O Address Mapping
  44. ****************************************************************************/
  45. static struct map_desc ts78xx_io_desc[] __initdata = {
  46. {
  47. .virtual = TS78XX_FPGA_REGS_VIRT_BASE,
  48. .pfn = __phys_to_pfn(TS78XX_FPGA_REGS_PHYS_BASE),
  49. .length = TS78XX_FPGA_REGS_SIZE,
  50. .type = MT_DEVICE,
  51. },
  52. };
  53. void __init ts78xx_map_io(void)
  54. {
  55. orion5x_map_io();
  56. iotable_init(ts78xx_io_desc, ARRAY_SIZE(ts78xx_io_desc));
  57. }
  58. /*****************************************************************************
  59. * 512kB NOR Boot Flash - the chip is a M25P40
  60. ****************************************************************************/
  61. static struct mtd_partition ts78xx_nor_boot_flash_resources[] = {
  62. {
  63. .name = "ts-bootrom",
  64. .offset = 0,
  65. /* only the first 256kB is used */
  66. .size = SZ_256K,
  67. .mask_flags = MTD_WRITEABLE,
  68. },
  69. };
  70. static struct physmap_flash_data ts78xx_nor_boot_flash_data = {
  71. .width = 1,
  72. .parts = ts78xx_nor_boot_flash_resources,
  73. .nr_parts = ARRAY_SIZE(ts78xx_nor_boot_flash_resources),
  74. };
  75. static struct resource ts78xx_nor_boot_flash_resource = {
  76. .flags = IORESOURCE_MEM,
  77. .start = TS78XX_NOR_BOOT_BASE,
  78. .end = TS78XX_NOR_BOOT_BASE + TS78XX_NOR_BOOT_SIZE - 1,
  79. };
  80. static struct platform_device ts78xx_nor_boot_flash = {
  81. .name = "physmap-flash",
  82. .id = -1,
  83. .dev = {
  84. .platform_data = &ts78xx_nor_boot_flash_data,
  85. },
  86. .num_resources = 1,
  87. .resource = &ts78xx_nor_boot_flash_resource,
  88. };
  89. /*****************************************************************************
  90. * Ethernet
  91. ****************************************************************************/
  92. static struct mv643xx_eth_platform_data ts78xx_eth_data = {
  93. .phy_addr = MV643XX_ETH_PHY_ADDR(0),
  94. };
  95. /*****************************************************************************
  96. * RTC M48T86 - nicked^Wborrowed from arch/arm/mach-ep93xx/ts72xx.c
  97. ****************************************************************************/
  98. #ifdef CONFIG_RTC_DRV_M48T86
  99. static unsigned char ts78xx_rtc_readbyte(unsigned long addr)
  100. {
  101. writeb(addr, TS78XX_FPGA_REGS_RTC_CTRL);
  102. return readb(TS78XX_FPGA_REGS_RTC_DATA);
  103. }
  104. static void ts78xx_rtc_writebyte(unsigned char value, unsigned long addr)
  105. {
  106. writeb(addr, TS78XX_FPGA_REGS_RTC_CTRL);
  107. writeb(value, TS78XX_FPGA_REGS_RTC_DATA);
  108. }
  109. static struct m48t86_ops ts78xx_rtc_ops = {
  110. .readbyte = ts78xx_rtc_readbyte,
  111. .writebyte = ts78xx_rtc_writebyte,
  112. };
  113. static struct platform_device ts78xx_rtc_device = {
  114. .name = "rtc-m48t86",
  115. .id = -1,
  116. .dev = {
  117. .platform_data = &ts78xx_rtc_ops,
  118. },
  119. .num_resources = 0,
  120. };
  121. /*
  122. * TS uses some of the user storage space on the RTC chip so see if it is
  123. * present; as it's an optional feature at purchase time and not all boards
  124. * will have it present
  125. *
  126. * I've used the method TS use in their rtc7800.c example for the detection
  127. *
  128. * TODO: track down a guinea pig without an RTC to see if we can work out a
  129. * better RTC detection routine
  130. */
  131. static int __init ts78xx_rtc_init(void)
  132. {
  133. unsigned char tmp_rtc0, tmp_rtc1;
  134. tmp_rtc0 = ts78xx_rtc_readbyte(126);
  135. tmp_rtc1 = ts78xx_rtc_readbyte(127);
  136. ts78xx_rtc_writebyte(0x00, 126);
  137. ts78xx_rtc_writebyte(0x55, 127);
  138. if (ts78xx_rtc_readbyte(127) == 0x55) {
  139. ts78xx_rtc_writebyte(0xaa, 127);
  140. if (ts78xx_rtc_readbyte(127) == 0xaa
  141. && ts78xx_rtc_readbyte(126) == 0x00) {
  142. ts78xx_rtc_writebyte(tmp_rtc0, 126);
  143. ts78xx_rtc_writebyte(tmp_rtc1, 127);
  144. platform_device_register(&ts78xx_rtc_device);
  145. return 1;
  146. }
  147. }
  148. return 0;
  149. };
  150. #else
  151. static int __init ts78xx_rtc_init(void)
  152. {
  153. return 0;
  154. }
  155. #endif
  156. /*****************************************************************************
  157. * SATA
  158. ****************************************************************************/
  159. static struct mv_sata_platform_data ts78xx_sata_data = {
  160. .n_ports = 2,
  161. };
  162. /*****************************************************************************
  163. * print some information regarding the board
  164. ****************************************************************************/
  165. static void __init ts78xx_print_board_id(void)
  166. {
  167. unsigned int board_info;
  168. board_info = readl(TS78XX_FPGA_REGS_SYSCON_ID);
  169. printk(KERN_INFO "TS-78xx Info: FPGA rev=%.2x, Board Magic=%.6x, ",
  170. board_info & 0xff,
  171. (board_info >> 8) & 0xffffff);
  172. board_info = readl(TS78XX_FPGA_REGS_SYSCON_LCDI);
  173. printk("JP1=%d, JP2=%d\n",
  174. (board_info >> 30) & 0x1,
  175. (board_info >> 31) & 0x1);
  176. };
  177. /*****************************************************************************
  178. * General Setup
  179. ****************************************************************************/
  180. static struct orion5x_mpp_mode ts78xx_mpp_modes[] __initdata = {
  181. { 0, MPP_UNUSED },
  182. { 1, MPP_GPIO }, /* JTAG Clock */
  183. { 2, MPP_GPIO }, /* JTAG Data In */
  184. { 3, MPP_GPIO }, /* Lat ECP2 256 FPGA - PB2B */
  185. { 4, MPP_GPIO }, /* JTAG Data Out */
  186. { 5, MPP_GPIO }, /* JTAG TMS */
  187. { 6, MPP_GPIO }, /* Lat ECP2 256 FPGA - PB31A_CLK4+ */
  188. { 7, MPP_GPIO }, /* Lat ECP2 256 FPGA - PB22B */
  189. { 8, MPP_UNUSED },
  190. { 9, MPP_UNUSED },
  191. { 10, MPP_UNUSED },
  192. { 11, MPP_UNUSED },
  193. { 12, MPP_UNUSED },
  194. { 13, MPP_UNUSED },
  195. { 14, MPP_UNUSED },
  196. { 15, MPP_UNUSED },
  197. { 16, MPP_UART },
  198. { 17, MPP_UART },
  199. { 18, MPP_UART },
  200. { 19, MPP_UART },
  201. { -1 },
  202. };
  203. static void __init ts78xx_init(void)
  204. {
  205. /*
  206. * Setup basic Orion functions. Need to be called early.
  207. */
  208. orion5x_init();
  209. ts78xx_print_board_id();
  210. orion5x_mpp_conf(ts78xx_mpp_modes);
  211. /*
  212. * MPP[20] PCI Clock Out 1
  213. * MPP[21] PCI Clock Out 0
  214. * MPP[22] Unused
  215. * MPP[23] Unused
  216. * MPP[24] Unused
  217. * MPP[25] Unused
  218. */
  219. /*
  220. * Configure peripherals.
  221. */
  222. orion5x_ehci0_init();
  223. orion5x_ehci1_init();
  224. orion5x_eth_init(&ts78xx_eth_data);
  225. orion5x_sata_init(&ts78xx_sata_data);
  226. orion5x_uart0_init();
  227. orion5x_uart1_init();
  228. orion5x_xor_init();
  229. orion5x_setup_dev_boot_win(TS78XX_NOR_BOOT_BASE,
  230. TS78XX_NOR_BOOT_SIZE);
  231. platform_device_register(&ts78xx_nor_boot_flash);
  232. if (!ts78xx_rtc_init())
  233. printk(KERN_INFO "TS-78xx RTC not detected or enabled\n");
  234. }
  235. MACHINE_START(TS78XX, "Technologic Systems TS-78xx SBC")
  236. /* Maintainer: Alexander Clouter <alex@digriz.org.uk> */
  237. .phys_io = ORION5X_REGS_PHYS_BASE,
  238. .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
  239. .boot_params = 0x00000100,
  240. .init_machine = ts78xx_init,
  241. .map_io = ts78xx_map_io,
  242. .init_irq = orion5x_init_irq,
  243. .timer = &orion5x_timer,
  244. MACHINE_END