mach-vr1000.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright (c) 2003-2008 Simtec Electronics
  4. // Ben Dooks <[email protected]>
  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/gpio/machine.h>
  16. #include <linux/dm9000.h>
  17. #include <linux/i2c.h>
  18. #include <linux/serial.h>
  19. #include <linux/tty.h>
  20. #include <linux/serial_8250.h>
  21. #include <linux/serial_reg.h>
  22. #include <linux/serial_s3c.h>
  23. #include <linux/io.h>
  24. #include <asm/mach/arch.h>
  25. #include <asm/mach/map.h>
  26. #include <asm/mach/irq.h>
  27. #include <asm/irq.h>
  28. #include <asm/mach-types.h>
  29. #include <linux/platform_data/leds-s3c24xx.h>
  30. #include <linux/platform_data/i2c-s3c2410.h>
  31. #include <linux/platform_data/asoc-s3c24xx_simtec.h>
  32. #include "regs-gpio.h"
  33. #include "gpio-samsung.h"
  34. #include "gpio-cfg.h"
  35. #include "cpu.h"
  36. #include "devs.h"
  37. #include "bast.h"
  38. #include "s3c24xx.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. /* CPLD control registers, and external interrupt controls */
  60. {
  61. .virtual = (u32)VR1000_VA_CTRL1,
  62. .pfn = __phys_to_pfn(VR1000_PA_CTRL1),
  63. .length = SZ_1M,
  64. .type = MT_DEVICE,
  65. }, {
  66. .virtual = (u32)VR1000_VA_CTRL2,
  67. .pfn = __phys_to_pfn(VR1000_PA_CTRL2),
  68. .length = SZ_1M,
  69. .type = MT_DEVICE,
  70. }, {
  71. .virtual = (u32)VR1000_VA_CTRL3,
  72. .pfn = __phys_to_pfn(VR1000_PA_CTRL3),
  73. .length = SZ_1M,
  74. .type = MT_DEVICE,
  75. }, {
  76. .virtual = (u32)VR1000_VA_CTRL4,
  77. .pfn = __phys_to_pfn(VR1000_PA_CTRL4),
  78. .length = SZ_1M,
  79. .type = MT_DEVICE,
  80. },
  81. };
  82. #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
  83. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
  84. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  85. static struct s3c2410_uartcfg vr1000_uartcfgs[] __initdata = {
  86. [0] = {
  87. .hwport = 0,
  88. .flags = 0,
  89. .ucon = UCON,
  90. .ulcon = ULCON,
  91. .ufcon = UFCON,
  92. },
  93. [1] = {
  94. .hwport = 1,
  95. .flags = 0,
  96. .ucon = UCON,
  97. .ulcon = ULCON,
  98. .ufcon = UFCON,
  99. },
  100. /* port 2 is not actually used */
  101. [2] = {
  102. .hwport = 2,
  103. .flags = 0,
  104. .ucon = UCON,
  105. .ulcon = ULCON,
  106. .ufcon = UFCON,
  107. }
  108. };
  109. /* definitions for the vr1000 extra 16550 serial ports */
  110. #define VR1000_BAUDBASE (3692307)
  111. #define VR1000_SERIAL_MAPBASE(x) (VR1000_PA_SERIAL + 0x80 + ((x) << 5))
  112. static struct plat_serial8250_port serial_platform_data[] = {
  113. [0] = {
  114. .mapbase = VR1000_SERIAL_MAPBASE(0),
  115. .irq = VR1000_IRQ_SERIAL + 0,
  116. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  117. .iotype = UPIO_MEM,
  118. .regshift = 0,
  119. .uartclk = VR1000_BAUDBASE,
  120. },
  121. [1] = {
  122. .mapbase = VR1000_SERIAL_MAPBASE(1),
  123. .irq = VR1000_IRQ_SERIAL + 1,
  124. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  125. .iotype = UPIO_MEM,
  126. .regshift = 0,
  127. .uartclk = VR1000_BAUDBASE,
  128. },
  129. [2] = {
  130. .mapbase = VR1000_SERIAL_MAPBASE(2),
  131. .irq = VR1000_IRQ_SERIAL + 2,
  132. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  133. .iotype = UPIO_MEM,
  134. .regshift = 0,
  135. .uartclk = VR1000_BAUDBASE,
  136. },
  137. [3] = {
  138. .mapbase = VR1000_SERIAL_MAPBASE(3),
  139. .irq = VR1000_IRQ_SERIAL + 3,
  140. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  141. .iotype = UPIO_MEM,
  142. .regshift = 0,
  143. .uartclk = VR1000_BAUDBASE,
  144. },
  145. { },
  146. };
  147. static struct platform_device serial_device = {
  148. .name = "serial8250",
  149. .id = PLAT8250_DEV_PLATFORM,
  150. .dev = {
  151. .platform_data = serial_platform_data,
  152. },
  153. };
  154. /* DM9000 ethernet devices */
  155. static struct resource vr1000_dm9k0_resource[] = {
  156. [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000, 4),
  157. [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x40, 0x40),
  158. [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000A, 1, NULL, IORESOURCE_IRQ \
  159. | IORESOURCE_IRQ_HIGHLEVEL),
  160. };
  161. static struct resource vr1000_dm9k1_resource[] = {
  162. [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x80, 4),
  163. [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0xC0, 0x40),
  164. [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000N, 1, NULL, IORESOURCE_IRQ \
  165. | IORESOURCE_IRQ_HIGHLEVEL),
  166. };
  167. /* for the moment we limit ourselves to 16bit IO until some
  168. * better IO routines can be written and tested
  169. */
  170. static struct dm9000_plat_data vr1000_dm9k_platdata = {
  171. .flags = DM9000_PLATF_16BITONLY,
  172. };
  173. static struct platform_device vr1000_dm9k0 = {
  174. .name = "dm9000",
  175. .id = 0,
  176. .num_resources = ARRAY_SIZE(vr1000_dm9k0_resource),
  177. .resource = vr1000_dm9k0_resource,
  178. .dev = {
  179. .platform_data = &vr1000_dm9k_platdata,
  180. }
  181. };
  182. static struct platform_device vr1000_dm9k1 = {
  183. .name = "dm9000",
  184. .id = 1,
  185. .num_resources = ARRAY_SIZE(vr1000_dm9k1_resource),
  186. .resource = vr1000_dm9k1_resource,
  187. .dev = {
  188. .platform_data = &vr1000_dm9k_platdata,
  189. }
  190. };
  191. /* LEDS */
  192. static struct gpiod_lookup_table vr1000_led1_gpio_table = {
  193. .dev_id = "s3c24xx_led.1",
  194. .table = {
  195. GPIO_LOOKUP("GPB", 0, NULL, GPIO_ACTIVE_HIGH),
  196. { },
  197. },
  198. };
  199. static struct gpiod_lookup_table vr1000_led2_gpio_table = {
  200. .dev_id = "s3c24xx_led.2",
  201. .table = {
  202. GPIO_LOOKUP("GPB", 1, NULL, GPIO_ACTIVE_HIGH),
  203. { },
  204. },
  205. };
  206. static struct gpiod_lookup_table vr1000_led3_gpio_table = {
  207. .dev_id = "s3c24xx_led.3",
  208. .table = {
  209. GPIO_LOOKUP("GPB", 2, NULL, GPIO_ACTIVE_HIGH),
  210. { },
  211. },
  212. };
  213. static struct s3c24xx_led_platdata vr1000_led1_pdata = {
  214. .name = "led1",
  215. .def_trigger = "",
  216. };
  217. static struct s3c24xx_led_platdata vr1000_led2_pdata = {
  218. .name = "led2",
  219. .def_trigger = "",
  220. };
  221. static struct s3c24xx_led_platdata vr1000_led3_pdata = {
  222. .name = "led3",
  223. .def_trigger = "",
  224. };
  225. static struct platform_device vr1000_led1 = {
  226. .name = "s3c24xx_led",
  227. .id = 1,
  228. .dev = {
  229. .platform_data = &vr1000_led1_pdata,
  230. },
  231. };
  232. static struct platform_device vr1000_led2 = {
  233. .name = "s3c24xx_led",
  234. .id = 2,
  235. .dev = {
  236. .platform_data = &vr1000_led2_pdata,
  237. },
  238. };
  239. static struct platform_device vr1000_led3 = {
  240. .name = "s3c24xx_led",
  241. .id = 3,
  242. .dev = {
  243. .platform_data = &vr1000_led3_pdata,
  244. },
  245. };
  246. /* I2C devices. */
  247. static struct i2c_board_info vr1000_i2c_devs[] __initdata = {
  248. {
  249. I2C_BOARD_INFO("tlv320aic23", 0x1a),
  250. }, {
  251. I2C_BOARD_INFO("tmp101", 0x48),
  252. }, {
  253. I2C_BOARD_INFO("m41st87", 0x68),
  254. },
  255. };
  256. /* devices for this board */
  257. static struct platform_device *vr1000_devices[] __initdata = {
  258. &s3c2410_device_dclk,
  259. &s3c_device_ohci,
  260. &s3c_device_lcd,
  261. &s3c_device_wdt,
  262. &s3c_device_i2c0,
  263. &s3c_device_adc,
  264. &serial_device,
  265. &vr1000_dm9k0,
  266. &vr1000_dm9k1,
  267. &vr1000_led1,
  268. &vr1000_led2,
  269. &vr1000_led3,
  270. };
  271. static void vr1000_power_off(void)
  272. {
  273. gpio_direction_output(S3C2410_GPB(9), 1);
  274. }
  275. static void __init vr1000_map_io(void)
  276. {
  277. pm_power_off = vr1000_power_off;
  278. s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
  279. s3c24xx_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
  280. s3c24xx_set_timer_source(S3C24XX_PWM3, S3C24XX_PWM4);
  281. }
  282. static void __init vr1000_init_time(void)
  283. {
  284. s3c2410_init_clocks(12000000);
  285. s3c24xx_timer_init();
  286. }
  287. static void __init vr1000_init(void)
  288. {
  289. s3c_i2c0_set_platdata(NULL);
  290. /* Disable pull-up on LED lines and register GPIO lookups */
  291. s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
  292. s3c_gpio_setpull(S3C2410_GPB(1), S3C_GPIO_PULL_NONE);
  293. s3c_gpio_setpull(S3C2410_GPB(2), S3C_GPIO_PULL_NONE);
  294. gpiod_add_lookup_table(&vr1000_led1_gpio_table);
  295. gpiod_add_lookup_table(&vr1000_led2_gpio_table);
  296. gpiod_add_lookup_table(&vr1000_led3_gpio_table);
  297. platform_add_devices(vr1000_devices, ARRAY_SIZE(vr1000_devices));
  298. i2c_register_board_info(0, vr1000_i2c_devs,
  299. ARRAY_SIZE(vr1000_i2c_devs));
  300. nor_simtec_init();
  301. simtec_audio_add(NULL, true, NULL);
  302. WARN_ON(gpio_request(S3C2410_GPB(9), "power off"));
  303. }
  304. MACHINE_START(VR1000, "Thorcom-VR1000")
  305. /* Maintainer: Ben Dooks <[email protected]> */
  306. .atag_offset = 0x100,
  307. .nr_irqs = NR_IRQS_S3C2410,
  308. .map_io = vr1000_map_io,
  309. .init_machine = vr1000_init,
  310. .init_irq = s3c2410_init_irq,
  311. .init_time = vr1000_init_time,
  312. MACHINE_END