board-a9m9750dev.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. * arch/arm/mach-ns9xxx/board-a9m9750dev.c
  3. *
  4. * Copyright (C) 2006,2007 by Digi International Inc.
  5. * All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published by
  9. * the Free Software Foundation.
  10. */
  11. #include <linux/platform_device.h>
  12. #include <linux/serial_8250.h>
  13. #include <linux/irq.h>
  14. #include <asm/mach/map.h>
  15. #include <asm/gpio.h>
  16. #include <asm/arch-ns9xxx/board.h>
  17. #include <asm/arch-ns9xxx/regs-sys.h>
  18. #include <asm/arch-ns9xxx/regs-mem.h>
  19. #include <asm/arch-ns9xxx/regs-bbu.h>
  20. #include <asm/arch-ns9xxx/regs-board-a9m9750dev.h>
  21. #include "board-a9m9750dev.h"
  22. static struct map_desc board_a9m9750dev_io_desc[] __initdata = {
  23. { /* FPGA on CS0 */
  24. .virtual = io_p2v(NS9XXX_CSxSTAT_PHYS(0)),
  25. .pfn = __phys_to_pfn(NS9XXX_CSxSTAT_PHYS(0)),
  26. .length = NS9XXX_CS0STAT_LENGTH,
  27. .type = MT_DEVICE,
  28. },
  29. };
  30. void __init board_a9m9750dev_map_io(void)
  31. {
  32. iotable_init(board_a9m9750dev_io_desc,
  33. ARRAY_SIZE(board_a9m9750dev_io_desc));
  34. }
  35. static void a9m9750dev_fpga_ack_irq(unsigned int irq)
  36. {
  37. /* nothing */
  38. }
  39. static void a9m9750dev_fpga_mask_irq(unsigned int irq)
  40. {
  41. FPGA_IER &= ~(1 << (irq - FPGA_IRQ(0)));
  42. }
  43. static void a9m9750dev_fpga_maskack_irq(unsigned int irq)
  44. {
  45. a9m9750dev_fpga_mask_irq(irq);
  46. a9m9750dev_fpga_ack_irq(irq);
  47. }
  48. static void a9m9750dev_fpga_unmask_irq(unsigned int irq)
  49. {
  50. FPGA_IER |= 1 << (irq - FPGA_IRQ(0));
  51. }
  52. static struct irq_chip a9m9750dev_fpga_chip = {
  53. .ack = a9m9750dev_fpga_ack_irq,
  54. .mask = a9m9750dev_fpga_mask_irq,
  55. .mask_ack = a9m9750dev_fpga_maskack_irq,
  56. .unmask = a9m9750dev_fpga_unmask_irq,
  57. };
  58. static void a9m9750dev_fpga_demux_handler(unsigned int irq,
  59. struct irq_desc *desc)
  60. {
  61. int stat = FPGA_ISR;
  62. desc->chip->mask_ack(irq);
  63. while (stat != 0) {
  64. int irqno = fls(stat) - 1;
  65. struct irq_desc *fpgadesc;
  66. stat &= ~(1 << irqno);
  67. fpgadesc = irq_desc + FPGA_IRQ(irqno);
  68. desc_handle_irq(FPGA_IRQ(irqno), fpgadesc);
  69. }
  70. desc->chip->unmask(irq);
  71. }
  72. void __init board_a9m9750dev_init_irq(void)
  73. {
  74. u32 reg;
  75. int i;
  76. if (gpio_request(11, "board a9m9750dev extirq2") == 0)
  77. ns9xxx_gpio_configure(11, 0, 1);
  78. else
  79. printk(KERN_ERR "%s: cannot get gpio 11 for IRQ_EXT2\n",
  80. __func__);
  81. for (i = FPGA_IRQ(0); i <= FPGA_IRQ(7); ++i) {
  82. set_irq_chip(i, &a9m9750dev_fpga_chip);
  83. set_irq_handler(i, handle_level_irq);
  84. set_irq_flags(i, IRQF_VALID);
  85. }
  86. /* IRQ_EXT2: level sensitive + active low */
  87. reg = SYS_EIC(2);
  88. REGSET(reg, SYS_EIC, PLTY, AL);
  89. REGSET(reg, SYS_EIC, LVEDG, LEVEL);
  90. SYS_EIC(2) = reg;
  91. set_irq_chained_handler(IRQ_EXT2,
  92. a9m9750dev_fpga_demux_handler);
  93. }
  94. static struct plat_serial8250_port board_a9m9750dev_serial8250_port[] = {
  95. {
  96. .iobase = FPGA_UARTA_BASE,
  97. .membase = (unsigned char*)FPGA_UARTA_BASE,
  98. .mapbase = FPGA_UARTA_BASE,
  99. .irq = IRQ_FPGA_UARTA,
  100. .iotype = UPIO_MEM,
  101. .uartclk = 18432000,
  102. .regshift = 0,
  103. .flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ,
  104. }, {
  105. .iobase = FPGA_UARTB_BASE,
  106. .membase = (unsigned char*)FPGA_UARTB_BASE,
  107. .mapbase = FPGA_UARTB_BASE,
  108. .irq = IRQ_FPGA_UARTB,
  109. .iotype = UPIO_MEM,
  110. .uartclk = 18432000,
  111. .regshift = 0,
  112. .flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ,
  113. }, {
  114. .iobase = FPGA_UARTC_BASE,
  115. .membase = (unsigned char*)FPGA_UARTC_BASE,
  116. .mapbase = FPGA_UARTC_BASE,
  117. .irq = IRQ_FPGA_UARTC,
  118. .iotype = UPIO_MEM,
  119. .uartclk = 18432000,
  120. .regshift = 0,
  121. .flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ,
  122. }, {
  123. .iobase = FPGA_UARTD_BASE,
  124. .membase = (unsigned char*)FPGA_UARTD_BASE,
  125. .mapbase = FPGA_UARTD_BASE,
  126. .irq = IRQ_FPGA_UARTD,
  127. .iotype = UPIO_MEM,
  128. .uartclk = 18432000,
  129. .regshift = 0,
  130. .flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ,
  131. }, {
  132. /* end marker */
  133. },
  134. };
  135. static struct platform_device board_a9m9750dev_serial_device = {
  136. .name = "serial8250",
  137. .dev = {
  138. .platform_data = board_a9m9750dev_serial8250_port,
  139. },
  140. };
  141. static struct platform_device *board_a9m9750dev_devices[] __initdata = {
  142. &board_a9m9750dev_serial_device,
  143. };
  144. void __init board_a9m9750dev_init_machine(void)
  145. {
  146. u32 reg;
  147. /* setup static CS0: memory base ... */
  148. REGSETIM(SYS_SMCSSMB(0), SYS_SMCSSMB, CSxB,
  149. NS9XXX_CSxSTAT_PHYS(0) >> 12);
  150. /* ... and mask */
  151. reg = SYS_SMCSSMM(0);
  152. REGSETIM(reg, SYS_SMCSSMM, CSxM, 0xfffff);
  153. REGSET(reg, SYS_SMCSSMM, CSEx, EN);
  154. SYS_SMCSSMM(0) = reg;
  155. /* setup static CS0: memory configuration */
  156. reg = MEM_SMC(0);
  157. REGSET(reg, MEM_SMC, PSMC, OFF);
  158. REGSET(reg, MEM_SMC, BSMC, OFF);
  159. REGSET(reg, MEM_SMC, EW, OFF);
  160. REGSET(reg, MEM_SMC, PB, 1);
  161. REGSET(reg, MEM_SMC, PC, AL);
  162. REGSET(reg, MEM_SMC, PM, DIS);
  163. REGSET(reg, MEM_SMC, MW, 8);
  164. MEM_SMC(0) = reg;
  165. /* setup static CS0: timing */
  166. MEM_SMWED(0) = 0x2;
  167. MEM_SMOED(0) = 0x2;
  168. MEM_SMRD(0) = 0x6;
  169. MEM_SMWD(0) = 0x6;
  170. platform_add_devices(board_a9m9750dev_devices,
  171. ARRAY_SIZE(board_a9m9750dev_devices));
  172. }