Re: [PATCH v2 net-next 2/3] net: ethernet: cadence-macb: Add fallback to read DT provided caps

2015-12-08 Thread Arnd Bergmann
On Tuesday 08 December 2015 14:52:05 Neil Armstrong wrote:
> 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 
> 

Translating the Linux implementation specific configuration into
DT properties directly is usually not the best way.

Could we instead have a lookup table by compatible string to set the
flags? It seems that there are lots of different flags but only a
couple of different users of this IP block. Also, the fact that
you are now adding yet another quirk tells me that the set you
define today is unlikely to cover all the future requirements.

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


[PATCH v2 net-next 2/3] net: ethernet: cadence-macb: Add fallback to read DT provided caps

2015-12-08 Thread Neil Armstrong
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 
---
 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", ))
+   macb_config->dma_burst_length = val;
+
+   if (!of_property_read_u32(np, "cdns,jumbo-max-length", )) {
+   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 = _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(>dev);
}
 
err = clk_init(pdev, , , _clk);
-- 
1.9.1

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


Re: [PATCH v2 net-next 2/3] net: ethernet: cadence-macb: Add fallback to read DT provided caps

2015-12-08 Thread Nicolas Ferre
Le 08/12/2015 16:00, Arnd Bergmann a écrit :
> On Tuesday 08 December 2015 14:52:05 Neil Armstrong wrote:
>> 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 
>>
> 
> Translating the Linux implementation specific configuration into
> DT properties directly is usually not the best way.
> 
> Could we instead have a lookup table by compatible string to set the
> flags? It seems that there are lots of different flags but only a
> couple of different users of this IP block. Also, the fact that
> you are now adding yet another quirk tells me that the set you
> define today is unlikely to cover all the future requirements.

This is basically what I told Neil in my previous email.

I understand you point Neil, but I don't find it makes sense and Arnd
described it better that I did.
So please find a proper compatibility string and simply use it. What
about:
"cdns,the_name_of_the_product_that_first_implemented_this_no_usrio_special_case-gem"?

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