aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/dsa
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2016-07-08 14:39:12 -0400
committerDavid S. Miller <davem@davemloft.net>2016-07-11 15:52:03 -0400
commitfefae6909ead1798c39bee4d94e7e8f1f2752ef6 (patch)
treef123c45f8e42d969acca66d2931efd7fec806223 /drivers/net/dsa
parentfb3bbdb859891e6bc27fd1afb3a07319f82c2ee4 (diff)
net: dsa: b53: Allow SRAB driver to specify platform data
For Northstart Plus SoCs, we cannot detect the switch because only the revision information is provied in the Management page, instead, rely on Device Tree to tell us the chip id, and pass it down using the b53_platform_data structure. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/dsa')
-rw-r--r--drivers/net/dsa/b53/b53_srab.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/drivers/net/dsa/b53/b53_srab.c b/drivers/net/dsa/b53/b53_srab.c
index 70fd47284535..de2b9e710041 100644
--- a/drivers/net/dsa/b53/b53_srab.c
+++ b/drivers/net/dsa/b53/b53_srab.c
@@ -21,6 +21,7 @@
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/platform_data/b53.h> 23#include <linux/platform_data/b53.h>
24#include <linux/of.h>
24 25
25#include "b53_priv.h" 26#include "b53_priv.h"
26 27
@@ -356,12 +357,37 @@ static struct b53_io_ops b53_srab_ops = {
356 .write64 = b53_srab_write64, 357 .write64 = b53_srab_write64,
357}; 358};
358 359
360static const struct of_device_id b53_srab_of_match[] = {
361 { .compatible = "brcm,bcm53010-srab" },
362 { .compatible = "brcm,bcm53011-srab" },
363 { .compatible = "brcm,bcm53012-srab" },
364 { .compatible = "brcm,bcm53018-srab" },
365 { .compatible = "brcm,bcm53019-srab" },
366 { .compatible = "brcm,bcm5301x-srab" },
367 { /* sentinel */ },
368};
369MODULE_DEVICE_TABLE(of, b53_srab_of_match);
370
359static int b53_srab_probe(struct platform_device *pdev) 371static int b53_srab_probe(struct platform_device *pdev)
360{ 372{
373 struct b53_platform_data *pdata = pdev->dev.platform_data;
374 struct device_node *dn = pdev->dev.of_node;
375 const struct of_device_id *of_id = NULL;
361 struct b53_srab_priv *priv; 376 struct b53_srab_priv *priv;
362 struct b53_device *dev; 377 struct b53_device *dev;
363 struct resource *r; 378 struct resource *r;
364 379
380 if (dn)
381 of_id = of_match_node(b53_srab_of_match, dn);
382
383 if (of_id) {
384 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
385 if (!pdata)
386 return -ENOMEM;
387
388 pdata->chip_id = (u32)of_id->data;
389 }
390
365 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 391 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
366 if (!priv) 392 if (!priv)
367 return -ENOMEM; 393 return -ENOMEM;
@@ -375,6 +401,9 @@ static int b53_srab_probe(struct platform_device *pdev)
375 if (!dev) 401 if (!dev)
376 return -ENOMEM; 402 return -ENOMEM;
377 403
404 if (pdata)
405 dev->pdata = pdata;
406
378 platform_set_drvdata(pdev, dev); 407 platform_set_drvdata(pdev, dev);
379 408
380 return b53_switch_register(dev); 409 return b53_switch_register(dev);
@@ -390,16 +419,6 @@ static int b53_srab_remove(struct platform_device *pdev)
390 return 0; 419 return 0;
391} 420}
392 421
393static const struct of_device_id b53_srab_of_match[] = {
394 { .compatible = "brcm,bcm53010-srab" },
395 { .compatible = "brcm,bcm53011-srab" },
396 { .compatible = "brcm,bcm53012-srab" },
397 { .compatible = "brcm,bcm53018-srab" },
398 { .compatible = "brcm,bcm53019-srab" },
399 { .compatible = "brcm,bcm5301x-srab" },
400 { /* sentinel */ },
401};
402
403static struct platform_driver b53_srab_driver = { 422static struct platform_driver b53_srab_driver = {
404 .probe = b53_srab_probe, 423 .probe = b53_srab_probe,
405 .remove = b53_srab_remove, 424 .remove = b53_srab_remove,