mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-24 07:46:48 +00:00
28dcb74de3
This adds experimental ethernet support for BCM6318, BCM6328, BCM6362, BCM6368 and BCM63268. BCM6358 needs a different driver, so there's no support for now. Working devices: - Comtrend AR-5315u - Comtrend AR-5387un - Comtrend VR-3025u - Comtrend VR-3032u Not working devices: - Netgear DGND3700 v2 (no idea on how the external switch is connected) - Huawei HG556a ver B (BCM6358 needs a separate driveer) Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
83 lines
2.1 KiB
Diff
83 lines
2.1 KiB
Diff
From f5419e7f362ae1c462baf28a2da7360267f8e4f9 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com>
|
|
Date: Mon, 1 Mar 2021 07:32:32 +0100
|
|
Subject: [PATCH 2/3] net: dsa: b53: mmap: Add device tree support
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Add device tree support to b53_mmap.c while keeping platform devices support.
|
|
|
|
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
|
|
---
|
|
drivers/net/dsa/b53/b53_mmap.c | 36 ++++++++++++++++++++++++++++++++++
|
|
1 file changed, 36 insertions(+)
|
|
|
|
--- a/drivers/net/dsa/b53/b53_mmap.c
|
|
+++ b/drivers/net/dsa/b53/b53_mmap.c
|
|
@@ -228,12 +228,64 @@ static const struct b53_io_ops b53_mmap_
|
|
.write64 = b53_mmap_write64,
|
|
};
|
|
|
|
+static int b53_mmap_probe_of(struct platform_device *pdev,
|
|
+ struct b53_platform_data **ppdata)
|
|
+{
|
|
+ struct device *dev = &pdev->dev;
|
|
+ struct device_node *np = dev->of_node;
|
|
+ struct device_node *of_ports, *of_port;
|
|
+ struct b53_platform_data *pdata;
|
|
+ void __iomem *mem;
|
|
+
|
|
+ mem = devm_platform_ioremap_resource(pdev, 0);
|
|
+ if (IS_ERR(mem))
|
|
+ return PTR_ERR(mem);
|
|
+
|
|
+ pdata = devm_kzalloc(dev, sizeof(struct b53_platform_data),
|
|
+ GFP_KERNEL);
|
|
+ if (!pdata)
|
|
+ return -ENOMEM;
|
|
+
|
|
+ pdata->regs = mem;
|
|
+ pdata->chip_id = BCM63XX_DEVICE_ID;
|
|
+ pdata->big_endian = of_property_read_bool(np, "big-endian");
|
|
+
|
|
+ of_ports = of_get_child_by_name(np, "ports");
|
|
+ if (!of_ports) {
|
|
+ dev_err(dev, "no ports child node found\n");
|
|
+ return -EINVAL;
|
|
+ }
|
|
+
|
|
+ for_each_available_child_of_node(of_ports, of_port) {
|
|
+ u32 reg;
|
|
+
|
|
+ if (of_property_read_u32(of_port, "reg", ®))
|
|
+ continue;
|
|
+
|
|
+ if (reg < B53_CPU_PORT)
|
|
+ pdata->enabled_ports |= BIT(reg);
|
|
+ }
|
|
+
|
|
+ *ppdata = pdata;
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
static int b53_mmap_probe(struct platform_device *pdev)
|
|
{
|
|
+ struct device_node *np = pdev->dev.of_node;
|
|
struct b53_platform_data *pdata = pdev->dev.platform_data;
|
|
struct b53_mmap_priv *priv;
|
|
struct b53_device *dev;
|
|
|
|
+ if (np) {
|
|
+ int ret = b53_mmap_probe_of(pdev, &pdata);
|
|
+ if (ret) {
|
|
+ dev_err(&pdev->dev, "OF probe error\n");
|
|
+ return ret;
|
|
+ }
|
|
+ }
|
|
+
|
|
if (!pdata)
|
|
return -EINVAL;
|
|
|