forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-16 50a212ec906f7524620675f0c57357691c26c81f
kernel/arch/mips/alchemy/devboards/db1200.c
....@@ -1,21 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * DBAu1200/PBAu1200 board platform device registration
34 *
45 * 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
196 */
207
218 #include <linux/clk.h>
....@@ -23,14 +10,12 @@
2310 #include <linux/gpio.h>
2411 #include <linux/i2c.h>
2512 #include <linux/init.h>
26
-#include <linux/module.h>
2713 #include <linux/interrupt.h>
2814 #include <linux/io.h>
2915 #include <linux/leds.h>
3016 #include <linux/mmc/host.h>
3117 #include <linux/mtd/mtd.h>
32
-#include <linux/mtd/rawnand.h>
33
-#include <linux/mtd/partitions.h>
18
+#include <linux/mtd/platnand.h>
3419 #include <linux/platform_device.h>
3520 #include <linux/serial_8250.h>
3621 #include <linux/spi/spi.h>
....@@ -154,6 +139,8 @@
154139
155140 /******************************************************************************/
156141
142
+static u64 au1200_all_dmamask = DMA_BIT_MASK(32);
143
+
157144 static struct mtd_partition db1200_spiflash_parts[] = {
158145 {
159146 .name = "spi_flash",
....@@ -197,11 +184,10 @@
197184
198185 /**********************************************************************/
199186
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,
201188 unsigned int ctrl)
202189 {
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;
205191
206192 ioaddr &= 0xffffff00;
207193
....@@ -213,14 +199,14 @@
213199 /* assume we want to r/w real data by default */
214200 ioaddr += MEM_STNAND_DATA;
215201 }
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;
217203 if (cmd != NAND_CMD_NONE) {
218
- __raw_writeb(cmd, this->IO_ADDR_W);
204
+ __raw_writeb(cmd, this->legacy.IO_ADDR_W);
219205 wmb();
220206 }
221207 }
222208
223
-static int au1200_nand_device_ready(struct mtd_info *mtd)
209
+static int au1200_nand_device_ready(struct nand_chip *this)
224210 {
225211 return alchemy_rdsmem(AU1000_MEM_STSTAT) & 1;
226212 }
....@@ -326,13 +312,11 @@
326312 },
327313 };
328314
329
-static u64 au1200_ide_dmamask = DMA_BIT_MASK(32);
330
-
331315 static struct platform_device db1200_ide_dev = {
332316 .name = "pata_platform",
333317 .id = 0,
334318 .dev = {
335
- .dma_mask = &au1200_ide_dmamask,
319
+ .dma_mask = &au1200_all_dmamask,
336320 .coherent_dma_mask = DMA_BIT_MASK(32),
337321 .platform_data = &db1200_ide_info,
338322 },
....@@ -342,6 +326,7 @@
342326
343327 /**********************************************************************/
344328
329
+#ifdef CONFIG_MMC_AU1X
345330 /* SD carddetects: they're supposed to be edge-triggered, but ack
346331 * doesn't seem to work (CPLD Rev 2). Instead, the screaming one
347332 * is disabled and its counterpart enabled. The 200ms timeout is
....@@ -355,14 +340,7 @@
355340
356341 static irqreturn_t db1200_mmc_cdfn(int irq, void *ptr)
357342 {
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));
366344
367345 msleep(100); /* debounce */
368346 if (irq == DB1200_SD0_INSERT_INT)
....@@ -446,14 +424,7 @@
446424
447425 static irqreturn_t pb1200_mmc1_cdfn(int irq, void *ptr)
448426 {
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));
457428
458429 msleep(100); /* debounce */
459430 if (irq == PB1200_SD1_INSERT_INT)
....@@ -568,13 +539,11 @@
568539 }
569540 };
570541
571
-static u64 au1xxx_mmc_dmamask = DMA_BIT_MASK(32);
572
-
573542 static struct platform_device db1200_mmc0_dev = {
574543 .name = "au1xxx-mmc",
575544 .id = 0,
576545 .dev = {
577
- .dma_mask = &au1xxx_mmc_dmamask,
546
+ .dma_mask = &au1200_all_dmamask,
578547 .coherent_dma_mask = DMA_BIT_MASK(32),
579548 .platform_data = &db1200_mmc_platdata[0],
580549 },
....@@ -609,13 +578,14 @@
609578 .name = "au1xxx-mmc",
610579 .id = 1,
611580 .dev = {
612
- .dma_mask = &au1xxx_mmc_dmamask,
581
+ .dma_mask = &au1200_all_dmamask,
613582 .coherent_dma_mask = DMA_BIT_MASK(32),
614583 .platform_data = &db1200_mmc_platdata[1],
615584 },
616585 .num_resources = ARRAY_SIZE(au1200_mmc1_res),
617586 .resource = au1200_mmc1_res,
618587 };
588
+#endif /* CONFIG_MMC_AU1X */
619589
620590 /**********************************************************************/
621591
....@@ -659,13 +629,11 @@
659629 }
660630 };
661631
662
-static u64 au1200_lcd_dmamask = DMA_BIT_MASK(32);
663
-
664632 static struct platform_device au1200_lcd_dev = {
665633 .name = "au1200-lcd",
666634 .id = 0,
667635 .dev = {
668
- .dma_mask = &au1200_lcd_dmamask,
636
+ .dma_mask = &au1200_all_dmamask,
669637 .coherent_dma_mask = DMA_BIT_MASK(32),
670638 .platform_data = &db1200fb_pd,
671639 },
....@@ -719,11 +687,9 @@
719687 .activate_cs = db1200_spi_cs_en,
720688 };
721689
722
-static u64 spi_dmamask = DMA_BIT_MASK(32);
723
-
724690 static struct platform_device db1200_spi_dev = {
725691 .dev = {
726
- .dma_mask = &spi_dmamask,
692
+ .dma_mask = &au1200_all_dmamask,
727693 .coherent_dma_mask = DMA_BIT_MASK(32),
728694 .platform_data = &db1200_spi_platdata,
729695 },
....@@ -768,6 +734,10 @@
768734 static struct platform_device db1200_sound_dev = {
769735 /* name assigned later based on switch setting */
770736 .id = 1, /* PSC ID */
737
+ .dev = {
738
+ .dma_mask = &au1200_all_dmamask,
739
+ .coherent_dma_mask = DMA_BIT_MASK(32),
740
+ },
771741 };
772742
773743 static struct platform_device db1200_stac_dev = {
....@@ -783,7 +753,9 @@
783753 static struct platform_device *db1200_devs[] __initdata = {
784754 NULL, /* PSC0, selected by S6.8 */
785755 &db1200_ide_dev,
756
+#ifdef CONFIG_MMC_AU1X
786757 &db1200_mmc0_dev,
758
+#endif
787759 &au1200_lcd_dev,
788760 &db1200_eth_dev,
789761 &db1200_nand_dev,
....@@ -794,7 +766,9 @@
794766 };
795767
796768 static struct platform_device *pb1200_devs[] __initdata = {
769
+#ifdef CONFIG_MMC_AU1X
797770 &pb1200_mmc1_dev,
771
+#endif
798772 };
799773
800774 /* Some peripheral base addresses differ on the PB1200 */