Commit 2b2ba3ec authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Paolo Abeni

net: ethernet: mtk_eth_wed: add axi bus support

Other than pcie bus, introduce support for axi bus to mtk wed driver.
Axi bus is used to connect mt7986-wmac soc chip available on mt7986
device.
Tested-by: default avatarDaniel Golle <daniel@makrotopia.org>
Co-developed-by: default avatarBo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: default avatarBo Jiao <Bo.Jiao@mediatek.com>
Co-developed-by: default avatarSujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: default avatarSujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent de84a090
...@@ -85,11 +85,31 @@ static struct mtk_wed_hw * ...@@ -85,11 +85,31 @@ static struct mtk_wed_hw *
mtk_wed_assign(struct mtk_wed_device *dev) mtk_wed_assign(struct mtk_wed_device *dev)
{ {
struct mtk_wed_hw *hw; struct mtk_wed_hw *hw;
int i;
if (dev->wlan.bus_type == MTK_WED_BUS_PCIE) {
hw = hw_list[pci_domain_nr(dev->wlan.pci_dev->bus)]; hw = hw_list[pci_domain_nr(dev->wlan.pci_dev->bus)];
if (!hw || hw->wed_dev) if (!hw)
return NULL;
if (!hw->wed_dev)
goto out;
if (hw->version == 1)
return NULL;
/* MT7986 WED devices do not have any pcie slot restrictions */
}
/* MT7986 PCIE or AXI */
for (i = 0; i < ARRAY_SIZE(hw_list); i++) {
hw = hw_list[i];
if (hw && !hw->wed_dev)
goto out;
}
return NULL; return NULL;
out:
hw->wed_dev = dev; hw->wed_dev = dev;
return hw; return hw;
} }
...@@ -322,7 +342,6 @@ mtk_wed_stop(struct mtk_wed_device *dev) ...@@ -322,7 +342,6 @@ mtk_wed_stop(struct mtk_wed_device *dev)
static void static void
mtk_wed_detach(struct mtk_wed_device *dev) mtk_wed_detach(struct mtk_wed_device *dev)
{ {
struct device_node *wlan_node = dev->wlan.pci_dev->dev.of_node;
struct mtk_wed_hw *hw = dev->hw; struct mtk_wed_hw *hw = dev->hw;
mutex_lock(&hw_lock); mutex_lock(&hw_lock);
...@@ -337,9 +356,14 @@ mtk_wed_detach(struct mtk_wed_device *dev) ...@@ -337,9 +356,14 @@ mtk_wed_detach(struct mtk_wed_device *dev)
mtk_wed_free_buffer(dev); mtk_wed_free_buffer(dev);
mtk_wed_free_tx_rings(dev); mtk_wed_free_tx_rings(dev);
if (dev->wlan.bus_type == MTK_WED_BUS_PCIE) {
struct device_node *wlan_node;
wlan_node = dev->wlan.pci_dev->dev.of_node;
if (of_dma_is_coherent(wlan_node) && hw->hifsys) if (of_dma_is_coherent(wlan_node) && hw->hifsys)
regmap_update_bits(hw->hifsys, HIFSYS_DMA_AG_MAP, regmap_update_bits(hw->hifsys, HIFSYS_DMA_AG_MAP,
BIT(hw->index), BIT(hw->index)); BIT(hw->index), BIT(hw->index));
}
if (!hw_list[!hw->index]->wed_dev && if (!hw_list[!hw->index]->wed_dev &&
hw->eth->dma_dev != hw->eth->dev) hw->eth->dma_dev != hw->eth->dev)
...@@ -356,12 +380,15 @@ mtk_wed_detach(struct mtk_wed_device *dev) ...@@ -356,12 +380,15 @@ mtk_wed_detach(struct mtk_wed_device *dev)
static void static void
mtk_wed_bus_init(struct mtk_wed_device *dev) mtk_wed_bus_init(struct mtk_wed_device *dev)
{ {
switch (dev->wlan.bus_type) {
case MTK_WED_BUS_PCIE: {
struct device_node *np = dev->hw->eth->dev->of_node; struct device_node *np = dev->hw->eth->dev->of_node;
struct regmap *regs; struct regmap *regs;
regs = syscon_regmap_lookup_by_phandle(np, "mediatek,wed-pcie"); regs = syscon_regmap_lookup_by_phandle(np,
"mediatek,wed-pcie");
if (IS_ERR(regs)) if (IS_ERR(regs))
return; break;
regmap_update_bits(regs, 0, BIT(0), BIT(0)); regmap_update_bits(regs, 0, BIT(0), BIT(0));
...@@ -382,7 +409,18 @@ mtk_wed_bus_init(struct mtk_wed_device *dev) ...@@ -382,7 +409,18 @@ mtk_wed_bus_init(struct mtk_wed_device *dev)
wed_r32(dev, MTK_WED_PCIE_INT_TRIGGER); wed_r32(dev, MTK_WED_PCIE_INT_TRIGGER);
/* pola setting */ /* pola setting */
wed_set(dev, MTK_WED_PCIE_INT_CTRL, MTK_WED_PCIE_INT_CTRL_MSK_EN_POLA); wed_set(dev, MTK_WED_PCIE_INT_CTRL,
MTK_WED_PCIE_INT_CTRL_MSK_EN_POLA);
break;
}
case MTK_WED_BUS_AXI:
wed_set(dev, MTK_WED_WPDMA_INT_CTRL,
MTK_WED_WPDMA_INT_CTRL_SIG_SRC |
FIELD_PREP(MTK_WED_WPDMA_INT_CTRL_SRC_SEL, 0));
break;
default:
break;
}
} }
static void static void
...@@ -793,12 +831,14 @@ mtk_wed_attach(struct mtk_wed_device *dev) ...@@ -793,12 +831,14 @@ mtk_wed_attach(struct mtk_wed_device *dev)
__releases(RCU) __releases(RCU)
{ {
struct mtk_wed_hw *hw; struct mtk_wed_hw *hw;
struct device *device;
int ret = 0; int ret = 0;
RCU_LOCKDEP_WARN(!rcu_read_lock_held(), RCU_LOCKDEP_WARN(!rcu_read_lock_held(),
"mtk_wed_attach without holding the RCU read lock"); "mtk_wed_attach without holding the RCU read lock");
if (pci_domain_nr(dev->wlan.pci_dev->bus) > 1 || if ((dev->wlan.bus_type == MTK_WED_BUS_PCIE &&
pci_domain_nr(dev->wlan.pci_dev->bus) > 1) ||
!try_module_get(THIS_MODULE)) !try_module_get(THIS_MODULE))
ret = -ENODEV; ret = -ENODEV;
...@@ -816,8 +856,10 @@ mtk_wed_attach(struct mtk_wed_device *dev) ...@@ -816,8 +856,10 @@ mtk_wed_attach(struct mtk_wed_device *dev)
goto out; goto out;
} }
dev_info(&dev->wlan.pci_dev->dev, device = dev->wlan.bus_type == MTK_WED_BUS_PCIE
"attaching wed device %d version %d\n", ? &dev->wlan.pci_dev->dev
: &dev->wlan.platform_dev->dev;
dev_info(device, "attaching wed device %d version %d\n",
hw->index, hw->version); hw->index, hw->version);
dev->hw = hw; dev->hw = hw;
......
...@@ -198,6 +198,8 @@ struct mtk_wdma_desc { ...@@ -198,6 +198,8 @@ struct mtk_wdma_desc {
#define MTK_WED_WPDMA_INT_CTRL 0x520 #define MTK_WED_WPDMA_INT_CTRL 0x520
#define MTK_WED_WPDMA_INT_CTRL_SUBRT_ADV BIT(21) #define MTK_WED_WPDMA_INT_CTRL_SUBRT_ADV BIT(21)
#define MTK_WED_WPDMA_INT_CTRL_SIG_SRC BIT(22)
#define MTK_WED_WPDMA_INT_CTRL_SRC_SEL GENMASK(17, 16)
#define MTK_WED_WPDMA_INT_MASK 0x524 #define MTK_WED_WPDMA_INT_MASK 0x524
......
...@@ -11,6 +11,11 @@ ...@@ -11,6 +11,11 @@
struct mtk_wed_hw; struct mtk_wed_hw;
struct mtk_wdma_desc; struct mtk_wdma_desc;
enum mtk_wed_bus_tye {
MTK_WED_BUS_PCIE,
MTK_WED_BUS_AXI,
};
struct mtk_wed_ring { struct mtk_wed_ring {
struct mtk_wdma_desc *desc; struct mtk_wdma_desc *desc;
dma_addr_t desc_phys; dma_addr_t desc_phys;
...@@ -43,7 +48,11 @@ struct mtk_wed_device { ...@@ -43,7 +48,11 @@ struct mtk_wed_device {
/* filled by driver: */ /* filled by driver: */
struct { struct {
union {
struct platform_device *platform_dev;
struct pci_dev *pci_dev; struct pci_dev *pci_dev;
};
enum mtk_wed_bus_tye bus_type;
u32 wpdma_phys; u32 wpdma_phys;
u32 wpdma_int; u32 wpdma_int;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment