core.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. }, { /* UART0 */
  118. .dev_id = "mb:16",
  119. .clk = &uartclk,
  120. }, { /* UART1 */
  121. .dev_id = "mb:17",
  122. .clk = &uartclk,
  123. }, { /* KMI0 */
  124. .dev_id = "mb:18",
  125. .clk = &clk24mhz,
  126. }, { /* KMI1 */
  127. .dev_id = "mb:19",
  128. .clk = &clk24mhz,
  129. }, { /* MMCI - IntegratorCP */
  130. .dev_id = "mb:1c",
  131. .clk = &uartclk,
  132. }
  133. };
  134. void __init integrator_init_early(void)
  135. {
  136. clkdev_add_table(lookups, ARRAY_SIZE(lookups));
  137. }
  138. static int __init integrator_init(void)
  139. {
  140. int i;
  141. for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
  142. struct amba_device *d = amba_devs[i];
  143. amba_device_register(d, &iomem_resource);
  144. }
  145. return 0;
  146. }
  147. arch_initcall(integrator_init);
  148. /*
  149. * On the Integrator platform, the port RTS and DTR are provided by
  150. * bits in the following SC_CTRLS register bits:
  151. * RTS DTR
  152. * UART0 7 6
  153. * UART1 5 4
  154. */
  155. #define SC_CTRLC IO_ADDRESS(INTEGRATOR_SC_CTRLC)
  156. #define SC_CTRLS IO_ADDRESS(INTEGRATOR_SC_CTRLS)
  157. static void integrator_uart_set_mctrl(struct amba_device *dev, void __iomem *base, unsigned int mctrl)
  158. {
  159. unsigned int ctrls = 0, ctrlc = 0, rts_mask, dtr_mask;
  160. if (dev == &uart0_device) {
  161. rts_mask = 1 << 4;
  162. dtr_mask = 1 << 5;
  163. } else {
  164. rts_mask = 1 << 6;
  165. dtr_mask = 1 << 7;
  166. }
  167. if (mctrl & TIOCM_RTS)
  168. ctrlc |= rts_mask;
  169. else
  170. ctrls |= rts_mask;
  171. if (mctrl & TIOCM_DTR)
  172. ctrlc |= dtr_mask;
  173. else
  174. ctrls |= dtr_mask;
  175. __raw_writel(ctrls, SC_CTRLS);
  176. __raw_writel(ctrlc, SC_CTRLC);
  177. }
  178. static struct amba_pl010_data integrator_uart_data = {
  179. .set_mctrl = integrator_uart_set_mctrl,
  180. };
  181. #define CM_CTRL IO_ADDRESS(INTEGRATOR_HDR_CTRL)
  182. static DEFINE_SPINLOCK(cm_lock);
  183. /**
  184. * cm_control - update the CM_CTRL register.
  185. * @mask: bits to change
  186. * @set: bits to set
  187. */
  188. void cm_control(u32 mask, u32 set)
  189. {
  190. unsigned long flags;
  191. u32 val;
  192. spin_lock_irqsave(&cm_lock, flags);
  193. val = readl(CM_CTRL) & ~mask;
  194. writel(val | set, CM_CTRL);
  195. spin_unlock_irqrestore(&cm_lock, flags);
  196. }
  197. EXPORT_SYMBOL(cm_control);
  198. /*
  199. * We need to stop things allocating the low memory; ideally we need a
  200. * better implementation of GFP_DMA which does not assume that DMA-able
  201. * memory starts at zero.
  202. */
  203. void __init integrator_reserve(void)
  204. {
  205. memblock_reserve(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET);
  206. }