diff options
author | Tom Rini <trini@konsulko.com> | 2024-04-15 07:39:14 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-04-15 07:39:14 -0600 |
commit | 6e316e3f397b5e01e98c5dd56cdbaab961daeedf (patch) | |
tree | 0e8293a905ca3233da6a9c9c22b340373b19b1c2 | |
parent | db972665794f38c7bf224d69f6a6206a4083d85d (diff) | |
parent | 8ecb0931940cc19728d686b9dba06585f4d93709 (diff) | |
download | u-boot-WIP/15Apr2024.zip u-boot-WIP/15Apr2024.tar.gz u-boot-WIP/15Apr2024.tar.bz2 |
Merge tag 'u-boot-imx-master-20240415' of https://gitlab.denx.de/u-boot/custodians/u-boot-imxWIP/15Apr2024
CI:
https://source.denx.de/u-boot/custodians/u-boot-imx/-/pipelines/20348
- Update the imx_rgpio2p to only access one address as per the
dt-schema.
- Remove unused imx9_cpu.c file.
- Only use the LPUART ipg clk for i.MX7ULP.
- Use the correct anatop base for accessing the PLL clocks on i.MX93.
-rw-r--r-- | drivers/clk/imx/clk-imx93.c | 2 | ||||
-rw-r--r-- | drivers/cpu/imx9_cpu.c | 224 | ||||
-rw-r--r-- | drivers/gpio/imx_rgpio2p.c | 42 | ||||
-rw-r--r-- | drivers/serial/serial_lpuart.c | 42 |
4 files changed, 65 insertions, 245 deletions
diff --git a/drivers/clk/imx/clk-imx93.c b/drivers/clk/imx/clk-imx93.c index ce10d79..f0cb797 100644 --- a/drivers/clk/imx/clk-imx93.c +++ b/drivers/clk/imx/clk-imx93.c @@ -289,7 +289,7 @@ static int imx93_clk_probe(struct udevice *dev) clk_dm(IMX93_CLK_SYS_PLL_PFD2_DIV2, imx_clk_fixed_factor("sys_pll_pfd2_div2", "sys_pll_pfd2", 1, 2)); - base = (void *)ANATOP_BASE_ADDR; + anatop_base = (void *)ANATOP_BASE_ADDR; clk_dm(IMX93_CLK_ARM_PLL, imx_clk_fracn_gppll_integer("arm_pll", "clock-osc-24m", diff --git a/drivers/cpu/imx9_cpu.c b/drivers/cpu/imx9_cpu.c deleted file mode 100644 index 66534fe..0000000 --- a/drivers/cpu/imx9_cpu.c +++ /dev/null @@ -1,224 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright 2019 NXP - */ - -#include <common.h> -#include <cpu.h> -#include <dm.h> -#include <thermal.h> -#include <asm/global_data.h> -#include <asm/system.h> -#include <firmware/linux/imx/sci/sci.h> -#include <asm/arch/sys_proto.h> -#include <asm/arch-imx/cpu.h> -#include <asm/armv8/cpu.h> -#include <linux/bitops.h> - -DECLARE_GLOBAL_DATA_PTR; - -struct cpu_imx_plat { - const char *name; - const char *rev; - const char *type; - u32 cpu_rsrc; - u32 cpurev; - u32 freq_mhz; - u32 mpidr; -}; - -const char *get_imx9_type(u32 imxtype) -{ - switch (imxtype) { - case MXC_CPU_IMX93: - return "93"; - default: - return "??"; - } -} - -const char *get_imx9_rev(u32 rev) -{ - switch (rev) { - case CHIP_REV_1_0: - return "1."; - case CHIP_REV_B: - return "B"; - case CHIP_REV_C: - return "C"; - default: - return "?"; - } -} - -static void set_core_data(struct udevice *dev) -{ - struct cpu_imx_plat *plat = dev_get_plat(dev); - - if (device_is_compatible(dev, "arm,cortex-a35")) - plat->name = "A35"; - else - plat->name = "?"; -} - -#if IS_ENABLED(CONFIG_IMX_SCU_THERMAL) -static int cpu_imx_get_temp(struct cpu_imx_plat *plat) -{ - struct udevice *thermal_dev; - int cpu_tmp, ret; - int idx = 1; /* use "cpu-thermal0" device */ - - if (plat->cpu_rsrc == SC_R_A72) - idx = 2; /* use "cpu-thermal1" device */ - - ret = uclass_get_device(UCLASS_THERMAL, idx, &thermal_dev); - if (!ret) { - ret = thermal_get_temp(thermal_dev, &cpu_tmp); - if (ret) - return 0xdeadbeef; - } else { - return 0xdeadbeef; - } - - return cpu_tmp; -} -#else -static int cpu_imx_get_temp(struct cpu_imx_plat *plat) -{ - return 0; -} -#endif - -int cpu_imx_get_desc(const struct udevice *dev, char *buf, int size) -{ - struct cpu_imx_plat *plat = dev_get_plat(dev); - int ret, temp; - - if (size < 100) - return -ENOSPC; - - ret = snprintf(buf, size, "NXP i.MX8%s Rev%s %s at %u MHz", - plat->type, plat->rev, plat->name, plat->freq_mhz); - - if (IS_ENABLED(CONFIG_IMX_SCU_THERMAL)) { - temp = cpu_imx_get_temp(plat); - buf = buf + ret; - size = size - ret; - if (temp != 0xdeadbeef) - ret = snprintf(buf, size, " at %dC", temp); - else - ret = snprintf(buf, size, " - invalid sensor data"); - } - - snprintf(buf + ret, size - ret, "\n"); - - return 0; -} - -static int cpu_imx_get_info(const struct udevice *dev, struct cpu_info *info) -{ - struct cpu_imx_plat *plat = dev_get_plat(dev); - - info->cpu_freq = plat->freq_mhz * 1000; - info->features = BIT(CPU_FEAT_L1_CACHE) | BIT(CPU_FEAT_MMU); - return 0; -} - -static int cpu_imx_get_count(const struct udevice *dev) -{ - ofnode node; - int num = 0; - - ofnode_for_each_subnode(node, dev_ofnode(dev->parent)) { - const char *device_type; - - if (!ofnode_is_enabled(node)) - continue; - - device_type = ofnode_read_string(node, "device_type"); - if (!device_type) - continue; - - if (!strcmp(device_type, "cpu")) - num++; - } - - return num; -} - -static int cpu_imx_get_vendor(const struct udevice *dev, char *buf, int size) -{ - snprintf(buf, size, "NXP"); - return 0; -} - -static int cpu_imx_is_current(struct udevice *dev) -{ - struct cpu_imx_plat *plat = dev_get_plat(dev); - - if (plat->mpidr == (read_mpidr() & 0xffff)) - return 1; - - return 0; -} - -static const struct cpu_ops cpu_imx9_ops = { - .get_desc = cpu_imx_get_desc, - .get_info = cpu_imx_get_info, - .get_count = cpu_imx_get_count, - .get_vendor = cpu_imx_get_vendor, - .is_current = cpu_imx_is_current, -}; - -static const struct udevice_id cpu_imx9_ids[] = { - { .compatible = "arm,cortex-a35" }, - { .compatible = "arm,cortex-a53" }, - { .compatible = "arm,cortex-a72" }, - { } -}; - -static ulong imx9_get_cpu_rate(struct udevice *dev) -{ - struct cpu_imx_plat *plat = dev_get_plat(dev); - ulong rate; - int ret; - - ret = sc_pm_get_clock_rate(-1, plat->cpu_rsrc, SC_PM_CLK_CPU, - (sc_pm_clock_rate_t *)&rate); - if (ret) { - printf("Could not read CPU frequency: %d\n", ret); - return 0; - } - - return rate; -} - -static int imx9_cpu_probe(struct udevice *dev) -{ - struct cpu_imx_plat *plat = dev_get_plat(dev); - u32 cpurev; - - set_core_data(dev); - cpurev = get_cpu_rev(); - plat->cpurev = cpurev; - plat->rev = get_imx9_rev(cpurev & 0xFFF); - plat->type = get_imx9_type((cpurev & 0xFF000) >> 12); - plat->freq_mhz = imx9_get_cpu_rate(dev) / 1000000; - plat->mpidr = dev_read_addr(dev); - if (plat->mpidr == FDT_ADDR_T_NONE) { - printf("%s: Failed to get CPU reg property\n", __func__); - return -EINVAL; - } - - return 0; -} - -U_BOOT_DRIVER(cpu_imx9_drv) = { - .name = "imx9x_cpu", - .id = UCLASS_CPU, - .of_match = cpu_imx9_ids, - .ops = &cpu_imx9_ops, - .probe = imx9_cpu_probe, - .plat_auto = sizeof(struct cpu_imx_plat), - .flags = DM_FLAG_PRE_RELOC, -}; diff --git a/drivers/gpio/imx_rgpio2p.c b/drivers/gpio/imx_rgpio2p.c index 175e460..3227a8d 100644 --- a/drivers/gpio/imx_rgpio2p.c +++ b/drivers/gpio/imx_rgpio2p.c @@ -21,6 +21,12 @@ enum imx_rgpio2p_direction { #define GPIO_PER_BANK 32 +struct imx_rgpio2p_soc_data { + bool have_dual_base; +}; + +#define IMX8ULP_GPIO_BASE_OFF 0x40 + struct imx_rgpio2p_data { struct gpio_regs *regs; }; @@ -165,6 +171,9 @@ static int imx_rgpio2p_probe(struct udevice *dev) static int imx_rgpio2p_bind(struct udevice *dev) { struct imx_rgpio2p_plat *plat = dev_get_plat(dev); + struct imx_rgpio2p_soc_data *data = + (struct imx_rgpio2p_soc_data *)dev_get_driver_data(dev); + bool dual_base = data->have_dual_base; fdt_addr_t addr; /* @@ -176,9 +185,26 @@ static int imx_rgpio2p_bind(struct udevice *dev) if (plat) return 0; - addr = devfdt_get_addr_index(dev, 1); - if (addr == FDT_ADDR_T_NONE) - return -EINVAL; + /* + * Handle legacy compatible combinations which used two reg values + * for the i.MX8ULP and i.MX93. + */ + if (device_is_compatible(dev, "fsl,imx7ulp-gpio") && + (device_is_compatible(dev, "fsl,imx93-gpio") || + (device_is_compatible(dev, "fsl,imx8ulp-gpio")))) + dual_base = true; + + if (dual_base) { + addr = devfdt_get_addr_index(dev, 1); + if (addr == FDT_ADDR_T_NONE) + return -EINVAL; + } else { + addr = devfdt_get_addr_index(dev, 0); + if (addr == FDT_ADDR_T_NONE) + return -EINVAL; + + addr += IMX8ULP_GPIO_BASE_OFF; + } /* * TODO: @@ -202,9 +228,17 @@ static int imx_rgpio2p_bind(struct udevice *dev) return 0; } +static struct imx_rgpio2p_soc_data imx7ulp_data = { + .have_dual_base = true, +}; + +static struct imx_rgpio2p_soc_data imx8ulp_data = { + .have_dual_base = false, +}; static const struct udevice_id imx_rgpio2p_ids[] = { - { .compatible = "fsl,imx7ulp-gpio" }, + { .compatible = "fsl,imx7ulp-gpio", .data = (ulong)&imx7ulp_data }, + { .compatible = "fsl,imx8ulp-gpio", .data = (ulong)&imx8ulp_data }, { } }; diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c index ce08a6b..3f2be72 100644 --- a/drivers/serial/serial_lpuart.c +++ b/drivers/serial/serial_lpuart.c @@ -109,28 +109,35 @@ u32 __weak get_lpuart_clk(void) } #if CONFIG_IS_ENABLED(CLK) -static int get_lpuart_clk_rate(struct udevice *dev, u32 *clk) +static int get_lpuart_clk_rate(struct udevice *dev, u32 *clk_rate) { - struct clk per_clk; + struct lpuart_serial_plat *plat = dev_get_plat(dev); + struct clk clk; ulong rate; int ret; + char *name; - ret = clk_get_by_name(dev, "per", &per_clk); + if (plat->devtype == DEV_MX7ULP) + name = "ipg"; + else + name = "per"; + + ret = clk_get_by_name(dev, name, &clk); if (ret) { - dev_err(dev, "Failed to get per clk: %d\n", ret); + dev_err(dev, "Failed to get clk: %d\n", ret); return ret; } - rate = clk_get_rate(&per_clk); + rate = clk_get_rate(&clk); if ((long)rate <= 0) { - dev_err(dev, "Failed to get per clk rate: %ld\n", (long)rate); + dev_err(dev, "Failed to get clk rate: %ld\n", (long)rate); return ret; } - *clk = rate; + *clk_rate = rate; return 0; } #else -static inline int get_lpuart_clk_rate(struct udevice *dev, u32 *clk) +static inline int get_lpuart_clk_rate(struct udevice *dev, u32 *clk_rate) { return -ENOSYS; } #endif @@ -479,19 +486,22 @@ static int lpuart_serial_pending(struct udevice *dev, bool input) static int lpuart_serial_probe(struct udevice *dev) { #if CONFIG_IS_ENABLED(CLK) + struct lpuart_serial_plat *plat = dev_get_plat(dev); struct clk per_clk; struct clk ipg_clk; int ret; - ret = clk_get_by_name(dev, "per", &per_clk); - if (!ret) { - ret = clk_enable(&per_clk); - if (ret) { - dev_err(dev, "Failed to enable per clk: %d\n", ret); - return ret; + if (plat->devtype != DEV_MX7ULP) { + ret = clk_get_by_name(dev, "per", &per_clk); + if (!ret) { + ret = clk_enable(&per_clk); + if (ret) { + dev_err(dev, "Failed to enable per clk: %d\n", ret); + return ret; + } + } else { + debug("%s: Failed to get per clk: %d\n", __func__, ret); } - } else { - debug("%s: Failed to get per clk: %d\n", __func__, ret); } ret = clk_get_by_name(dev, "ipg", &ipg_clk); |