common.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /*
  2. * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
  3. * http://www.samsung.com
  4. *
  5. * Copyright 2009 Samsung Electronics Co.
  6. * Byungho Min <bhmin@samsung.com>
  7. *
  8. * Common Codes for S5PC100
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/types.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/list.h>
  18. #include <linux/timer.h>
  19. #include <linux/init.h>
  20. #include <linux/clk.h>
  21. #include <linux/io.h>
  22. #include <linux/sysdev.h>
  23. #include <linux/serial_core.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/sched.h>
  26. #include <asm/irq.h>
  27. #include <asm/proc-fns.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include <asm/mach/irq.h>
  31. #include <mach/map.h>
  32. #include <mach/hardware.h>
  33. #include <mach/regs-clock.h>
  34. #include <plat/cpu.h>
  35. #include <plat/devs.h>
  36. #include <plat/clock.h>
  37. #include <plat/sdhci.h>
  38. #include <plat/adc-core.h>
  39. #include <plat/ata-core.h>
  40. #include <plat/fb-core.h>
  41. #include <plat/iic-core.h>
  42. #include <plat/onenand-core.h>
  43. #include <plat/regs-serial.h>
  44. #include "common.h"
  45. static const char name_s5pc100[] = "S5PC100";
  46. static struct cpu_table cpu_ids[] __initdata = {
  47. {
  48. .idcode = S5PC100_CPU_ID,
  49. .idmask = S5PC100_CPU_MASK,
  50. .map_io = s5pc100_map_io,
  51. .init_clocks = s5pc100_init_clocks,
  52. .init_uarts = s5pc100_init_uarts,
  53. .init = s5pc100_init,
  54. .name = name_s5pc100,
  55. },
  56. };
  57. /* Initial IO mappings */
  58. static struct map_desc s5pc100_iodesc[] __initdata = {
  59. {
  60. .virtual = (unsigned long)S5P_VA_CHIPID,
  61. .pfn = __phys_to_pfn(S5PC100_PA_CHIPID),
  62. .length = SZ_4K,
  63. .type = MT_DEVICE,
  64. }, {
  65. .virtual = (unsigned long)S3C_VA_SYS,
  66. .pfn = __phys_to_pfn(S5PC100_PA_SYSCON),
  67. .length = SZ_64K,
  68. .type = MT_DEVICE,
  69. }, {
  70. .virtual = (unsigned long)S3C_VA_TIMER,
  71. .pfn = __phys_to_pfn(S5PC100_PA_TIMER),
  72. .length = SZ_16K,
  73. .type = MT_DEVICE,
  74. }, {
  75. .virtual = (unsigned long)S3C_VA_WATCHDOG,
  76. .pfn = __phys_to_pfn(S5PC100_PA_WATCHDOG),
  77. .length = SZ_4K,
  78. .type = MT_DEVICE,
  79. }, {
  80. .virtual = (unsigned long)S5P_VA_SROMC,
  81. .pfn = __phys_to_pfn(S5PC100_PA_SROMC),
  82. .length = SZ_4K,
  83. .type = MT_DEVICE,
  84. }, {
  85. .virtual = (unsigned long)S5P_VA_SYSTIMER,
  86. .pfn = __phys_to_pfn(S5PC100_PA_SYSTIMER),
  87. .length = SZ_16K,
  88. .type = MT_DEVICE,
  89. }, {
  90. .virtual = (unsigned long)S5P_VA_GPIO,
  91. .pfn = __phys_to_pfn(S5PC100_PA_GPIO),
  92. .length = SZ_4K,
  93. .type = MT_DEVICE,
  94. }, {
  95. .virtual = (unsigned long)VA_VIC0,
  96. .pfn = __phys_to_pfn(S5PC100_PA_VIC0),
  97. .length = SZ_16K,
  98. .type = MT_DEVICE,
  99. }, {
  100. .virtual = (unsigned long)VA_VIC1,
  101. .pfn = __phys_to_pfn(S5PC100_PA_VIC1),
  102. .length = SZ_16K,
  103. .type = MT_DEVICE,
  104. }, {
  105. .virtual = (unsigned long)VA_VIC2,
  106. .pfn = __phys_to_pfn(S5PC100_PA_VIC2),
  107. .length = SZ_16K,
  108. .type = MT_DEVICE,
  109. }, {
  110. .virtual = (unsigned long)S3C_VA_UART,
  111. .pfn = __phys_to_pfn(S3C_PA_UART),
  112. .length = SZ_512K,
  113. .type = MT_DEVICE,
  114. }, {
  115. .virtual = (unsigned long)S5PC100_VA_OTHERS,
  116. .pfn = __phys_to_pfn(S5PC100_PA_OTHERS),
  117. .length = SZ_4K,
  118. .type = MT_DEVICE,
  119. }
  120. };
  121. static void s5pc100_idle(void)
  122. {
  123. if (!need_resched())
  124. cpu_do_idle();
  125. local_irq_enable();
  126. }
  127. /*
  128. * s5pc100_map_io
  129. *
  130. * register the standard CPU IO areas
  131. */
  132. void __init s5pc100_init_io(struct map_desc *mach_desc, int size)
  133. {
  134. /* initialize the io descriptors we need for initialization */
  135. iotable_init(s5pc100_iodesc, ARRAY_SIZE(s5pc100_iodesc));
  136. if (mach_desc)
  137. iotable_init(mach_desc, size);
  138. /* detect cpu id and rev. */
  139. s5p_init_cpu(S5P_VA_CHIPID);
  140. s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
  141. }
  142. void __init s5pc100_map_io(void)
  143. {
  144. /* initialise device information early */
  145. s5pc100_default_sdhci0();
  146. s5pc100_default_sdhci1();
  147. s5pc100_default_sdhci2();
  148. s3c_adc_setname("s3c64xx-adc");
  149. /* the i2c devices are directly compatible with s3c2440 */
  150. s3c_i2c0_setname("s3c2440-i2c");
  151. s3c_i2c1_setname("s3c2440-i2c");
  152. s3c_onenand_setname("s5pc100-onenand");
  153. s3c_fb_setname("s5pc100-fb");
  154. s3c_cfcon_setname("s5pc100-pata");
  155. }
  156. void __init s5pc100_init_clocks(int xtal)
  157. {
  158. printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
  159. s3c24xx_register_baseclocks(xtal);
  160. s5p_register_clocks(xtal);
  161. s5pc100_register_clocks();
  162. s5pc100_setup_clocks();
  163. }
  164. void __init s5pc100_init_irq(void)
  165. {
  166. u32 vic[] = {~0, ~0, ~0};
  167. /* VIC0, VIC1, and VIC2 are fully populated. */
  168. s5p_init_irq(vic, ARRAY_SIZE(vic));
  169. }
  170. static struct sysdev_class s5pc100_sysclass = {
  171. .name = "s5pc100-core",
  172. };
  173. static struct sys_device s5pc100_sysdev = {
  174. .cls = &s5pc100_sysclass,
  175. };
  176. static int __init s5pc100_core_init(void)
  177. {
  178. return sysdev_class_register(&s5pc100_sysclass);
  179. }
  180. core_initcall(s5pc100_core_init);
  181. int __init s5pc100_init(void)
  182. {
  183. printk(KERN_INFO "S5PC100: Initializing architecture\n");
  184. /* set idle function */
  185. pm_idle = s5pc100_idle;
  186. return sysdev_register(&s5pc100_sysdev);
  187. }
  188. /* uart registration process */
  189. void __init s5pc100_init_uarts(struct s3c2410_uartcfg *cfg, int no)
  190. {
  191. s3c24xx_init_uartdevs("s3c6400-uart", s5p_uart_resources, cfg, no);
  192. }