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> |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include <asm/mach-au1x00/au1000.h> |
| 35 | |
Manuel Lauss | 7179380 | 2008-12-21 09:26:16 +0100 | [diff] [blame] | 36 | #include <prom.h> |
| 37 | |
Florian Fainelli | baa545f | 2007-03-02 22:07:48 +0100 | [diff] [blame] | 38 | extern int (*board_pci_idsel)(unsigned int devsel, int assert); |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 39 | int mtx1_pci_idsel(unsigned int devsel, int assert); |
Florian Fainelli | baa545f | 2007-03-02 22:07:48 +0100 | [diff] [blame] | 40 | |
Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 41 | void board_reset(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | { |
| 43 | /* Hit BCSR.SYSTEM_CONTROL[SW_RST] */ |
| 44 | au_writel(0x00000000, 0xAE00001C); |
| 45 | } |
| 46 | |
| 47 | void __init board_setup(void) |
| 48 | { |
Manuel Lauss | 7179380 | 2008-12-21 09:26:16 +0100 | [diff] [blame] | 49 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
| 50 | char *argptr; |
| 51 | argptr = prom_getcmdline(); |
| 52 | argptr = strstr(argptr, "console="); |
| 53 | if (argptr == NULL) { |
| 54 | argptr = prom_getcmdline(); |
| 55 | strcat(argptr, " console=ttyS0,115200"); |
| 56 | } |
| 57 | #endif |
| 58 | |
Manuel Lauss | bb706b2 | 2009-06-06 14:09:56 +0200 | [diff] [blame] | 59 | alchemy_gpio2_enable(); |
| 60 | |
Florian Fainelli | f708631 | 2007-09-25 17:07:24 +0200 | [diff] [blame] | 61 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 62 | /* Enable USB power switch */ |
Manuel Lauss | bb706b2 | 2009-06-06 14:09:56 +0200 | [diff] [blame] | 63 | alchemy_gpio_direction_output(204, 0); |
Florian Fainelli | f708631 | 2007-09-25 17:07:24 +0200 | [diff] [blame] | 64 | #endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | |
| 66 | #ifdef CONFIG_PCI |
| 67 | #if defined(__MIPSEB__) |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 68 | au_writel(0xf | (2 << 6) | (1 << 4), Au1500_PCI_CFG); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | #else |
| 70 | au_writel(0xf, Au1500_PCI_CFG); |
| 71 | #endif |
| 72 | #endif |
| 73 | |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 74 | /* Initialize sys_pinfunc */ |
| 75 | au_writel(SYS_PF_NI2, SYS_PINFUNC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 77 | /* Initialize GPIO */ |
| 78 | au_writel(0xFFFFFFFF, SYS_TRIOUTCLR); |
Manuel Lauss | bb706b2 | 2009-06-06 14:09:56 +0200 | [diff] [blame] | 79 | alchemy_gpio_direction_output(0, 0); /* Disable M66EN (PCI 66MHz) */ |
| 80 | alchemy_gpio_direction_output(3, 1); /* Disable PCI CLKRUN# */ |
| 81 | alchemy_gpio_direction_output(1, 1); /* Enable EXT_IO3 */ |
| 82 | alchemy_gpio_direction_output(5, 0); /* Disable eth PHY TX_ER */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 84 | /* Enable LED and set it to green */ |
Manuel Lauss | bb706b2 | 2009-06-06 14:09:56 +0200 | [diff] [blame] | 85 | alchemy_gpio_direction_output(211, 1); /* green on */ |
| 86 | alchemy_gpio_direction_output(212, 0); /* red off */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
Florian Fainelli | baa545f | 2007-03-02 22:07:48 +0100 | [diff] [blame] | 88 | board_pci_idsel = mtx1_pci_idsel; |
| 89 | |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 90 | printk(KERN_INFO "4G Systems MTX-1 Board\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | } |
Florian Fainelli | baa545f | 2007-03-02 22:07:48 +0100 | [diff] [blame] | 92 | |
| 93 | int |
| 94 | mtx1_pci_idsel(unsigned int devsel, int assert) |
| 95 | { |
| 96 | #define MTX_IDSEL_ONLY_0_AND_3 0 |
| 97 | #if MTX_IDSEL_ONLY_0_AND_3 |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 98 | if (devsel != 0 && devsel != 3) { |
| 99 | printk(KERN_ERR "*** not 0 or 3\n"); |
| 100 | return 0; |
| 101 | } |
Florian Fainelli | baa545f | 2007-03-02 22:07:48 +0100 | [diff] [blame] | 102 | #endif |
| 103 | |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 104 | if (assert && devsel != 0) |
| 105 | /* Suppress signal to Cardbus */ |
Manuel Lauss | bb706b2 | 2009-06-06 14:09:56 +0200 | [diff] [blame] | 106 | gpio_set_value(1, 0); /* set EXT_IO3 OFF */ |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 107 | else |
Manuel Lauss | bb706b2 | 2009-06-06 14:09:56 +0200 | [diff] [blame] | 108 | gpio_set_value(1, 1); /* set EXT_IO3 ON */ |
| 109 | |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 110 | au_sync_udelay(1); |
| 111 | return 1; |
Florian Fainelli | baa545f | 2007-03-02 22:07:48 +0100 | [diff] [blame] | 112 | } |