blob: 67b36e8a4c98a78a555215d2fe4cb4c318f78b45 [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 Lauss3766386032011-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
Manuel Lauss27dd65a2009-10-04 14:55:28 +020037 */
Manuel Lauss78814462009-10-07 20:15:15 +020038
Manuel Lauss206aa6c2009-10-19 12:53:37 +020039#define F_SWAPPED (bcsr_read(BCSR_STATUS) & BCSR_STATUS_DB1000_SWAPBOOT)
Manuel Lauss78814462009-10-07 20:15:15 +020040
41#if defined(CONFIG_MIPS_DB1000)
42#define DB1XXX_PCMCIA_CD0 AU1000_GPIO0_INT
43#define DB1XXX_PCMCIA_STSCHG0 AU1000_GPIO1_INT
44#define DB1XXX_PCMCIA_CARD0 AU1000_GPIO2_INT
45#define DB1XXX_PCMCIA_CD1 AU1000_GPIO3_INT
46#define DB1XXX_PCMCIA_STSCHG1 AU1000_GPIO4_INT
47#define DB1XXX_PCMCIA_CARD1 AU1000_GPIO5_INT
48#elif defined(CONFIG_MIPS_DB1100)
49#define DB1XXX_PCMCIA_CD0 AU1100_GPIO0_INT
50#define DB1XXX_PCMCIA_STSCHG0 AU1100_GPIO1_INT
51#define DB1XXX_PCMCIA_CARD0 AU1100_GPIO2_INT
52#define DB1XXX_PCMCIA_CD1 AU1100_GPIO3_INT
53#define DB1XXX_PCMCIA_STSCHG1 AU1100_GPIO4_INT
54#define DB1XXX_PCMCIA_CARD1 AU1100_GPIO5_INT
55#elif defined(CONFIG_MIPS_DB1500)
56#define DB1XXX_PCMCIA_CD0 AU1500_GPIO0_INT
57#define DB1XXX_PCMCIA_STSCHG0 AU1500_GPIO1_INT
58#define DB1XXX_PCMCIA_CARD0 AU1500_GPIO2_INT
59#define DB1XXX_PCMCIA_CD1 AU1500_GPIO3_INT
60#define DB1XXX_PCMCIA_STSCHG1 AU1500_GPIO4_INT
61#define DB1XXX_PCMCIA_CARD1 AU1500_GPIO5_INT
Manuel Lauss27dd65a2009-10-04 14:55:28 +020062
Manuel Laussf869d422011-11-10 12:06:16 +000063static int db1500_map_pci_irq(const struct pci_dev *d, u8 slot, u8 pin)
Manuel Lauss7517de32011-08-12 11:39:44 +020064{
65 if ((slot < 12) || (slot > 13) || pin == 0)
66 return -1;
67 if (slot == 12)
68 return (pin == 1) ? AU1500_PCI_INTA : 0xff;
69 if (slot == 13) {
70 switch (pin) {
71 case 1: return AU1500_PCI_INTA;
72 case 2: return AU1500_PCI_INTB;
73 case 3: return AU1500_PCI_INTC;
74 case 4: return AU1500_PCI_INTD;
75 }
76 }
77 return -1;
78}
Manuel Lauss7517de32011-08-12 11:39:44 +020079
Manuel Lauss7517de32011-08-12 11:39:44 +020080static struct resource alchemy_pci_host_res[] = {
81 [0] = {
82 .start = AU1500_PCI_PHYS_ADDR,
83 .end = AU1500_PCI_PHYS_ADDR + 0xfff,
84 .flags = IORESOURCE_MEM,
85 },
86};
87
Manuel Laussf869d422011-11-10 12:06:16 +000088static struct alchemy_pci_platdata db1500_pci_pd = {
89 .board_map_irq = db1500_map_pci_irq,
Manuel Lauss7517de32011-08-12 11:39:44 +020090};
91
Manuel Laussf869d422011-11-10 12:06:16 +000092static struct platform_device db1500_pci_host_dev = {
93 .dev.platform_data = &db1500_pci_pd,
Manuel Lauss7517de32011-08-12 11:39:44 +020094 .name = "alchemy-pci",
95 .id = 0,
96 .num_resources = ARRAY_SIZE(alchemy_pci_host_res),
97 .resource = alchemy_pci_host_res,
98};
99
Manuel Laussf869d422011-11-10 12:06:16 +0000100static int __init db1500_pci_init(void)
Manuel Lauss7517de32011-08-12 11:39:44 +0200101{
Manuel Laussf869d422011-11-10 12:06:16 +0000102 return platform_device_register(&db1500_pci_host_dev);
Manuel Lauss7517de32011-08-12 11:39:44 +0200103}
104/* must be arch_initcall; MIPS PCI scans busses in a subsys_initcall */
Manuel Laussf869d422011-11-10 12:06:16 +0000105arch_initcall(db1500_pci_init);
Manuel Lauss7517de32011-08-12 11:39:44 +0200106#endif
107
Manuel Lauss3766386032011-08-12 11:39:45 +0200108#ifdef CONFIG_MIPS_DB1100
109static struct resource au1100_lcd_resources[] = {
110 [0] = {
111 .start = AU1100_LCD_PHYS_ADDR,
112 .end = AU1100_LCD_PHYS_ADDR + 0x800 - 1,
113 .flags = IORESOURCE_MEM,
114 },
115 [1] = {
116 .start = AU1100_LCD_INT,
117 .end = AU1100_LCD_INT,
118 .flags = IORESOURCE_IRQ,
119 }
120};
121
122static u64 au1100_lcd_dmamask = DMA_BIT_MASK(32);
123
124static struct platform_device au1100_lcd_device = {
125 .name = "au1100-lcd",
126 .id = 0,
127 .dev = {
128 .dma_mask = &au1100_lcd_dmamask,
129 .coherent_dma_mask = DMA_BIT_MASK(32),
130 },
131 .num_resources = ARRAY_SIZE(au1100_lcd_resources),
132 .resource = au1100_lcd_resources,
133};
134#endif
135
Manuel Laussb2ce3052011-07-25 13:44:46 +0200136static struct resource alchemy_ac97c_res[] = {
137 [0] = {
138 .start = AU1000_AC97_PHYS_ADDR,
139 .end = AU1000_AC97_PHYS_ADDR + 0xfff,
140 .flags = IORESOURCE_MEM,
141 },
142 [1] = {
143 .start = DMA_ID_AC97C_TX,
144 .end = DMA_ID_AC97C_TX,
145 .flags = IORESOURCE_DMA,
146 },
147 [2] = {
148 .start = DMA_ID_AC97C_RX,
149 .end = DMA_ID_AC97C_RX,
150 .flags = IORESOURCE_DMA,
151 },
152};
153
154static struct platform_device alchemy_ac97c_dev = {
155 .name = "alchemy-ac97c",
156 .id = -1,
157 .resource = alchemy_ac97c_res,
158 .num_resources = ARRAY_SIZE(alchemy_ac97c_res),
159};
160
161static struct platform_device alchemy_ac97c_dma_dev = {
162 .name = "alchemy-pcm-dma",
163 .id = 0,
164};
165
166static struct platform_device db1x00_codec_dev = {
167 .name = "ac97-codec",
168 .id = -1,
169};
170
171static struct platform_device db1x00_audio_dev = {
172 .name = "db1000-audio",
173};
174
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200175static int __init db1xxx_dev_init(void)
176{
Manuel Lauss7cc2e272011-08-12 11:39:40 +0200177 db1x_register_pcmcia_socket(
178 AU1000_PCMCIA_ATTR_PHYS_ADDR,
179 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
180 AU1000_PCMCIA_MEM_PHYS_ADDR,
181 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1,
182 AU1000_PCMCIA_IO_PHYS_ADDR,
183 AU1000_PCMCIA_IO_PHYS_ADDR + 0x000010000 - 1,
184 DB1XXX_PCMCIA_CARD0, DB1XXX_PCMCIA_CD0,
185 /*DB1XXX_PCMCIA_STSCHG0*/0, 0, 0);
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200186
Manuel Lauss7cc2e272011-08-12 11:39:40 +0200187 db1x_register_pcmcia_socket(
188 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004000000,
189 AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x004400000 - 1,
190 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004000000,
191 AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004400000 - 1,
192 AU1000_PCMCIA_IO_PHYS_ADDR + 0x004000000,
193 AU1000_PCMCIA_IO_PHYS_ADDR + 0x004010000 - 1,
194 DB1XXX_PCMCIA_CARD1, DB1XXX_PCMCIA_CD1,
195 /*DB1XXX_PCMCIA_STSCHG1*/0, 0, 1);
Manuel Lauss3766386032011-08-12 11:39:45 +0200196#ifdef CONFIG_MIPS_DB1100
197 platform_device_register(&au1100_lcd_device);
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200198#endif
Manuel Laussb2ce3052011-07-25 13:44:46 +0200199 platform_device_register(&db1x00_codec_dev);
200 platform_device_register(&alchemy_ac97c_dma_dev);
201 platform_device_register(&alchemy_ac97c_dev);
202 platform_device_register(&db1x00_audio_dev);
203
Manuel Laussf869d422011-11-10 12:06:16 +0000204 db1x_register_norflash(0x02000000, 4 /* 32bit */, F_SWAPPED);
Manuel Lauss27dd65a2009-10-04 14:55:28 +0200205 return 0;
206}
207device_initcall(db1xxx_dev_init);