ts72xx.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * arch/arm/mach-ep93xx/ts72xx.c
  3. * Technologic Systems TS72xx SBC support.
  4. *
  5. * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at
  10. * your option) any later version.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/mm.h>
  15. #include <linux/sched.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/ioport.h>
  18. #include <linux/mtd/physmap.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/m48t86.h>
  21. #include <linux/io.h>
  22. #include <linux/i2c.h>
  23. #include <mach/hardware.h>
  24. #include <asm/mach-types.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach/map.h>
  27. static struct map_desc ts72xx_io_desc[] __initdata = {
  28. {
  29. .virtual = TS72XX_MODEL_VIRT_BASE,
  30. .pfn = __phys_to_pfn(TS72XX_MODEL_PHYS_BASE),
  31. .length = TS72XX_MODEL_SIZE,
  32. .type = MT_DEVICE,
  33. }, {
  34. .virtual = TS72XX_OPTIONS_VIRT_BASE,
  35. .pfn = __phys_to_pfn(TS72XX_OPTIONS_PHYS_BASE),
  36. .length = TS72XX_OPTIONS_SIZE,
  37. .type = MT_DEVICE,
  38. }, {
  39. .virtual = TS72XX_OPTIONS2_VIRT_BASE,
  40. .pfn = __phys_to_pfn(TS72XX_OPTIONS2_PHYS_BASE),
  41. .length = TS72XX_OPTIONS2_SIZE,
  42. .type = MT_DEVICE,
  43. }, {
  44. .virtual = TS72XX_RTC_INDEX_VIRT_BASE,
  45. .pfn = __phys_to_pfn(TS72XX_RTC_INDEX_PHYS_BASE),
  46. .length = TS72XX_RTC_INDEX_SIZE,
  47. .type = MT_DEVICE,
  48. }, {
  49. .virtual = TS72XX_RTC_DATA_VIRT_BASE,
  50. .pfn = __phys_to_pfn(TS72XX_RTC_DATA_PHYS_BASE),
  51. .length = TS72XX_RTC_DATA_SIZE,
  52. .type = MT_DEVICE,
  53. }
  54. };
  55. static struct map_desc ts72xx_nand_io_desc[] __initdata = {
  56. {
  57. .virtual = TS72XX_NAND_DATA_VIRT_BASE,
  58. .pfn = __phys_to_pfn(TS72XX_NAND1_DATA_PHYS_BASE),
  59. .length = TS72XX_NAND_DATA_SIZE,
  60. .type = MT_DEVICE,
  61. }, {
  62. .virtual = TS72XX_NAND_CONTROL_VIRT_BASE,
  63. .pfn = __phys_to_pfn(TS72XX_NAND1_CONTROL_PHYS_BASE),
  64. .length = TS72XX_NAND_CONTROL_SIZE,
  65. .type = MT_DEVICE,
  66. }, {
  67. .virtual = TS72XX_NAND_BUSY_VIRT_BASE,
  68. .pfn = __phys_to_pfn(TS72XX_NAND1_BUSY_PHYS_BASE),
  69. .length = TS72XX_NAND_BUSY_SIZE,
  70. .type = MT_DEVICE,
  71. }
  72. };
  73. static struct map_desc ts72xx_alternate_nand_io_desc[] __initdata = {
  74. {
  75. .virtual = TS72XX_NAND_DATA_VIRT_BASE,
  76. .pfn = __phys_to_pfn(TS72XX_NAND2_DATA_PHYS_BASE),
  77. .length = TS72XX_NAND_DATA_SIZE,
  78. .type = MT_DEVICE,
  79. }, {
  80. .virtual = TS72XX_NAND_CONTROL_VIRT_BASE,
  81. .pfn = __phys_to_pfn(TS72XX_NAND2_CONTROL_PHYS_BASE),
  82. .length = TS72XX_NAND_CONTROL_SIZE,
  83. .type = MT_DEVICE,
  84. }, {
  85. .virtual = TS72XX_NAND_BUSY_VIRT_BASE,
  86. .pfn = __phys_to_pfn(TS72XX_NAND2_BUSY_PHYS_BASE),
  87. .length = TS72XX_NAND_BUSY_SIZE,
  88. .type = MT_DEVICE,
  89. }
  90. };
  91. static void __init ts72xx_map_io(void)
  92. {
  93. ep93xx_map_io();
  94. iotable_init(ts72xx_io_desc, ARRAY_SIZE(ts72xx_io_desc));
  95. /*
  96. * The TS-7200 has NOR flash, the other models have NAND flash.
  97. */
  98. if (!board_is_ts7200()) {
  99. if (is_ts9420_installed()) {
  100. iotable_init(ts72xx_alternate_nand_io_desc,
  101. ARRAY_SIZE(ts72xx_alternate_nand_io_desc));
  102. } else {
  103. iotable_init(ts72xx_nand_io_desc,
  104. ARRAY_SIZE(ts72xx_nand_io_desc));
  105. }
  106. }
  107. }
  108. static struct physmap_flash_data ts72xx_flash_data = {
  109. .width = 1,
  110. };
  111. static struct resource ts72xx_flash_resource = {
  112. .start = TS72XX_NOR_PHYS_BASE,
  113. .end = TS72XX_NOR_PHYS_BASE + SZ_16M - 1,
  114. .flags = IORESOURCE_MEM,
  115. };
  116. static struct platform_device ts72xx_flash = {
  117. .name = "physmap-flash",
  118. .id = 0,
  119. .dev = {
  120. .platform_data = &ts72xx_flash_data,
  121. },
  122. .num_resources = 1,
  123. .resource = &ts72xx_flash_resource,
  124. };
  125. static unsigned char ts72xx_rtc_readbyte(unsigned long addr)
  126. {
  127. __raw_writeb(addr, TS72XX_RTC_INDEX_VIRT_BASE);
  128. return __raw_readb(TS72XX_RTC_DATA_VIRT_BASE);
  129. }
  130. static void ts72xx_rtc_writebyte(unsigned char value, unsigned long addr)
  131. {
  132. __raw_writeb(addr, TS72XX_RTC_INDEX_VIRT_BASE);
  133. __raw_writeb(value, TS72XX_RTC_DATA_VIRT_BASE);
  134. }
  135. static struct m48t86_ops ts72xx_rtc_ops = {
  136. .readbyte = ts72xx_rtc_readbyte,
  137. .writebyte = ts72xx_rtc_writebyte,
  138. };
  139. static struct platform_device ts72xx_rtc_device = {
  140. .name = "rtc-m48t86",
  141. .id = -1,
  142. .dev = {
  143. .platform_data = &ts72xx_rtc_ops,
  144. },
  145. .num_resources = 0,
  146. };
  147. static struct ep93xx_eth_data ts72xx_eth_data = {
  148. .phy_id = 1,
  149. };
  150. static void __init ts72xx_init_machine(void)
  151. {
  152. ep93xx_init_devices();
  153. if (board_is_ts7200())
  154. platform_device_register(&ts72xx_flash);
  155. platform_device_register(&ts72xx_rtc_device);
  156. ep93xx_register_eth(&ts72xx_eth_data, 1);
  157. }
  158. MACHINE_START(TS72XX, "Technologic Systems TS-72xx SBC")
  159. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  160. .phys_io = EP93XX_APB_PHYS_BASE,
  161. .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
  162. .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
  163. .map_io = ts72xx_map_io,
  164. .init_irq = ep93xx_init_irq,
  165. .timer = &ep93xx_timer,
  166. .init_machine = ts72xx_init_machine,
  167. MACHINE_END