| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * DBAu1000/1500/1100 PBAu1100/1500 board support |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright 2000, 2008 MontaVista Software Inc. |
|---|
| 5 | 6 | * Author: MontaVista Software, Inc. <source@mvista.com> |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 9 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | | - * (at your option) any later version. |
|---|
| 11 | | - * |
|---|
| 12 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | | - * GNU General Public License for more details. |
|---|
| 16 | | - * |
|---|
| 17 | | - * You should have received a copy of the GNU General Public License |
|---|
| 18 | | - * along with this program; if not, write to the Free Software |
|---|
| 19 | | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 20 | 7 | */ |
|---|
| 21 | 8 | |
|---|
| 22 | 9 | #include <linux/clk.h> |
|---|
| .. | .. |
|---|
| 27 | 14 | #include <linux/interrupt.h> |
|---|
| 28 | 15 | #include <linux/leds.h> |
|---|
| 29 | 16 | #include <linux/mmc/host.h> |
|---|
| 30 | | -#include <linux/module.h> |
|---|
| 31 | 17 | #include <linux/platform_device.h> |
|---|
| 32 | 18 | #include <linux/pm.h> |
|---|
| 33 | 19 | #include <linux/spi/spi.h> |
|---|
| .. | .. |
|---|
| 82 | 68 | return -1; |
|---|
| 83 | 69 | } |
|---|
| 84 | 70 | |
|---|
| 71 | +static u64 au1xxx_all_dmamask = DMA_BIT_MASK(32); |
|---|
| 72 | + |
|---|
| 85 | 73 | static struct resource alchemy_pci_host_res[] = { |
|---|
| 86 | 74 | [0] = { |
|---|
| 87 | 75 | .start = AU1500_PCI_PHYS_ADDR, |
|---|
| .. | .. |
|---|
| 120 | 108 | } |
|---|
| 121 | 109 | }; |
|---|
| 122 | 110 | |
|---|
| 123 | | -static u64 au1100_lcd_dmamask = DMA_BIT_MASK(32); |
|---|
| 124 | | - |
|---|
| 125 | 111 | static struct platform_device au1100_lcd_device = { |
|---|
| 126 | 112 | .name = "au1100-lcd", |
|---|
| 127 | 113 | .id = 0, |
|---|
| 128 | 114 | .dev = { |
|---|
| 129 | | - .dma_mask = &au1100_lcd_dmamask, |
|---|
| 115 | + .dma_mask = &au1xxx_all_dmamask, |
|---|
| 130 | 116 | .coherent_dma_mask = DMA_BIT_MASK(32), |
|---|
| 131 | 117 | }, |
|---|
| 132 | 118 | .num_resources = ARRAY_SIZE(au1100_lcd_resources), |
|---|
| .. | .. |
|---|
| 170 | 156 | |
|---|
| 171 | 157 | static struct platform_device db1x00_audio_dev = { |
|---|
| 172 | 158 | .name = "db1000-audio", |
|---|
| 159 | + .dev = { |
|---|
| 160 | + .dma_mask = &au1xxx_all_dmamask, |
|---|
| 161 | + .coherent_dma_mask = DMA_BIT_MASK(32), |
|---|
| 162 | + }, |
|---|
| 173 | 163 | }; |
|---|
| 174 | 164 | |
|---|
| 175 | 165 | /******************************************************************************/ |
|---|
| 176 | 166 | |
|---|
| 167 | +#ifdef CONFIG_MMC_AU1X |
|---|
| 177 | 168 | static irqreturn_t db1100_mmc_cd(int irq, void *ptr) |
|---|
| 178 | 169 | { |
|---|
| 179 | | - void (*mmc_cd)(struct mmc_host *, unsigned long); |
|---|
| 180 | | - /* link against CONFIG_MMC=m */ |
|---|
| 181 | | - mmc_cd = symbol_get(mmc_detect_change); |
|---|
| 182 | | - mmc_cd(ptr, msecs_to_jiffies(500)); |
|---|
| 183 | | - symbol_put(mmc_detect_change); |
|---|
| 184 | | - |
|---|
| 170 | + mmc_detect_change(ptr, msecs_to_jiffies(500)); |
|---|
| 185 | 171 | return IRQ_HANDLED; |
|---|
| 186 | 172 | } |
|---|
| 187 | 173 | |
|---|
| .. | .. |
|---|
| 338 | 324 | } |
|---|
| 339 | 325 | }; |
|---|
| 340 | 326 | |
|---|
| 341 | | -static u64 au1xxx_mmc_dmamask = DMA_BIT_MASK(32); |
|---|
| 342 | | - |
|---|
| 343 | 327 | static struct platform_device db1100_mmc0_dev = { |
|---|
| 344 | 328 | .name = "au1xxx-mmc", |
|---|
| 345 | 329 | .id = 0, |
|---|
| 346 | 330 | .dev = { |
|---|
| 347 | | - .dma_mask = &au1xxx_mmc_dmamask, |
|---|
| 331 | + .dma_mask = &au1xxx_all_dmamask, |
|---|
| 348 | 332 | .coherent_dma_mask = DMA_BIT_MASK(32), |
|---|
| 349 | 333 | .platform_data = &db1100_mmc_platdata[0], |
|---|
| 350 | 334 | }, |
|---|
| .. | .. |
|---|
| 379 | 363 | .name = "au1xxx-mmc", |
|---|
| 380 | 364 | .id = 1, |
|---|
| 381 | 365 | .dev = { |
|---|
| 382 | | - .dma_mask = &au1xxx_mmc_dmamask, |
|---|
| 366 | + .dma_mask = &au1xxx_all_dmamask, |
|---|
| 383 | 367 | .coherent_dma_mask = DMA_BIT_MASK(32), |
|---|
| 384 | 368 | .platform_data = &db1100_mmc_platdata[1], |
|---|
| 385 | 369 | }, |
|---|
| 386 | 370 | .num_resources = ARRAY_SIZE(au1100_mmc1_res), |
|---|
| 387 | 371 | .resource = au1100_mmc1_res, |
|---|
| 388 | 372 | }; |
|---|
| 389 | | - |
|---|
| 390 | | -/******************************************************************************/ |
|---|
| 391 | | - |
|---|
| 392 | | -static void db1000_irda_set_phy_mode(int mode) |
|---|
| 393 | | -{ |
|---|
| 394 | | - unsigned short mask = BCSR_RESETS_IRDA_MODE_MASK | BCSR_RESETS_FIR_SEL; |
|---|
| 395 | | - |
|---|
| 396 | | - switch (mode) { |
|---|
| 397 | | - case AU1000_IRDA_PHY_MODE_OFF: |
|---|
| 398 | | - bcsr_mod(BCSR_RESETS, mask, BCSR_RESETS_IRDA_MODE_OFF); |
|---|
| 399 | | - break; |
|---|
| 400 | | - case AU1000_IRDA_PHY_MODE_SIR: |
|---|
| 401 | | - bcsr_mod(BCSR_RESETS, mask, BCSR_RESETS_IRDA_MODE_FULL); |
|---|
| 402 | | - break; |
|---|
| 403 | | - case AU1000_IRDA_PHY_MODE_FIR: |
|---|
| 404 | | - bcsr_mod(BCSR_RESETS, mask, BCSR_RESETS_IRDA_MODE_FULL | |
|---|
| 405 | | - BCSR_RESETS_FIR_SEL); |
|---|
| 406 | | - break; |
|---|
| 407 | | - } |
|---|
| 408 | | -} |
|---|
| 409 | | - |
|---|
| 410 | | -static struct au1k_irda_platform_data db1000_irda_platdata = { |
|---|
| 411 | | - .set_phy_mode = db1000_irda_set_phy_mode, |
|---|
| 412 | | -}; |
|---|
| 413 | | - |
|---|
| 414 | | -static struct resource au1000_irda_res[] = { |
|---|
| 415 | | - [0] = { |
|---|
| 416 | | - .start = AU1000_IRDA_PHYS_ADDR, |
|---|
| 417 | | - .end = AU1000_IRDA_PHYS_ADDR + 0x0fff, |
|---|
| 418 | | - .flags = IORESOURCE_MEM, |
|---|
| 419 | | - }, |
|---|
| 420 | | - [1] = { |
|---|
| 421 | | - .start = AU1000_IRDA_TX_INT, |
|---|
| 422 | | - .end = AU1000_IRDA_TX_INT, |
|---|
| 423 | | - .flags = IORESOURCE_IRQ, |
|---|
| 424 | | - }, |
|---|
| 425 | | - [2] = { |
|---|
| 426 | | - .start = AU1000_IRDA_RX_INT, |
|---|
| 427 | | - .end = AU1000_IRDA_RX_INT, |
|---|
| 428 | | - .flags = IORESOURCE_IRQ, |
|---|
| 429 | | - }, |
|---|
| 430 | | -}; |
|---|
| 431 | | - |
|---|
| 432 | | -static struct platform_device db1000_irda_dev = { |
|---|
| 433 | | - .name = "au1000-irda", |
|---|
| 434 | | - .id = -1, |
|---|
| 435 | | - .dev = { |
|---|
| 436 | | - .platform_data = &db1000_irda_platdata, |
|---|
| 437 | | - }, |
|---|
| 438 | | - .resource = au1000_irda_res, |
|---|
| 439 | | - .num_resources = ARRAY_SIZE(au1000_irda_res), |
|---|
| 440 | | -}; |
|---|
| 373 | +#endif /* CONFIG_MMC_AU1X */ |
|---|
| 441 | 374 | |
|---|
| 442 | 375 | /******************************************************************************/ |
|---|
| 443 | 376 | |
|---|
| .. | .. |
|---|
| 468 | 401 | .id = 0, |
|---|
| 469 | 402 | .dev = { |
|---|
| 470 | 403 | .platform_data = &db1100_spictl_pd, |
|---|
| 404 | + .dma_mask = &au1xxx_all_dmamask, |
|---|
| 405 | + .coherent_dma_mask = DMA_BIT_MASK(32), |
|---|
| 471 | 406 | }, |
|---|
| 472 | 407 | }; |
|---|
| 473 | 408 | |
|---|
| .. | .. |
|---|
| 497 | 432 | &db1x00_audio_dev, |
|---|
| 498 | 433 | }; |
|---|
| 499 | 434 | |
|---|
| 500 | | -static struct platform_device *db1000_devs[] = { |
|---|
| 501 | | - &db1000_irda_dev, |
|---|
| 502 | | -}; |
|---|
| 503 | | - |
|---|
| 504 | 435 | static struct platform_device *db1100_devs[] = { |
|---|
| 505 | 436 | &au1100_lcd_device, |
|---|
| 437 | +#ifdef CONFIG_MMC_AU1X |
|---|
| 506 | 438 | &db1100_mmc0_dev, |
|---|
| 507 | 439 | &db1100_mmc1_dev, |
|---|
| 508 | | - &db1000_irda_dev, |
|---|
| 440 | +#endif |
|---|
| 509 | 441 | }; |
|---|
| 510 | 442 | |
|---|
| 511 | 443 | int __init db1000_dev_setup(void) |
|---|
| .. | .. |
|---|
| 565 | 497 | d1 = 3; /* GPIO number, NOT irq! */ |
|---|
| 566 | 498 | s0 = AU1000_GPIO1_INT; |
|---|
| 567 | 499 | s1 = AU1000_GPIO4_INT; |
|---|
| 568 | | - platform_add_devices(db1000_devs, ARRAY_SIZE(db1000_devs)); |
|---|
| 569 | 500 | } else if ((board == BCSR_WHOAMI_PB1500) || |
|---|
| 570 | 501 | (board == BCSR_WHOAMI_PB1500R2)) { |
|---|
| 571 | 502 | c0 = AU1500_GPIO203_INT; |
|---|