s3c2410.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /* linux/arch/arm/mach-s3c2410/s3c2410.c
  2. *
  3. * Copyright (c) 2003-2005 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * http://www.simtec.co.uk/products/EB2410ITX/
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/types.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/list.h>
  16. #include <linux/timer.h>
  17. #include <linux/init.h>
  18. #include <linux/gpio.h>
  19. #include <linux/clk.h>
  20. #include <linux/device.h>
  21. #include <linux/syscore_ops.h>
  22. #include <linux/serial_core.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/io.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach/map.h>
  27. #include <asm/mach/irq.h>
  28. #include <mach/hardware.h>
  29. #include <asm/irq.h>
  30. #include <asm/system_misc.h>
  31. #include <plat/cpu-freq.h>
  32. #include <mach/regs-clock.h>
  33. #include <plat/regs-serial.h>
  34. #include <plat/s3c2410.h>
  35. #include <plat/cpu.h>
  36. #include <plat/devs.h>
  37. #include <plat/clock.h>
  38. #include <plat/pll.h>
  39. #include <plat/pm.h>
  40. #include <plat/watchdog-reset.h>
  41. #include <plat/gpio-core.h>
  42. #include <plat/gpio-cfg.h>
  43. #include <plat/gpio-cfg-helpers.h>
  44. #include "common.h"
  45. /* Initial IO mappings */
  46. static struct map_desc s3c2410_iodesc[] __initdata = {
  47. IODESC_ENT(CLKPWR),
  48. IODESC_ENT(TIMER),
  49. IODESC_ENT(WATCHDOG),
  50. };
  51. /* our uart devices */
  52. /* uart registration process */
  53. void __init s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no)
  54. {
  55. s3c24xx_init_uartdevs("s3c2410-uart", s3c2410_uart_resources, cfg, no);
  56. }
  57. /* s3c2410_map_io
  58. *
  59. * register the standard cpu IO areas, and any passed in from the
  60. * machine specific initialisation.
  61. */
  62. void __init s3c2410_map_io(void)
  63. {
  64. s3c24xx_gpiocfg_default.set_pull = s3c24xx_gpio_setpull_1up;
  65. s3c24xx_gpiocfg_default.get_pull = s3c24xx_gpio_getpull_1up;
  66. iotable_init(s3c2410_iodesc, ARRAY_SIZE(s3c2410_iodesc));
  67. }
  68. void __init_or_cpufreq s3c2410_setup_clocks(void)
  69. {
  70. struct clk *xtal_clk;
  71. unsigned long tmp;
  72. unsigned long xtal;
  73. unsigned long fclk;
  74. unsigned long hclk;
  75. unsigned long pclk;
  76. xtal_clk = clk_get(NULL, "xtal");
  77. xtal = clk_get_rate(xtal_clk);
  78. clk_put(xtal_clk);
  79. /* now we've got our machine bits initialised, work out what
  80. * clocks we've got */
  81. fclk = s3c24xx_get_pll(__raw_readl(S3C2410_MPLLCON), xtal);
  82. tmp = __raw_readl(S3C2410_CLKDIVN);
  83. /* work out clock scalings */
  84. hclk = fclk / ((tmp & S3C2410_CLKDIVN_HDIVN) ? 2 : 1);
  85. pclk = hclk / ((tmp & S3C2410_CLKDIVN_PDIVN) ? 2 : 1);
  86. /* print brieft summary of clocks, etc */
  87. printk("S3C2410: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n",
  88. print_mhz(fclk), print_mhz(hclk), print_mhz(pclk));
  89. /* initialise the clocks here, to allow other things like the
  90. * console to use them
  91. */
  92. s3c24xx_setup_clocks(fclk, hclk, pclk);
  93. }
  94. /* fake ARMCLK for use with cpufreq, etc. */
  95. static struct clk s3c2410_armclk = {
  96. .name = "armclk",
  97. .parent = &clk_f,
  98. .id = -1,
  99. };
  100. static struct clk_lookup s3c2410_clk_lookup[] = {
  101. CLKDEV_INIT(NULL, "clk_uart_baud0", &clk_p),
  102. CLKDEV_INIT(NULL, "clk_uart_baud1", &s3c24xx_uclk),
  103. };
  104. void __init s3c2410_init_clocks(int xtal)
  105. {
  106. s3c24xx_register_baseclocks(xtal);
  107. s3c2410_setup_clocks();
  108. s3c2410_baseclk_add();
  109. s3c24xx_register_clock(&s3c2410_armclk);
  110. clkdev_add_table(s3c2410_clk_lookup, ARRAY_SIZE(s3c2410_clk_lookup));
  111. }
  112. struct bus_type s3c2410_subsys = {
  113. .name = "s3c2410-core",
  114. .dev_name = "s3c2410-core",
  115. };
  116. /* Note, we would have liked to name this s3c2410-core, but we cannot
  117. * register two subsystems with the same name.
  118. */
  119. struct bus_type s3c2410a_subsys = {
  120. .name = "s3c2410a-core",
  121. .dev_name = "s3c2410a-core",
  122. };
  123. static struct device s3c2410_dev = {
  124. .bus = &s3c2410_subsys,
  125. };
  126. /* need to register the subsystem before we actually register the device, and
  127. * we also need to ensure that it has been initialised before any of the
  128. * drivers even try to use it (even if not on an s3c2410 based system)
  129. * as a driver which may support both 2410 and 2440 may try and use it.
  130. */
  131. static int __init s3c2410_core_init(void)
  132. {
  133. return subsys_system_register(&s3c2410_subsys, NULL);
  134. }
  135. core_initcall(s3c2410_core_init);
  136. static int __init s3c2410a_core_init(void)
  137. {
  138. return subsys_system_register(&s3c2410a_subsys, NULL);
  139. }
  140. core_initcall(s3c2410a_core_init);
  141. int __init s3c2410_init(void)
  142. {
  143. printk("S3C2410: Initialising architecture\n");
  144. #ifdef CONFIG_PM
  145. register_syscore_ops(&s3c2410_pm_syscore_ops);
  146. register_syscore_ops(&s3c24xx_irq_syscore_ops);
  147. #endif
  148. return device_register(&s3c2410_dev);
  149. }
  150. int __init s3c2410a_init(void)
  151. {
  152. s3c2410_dev.bus = &s3c2410a_subsys;
  153. return s3c2410_init();
  154. }
  155. void s3c2410_restart(char mode, const char *cmd)
  156. {
  157. if (mode == 's') {
  158. soft_restart(0);
  159. }
  160. arch_wdt_reset();
  161. /* we'll take a jump through zero as a poor second */
  162. soft_restart(0);
  163. }