8e7c8233e224ffe8a4f92cb2318509ba3edeb180
[openwrt/staging/wigyori.git] /
1 From 998f0633773b3432829fe45d2cd2ffb842f3c78e Mon Sep 17 00:00:00 2001
2 From: William-tw Lin <william-tw.lin@mediatek.com>
3 Date: Sat, 24 Feb 2024 11:45:07 +0000
4 Subject: [PATCH] nvmem: mtk-efuse: Register MediaTek socinfo driver from efuse
5
6 The socinfo driver reads chip information from eFuses and does not need
7 any devicetree node. Register it from mtk-efuse.
8
9 While at it, also add the name for this driver's nvmem_config.
10
11 Signed-off-by: William-tw Lin <william-tw.lin@mediatek.com>
12 Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
13 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
14 Link: https://lore.kernel.org/r/20240224114516.86365-3-srinivas.kandagatla@linaro.org
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
16 ---
17 drivers/nvmem/mtk-efuse.c | 21 ++++++++++++++++++++-
18 1 file changed, 20 insertions(+), 1 deletion(-)
19
20 --- a/drivers/nvmem/mtk-efuse.c
21 +++ b/drivers/nvmem/mtk-efuse.c
22 @@ -68,6 +68,7 @@ static int mtk_efuse_probe(struct platfo
23 struct nvmem_config econfig = {};
24 struct mtk_efuse_priv *priv;
25 const struct mtk_efuse_pdata *pdata;
26 + struct platform_device *socinfo;
27
28 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
29 if (!priv)
30 @@ -85,11 +86,20 @@ static int mtk_efuse_probe(struct platfo
31 econfig.size = resource_size(res);
32 econfig.priv = priv;
33 econfig.dev = dev;
34 + econfig.name = "mtk-efuse";
35 if (pdata->uses_post_processing)
36 econfig.fixup_dt_cell_info = &mtk_efuse_fixup_dt_cell_info;
37 nvmem = devm_nvmem_register(dev, &econfig);
38 + if (IS_ERR(nvmem))
39 + return PTR_ERR(nvmem);
40
41 - return PTR_ERR_OR_ZERO(nvmem);
42 + socinfo = platform_device_register_data(&pdev->dev, "mtk-socinfo",
43 + PLATFORM_DEVID_AUTO, NULL, 0);
44 + if (IS_ERR(socinfo))
45 + dev_info(dev, "MediaTek SoC Information will be unavailable\n");
46 +
47 + platform_set_drvdata(pdev, socinfo);
48 + return 0;
49 }
50
51 static const struct mtk_efuse_pdata mtk_mt8186_efuse_pdata = {
52 @@ -108,8 +118,17 @@ static const struct of_device_id mtk_efu
53 };
54 MODULE_DEVICE_TABLE(of, mtk_efuse_of_match);
55
56 +static void mtk_efuse_remove(struct platform_device *pdev)
57 +{
58 + struct platform_device *socinfo = platform_get_drvdata(pdev);
59 +
60 + if (!IS_ERR_OR_NULL(socinfo))
61 + platform_device_unregister(socinfo);
62 +}
63 +
64 static struct platform_driver mtk_efuse_driver = {
65 .probe = mtk_efuse_probe,
66 + .remove_new = mtk_efuse_remove,
67 .driver = {
68 .name = "mediatek,efuse",
69 .of_match_table = mtk_efuse_of_match,