netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Barry G <mr.scada@gmail.com>
To: netdev@vger.kernel.org
Subject: Configure Distributed Switch Architecture Via Device Tree
Date: Wed, 8 Jun 2011 10:18:15 -0700	[thread overview]
Message-ID: <BANLkTikystOn-36tCWWnYZR7_+yx2wFt=Q@mail.gmail.com> (raw)

Hello,

We are working on bringing up a powerpc platform that has a few
Marvell switches on it.  We would like to make use of the DSA
stuff in the kernel.

It appears all the devices currently in the kernel that use DSA
are done via the platform_add_devices route.  I was hoping
to use the device tree since most of the powerpc stuff does.

My main two questions right now are:
How do I pull together the various components into the
dsa structures and how do I register that structure with
the dsa subsystem.

I added the following to my device tree:
   virtual-device {
      compatible = "simple-bus";
      dsa {
         compatible = "vendor,my-dsa-of";
         ethernet-handle = <&enet0>;
         mdio-handle = <&mdio0>;
      };
   };

And wrote the attached driver.  It loads at boot, so I
know the compatible stuff is working and all, but
I am a little lost as to the next steps.  Any help
would be much appreciated.

Thanks,

Barry


Here is my first hack at a drive:
#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 = 0,
      .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 []){-1, 8, 9},
   },
   {
      .sw_addr = 1,
      .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
         "cpu",   //10
      },
      .rtable = (s8 []){9, -1, 8},
   },
   {
      .sw_addr = 2,
      .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 []){8, 9, -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 int __devinit dsa_probe(struct platform_device *pdev)
{
   /* Question 1:
      I need to hookup the mii_bus in the dsa_chip_data and
      the netdev in the dsa_platform_data to the various
      struct device *s.  I could get access to the device nodes
      like:

      ph = of_get_property(np, "mdio-handle", NULL);
      mdio = of_find_node_by_phandle(*ph);

      Now I have the mdio device_node, but what do I do with
      it?  How do I get the device *?

      */

   /* Question 2: Whats the entry point into the DSA stuff
      now that I have my snazzy chips setup in the
      my_switch_data?  Usually it is added as a stamp device
      ad added with platform_add_devices.  Do I need to edit
      the DSA stuff to work with OF devices? */


   dev_info(&pdev->dev, "Initializing OF Marvell DSA driver\n");

   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");

             reply	other threads:[~2011-06-08 17:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-08 17:18 Barry G [this message]
2011-06-10 15:14 ` Configure Distributed Switch Architecture Via Device Tree Barry G

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='BANLkTikystOn-36tCWWnYZR7_+yx2wFt=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).