From: Neil Armstrong <narmstrong@baylibre.com>
To: nicolas.ferre@atmel.com, davem@davemloft.net,
harini.katakam@xilinx.com, boris.brezillon@free-electrons.com,
alexandre.belloni@free-electrons.com,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
devicetree@vger.kernel.org, joshc@ni.com
Cc: Neil Armstrong <narmstrong@baylibre.com>
Subject: [PATCH v2 net-next 2/3] net: ethernet: cadence-macb: Add fallback to read DT provided caps
Date: Tue, 8 Dec 2015 14:52:05 +0100 [thread overview]
Message-ID: <1449582726-6148-3-git-send-email-narmstrong@baylibre.com> (raw)
In-Reply-To: <1449582726-6148-1-git-send-email-narmstrong@baylibre.com>
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@baylibre.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
next prev parent reply other threads:[~2015-12-08 13:52 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-07 10:58 [PATCH net 0/2] Add a property to disable MACB USRIO register Neil Armstrong
2015-12-07 10:58 ` [PATCH net 1/2] net: cadence: macb: Disable USRIO register on some platforms Neil Armstrong
2015-12-07 19:09 ` David Miller
2015-12-07 19:32 ` Josh Cartwright
2015-12-08 9:21 ` Neil Armstrong
2015-12-08 9:38 ` Nicolas Ferre
2015-12-07 10:58 ` [PATCH net 2/2] bindings: net: macb: add no-usrio optional property Neil Armstrong
2015-12-08 15:26 ` Rob Herring
2015-12-08 13:52 ` [PATCH v2 net-next 0/3] Add new capability and parse from DT Neil Armstrong
2015-12-08 13:52 ` [PATCH v2 net-next 1/3] net: ethernet: cadence-macb: Add disabled usrio caps Neil Armstrong
2015-12-08 13:52 ` Neil Armstrong [this message]
2015-12-08 15:00 ` [PATCH v2 net-next 2/3] net: ethernet: cadence-macb: Add fallback to read DT provided caps Arnd Bergmann
2015-12-08 16:22 ` Nicolas Ferre
2015-12-08 13:52 ` [PATCH v2 net-next 3/3] bindings: ethernet: macb: Add optional caps properties Neil Armstrong
2015-12-09 3:49 ` Rob Herring
2016-01-04 9:01 ` [PATCH v3 net-next] net: ethernet: cadence-macb: Add disabled usrio caps Neil Armstrong
2016-01-04 9:25 ` Nicolas Ferre
2016-01-04 9:42 ` [PATCH v4 net-next 0/3] Add new capability and macb DT variant Neil Armstrong
2016-01-04 9:42 ` [PATCH v4 net-next 1/3] net: ethernet: cadence-macb: Add disabled usrio caps Neil Armstrong
2016-01-04 9:42 ` [PATCH v4 net-next 2/3] net: macb: Add NPx macb config using USRIO_DISABLED cap Neil Armstrong
2016-01-04 10:38 ` Nicolas Ferre
2016-01-05 12:20 ` Neil Armstrong
2016-01-05 13:27 ` Nicolas Ferre
2016-01-04 9:42 ` [PATCH v4 net-next 3/3] dt-bindings: net: macb: Add NPx macb variant Neil Armstrong
2016-01-05 13:39 ` [PATCH v5 net-next 0/3] Add new capability and macb DT variant Neil Armstrong
2016-01-05 13:39 ` [PATCH v5 net-next 1/3] net: ethernet: cadence-macb: Add disabled usrio caps Neil Armstrong
2016-01-05 13:45 ` Nicolas Ferre
2016-01-05 13:39 ` [PATCH v5 net-next 2/3] net: macb: Add NP4 macb config using USRIO_DISABLED Neil Armstrong
2016-01-05 13:45 ` Nicolas Ferre
2016-01-05 13:39 ` [PATCH v5 net-next 3/3] dt-bindings: net: macb: Add NP4 macb variant Neil Armstrong
2016-01-05 13:46 ` Nicolas Ferre
2016-01-06 14:52 ` Rob Herring
2016-01-07 21:26 ` [PATCH v5 net-next 0/3] Add new capability and macb DT variant David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1449582726-6148-3-git-send-email-narmstrong@baylibre.com \
--to=narmstrong@baylibre.com \
--cc=alexandre.belloni@free-electrons.com \
--cc=boris.brezillon@free-electrons.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=harini.katakam@xilinx.com \
--cc=joshc@ni.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@atmel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®