| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * DBAu1200/PBAu1200 board platform device registration |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2008-2011 Manuel Lauss |
|---|
| 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 | 6 | */ |
|---|
| 20 | 7 | |
|---|
| 21 | 8 | #include <linux/clk.h> |
|---|
| .. | .. |
|---|
| 23 | 10 | #include <linux/gpio.h> |
|---|
| 24 | 11 | #include <linux/i2c.h> |
|---|
| 25 | 12 | #include <linux/init.h> |
|---|
| 26 | | -#include <linux/module.h> |
|---|
| 27 | 13 | #include <linux/interrupt.h> |
|---|
| 28 | 14 | #include <linux/io.h> |
|---|
| 29 | 15 | #include <linux/leds.h> |
|---|
| 30 | 16 | #include <linux/mmc/host.h> |
|---|
| 31 | 17 | #include <linux/mtd/mtd.h> |
|---|
| 32 | | -#include <linux/mtd/rawnand.h> |
|---|
| 33 | | -#include <linux/mtd/partitions.h> |
|---|
| 18 | +#include <linux/mtd/platnand.h> |
|---|
| 34 | 19 | #include <linux/platform_device.h> |
|---|
| 35 | 20 | #include <linux/serial_8250.h> |
|---|
| 36 | 21 | #include <linux/spi/spi.h> |
|---|
| .. | .. |
|---|
| 154 | 139 | |
|---|
| 155 | 140 | /******************************************************************************/ |
|---|
| 156 | 141 | |
|---|
| 142 | +static u64 au1200_all_dmamask = DMA_BIT_MASK(32); |
|---|
| 143 | + |
|---|
| 157 | 144 | static struct mtd_partition db1200_spiflash_parts[] = { |
|---|
| 158 | 145 | { |
|---|
| 159 | 146 | .name = "spi_flash", |
|---|
| .. | .. |
|---|
| 197 | 184 | |
|---|
| 198 | 185 | /**********************************************************************/ |
|---|
| 199 | 186 | |
|---|
| 200 | | -static void au1200_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, |
|---|
| 187 | +static void au1200_nand_cmd_ctrl(struct nand_chip *this, int cmd, |
|---|
| 201 | 188 | unsigned int ctrl) |
|---|
| 202 | 189 | { |
|---|
| 203 | | - struct nand_chip *this = mtd_to_nand(mtd); |
|---|
| 204 | | - unsigned long ioaddr = (unsigned long)this->IO_ADDR_W; |
|---|
| 190 | + unsigned long ioaddr = (unsigned long)this->legacy.IO_ADDR_W; |
|---|
| 205 | 191 | |
|---|
| 206 | 192 | ioaddr &= 0xffffff00; |
|---|
| 207 | 193 | |
|---|
| .. | .. |
|---|
| 213 | 199 | /* assume we want to r/w real data by default */ |
|---|
| 214 | 200 | ioaddr += MEM_STNAND_DATA; |
|---|
| 215 | 201 | } |
|---|
| 216 | | - this->IO_ADDR_R = this->IO_ADDR_W = (void __iomem *)ioaddr; |
|---|
| 202 | + this->legacy.IO_ADDR_R = this->legacy.IO_ADDR_W = (void __iomem *)ioaddr; |
|---|
| 217 | 203 | if (cmd != NAND_CMD_NONE) { |
|---|
| 218 | | - __raw_writeb(cmd, this->IO_ADDR_W); |
|---|
| 204 | + __raw_writeb(cmd, this->legacy.IO_ADDR_W); |
|---|
| 219 | 205 | wmb(); |
|---|
| 220 | 206 | } |
|---|
| 221 | 207 | } |
|---|
| 222 | 208 | |
|---|
| 223 | | -static int au1200_nand_device_ready(struct mtd_info *mtd) |
|---|
| 209 | +static int au1200_nand_device_ready(struct nand_chip *this) |
|---|
| 224 | 210 | { |
|---|
| 225 | 211 | return alchemy_rdsmem(AU1000_MEM_STSTAT) & 1; |
|---|
| 226 | 212 | } |
|---|
| .. | .. |
|---|
| 326 | 312 | }, |
|---|
| 327 | 313 | }; |
|---|
| 328 | 314 | |
|---|
| 329 | | -static u64 au1200_ide_dmamask = DMA_BIT_MASK(32); |
|---|
| 330 | | - |
|---|
| 331 | 315 | static struct platform_device db1200_ide_dev = { |
|---|
| 332 | 316 | .name = "pata_platform", |
|---|
| 333 | 317 | .id = 0, |
|---|
| 334 | 318 | .dev = { |
|---|
| 335 | | - .dma_mask = &au1200_ide_dmamask, |
|---|
| 319 | + .dma_mask = &au1200_all_dmamask, |
|---|
| 336 | 320 | .coherent_dma_mask = DMA_BIT_MASK(32), |
|---|
| 337 | 321 | .platform_data = &db1200_ide_info, |
|---|
| 338 | 322 | }, |
|---|
| .. | .. |
|---|
| 342 | 326 | |
|---|
| 343 | 327 | /**********************************************************************/ |
|---|
| 344 | 328 | |
|---|
| 329 | +#ifdef CONFIG_MMC_AU1X |
|---|
| 345 | 330 | /* SD carddetects: they're supposed to be edge-triggered, but ack |
|---|
| 346 | 331 | * doesn't seem to work (CPLD Rev 2). Instead, the screaming one |
|---|
| 347 | 332 | * is disabled and its counterpart enabled. The 200ms timeout is |
|---|
| .. | .. |
|---|
| 355 | 340 | |
|---|
| 356 | 341 | static irqreturn_t db1200_mmc_cdfn(int irq, void *ptr) |
|---|
| 357 | 342 | { |
|---|
| 358 | | - void (*mmc_cd)(struct mmc_host *, unsigned long); |
|---|
| 359 | | - |
|---|
| 360 | | - /* link against CONFIG_MMC=m */ |
|---|
| 361 | | - mmc_cd = symbol_get(mmc_detect_change); |
|---|
| 362 | | - if (mmc_cd) { |
|---|
| 363 | | - mmc_cd(ptr, msecs_to_jiffies(200)); |
|---|
| 364 | | - symbol_put(mmc_detect_change); |
|---|
| 365 | | - } |
|---|
| 343 | + mmc_detect_change(ptr, msecs_to_jiffies(200)); |
|---|
| 366 | 344 | |
|---|
| 367 | 345 | msleep(100); /* debounce */ |
|---|
| 368 | 346 | if (irq == DB1200_SD0_INSERT_INT) |
|---|
| .. | .. |
|---|
| 446 | 424 | |
|---|
| 447 | 425 | static irqreturn_t pb1200_mmc1_cdfn(int irq, void *ptr) |
|---|
| 448 | 426 | { |
|---|
| 449 | | - void (*mmc_cd)(struct mmc_host *, unsigned long); |
|---|
| 450 | | - |
|---|
| 451 | | - /* link against CONFIG_MMC=m */ |
|---|
| 452 | | - mmc_cd = symbol_get(mmc_detect_change); |
|---|
| 453 | | - if (mmc_cd) { |
|---|
| 454 | | - mmc_cd(ptr, msecs_to_jiffies(200)); |
|---|
| 455 | | - symbol_put(mmc_detect_change); |
|---|
| 456 | | - } |
|---|
| 427 | + mmc_detect_change(ptr, msecs_to_jiffies(200)); |
|---|
| 457 | 428 | |
|---|
| 458 | 429 | msleep(100); /* debounce */ |
|---|
| 459 | 430 | if (irq == PB1200_SD1_INSERT_INT) |
|---|
| .. | .. |
|---|
| 568 | 539 | } |
|---|
| 569 | 540 | }; |
|---|
| 570 | 541 | |
|---|
| 571 | | -static u64 au1xxx_mmc_dmamask = DMA_BIT_MASK(32); |
|---|
| 572 | | - |
|---|
| 573 | 542 | static struct platform_device db1200_mmc0_dev = { |
|---|
| 574 | 543 | .name = "au1xxx-mmc", |
|---|
| 575 | 544 | .id = 0, |
|---|
| 576 | 545 | .dev = { |
|---|
| 577 | | - .dma_mask = &au1xxx_mmc_dmamask, |
|---|
| 546 | + .dma_mask = &au1200_all_dmamask, |
|---|
| 578 | 547 | .coherent_dma_mask = DMA_BIT_MASK(32), |
|---|
| 579 | 548 | .platform_data = &db1200_mmc_platdata[0], |
|---|
| 580 | 549 | }, |
|---|
| .. | .. |
|---|
| 609 | 578 | .name = "au1xxx-mmc", |
|---|
| 610 | 579 | .id = 1, |
|---|
| 611 | 580 | .dev = { |
|---|
| 612 | | - .dma_mask = &au1xxx_mmc_dmamask, |
|---|
| 581 | + .dma_mask = &au1200_all_dmamask, |
|---|
| 613 | 582 | .coherent_dma_mask = DMA_BIT_MASK(32), |
|---|
| 614 | 583 | .platform_data = &db1200_mmc_platdata[1], |
|---|
| 615 | 584 | }, |
|---|
| 616 | 585 | .num_resources = ARRAY_SIZE(au1200_mmc1_res), |
|---|
| 617 | 586 | .resource = au1200_mmc1_res, |
|---|
| 618 | 587 | }; |
|---|
| 588 | +#endif /* CONFIG_MMC_AU1X */ |
|---|
| 619 | 589 | |
|---|
| 620 | 590 | /**********************************************************************/ |
|---|
| 621 | 591 | |
|---|
| .. | .. |
|---|
| 659 | 629 | } |
|---|
| 660 | 630 | }; |
|---|
| 661 | 631 | |
|---|
| 662 | | -static u64 au1200_lcd_dmamask = DMA_BIT_MASK(32); |
|---|
| 663 | | - |
|---|
| 664 | 632 | static struct platform_device au1200_lcd_dev = { |
|---|
| 665 | 633 | .name = "au1200-lcd", |
|---|
| 666 | 634 | .id = 0, |
|---|
| 667 | 635 | .dev = { |
|---|
| 668 | | - .dma_mask = &au1200_lcd_dmamask, |
|---|
| 636 | + .dma_mask = &au1200_all_dmamask, |
|---|
| 669 | 637 | .coherent_dma_mask = DMA_BIT_MASK(32), |
|---|
| 670 | 638 | .platform_data = &db1200fb_pd, |
|---|
| 671 | 639 | }, |
|---|
| .. | .. |
|---|
| 719 | 687 | .activate_cs = db1200_spi_cs_en, |
|---|
| 720 | 688 | }; |
|---|
| 721 | 689 | |
|---|
| 722 | | -static u64 spi_dmamask = DMA_BIT_MASK(32); |
|---|
| 723 | | - |
|---|
| 724 | 690 | static struct platform_device db1200_spi_dev = { |
|---|
| 725 | 691 | .dev = { |
|---|
| 726 | | - .dma_mask = &spi_dmamask, |
|---|
| 692 | + .dma_mask = &au1200_all_dmamask, |
|---|
| 727 | 693 | .coherent_dma_mask = DMA_BIT_MASK(32), |
|---|
| 728 | 694 | .platform_data = &db1200_spi_platdata, |
|---|
| 729 | 695 | }, |
|---|
| .. | .. |
|---|
| 768 | 734 | static struct platform_device db1200_sound_dev = { |
|---|
| 769 | 735 | /* name assigned later based on switch setting */ |
|---|
| 770 | 736 | .id = 1, /* PSC ID */ |
|---|
| 737 | + .dev = { |
|---|
| 738 | + .dma_mask = &au1200_all_dmamask, |
|---|
| 739 | + .coherent_dma_mask = DMA_BIT_MASK(32), |
|---|
| 740 | + }, |
|---|
| 771 | 741 | }; |
|---|
| 772 | 742 | |
|---|
| 773 | 743 | static struct platform_device db1200_stac_dev = { |
|---|
| .. | .. |
|---|
| 783 | 753 | static struct platform_device *db1200_devs[] __initdata = { |
|---|
| 784 | 754 | NULL, /* PSC0, selected by S6.8 */ |
|---|
| 785 | 755 | &db1200_ide_dev, |
|---|
| 756 | +#ifdef CONFIG_MMC_AU1X |
|---|
| 786 | 757 | &db1200_mmc0_dev, |
|---|
| 758 | +#endif |
|---|
| 787 | 759 | &au1200_lcd_dev, |
|---|
| 788 | 760 | &db1200_eth_dev, |
|---|
| 789 | 761 | &db1200_nand_dev, |
|---|
| .. | .. |
|---|
| 794 | 766 | }; |
|---|
| 795 | 767 | |
|---|
| 796 | 768 | static struct platform_device *pb1200_devs[] __initdata = { |
|---|
| 769 | +#ifdef CONFIG_MMC_AU1X |
|---|
| 797 | 770 | &pb1200_mmc1_dev, |
|---|
| 771 | +#endif |
|---|
| 798 | 772 | }; |
|---|
| 799 | 773 | |
|---|
| 800 | 774 | /* Some peripheral base addresses differ on the PB1200 */ |
|---|