]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/mips/alchemy/devboards/pb1200/platform.c
MIPS: Alchemy: Extended DB1200 board support.
[net-next-2.6.git] / arch / mips / alchemy / devboards / pb1200 / platform.c
CommitLineData
fcbd3b4b
SS
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
4b62220b 21#include <linux/dma-mapping.h>
fcbd3b4b 22#include <linux/init.h>
f591eb1e 23#include <linux/leds.h>
fcbd3b4b 24#include <linux/platform_device.h>
91e8a30e 25#include <linux/smc91x.h>
fcbd3b4b
SS
26
27#include <asm/mach-au1x00/au1xxx.h>
f591eb1e 28#include <asm/mach-au1x00/au1100_mmc.h>
9bdcf336 29#include <asm/mach-db1x00/bcsr.h>
f591eb1e 30
27dd65ac
ML
31#include "../platform.h"
32
f591eb1e
ML
33static int mmc_activity;
34
35static void pb1200mmc0_set_power(void *mmc_host, int state)
36{
37 if (state)
9bdcf336 38 bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_SD0PWR);
f591eb1e 39 else
9bdcf336 40 bcsr_mod(BCSR_BOARD, BCSR_BOARD_SD0PWR, 0);
f591eb1e 41
9bdcf336 42 msleep(1);
f591eb1e
ML
43}
44
45static int pb1200mmc0_card_readonly(void *mmc_host)
46{
9bdcf336 47 return (bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD0WP) ? 1 : 0;
f591eb1e
ML
48}
49
50static int pb1200mmc0_card_inserted(void *mmc_host)
51{
9bdcf336 52 return (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD0INSERT) ? 1 : 0;
f591eb1e
ML
53}
54
55static void pb1200_mmcled_set(struct led_classdev *led,
56 enum led_brightness brightness)
57{
58 if (brightness != LED_OFF) {
59 if (++mmc_activity == 1)
9bdcf336 60 bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED0, 0);
f591eb1e
ML
61 } else {
62 if (--mmc_activity == 0)
9bdcf336 63 bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED0);
f591eb1e
ML
64 }
65}
66
67static struct led_classdev pb1200mmc_led = {
68 .brightness_set = pb1200_mmcled_set,
69};
70
f591eb1e
ML
71static void pb1200mmc1_set_power(void *mmc_host, int state)
72{
73 if (state)
9bdcf336 74 bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_SD1PWR);
f591eb1e 75 else
9bdcf336 76 bcsr_mod(BCSR_BOARD, BCSR_BOARD_SD1PWR, 0);
f591eb1e 77
9bdcf336 78 msleep(1);
f591eb1e
ML
79}
80
81static int pb1200mmc1_card_readonly(void *mmc_host)
82{
9bdcf336 83 return (bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD1WP) ? 1 : 0;
f591eb1e
ML
84}
85
86static int pb1200mmc1_card_inserted(void *mmc_host)
87{
9bdcf336 88 return (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD1INSERT) ? 1 : 0;
f591eb1e 89}
f591eb1e
ML
90
91const struct au1xmmc_platform_data au1xmmc_platdata[2] = {
92 [0] = {
93 .set_power = pb1200mmc0_set_power,
94 .card_inserted = pb1200mmc0_card_inserted,
95 .card_readonly = pb1200mmc0_card_readonly,
96 .cd_setup = NULL, /* use poll-timer in driver */
97 .led = &pb1200mmc_led,
98 },
f591eb1e
ML
99 [1] = {
100 .set_power = pb1200mmc1_set_power,
101 .card_inserted = pb1200mmc1_card_inserted,
102 .card_readonly = pb1200mmc1_card_readonly,
103 .cd_setup = NULL, /* use poll-timer in driver */
104 .led = &pb1200mmc_led,
105 },
f591eb1e 106};
fcbd3b4b
SS
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
284901a9 121static u64 ide_dmamask = DMA_BIT_MASK(32);
fcbd3b4b
SS
122
123static struct platform_device ide_device = {
124 .name = "au1200-ide",
125 .id = 0,
126 .dev = {
127 .dma_mask = &ide_dmamask,
284901a9 128 .coherent_dma_mask = DMA_BIT_MASK(32),
fcbd3b4b
SS
129 },
130 .num_resources = ARRAY_SIZE(ide_resources),
131 .resource = ide_resources
132};
133
91e8a30e
ML
134static struct smc91x_platdata smc_data = {
135 .flags = SMC91X_NOWAIT | SMC91X_USE_16BIT,
136 .leda = RPC_LED_100_10,
137 .ledb = RPC_LED_TX_RX,
138};
139
fcbd3b4b
SS
140static struct resource smc91c111_resources[] = {
141 [0] = {
142 .name = "smc91x-regs",
143 .start = SMC91C111_PHYS_ADDR,
144 .end = SMC91C111_PHYS_ADDR + 0xf,
145 .flags = IORESOURCE_MEM
146 },
147 [1] = {
148 .start = SMC91C111_INT,
149 .end = SMC91C111_INT,
150 .flags = IORESOURCE_IRQ
151 },
152};
153
154static struct platform_device smc91c111_device = {
91e8a30e
ML
155 .dev = {
156 .platform_data = &smc_data,
157 },
fcbd3b4b
SS
158 .name = "smc91x",
159 .id = -1,
160 .num_resources = ARRAY_SIZE(smc91c111_resources),
161 .resource = smc91c111_resources
162};
163
164static struct platform_device *board_platform_devices[] __initdata = {
165 &ide_device,
166 &smc91c111_device
167};
168
169static int __init board_register_devices(void)
170{
206aa6cd
ML
171 int swapped;
172
27dd65ac
ML
173 db1x_register_pcmcia_socket(PCMCIA_ATTR_PSEUDO_PHYS,
174 PCMCIA_ATTR_PSEUDO_PHYS + 0x00040000 - 1,
175 PCMCIA_MEM_PSEUDO_PHYS,
176 PCMCIA_MEM_PSEUDO_PHYS + 0x00040000 - 1,
177 PCMCIA_IO_PSEUDO_PHYS,
178 PCMCIA_IO_PSEUDO_PHYS + 0x00001000 - 1,
179 PB1200_PC0_INT,
180 PB1200_PC0_INSERT_INT,
181 /*PB1200_PC0_STSCHG_INT*/0,
182 PB1200_PC0_EJECT_INT,
183 0);
184
185 db1x_register_pcmcia_socket(PCMCIA_ATTR_PSEUDO_PHYS + 0x00800000,
186 PCMCIA_ATTR_PSEUDO_PHYS + 0x00840000 - 1,
187 PCMCIA_MEM_PSEUDO_PHYS + 0x00800000,
188 PCMCIA_MEM_PSEUDO_PHYS + 0x00840000 - 1,
189 PCMCIA_IO_PSEUDO_PHYS + 0x00800000,
190 PCMCIA_IO_PSEUDO_PHYS + 0x00801000 - 1,
191 PB1200_PC1_INT,
192 PB1200_PC1_INSERT_INT,
193 /*PB1200_PC1_STSCHG_INT*/0,
194 PB1200_PC1_EJECT_INT,
195 1);
27dd65ac 196
206aa6cd 197 swapped = bcsr_read(BCSR_STATUS) & BCSR_STATUS_DB1200_SWAPBOOT;
206aa6cd 198 db1x_register_norflash(128 * 1024 * 1024, 2, swapped);
206aa6cd 199
fcbd3b4b
SS
200 return platform_add_devices(board_platform_devices,
201 ARRAY_SIZE(board_platform_devices));
202}
27dd65ac 203device_initcall(board_register_devices);