ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / mips / au1000 / mtx-1 / board_setup.c
1 /*
2  *
3  * BRIEF MODULE DESCRIPTION
4  *      4G Systems MTX-1 board setup.
5  *
6  * Copyright 2003 MontaVista Software Inc.
7  * Author: MontaVista Software, Inc.
8  *              ppopov@mvista.com or source@mvista.com
9  *         Bruno Randolf <bruno.randolf@4g-systems.biz>
10  *
11  *  This program is free software; you can redistribute  it and/or modify it
12  *  under  the terms of  the GNU General  Public License as published by the
13  *  Free Software Foundation;  either version 2 of the  License, or (at your
14  *  option) any later version.
15  *
16  *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
17  *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
18  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
19  *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
20  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
22  *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23  *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
24  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  *  You should have received a copy of the  GNU General Public License along
28  *  with this program; if not, write  to the Free Software Foundation, Inc.,
29  *  675 Mass Ave, Cambridge, MA 02139, USA.
30  */
31 #include <linux/config.h>
32 #include <linux/init.h>
33 #include <linux/sched.h>
34 #include <linux/ioport.h>
35 #include <linux/mm.h>
36 #include <linux/console.h>
37 #include <linux/mc146818rtc.h>
38 #include <linux/delay.h>
39
40 #include <asm/cpu.h>
41 #include <asm/bootinfo.h>
42 #include <asm/irq.h>
43 #include <asm/keyboard.h>
44 #include <asm/mipsregs.h>
45 #include <asm/reboot.h>
46 #include <asm/pgtable.h>
47 #include <asm/au1000.h>
48
49 extern struct rtc_ops no_rtc_ops;
50
51 void __init board_setup(void)
52 {
53         rtc_ops = &no_rtc_ops;
54
55 #if defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE)
56 #ifdef CONFIG_AU1X00_USB_DEVICE
57         // 2nd USB port is USB device
58         au_writel(au_readl(SYS_PINFUNC) & (u32)(~0x8000), SYS_PINFUNC);
59 #endif
60         // enable USB power switch
61         au_writel( au_readl(GPIO2_DIR) | 0x10, GPIO2_DIR );
62         au_writel( 0x100000, GPIO2_OUTPUT );
63 #endif // defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1000_USB_DEVICE)
64
65 #ifdef CONFIG_PCI
66 #if defined(__MIPSEB__)
67         au_writel(0xf | (2<<6) | (1<<4), Au1500_PCI_CFG);
68 #else
69         au_writel(0xf, Au1500_PCI_CFG);
70 #endif
71 #endif
72
73         // initialize sys_pinfunc:
74         // disable second ethernet port (SYS_PF_NI2)
75         // set U3/GPIO23 to GPIO23 (SYS_PF_U3)
76         au_writel( SYS_PF_NI2 | SYS_PF_U3, SYS_PINFUNC );
77
78         // initialize GPIO
79         au_writel( 0xFFFFFFFF, SYS_TRIOUTCLR );
80         au_writel( 0x00000001, SYS_OUTPUTCLR ); // set M66EN (PCI 66MHz) to OFF
81         au_writel( 0x00000008, SYS_OUTPUTSET ); // set PCI CLKRUN# to OFF
82         au_writel( 0x00000020, SYS_OUTPUTCLR ); // set eth PHY TX_ER to OFF
83
84         // enable LED and set it to green
85         au_writel( au_readl(GPIO2_DIR) | 0x1800, GPIO2_DIR );
86         au_writel( 0x18000800, GPIO2_OUTPUT );
87
88         printk("4G Systems MTX-1 Board\n");
89 }