common.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /*
  2. * Copyright (c) 2009-2011 Samsung Electronics Co., Ltd.
  3. * http://www.samsung.com
  4. *
  5. * Common Codes for S5PV210
  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 version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/types.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/list.h>
  15. #include <linux/timer.h>
  16. #include <linux/init.h>
  17. #include <linux/module.h>
  18. #include <linux/clk.h>
  19. #include <linux/io.h>
  20. #include <linux/device.h>
  21. #include <clocksource/samsung_pwm.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/sched.h>
  24. #include <linux/dma-mapping.h>
  25. #include <linux/serial_core.h>
  26. #include <asm/proc-fns.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <asm/mach/irq.h>
  30. #include <mach/map.h>
  31. #include <mach/regs-clock.h>
  32. #include <plat/cpu.h>
  33. #include <plat/clock.h>
  34. #include <plat/devs.h>
  35. #include <plat/sdhci.h>
  36. #include <plat/adc-core.h>
  37. #include <plat/ata-core.h>
  38. #include <plat/fb-core.h>
  39. #include <plat/fimc-core.h>
  40. #include <plat/iic-core.h>
  41. #include <plat/keypad-core.h>
  42. #include <plat/pwm-core.h>
  43. #include <plat/tv-core.h>
  44. #include <plat/spi-core.h>
  45. #include <plat/regs-serial.h>
  46. #include "common.h"
  47. static const char name_s5pv210[] = "S5PV210/S5PC110";
  48. static struct cpu_table cpu_ids[] __initdata = {
  49. {
  50. .idcode = S5PV210_CPU_ID,
  51. .idmask = S5PV210_CPU_MASK,
  52. .map_io = s5pv210_map_io,
  53. .init_clocks = s5pv210_init_clocks,
  54. .init_uarts = s5pv210_init_uarts,
  55. .init = s5pv210_init,
  56. .name = name_s5pv210,
  57. },
  58. };
  59. /* Initial IO mappings */
  60. static struct map_desc s5pv210_iodesc[] __initdata = {
  61. {
  62. .virtual = (unsigned long)S5P_VA_CHIPID,
  63. .pfn = __phys_to_pfn(S5PV210_PA_CHIPID),
  64. .length = SZ_4K,
  65. .type = MT_DEVICE,
  66. }, {
  67. .virtual = (unsigned long)S3C_VA_SYS,
  68. .pfn = __phys_to_pfn(S5PV210_PA_SYSCON),
  69. .length = SZ_64K,
  70. .type = MT_DEVICE,
  71. }, {
  72. .virtual = (unsigned long)S3C_VA_TIMER,
  73. .pfn = __phys_to_pfn(S5PV210_PA_TIMER),
  74. .length = SZ_16K,
  75. .type = MT_DEVICE,
  76. }, {
  77. .virtual = (unsigned long)S3C_VA_WATCHDOG,
  78. .pfn = __phys_to_pfn(S5PV210_PA_WATCHDOG),
  79. .length = SZ_4K,
  80. .type = MT_DEVICE,
  81. }, {
  82. .virtual = (unsigned long)S5P_VA_SROMC,
  83. .pfn = __phys_to_pfn(S5PV210_PA_SROMC),
  84. .length = SZ_4K,
  85. .type = MT_DEVICE,
  86. }, {
  87. .virtual = (unsigned long)S5P_VA_SYSTIMER,
  88. .pfn = __phys_to_pfn(S5PV210_PA_SYSTIMER),
  89. .length = SZ_4K,
  90. .type = MT_DEVICE,
  91. }, {
  92. .virtual = (unsigned long)S5P_VA_GPIO,
  93. .pfn = __phys_to_pfn(S5PV210_PA_GPIO),
  94. .length = SZ_4K,
  95. .type = MT_DEVICE,
  96. }, {
  97. .virtual = (unsigned long)VA_VIC0,
  98. .pfn = __phys_to_pfn(S5PV210_PA_VIC0),
  99. .length = SZ_16K,
  100. .type = MT_DEVICE,
  101. }, {
  102. .virtual = (unsigned long)VA_VIC1,
  103. .pfn = __phys_to_pfn(S5PV210_PA_VIC1),
  104. .length = SZ_16K,
  105. .type = MT_DEVICE,
  106. }, {
  107. .virtual = (unsigned long)VA_VIC2,
  108. .pfn = __phys_to_pfn(S5PV210_PA_VIC2),
  109. .length = SZ_16K,
  110. .type = MT_DEVICE,
  111. }, {
  112. .virtual = (unsigned long)VA_VIC3,
  113. .pfn = __phys_to_pfn(S5PV210_PA_VIC3),
  114. .length = SZ_16K,
  115. .type = MT_DEVICE,
  116. }, {
  117. .virtual = (unsigned long)S3C_VA_UART,
  118. .pfn = __phys_to_pfn(S3C_PA_UART),
  119. .length = SZ_512K,
  120. .type = MT_DEVICE,
  121. }, {
  122. .virtual = (unsigned long)S5P_VA_DMC0,
  123. .pfn = __phys_to_pfn(S5PV210_PA_DMC0),
  124. .length = SZ_4K,
  125. .type = MT_DEVICE,
  126. }, {
  127. .virtual = (unsigned long)S5P_VA_DMC1,
  128. .pfn = __phys_to_pfn(S5PV210_PA_DMC1),
  129. .length = SZ_4K,
  130. .type = MT_DEVICE,
  131. }, {
  132. .virtual = (unsigned long)S3C_VA_USB_HSPHY,
  133. .pfn =__phys_to_pfn(S5PV210_PA_HSPHY),
  134. .length = SZ_4K,
  135. .type = MT_DEVICE,
  136. }
  137. };
  138. void s5pv210_restart(enum reboot_mode mode, const char *cmd)
  139. {
  140. __raw_writel(0x1, S5P_SWRESET);
  141. }
  142. static struct samsung_pwm_variant s5pv210_pwm_variant = {
  143. .bits = 32,
  144. .div_base = 0,
  145. .has_tint_cstat = true,
  146. .tclk_mask = (1 << 5),
  147. };
  148. void __init samsung_set_timer_source(unsigned int event, unsigned int source)
  149. {
  150. s5pv210_pwm_variant.output_mask = BIT(SAMSUNG_PWM_NUM) - 1;
  151. s5pv210_pwm_variant.output_mask &= ~(BIT(event) | BIT(source));
  152. }
  153. void __init samsung_timer_init(void)
  154. {
  155. unsigned int timer_irqs[SAMSUNG_PWM_NUM] = {
  156. IRQ_TIMER0_VIC, IRQ_TIMER1_VIC, IRQ_TIMER2_VIC,
  157. IRQ_TIMER3_VIC, IRQ_TIMER4_VIC,
  158. };
  159. samsung_pwm_clocksource_init(S3C_VA_TIMER,
  160. timer_irqs, &s5pv210_pwm_variant);
  161. }
  162. /*
  163. * s5pv210_map_io
  164. *
  165. * register the standard cpu IO areas
  166. */
  167. void __init s5pv210_init_io(struct map_desc *mach_desc, int size)
  168. {
  169. /* initialize the io descriptors we need for initialization */
  170. iotable_init(s5pv210_iodesc, ARRAY_SIZE(s5pv210_iodesc));
  171. if (mach_desc)
  172. iotable_init(mach_desc, size);
  173. /* detect cpu id and rev. */
  174. s5p_init_cpu(S5P_VA_CHIPID);
  175. s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
  176. samsung_pwm_set_platdata(&s5pv210_pwm_variant);
  177. }
  178. void __init s5pv210_map_io(void)
  179. {
  180. /* initialise device information early */
  181. s5pv210_default_sdhci0();
  182. s5pv210_default_sdhci1();
  183. s5pv210_default_sdhci2();
  184. s5pv210_default_sdhci3();
  185. s3c_adc_setname("samsung-adc-v3");
  186. s3c_cfcon_setname("s5pv210-pata");
  187. s3c_fimc_setname(0, "s5pv210-fimc");
  188. s3c_fimc_setname(1, "s5pv210-fimc");
  189. s3c_fimc_setname(2, "s5pv210-fimc");
  190. /* the i2c devices are directly compatible with s3c2440 */
  191. s3c_i2c0_setname("s3c2440-i2c");
  192. s3c_i2c1_setname("s3c2440-i2c");
  193. s3c_i2c2_setname("s3c2440-i2c");
  194. s3c_fb_setname("s5pv210-fb");
  195. /* Use s5pv210-keypad instead of samsung-keypad */
  196. samsung_keypad_setname("s5pv210-keypad");
  197. /* setup TV devices */
  198. s5p_hdmi_setname("s5pv210-hdmi");
  199. s3c64xx_spi_setname("s5pv210-spi");
  200. }
  201. void __init s5pv210_init_clocks(int xtal)
  202. {
  203. printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
  204. s3c24xx_register_baseclocks(xtal);
  205. s5p_register_clocks(xtal);
  206. s5pv210_register_clocks();
  207. s5pv210_setup_clocks();
  208. }
  209. void __init s5pv210_init_irq(void)
  210. {
  211. u32 vic[4]; /* S5PV210 supports 4 VIC */
  212. /* All the VICs are fully populated. */
  213. vic[0] = ~0;
  214. vic[1] = ~0;
  215. vic[2] = ~0;
  216. vic[3] = ~0;
  217. s5p_init_irq(vic, ARRAY_SIZE(vic));
  218. }
  219. struct bus_type s5pv210_subsys = {
  220. .name = "s5pv210-core",
  221. .dev_name = "s5pv210-core",
  222. };
  223. static struct device s5pv210_dev = {
  224. .bus = &s5pv210_subsys,
  225. };
  226. static int __init s5pv210_core_init(void)
  227. {
  228. return subsys_system_register(&s5pv210_subsys, NULL);
  229. }
  230. core_initcall(s5pv210_core_init);
  231. int __init s5pv210_init(void)
  232. {
  233. printk(KERN_INFO "S5PV210: Initializing architecture\n");
  234. return device_register(&s5pv210_dev);
  235. }
  236. /* uart registration process */
  237. void __init s5pv210_init_uarts(struct s3c2410_uartcfg *cfg, int no)
  238. {
  239. s3c24xx_init_uartdevs("s5pv210-uart", s5p_uart_resources, cfg, no);
  240. }