blob: 8ed1ae12bc55e26b400fccadb1b30beb3acac780 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 *
3 * BRIEF MODULE DESCRIPTION
4 * 4G Systems MTX-1 board setup.
5 *
Sergei Shtylyov1ff1a782008-04-30 23:30:12 +04006 * Copyright 2003, 2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. <source@mvista.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * 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 Torvalds1da177e2005-04-16 15:20:36 -070030
Sergei Shtylyovce28f942008-04-23 22:43:55 +040031#include <linux/init.h>
32
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include <asm/mach-au1x00/au1000.h>
34
Manuel Lauss71793802008-12-21 09:26:16 +010035#include <prom.h>
36
Florian Fainellibaa545f2007-03-02 22:07:48 +010037extern int (*board_pci_idsel)(unsigned int devsel, int assert);
Sergei Shtylyov1ff1a782008-04-30 23:30:12 +040038int mtx1_pci_idsel(unsigned int devsel, int assert);
Florian Fainellibaa545f2007-03-02 22:07:48 +010039
Ralf Baechle49a89ef2007-10-11 23:46:15 +010040void board_reset(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070041{
42 /* Hit BCSR.SYSTEM_CONTROL[SW_RST] */
43 au_writel(0x00000000, 0xAE00001C);
44}
45
46void __init board_setup(void)
47{
Manuel Lauss71793802008-12-21 09:26:16 +010048#ifdef CONFIG_SERIAL_8250_CONSOLE
49 char *argptr;
50 argptr = prom_getcmdline();
51 argptr = strstr(argptr, "console=");
52 if (argptr == NULL) {
53 argptr = prom_getcmdline();
54 strcat(argptr, " console=ttyS0,115200");
55 }
56#endif
57
Florian Fainellif7086312007-09-25 17:07:24 +020058#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
Sergei Shtylyov1ff1a782008-04-30 23:30:12 +040059 /* Enable USB power switch */
60 au_writel(au_readl(GPIO2_DIR) | 0x10, GPIO2_DIR);
61 au_writel(0x100000, GPIO2_OUTPUT);
Florian Fainellif7086312007-09-25 17:07:24 +020062#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64#ifdef CONFIG_PCI
65#if defined(__MIPSEB__)
Sergei Shtylyov1ff1a782008-04-30 23:30:12 +040066 au_writel(0xf | (2 << 6) | (1 << 4), Au1500_PCI_CFG);
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#else
68 au_writel(0xf, Au1500_PCI_CFG);
69#endif
70#endif
71
Sergei Shtylyov1ff1a782008-04-30 23:30:12 +040072 /* Initialize sys_pinfunc */
73 au_writel(SYS_PF_NI2, SYS_PINFUNC);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
Sergei Shtylyov1ff1a782008-04-30 23:30:12 +040075 /* Initialize GPIO */
76 au_writel(0xFFFFFFFF, SYS_TRIOUTCLR);
77 au_writel(0x00000001, SYS_OUTPUTCLR); /* set M66EN (PCI 66MHz) to OFF */
78 au_writel(0x00000008, SYS_OUTPUTSET); /* set PCI CLKRUN# to OFF */
79 au_writel(0x00000002, SYS_OUTPUTSET); /* set EXT_IO3 ON */
80 au_writel(0x00000020, SYS_OUTPUTCLR); /* set eth PHY TX_ER to OFF */
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
Sergei Shtylyov1ff1a782008-04-30 23:30:12 +040082 /* Enable LED and set it to green */
83 au_writel(au_readl(GPIO2_DIR) | 0x1800, GPIO2_DIR);
84 au_writel(0x18000800, GPIO2_OUTPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
Florian Fainellibaa545f2007-03-02 22:07:48 +010086 board_pci_idsel = mtx1_pci_idsel;
87
Sergei Shtylyov1ff1a782008-04-30 23:30:12 +040088 printk(KERN_INFO "4G Systems MTX-1 Board\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -070089}
Florian Fainellibaa545f2007-03-02 22:07:48 +010090
91int
92mtx1_pci_idsel(unsigned int devsel, int assert)
93{
94#define MTX_IDSEL_ONLY_0_AND_3 0
95#if MTX_IDSEL_ONLY_0_AND_3
Sergei Shtylyov1ff1a782008-04-30 23:30:12 +040096 if (devsel != 0 && devsel != 3) {
97 printk(KERN_ERR "*** not 0 or 3\n");
98 return 0;
99 }
Florian Fainellibaa545f2007-03-02 22:07:48 +0100100#endif
101
Sergei Shtylyov1ff1a782008-04-30 23:30:12 +0400102 if (assert && devsel != 0)
103 /* Suppress signal to Cardbus */
104 au_writel(0x00000002, SYS_OUTPUTCLR); /* set EXT_IO3 OFF */
105 else
106 au_writel(0x00000002, SYS_OUTPUTSET); /* set EXT_IO3 ON */
107 au_sync_udelay(1);
108 return 1;
Florian Fainellibaa545f2007-03-02 22:07:48 +0100109}
110