lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue,  8 Dec 2015 14:52:05 +0100
From:	Neil Armstrong <narmstrong@...libre.com>
To:	nicolas.ferre@...el.com, davem@...emloft.net,
	harini.katakam@...inx.com, boris.brezillon@...e-electrons.com,
	alexandre.belloni@...e-electrons.com, linux-kernel@...r.kernel.org,
	netdev@...r.kernel.org, devicetree@...r.kernel.org, joshc@...com
Cc:	Neil Armstrong <narmstrong@...libre.com>
Subject: [PATCH v2 net-next 2/3] net: ethernet: cadence-macb: Add fallback to read DT provided caps

Add 1:1 mapping of software defines caps parsing from DT in case the
generic macb compatible form is used.
These properties will provide support for futures implementations
only defined from DT without need to update the driver code to support
new variants.

Signed-off-by: Neil Armstrong <narmstrong@...libre.com>
---
 drivers/net/ethernet/cadence/macb.c | 45 +++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 9325140..28a9a8b 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -2795,6 +2795,48 @@ static const struct macb_config zynq_config = {
 	.init = macb_init,
 };
 
+static const struct macb_config *macb_parse_dt_caps(struct device *dev)
+{
+	struct device_node *np = dev->of_node;
+	struct macb_config *macb_config;
+	u32 val;
+
+	macb_config = devm_kzalloc(dev, sizeof(*macb_config), GFP_KERNEL);
+	if (!macb_config)
+		return NULL;
+
+	if (of_property_read_bool(np, "cdns,usrio-has-clken"))
+		macb_config->caps |= MACB_CAPS_USRIO_HAS_CLKEN;
+
+	if (of_property_read_bool(np, "cdns,usrio-default-mii"))
+		macb_config->caps |= MACB_CAPS_USRIO_DEFAULT_IS_MII;
+
+	if (of_property_read_bool(np, "cdns,no-gigabit-half"))
+		macb_config->caps |= MACB_CAPS_NO_GIGABIT_HALF;
+
+	if (of_property_read_bool(np, "cdns,usrio-disabled"))
+		macb_config->caps |= MACB_CAPS_USRIO_DISABLED;
+
+	if (of_property_read_bool(np, "cdns,gem-sg-disabled"))
+		macb_config->caps |= MACB_CAPS_SG_DISABLED;
+
+	if (of_property_read_bool(np, "cdns,gem-has-gigabit"))
+		macb_config->caps |= MACB_CAPS_GIGABIT_MODE_AVAILABLE;
+
+	if (of_property_read_bool(np, "cdns,usrio-disabled"))
+		macb_config->caps |= MACB_CAPS_USRIO_DISABLED;
+
+	if (!of_property_read_u32(np, "cdns,dma-burst-length", &val))
+		macb_config->dma_burst_length = val;
+
+	if (!of_property_read_u32(np, "cdns,jumbo-max-length", &val)) {
+		macb_config->jumbo_max_len = val;
+		macb_config->caps |= MACB_CAPS_JUMBO;
+	}
+
+	return macb_config;
+}
+
 static const struct of_device_id macb_dt_ids[] = {
 	{ .compatible = "cdns,at32ap7000-macb" },
 	{ .compatible = "cdns,at91sam9260-macb", .data = &at91sam9260_config },
@@ -2847,6 +2889,9 @@ static int macb_probe(struct platform_device *pdev)
 			clk_init = macb_config->clk_init;
 			init = macb_config->init;
 		}
+
+		if (!macb_config)
+			macb_config = macb_parse_dt_caps(&pdev->dev);
 	}
 
 	err = clk_init(pdev, &pclk, &hclk, &tx_clk);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists