common.c 6.3 KB

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