From: Barry G <mr.scada@gmail.com>
To: netdev@vger.kernel.org
Subject: Re: Configure Distributed Switch Architecture Via Device Tree
Date: Fri, 10 Jun 2011 08:14:39 -0700 [thread overview]
Message-ID: <BANLkTin0L010DLSBitOgS09x6UDU-NYS=Q@mail.gmail.com> (raw)
In-Reply-To: <BANLkTikystOn-36tCWWnYZR7_+yx2wFt=Q@mail.gmail.com>
Just in case anyone else runs into this problem, this is what I ended up doing.
This code needs more error checking and isn't "right", plus it needs
to read the
chip mapping stuff from the OF, but it answers my original two questions :-)
#include <linux/of.h>
#include <linux/kernel.h>
#include <linux/of_platform.h>
#include <net/dsa.h>
static struct dsa_chip_data switches[] = {
{
.sw_addr = 0x9,
.port_names = {
"eth%d", //0
"eth%d", //1
"eth%d", //2
"eth%d", //3
"eth%d", //4
"eth%d", //5
"eth%d", //6
"eth%d", //7
NULL, //8
NULL, //9
"cpu", //10
},
.rtable = (s8 []){-1, 9, 8},
},
{
.sw_addr = 0xa,
.port_names = {
"eth%d", //0
"eth%d", //1
"eth%d", //2
"eth%d", //3
"eth%d", //4
"eth%d", //5
"eth%d", //6
"eth%d", //7
"dsa", //8
"dsa", //9
},
.rtable = (s8 []){8, -1, 9},
},
{
.sw_addr = 0x8,
.port_names = {
"eth%d", //0
"eth%d", //1
"eth%d", //2
"eth%d", //3
"eth%d", //4
"eth%d", //5
"eth%d", //6
"eth%d", //7
"dsa", //8
"dsa", //9
NULL, //10
},
.rtable = (s8 []){9, 8, -1},
},
};
static struct dsa_platform_data my_switch_data = {
.nr_chips = 3,
.chip = switches,
};
static int __devinit dsa_probe(struct platform_device *);
static int __devexit dsa_remove(struct platform_device *);
static const struct of_device_id dsa_match[] = {
{
.compatible = "vendor,my-dsa-of",
},
{}
};
static struct platform_driver dsa_driver = {
.driver = {
.name = "dsa-driver",
.owner = THIS_MODULE,
.of_match_table = dsa_match,
},
.probe = dsa_probe,
.remove = dsa_remove,
};
static struct platform_device switchdriver = {
.name = "dsa",
.id = 0,
.num_resources = 0,
.dev.platform_data = &my_switch_data
};
static int __devinit dsa_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
const phandle *mdio_ph;
const phandle *ethernet_ph;
struct device_node *mdio;
struct device_node *ethernet;
struct platform_device *mdio_pd;
struct platform_device *ethernet_pd;
int i;
dev_info(&pdev->dev, "Initializing OF Marvell DSA driver\n");
mdio_ph = of_get_property(np, "mdio-handle", NULL);
ethernet_ph = of_get_property(np, "ethernet-handle", NULL);
mdio = of_find_node_by_phandle(*mdio_ph);
ethernet = of_find_node_by_phandle(*ethernet_ph);
mdio_pd = of_find_device_by_node(mdio);
ethernet_pd = of_find_device_by_node(ethernet);
my_switch_data.netdev = ðernet_pd->dev;
for(i = 0; i < my_switch_data.nr_chips; i++)
{
switches[i].mii_bus = &mdio_pd->dev;
}
platform_device_register(&switchdriver);
return 0;
}
static int __devexit dsa_remove(struct platform_device *pdev)
{
printk("dsa_remove\n");
return 0;
}
static int __init dsa_driver_init(void)
{
printk("dsa_drver_init\n");
return platform_driver_register(&dsa_driver);
}
static void __exit dsa_driver_cleanup(void)
{
printk("dsa_driver_cleanup\n");
platform_driver_unregister(&dsa_driver);
}
module_init(dsa_driver_init);
module_exit(dsa_driver_cleanup);
MODULE_DESCRIPTION("Marvell DSA OF driver");
MODULE_AUTHOR("Barry G <mr.scada@gmail.com>");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:dsa-driver");
prev parent reply other threads:[~2011-06-10 15:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-08 17:18 Configure Distributed Switch Architecture Via Device Tree Barry G
2011-06-10 15:14 ` Barry G [this message]
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='BANLkTin0L010DLSBitOgS09x6UDU-NYS=Q@mail.gmail.com' \
--to=mr.scada@gmail.com \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).