unit-init.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* ASB2364 initialisation
  2. *
  3. * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/param.h>
  13. #include <linux/init.h>
  14. #include <linux/device.h>
  15. #include <linux/delay.h>
  16. #include <asm/io.h>
  17. #include <asm/setup.h>
  18. #include <asm/processor.h>
  19. #include <asm/irq.h>
  20. #include <asm/intctl-regs.h>
  21. #include <asm/serial-regs.h>
  22. #include <unit/fpga-regs.h>
  23. #include <unit/serial.h>
  24. #include <unit/smsc911x.h>
  25. #define TTYS0_SERIAL_IER __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_IER * 2, u8)
  26. #define LAN_IRQ_CFG __SYSREG(SMSC911X_BASE + 0x54, u32)
  27. #define LAN_INT_EN __SYSREG(SMSC911X_BASE + 0x5c, u32)
  28. /*
  29. * initialise some of the unit hardware before gdbstub is set up
  30. */
  31. asmlinkage void __init unit_init(void)
  32. {
  33. /* Make sure we aren't going to get unexpected interrupts */
  34. TTYS0_SERIAL_IER = 0;
  35. SC0RXICR = 0;
  36. SC0TXICR = 0;
  37. SC1RXICR = 0;
  38. SC1TXICR = 0;
  39. SC2RXICR = 0;
  40. SC2TXICR = 0;
  41. /* Attempt to reset the FPGA attached peripherals */
  42. ASB2364_FPGA_REG_RESET_LAN = 0x0000;
  43. SyncExBus();
  44. ASB2364_FPGA_REG_RESET_UART = 0x0000;
  45. SyncExBus();
  46. ASB2364_FPGA_REG_RESET_I2C = 0x0000;
  47. SyncExBus();
  48. ASB2364_FPGA_REG_RESET_USB = 0x0000;
  49. SyncExBus();
  50. ASB2364_FPGA_REG_RESET_AV = 0x0000;
  51. SyncExBus();
  52. /* set up the external interrupts */
  53. /* XIRQ[0]: NAND RXBY */
  54. /* SET_XIRQ_TRIGGER(0, XIRQ_TRIGGER_LOWLEVEL); */
  55. /* XIRQ[1]: LAN, UART, I2C, USB, PCI, FPGA */
  56. SET_XIRQ_TRIGGER(1, XIRQ_TRIGGER_LOWLEVEL);
  57. /* XIRQ[2]: Extend Slot 1-9 */
  58. /* SET_XIRQ_TRIGGER(2, XIRQ_TRIGGER_LOWLEVEL); */
  59. #if defined(CONFIG_EXT_SERIAL_IRQ_LEVEL) && \
  60. defined(CONFIG_ETHERNET_IRQ_LEVEL) && \
  61. (CONFIG_EXT_SERIAL_IRQ_LEVEL != CONFIG_ETHERNET_IRQ_LEVEL)
  62. # error CONFIG_EXT_SERIAL_IRQ_LEVEL != CONFIG_ETHERNET_IRQ_LEVEL
  63. #endif
  64. #if defined(CONFIG_EXT_SERIAL_IRQ_LEVEL)
  65. set_intr_level(XIRQ1, NUM2GxICR_LEVEL(CONFIG_EXT_SERIAL_IRQ_LEVEL));
  66. #elif defined(CONFIG_ETHERNET_IRQ_LEVEL)
  67. set_intr_level(XIRQ1, NUM2GxICR_LEVEL(CONFIG_ETHERNET_IRQ_LEVEL));
  68. #endif
  69. }
  70. /*
  71. * initialise the rest of the unit hardware after gdbstub is ready
  72. */
  73. asmlinkage void __init unit_setup(void)
  74. {
  75. /* Release the reset on the SMSC911X so that it is ready by the time we
  76. * need it */
  77. ASB2364_FPGA_REG_RESET_LAN = 0x0001;
  78. SyncExBus();
  79. ASB2364_FPGA_REG_RESET_UART = 0x0001;
  80. SyncExBus();
  81. ASB2364_FPGA_REG_RESET_I2C = 0x0001;
  82. SyncExBus();
  83. ASB2364_FPGA_REG_RESET_USB = 0x0001;
  84. SyncExBus();
  85. ASB2364_FPGA_REG_RESET_AV = 0x0001;
  86. SyncExBus();
  87. /* Make sure the ethernet chipset isn't going to give us an interrupt
  88. * storm from stuff it was doing pre-reset */
  89. LAN_IRQ_CFG = 0;
  90. LAN_INT_EN = 0;
  91. }
  92. /*
  93. * initialise the external interrupts used by a unit of this type
  94. */
  95. void __init unit_init_IRQ(void)
  96. {
  97. unsigned int extnum;
  98. for (extnum = 0 ; extnum < NR_XIRQS ; extnum++) {
  99. switch (GET_XIRQ_TRIGGER(extnum)) {
  100. /* LEVEL triggered interrupts should be made
  101. * post-ACK'able as they hold their lines until
  102. * serviced
  103. */
  104. case XIRQ_TRIGGER_HILEVEL:
  105. case XIRQ_TRIGGER_LOWLEVEL:
  106. mn10300_set_lateack_irq_type(XIRQ2IRQ(extnum));
  107. break;
  108. default:
  109. break;
  110. }
  111. }
  112. #define IRQCTL __SYSREG(0xd5000090, u32)
  113. IRQCTL |= 0x02;
  114. irq_fpga_init();
  115. }