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
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
10 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
11 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
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
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)
24 struct reserved_mem *rmem;
25 struct device_node *np;
28 - index = of_property_match_string(wo->hw->node, "memory-region-names",
33 - np = of_parse_phandle(wo->hw->node, "memory-region", index);
34 + np = of_parse_phandle(hw->node, "memory-region", index);
38 @@ -258,7 +252,7 @@ mtk_wed_get_memory_region(struct mtk_wed
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);
45 return !region->addr ? -EINVAL : 0;
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;
51 + if (!region->phy_addr || !region->size)
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
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);
68 + ret = mtk_wed_get_memory_region(wo->hw, index, &mem_region[i]);