From: Clément Léger <[email protected]> Remove the kvx SoC info driver.
Signed-off-by: Clément Léger <[email protected]> --- Documentation/gen_magicvars.py | 19 ---- drivers/soc/Kconfig | 1 - drivers/soc/Makefile | 1 - drivers/soc/kvx/Kconfig | 10 -- drivers/soc/kvx/Makefile | 1 - drivers/soc/kvx/kvx_socinfo.c | 178 --------------------------------- 6 files changed, 210 deletions(-) delete mode 100644 drivers/soc/kvx/Kconfig delete mode 100644 drivers/soc/kvx/Makefile delete mode 100644 drivers/soc/kvx/kvx_socinfo.c diff --git a/Documentation/gen_magicvars.py b/Documentation/gen_magicvars.py index e2bb020360..142e770c10 100755 --- a/Documentation/gen_magicvars.py +++ b/Documentation/gen_magicvars.py @@ -13,12 +13,6 @@ MAGICVAR_CONT = re.compile(r'(.*?)"\s*\)') UNESCAPE = re.compile(r'''\\(["\\])''') -# Global override dictionary to map directories to specific arch or board -DIRECTORY_OVERRIDES = { - 'drivers/soc/kvx': {'arch': 'kvx'}, -} - - def string_unescape(s): return re.sub(UNESCAPE, r'\1', s.replace(r'\t', '').replace(r'\n', '')) @@ -81,19 +75,6 @@ def categorize_file(filepath): arch = None board = None - # Check for directory overrides first - for override_path, override_spec in DIRECTORY_OVERRIDES.items(): - override_parts = override_path.split('/') - # Check if the filepath starts with the override path - if len(parts) >= len(override_parts): - if all(parts[i] == override_parts[i] for i in range(len(override_parts))): - # This file matches the override path - if 'arch' in override_spec: - arch = override_spec['arch'] - if 'board' in override_spec: - board = override_spec['board'] - return arch, board - # Check for arch if 'arch' in parts: arch_idx = parts.index('arch') diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index cbde3c35a4..1fc0efbb3b 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -1,7 +1,6 @@ menu "SoC drivers" source "drivers/soc/imx/Kconfig" -source "drivers/soc/kvx/Kconfig" source "drivers/soc/rockchip/Kconfig" source "drivers/soc/ti/Kconfig" diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 975304cd50..abe9c38d03 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -1,7 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_ARCH_IMX) += imx/ -obj-$(CONFIG_KVX) += kvx/ obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/ obj-$(CONFIG_CPU_SIFIVE) += sifive/ obj-$(CONFIG_SOC_STARFIVE) += starfive/ diff --git a/drivers/soc/kvx/Kconfig b/drivers/soc/kvx/Kconfig deleted file mode 100644 index 18dcb8ba14..0000000000 --- a/drivers/soc/kvx/Kconfig +++ /dev/null @@ -1,10 +0,0 @@ -menu "KVX SoC drivers" - -config KVX_SOCINFO - bool "KVX SoC Info driver" - depends on KVX - select NVMEM - select KVX_OTP_NV - default y - -endmenu diff --git a/drivers/soc/kvx/Makefile b/drivers/soc/kvx/Makefile deleted file mode 100644 index cacfef21a1..0000000000 --- a/drivers/soc/kvx/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-$(CONFIG_KVX_SOCINFO) += kvx_socinfo.o diff --git a/drivers/soc/kvx/kvx_socinfo.c b/drivers/soc/kvx/kvx_socinfo.c deleted file mode 100644 index 9b85af6464..0000000000 --- a/drivers/soc/kvx/kvx_socinfo.c +++ /dev/null @@ -1,178 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright (C) 2020 Kalray Inc., Clément Léger - */ - -#define pr_fmt(fmt) "kvx_socinfo: " fmt - -#include <init.h> -#include <driver.h> -#include <globalvar.h> -#include <magicvar.h> -#include <command.h> -#include <libfile.h> -#include <getopt.h> -#include <common.h> -#include <fs.h> - -#include <asm/sfr.h> - -#include <linux/kernel.h> -#include <linux/nvmem-consumer.h> - -#define LOT_ID_STR_LEN 8 - -#define EWS_LOT_ID_MASK 0x3ffffffffffULL -#define EWS_WAFER_ID_SHIFT 42 -#define EWS_WAFER_ID_MASK 0x1fULL - -#define FT_COM_AP_SHIFT 16 -#define FT_COM_AP_MASK 0x3f -#define FT_DEVICE_ID_SHIFT 22 -#define FT_DEVICE_ID_MASK 0x1ff - -static char *kvx_mppa_id; -static char *kvx_arch_rev; -static char *kvx_board_sn; - -BAREBOX_MAGICVAR(global.kvx.arch_rev, "KVX architecture revision"); -BAREBOX_MAGICVAR(global.kvx.mppa_id, "KVX MPPA chip id"); -BAREBOX_MAGICVAR(global.kvx.board_sn, "KVX board sn"); - -static void kvx_soc_info_read_revision(void) -{ - u64 pcr = kvx_sfr_get(PCR); - u8 sv = kvx_sfr_field_val(pcr, PCR, SV); - u8 car = kvx_sfr_field_val(pcr, PCR, CAR); - const char *car_str = "", *ver_str = ""; - - switch (sv) { - case 0: - case 1: - car_str = "kv3"; - break; - } - - switch (car) { - case 0: - ver_str = "1"; - break; - case 1: - ver_str = "2"; - break; - } - - kvx_arch_rev = basprintf("%s-%s", car_str, ver_str); - - globalvar_add_simple_string("kvx.arch_rev", &kvx_arch_rev); -} - -static int base38_decode(char *s, u64 val, int nb_char) -{ - int i; - const char alphabet[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_"; - const int base = sizeof(alphabet); - - if (s == NULL) - return -1; - - for (i = 0; i < nb_char; i++) { - s[i] = alphabet[val % base]; - val /= base; - } - - return 0; -} - -static int kvx_read_mppa_id(struct device_node *socinfo) -{ - char lot_id[LOT_ID_STR_LEN + 1] = ""; - char com_ap; - u64 *cell_val64; - u64 ews_val; - u32 *cell_val32; - u32 ft_val; - u8 wafer_id; - u16 device_id; - - cell_val64 = (u64 *) nvmem_cell_get_and_read(socinfo, "ews_fuse", 8); - if (IS_ERR(cell_val64)) { - pr_debug("Fail to read ews_fuse\n"); - return PTR_ERR(cell_val64); - } - - ews_val = *cell_val64; -#ifdef CONFIG_ARCH_COOLIDGE_V1 - /* On kv3-1, 32b regs on traceability are written in reverse order */ - ews_val = (ews_val >> 32) | (ews_val << 32); -#endif - wafer_id = (ews_val >> EWS_WAFER_ID_SHIFT) & EWS_WAFER_ID_MASK; - base38_decode(lot_id, ews_val & EWS_LOT_ID_MASK, LOT_ID_STR_LEN); - free(cell_val64); - - cell_val32 = (u32 *) nvmem_cell_get_and_read(socinfo, "ft_fuse", 4); - if (IS_ERR(cell_val32)) { - pr_debug("Fail to read ft_fuse\n"); - return PTR_ERR(cell_val32); - } - - ft_val = *cell_val32; - device_id = (ft_val >> FT_DEVICE_ID_SHIFT) & FT_DEVICE_ID_MASK; - base38_decode(&com_ap, (ft_val >> FT_COM_AP_SHIFT) & FT_COM_AP_MASK, 1); - free(cell_val32); - - kvx_mppa_id = basprintf("%sA-%dE-%03d", lot_id, wafer_id, device_id); - - globalvar_add_simple_string("kvx.mppa_id", &kvx_mppa_id); - - return 0; -} - -static int kvx_read_board_sn(struct device_node *socinfo) -{ - struct nvmem_cell *cell; - size_t len; - char *sn; - - cell = of_nvmem_cell_get(socinfo, "board_sn"); - if (IS_ERR(cell)) { - pr_debug("Fail to get board_sn cell\n"); - return PTR_ERR(cell); - } - - sn = nvmem_cell_read(cell, &len); - nvmem_cell_put(cell); - if (IS_ERR(sn)) { - pr_debug("Fail to read board_sn\n"); - return PTR_ERR(sn); - } - - kvx_board_sn = xzalloc(len + 1); - memcpy(kvx_board_sn, sn, len); - globalvar_add_simple_string("kvx.board_sn", &kvx_board_sn); - free(sn); - - return 0; -} - -static int kvx_socinfo_probe(struct device *dev) -{ - kvx_soc_info_read_revision(); - - kvx_read_board_sn(dev->device_node); - - return kvx_read_mppa_id(dev->device_node); -} - -static const struct of_device_id kvx_socinfo_dt_ids[] = { - { .compatible = "kalray,kvx-socinfo" }, - { } -}; -MODULE_DEVICE_TABLE(of, kvx_socinfo_dt_ids); - -static struct driver kvx_socinfo_driver = { - .name = "kvx-socinfo", - .probe = kvx_socinfo_probe, - .of_compatible = DRV_OF_COMPAT(kvx_socinfo_dt_ids), -}; -coredevice_platform_driver(kvx_socinfo_driver); -- 2.55.0
