core.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /*
  2. * linux/arch/arm/mach-integrator/core.c
  3. *
  4. * Copyright (C) 2000-2003 Deep Blue Solutions Ltd
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2, as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/types.h>
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/device.h>
  14. #include <linux/spinlock.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/irq.h>
  17. #include <linux/memblock.h>
  18. #include <linux/sched.h>
  19. #include <linux/smp.h>
  20. #include <linux/termios.h>
  21. #include <linux/amba/bus.h>
  22. #include <linux/amba/serial.h>
  23. #include <linux/io.h>
  24. #include <linux/clkdev.h>
  25. #include <mach/hardware.h>
  26. #include <mach/platform.h>
  27. #include <asm/irq.h>
  28. #include <mach/cm.h>
  29. #include <asm/system.h>
  30. #include <asm/leds.h>
  31. #include <asm/mach/time.h>
  32. #include <asm/pgtable.h>
  33. static struct amba_pl010_data integrator_uart_data;
  34. static struct amba_device rtc_device = {
  35. .dev = {
  36. .init_name = "mb:15",
  37. },
  38. .res = {
  39. .start = INTEGRATOR_RTC_BASE,
  40. .end = INTEGRATOR_RTC_BASE + SZ_4K - 1,
  41. .flags = IORESOURCE_MEM,
  42. },
  43. .irq = { IRQ_RTCINT, NO_IRQ },
  44. .periphid = 0x00041030,
  45. };
  46. static struct amba_device uart0_device = {
  47. .dev = {
  48. .init_name = "mb:16",
  49. .platform_data = &integrator_uart_data,
  50. },
  51. .res = {
  52. .start = INTEGRATOR_UART0_BASE,
  53. .end = INTEGRATOR_UART0_BASE + SZ_4K - 1,
  54. .flags = IORESOURCE_MEM,
  55. },
  56. .irq = { IRQ_UARTINT0, NO_IRQ },
  57. .periphid = 0x0041010,
  58. };
  59. static struct amba_device uart1_device = {
  60. .dev = {
  61. .init_name = "mb:17",
  62. .platform_data = &integrator_uart_data,
  63. },
  64. .res = {
  65. .start = INTEGRATOR_UART1_BASE,
  66. .end = INTEGRATOR_UART1_BASE + SZ_4K - 1,
  67. .flags = IORESOURCE_MEM,
  68. },
  69. .irq = { IRQ_UARTINT1, NO_IRQ },
  70. .periphid = 0x0041010,
  71. };
  72. static struct amba_device kmi0_device = {
  73. .dev = {
  74. .init_name = "mb:18",
  75. },
  76. .res = {
  77. .start = KMI0_BASE,
  78. .end = KMI0_BASE + SZ_4K - 1,
  79. .flags = IORESOURCE_MEM,
  80. },
  81. .irq = { IRQ_KMIINT0, NO_IRQ },
  82. .periphid = 0x00041050,
  83. };
  84. static struct amba_device kmi1_device = {
  85. .dev = {
  86. .init_name = "mb:19",
  87. },
  88. .res = {
  89. .start = KMI1_BASE,
  90. .end = KMI1_BASE + SZ_4K - 1,
  91. .flags = IORESOURCE_MEM,
  92. },
  93. .irq = { IRQ_KMIINT1, NO_IRQ },
  94. .periphid = 0x00041050,
  95. };
  96. static struct amba_device *amba_devs[] __initdata = {
  97. &rtc_device,
  98. &uart0_device,
  99. &uart1_device,
  100. &kmi0_device,
  101. &kmi1_device,
  102. };
  103. /*
  104. * These are fixed clocks.
  105. */
  106. static struct clk clk24mhz = {
  107. .rate = 24000000,
  108. };
  109. static struct clk uartclk = {
  110. .rate = 14745600,
  111. };
  112. static struct clk dummy_apb_pclk;
  113. static struct clk_lookup lookups[] = {
  114. { /* Bus clock */
  115. .con_id = "apb_pclk",
  116. .clk = &dummy_apb_pclk,
  117. }, {
  118. /* Integrator/AP timer frequency */
  119. .dev_id = "ap_timer",
  120. .clk = &clk24mhz,
  121. }, { /* UART0 */
  122. .dev_id = "mb:16",
  123. .clk = &uartclk,
  124. }, { /* UART1 */
  125. .dev_id = "mb:17",
  126. .clk = &uartclk,
  127. }, { /* KMI0 */
  128. .dev_id = "mb:18",
  129. .clk = &clk24mhz,
  130. }, { /* KMI1 */
  131. .dev_id = "mb:19",
  132. .clk = &clk24mhz,
  133. }, { /* MMCI - IntegratorCP */
  134. .dev_id = "mb:1c",
  135. .clk = &uartclk,
  136. }
  137. };
  138. void __init integrator_init_early(void)
  139. {
  140. clkdev_add_table(lookups, ARRAY_SIZE(lookups));
  141. }
  142. static int __init integrator_init(void)
  143. {
  144. int i;
  145. for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
  146. struct amba_device *d = amba_devs[i];
  147. amba_device_register(d, &iomem_resource);
  148. }
  149. return 0;
  150. }
  151. arch_initcall(integrator_init);
  152. /*
  153. * On the Integrator platform, the port RTS and DTR are provided by
  154. * bits in the following SC_CTRLS register bits:
  155. * RTS DTR
  156. * UART0 7 6
  157. * UART1 5 4
  158. */
  159. #define SC_CTRLC IO_ADDRESS(INTEGRATOR_SC_CTRLC)
  160. #define SC_CTRLS IO_ADDRESS(INTEGRATOR_SC_CTRLS)
  161. static void integrator_uart_set_mctrl(struct amba_device *dev, void __iomem *base, unsigned int mctrl)
  162. {
  163. unsigned int ctrls = 0, ctrlc = 0, rts_mask, dtr_mask;
  164. if (dev == &uart0_device) {
  165. rts_mask = 1 << 4;
  166. dtr_mask = 1 << 5;
  167. } else {
  168. rts_mask = 1 << 6;
  169. dtr_mask = 1 << 7;
  170. }
  171. if (mctrl & TIOCM_RTS)
  172. ctrlc |= rts_mask;
  173. else
  174. ctrls |= rts_mask;
  175. if (mctrl & TIOCM_DTR)
  176. ctrlc |= dtr_mask;
  177. else
  178. ctrls |= dtr_mask;
  179. __raw_writel(ctrls, SC_CTRLS);
  180. __raw_writel(ctrlc, SC_CTRLC);
  181. }
  182. static struct amba_pl010_data integrator_uart_data = {
  183. .set_mctrl = integrator_uart_set_mctrl,
  184. };
  185. #define CM_CTRL IO_ADDRESS(INTEGRATOR_HDR_CTRL)
  186. static DEFINE_RAW_SPINLOCK(cm_lock);
  187. /**
  188. * cm_control - update the CM_CTRL register.
  189. * @mask: bits to change
  190. * @set: bits to set
  191. */
  192. void cm_control(u32 mask, u32 set)
  193. {
  194. unsigned long flags;
  195. u32 val;
  196. raw_spin_lock_irqsave(&cm_lock, flags);
  197. val = readl(CM_CTRL) & ~mask;
  198. writel(val | set, CM_CTRL);
  199. raw_spin_unlock_irqrestore(&cm_lock, flags);
  200. }
  201. EXPORT_SYMBOL(cm_control);
  202. /*
  203. * We need to stop things allocating the low memory; ideally we need a
  204. * better implementation of GFP_DMA which does not assume that DMA-able
  205. * memory starts at zero.
  206. */
  207. void __init integrator_reserve(void)
  208. {
  209. memblock_reserve(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET);
  210. }