Full support for Ginger Console
[linux-ginger.git] / arch / mips / alchemy / devboards / pb1200 / platform.c
blobb93dff4a6789ca4e5c054a42302e640b619e9f69
1 /*
2 * Pb1200/DBAu1200 board platform device registration
4 * Copyright (C) 2008 MontaVista Software Inc. <source@mvista.com>
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.
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.
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
21 #include <linux/dma-mapping.h>
22 #include <linux/init.h>
23 #include <linux/leds.h>
24 #include <linux/platform_device.h>
25 #include <linux/smc91x.h>
27 #include <asm/mach-au1x00/au1xxx.h>
28 #include <asm/mach-au1x00/au1100_mmc.h>
30 static int mmc_activity;
32 static void pb1200mmc0_set_power(void *mmc_host, int state)
34 if (state)
35 bcsr->board |= BCSR_BOARD_SD0PWR;
36 else
37 bcsr->board &= ~BCSR_BOARD_SD0PWR;
39 au_sync_delay(1);
42 static int pb1200mmc0_card_readonly(void *mmc_host)
44 return (bcsr->status & BCSR_STATUS_SD0WP) ? 1 : 0;
47 static int pb1200mmc0_card_inserted(void *mmc_host)
49 return (bcsr->sig_status & BCSR_INT_SD0INSERT) ? 1 : 0;
52 static void pb1200_mmcled_set(struct led_classdev *led,
53 enum led_brightness brightness)
55 if (brightness != LED_OFF) {
56 if (++mmc_activity == 1)
57 bcsr->disk_leds &= ~(1 << 8);
58 } else {
59 if (--mmc_activity == 0)
60 bcsr->disk_leds |= (1 << 8);
64 static struct led_classdev pb1200mmc_led = {
65 .brightness_set = pb1200_mmcled_set,
68 #ifndef CONFIG_MIPS_DB1200
69 static void pb1200mmc1_set_power(void *mmc_host, int state)
71 if (state)
72 bcsr->board |= BCSR_BOARD_SD1PWR;
73 else
74 bcsr->board &= ~BCSR_BOARD_SD1PWR;
76 au_sync_delay(1);
79 static int pb1200mmc1_card_readonly(void *mmc_host)
81 return (bcsr->status & BCSR_STATUS_SD1WP) ? 1 : 0;
84 static int pb1200mmc1_card_inserted(void *mmc_host)
86 return (bcsr->sig_status & BCSR_INT_SD1INSERT) ? 1 : 0;
88 #endif
90 const struct au1xmmc_platform_data au1xmmc_platdata[2] = {
91 [0] = {
92 .set_power = pb1200mmc0_set_power,
93 .card_inserted = pb1200mmc0_card_inserted,
94 .card_readonly = pb1200mmc0_card_readonly,
95 .cd_setup = NULL, /* use poll-timer in driver */
96 .led = &pb1200mmc_led,
98 #ifndef CONFIG_MIPS_DB1200
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,
106 #endif
109 static struct resource ide_resources[] = {
110 [0] = {
111 .start = IDE_PHYS_ADDR,
112 .end = IDE_PHYS_ADDR + IDE_PHYS_LEN - 1,
113 .flags = IORESOURCE_MEM
115 [1] = {
116 .start = IDE_INT,
117 .end = IDE_INT,
118 .flags = IORESOURCE_IRQ
122 static u64 ide_dmamask = DMA_BIT_MASK(32);
124 static struct platform_device ide_device = {
125 .name = "au1200-ide",
126 .id = 0,
127 .dev = {
128 .dma_mask = &ide_dmamask,
129 .coherent_dma_mask = DMA_BIT_MASK(32),
131 .num_resources = ARRAY_SIZE(ide_resources),
132 .resource = ide_resources
135 static struct smc91x_platdata smc_data = {
136 .flags = SMC91X_NOWAIT | SMC91X_USE_16BIT,
137 .leda = RPC_LED_100_10,
138 .ledb = RPC_LED_TX_RX,
141 static struct resource smc91c111_resources[] = {
142 [0] = {
143 .name = "smc91x-regs",
144 .start = SMC91C111_PHYS_ADDR,
145 .end = SMC91C111_PHYS_ADDR + 0xf,
146 .flags = IORESOURCE_MEM
148 [1] = {
149 .start = SMC91C111_INT,
150 .end = SMC91C111_INT,
151 .flags = IORESOURCE_IRQ
155 static struct platform_device smc91c111_device = {
156 .dev = {
157 .platform_data = &smc_data,
159 .name = "smc91x",
160 .id = -1,
161 .num_resources = ARRAY_SIZE(smc91c111_resources),
162 .resource = smc91c111_resources
165 static struct platform_device *board_platform_devices[] __initdata = {
166 &ide_device,
167 &smc91c111_device
170 static int __init board_register_devices(void)
172 return platform_add_devices(board_platform_devices,
173 ARRAY_SIZE(board_platform_devices));
176 arch_initcall(board_register_devices);