aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/alchemy/devboards/pb1200
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/alchemy/devboards/pb1200')
-rw-r--r--arch/mips/alchemy/devboards/pb1200/Makefile7
-rw-r--r--arch/mips/alchemy/devboards/pb1200/board_setup.c164
-rw-r--r--arch/mips/alchemy/devboards/pb1200/irqmap.c134
-rw-r--r--arch/mips/alchemy/devboards/pb1200/platform.c166
4 files changed, 471 insertions, 0 deletions
diff --git a/arch/mips/alchemy/devboards/pb1200/Makefile b/arch/mips/alchemy/devboards/pb1200/Makefile
new file mode 100644
index 000000000000..c8c3a99fb68a
--- /dev/null
+++ b/arch/mips/alchemy/devboards/pb1200/Makefile
@@ -0,0 +1,7 @@
1#
2# Makefile for the Alchemy Semiconductor Pb1200/DBAu1200 boards.
3#
4
5obj-y := board_setup.o irqmap.o platform.o
6
7EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/alchemy/devboards/pb1200/board_setup.c b/arch/mips/alchemy/devboards/pb1200/board_setup.c
new file mode 100644
index 000000000000..94e6b7e7753d
--- /dev/null
+++ b/arch/mips/alchemy/devboards/pb1200/board_setup.c
@@ -0,0 +1,164 @@
1/*
2 *
3 * BRIEF MODULE DESCRIPTION
4 * Alchemy Pb1200/Db1200 board setup.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
12 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
14 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
15 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
18 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26
27#include <linux/init.h>
28#include <linux/sched.h>
29
30#include <prom.h>
31#include <au1xxx.h>
32
33
34const char *get_system_type(void)
35{
36 return "Alchemy Pb1200";
37}
38
39void board_reset(void)
40{
41 bcsr->resets = 0;
42 bcsr->system = 0;
43}
44
45void __init board_setup(void)
46{
47 char *argptr;
48
49 argptr = prom_getcmdline();
50#ifdef CONFIG_SERIAL_8250_CONSOLE
51 argptr = strstr(argptr, "console=");
52 if (argptr == NULL) {
53 argptr = prom_getcmdline();
54 strcat(argptr, " console=ttyS0,115200");
55 }
56#endif
57#ifdef CONFIG_FB_AU1200
58 strcat(argptr, " video=au1200fb:panel:bs");
59#endif
60
61#if 0
62 {
63 u32 pin_func;
64
65 /*
66 * Enable PSC1 SYNC for AC97. Normaly done in audio driver,
67 * but it is board specific code, so put it here.
68 */
69 pin_func = au_readl(SYS_PINFUNC);
70 au_sync();
71 pin_func |= SYS_PF_MUST_BE_SET | SYS_PF_PSC1_S1;
72 au_writel(pin_func, SYS_PINFUNC);
73
74 au_writel(0, (u32)bcsr | 0x10); /* turn off PCMCIA power */
75 au_sync();
76 }
77#endif
78
79#if defined(CONFIG_I2C_AU1550)
80 {
81 u32 freq0, clksrc;
82 u32 pin_func;
83
84 /* Select SMBus in CPLD */
85 bcsr->resets &= ~BCSR_RESETS_PCS0MUX;
86
87 pin_func = au_readl(SYS_PINFUNC);
88 au_sync();
89 pin_func &= ~(SYS_PINFUNC_P0A | SYS_PINFUNC_P0B);
90 /* Set GPIOs correctly */
91 pin_func |= 2 << 17;
92 au_writel(pin_func, SYS_PINFUNC);
93 au_sync();
94
95 /* The I2C driver depends on 50 MHz clock */
96 freq0 = au_readl(SYS_FREQCTRL0);
97 au_sync();
98 freq0 &= ~(SYS_FC_FRDIV1_MASK | SYS_FC_FS1 | SYS_FC_FE1);
99 freq0 |= 3 << SYS_FC_FRDIV1_BIT;
100 /* 396 MHz / (3 + 1) * 2 == 49.5 MHz */
101 au_writel(freq0, SYS_FREQCTRL0);
102 au_sync();
103 freq0 |= SYS_FC_FE1;
104 au_writel(freq0, SYS_FREQCTRL0);
105 au_sync();
106
107 clksrc = au_readl(SYS_CLKSRC);
108 au_sync();
109 clksrc &= ~(SYS_CS_CE0 | SYS_CS_DE0 | SYS_CS_ME0_MASK);
110 /* Bit 22 is EXTCLK0 for PSC0 */
111 clksrc |= SYS_CS_MUX_FQ1 << SYS_CS_ME0_BIT;
112 au_writel(clksrc, SYS_CLKSRC);
113 au_sync();
114 }
115#endif
116
117 /*
118 * The Pb1200 development board uses external MUX for PSC0 to
119 * support SMB/SPI. bcsr->resets bit 12: 0=SMB 1=SPI
120 */
121#ifdef CONFIG_I2C_AU1550
122 bcsr->resets &= ~BCSR_RESETS_PCS0MUX;
123#endif
124 au_sync();
125
126#ifdef CONFIG_MIPS_PB1200
127 printk(KERN_INFO "AMD Alchemy Pb1200 Board\n");
128#endif
129#ifdef CONFIG_MIPS_DB1200
130 printk(KERN_INFO "AMD Alchemy Db1200 Board\n");
131#endif
132}
133
134int board_au1200fb_panel(void)
135{
136 BCSR *bcsr = (BCSR *)BCSR_KSEG1_ADDR;
137 int p;
138
139 p = bcsr->switches;
140 p >>= 8;
141 p &= 0x0F;
142 return p;
143}
144
145int board_au1200fb_panel_init(void)
146{
147 /* Apply power */
148 BCSR *bcsr = (BCSR *)BCSR_KSEG1_ADDR;
149
150 bcsr->board |= BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD | BCSR_BOARD_LCDBL;
151 /* printk(KERN_DEBUG "board_au1200fb_panel_init()\n"); */
152 return 0;
153}
154
155int board_au1200fb_panel_shutdown(void)
156{
157 /* Remove power */
158 BCSR *bcsr = (BCSR *)BCSR_KSEG1_ADDR;
159
160 bcsr->board &= ~(BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
161 BCSR_BOARD_LCDBL);
162 /* printk(KERN_DEBUG "board_au1200fb_panel_shutdown()\n"); */
163 return 0;
164}
diff --git a/arch/mips/alchemy/devboards/pb1200/irqmap.c b/arch/mips/alchemy/devboards/pb1200/irqmap.c
new file mode 100644
index 000000000000..fe47498da280
--- /dev/null
+++ b/arch/mips/alchemy/devboards/pb1200/irqmap.c
@@ -0,0 +1,134 @@
1/*
2 * BRIEF MODULE DESCRIPTION
3 * Au1xxx irq map table
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
11 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
13 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
14 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
15 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
16 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
17 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
18 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
19 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26#include <linux/init.h>
27#include <linux/interrupt.h>
28
29#include <asm/mach-au1x00/au1000.h>
30
31#ifdef CONFIG_MIPS_PB1200
32#include <asm/mach-pb1x00/pb1200.h>
33#endif
34
35#ifdef CONFIG_MIPS_DB1200
36#include <asm/mach-db1x00/db1200.h>
37#define PB1200_INT_BEGIN DB1200_INT_BEGIN
38#define PB1200_INT_END DB1200_INT_END
39#endif
40
41struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
42 /* This is external interrupt cascade */
43 { AU1000_GPIO_7, IRQF_TRIGGER_LOW, 0 },
44};
45
46
47/*
48 * Support for External interrupts on the Pb1200 Development platform.
49 */
50
51static void pb1200_cascade_handler(unsigned int irq, struct irq_desc *d)
52{
53 unsigned short bisr = bcsr->int_status;
54
55 for ( ; bisr; bisr &= bisr - 1)
56 generic_handle_irq(PB1200_INT_BEGIN + __ffs(bisr));
57}
58
59/* NOTE: both the enable and mask bits must be cleared, otherwise the
60 * CPLD generates tons of spurious interrupts (at least on the DB1200).
61 */
62static void pb1200_mask_irq(unsigned int irq_nr)
63{
64 bcsr->intclr_mask = 1 << (irq_nr - PB1200_INT_BEGIN);
65 bcsr->intclr = 1 << (irq_nr - PB1200_INT_BEGIN);
66 au_sync();
67}
68
69static void pb1200_maskack_irq(unsigned int irq_nr)
70{
71 bcsr->intclr_mask = 1 << (irq_nr - PB1200_INT_BEGIN);
72 bcsr->intclr = 1 << (irq_nr - PB1200_INT_BEGIN);
73 bcsr->int_status = 1 << (irq_nr - PB1200_INT_BEGIN); /* ack */
74 au_sync();
75}
76
77static void pb1200_unmask_irq(unsigned int irq_nr)
78{
79 bcsr->intset = 1 << (irq_nr - PB1200_INT_BEGIN);
80 bcsr->intset_mask = 1 << (irq_nr - PB1200_INT_BEGIN);
81 au_sync();
82}
83
84static struct irq_chip pb1200_cpld_irq_type = {
85#ifdef CONFIG_MIPS_PB1200
86 .name = "Pb1200 Ext",
87#endif
88#ifdef CONFIG_MIPS_DB1200
89 .name = "Db1200 Ext",
90#endif
91 .mask = pb1200_mask_irq,
92 .mask_ack = pb1200_maskack_irq,
93 .unmask = pb1200_unmask_irq,
94};
95
96void __init board_init_irq(void)
97{
98 unsigned int irq;
99
100 au1xxx_setup_irqmap(au1xxx_irq_map, ARRAY_SIZE(au1xxx_irq_map));
101
102#ifdef CONFIG_MIPS_PB1200
103 /* We have a problem with CPLD rev 3. */
104 if (((bcsr->whoami & BCSR_WHOAMI_CPLD) >> 4) <= 3) {
105 printk(KERN_ERR "WARNING!!!\n");
106 printk(KERN_ERR "WARNING!!!\n");
107 printk(KERN_ERR "WARNING!!!\n");
108 printk(KERN_ERR "WARNING!!!\n");
109 printk(KERN_ERR "WARNING!!!\n");
110 printk(KERN_ERR "WARNING!!!\n");
111 printk(KERN_ERR "Pb1200 must be at CPLD rev 4. Please have Pb1200\n");
112 printk(KERN_ERR "updated to latest revision. This software will\n");
113 printk(KERN_ERR "not work on anything less than CPLD rev 4.\n");
114 printk(KERN_ERR "WARNING!!!\n");
115 printk(KERN_ERR "WARNING!!!\n");
116 printk(KERN_ERR "WARNING!!!\n");
117 printk(KERN_ERR "WARNING!!!\n");
118 printk(KERN_ERR "WARNING!!!\n");
119 printk(KERN_ERR "WARNING!!!\n");
120 panic("Game over. Your score is 0.");
121 }
122#endif
123 /* mask & disable & ack all */
124 bcsr->intclr_mask = 0xffff;
125 bcsr->intclr = 0xffff;
126 bcsr->int_status = 0xffff;
127 au_sync();
128
129 for (irq = PB1200_INT_BEGIN; irq <= PB1200_INT_END; irq++)
130 set_irq_chip_and_handler_name(irq, &pb1200_cpld_irq_type,
131 handle_level_irq, "level");
132
133 set_irq_chained_handler(AU1000_GPIO_7, pb1200_cascade_handler);
134}
diff --git a/arch/mips/alchemy/devboards/pb1200/platform.c b/arch/mips/alchemy/devboards/pb1200/platform.c
new file mode 100644
index 000000000000..95303297c534
--- /dev/null
+++ b/arch/mips/alchemy/devboards/pb1200/platform.c
@@ -0,0 +1,166 @@
1/*
2 * Pb1200/DBAu1200 board platform device registration
3 *
4 * Copyright (C) 2008 MontaVista Software Inc. <source@mvista.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <linux/dma-mapping.h>
22#include <linux/init.h>
23#include <linux/leds.h>
24#include <linux/platform_device.h>
25
26#include <asm/mach-au1x00/au1xxx.h>
27#include <asm/mach-au1x00/au1100_mmc.h>
28
29static int mmc_activity;
30
31static void pb1200mmc0_set_power(void *mmc_host, int state)
32{
33 if (state)
34 bcsr->board |= BCSR_BOARD_SD0PWR;
35 else
36 bcsr->board &= ~BCSR_BOARD_SD0PWR;
37
38 au_sync_delay(1);
39}
40
41static int pb1200mmc0_card_readonly(void *mmc_host)
42{
43 return (bcsr->status & BCSR_STATUS_SD0WP) ? 1 : 0;
44}
45
46static int pb1200mmc0_card_inserted(void *mmc_host)
47{
48 return (bcsr->sig_status & BCSR_INT_SD0INSERT) ? 1 : 0;
49}
50
51static void pb1200_mmcled_set(struct led_classdev *led,
52 enum led_brightness brightness)
53{
54 if (brightness != LED_OFF) {
55 if (++mmc_activity == 1)
56 bcsr->disk_leds &= ~(1 << 8);
57 } else {
58 if (--mmc_activity == 0)
59 bcsr->disk_leds |= (1 << 8);
60 }
61}
62
63static struct led_classdev pb1200mmc_led = {
64 .brightness_set = pb1200_mmcled_set,
65};
66
67#ifndef CONFIG_MIPS_DB1200
68static void pb1200mmc1_set_power(void *mmc_host, int state)
69{
70 if (state)
71 bcsr->board |= BCSR_BOARD_SD1PWR;
72 else
73 bcsr->board &= ~BCSR_BOARD_SD1PWR;
74
75 au_sync_delay(1);
76}
77
78static int pb1200mmc1_card_readonly(void *mmc_host)
79{
80 return (bcsr->status & BCSR_STATUS_SD1WP) ? 1 : 0;
81}
82
83static int pb1200mmc1_card_inserted(void *mmc_host)
84{
85 return (bcsr->sig_status & BCSR_INT_SD1INSERT) ? 1 : 0;
86}
87#endif
88
89const struct au1xmmc_platform_data au1xmmc_platdata[2] = {
90 [0] = {
91 .set_power = pb1200mmc0_set_power,
92 .card_inserted = pb1200mmc0_card_inserted,
93 .card_readonly = pb1200mmc0_card_readonly,
94 .cd_setup = NULL, /* use poll-timer in driver */
95 .led = &pb1200mmc_led,
96 },
97#ifndef CONFIG_MIPS_DB1200
98 [1] = {
99 .set_power = pb1200mmc1_set_power,
100 .card_inserted = pb1200mmc1_card_inserted,
101 .card_readonly = pb1200mmc1_card_readonly,
102 .cd_setup = NULL, /* use poll-timer in driver */
103 .led = &pb1200mmc_led,
104 },
105#endif
106};
107
108static struct resource ide_resources[] = {
109 [0] = {
110 .start = IDE_PHYS_ADDR,
111 .end = IDE_PHYS_ADDR + IDE_PHYS_LEN - 1,
112 .flags = IORESOURCE_MEM
113 },
114 [1] = {
115 .start = IDE_INT,
116 .end = IDE_INT,
117 .flags = IORESOURCE_IRQ
118 }
119};
120
121static u64 ide_dmamask = DMA_32BIT_MASK;
122
123static struct platform_device ide_device = {
124 .name = "au1200-ide",
125 .id = 0,
126 .dev = {
127 .dma_mask = &ide_dmamask,
128 .coherent_dma_mask = DMA_32BIT_MASK,
129 },
130 .num_resources = ARRAY_SIZE(ide_resources),
131 .resource = ide_resources
132};
133
134static struct resource smc91c111_resources[] = {
135 [0] = {
136 .name = "smc91x-regs",
137 .start = SMC91C111_PHYS_ADDR,
138 .end = SMC91C111_PHYS_ADDR + 0xf,
139 .flags = IORESOURCE_MEM
140 },
141 [1] = {
142 .start = SMC91C111_INT,
143 .end = SMC91C111_INT,
144 .flags = IORESOURCE_IRQ
145 },
146};
147
148static struct platform_device smc91c111_device = {
149 .name = "smc91x",
150 .id = -1,
151 .num_resources = ARRAY_SIZE(smc91c111_resources),
152 .resource = smc91c111_resources
153};
154
155static struct platform_device *board_platform_devices[] __initdata = {
156 &ide_device,
157 &smc91c111_device
158};
159
160static int __init board_register_devices(void)
161{
162 return platform_add_devices(board_platform_devices,
163 ARRAY_SIZE(board_platform_devices));
164}
165
166arch_initcall(board_register_devices);