hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/arch/sh/boards/mach-ecovec24/setup.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Copyright (C) 2009 Renesas Solutions Corp.
34 *
45 * Kuninori Morimoto <morimoto.kuninori@renesas.com>
5
- *
6
- * This file is subject to the terms and conditions of the GNU General Public
7
- * License. See the file "COPYING" in the main directory of this archive
8
- * for more details.
96 */
107 #include <asm/clock.h>
118 #include <asm/heartbeat.h>
....@@ -39,6 +36,7 @@
3936 #include <linux/usb/r8a66597.h>
4037 #include <linux/usb/renesas_usbhs.h>
4138 #include <linux/videodev2.h>
39
+#include <linux/dma-map-ops.h>
4240
4341 #include <media/drv-intf/renesas-ceu.h>
4442 #include <media/i2c/mt9t112.h>
....@@ -374,19 +372,31 @@
374372 },
375373 };
376374
377
-static struct gpio_backlight_platform_data gpio_backlight_data = {
378
- .fbdev = &lcdc_device.dev,
379
- .gpio = GPIO_PTR1,
380
- .def_value = 1,
381
- .name = "backlight",
382
-};
383
-
384
-static struct platform_device gpio_backlight_device = {
385
- .name = "gpio-backlight",
386
- .dev = {
387
- .platform_data = &gpio_backlight_data,
375
+static struct gpiod_lookup_table gpio_backlight_lookup = {
376
+ .dev_id = "gpio-backlight.0",
377
+ .table = {
378
+ GPIO_LOOKUP("sh7724_pfc", GPIO_PTR1, NULL, GPIO_ACTIVE_HIGH),
379
+ { }
388380 },
389381 };
382
+
383
+static struct property_entry gpio_backlight_props[] = {
384
+ PROPERTY_ENTRY_BOOL("default-on"),
385
+ { }
386
+};
387
+
388
+static struct gpio_backlight_platform_data gpio_backlight_data = {
389
+ .fbdev = &lcdc_device.dev,
390
+};
391
+
392
+static const struct platform_device_info gpio_backlight_device_info = {
393
+ .name = "gpio-backlight",
394
+ .data = &gpio_backlight_data,
395
+ .size_data = sizeof(gpio_backlight_data),
396
+ .properties = gpio_backlight_props,
397
+};
398
+
399
+static struct platform_device *gpio_backlight_device;
390400
391401 /* CEU0 */
392402 static struct ceu_platform_data ceu0_pdata = {
....@@ -633,8 +643,6 @@
633643 static struct fixed_voltage_config cn12_power_info = {
634644 .supply_name = "CN12 SD/MMC Vdd",
635645 .microvolts = 3300000,
636
- .gpio = GPIO_PTB7,
637
- .enable_high = 1,
638646 .init_data = &cn12_power_init_data,
639647 };
640648
....@@ -643,6 +651,16 @@
643651 .id = 0,
644652 .dev = {
645653 .platform_data = &cn12_power_info,
654
+ },
655
+};
656
+
657
+static struct gpiod_lookup_table cn12_power_gpiod_table = {
658
+ .dev_id = "reg-fixed-voltage.0",
659
+ .table = {
660
+ /* Offset 7 on port B */
661
+ GPIO_LOOKUP("sh7724_pfc", GPIO_PTB7,
662
+ NULL, GPIO_ACTIVE_HIGH),
663
+ { },
646664 },
647665 };
648666
....@@ -665,8 +683,6 @@
665683 static struct fixed_voltage_config sdhi0_power_info = {
666684 .supply_name = "CN11 SD/MMC Vdd",
667685 .microvolts = 3300000,
668
- .gpio = GPIO_PTB6,
669
- .enable_high = 1,
670686 .init_data = &sdhi0_power_init_data,
671687 };
672688
....@@ -678,13 +694,30 @@
678694 },
679695 };
680696
697
+static struct gpiod_lookup_table sdhi0_power_gpiod_table = {
698
+ .dev_id = "reg-fixed-voltage.1",
699
+ .table = {
700
+ /* Offset 6 on port B */
701
+ GPIO_LOOKUP("sh7724_pfc", GPIO_PTB6,
702
+ NULL, GPIO_ACTIVE_HIGH),
703
+ { },
704
+ },
705
+};
706
+
707
+static struct gpiod_lookup_table sdhi0_gpio_table = {
708
+ .dev_id = "sh_mobile_sdhi.0",
709
+ .table = {
710
+ /* Card detect */
711
+ GPIO_LOOKUP("sh7724_pfc", GPIO_PTY7, "cd", GPIO_ACTIVE_LOW),
712
+ { },
713
+ },
714
+};
715
+
681716 static struct tmio_mmc_data sdhi0_info = {
682717 .chan_priv_tx = (void *)SHDMA_SLAVE_SDHI0_TX,
683718 .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI0_RX,
684719 .capabilities = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
685720 MMC_CAP_NEEDS_POLL,
686
- .flags = TMIO_MMC_USE_GPIO_CD,
687
- .cd_gpio = GPIO_PTY7,
688721 };
689722
690723 static struct resource sdhi0_resources[] = {
....@@ -717,8 +750,15 @@
717750 .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI1_RX,
718751 .capabilities = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
719752 MMC_CAP_NEEDS_POLL,
720
- .flags = TMIO_MMC_USE_GPIO_CD,
721
- .cd_gpio = GPIO_PTW7,
753
+};
754
+
755
+static struct gpiod_lookup_table sdhi1_gpio_table = {
756
+ .dev_id = "sh_mobile_sdhi.1",
757
+ .table = {
758
+ /* Card detect */
759
+ GPIO_LOOKUP("sh7724_pfc", GPIO_PTW7, "cd", GPIO_ACTIVE_LOW),
760
+ { },
761
+ },
722762 };
723763
724764 static struct resource sdhi1_resources[] = {
....@@ -758,9 +798,19 @@
758798 .caps2 = MMC_CAP2_RO_ACTIVE_HIGH,
759799 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */
760800 .setpower = mmc_spi_setpower,
761
- .flags = MMC_SPI_USE_CD_GPIO | MMC_SPI_USE_RO_GPIO,
762
- .cd_gpio = GPIO_PTY7,
763
- .ro_gpio = GPIO_PTY6,
801
+};
802
+
803
+static struct gpiod_lookup_table mmc_spi_gpio_table = {
804
+ .dev_id = "mmc_spi.0", /* device "mmc_spi" @ CS0 */
805
+ .table = {
806
+ /* Card detect */
807
+ GPIO_LOOKUP_IDX("sh7724_pfc", GPIO_PTY7, NULL, 0,
808
+ GPIO_ACTIVE_LOW),
809
+ /* Write protect */
810
+ GPIO_LOOKUP_IDX("sh7724_pfc", GPIO_PTY6, NULL, 1,
811
+ GPIO_ACTIVE_HIGH),
812
+ { },
813
+ },
764814 };
765815
766816 static struct spi_board_info spi_bus[] = {
....@@ -769,7 +819,6 @@
769819 .platform_data = &mmc_spi_info,
770820 .max_speed_hz = 5000000,
771821 .mode = SPI_MODE_0,
772
- .controller_data = (void *) GPIO_PTM4,
773822 },
774823 };
775824
....@@ -799,6 +848,14 @@
799848 },
800849 .num_resources = ARRAY_SIZE(msiof0_resources),
801850 .resource = msiof0_resources,
851
+};
852
+
853
+static struct gpiod_lookup_table msiof_gpio_table = {
854
+ .dev_id = "spi_sh_msiof.0",
855
+ .table = {
856
+ GPIO_LOOKUP("sh7724_pfc", GPIO_PTM4, "cs", GPIO_ACTIVE_HIGH),
857
+ { },
858
+ },
802859 };
803860
804861 #endif
....@@ -962,7 +1019,6 @@
9621019 &usb1_common_device,
9631020 &usbhs_device,
9641021 &lcdc_device,
965
- &gpio_backlight_device,
9661022 &keysc_device,
9671023 &cn12_power,
9681024 #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
....@@ -1259,11 +1315,11 @@
12591315 gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
12601316 gpio_request(GPIO_FN_MSIOF0_RXD, NULL);
12611317 gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);
1262
- gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */
1263
- gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
12641318 gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
12651319 gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
12661320
1321
+ gpiod_add_lookup_table(&mmc_spi_gpio_table);
1322
+ gpiod_add_lookup_table(&msiof_gpio_table);
12671323 spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
12681324 #endif
12691325
....@@ -1396,22 +1452,31 @@
13961452
13971453 /* Initialize CEU platform devices separately to map memory first */
13981454 device_initialize(&ecovec_ceu_devices[0]->dev);
1399
- arch_setup_pdev_archdata(ecovec_ceu_devices[0]);
14001455 dma_declare_coherent_memory(&ecovec_ceu_devices[0]->dev,
14011456 ceu0_dma_membase, ceu0_dma_membase,
1402
- ceu0_dma_membase +
1403
- CEU_BUFFER_MEMORY_SIZE - 1,
1404
- DMA_MEMORY_EXCLUSIVE);
1457
+ CEU_BUFFER_MEMORY_SIZE);
14051458 platform_device_add(ecovec_ceu_devices[0]);
14061459
14071460 device_initialize(&ecovec_ceu_devices[1]->dev);
1408
- arch_setup_pdev_archdata(ecovec_ceu_devices[1]);
14091461 dma_declare_coherent_memory(&ecovec_ceu_devices[1]->dev,
14101462 ceu1_dma_membase, ceu1_dma_membase,
1411
- ceu1_dma_membase +
1412
- CEU_BUFFER_MEMORY_SIZE - 1,
1413
- DMA_MEMORY_EXCLUSIVE);
1463
+ CEU_BUFFER_MEMORY_SIZE);
14141464 platform_device_add(ecovec_ceu_devices[1]);
1465
+
1466
+ gpiod_add_lookup_table(&cn12_power_gpiod_table);
1467
+#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
1468
+ gpiod_add_lookup_table(&sdhi0_power_gpiod_table);
1469
+ gpiod_add_lookup_table(&sdhi0_gpio_table);
1470
+#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
1471
+ gpiod_add_lookup_table(&sdhi1_gpio_table);
1472
+#endif
1473
+#endif
1474
+
1475
+ gpiod_add_lookup_table(&gpio_backlight_lookup);
1476
+ gpio_backlight_device = platform_device_register_full(
1477
+ &gpio_backlight_device_info);
1478
+ if (IS_ERR(gpio_backlight_device))
1479
+ return PTR_ERR(gpio_backlight_device);
14151480
14161481 return platform_add_devices(ecovec_devices,
14171482 ARRAY_SIZE(ecovec_devices));
....@@ -1431,12 +1496,18 @@
14311496 phys_addr_t phys;
14321497 phys_addr_t size = CEU_BUFFER_MEMORY_SIZE;
14331498
1434
- phys = memblock_alloc_base(size, PAGE_SIZE, MEMBLOCK_ALLOC_ANYWHERE);
1499
+ phys = memblock_phys_alloc(size, PAGE_SIZE);
1500
+ if (!phys)
1501
+ panic("Failed to allocate CEU0 memory\n");
1502
+
14351503 memblock_free(phys, size);
14361504 memblock_remove(phys, size);
14371505 ceu0_dma_membase = phys;
14381506
1439
- phys = memblock_alloc_base(size, PAGE_SIZE, MEMBLOCK_ALLOC_ANYWHERE);
1507
+ phys = memblock_phys_alloc(size, PAGE_SIZE);
1508
+ if (!phys)
1509
+ panic("Failed to allocate CEU1 memory\n");
1510
+
14401511 memblock_free(phys, size);
14411512 memblock_remove(phys, size);
14421513 ceu1_dma_membase = phys;