Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: Add VIA/WonderMedia SoC identification driver

Add a small SOC bus driver to parse the chip ID and revision made
available on VIA/WonderMedia SoCs via their system configuration
controller's SCC_ID register.

This is intended to select appropriate sets of on-chip device quirks
at runtime, as it has been found that even within the same SoC
version there can be register-incompatible differences, such as
with the SDMMC controller on WM8505 rev. A0-A1 vs. rev. A2.

The list of SoC versions is compiled from various vendor source dumps
and not all of them have corresponding mainline driver support.
Some of them also have been seen with varying on-chip markings while
sharing the same hardware chip ID's (as is the case with e.g. WM8850
vs. WM8950). In such cases the selection of names to use here among
those seen in various source dumps and chip markings was arbitrary.

Suggested by Krzysztof at [1] - thanks a lot!

[1] https://lore.kernel.org/all/14de236b-e2a7-4bde-986d-1e5ffddd01b4@kernel.org/

Signed-off-by: Alexey Charkov <alchark@gmail.com>
Link: https://lore.kernel.org/r/20250503-wmt-soc-driver-v3-2-2daa9056fa10@gmail.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

authored by

Alexey Charkov and committed by
Krzysztof Kozlowski
96f94587 04e394d6

+148
+1
drivers/soc/Kconfig
··· 28 28 source "drivers/soc/ti/Kconfig" 29 29 source "drivers/soc/ux500/Kconfig" 30 30 source "drivers/soc/versatile/Kconfig" 31 + source "drivers/soc/vt8500/Kconfig" 31 32 source "drivers/soc/xilinx/Kconfig" 32 33 33 34 endmenu
+1
drivers/soc/Makefile
··· 34 34 obj-y += ti/ 35 35 obj-$(CONFIG_ARCH_U8500) += ux500/ 36 36 obj-y += versatile/ 37 + obj-y += vt8500/ 37 38 obj-y += xilinx/
+19
drivers/soc/vt8500/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + 3 + if ARCH_VT8500 || COMPILE_TEST 4 + 5 + menu "VIA/WonderMedia SoC drivers" 6 + 7 + config WMT_SOCINFO 8 + bool "VIA/WonderMedia SoC Information driver" 9 + default ARCH_VT8500 10 + select SOC_BUS 11 + help 12 + Say yes to support decoding of VIA/WonderMedia system configuration 13 + register information. This currently includes just the chip ID register 14 + which helps identify the exact hardware revision of the SoC the kernel 15 + is running on (to know if any revision-specific quirks are required) 16 + 17 + endmenu 18 + 19 + endif
+2
drivers/soc/vt8500/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + obj-$(CONFIG_WMT_SOCINFO) += wmt-socinfo.o
+125
drivers/soc/vt8500/wmt-socinfo.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * Copyright 2025 Alexey Charkov <alchark@gmail.com> 4 + * Based on aspeed-socinfo.c 5 + */ 6 + 7 + #include <linux/dev_printk.h> 8 + #include <linux/device.h> 9 + #include <linux/io.h> 10 + #include <linux/of.h> 11 + #include <linux/platform_device.h> 12 + #include <linux/sys_soc.h> 13 + 14 + static const struct { 15 + const char *name; 16 + const u32 id; 17 + } chip_id_table[] = { 18 + /* VIA */ 19 + { "VT8420", 0x3300 }, 20 + { "VT8430", 0x3357 }, 21 + { "VT8500", 0x3400 }, 22 + 23 + /* WonderMedia */ 24 + { "WM8425", 0x3429 }, 25 + { "WM8435", 0x3437 }, 26 + { "WM8440", 0x3451 }, 27 + { "WM8505", 0x3426 }, 28 + { "WM8650", 0x3465 }, 29 + { "WM8750", 0x3445 }, 30 + { "WM8850", 0x3481 }, 31 + { "WM8880", 0x3498 }, 32 + }; 33 + 34 + static const char *sccid_to_name(u32 sccid) 35 + { 36 + u32 id = sccid >> 16; 37 + unsigned int i; 38 + 39 + for (i = 0 ; i < ARRAY_SIZE(chip_id_table) ; ++i) { 40 + if (chip_id_table[i].id == id) 41 + return chip_id_table[i].name; 42 + } 43 + 44 + return "Unknown"; 45 + } 46 + 47 + static int wmt_socinfo_probe(struct platform_device *pdev) 48 + { 49 + struct device_node *np = pdev->dev.of_node; 50 + struct soc_device_attribute *attrs; 51 + struct soc_device *soc_dev; 52 + char letter, digit; 53 + void __iomem *reg; 54 + u32 sccid; 55 + 56 + reg = devm_of_iomap(&pdev->dev, np, 0, NULL); 57 + if (IS_ERR(reg)) 58 + return PTR_ERR(reg); 59 + 60 + sccid = readl(reg); 61 + 62 + attrs = devm_kzalloc(&pdev->dev, sizeof(*attrs), GFP_KERNEL); 63 + if (!attrs) 64 + return -ENOMEM; 65 + 66 + /* 67 + * Machine: VIA APC Rock 68 + * Family: WM8850 69 + * Revision: A2 70 + * SoC ID: raw silicon revision id (34810103 in hexadecimal) 71 + */ 72 + 73 + attrs->family = sccid_to_name(sccid); 74 + 75 + letter = (sccid >> 8) & 0xf; 76 + letter = (letter - 1) + 'A'; 77 + digit = sccid & 0xff; 78 + digit = (digit - 1) + '0'; 79 + attrs->revision = devm_kasprintf(&pdev->dev, GFP_KERNEL, 80 + "%c%c", letter, digit); 81 + 82 + attrs->soc_id = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%08x", sccid); 83 + 84 + if (!attrs->revision || !attrs->soc_id) 85 + return -ENOMEM; 86 + 87 + soc_dev = soc_device_register(attrs); 88 + if (IS_ERR(soc_dev)) 89 + return PTR_ERR(soc_dev); 90 + 91 + dev_info(&pdev->dev, 92 + "VIA/WonderMedia %s rev %s (%s)\n", 93 + attrs->family, 94 + attrs->revision, 95 + attrs->soc_id); 96 + 97 + platform_set_drvdata(pdev, soc_dev); 98 + return 0; 99 + } 100 + 101 + static void wmt_socinfo_remove(struct platform_device *pdev) 102 + { 103 + struct soc_device *soc_dev = platform_get_drvdata(pdev); 104 + 105 + soc_device_unregister(soc_dev); 106 + } 107 + 108 + static const struct of_device_id wmt_socinfo_ids[] = { 109 + { .compatible = "via,vt8500-scc-id" }, 110 + { /* Sentinel */ }, 111 + }; 112 + 113 + static struct platform_driver wmt_socinfo = { 114 + .probe = wmt_socinfo_probe, 115 + .remove = wmt_socinfo_remove, 116 + .driver = { 117 + .name = "wmt-socinfo", 118 + .of_match_table = wmt_socinfo_ids, 119 + }, 120 + }; 121 + module_platform_driver(wmt_socinfo); 122 + 123 + MODULE_AUTHOR("Alexey Charkov <alchark@gmail.com>"); 124 + MODULE_DESCRIPTION("VIA/WonderMedia socinfo driver"); 125 + MODULE_LICENSE("GPL");