common.c 5.8 KB

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