board_setup.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. *
  3. * BRIEF MODULE DESCRIPTION
  4. * 4G Systems MTX-1 board setup.
  5. *
  6. * Copyright 2003, 2008 MontaVista Software Inc.
  7. * Author: MontaVista Software, Inc. <source@mvista.com>
  8. * Bruno Randolf <bruno.randolf@4g-systems.biz>
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the License, or (at your
  13. * option) any later version.
  14. *
  15. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  16. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  17. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  18. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  19. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  20. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  21. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  22. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  24. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. *
  26. * You should have received a copy of the GNU General Public License along
  27. * with this program; if not, write to the Free Software Foundation, Inc.,
  28. * 675 Mass Ave, Cambridge, MA 02139, USA.
  29. */
  30. #include <linux/gpio.h>
  31. #include <linux/init.h>
  32. #include <linux/interrupt.h>
  33. #include <linux/pm.h>
  34. #include <asm/reboot.h>
  35. #include <asm/mach-au1x00/au1000.h>
  36. #include <prom.h>
  37. char irq_tab_alchemy[][5] __initdata = {
  38. [0] = { -1, AU1500_PCI_INTA, AU1500_PCI_INTA, 0xff, 0xff }, /* IDSEL 00 - AdapterA-Slot0 (top) */
  39. [1] = { -1, AU1500_PCI_INTB, AU1500_PCI_INTA, 0xff, 0xff }, /* IDSEL 01 - AdapterA-Slot1 (bottom) */
  40. [2] = { -1, AU1500_PCI_INTC, AU1500_PCI_INTD, 0xff, 0xff }, /* IDSEL 02 - AdapterB-Slot0 (top) */
  41. [3] = { -1, AU1500_PCI_INTD, AU1500_PCI_INTC, 0xff, 0xff }, /* IDSEL 03 - AdapterB-Slot1 (bottom) */
  42. [4] = { -1, AU1500_PCI_INTA, AU1500_PCI_INTB, 0xff, 0xff }, /* IDSEL 04 - AdapterC-Slot0 (top) */
  43. [5] = { -1, AU1500_PCI_INTB, AU1500_PCI_INTA, 0xff, 0xff }, /* IDSEL 05 - AdapterC-Slot1 (bottom) */
  44. [6] = { -1, AU1500_PCI_INTC, AU1500_PCI_INTD, 0xff, 0xff }, /* IDSEL 06 - AdapterD-Slot0 (top) */
  45. [7] = { -1, AU1500_PCI_INTD, AU1500_PCI_INTC, 0xff, 0xff }, /* IDSEL 07 - AdapterD-Slot1 (bottom) */
  46. };
  47. extern int (*board_pci_idsel)(unsigned int devsel, int assert);
  48. int mtx1_pci_idsel(unsigned int devsel, int assert);
  49. static void mtx1_reset(char *c)
  50. {
  51. /* Hit BCSR.SYSTEM_CONTROL[SW_RST] */
  52. au_writel(0x00000000, 0xAE00001C);
  53. }
  54. static void mtx1_power_off(void)
  55. {
  56. while (1)
  57. asm volatile (
  58. " .set mips32 \n"
  59. " wait \n"
  60. " .set mips0 \n");
  61. }
  62. void __init board_setup(void)
  63. {
  64. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  65. /* Enable USB power switch */
  66. alchemy_gpio_direction_output(204, 0);
  67. #endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */
  68. #ifdef CONFIG_PCI
  69. #if defined(__MIPSEB__)
  70. au_writel(0xf | (2 << 6) | (1 << 4), Au1500_PCI_CFG);
  71. #else
  72. au_writel(0xf, Au1500_PCI_CFG);
  73. #endif
  74. board_pci_idsel = mtx1_pci_idsel;
  75. #endif
  76. /* Initialize sys_pinfunc */
  77. au_writel(SYS_PF_NI2, SYS_PINFUNC);
  78. /* Initialize GPIO */
  79. au_writel(0xFFFFFFFF, SYS_TRIOUTCLR);
  80. alchemy_gpio_direction_output(0, 0); /* Disable M66EN (PCI 66MHz) */
  81. alchemy_gpio_direction_output(3, 1); /* Disable PCI CLKRUN# */
  82. alchemy_gpio_direction_output(1, 1); /* Enable EXT_IO3 */
  83. alchemy_gpio_direction_output(5, 0); /* Disable eth PHY TX_ER */
  84. /* Enable LED and set it to green */
  85. alchemy_gpio_direction_output(211, 1); /* green on */
  86. alchemy_gpio_direction_output(212, 0); /* red off */
  87. pm_power_off = mtx1_power_off;
  88. _machine_halt = mtx1_power_off;
  89. _machine_restart = mtx1_reset;
  90. printk(KERN_INFO "4G Systems MTX-1 Board\n");
  91. }
  92. int
  93. mtx1_pci_idsel(unsigned int devsel, int assert)
  94. {
  95. /* This function is only necessary to support a proprietary Cardbus
  96. * adapter on the mtx-1 "singleboard" variant. It triggers a custom
  97. * logic chip connected to EXT_IO3 (GPIO1) to suppress IDSEL signals.
  98. */
  99. if (assert && devsel != 0)
  100. /* Suppress signal to Cardbus */
  101. alchemy_gpio_set_value(1, 0); /* set EXT_IO3 OFF */
  102. else
  103. alchemy_gpio_set_value(1, 1); /* set EXT_IO3 ON */
  104. udelay(1);
  105. return 1;
  106. }
  107. static int __init mtx1_init_irq(void)
  108. {
  109. set_irq_type(AU1500_GPIO204_INT, IRQF_TRIGGER_HIGH);
  110. set_irq_type(AU1500_GPIO201_INT, IRQF_TRIGGER_LOW);
  111. set_irq_type(AU1500_GPIO202_INT, IRQF_TRIGGER_LOW);
  112. set_irq_type(AU1500_GPIO203_INT, IRQF_TRIGGER_LOW);
  113. set_irq_type(AU1500_GPIO205_INT, IRQF_TRIGGER_LOW);
  114. return 0;
  115. }
  116. arch_initcall(mtx1_init_irq);