common.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-footbridge/common.c
  4. *
  5. * Copyright (C) 1998-2000 Russell King, Dave Gilbert.
  6. */
  7. #include <linux/module.h>
  8. #include <linux/types.h>
  9. #include <linux/mm.h>
  10. #include <linux/ioport.h>
  11. #include <linux/list.h>
  12. #include <linux/init.h>
  13. #include <linux/io.h>
  14. #include <linux/spinlock.h>
  15. #include <linux/dma-direct.h>
  16. #include <video/vga.h>
  17. #include <asm/page.h>
  18. #include <asm/irq.h>
  19. #include <asm/mach-types.h>
  20. #include <asm/setup.h>
  21. #include <asm/system_misc.h>
  22. #include <asm/hardware/dec21285.h>
  23. #include <asm/mach/irq.h>
  24. #include <asm/mach/map.h>
  25. #include <asm/mach/pci.h>
  26. #include "common.h"
  27. #include <mach/hardware.h>
  28. #include <mach/irqs.h>
  29. #include <asm/hardware/dec21285.h>
  30. static int dc21285_get_irq(void)
  31. {
  32. void __iomem *irqstatus = (void __iomem *)CSR_IRQ_STATUS;
  33. u32 mask = readl(irqstatus);
  34. if (mask & IRQ_MASK_SDRAMPARITY)
  35. return IRQ_SDRAMPARITY;
  36. if (mask & IRQ_MASK_UART_RX)
  37. return IRQ_CONRX;
  38. if (mask & IRQ_MASK_DMA1)
  39. return IRQ_DMA1;
  40. if (mask & IRQ_MASK_DMA2)
  41. return IRQ_DMA2;
  42. if (mask & IRQ_MASK_IN0)
  43. return IRQ_IN0;
  44. if (mask & IRQ_MASK_IN1)
  45. return IRQ_IN1;
  46. if (mask & IRQ_MASK_IN2)
  47. return IRQ_IN2;
  48. if (mask & IRQ_MASK_IN3)
  49. return IRQ_IN3;
  50. if (mask & IRQ_MASK_PCI)
  51. return IRQ_PCI;
  52. if (mask & IRQ_MASK_DOORBELLHOST)
  53. return IRQ_DOORBELLHOST;
  54. if (mask & IRQ_MASK_I2OINPOST)
  55. return IRQ_I2OINPOST;
  56. if (mask & IRQ_MASK_TIMER1)
  57. return IRQ_TIMER1;
  58. if (mask & IRQ_MASK_TIMER2)
  59. return IRQ_TIMER2;
  60. if (mask & IRQ_MASK_TIMER3)
  61. return IRQ_TIMER3;
  62. if (mask & IRQ_MASK_UART_TX)
  63. return IRQ_CONTX;
  64. if (mask & IRQ_MASK_PCI_ABORT)
  65. return IRQ_PCI_ABORT;
  66. if (mask & IRQ_MASK_PCI_SERR)
  67. return IRQ_PCI_SERR;
  68. if (mask & IRQ_MASK_DISCARD_TIMER)
  69. return IRQ_DISCARD_TIMER;
  70. if (mask & IRQ_MASK_PCI_DPERR)
  71. return IRQ_PCI_DPERR;
  72. if (mask & IRQ_MASK_PCI_PERR)
  73. return IRQ_PCI_PERR;
  74. return 0;
  75. }
  76. static void dc21285_handle_irq(struct pt_regs *regs)
  77. {
  78. int irq;
  79. do {
  80. irq = dc21285_get_irq();
  81. if (!irq)
  82. break;
  83. generic_handle_irq(irq);
  84. } while (1);
  85. }
  86. unsigned int mem_fclk_21285 = 50000000;
  87. EXPORT_SYMBOL(mem_fclk_21285);
  88. static int __init early_fclk(char *arg)
  89. {
  90. mem_fclk_21285 = simple_strtoul(arg, NULL, 0);
  91. return 0;
  92. }
  93. early_param("mem_fclk_21285", early_fclk);
  94. static int __init parse_tag_memclk(const struct tag *tag)
  95. {
  96. mem_fclk_21285 = tag->u.memclk.fmemclk;
  97. return 0;
  98. }
  99. __tagtable(ATAG_MEMCLK, parse_tag_memclk);
  100. /*
  101. * Footbridge IRQ translation table
  102. * Converts from our IRQ numbers into FootBridge masks
  103. */
  104. static const int fb_irq_mask[] = {
  105. IRQ_MASK_UART_RX, /* 0 */
  106. IRQ_MASK_UART_TX, /* 1 */
  107. IRQ_MASK_TIMER1, /* 2 */
  108. IRQ_MASK_TIMER2, /* 3 */
  109. IRQ_MASK_TIMER3, /* 4 */
  110. IRQ_MASK_IN0, /* 5 */
  111. IRQ_MASK_IN1, /* 6 */
  112. IRQ_MASK_IN2, /* 7 */
  113. IRQ_MASK_IN3, /* 8 */
  114. IRQ_MASK_DOORBELLHOST, /* 9 */
  115. IRQ_MASK_DMA1, /* 10 */
  116. IRQ_MASK_DMA2, /* 11 */
  117. IRQ_MASK_PCI, /* 12 */
  118. IRQ_MASK_SDRAMPARITY, /* 13 */
  119. IRQ_MASK_I2OINPOST, /* 14 */
  120. IRQ_MASK_PCI_ABORT, /* 15 */
  121. IRQ_MASK_PCI_SERR, /* 16 */
  122. IRQ_MASK_DISCARD_TIMER, /* 17 */
  123. IRQ_MASK_PCI_DPERR, /* 18 */
  124. IRQ_MASK_PCI_PERR, /* 19 */
  125. };
  126. static void fb_mask_irq(struct irq_data *d)
  127. {
  128. *CSR_IRQ_DISABLE = fb_irq_mask[_DC21285_INR(d->irq)];
  129. }
  130. static void fb_unmask_irq(struct irq_data *d)
  131. {
  132. *CSR_IRQ_ENABLE = fb_irq_mask[_DC21285_INR(d->irq)];
  133. }
  134. static struct irq_chip fb_chip = {
  135. .irq_ack = fb_mask_irq,
  136. .irq_mask = fb_mask_irq,
  137. .irq_unmask = fb_unmask_irq,
  138. };
  139. static void __init __fb_init_irq(void)
  140. {
  141. unsigned int irq;
  142. /*
  143. * setup DC21285 IRQs
  144. */
  145. *CSR_IRQ_DISABLE = -1;
  146. *CSR_FIQ_DISABLE = -1;
  147. for (irq = _DC21285_IRQ(0); irq < _DC21285_IRQ(20); irq++) {
  148. irq_set_chip_and_handler(irq, &fb_chip, handle_level_irq);
  149. irq_clear_status_flags(irq, IRQ_NOREQUEST | IRQ_NOPROBE);
  150. }
  151. }
  152. void __init footbridge_init_irq(void)
  153. {
  154. set_handle_irq(dc21285_handle_irq);
  155. __fb_init_irq();
  156. if (machine_is_ebsa285())
  157. /* The following is dependent on which slot
  158. * you plug the Southbridge card into. We
  159. * currently assume that you plug it into
  160. * the right-hand most slot.
  161. */
  162. isa_init_irq(IRQ_PCI);
  163. if (machine_is_cats())
  164. isa_init_irq(IRQ_IN2);
  165. if (machine_is_netwinder())
  166. isa_init_irq(IRQ_IN3);
  167. }
  168. /*
  169. * Common mapping for all systems. Note that the outbound write flush is
  170. * commented out since there is a "No Fix" problem with it. Not mapping
  171. * it means that we have extra bullet protection on our feet.
  172. */
  173. static struct map_desc ebsa285_host_io_desc[] __initdata = {
  174. {
  175. .virtual = ARMCSR_BASE,
  176. .pfn = __phys_to_pfn(DC21285_ARMCSR_BASE),
  177. .length = ARMCSR_SIZE,
  178. .type = MT_DEVICE,
  179. },
  180. {
  181. .virtual = PCIMEM_BASE,
  182. .pfn = __phys_to_pfn(DC21285_PCI_MEM),
  183. .length = PCIMEM_SIZE,
  184. .type = MT_DEVICE,
  185. }, {
  186. .virtual = PCICFG0_BASE,
  187. .pfn = __phys_to_pfn(DC21285_PCI_TYPE_0_CONFIG),
  188. .length = PCICFG0_SIZE,
  189. .type = MT_DEVICE,
  190. }, {
  191. .virtual = PCICFG1_BASE,
  192. .pfn = __phys_to_pfn(DC21285_PCI_TYPE_1_CONFIG),
  193. .length = PCICFG1_SIZE,
  194. .type = MT_DEVICE,
  195. }, {
  196. .virtual = PCIIACK_BASE,
  197. .pfn = __phys_to_pfn(DC21285_PCI_IACK),
  198. .length = PCIIACK_SIZE,
  199. .type = MT_DEVICE,
  200. },
  201. };
  202. void __init footbridge_map_io(void)
  203. {
  204. iotable_init(ebsa285_host_io_desc, ARRAY_SIZE(ebsa285_host_io_desc));
  205. pci_map_io_early(__phys_to_pfn(DC21285_PCI_IO));
  206. vga_base = PCIMEM_BASE;
  207. }
  208. void footbridge_restart(enum reboot_mode mode, const char *cmd)
  209. {
  210. if (mode == REBOOT_SOFT) {
  211. /* Jump into the ROM */
  212. soft_restart(0x41000000);
  213. } else {
  214. /*
  215. * Force the watchdog to do a CPU reset.
  216. *
  217. * After making sure that the watchdog is disabled
  218. * (so we can change the timer registers) we first
  219. * enable the timer to autoreload itself. Next, the
  220. * timer interval is set really short and any
  221. * current interrupt request is cleared (so we can
  222. * see an edge transition). Finally, TIMER4 is
  223. * enabled as the watchdog.
  224. */
  225. *CSR_SA110_CNTL &= ~(1 << 13);
  226. *CSR_TIMER4_CNTL = TIMER_CNTL_ENABLE |
  227. TIMER_CNTL_AUTORELOAD |
  228. TIMER_CNTL_DIV16;
  229. *CSR_TIMER4_LOAD = 0x2;
  230. *CSR_TIMER4_CLR = 0;
  231. *CSR_SA110_CNTL |= (1 << 13);
  232. }
  233. }