blob: 677414d5f5b47b551a4913f96f88e80b33f7a1f7 [file] [log] [blame]
Manuel Lauss27dd65a2009-10-04 14:55:28 +02001/*
2 * DBAu1xxx board platform device registration
3 *
4 * Copyright (C) 2009 Manuel Lauss
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/init.h>
Manuel Laussb2ce3052011-07-25 13:44:46 +020022#include <linux/interrupt.h>
Manuel Lauss37663862011-08-12 11:39:45 +020023#include <linux/dma-mapping.h>
Manuel Lauss27dd65a2009-10-04 14:55:28 +020024#include <linux/platform_device.h>
25
Manuel Laussb2ce3052011-07-25 13:44:46 +020026#include <asm/mach-au1x00/au1000.h>
27#include <asm/mach-au1x00/au1000_dma.h>
Manuel Lauss206aa6c2009-10-19 12:53:37 +020028#include <asm/mach-db1x00/bcsr.h>
Manuel Lauss27dd65a2009-10-04 14:55:28 +020029#include "../platform.h"
30
Manuel Lauss7517de32011-08-12 11:39:44 +020031struct pci_dev;
32
Manuel Lauss27dd65a2009-10-04 14:55:28 +020033/* DB1xxx PCMCIA interrupt sources:
34 * CD0/1 GPIO0/3
35 * STSCHG0/1 GPIO1/4
36 * CARD0/1 GPIO2/5
37 * Db1550: 0/1, 21/22, 3/5
38 */
Manuel Lauss78814462009-10-07 20:15:15 +020039
Manuel Lauss206aa6c2009-10-19 12:53:37 +020040#define F_SWAPPED (bcsr_read(BCSR_STATUS) & BCSR_STATUS_DB1000_SWAPBOOT)
Manuel Lauss78814462009-10-07 20:15:15 +020041
42#if defined(CONFIG_MIPS_DB1000)
43#define DB1XXX_PCMCIA_CD0 AU1000_GPIO0_INT
44#define DB1XXX_PCMCIA_STSCHG0 AU1000_GPIO1_INT
45#define DB1XXX_PCMCIA_CARD0 AU1000_GPIO2_INT
46#define DB1XXX_PCMCIA_CD1 AU1000_GPIO3_INT
47#define DB1XXX_PCMCIA_STSCHG1 AU1000_GPIO4_INT
48#define DB1XXX_PCMCIA_CARD1 AU1000_GPIO5_INT
Manuel Lauss206aa6c2009-10-19 12:53:37 +020049#define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
Manuel Lauss78814462009-10-07 20:15:15 +020050#elif defined(CONFIG_MIPS_DB1100)
51#define DB1XXX_PCMCIA_CD0 AU1100_GPIO0_INT
52#define DB1XXX_PCMCIA_STSCHG0 AU1100_GPIO1_INT
53#define DB1XXX_PCMCIA_CARD0 AU1100_GPIO2_INT
54#define DB1XXX_PCMCIA_CD1 AU1100_GPIO3_INT
55#define DB1XXX_PCMCIA_STSCHG1 AU1100_GPIO4_INT
56#define DB1XXX_PCMCIA_CARD1 AU1100_GPIO5_INT
Manuel Lauss206aa6c2009-10-19 12:53:37 +020057#define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
Manuel Lauss78814462009-10-07 20:15:15 +020058#elif defined(CONFIG_MIPS_DB1500)
59#define DB1XXX_PCMCIA_CD0 AU1500_GPIO0_INT
60#define DB1XXX_PCMCIA_STSCHG0 AU1500_GPIO1_INT
61#define DB1XXX_PCMCIA_CARD0 AU1500_GPIO2_INT
62#define DB1XXX_PCMCIA_CD1 AU1500_GPIO3_INT
63#define DB1XXX_PCMCIA_STSCHG1 AU1500_GPIO4_INT
64#define DB1XXX_PCMCIA_CARD1 AU1500_GPIO5_INT
Manuel Lauss206aa6c2009-10-19 12:53:37 +020065#define BOARD_FLASH_SIZE 0x02000000 /* 32MB */
Manuel Lauss78814462009-10-07 20:15:15 +020066#elif defined(CONFIG_MIPS_DB1550)
67#define DB1XXX_PCMCIA_CD0 AU1550_GPIO0_INT
68#define DB1XXX_PCMCIA_STSCHG0 AU1550_GPIO21_INT
69#define DB1XXX_PCMCIA_CARD0 AU1550_GPIO3_INT
70#define DB1XXX_PCMCIA_CD1 AU1550_GPIO1_INT
71#define DB1XXX_PCMCIA_STSCHG1 AU1550_GPIO22_INT
72#define DB1XXX_PCMCIA_CARD1 AU1550_GPIO5_INT
Manuel Lauss206aa6c2009-10-19 12:53:37 +020073#define BOARD_FLASH_SIZE 0x08000000 /* 128MB */
Manuel Lauss27dd65a2009-10-04 14:55:28 +020074#endif
75
Manuel Lauss7517de32011-08-12 11:39:44 +020076#ifdef CONFIG_PCI
77#ifdef CONFIG_MIPS_DB1500
78static int db1xxx_map_pci_irq(const struct pci_dev *d, u8 slot, u8 pin)
79{
80 if ((slot < 12) || (slot > 13) || pin == 0)
81 return -1;
82 if (slot == 12)
83 return (pin == 1) ? AU1500_PCI_INTA : 0xff;
84 if (slot == 13) {
85 switch (pin) {
86 case 1: return AU1500_PCI_INTA;
87 case 2: return AU1500_PCI_INTB;
88 case 3: return AU1500_PCI_INTC;
89 case 4: return AU1500_PCI_INTD;
90 }
91 }
92 return -1;
93}
94#endif
95
96#ifdef CONFIG_MIPS_DB1550
97static int db1xxx_map_pci_irq(const struct pci_dev *d, u8 slot, u8 pin)
98{
99 if ((slot < 11) || (slot > 13) || pin == 0)
100 return -1;
101 if (slot == 11)
102 return (pin == 1) ? AU1550_PCI_INTC : 0xff;
103 if (slot == 12) {
104 switch (pin) {
105 case 1: return AU1550_PCI_INTB;
106 case 2: return AU1550_PCI_INTC;
107 case 3: return AU1550_PCI_INTD;
108 case 4: return AU1550_PCI_INTA;
109 }
110 }
111 if (slot == 13) {
112 switch (pin) {
113 case 1: return AU1550_PCI_INTA;
114 case 2: return AU1550_PCI_INTB;
115 case 3: return AU1550_PCI_INTC;
116 case 4: return AU1550_PCI_INTD;
117 }
118 }
119 return -1;
120}
121#endif
122
Manuel Lauss7517de32011-08-12 11:39:44 +0200123static struct resource alchemy_pci_host_res[] = {
124 [0] = {
125 .start = AU1500_PCI_PHYS_ADDR,
126 .end = AU1500_PCI_PHYS_ADDR + 0xfff,
127 .flags = IORESOURCE_MEM,
128 },
129};
130
131static struct alchemy_pci_platdata db1xxx_pci_pd = {
132 .board_map_irq = db1xxx_map_pci_irq,
133};
134
135static struct platform_device db1xxx_pci_host_dev = {
136 .dev.platform_data = &db1xxx_pci_pd,
137 .name = "alchemy-pci",
138 .id = 0,
139 .num_resources = ARRAY_SIZE(alchemy_pci_host_res),
140 .resource = alchemy_pci_host_res,
141};
142
143static int __init db15x0_pci_init(void)
144{
145 return platform_device_register(&db1xxx_pci_host_dev);
146}
147/* must be arch_initcall; MIPS PCI scans busses in a subsys_initcall */
148arch_initcall(db15x0_pci_init);
149#endif
150
Manuel Lauss37663862011-08-12 11:39:45 +0200151#ifdef CONFIG_MIPS_DB1100
152static struct resource au1100_lcd_resources[] = {
153 [0] = {
154 .start = AU1100_LCD_PHYS_ADDR,
155 .end = AU1100_LCD_PHYS_ADDR + 0x800 - 1,
156 .flags = IORESOURCE_MEM,
157 },
158 [1] = {
159 .start = AU1100_LCD_INT,
160 .end = AU1100_LCD_INT,
161 .flags = IORESOURCE_IRQ,
162 }
163};
164
165static u64 au1100_lcd_dmamask = DMA_BIT_MASK(32);
166
167static struct platform_device au1100_lcd_device = {
168 .name = "au1100-lcd",
169 .id = 0,
170 .dev = {
171 .dma_mask = &au1100_lcd_dmamask,
172 .coherent_dma_mask = DMA_BIT_MASK(32),
173 },
174 .num_resources = ARRAY_SIZE(au1100_lcd_resources),
175 .resource = au1100_lcd_resources,
176};
177#endif
178
Manuel Laussb2ce3052011-07-25 13:44:46 +0200179static struct resource alchemy_ac97c_res[] = {
180 [0] = {
181 .start = AU1000_AC97_PHYS_ADDR,
182 .end = AU1000_AC97_PHYS_ADDR + 0xfff,
183 .flags = IORESOURCE_MEM,
184 },
185 [1] = {
186 .start = DMA_ID_AC97C_TX,
187 .end = DMA_ID_AC97C_TX,
188 .flags = IORESOURCE_DMA,
189 },
190 [2] = {
191 .start = DMA_ID_AC97C_RX,
192 .end = DMA_ID_AC97C_RX,
193 .flags = IORESOURCE_DMA,
194 },
195};
196
197static struct platform_device alchemy_ac97c_dev = {
198 .name = "alchemy-ac97c",
199 .id = -1,
200 .resource = alchemy_ac97c_res,
201 .num_resources = ARRAY_SIZE(alchemy_ac97c_res),
202};
203
204static struct platform_device alchemy_ac97c_dma_dev = {
205 .name = "alchemy-pcm-dma",
206 .id = 0,
207};
208
209static struct platform_device db1x00_codec_dev = {
210 .name = "ac97-codec",
211 .id = -1,
212};
213
214static struct platform_device db1x00_audio_dev = {
215 .name = "db1000-audio",
216};
217
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200218static int __init db1xxx_dev_init(void)
219{
Manuel Lauss7cc2e272011-08-12 11:39:40 +0200220 db1x_register_pcmcia_socket(
221 AU1000_PCMCIA_ATTR_PHYS_ADDR,
222 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
223 AU1000_PCMCIA_MEM_PHYS_ADDR,
224 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1,
225 AU1000_PCMCIA_IO_PHYS_ADDR,
226 AU1000_PCMCIA_IO_PHYS_ADDR + 0x000010000 - 1,
227 DB1XXX_PCMCIA_CARD0, DB1XXX_PCMCIA_CD0,
228 /*DB1XXX_PCMCIA_STSCHG0*/0, 0, 0);
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200229
Manuel Lauss7cc2e272011-08-12 11:39:40 +0200230 db1x_register_pcmcia_socket(
231 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004000000,
232 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004400000 - 1,
233 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004000000,
234 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004400000 - 1,
235 AU1000_PCMCIA_IO_PHYS_ADDR + 0x004000000,
236 AU1000_PCMCIA_IO_PHYS_ADDR + 0x004010000 - 1,
237 DB1XXX_PCMCIA_CARD1, DB1XXX_PCMCIA_CD1,
238 /*DB1XXX_PCMCIA_STSCHG1*/0, 0, 1);
Manuel Lauss37663862011-08-12 11:39:45 +0200239#ifdef CONFIG_MIPS_DB1100
240 platform_device_register(&au1100_lcd_device);
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200241#endif
Manuel Laussb2ce3052011-07-25 13:44:46 +0200242 platform_device_register(&db1x00_codec_dev);
243 platform_device_register(&alchemy_ac97c_dma_dev);
244 platform_device_register(&alchemy_ac97c_dev);
245 platform_device_register(&db1x00_audio_dev);
246
Manuel Lauss435037c2011-11-01 20:03:28 +0100247 db1x_register_norflash(BOARD_FLASH_SIZE, 4 /* 32bit */, F_SWAPPED);
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200248 return 0;
249}
250device_initcall(db1xxx_dev_init);