Skip to content

Commit ec2da07

Browse files
YongWu-HFjoergroedel
authored andcommitted
memory: mtk-smi: Get rid of need_larbid
The "mediatek,larb-id" has already been parsed in MTK IOMMU driver. It's no need to parse it again in SMI driver. Only clean some codes. This patch is fit for all the current mt2701, mt2712, mt7623, mt8173 and mt8183. After this patch, the "mediatek,larb-id" only be needed for mt2712 which have 2 M4Us. In the other SoCs, we can get the larb-id from M4U in which the larbs in the "mediatek,larbs" always are ordered. Correspondingly, the larb_nr in the "struct mtk_smi_iommu" could also be deleted. CC: Matthias Brugger <[email protected]> Signed-off-by: Yong Wu <[email protected]> Reviewed-by: Evan Green <[email protected]> Reviewed-by: Matthias Brugger <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent b9475b3 commit ec2da07

File tree

4 files changed

+2
-28
lines changed

4 files changed

+2
-28
lines changed

drivers/iommu/mtk_iommu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,6 @@ static int mtk_iommu_probe(struct platform_device *pdev)
656656
"mediatek,larbs", NULL);
657657
if (larb_nr < 0)
658658
return larb_nr;
659-
data->smi_imu.larb_nr = larb_nr;
660659

661660
for (i = 0; i < larb_nr; i++) {
662661
struct device_node *larbnode;

drivers/iommu/mtk_iommu_v1.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,6 @@ static int mtk_iommu_probe(struct platform_device *pdev)
616616
larb_nr++;
617617
}
618618

619-
data->smi_imu.larb_nr = larb_nr;
620-
621619
platform_set_drvdata(pdev, data);
622620

623621
ret = mtk_iommu_hw_init(data);

drivers/memory/mtk-smi.c

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ struct mtk_smi_common_plat {
5959
};
6060

6161
struct mtk_smi_larb_gen {
62-
bool need_larbid;
6362
int port_in_larb[MTK_LARB_NR_MAX + 1];
6463
void (*config_port)(struct device *);
6564
unsigned int larb_direct_to_common_mask;
@@ -147,18 +146,9 @@ mtk_smi_larb_bind(struct device *dev, struct device *master, void *data)
147146
struct mtk_smi_iommu *smi_iommu = data;
148147
unsigned int i;
149148

150-
if (larb->larb_gen->need_larbid) {
151-
larb->mmu = &smi_iommu->larb_imu[larb->larbid].mmu;
152-
return 0;
153-
}
154-
155-
/*
156-
* If there is no larbid property, Loop to find the corresponding
157-
* iommu information.
158-
*/
159-
for (i = 0; i < smi_iommu->larb_nr; i++) {
149+
for (i = 0; i < MTK_LARB_NR_MAX; i++) {
160150
if (dev == smi_iommu->larb_imu[i].dev) {
161-
/* The 'mmu' may be updated in iommu-attach/detach. */
151+
larb->larbid = i;
162152
larb->mmu = &smi_iommu->larb_imu[i].mmu;
163153
return 0;
164154
}
@@ -237,7 +227,6 @@ static const struct mtk_smi_larb_gen mtk_smi_larb_mt8173 = {
237227
};
238228

239229
static const struct mtk_smi_larb_gen mtk_smi_larb_mt2701 = {
240-
.need_larbid = true,
241230
.port_in_larb = {
242231
LARB0_PORT_OFFSET, LARB1_PORT_OFFSET,
243232
LARB2_PORT_OFFSET, LARB3_PORT_OFFSET
@@ -246,7 +235,6 @@ static const struct mtk_smi_larb_gen mtk_smi_larb_mt2701 = {
246235
};
247236

248237
static const struct mtk_smi_larb_gen mtk_smi_larb_mt2712 = {
249-
.need_larbid = true,
250238
.config_port = mtk_smi_larb_config_port_gen2_general,
251239
.larb_direct_to_common_mask = BIT(8) | BIT(9), /* bdpsys */
252240
};
@@ -285,7 +273,6 @@ static int mtk_smi_larb_probe(struct platform_device *pdev)
285273
struct device *dev = &pdev->dev;
286274
struct device_node *smi_node;
287275
struct platform_device *smi_pdev;
288-
int err;
289276

290277
larb = devm_kzalloc(dev, sizeof(*larb), GFP_KERNEL);
291278
if (!larb)
@@ -315,15 +302,6 @@ static int mtk_smi_larb_probe(struct platform_device *pdev)
315302
}
316303
larb->smi.dev = dev;
317304

318-
if (larb->larb_gen->need_larbid) {
319-
err = of_property_read_u32(dev->of_node, "mediatek,larb-id",
320-
&larb->larbid);
321-
if (err) {
322-
dev_err(dev, "missing larbid property\n");
323-
return err;
324-
}
325-
}
326-
327305
smi_node = of_parse_phandle(dev->of_node, "mediatek,smi", 0);
328306
if (!smi_node)
329307
return -EINVAL;

include/soc/mediatek/smi.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ struct mtk_smi_larb_iommu {
2121
};
2222

2323
struct mtk_smi_iommu {
24-
unsigned int larb_nr;
2524
struct mtk_smi_larb_iommu larb_imu[MTK_LARB_NR_MAX];
2625
};
2726

0 commit comments

Comments
 (0)