board_setup.c 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. static void mtx1_reset(char *c)
  38. {
  39. /* Jump to the reset vector */
  40. __asm__ __volatile__("jr\t%0"::"r"(0xbfc00000));
  41. }
  42. static void mtx1_power_off(void)
  43. {
  44. while (1)
  45. asm volatile (
  46. " .set mips32 \n"
  47. " wait \n"
  48. " .set mips0 \n");
  49. }
  50. void __init board_setup(void)
  51. {
  52. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  53. /* Enable USB power switch */
  54. alchemy_gpio_direction_output(204, 0);
  55. #endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */
  56. /* Initialize sys_pinfunc */
  57. au_writel(SYS_PF_NI2, SYS_PINFUNC);
  58. /* Initialize GPIO */
  59. au_writel(~0, KSEG1ADDR(AU1000_SYS_PHYS_ADDR) + SYS_TRIOUTCLR);
  60. alchemy_gpio_direction_output(0, 0); /* Disable M66EN (PCI 66MHz) */
  61. alchemy_gpio_direction_output(3, 1); /* Disable PCI CLKRUN# */
  62. alchemy_gpio_direction_output(1, 1); /* Enable EXT_IO3 */
  63. alchemy_gpio_direction_output(5, 0); /* Disable eth PHY TX_ER */
  64. /* Enable LED and set it to green */
  65. alchemy_gpio_direction_output(211, 1); /* green on */
  66. alchemy_gpio_direction_output(212, 0); /* red off */
  67. pm_power_off = mtx1_power_off;
  68. _machine_halt = mtx1_power_off;
  69. _machine_restart = mtx1_reset;
  70. printk(KERN_INFO "4G Systems MTX-1 Board\n");
  71. }
  72. static int __init mtx1_init_irq(void)
  73. {
  74. irq_set_irq_type(AU1500_GPIO204_INT, IRQF_TRIGGER_HIGH);
  75. irq_set_irq_type(AU1500_GPIO201_INT, IRQF_TRIGGER_LOW);
  76. irq_set_irq_type(AU1500_GPIO202_INT, IRQF_TRIGGER_LOW);
  77. irq_set_irq_type(AU1500_GPIO203_INT, IRQF_TRIGGER_LOW);
  78. irq_set_irq_type(AU1500_GPIO205_INT, IRQF_TRIGGER_LOW);
  79. return 0;
  80. }
  81. arch_initcall(mtx1_init_irq);