1
1
// SPDX-License-Identifier: GPL-2.0-only
2
+ #include <linux/iommu.h>
2
3
#include <linux/platform_device.h>
3
4
#include <linux/of.h>
4
5
#include <linux/module.h>
@@ -19,6 +20,8 @@ struct tegra_mgbe {
19
20
struct reset_control * rst_mac ;
20
21
struct reset_control * rst_pcs ;
21
22
23
+ u32 iommu_sid ;
24
+
22
25
void __iomem * hv ;
23
26
void __iomem * regs ;
24
27
void __iomem * xpcs ;
@@ -50,7 +53,6 @@ struct tegra_mgbe {
50
53
#define MGBE_WRAP_COMMON_INTR_ENABLE 0x8704
51
54
#define MAC_SBD_INTR BIT(2)
52
55
#define MGBE_WRAP_AXI_ASID0_CTRL 0x8400
53
- #define MGBE_SID 0x6
54
56
55
57
static int __maybe_unused tegra_mgbe_suspend (struct device * dev )
56
58
{
@@ -84,7 +86,7 @@ static int __maybe_unused tegra_mgbe_resume(struct device *dev)
84
86
writel (MAC_SBD_INTR , mgbe -> regs + MGBE_WRAP_COMMON_INTR_ENABLE );
85
87
86
88
/* Program SID */
87
- writel (MGBE_SID , mgbe -> hv + MGBE_WRAP_AXI_ASID0_CTRL );
89
+ writel (mgbe -> iommu_sid , mgbe -> hv + MGBE_WRAP_AXI_ASID0_CTRL );
88
90
89
91
value = readl (mgbe -> xpcs + XPCS_WRAP_UPHY_STATUS );
90
92
if ((value & XPCS_WRAP_UPHY_STATUS_TX_P_UP ) == 0 ) {
@@ -241,6 +243,12 @@ static int tegra_mgbe_probe(struct platform_device *pdev)
241
243
if (IS_ERR (mgbe -> xpcs ))
242
244
return PTR_ERR (mgbe -> xpcs );
243
245
246
+ /* get controller's stream id from iommu property in device tree */
247
+ if (!tegra_dev_iommu_get_stream_id (mgbe -> dev , & mgbe -> iommu_sid )) {
248
+ dev_err (mgbe -> dev , "failed to get iommu stream id\n" );
249
+ return - EINVAL ;
250
+ }
251
+
244
252
res .addr = mgbe -> regs ;
245
253
res .irq = irq ;
246
254
@@ -346,7 +354,7 @@ static int tegra_mgbe_probe(struct platform_device *pdev)
346
354
writel (MAC_SBD_INTR , mgbe -> regs + MGBE_WRAP_COMMON_INTR_ENABLE );
347
355
348
356
/* Program SID */
349
- writel (MGBE_SID , mgbe -> hv + MGBE_WRAP_AXI_ASID0_CTRL );
357
+ writel (mgbe -> iommu_sid , mgbe -> hv + MGBE_WRAP_AXI_ASID0_CTRL );
350
358
351
359
plat -> flags |= STMMAC_FLAG_SERDES_UP_AFTER_PHY_LINKUP ;
352
360
0 commit comments