mach-vr1000.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright (c) 2003-2008 Simtec Electronics
  4. // Ben Dooks <ben@simtec.co.uk>
  5. //
  6. // Machine support for Thorcom VR1000 board. Designed for Thorcom by
  7. // Simtec Electronics, http://www.simtec.co.uk/
  8. #include <linux/kernel.h>
  9. #include <linux/types.h>
  10. #include <linux/interrupt.h>
  11. #include <linux/list.h>
  12. #include <linux/timer.h>
  13. #include <linux/init.h>
  14. #include <linux/gpio.h>
  15. #include <linux/dm9000.h>
  16. #include <linux/i2c.h>
  17. #include <linux/serial.h>
  18. #include <linux/tty.h>
  19. #include <linux/serial_8250.h>
  20. #include <linux/serial_reg.h>
  21. #include <linux/serial_s3c.h>
  22. #include <linux/io.h>
  23. #include <asm/mach/arch.h>
  24. #include <asm/mach/map.h>
  25. #include <asm/mach/irq.h>
  26. #include <asm/irq.h>
  27. #include <asm/mach-types.h>
  28. #include <linux/platform_data/leds-s3c24xx.h>
  29. #include <linux/platform_data/i2c-s3c2410.h>
  30. #include <linux/platform_data/asoc-s3c24xx_simtec.h>
  31. #include <mach/hardware.h>
  32. #include <mach/regs-gpio.h>
  33. #include <mach/gpio-samsung.h>
  34. #include <plat/cpu.h>
  35. #include <plat/devs.h>
  36. #include <plat/samsung-time.h>
  37. #include "bast.h"
  38. #include "common.h"
  39. #include "simtec.h"
  40. #include "vr1000.h"
  41. /* macros for virtual address mods for the io space entries */
  42. #define VA_C5(item) ((unsigned long)(item) + BAST_VAM_CS5)
  43. #define VA_C4(item) ((unsigned long)(item) + BAST_VAM_CS4)
  44. #define VA_C3(item) ((unsigned long)(item) + BAST_VAM_CS3)
  45. #define VA_C2(item) ((unsigned long)(item) + BAST_VAM_CS2)
  46. /* macros to modify the physical addresses for io space */
  47. #define PA_CS2(item) (__phys_to_pfn((item) + S3C2410_CS2))
  48. #define PA_CS3(item) (__phys_to_pfn((item) + S3C2410_CS3))
  49. #define PA_CS4(item) (__phys_to_pfn((item) + S3C2410_CS4))
  50. #define PA_CS5(item) (__phys_to_pfn((item) + S3C2410_CS5))
  51. static struct map_desc vr1000_iodesc[] __initdata = {
  52. /* ISA IO areas */
  53. {
  54. .virtual = (u32)S3C24XX_VA_ISA_BYTE,
  55. .pfn = PA_CS2(BAST_PA_ISAIO),
  56. .length = SZ_16M,
  57. .type = MT_DEVICE,
  58. }, {
  59. .virtual = (u32)S3C24XX_VA_ISA_WORD,
  60. .pfn = PA_CS3(BAST_PA_ISAIO),
  61. .length = SZ_16M,
  62. .type = MT_DEVICE,
  63. },
  64. /* CPLD control registers, and external interrupt controls */
  65. {
  66. .virtual = (u32)VR1000_VA_CTRL1,
  67. .pfn = __phys_to_pfn(VR1000_PA_CTRL1),
  68. .length = SZ_1M,
  69. .type = MT_DEVICE,
  70. }, {
  71. .virtual = (u32)VR1000_VA_CTRL2,
  72. .pfn = __phys_to_pfn(VR1000_PA_CTRL2),
  73. .length = SZ_1M,
  74. .type = MT_DEVICE,
  75. }, {
  76. .virtual = (u32)VR1000_VA_CTRL3,
  77. .pfn = __phys_to_pfn(VR1000_PA_CTRL3),
  78. .length = SZ_1M,
  79. .type = MT_DEVICE,
  80. }, {
  81. .virtual = (u32)VR1000_VA_CTRL4,
  82. .pfn = __phys_to_pfn(VR1000_PA_CTRL4),
  83. .length = SZ_1M,
  84. .type = MT_DEVICE,
  85. },
  86. };
  87. #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
  88. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
  89. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  90. static struct s3c2410_uartcfg vr1000_uartcfgs[] __initdata = {
  91. [0] = {
  92. .hwport = 0,
  93. .flags = 0,
  94. .ucon = UCON,
  95. .ulcon = ULCON,
  96. .ufcon = UFCON,
  97. },
  98. [1] = {
  99. .hwport = 1,
  100. .flags = 0,
  101. .ucon = UCON,
  102. .ulcon = ULCON,
  103. .ufcon = UFCON,
  104. },
  105. /* port 2 is not actually used */
  106. [2] = {
  107. .hwport = 2,
  108. .flags = 0,
  109. .ucon = UCON,
  110. .ulcon = ULCON,
  111. .ufcon = UFCON,
  112. }
  113. };
  114. /* definitions for the vr1000 extra 16550 serial ports */
  115. #define VR1000_BAUDBASE (3692307)
  116. #define VR1000_SERIAL_MAPBASE(x) (VR1000_PA_SERIAL + 0x80 + ((x) << 5))
  117. static struct plat_serial8250_port serial_platform_data[] = {
  118. [0] = {
  119. .mapbase = VR1000_SERIAL_MAPBASE(0),
  120. .irq = VR1000_IRQ_SERIAL + 0,
  121. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  122. .iotype = UPIO_MEM,
  123. .regshift = 0,
  124. .uartclk = VR1000_BAUDBASE,
  125. },
  126. [1] = {
  127. .mapbase = VR1000_SERIAL_MAPBASE(1),
  128. .irq = VR1000_IRQ_SERIAL + 1,
  129. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  130. .iotype = UPIO_MEM,
  131. .regshift = 0,
  132. .uartclk = VR1000_BAUDBASE,
  133. },
  134. [2] = {
  135. .mapbase = VR1000_SERIAL_MAPBASE(2),
  136. .irq = VR1000_IRQ_SERIAL + 2,
  137. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  138. .iotype = UPIO_MEM,
  139. .regshift = 0,
  140. .uartclk = VR1000_BAUDBASE,
  141. },
  142. [3] = {
  143. .mapbase = VR1000_SERIAL_MAPBASE(3),
  144. .irq = VR1000_IRQ_SERIAL + 3,
  145. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  146. .iotype = UPIO_MEM,
  147. .regshift = 0,
  148. .uartclk = VR1000_BAUDBASE,
  149. },
  150. { },
  151. };
  152. static struct platform_device serial_device = {
  153. .name = "serial8250",
  154. .id = PLAT8250_DEV_PLATFORM,
  155. .dev = {
  156. .platform_data = serial_platform_data,
  157. },
  158. };
  159. /* DM9000 ethernet devices */
  160. static struct resource vr1000_dm9k0_resource[] = {
  161. [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000, 4),
  162. [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x40, 0x40),
  163. [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000A, 1, NULL, IORESOURCE_IRQ \
  164. | IORESOURCE_IRQ_HIGHLEVEL),
  165. };
  166. static struct resource vr1000_dm9k1_resource[] = {
  167. [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x80, 4),
  168. [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0xC0, 0x40),
  169. [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000N, 1, NULL, IORESOURCE_IRQ \
  170. | IORESOURCE_IRQ_HIGHLEVEL),
  171. };
  172. /* for the moment we limit ourselves to 16bit IO until some
  173. * better IO routines can be written and tested
  174. */
  175. static struct dm9000_plat_data vr1000_dm9k_platdata = {
  176. .flags = DM9000_PLATF_16BITONLY,
  177. };
  178. static struct platform_device vr1000_dm9k0 = {
  179. .name = "dm9000",
  180. .id = 0,
  181. .num_resources = ARRAY_SIZE(vr1000_dm9k0_resource),
  182. .resource = vr1000_dm9k0_resource,
  183. .dev = {
  184. .platform_data = &vr1000_dm9k_platdata,
  185. }
  186. };
  187. static struct platform_device vr1000_dm9k1 = {
  188. .name = "dm9000",
  189. .id = 1,
  190. .num_resources = ARRAY_SIZE(vr1000_dm9k1_resource),
  191. .resource = vr1000_dm9k1_resource,
  192. .dev = {
  193. .platform_data = &vr1000_dm9k_platdata,
  194. }
  195. };
  196. /* LEDS */
  197. static struct s3c24xx_led_platdata vr1000_led1_pdata = {
  198. .name = "led1",
  199. .gpio = S3C2410_GPB(0),
  200. .def_trigger = "",
  201. };
  202. static struct s3c24xx_led_platdata vr1000_led2_pdata = {
  203. .name = "led2",
  204. .gpio = S3C2410_GPB(1),
  205. .def_trigger = "",
  206. };
  207. static struct s3c24xx_led_platdata vr1000_led3_pdata = {
  208. .name = "led3",
  209. .gpio = S3C2410_GPB(2),
  210. .def_trigger = "",
  211. };
  212. static struct platform_device vr1000_led1 = {
  213. .name = "s3c24xx_led",
  214. .id = 1,
  215. .dev = {
  216. .platform_data = &vr1000_led1_pdata,
  217. },
  218. };
  219. static struct platform_device vr1000_led2 = {
  220. .name = "s3c24xx_led",
  221. .id = 2,
  222. .dev = {
  223. .platform_data = &vr1000_led2_pdata,
  224. },
  225. };
  226. static struct platform_device vr1000_led3 = {
  227. .name = "s3c24xx_led",
  228. .id = 3,
  229. .dev = {
  230. .platform_data = &vr1000_led3_pdata,
  231. },
  232. };
  233. /* I2C devices. */
  234. static struct i2c_board_info vr1000_i2c_devs[] __initdata = {
  235. {
  236. I2C_BOARD_INFO("tlv320aic23", 0x1a),
  237. }, {
  238. I2C_BOARD_INFO("tmp101", 0x48),
  239. }, {
  240. I2C_BOARD_INFO("m41st87", 0x68),
  241. },
  242. };
  243. /* devices for this board */
  244. static struct platform_device *vr1000_devices[] __initdata = {
  245. &s3c2410_device_dclk,
  246. &s3c_device_ohci,
  247. &s3c_device_lcd,
  248. &s3c_device_wdt,
  249. &s3c_device_i2c0,
  250. &s3c_device_adc,
  251. &serial_device,
  252. &vr1000_dm9k0,
  253. &vr1000_dm9k1,
  254. &vr1000_led1,
  255. &vr1000_led2,
  256. &vr1000_led3,
  257. };
  258. static void vr1000_power_off(void)
  259. {
  260. gpio_direction_output(S3C2410_GPB(9), 1);
  261. }
  262. static void __init vr1000_map_io(void)
  263. {
  264. pm_power_off = vr1000_power_off;
  265. s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
  266. s3c24xx_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
  267. samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
  268. }
  269. static void __init vr1000_init_time(void)
  270. {
  271. s3c2410_init_clocks(12000000);
  272. samsung_timer_init();
  273. }
  274. static void __init vr1000_init(void)
  275. {
  276. s3c_i2c0_set_platdata(NULL);
  277. platform_add_devices(vr1000_devices, ARRAY_SIZE(vr1000_devices));
  278. i2c_register_board_info(0, vr1000_i2c_devs,
  279. ARRAY_SIZE(vr1000_i2c_devs));
  280. nor_simtec_init();
  281. simtec_audio_add(NULL, true, NULL);
  282. WARN_ON(gpio_request(S3C2410_GPB(9), "power off"));
  283. }
  284. MACHINE_START(VR1000, "Thorcom-VR1000")
  285. /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
  286. .atag_offset = 0x100,
  287. .map_io = vr1000_map_io,
  288. .init_machine = vr1000_init,
  289. .init_irq = s3c2410_init_irq,
  290. .init_time = vr1000_init_time,
  291. MACHINE_END