48b0d02049194d37997d66eb1a0fd7cb8314e44d
[openwrt/staging/thess.git] /
1 From: Lorenzo Bianconi <lorenzo@kernel.org>
2 Date: Mon, 18 Sep 2023 12:29:10 +0200
3 Subject: [PATCH] net: ethernet: mtk_wed: make memory region optional
4
5 Make mtk_wed_wo_memory_region optionals.
6 This is a preliminary patch to introduce Wireless Ethernet Dispatcher
7 support for MT7988 SoC since MT7988 WED fw image will have a different
8 layout.
9
10 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
11 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
12 ---
13
14 --- a/drivers/net/ethernet/mediatek/mtk_wed_mcu.c
15 +++ b/drivers/net/ethernet/mediatek/mtk_wed_mcu.c
16 @@ -234,19 +234,13 @@ int mtk_wed_mcu_msg_update(struct mtk_we
17 }
18
19 static int
20 -mtk_wed_get_memory_region(struct mtk_wed_wo *wo,
21 +mtk_wed_get_memory_region(struct mtk_wed_hw *hw, int index,
22 struct mtk_wed_wo_memory_region *region)
23 {
24 struct reserved_mem *rmem;
25 struct device_node *np;
26 - int index;
27
28 - index = of_property_match_string(wo->hw->node, "memory-region-names",
29 - region->name);
30 - if (index < 0)
31 - return index;
32 -
33 - np = of_parse_phandle(wo->hw->node, "memory-region", index);
34 + np = of_parse_phandle(hw->node, "memory-region", index);
35 if (!np)
36 return -ENODEV;
37
38 @@ -258,7 +252,7 @@ mtk_wed_get_memory_region(struct mtk_wed
39
40 region->phy_addr = rmem->base;
41 region->size = rmem->size;
42 - region->addr = devm_ioremap(wo->hw->dev, region->phy_addr, region->size);
43 + region->addr = devm_ioremap(hw->dev, region->phy_addr, region->size);
44
45 return !region->addr ? -EINVAL : 0;
46 }
47 @@ -271,6 +265,9 @@ mtk_wed_mcu_run_firmware(struct mtk_wed_
48 const struct mtk_wed_fw_trailer *trailer;
49 const struct mtk_wed_fw_region *fw_region;
50
51 + if (!region->phy_addr || !region->size)
52 + return 0;
53 +
54 trailer_ptr = fw->data + fw->size - sizeof(*trailer);
55 trailer = (const struct mtk_wed_fw_trailer *)trailer_ptr;
56 region_ptr = trailer_ptr - trailer->num_region * sizeof(*fw_region);
57 @@ -318,7 +315,13 @@ mtk_wed_mcu_load_firmware(struct mtk_wed
58
59 /* load firmware region metadata */
60 for (i = 0; i < ARRAY_SIZE(mem_region); i++) {
61 - ret = mtk_wed_get_memory_region(wo, &mem_region[i]);
62 + int index = of_property_match_string(wo->hw->node,
63 + "memory-region-names",
64 + mem_region[i].name);
65 + if (index < 0)
66 + continue;
67 +
68 + ret = mtk_wed_get_memory_region(wo->hw, index, &mem_region[i]);
69 if (ret)
70 return ret;
71 }