mach-vr1000.c 8.1 KB

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