diff options
| author | Manuel Lauss <manuel.lauss@googlemail.com> | 2011-11-10 07:06:22 -0500 |
|---|---|---|
| committer | Ralf Baechle <ralf@linux-mips.org> | 2011-12-07 17:02:07 -0500 |
| commit | c9af5144ce5e6270a8bffad348cf2f20648f5f67 (patch) | |
| tree | 450082958bdd2aecb968f8cfd76fc1d0d21dd637 /arch/mips/alchemy/devboards | |
| parent | f59c811f8c44e60a59783e3337594da638a48dff (diff) | |
MIPS: Alchemy: MMC for DB1100
This patch hooks up the 2 MMC sockets on the DB1100 board.
Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com>
To: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/2873/
Patchwork: https://patchwork.linux-mips.org/patch/2920/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/alchemy/devboards')
| -rw-r--r-- | arch/mips/alchemy/devboards/db1000.c | 202 |
1 files changed, 202 insertions, 0 deletions
diff --git a/arch/mips/alchemy/devboards/db1000.c b/arch/mips/alchemy/devboards/db1000.c index 57ed5f1c491..a3a44803303 100644 --- a/arch/mips/alchemy/devboards/db1000.c +++ b/arch/mips/alchemy/devboards/db1000.c | |||
| @@ -23,10 +23,14 @@ | |||
| 23 | #include <linux/gpio.h> | 23 | #include <linux/gpio.h> |
| 24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
| 25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
| 26 | #include <linux/leds.h> | ||
| 27 | #include <linux/mmc/host.h> | ||
| 28 | #include <linux/module.h> | ||
| 26 | #include <linux/platform_device.h> | 29 | #include <linux/platform_device.h> |
| 27 | #include <linux/pm.h> | 30 | #include <linux/pm.h> |
| 28 | #include <asm/mach-au1x00/au1000.h> | 31 | #include <asm/mach-au1x00/au1000.h> |
| 29 | #include <asm/mach-au1x00/au1000_dma.h> | 32 | #include <asm/mach-au1x00/au1000_dma.h> |
| 33 | #include <asm/mach-au1x00/au1100_mmc.h> | ||
| 30 | #include <asm/mach-db1x00/bcsr.h> | 34 | #include <asm/mach-db1x00/bcsr.h> |
| 31 | #include <asm/reboot.h> | 35 | #include <asm/reboot.h> |
| 32 | #include <prom.h> | 36 | #include <prom.h> |
| @@ -194,6 +198,198 @@ static struct platform_device db1x00_audio_dev = { | |||
| 194 | .name = "db1000-audio", | 198 | .name = "db1000-audio", |
| 195 | }; | 199 | }; |
| 196 | 200 | ||
| 201 | /******************************************************************************/ | ||
| 202 | |||
| 203 | static irqreturn_t db1100_mmc_cd(int irq, void *ptr) | ||
| 204 | { | ||
| 205 | void (*mmc_cd)(struct mmc_host *, unsigned long); | ||
| 206 | /* link against CONFIG_MMC=m */ | ||
| 207 | mmc_cd = symbol_get(mmc_detect_change); | ||
| 208 | mmc_cd(ptr, msecs_to_jiffies(500)); | ||
| 209 | symbol_put(mmc_detect_change); | ||
| 210 | |||
| 211 | return IRQ_HANDLED; | ||
| 212 | } | ||
| 213 | |||
| 214 | static int db1100_mmc_cd_setup(void *mmc_host, int en) | ||
| 215 | { | ||
| 216 | int ret = 0; | ||
| 217 | |||
| 218 | if (en) { | ||
| 219 | irq_set_irq_type(AU1100_GPIO19_INT, IRQ_TYPE_EDGE_BOTH); | ||
| 220 | ret = request_irq(AU1100_GPIO19_INT, db1100_mmc_cd, 0, | ||
| 221 | "sd0_cd", mmc_host); | ||
| 222 | } else | ||
| 223 | free_irq(AU1100_GPIO19_INT, mmc_host); | ||
| 224 | return ret; | ||
| 225 | } | ||
| 226 | |||
| 227 | static int db1100_mmc1_cd_setup(void *mmc_host, int en) | ||
| 228 | { | ||
| 229 | int ret = 0; | ||
| 230 | |||
| 231 | if (en) { | ||
| 232 | irq_set_irq_type(AU1100_GPIO20_INT, IRQ_TYPE_EDGE_BOTH); | ||
| 233 | ret = request_irq(AU1100_GPIO20_INT, db1100_mmc_cd, 0, | ||
| 234 | "sd1_cd", mmc_host); | ||
| 235 | } else | ||
| 236 | free_irq(AU1100_GPIO20_INT, mmc_host); | ||
| 237 | return ret; | ||
| 238 | } | ||
| 239 | |||
| 240 | static int db1100_mmc_card_readonly(void *mmc_host) | ||
| 241 | { | ||
| 242 | /* testing suggests that this bit is inverted */ | ||
| 243 | return (bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD0WP) ? 0 : 1; | ||
| 244 | } | ||
| 245 | |||
| 246 | static int db1100_mmc_card_inserted(void *mmc_host) | ||
| 247 | { | ||
| 248 | return !alchemy_gpio_get_value(19); | ||
| 249 | } | ||
| 250 | |||
| 251 | static void db1100_mmc_set_power(void *mmc_host, int state) | ||
| 252 | { | ||
| 253 | if (state) { | ||
| 254 | bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_SD0PWR); | ||
| 255 | msleep(400); /* stabilization time */ | ||
| 256 | } else | ||
| 257 | bcsr_mod(BCSR_BOARD, BCSR_BOARD_SD0PWR, 0); | ||
| 258 | } | ||
| 259 | |||
| 260 | static void db1100_mmcled_set(struct led_classdev *led, enum led_brightness b) | ||
| 261 | { | ||
| 262 | if (b != LED_OFF) | ||
| 263 | bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED0, 0); | ||
| 264 | else | ||
| 265 | bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED0); | ||
| 266 | } | ||
| 267 | |||
| 268 | static struct led_classdev db1100_mmc_led = { | ||
| 269 | .brightness_set = db1100_mmcled_set, | ||
| 270 | }; | ||
| 271 | |||
| 272 | static int db1100_mmc1_card_readonly(void *mmc_host) | ||
| 273 | { | ||
| 274 | return (bcsr_read(BCSR_BOARD) & BCSR_BOARD_SD1WP) ? 1 : 0; | ||
| 275 | } | ||
| 276 | |||
| 277 | static int db1100_mmc1_card_inserted(void *mmc_host) | ||
| 278 | { | ||
| 279 | return !alchemy_gpio_get_value(20); | ||
| 280 | } | ||
| 281 | |||
| 282 | static void db1100_mmc1_set_power(void *mmc_host, int state) | ||
| 283 | { | ||
| 284 | if (state) { | ||
| 285 | bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_SD1PWR); | ||
| 286 | msleep(400); /* stabilization time */ | ||
| 287 | } else | ||
| 288 | bcsr_mod(BCSR_BOARD, BCSR_BOARD_SD1PWR, 0); | ||
| 289 | } | ||
| 290 | |||
| 291 | static void db1100_mmc1led_set(struct led_classdev *led, enum led_brightness b) | ||
| 292 | { | ||
| 293 | if (b != LED_OFF) | ||
| 294 | bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED1, 0); | ||
| 295 | else | ||
| 296 | bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED1); | ||
| 297 | } | ||
| 298 | |||
| 299 | static struct led_classdev db1100_mmc1_led = { | ||
| 300 | .brightness_set = db1100_mmc1led_set, | ||
| 301 | }; | ||
| 302 | |||
| 303 | static struct au1xmmc_platform_data db1100_mmc_platdata[2] = { | ||
| 304 | [0] = { | ||
| 305 | .cd_setup = db1100_mmc_cd_setup, | ||
| 306 | .set_power = db1100_mmc_set_power, | ||
| 307 | .card_inserted = db1100_mmc_card_inserted, | ||
| 308 | .card_readonly = db1100_mmc_card_readonly, | ||
| 309 | .led = &db1100_mmc_led, | ||
| 310 | }, | ||
| 311 | [1] = { | ||
| 312 | .cd_setup = db1100_mmc1_cd_setup, | ||
| 313 | .set_power = db1100_mmc1_set_power, | ||
| 314 | .card_inserted = db1100_mmc1_card_inserted, | ||
| 315 | .card_readonly = db1100_mmc1_card_readonly, | ||
| 316 | .led = &db1100_mmc1_led, | ||
| 317 | }, | ||
| 318 | }; | ||
| 319 | |||
| 320 | static struct resource au1100_mmc0_resources[] = { | ||
| 321 | [0] = { | ||
| 322 | .start = AU1100_SD0_PHYS_ADDR, | ||
| 323 | .end = AU1100_SD0_PHYS_ADDR + 0xfff, | ||
| 324 | .flags = IORESOURCE_MEM, | ||
| 325 | }, | ||
| 326 | [1] = { | ||
| 327 | .start = AU1100_SD_INT, | ||
| 328 | .end = AU1100_SD_INT, | ||
| 329 | .flags = IORESOURCE_IRQ, | ||
| 330 | }, | ||
| 331 | [2] = { | ||
| 332 | .start = DMA_ID_SD0_TX, | ||
| 333 | .end = DMA_ID_SD0_TX, | ||
| 334 | .flags = IORESOURCE_DMA, | ||
| 335 | }, | ||
| 336 | [3] = { | ||
| 337 | .start = DMA_ID_SD0_RX, | ||
| 338 | .end = DMA_ID_SD0_RX, | ||
| 339 | .flags = IORESOURCE_DMA, | ||
| 340 | } | ||
| 341 | }; | ||
| 342 | |||
| 343 | static u64 au1xxx_mmc_dmamask = DMA_BIT_MASK(32); | ||
| 344 | |||
| 345 | static struct platform_device db1100_mmc0_dev = { | ||
| 346 | .name = "au1xxx-mmc", | ||
| 347 | .id = 0, | ||
| 348 | .dev = { | ||
| 349 | .dma_mask = &au1xxx_mmc_dmamask, | ||
| 350 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
| 351 | .platform_data = &db1100_mmc_platdata[0], | ||
| 352 | }, | ||
| 353 | .num_resources = ARRAY_SIZE(au1100_mmc0_resources), | ||
| 354 | .resource = au1100_mmc0_resources, | ||
| 355 | }; | ||
| 356 | |||
| 357 | static struct resource au1100_mmc1_res[] = { | ||
| 358 | [0] = { | ||
| 359 | .start = AU1100_SD1_PHYS_ADDR, | ||
| 360 | .end = AU1100_SD1_PHYS_ADDR + 0xfff, | ||
| 361 | .flags = IORESOURCE_MEM, | ||
| 362 | }, | ||
| 363 | [1] = { | ||
| 364 | .start = AU1100_SD_INT, | ||
| 365 | .end = AU1100_SD_INT, | ||
| 366 | .flags = IORESOURCE_IRQ, | ||
| 367 | }, | ||
| 368 | [2] = { | ||
| 369 | .start = DMA_ID_SD1_TX, | ||
| 370 | .end = DMA_ID_SD1_TX, | ||
| 371 | .flags = IORESOURCE_DMA, | ||
| 372 | }, | ||
| 373 | [3] = { | ||
| 374 | .start = DMA_ID_SD1_RX, | ||
| 375 | .end = DMA_ID_SD1_RX, | ||
| 376 | .flags = IORESOURCE_DMA, | ||
| 377 | } | ||
| 378 | }; | ||
| 379 | |||
| 380 | static struct platform_device db1100_mmc1_dev = { | ||
| 381 | .name = "au1xxx-mmc", | ||
| 382 | .id = 1, | ||
| 383 | .dev = { | ||
| 384 | .dma_mask = &au1xxx_mmc_dmamask, | ||
| 385 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
| 386 | .platform_data = &db1100_mmc_platdata[1], | ||
| 387 | }, | ||
| 388 | .num_resources = ARRAY_SIZE(au1100_mmc1_res), | ||
| 389 | .resource = au1100_mmc1_res, | ||
| 390 | }; | ||
| 391 | |||
| 392 | |||
| 197 | static struct platform_device *db1x00_devs[] = { | 393 | static struct platform_device *db1x00_devs[] = { |
| 198 | &db1x00_codec_dev, | 394 | &db1x00_codec_dev, |
| 199 | &alchemy_ac97c_dma_dev, | 395 | &alchemy_ac97c_dma_dev, |
| @@ -203,6 +399,8 @@ static struct platform_device *db1x00_devs[] = { | |||
| 203 | 399 | ||
| 204 | static struct platform_device *db1100_devs[] = { | 400 | static struct platform_device *db1100_devs[] = { |
| 205 | &au1100_lcd_device, | 401 | &au1100_lcd_device, |
| 402 | &db1100_mmc0_dev, | ||
| 403 | &db1100_mmc1_dev, | ||
| 206 | }; | 404 | }; |
| 207 | 405 | ||
| 208 | static int __init db1000_dev_init(void) | 406 | static int __init db1000_dev_init(void) |
| @@ -224,6 +422,10 @@ static int __init db1000_dev_init(void) | |||
| 224 | d1 = AU1100_GPIO3_INT; | 422 | d1 = AU1100_GPIO3_INT; |
| 225 | s0 = AU1100_GPIO1_INT; | 423 | s0 = AU1100_GPIO1_INT; |
| 226 | s1 = AU1100_GPIO4_INT; | 424 | s1 = AU1100_GPIO4_INT; |
| 425 | |||
| 426 | gpio_direction_input(19); /* sd0 cd# */ | ||
| 427 | gpio_direction_input(20); /* sd1 cd# */ | ||
| 428 | |||
| 227 | platform_add_devices(db1100_devs, ARRAY_SIZE(db1100_devs)); | 429 | platform_add_devices(db1100_devs, ARRAY_SIZE(db1100_devs)); |
| 228 | } else if (board == BCSR_WHOAMI_DB1000) { | 430 | } else if (board == BCSR_WHOAMI_DB1000) { |
| 229 | c0 = AU1000_GPIO2_INT; | 431 | c0 = AU1000_GPIO2_INT; |
