Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * BRIEF MODULE DESCRIPTION |
| 4 | * 4G Systems MTX-1 board setup. |
| 5 | * |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 6 | * Copyright 2003, 2008 MontaVista Software Inc. |
| 7 | * Author: MontaVista Software, Inc. <source@mvista.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Manuel Lauss | bb706b2 | 2009-06-06 14:09:56 +0200 | [diff] [blame] | 31 | #include <linux/gpio.h> |
Sergei Shtylyov | ce28f94 | 2008-04-23 22:43:55 +0400 | [diff] [blame] | 32 | #include <linux/init.h> |
Manuel Lauss | 7e50b2b | 2009-10-04 14:55:26 +0200 | [diff] [blame] | 33 | #include <linux/interrupt.h> |
Manuel Lauss | 32fd690 | 2009-12-08 19:18:13 +0100 | [diff] [blame] | 34 | #include <linux/pm.h> |
Sergei Shtylyov | ce28f94 | 2008-04-23 22:43:55 +0400 | [diff] [blame] | 35 | |
Manuel Lauss | 32fd690 | 2009-12-08 19:18:13 +0100 | [diff] [blame] | 36 | #include <asm/reboot.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #include <asm/mach-au1x00/au1000.h> |
| 38 | |
Manuel Lauss | 7179380 | 2008-12-21 09:26:16 +0100 | [diff] [blame] | 39 | #include <prom.h> |
| 40 | |
Manuel Lauss | 7e50b2b | 2009-10-04 14:55:26 +0200 | [diff] [blame] | 41 | char irq_tab_alchemy[][5] __initdata = { |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 42 | [0] = { -1, AU1500_PCI_INTA, AU1500_PCI_INTA, 0xff, 0xff }, /* IDSEL 00 - AdapterA-Slot0 (top) */ |
| 43 | [1] = { -1, AU1500_PCI_INTB, AU1500_PCI_INTA, 0xff, 0xff }, /* IDSEL 01 - AdapterA-Slot1 (bottom) */ |
| 44 | [2] = { -1, AU1500_PCI_INTC, AU1500_PCI_INTD, 0xff, 0xff }, /* IDSEL 02 - AdapterB-Slot0 (top) */ |
| 45 | [3] = { -1, AU1500_PCI_INTD, AU1500_PCI_INTC, 0xff, 0xff }, /* IDSEL 03 - AdapterB-Slot1 (bottom) */ |
| 46 | [4] = { -1, AU1500_PCI_INTA, AU1500_PCI_INTB, 0xff, 0xff }, /* IDSEL 04 - AdapterC-Slot0 (top) */ |
| 47 | [5] = { -1, AU1500_PCI_INTB, AU1500_PCI_INTA, 0xff, 0xff }, /* IDSEL 05 - AdapterC-Slot1 (bottom) */ |
| 48 | [6] = { -1, AU1500_PCI_INTC, AU1500_PCI_INTD, 0xff, 0xff }, /* IDSEL 06 - AdapterD-Slot0 (top) */ |
| 49 | [7] = { -1, AU1500_PCI_INTD, AU1500_PCI_INTC, 0xff, 0xff }, /* IDSEL 07 - AdapterD-Slot1 (bottom) */ |
Manuel Lauss | 7e50b2b | 2009-10-04 14:55:26 +0200 | [diff] [blame] | 50 | }; |
| 51 | |
Florian Fainelli | baa545f | 2007-03-02 22:07:48 +0100 | [diff] [blame] | 52 | extern int (*board_pci_idsel)(unsigned int devsel, int assert); |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 53 | int mtx1_pci_idsel(unsigned int devsel, int assert); |
Florian Fainelli | baa545f | 2007-03-02 22:07:48 +0100 | [diff] [blame] | 54 | |
Manuel Lauss | 32fd690 | 2009-12-08 19:18:13 +0100 | [diff] [blame] | 55 | static void mtx1_reset(char *c) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | { |
Florian Fainelli | 9ced975 | 2011-02-21 14:28:02 +0100 | [diff] [blame] | 57 | /* Jump to the reset vector */ |
| 58 | __asm__ __volatile__("jr\t%0"::"r"(0xbfc00000)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | } |
| 60 | |
Manuel Lauss | 32fd690 | 2009-12-08 19:18:13 +0100 | [diff] [blame] | 61 | static void mtx1_power_off(void) |
| 62 | { |
Manuel Lauss | 32fd690 | 2009-12-08 19:18:13 +0100 | [diff] [blame] | 63 | while (1) |
Ralf Baechle | 36f217d | 2010-08-03 03:42:32 +0100 | [diff] [blame] | 64 | asm volatile ( |
| 65 | " .set mips32 \n" |
| 66 | " wait \n" |
| 67 | " .set mips0 \n"); |
Manuel Lauss | 32fd690 | 2009-12-08 19:18:13 +0100 | [diff] [blame] | 68 | } |
| 69 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | void __init board_setup(void) |
| 71 | { |
Florian Fainelli | f708631 | 2007-09-25 17:07:24 +0200 | [diff] [blame] | 72 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 73 | /* Enable USB power switch */ |
Manuel Lauss | bb706b2 | 2009-06-06 14:09:56 +0200 | [diff] [blame] | 74 | alchemy_gpio_direction_output(204, 0); |
Florian Fainelli | f708631 | 2007-09-25 17:07:24 +0200 | [diff] [blame] | 75 | #endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
| 77 | #ifdef CONFIG_PCI |
| 78 | #if defined(__MIPSEB__) |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 79 | au_writel(0xf | (2 << 6) | (1 << 4), Au1500_PCI_CFG); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | #else |
| 81 | au_writel(0xf, Au1500_PCI_CFG); |
| 82 | #endif |
Ralf Baechle | 39d2211 | 2009-10-12 02:23:48 +0200 | [diff] [blame] | 83 | board_pci_idsel = mtx1_pci_idsel; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | #endif |
| 85 | |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 86 | /* Initialize sys_pinfunc */ |
| 87 | au_writel(SYS_PF_NI2, SYS_PINFUNC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 89 | /* Initialize GPIO */ |
Manuel Lauss | b7f720d | 2011-05-08 10:42:20 +0200 | [diff] [blame] | 90 | au_writel(~0, KSEG1ADDR(AU1000_SYS_PHYS_ADDR) + SYS_TRIOUTCLR); |
Manuel Lauss | bb706b2 | 2009-06-06 14:09:56 +0200 | [diff] [blame] | 91 | alchemy_gpio_direction_output(0, 0); /* Disable M66EN (PCI 66MHz) */ |
| 92 | alchemy_gpio_direction_output(3, 1); /* Disable PCI CLKRUN# */ |
| 93 | alchemy_gpio_direction_output(1, 1); /* Enable EXT_IO3 */ |
| 94 | alchemy_gpio_direction_output(5, 0); /* Disable eth PHY TX_ER */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 96 | /* Enable LED and set it to green */ |
Manuel Lauss | bb706b2 | 2009-06-06 14:09:56 +0200 | [diff] [blame] | 97 | alchemy_gpio_direction_output(211, 1); /* green on */ |
| 98 | alchemy_gpio_direction_output(212, 0); /* red off */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
Manuel Lauss | 32fd690 | 2009-12-08 19:18:13 +0100 | [diff] [blame] | 100 | pm_power_off = mtx1_power_off; |
| 101 | _machine_halt = mtx1_power_off; |
| 102 | _machine_restart = mtx1_reset; |
| 103 | |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 104 | printk(KERN_INFO "4G Systems MTX-1 Board\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | } |
Florian Fainelli | baa545f | 2007-03-02 22:07:48 +0100 | [diff] [blame] | 106 | |
| 107 | int |
| 108 | mtx1_pci_idsel(unsigned int devsel, int assert) |
| 109 | { |
Bruno Randolf | b3b3c17 | 2010-07-12 00:40:38 +0900 | [diff] [blame] | 110 | /* This function is only necessary to support a proprietary Cardbus |
| 111 | * adapter on the mtx-1 "singleboard" variant. It triggers a custom |
| 112 | * logic chip connected to EXT_IO3 (GPIO1) to suppress IDSEL signals. |
| 113 | */ |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 114 | if (assert && devsel != 0) |
| 115 | /* Suppress signal to Cardbus */ |
Bruno Randolf | 98a0f86 | 2010-07-12 00:40:28 +0900 | [diff] [blame] | 116 | alchemy_gpio_set_value(1, 0); /* set EXT_IO3 OFF */ |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 117 | else |
Bruno Randolf | 98a0f86 | 2010-07-12 00:40:28 +0900 | [diff] [blame] | 118 | alchemy_gpio_set_value(1, 1); /* set EXT_IO3 ON */ |
Manuel Lauss | bb706b2 | 2009-06-06 14:09:56 +0200 | [diff] [blame] | 119 | |
Bruno Randolf | 98a0f86 | 2010-07-12 00:40:28 +0900 | [diff] [blame] | 120 | udelay(1); |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 121 | return 1; |
Florian Fainelli | baa545f | 2007-03-02 22:07:48 +0100 | [diff] [blame] | 122 | } |
Manuel Lauss | 7e50b2b | 2009-10-04 14:55:26 +0200 | [diff] [blame] | 123 | |
| 124 | static int __init mtx1_init_irq(void) |
| 125 | { |
Thomas Gleixner | e4ec798 | 2011-03-27 15:19:28 +0200 | [diff] [blame] | 126 | irq_set_irq_type(AU1500_GPIO204_INT, IRQF_TRIGGER_HIGH); |
| 127 | irq_set_irq_type(AU1500_GPIO201_INT, IRQF_TRIGGER_LOW); |
| 128 | irq_set_irq_type(AU1500_GPIO202_INT, IRQF_TRIGGER_LOW); |
| 129 | irq_set_irq_type(AU1500_GPIO203_INT, IRQF_TRIGGER_LOW); |
| 130 | irq_set_irq_type(AU1500_GPIO205_INT, IRQF_TRIGGER_LOW); |
Manuel Lauss | 7e50b2b | 2009-10-04 14:55:26 +0200 | [diff] [blame] | 131 | |
| 132 | return 0; |
| 133 | } |
| 134 | arch_initcall(mtx1_init_irq); |