blob: 57ed5f1c491987d7186e77a1d10ee2c88f5aba58 [file] [log] [blame]
Manuel Lauss27dd65a2009-10-04 14:55:28 +02001/*
Manuel Lauss7c4b24d2011-11-10 12:06:21 +00002 * DBAu1000/1500/1100 board support
Manuel Lauss27dd65a2009-10-04 14:55:28 +02003 *
Manuel Lauss7c4b24d2011-11-10 12:06:21 +00004 * Copyright 2000, 2008 MontaVista Software Inc.
5 * Author: MontaVista Software, Inc. <source@mvista.com>
Manuel Lauss27dd65a2009-10-04 14:55:28 +02006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000022#include <linux/dma-mapping.h>
23#include <linux/gpio.h>
Manuel Lauss27dd65a2009-10-04 14:55:28 +020024#include <linux/init.h>
Manuel Laussb2ce3052011-07-25 13:44:46 +020025#include <linux/interrupt.h>
Manuel Lauss27dd65a2009-10-04 14:55:28 +020026#include <linux/platform_device.h>
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000027#include <linux/pm.h>
Manuel Laussb2ce3052011-07-25 13:44:46 +020028#include <asm/mach-au1x00/au1000.h>
29#include <asm/mach-au1x00/au1000_dma.h>
Manuel Lauss206aa6c2009-10-19 12:53:37 +020030#include <asm/mach-db1x00/bcsr.h>
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000031#include <asm/reboot.h>
32#include <prom.h>
33#include "platform.h"
Manuel Lauss27dd65a2009-10-04 14:55:28 +020034
Manuel Laussf59c8112011-11-10 12:06:22 +000035#define F_SWAPPED (bcsr_read(BCSR_STATUS) & BCSR_STATUS_DB1000_SWAPBOOT)
36
Manuel Lauss7517de32011-08-12 11:39:44 +020037struct pci_dev;
38
Manuel Laussf59c8112011-11-10 12:06:22 +000039static const char *board_type_str(void)
40{
41 switch (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI))) {
42 case BCSR_WHOAMI_DB1000:
43 return "DB1000";
44 case BCSR_WHOAMI_DB1500:
45 return "DB1500";
46 case BCSR_WHOAMI_DB1100:
47 return "DB1100";
48 default:
49 return "(unknown)";
50 }
51}
52
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000053const char *get_system_type(void)
54{
Manuel Laussf59c8112011-11-10 12:06:22 +000055 return board_type_str();
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000056}
57
58void __init board_setup(void)
59{
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000060 /* initialize board register space */
61 bcsr_init(DB1000_BCSR_PHYS_ADDR,
62 DB1000_BCSR_PHYS_ADDR + DB1000_BCSR_HEXLED_OFS);
63
Manuel Laussf59c8112011-11-10 12:06:22 +000064 printk(KERN_INFO "AMD Alchemy %s Board\n", board_type_str());
65
Manuel Lauss7c4b24d2011-11-10 12:06:21 +000066#if defined(CONFIG_IRDA) && defined(CONFIG_AU1000_FIR)
67 {
68 u32 pin_func;
69
70 /* Set IRFIRSEL instead of GPIO15 */
71 pin_func = au_readl(SYS_PINFUNC) | SYS_PF_IRF;
72 au_writel(pin_func, SYS_PINFUNC);
73 /* Power off until the driver is in use */
74 bcsr_mod(BCSR_RESETS, BCSR_RESETS_IRDA_MODE_MASK,
75 BCSR_RESETS_IRDA_MODE_OFF);
76 }
77#endif
78 bcsr_write(BCSR_PCMCIA, 0); /* turn off PCMCIA power */
79
80 /* Enable GPIO[31:0] inputs */
81 alchemy_gpio1_input_enable();
82}
83
Manuel Lauss27dd65a2009-10-04 14:55:28 +020084
Manuel Laussf869d422011-11-10 12:06:16 +000085static int db1500_map_pci_irq(const struct pci_dev *d, u8 slot, u8 pin)
Manuel Lauss7517de32011-08-12 11:39:44 +020086{
87 if ((slot < 12) || (slot > 13) || pin == 0)
88 return -1;
89 if (slot == 12)
90 return (pin == 1) ? AU1500_PCI_INTA : 0xff;
91 if (slot == 13) {
92 switch (pin) {
93 case 1: return AU1500_PCI_INTA;
94 case 2: return AU1500_PCI_INTB;
95 case 3: return AU1500_PCI_INTC;
96 case 4: return AU1500_PCI_INTD;
97 }
98 }
99 return -1;
100}
Manuel Lauss7517de32011-08-12 11:39:44 +0200101
Manuel Lauss7517de32011-08-12 11:39:44 +0200102static struct resource alchemy_pci_host_res[] = {
103 [0] = {
104 .start = AU1500_PCI_PHYS_ADDR,
105 .end = AU1500_PCI_PHYS_ADDR + 0xfff,
106 .flags = IORESOURCE_MEM,
107 },
108};
109
Manuel Laussf869d422011-11-10 12:06:16 +0000110static struct alchemy_pci_platdata db1500_pci_pd = {
111 .board_map_irq = db1500_map_pci_irq,
Manuel Lauss7517de32011-08-12 11:39:44 +0200112};
113
Manuel Laussf869d422011-11-10 12:06:16 +0000114static struct platform_device db1500_pci_host_dev = {
115 .dev.platform_data = &db1500_pci_pd,
Manuel Lauss7517de32011-08-12 11:39:44 +0200116 .name = "alchemy-pci",
117 .id = 0,
118 .num_resources = ARRAY_SIZE(alchemy_pci_host_res),
119 .resource = alchemy_pci_host_res,
120};
121
Manuel Laussf869d422011-11-10 12:06:16 +0000122static int __init db1500_pci_init(void)
Manuel Lauss7517de32011-08-12 11:39:44 +0200123{
Manuel Laussf59c8112011-11-10 12:06:22 +0000124 if (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)) == BCSR_WHOAMI_DB1500)
125 return platform_device_register(&db1500_pci_host_dev);
126 return 0;
Manuel Lauss7517de32011-08-12 11:39:44 +0200127}
128/* must be arch_initcall; MIPS PCI scans busses in a subsys_initcall */
Manuel Laussf869d422011-11-10 12:06:16 +0000129arch_initcall(db1500_pci_init);
Manuel Lauss7517de32011-08-12 11:39:44 +0200130
Manuel Laussf59c8112011-11-10 12:06:22 +0000131
Manuel Lauss3766386032011-08-12 11:39:45 +0200132static struct resource au1100_lcd_resources[] = {
133 [0] = {
134 .start = AU1100_LCD_PHYS_ADDR,
135 .end = AU1100_LCD_PHYS_ADDR + 0x800 - 1,
136 .flags = IORESOURCE_MEM,
137 },
138 [1] = {
139 .start = AU1100_LCD_INT,
140 .end = AU1100_LCD_INT,
141 .flags = IORESOURCE_IRQ,
142 }
143};
144
145static u64 au1100_lcd_dmamask = DMA_BIT_MASK(32);
146
147static struct platform_device au1100_lcd_device = {
148 .name = "au1100-lcd",
149 .id = 0,
150 .dev = {
151 .dma_mask = &au1100_lcd_dmamask,
152 .coherent_dma_mask = DMA_BIT_MASK(32),
153 },
154 .num_resources = ARRAY_SIZE(au1100_lcd_resources),
155 .resource = au1100_lcd_resources,
156};
Manuel Lauss3766386032011-08-12 11:39:45 +0200157
Manuel Laussb2ce3052011-07-25 13:44:46 +0200158static struct resource alchemy_ac97c_res[] = {
159 [0] = {
160 .start = AU1000_AC97_PHYS_ADDR,
161 .end = AU1000_AC97_PHYS_ADDR + 0xfff,
162 .flags = IORESOURCE_MEM,
163 },
164 [1] = {
165 .start = DMA_ID_AC97C_TX,
166 .end = DMA_ID_AC97C_TX,
167 .flags = IORESOURCE_DMA,
168 },
169 [2] = {
170 .start = DMA_ID_AC97C_RX,
171 .end = DMA_ID_AC97C_RX,
172 .flags = IORESOURCE_DMA,
173 },
174};
175
176static struct platform_device alchemy_ac97c_dev = {
177 .name = "alchemy-ac97c",
178 .id = -1,
179 .resource = alchemy_ac97c_res,
180 .num_resources = ARRAY_SIZE(alchemy_ac97c_res),
181};
182
183static struct platform_device alchemy_ac97c_dma_dev = {
184 .name = "alchemy-pcm-dma",
185 .id = 0,
186};
187
188static struct platform_device db1x00_codec_dev = {
189 .name = "ac97-codec",
190 .id = -1,
191};
192
193static struct platform_device db1x00_audio_dev = {
194 .name = "db1000-audio",
195};
196
Manuel Laussf59c8112011-11-10 12:06:22 +0000197static struct platform_device *db1x00_devs[] = {
198 &db1x00_codec_dev,
199 &alchemy_ac97c_dma_dev,
200 &alchemy_ac97c_dev,
201 &db1x00_audio_dev,
202};
203
204static struct platform_device *db1100_devs[] = {
205 &au1100_lcd_device,
206};
207
208static int __init db1000_dev_init(void)
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200209{
Manuel Laussf59c8112011-11-10 12:06:22 +0000210 int board = BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI));
211 int c0, c1, d0, d1, s0, s1;
212
213 if (board == BCSR_WHOAMI_DB1500) {
214 c0 = AU1500_GPIO2_INT;
215 c1 = AU1500_GPIO5_INT;
216 d0 = AU1500_GPIO0_INT;
217 d1 = AU1500_GPIO3_INT;
218 s0 = AU1500_GPIO1_INT;
219 s1 = AU1500_GPIO4_INT;
220 } else if (board == BCSR_WHOAMI_DB1100) {
221 c0 = AU1100_GPIO2_INT;
222 c1 = AU1100_GPIO5_INT;
223 d0 = AU1100_GPIO0_INT;
224 d1 = AU1100_GPIO3_INT;
225 s0 = AU1100_GPIO1_INT;
226 s1 = AU1100_GPIO4_INT;
227 platform_add_devices(db1100_devs, ARRAY_SIZE(db1100_devs));
228 } else if (board == BCSR_WHOAMI_DB1000) {
229 c0 = AU1000_GPIO2_INT;
230 c1 = AU1000_GPIO5_INT;
231 d0 = AU1000_GPIO0_INT;
232 d1 = AU1000_GPIO3_INT;
233 s0 = AU1000_GPIO1_INT;
234 s1 = AU1000_GPIO4_INT;
235 } else
236 return 0; /* unknown board, no further dev setup to do */
237
238 irq_set_irq_type(d0, IRQ_TYPE_EDGE_BOTH);
239 irq_set_irq_type(d1, IRQ_TYPE_EDGE_BOTH);
240 irq_set_irq_type(c0, IRQ_TYPE_LEVEL_LOW);
241 irq_set_irq_type(c1, IRQ_TYPE_LEVEL_LOW);
242 irq_set_irq_type(s0, IRQ_TYPE_LEVEL_LOW);
243 irq_set_irq_type(s1, IRQ_TYPE_LEVEL_LOW);
Manuel Lauss7c4b24d2011-11-10 12:06:21 +0000244
Manuel Lauss7cc2e272011-08-12 11:39:40 +0200245 db1x_register_pcmcia_socket(
246 AU1000_PCMCIA_ATTR_PHYS_ADDR,
247 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
248 AU1000_PCMCIA_MEM_PHYS_ADDR,
249 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1,
250 AU1000_PCMCIA_IO_PHYS_ADDR,
251 AU1000_PCMCIA_IO_PHYS_ADDR + 0x000010000 - 1,
Manuel Laussf59c8112011-11-10 12:06:22 +0000252 c0, d0, /*s0*/0, 0, 0);
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200253
Manuel Lauss7cc2e272011-08-12 11:39:40 +0200254 db1x_register_pcmcia_socket(
255 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004000000,
256 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004400000 - 1,
257 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004000000,
258 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004400000 - 1,
259 AU1000_PCMCIA_IO_PHYS_ADDR + 0x004000000,
260 AU1000_PCMCIA_IO_PHYS_ADDR + 0x004010000 - 1,
Manuel Laussf59c8112011-11-10 12:06:22 +0000261 c1, d1, /*s1*/0, 0, 1);
Manuel Laussb2ce3052011-07-25 13:44:46 +0200262
Manuel Laussf59c8112011-11-10 12:06:22 +0000263 platform_add_devices(db1x00_devs, ARRAY_SIZE(db1x00_devs));
Manuel Lauss7c4b24d2011-11-10 12:06:21 +0000264 db1x_register_norflash(32 << 20, 4 /* 32bit */, F_SWAPPED);
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200265 return 0;
266}
Manuel Laussf59c8112011-11-10 12:06:22 +0000267device_initcall(db1000_dev_init);