common.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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/device.h>
  23. #include <linux/serial_core.h>
  24. #include <clocksource/samsung_pwm.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/sched.h>
  27. #include <linux/reboot.h>
  28. #include <asm/irq.h>
  29. #include <asm/proc-fns.h>
  30. #include <asm/system_misc.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/map.h>
  33. #include <asm/mach/irq.h>
  34. #include <mach/map.h>
  35. #include <mach/hardware.h>
  36. #include <mach/regs-clock.h>
  37. #include <plat/cpu.h>
  38. #include <plat/devs.h>
  39. #include <plat/clock.h>
  40. #include <plat/sdhci.h>
  41. #include <plat/adc-core.h>
  42. #include <plat/ata-core.h>
  43. #include <plat/fb-core.h>
  44. #include <plat/iic-core.h>
  45. #include <plat/onenand-core.h>
  46. #include <plat/pwm-core.h>
  47. #include <plat/spi-core.h>
  48. #include <plat/regs-serial.h>
  49. #include <plat/watchdog-reset.h>
  50. #include "common.h"
  51. static const char name_s5pc100[] = "S5PC100";
  52. static struct cpu_table cpu_ids[] __initdata = {
  53. {
  54. .idcode = S5PC100_CPU_ID,
  55. .idmask = S5PC100_CPU_MASK,
  56. .map_io = s5pc100_map_io,
  57. .init_clocks = s5pc100_init_clocks,
  58. .init_uarts = s5pc100_init_uarts,
  59. .init = s5pc100_init,
  60. .name = name_s5pc100,
  61. },
  62. };
  63. /* Initial IO mappings */
  64. static struct map_desc s5pc100_iodesc[] __initdata = {
  65. {
  66. .virtual = (unsigned long)S5P_VA_CHIPID,
  67. .pfn = __phys_to_pfn(S5PC100_PA_CHIPID),
  68. .length = SZ_4K,
  69. .type = MT_DEVICE,
  70. }, {
  71. .virtual = (unsigned long)S3C_VA_SYS,
  72. .pfn = __phys_to_pfn(S5PC100_PA_SYSCON),
  73. .length = SZ_64K,
  74. .type = MT_DEVICE,
  75. }, {
  76. .virtual = (unsigned long)S3C_VA_TIMER,
  77. .pfn = __phys_to_pfn(S5PC100_PA_TIMER),
  78. .length = SZ_16K,
  79. .type = MT_DEVICE,
  80. }, {
  81. .virtual = (unsigned long)S3C_VA_WATCHDOG,
  82. .pfn = __phys_to_pfn(S5PC100_PA_WATCHDOG),
  83. .length = SZ_4K,
  84. .type = MT_DEVICE,
  85. }, {
  86. .virtual = (unsigned long)S5P_VA_SROMC,
  87. .pfn = __phys_to_pfn(S5PC100_PA_SROMC),
  88. .length = SZ_4K,
  89. .type = MT_DEVICE,
  90. }, {
  91. .virtual = (unsigned long)S5P_VA_SYSTIMER,
  92. .pfn = __phys_to_pfn(S5PC100_PA_SYSTIMER),
  93. .length = SZ_16K,
  94. .type = MT_DEVICE,
  95. }, {
  96. .virtual = (unsigned long)S5P_VA_GPIO,
  97. .pfn = __phys_to_pfn(S5PC100_PA_GPIO),
  98. .length = SZ_4K,
  99. .type = MT_DEVICE,
  100. }, {
  101. .virtual = (unsigned long)VA_VIC0,
  102. .pfn = __phys_to_pfn(S5PC100_PA_VIC0),
  103. .length = SZ_16K,
  104. .type = MT_DEVICE,
  105. }, {
  106. .virtual = (unsigned long)VA_VIC1,
  107. .pfn = __phys_to_pfn(S5PC100_PA_VIC1),
  108. .length = SZ_16K,
  109. .type = MT_DEVICE,
  110. }, {
  111. .virtual = (unsigned long)VA_VIC2,
  112. .pfn = __phys_to_pfn(S5PC100_PA_VIC2),
  113. .length = SZ_16K,
  114. .type = MT_DEVICE,
  115. }, {
  116. .virtual = (unsigned long)S3C_VA_UART,
  117. .pfn = __phys_to_pfn(S3C_PA_UART),
  118. .length = SZ_512K,
  119. .type = MT_DEVICE,
  120. }, {
  121. .virtual = (unsigned long)S5PC100_VA_OTHERS,
  122. .pfn = __phys_to_pfn(S5PC100_PA_OTHERS),
  123. .length = SZ_4K,
  124. .type = MT_DEVICE,
  125. }
  126. };
  127. static struct samsung_pwm_variant s5pc100_pwm_variant = {
  128. .bits = 32,
  129. .div_base = 0,
  130. .has_tint_cstat = true,
  131. .tclk_mask = (1 << 5),
  132. };
  133. void __init samsung_set_timer_source(unsigned int event, unsigned int source)
  134. {
  135. s5pc100_pwm_variant.output_mask = BIT(SAMSUNG_PWM_NUM) - 1;
  136. s5pc100_pwm_variant.output_mask &= ~(BIT(event) | BIT(source));
  137. }
  138. void __init samsung_timer_init(void)
  139. {
  140. unsigned int timer_irqs[SAMSUNG_PWM_NUM] = {
  141. IRQ_TIMER0_VIC, IRQ_TIMER1_VIC, IRQ_TIMER2_VIC,
  142. IRQ_TIMER3_VIC, IRQ_TIMER4_VIC,
  143. };
  144. samsung_pwm_clocksource_init(S3C_VA_TIMER,
  145. timer_irqs, &s5pc100_pwm_variant);
  146. }
  147. /*
  148. * s5pc100_map_io
  149. *
  150. * register the standard CPU IO areas
  151. */
  152. void __init s5pc100_init_io(struct map_desc *mach_desc, int size)
  153. {
  154. /* initialize the io descriptors we need for initialization */
  155. iotable_init(s5pc100_iodesc, ARRAY_SIZE(s5pc100_iodesc));
  156. if (mach_desc)
  157. iotable_init(mach_desc, size);
  158. /* detect cpu id and rev. */
  159. s5p_init_cpu(S5P_VA_CHIPID);
  160. s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
  161. samsung_pwm_set_platdata(&s5pc100_pwm_variant);
  162. }
  163. void __init s5pc100_map_io(void)
  164. {
  165. /* initialise device information early */
  166. s5pc100_default_sdhci0();
  167. s5pc100_default_sdhci1();
  168. s5pc100_default_sdhci2();
  169. s3c_adc_setname("s3c64xx-adc");
  170. /* the i2c devices are directly compatible with s3c2440 */
  171. s3c_i2c0_setname("s3c2440-i2c");
  172. s3c_i2c1_setname("s3c2440-i2c");
  173. s3c_onenand_setname("s5pc100-onenand");
  174. s3c_fb_setname("s5pc100-fb");
  175. s3c_cfcon_setname("s5pc100-pata");
  176. s3c64xx_spi_setname("s5pc100-spi");
  177. }
  178. void __init s5pc100_init_clocks(int xtal)
  179. {
  180. printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
  181. s3c24xx_register_baseclocks(xtal);
  182. s5p_register_clocks(xtal);
  183. s5pc100_register_clocks();
  184. s5pc100_setup_clocks();
  185. samsung_wdt_reset_init(S3C_VA_WATCHDOG);
  186. }
  187. void __init s5pc100_init_irq(void)
  188. {
  189. u32 vic[] = {~0, ~0, ~0};
  190. /* VIC0, VIC1, and VIC2 are fully populated. */
  191. s5p_init_irq(vic, ARRAY_SIZE(vic));
  192. }
  193. static struct bus_type s5pc100_subsys = {
  194. .name = "s5pc100-core",
  195. .dev_name = "s5pc100-core",
  196. };
  197. static struct device s5pc100_dev = {
  198. .bus = &s5pc100_subsys,
  199. };
  200. static int __init s5pc100_core_init(void)
  201. {
  202. return subsys_system_register(&s5pc100_subsys, NULL);
  203. }
  204. core_initcall(s5pc100_core_init);
  205. int __init s5pc100_init(void)
  206. {
  207. printk(KERN_INFO "S5PC100: Initializing architecture\n");
  208. return device_register(&s5pc100_dev);
  209. }
  210. /* uart registration process */
  211. void __init s5pc100_init_uarts(struct s3c2410_uartcfg *cfg, int no)
  212. {
  213. s3c24xx_init_uartdevs("s3c6400-uart", s5p_uart_resources, cfg, no);
  214. }
  215. void s5pc100_restart(enum reboot_mode mode, const char *cmd)
  216. {
  217. if (mode != REBOOT_SOFT)
  218. samsung_wdt_reset();
  219. soft_restart(0);
  220. }