]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
samsung: exynos: Convert SROMC interface to a driver
authorSimon Glass <sjg@chromium.org>
Mon, 19 Jul 2021 01:02:40 +0000 (19:02 -0600)
committerMinkyu Kang <mk7.kang@samsung.com>
Tue, 27 Jul 2021 01:34:27 +0000 (10:34 +0900)
Add a bus driver for this and use it to configure the bus parameters for
the Ethernet interface. Drop the old pre-driver-model code.

Switch over to use driver model for Ethernet.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
18 files changed:
arch/arm/Kconfig
arch/arm/dts/exynos5250-smdk5250.dts
arch/arm/mach-exynos/include/mach/sromc.h
board/samsung/common/Makefile
board/samsung/common/board.c
board/samsung/common/sromc.c [new file with mode: 0644]
board/samsung/smdkv310/smdkv310.c
configs/arndale_defconfig
configs/odroid-xu3_defconfig
configs/peach-pi_defconfig
configs/peach-pit_defconfig
configs/smdk5250_defconfig
configs/smdk5420_defconfig
configs/smdkv310_defconfig
configs/snow_defconfig
configs/spring_defconfig
include/fdtdec.h
lib/fdtdec.c

index 9de97cc1015203bb1a3de4800b832f6b0a8f9d2e..ff51a4e623b27dbeae905314b260b7ba1f3dfe51 100644 (file)
@@ -661,6 +661,7 @@ config ARCH_EXYNOS
        select DM
        select DM_GPIO
        select DM_I2C
+       select DM_ETH
        select DM_KEYBOARD
        select DM_SERIAL
        select DM_SPI
index e542a7907610ae4f615ff81333bd318f1fea4c96..afe0cca48a931e6c13301c5b3473f2b42a82adf2 100644 (file)
@@ -41,6 +41,7 @@
        };
 
        sromc@12250000 {
+               compatible = "samsung,exynos5-sromc";
                bank = <1>;
                srom-timing = <1 9 12 1 6 1 1>;
                width = <2>;
index 15c9ccc723d823bf21ddd1b57a77dcab43d971ca..ac229e0d169392421443d59d17a81b1d2d0da7b7 100644 (file)
@@ -33,22 +33,4 @@ struct s5p_sromc {
 /* Configure the Band Width and Bank Control Regs for required SROMC Bank */
 void s5p_config_sromc(u32 srom_bank, u32 srom_bw_conf, u32 srom_bc_conf);
 
-enum {
-       FDT_SROM_PMC,
-       FDT_SROM_TACP,
-       FDT_SROM_TAH,
-       FDT_SROM_TCOH,
-       FDT_SROM_TACC,
-       FDT_SROM_TCOS,
-       FDT_SROM_TACS,
-
-       FDT_SROM_TIMING_COUNT,
-};
-
-struct fdt_sromc {
-       u8 bank;        /* srom bank number */
-       u8 width;       /* bus width in bytes */
-       unsigned int timing[FDT_SROM_TIMING_COUNT]; /* timing parameters */
-};
-
 #endif /* __ASM_ARCH_SROMC_H_ */
index 3593c77cbc20a3cce2e24e612ca155d60261a75b..d31b81abf1ee9648ff69e746d80fc4e1f03e4047 100644 (file)
@@ -7,7 +7,7 @@ obj-$(CONFIG_USB_GADGET_DOWNLOAD) += gadget.o
 obj-$(CONFIG_MISC_COMMON) += misc.o
 
 ifndef CONFIG_SPL_BUILD
-obj-$(CONFIG_BOARD_COMMON)     += board.o
+obj-$(CONFIG_BOARD_COMMON)     += board.o sromc.o
 ifdef CONFIG_EXYNOS5_DT
 obj-y += exynos5-dt.o
 obj-$(CONFIG_BOARD_TYPES) += exynos5-dt-types.o
index 104d2a6574698ead2103a356ff7d5cd80f52f2f5..1c2fe025e89c2d7a8e776816cc4ea8e23e759d94 100644 (file)
@@ -26,7 +26,6 @@
 #include <asm/arch/pinmux.h>
 #include <asm/arch/power.h>
 #include <asm/arch/system.h>
-#include <asm/arch/sromc.h>
 #include <lcd.h>
 #include <i2c.h>
 #include <mmc.h>
@@ -195,83 +194,6 @@ int power_init_board(void)
 }
 #endif
 
-#ifdef CONFIG_SMC911X
-static int decode_sromc(const void *blob, struct fdt_sromc *config)
-{
-       int err;
-       int node;
-
-       node = fdtdec_next_compatible(blob, 0, COMPAT_SAMSUNG_EXYNOS5_SROMC);
-       if (node < 0) {
-               debug("Could not find SROMC node\n");
-               return node;
-       }
-
-       config->bank = fdtdec_get_int(blob, node, "bank", 0);
-       config->width = fdtdec_get_int(blob, node, "width", 2);
-
-       err = fdtdec_get_int_array(blob, node, "srom-timing", config->timing,
-                       FDT_SROM_TIMING_COUNT);
-       if (err < 0) {
-               debug("Could not decode SROMC configuration Error: %s\n",
-                     fdt_strerror(err));
-               return -FDT_ERR_NOTFOUND;
-       }
-       return 0;
-}
-#endif
-
-int board_eth_init(struct bd_info *bis)
-{
-#ifdef CONFIG_SMC911X
-       u32 smc_bw_conf, smc_bc_conf;
-       struct fdt_sromc config;
-       fdt_addr_t base_addr;
-       int node;
-
-       node = decode_sromc(gd->fdt_blob, &config);
-       if (node < 0) {
-               debug("%s: Could not find sromc configuration\n", __func__);
-               return 0;
-       }
-       node = fdtdec_next_compatible(gd->fdt_blob, node, COMPAT_SMSC_LAN9215);
-       if (node < 0) {
-               debug("%s: Could not find lan9215 configuration\n", __func__);
-               return 0;
-       }
-
-       /* We now have a node, so any problems from now on are errors */
-       base_addr = fdtdec_get_addr(gd->fdt_blob, node, "reg");
-       if (base_addr == FDT_ADDR_T_NONE) {
-               debug("%s: Could not find lan9215 address\n", __func__);
-               return -1;
-       }
-
-       /* Ethernet needs data bus width of 16 bits */
-       if (config.width != 2) {
-               debug("%s: Unsupported bus width %d\n", __func__,
-                     config.width);
-               return -1;
-       }
-       smc_bw_conf = SROMC_DATA16_WIDTH(config.bank)
-                       | SROMC_BYTE_ENABLE(config.bank);
-
-       smc_bc_conf = SROMC_BC_TACS(config.timing[FDT_SROM_TACS])   |
-                       SROMC_BC_TCOS(config.timing[FDT_SROM_TCOS]) |
-                       SROMC_BC_TACC(config.timing[FDT_SROM_TACC]) |
-                       SROMC_BC_TCOH(config.timing[FDT_SROM_TCOH]) |
-                       SROMC_BC_TAH(config.timing[FDT_SROM_TAH])   |
-                       SROMC_BC_TACP(config.timing[FDT_SROM_TACP]) |
-                       SROMC_BC_PMC(config.timing[FDT_SROM_PMC]);
-
-       /* Select and configure the SROMC bank */
-       exynos_pinmux_config(PERIPH_ID_SROMC, config.bank);
-       s5p_config_sromc(config.bank, smc_bw_conf, smc_bc_conf);
-       return smc911x_initialize(0, base_addr);
-#endif
-       return 0;
-}
-
 #if defined(CONFIG_DISPLAY_BOARDINFO) || defined(CONFIG_DISPLAY_BOARDINFO_LATE)
 int checkboard(void)
 {
diff --git a/board/samsung/common/sromc.c b/board/samsung/common/sromc.c
new file mode 100644 (file)
index 0000000..76e37df
--- /dev/null
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2021 Google LLC
+ */
+
+#define LOG_CATEGORY   UCLASS_ETH
+
+#include <common.h>
+#include <dm.h>
+#include <log.h>
+#include <asm/arch/pinmux.h>
+#include <asm/arch/sromc.h>
+
+enum {
+       FDT_SROM_PMC,
+       FDT_SROM_TACP,
+       FDT_SROM_TAH,
+       FDT_SROM_TCOH,
+       FDT_SROM_TACC,
+       FDT_SROM_TCOS,
+       FDT_SROM_TACS,
+
+       FDT_SROM_TIMING_COUNT,
+};
+
+static int exyno5_sromc_probe(struct udevice *dev)
+{
+       u32 timing[FDT_SROM_TIMING_COUNT]; /* timing parameters */
+       u32 smc_bw_conf, smc_bc_conf;
+       int bank;       /* srom bank number */
+       int width;      /* bus width in bytes */
+       int ret;
+
+       if (!IS_ENABLED(CONFIG_SMC911X))
+               return 0;
+
+       bank = dev_read_s32_default(dev, "bank", 0);
+       width = dev_read_s32_default(dev, "width", 2);
+
+       /* Ethernet needs data bus width of 16 bits */
+       if (width != 2) {
+               log_debug("Unsupported bus width %d\n", width);
+               return log_msg_ret("width", -EINVAL);
+       }
+       ret = dev_read_u32_array(dev, "srom-timing", timing,
+                                FDT_SROM_TIMING_COUNT);
+       if (ret)
+               return log_msg_ret("sromc", -EINVAL);
+
+       smc_bw_conf = SROMC_DATA16_WIDTH(bank) | SROMC_BYTE_ENABLE(bank);
+       smc_bc_conf = SROMC_BC_TACS(timing[FDT_SROM_TACS])   |
+                       SROMC_BC_TCOS(timing[FDT_SROM_TCOS]) |
+                       SROMC_BC_TACC(timing[FDT_SROM_TACC]) |
+                       SROMC_BC_TCOH(timing[FDT_SROM_TCOH]) |
+                       SROMC_BC_TAH(timing[FDT_SROM_TAH])   |
+                       SROMC_BC_TACP(timing[FDT_SROM_TACP]) |
+                       SROMC_BC_PMC(timing[FDT_SROM_PMC]);
+
+       /* Select and configure the SROMC bank */
+       exynos_pinmux_config(PERIPH_ID_SROMC, bank);
+       s5p_config_sromc(bank, smc_bw_conf, smc_bc_conf);
+
+       return 0;
+}
+
+static const struct udevice_id exyno5_sromc_ids[] = {
+       { .compatible = "samsung,exynos5-sromc" },
+       {}
+};
+
+U_BOOT_DRIVER(exyno5_sromc) = {
+       .name           = "exyno5_sromc",
+       .id             = UCLASS_SIMPLE_BUS,
+       .of_match       = exyno5_sromc_ids,
+       .probe          = exyno5_sromc_probe,
+};
index 8811cbb9ad0bb66d73f5c4b7ff015207c1e489ec..bb61ba1f81c63d87b22a2648c4ee4a90914ad2ec 100644 (file)
@@ -73,15 +73,6 @@ int dram_init_banksize(void)
        return 0;
 }
 
-int board_eth_init(struct bd_info *bis)
-{
-       int rc = 0;
-#ifdef CONFIG_SMC911X
-       rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
-#endif
-       return rc;
-}
-
 #ifdef CONFIG_DISPLAY_BOARDINFO
 int checkboard(void)
 {
index bc7af829fb8ee089c54f4ec0757b445ae03c57fe..4f4ae5f7ba430b5442be9699eebe800ad1f81d32 100644 (file)
@@ -37,7 +37,6 @@ CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_S5P=y
 CONFIG_MTD=y
 CONFIG_SMC911X=y
-CONFIG_SMC911X_BASE=0x5000000
 CONFIG_SOUND=y
 CONFIG_I2S=y
 CONFIG_I2S_SAMSUNG=y
index e0b87dfc259550bf1b767cb03acbcfdcb4974958..2351e14fc6a92fb7f19e390dd13d288990a4580d 100644 (file)
@@ -46,7 +46,6 @@ CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_DW=y
 CONFIG_MTD=y
 CONFIG_SMC911X=y
-CONFIG_SMC911X_BASE=0x5000000
 CONFIG_DM_PMIC=y
 CONFIG_PMIC_S2MPS11=y
 CONFIG_DM_REGULATOR=y
index d3fbc4eca966a15a4b2d95b7f7a6d87c5ff7e0aa..aad1ff6804f78ec0403134017c291e0f407fd925 100644 (file)
@@ -53,7 +53,6 @@ CONFIG_SF_DEFAULT_SPEED=50000000
 CONFIG_SPI_FLASH_GIGADEVICE=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SMC911X=y
-CONFIG_SMC911X_BASE=0x5000000
 CONFIG_DM_PMIC=y
 CONFIG_PMIC_TPS65090=y
 CONFIG_DM_REGULATOR=y
index d6d97a84c36f25c86a0d04921afa31c53651e538..6382419e2402bb30b1b8f6da693ece70bec89ff3 100644 (file)
@@ -52,7 +52,6 @@ CONFIG_SF_DEFAULT_SPEED=50000000
 CONFIG_SPI_FLASH_GIGADEVICE=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SMC911X=y
-CONFIG_SMC911X_BASE=0x5000000
 CONFIG_DM_PMIC=y
 CONFIG_PMIC_TPS65090=y
 CONFIG_DM_REGULATOR=y
index a2a20cf6c4c61416215d049be717bad92adb8e39..1e8f24e03f865be303ceb570c35165b0d07f6369 100644 (file)
@@ -48,7 +48,6 @@ CONFIG_SF_DEFAULT_SPEED=50000000
 CONFIG_SPI_FLASH_GIGADEVICE=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SMC911X=y
-CONFIG_SMC911X_BASE=0x5000000
 CONFIG_DM_PMIC=y
 CONFIG_DM_PMIC_MAX77686=y
 CONFIG_DM_REGULATOR=y
index 04b560a8a8047fed8d0292db2f6c708f3c69af53..a322871d5cd63c4351ca2ec27854cc9554111cf9 100644 (file)
@@ -43,7 +43,6 @@ CONFIG_SF_DEFAULT_SPEED=50000000
 CONFIG_SPI_FLASH_GIGADEVICE=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SMC911X=y
-CONFIG_SMC911X_BASE=0x5000000
 CONFIG_DM_PMIC=y
 CONFIG_DM_REGULATOR=y
 CONFIG_EXYNOS_SPI=y
index 568f95a813c98881e1a1b7b7c945dbce4849c746..6b738b47d8fd5d8aa5f9266c07968b951fe82784 100644 (file)
@@ -28,6 +28,5 @@ CONFIG_MMC_SDHCI_SDMA=y
 CONFIG_MMC_SDHCI_S5P=y
 CONFIG_MTD=y
 CONFIG_SMC911X=y
-CONFIG_SMC911X_BASE=0x5000000
 CONFIG_USB=y
 CONFIG_DM_USB=y
index cb7dabfaba61741d9a4ed8b49b98dfbc33af59db..6090fea2b8fb0004a4125d59662deaf9a3cb72aa 100644 (file)
@@ -58,7 +58,6 @@ CONFIG_SF_DEFAULT_SPEED=50000000
 CONFIG_SPI_FLASH_GIGADEVICE=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SMC911X=y
-CONFIG_SMC911X_BASE=0x5000000
 CONFIG_DM_PMIC=y
 CONFIG_DM_PMIC_MAX77686=y
 CONFIG_PMIC_S5M8767=y
index bbe5ab29a8c6593afa22048f126032b90d3f572e..d8709b59a74ad6846d19292461021eb7f0341af6 100644 (file)
@@ -58,7 +58,6 @@ CONFIG_SF_DEFAULT_SPEED=50000000
 CONFIG_SPI_FLASH_GIGADEVICE=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SMC911X=y
-CONFIG_SMC911X_BASE=0x5000000
 CONFIG_DM_PMIC=y
 CONFIG_DM_PMIC_MAX77686=y
 CONFIG_PMIC_S5M8767=y
index e0a49b1e57fbb92302af4d371f131a1c72d0da48..8ac20c9a64f754c58c252fac12862ce17976c5b5 100644 (file)
@@ -140,8 +140,6 @@ enum fdt_compat_id {
                                        /* Tegra124 XUSB pad controller */
        COMPAT_NVIDIA_TEGRA210_XUSB_PADCTL,
                                        /* Tegra210 XUSB pad controller */
-       COMPAT_SMSC_LAN9215,            /* SMSC 10/100 Ethernet LAN9215 */
-       COMPAT_SAMSUNG_EXYNOS5_SROMC,   /* Exynos5 SROMC */
        COMPAT_SAMSUNG_EXYNOS_USB_PHY,  /* Exynos phy controller for usb2.0 */
        COMPAT_SAMSUNG_EXYNOS5_USB3_PHY,/* Exynos phy controller for usb3.0 */
        COMPAT_SAMSUNG_EXYNOS_TMU,      /* Exynos TMU */
index 4b097fb588ed24ec78adc245fff6ee8cda2da368..3f178b975aea7d4dbb94d2d9de632bcfc7cde612 100644 (file)
@@ -47,8 +47,6 @@ static const char * const compat_names[COMPAT_COUNT] = {
        COMPAT(NVIDIA_TEGRA20_NAND, "nvidia,tegra20-nand"),
        COMPAT(NVIDIA_TEGRA124_XUSB_PADCTL, "nvidia,tegra124-xusb-padctl"),
        COMPAT(NVIDIA_TEGRA210_XUSB_PADCTL, "nvidia,tegra210-xusb-padctl"),
-       COMPAT(SMSC_LAN9215, "smsc,lan9215"),
-       COMPAT(SAMSUNG_EXYNOS5_SROMC, "samsung,exynos-sromc"),
        COMPAT(SAMSUNG_EXYNOS_USB_PHY, "samsung,exynos-usb-phy"),
        COMPAT(SAMSUNG_EXYNOS5_USB3_PHY, "samsung,exynos5250-usb3-phy"),
        COMPAT(SAMSUNG_EXYNOS_TMU, "samsung,exynos-tmu"),