Commit | Line | Data |
---|---|---|
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 ML |
28 | #include <asm/mach-au1x00/au1100_mmc.h> |
29 | ||
30 | static int mmc_activity; | |
31 | ||
32 | static void pb1200mmc0_set_power(void *mmc_host, int state) | |
33 | { | |
34 | if (state) | |
35 | bcsr->board |= BCSR_BOARD_SD0PWR; | |
36 | else | |
37 | bcsr->board &= ~BCSR_BOARD_SD0PWR; | |
38 | ||
39 | au_sync_delay(1); | |
40 | } | |
41 | ||
42 | static int pb1200mmc0_card_readonly(void *mmc_host) | |
43 | { | |
44 | return (bcsr->status & BCSR_STATUS_SD0WP) ? 1 : 0; | |
45 | } | |
46 | ||
47 | static int pb1200mmc0_card_inserted(void *mmc_host) | |
48 | { | |
49 | return (bcsr->sig_status & BCSR_INT_SD0INSERT) ? 1 : 0; | |
50 | } | |
51 | ||
52 | static void pb1200_mmcled_set(struct led_classdev *led, | |
53 | enum led_brightness brightness) | |
54 | { | |
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); | |
61 | } | |
62 | } | |
63 | ||
64 | static struct led_classdev pb1200mmc_led = { | |
65 | .brightness_set = pb1200_mmcled_set, | |
66 | }; | |
67 | ||
68 | #ifndef CONFIG_MIPS_DB1200 | |
69 | static void pb1200mmc1_set_power(void *mmc_host, int state) | |
70 | { | |
71 | if (state) | |
72 | bcsr->board |= BCSR_BOARD_SD1PWR; | |
73 | else | |
74 | bcsr->board &= ~BCSR_BOARD_SD1PWR; | |
75 | ||
76 | au_sync_delay(1); | |
77 | } | |
78 | ||
79 | static int pb1200mmc1_card_readonly(void *mmc_host) | |
80 | { | |
81 | return (bcsr->status & BCSR_STATUS_SD1WP) ? 1 : 0; | |
82 | } | |
83 | ||
84 | static int pb1200mmc1_card_inserted(void *mmc_host) | |
85 | { | |
86 | return (bcsr->sig_status & BCSR_INT_SD1INSERT) ? 1 : 0; | |
87 | } | |
88 | #endif | |
89 | ||
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, | |
97 | }, | |
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, | |
105 | }, | |
106 | #endif | |
107 | }; | |
fcbd3b4b SS |
108 | |
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 | |
114 | }, | |
115 | [1] = { | |
116 | .start = IDE_INT, | |
117 | .end = IDE_INT, | |
118 | .flags = IORESOURCE_IRQ | |
119 | } | |
120 | }; | |
121 | ||
284901a9 | 122 | static u64 ide_dmamask = DMA_BIT_MASK(32); |
fcbd3b4b SS |
123 | |
124 | static struct platform_device ide_device = { | |
125 | .name = "au1200-ide", | |
126 | .id = 0, | |
127 | .dev = { | |
128 | .dma_mask = &ide_dmamask, | |
284901a9 | 129 | .coherent_dma_mask = DMA_BIT_MASK(32), |
fcbd3b4b SS |
130 | }, |
131 | .num_resources = ARRAY_SIZE(ide_resources), | |
132 | .resource = ide_resources | |
133 | }; | |
134 | ||
91e8a30e ML |
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, | |
139 | }; | |
140 | ||
fcbd3b4b SS |
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 | |
147 | }, | |
148 | [1] = { | |
149 | .start = SMC91C111_INT, | |
150 | .end = SMC91C111_INT, | |
151 | .flags = IORESOURCE_IRQ | |
152 | }, | |
153 | }; | |
154 | ||
155 | static struct platform_device smc91c111_device = { | |
91e8a30e ML |
156 | .dev = { |
157 | .platform_data = &smc_data, | |
158 | }, | |
fcbd3b4b SS |
159 | .name = "smc91x", |
160 | .id = -1, | |
161 | .num_resources = ARRAY_SIZE(smc91c111_resources), | |
162 | .resource = smc91c111_resources | |
163 | }; | |
164 | ||
165 | static struct platform_device *board_platform_devices[] __initdata = { | |
166 | &ide_device, | |
167 | &smc91c111_device | |
168 | }; | |
169 | ||
170 | static int __init board_register_devices(void) | |
171 | { | |
172 | return platform_add_devices(board_platform_devices, | |
173 | ARRAY_SIZE(board_platform_devices)); | |
174 | } | |
175 | ||
176 | arch_initcall(board_register_devices); |