All of lore.kernel.org
 help / color / mirror / Atom feed
* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
@ 2014-10-13 10:14 post at twien.net
  2014-10-13 11:19 ` Jason Cooper
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: post at twien.net @ 2014-10-13 10:14 UTC (permalink / raw)
  To: linux-arm-kernel

Dear all,
I have a custom board equipped with an ARMADA 370 SoC (88f6W11) and a 
Marvell switch chip (88e6352) (I have written a device driver for the 
latter).
My question is how to set up a proper device tree specification for the 
board. The device tree specification is listed below. This is based on a 
similar .dts-file for the kirkwood SoC.
Further down is a excerpt of the start up sequence. I would imagine the 
switch would be installed as the "PHY" for eth0 (which seems not to be 
the case). I added some additional printout messages, and from what I 
can see a generic device driver is loaded, and eventually the 
mvneta_open/-probe function states that the PHY can not be found. I have 
read the "examples" in the ../boot/dts directory and also read the 
documentation. There are some confusing things, for example the 
"dsa,mii-bus;" specification where I eventually put in "dsa,mii-bus = 
<&mdio_bus>;". From both the examples and the documentation it seemed I 
should specify a device on the mdio_bus, e.g. "phy0", but when I did the 
whole thing crashed.
So specifying "mdio_bus" at least got me running a bit further, and the 
dsa driver was detected and the proper switch device was identified.
What I would like to achieve is to get eth0 to connect to port 5 on the 
switch using SGMII.
Any advice on how to proceed would  be appreciated.


+---------+
|         |           +--------+
|         |   SGMII   |        |----- p0
|     eth0|-----------|p5      |  .    .
|         |           |        |----- p4
+---------+           +--------+
ARMADA 370             88e6352


Tormod



/*
  * Device Tree file for Marvell Armada 370 Ethernet Prototype board
  * ()
  *
  *  Copied from arch/arm/boot/dts/armada-370-rd.dts
  *
  *  Copyright (C) 2014 ...
  *
  * This file is licensed under the terms of the GNU General Public
  * License version 2.  This program is licensed "as is" without any
  * warranty of any kind, whether express or implied.
  */

/dts-v1/;
#include <dt-bindings/input/input.h>
#include <dt-bindings/gpio/gpio.h>
#include "armada-370.dtsi"

/ {
	model = "Marvell Armada 370 Ethernet Prototype";
	compatible = "marvell,armada370", "marvell,armada-370-xp";

	chosen {
		bootargs = "console=ttyS0,115200 earlyprintk";
	};

	memory {
		device_type = "memory";
		reg = <0x00000000 0x40000000>; /* 1 GB */
	};

	soc {
		ranges = <MBUS_ID(0xf0, 0x01) 0 0xf1000000 0x100000
			  MBUS_ID(0x01, 0xe0) 0 0xfff00000 0x100000>;


                 pcie-controller {
                         status = "okay";

                         /* Internal mini-PCIe connector */
                         pcie at 1,0 {
                                 /* Port 0, Lane 0 */
                                 status = "okay";
                         };

                         /* Internal mini-PCIe connector */
                         pcie at 2,0 {
                                 /* Port 1, Lane 0 */
                                 status = "okay";
                         };
                 };

		internal-regs {
			serial at 12000 {
				status = "okay";
			};

			mdio_bus: mdio {
				phy0: ethernet-phy at ff {
/*					compatible = "ethernet-phy-id5043.0eb0", 
"ethernet-phy-ieee802.3-c22";
*/
					reg = <0xff>;  /* no PHY connected */
					speed = <1000>;
					duplex = <1>;
				};

/*				phy1: ethernet-phy at 1 {
					reg = <0x1>;
				};
*/
			};

			ethernet at 70000 {
				status = "okay";
				phy = <&phy0>;
				phy-mode = "sgmii";
			};

/*			ethernet at 74000 {
				status = "okay";
				phy = <&phy1>;
				phy-mode = "rgmii-id";
			};
*/
			mvsdio at d4000 {
				pinctrl-0 = <&sdio_pins1>;
				pinctrl-names = "default";
				status = "okay";
				/* No CD or WP GPIOs */
				broken-cd;
			};

			usb at 50000 {
				status = "okay";
			};


/*			usb at 51000 {
				status = "okay";
			};
*/
			spi0: spi at 10600 {
                                 status = "okay";
                                 };

			i2c at 11000 {
                                 pinctrl-0 = <&i2c0_pins>;
                                 pinctrl-names = "default";
                                 clock-frequency = <100000>;
                                 status = "okay";
                         };

			nand at d0000 {
				status = "okay";
				num-cs = <1>;
				marvell,nand-keep-config;
				marvell,nand-enable-arbiter;
				nand-on-flash-bbt;

				partition at 0 {
					label = "U-Boot";
					reg = <0 0x800000>;
				};
				partition at 800000 {
					label = "Linux";
					reg = <0x800000 0x800000>;
				};
				partition at 1000000 {
					label = "Filesystem";
					reg = <0x1000000 0x3f000000>;
				};
			};
		};
	};

	dsa at 0 {
                	compatible = "marvell,dsa";
                #address-cells = <2>;
                 #size-cells = <0>;
                	dsa,ethernet = <&eth0>;
                 dsa,mii-bus = <&mdio_bus>;

        	        switch at 0 {
                	        #address-cells = <1>;
                        	#size-cells = <0>;

			reg = <0 0>;

        	                port at 0 {
                	                reg = <0>;
                        	        label = "lan1";
                         };

        	                port at 1 {
                	                reg = <1>;
                        	        label = "lan2";
                         };

        	                port at 2 {
                	                reg = <2>;
                        	        label = "lan3";
                         };

        	                port at 3 {
                	                reg = <3>;
                        	        label = "lan4";
                         };

        	                port at 5 {
                	                reg = <5>;
                        	        label = "cpu";
                         };

			port at 6 {
				reg = <6>;
				label = "lan6";
			};
	 	};
	};

  };


nand: device found, Manufacturer ID: 0x2c, Chip ID: 0x38
nand: Micron MT29F8G08ABABAWP
nand: 1024MiB, SLC, page size: 4096, OOB size: 224
pxa3xx-nand f10d0000.nand: ECC strength 16, ECC step size 2048
Bad block table found at page 262016, version 0x01
Bad block table found at page 261888, version 0x01
3 ofpart partitions found on MTD device pxa3xx_nand-0
Creating 3 MTD partitions on "pxa3xx_nand-0":
0x000000000000-0x000000800000 : "U-Boot"
0x000000800000-0x000001000000 : "Linux"
0x000001000000-0x000040000000 : "Filesystem"
mdiobus register device_node: mdio
libphy: orion_mdio_bus: probed
mdio_bus f1072004.mdio-mi: /soc/internal-regs/mdio/ethernet-phy at ff PHY 
address 255 is too large
mvneta_probe: ethernet device: eth%d
mvneta_probe: phy_node: ethernet-phy
mvneta f1070000.ethernet eth0: Using hardware mac address 
00:50:43:02:02:00
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-pci: EHCI PCI platform driver
ehci-orion: EHCI orion driver
orion-ehci f1050000.usb: EHCI Host Controller
orion-ehci f1050000.usb: new USB bus registered, assigned bus number 1
orion-ehci f1050000.usb: irq 26, io mem 0xf1050000
orion-ehci f1050000.usb: USB 2.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
usbcore: registered new interface driver usb-storage
mousedev: PS/2 mouse device common for all mice
rtc-mv f1010300.rtc: internal RTC not ticking
orion_wdt: Initial timeout 229 sec
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
TCP: cubic registered
Distributed Switch Architecture driver version 0.1
eth0[0]: detected a Marvell 88E6352 switch
libphy: dsa slave smi: probed
ThumbEE CPU extension supported.
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
mvneta_mdio_probe: mvneta_probe: ethernet-phy
mvneta f1070000.ethernet eth0: could not find the PHY
mvneta f1070000.ethernet eth0: cannot probe MDIO bus
IP-Config: Failed to open eth0
IP-Config: Failed to open lan1
IP-Config: Failed to open lan2
IP-Config: Failed to open lan3
IP-Config: Failed to open lan4
IP-Config: Failed to open lan6
IP-Config: No network devices available

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-13 10:14 ARMADA 370 - Distributed Switch Architecture (dsa) - device tree post at twien.net
@ 2014-10-13 11:19 ` Jason Cooper
  2014-10-23  9:20   ` Thomas Petazzoni
  2014-10-13 13:19 ` Andrew Lunn
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 19+ messages in thread
From: Jason Cooper @ 2014-10-13 11:19 UTC (permalink / raw)
  To: linux-arm-kernel

Tormod,

Sorry, I don't have time to reply atm.  However, I'm adding the mvebu
devs and maintainers to the Cc.  You can also hit us up at #mvlinux on
freenode.

thx,

Jason.

On Mon, Oct 13, 2014 at 12:14:41PM +0200, post at twien.net wrote:
> Dear all,
> I have a custom board equipped with an ARMADA 370 SoC (88f6W11) and
> a Marvell switch chip (88e6352) (I have written a device driver for
> the latter).
> My question is how to set up a proper device tree specification for
> the board. The device tree specification is listed below. This is
> based on a similar .dts-file for the kirkwood SoC.
> Further down is a excerpt of the start up sequence. I would imagine
> the switch would be installed as the "PHY" for eth0 (which seems not
> to be the case). I added some additional printout messages, and from
> what I can see a generic device driver is loaded, and eventually the
> mvneta_open/-probe function states that the PHY can not be found. I
> have read the "examples" in the ../boot/dts directory and also read
> the documentation. There are some confusing things, for example the
> "dsa,mii-bus;" specification where I eventually put in "dsa,mii-bus
> = <&mdio_bus>;". From both the examples and the documentation it
> seemed I should specify a device on the mdio_bus, e.g. "phy0", but
> when I did the whole thing crashed.
> So specifying "mdio_bus" at least got me running a bit further, and
> the dsa driver was detected and the proper switch device was
> identified.
> What I would like to achieve is to get eth0 to connect to port 5 on
> the switch using SGMII.
> Any advice on how to proceed would  be appreciated.
> 
> 
> +---------+
> |         |           +--------+
> |         |   SGMII   |        |----- p0
> |     eth0|-----------|p5      |  .    .
> |         |           |        |----- p4
> +---------+           +--------+
> ARMADA 370             88e6352
> 
> 
> Tormod
> 
> 
> 
> /*
>  * Device Tree file for Marvell Armada 370 Ethernet Prototype board
>  * ()
>  *
>  *  Copied from arch/arm/boot/dts/armada-370-rd.dts
>  *
>  *  Copyright (C) 2014 ...
>  *
>  * This file is licensed under the terms of the GNU General Public
>  * License version 2.  This program is licensed "as is" without any
>  * warranty of any kind, whether express or implied.
>  */
> 
> /dts-v1/;
> #include <dt-bindings/input/input.h>
> #include <dt-bindings/gpio/gpio.h>
> #include "armada-370.dtsi"
> 
> / {
> 	model = "Marvell Armada 370 Ethernet Prototype";
> 	compatible = "marvell,armada370", "marvell,armada-370-xp";
> 
> 	chosen {
> 		bootargs = "console=ttyS0,115200 earlyprintk";
> 	};
> 
> 	memory {
> 		device_type = "memory";
> 		reg = <0x00000000 0x40000000>; /* 1 GB */
> 	};
> 
> 	soc {
> 		ranges = <MBUS_ID(0xf0, 0x01) 0 0xf1000000 0x100000
> 			  MBUS_ID(0x01, 0xe0) 0 0xfff00000 0x100000>;
> 
> 
>                 pcie-controller {
>                         status = "okay";
> 
>                         /* Internal mini-PCIe connector */
>                         pcie at 1,0 {
>                                 /* Port 0, Lane 0 */
>                                 status = "okay";
>                         };
> 
>                         /* Internal mini-PCIe connector */
>                         pcie at 2,0 {
>                                 /* Port 1, Lane 0 */
>                                 status = "okay";
>                         };
>                 };
> 
> 		internal-regs {
> 			serial at 12000 {
> 				status = "okay";
> 			};
> 
> 			mdio_bus: mdio {
> 				phy0: ethernet-phy at ff {
> /*					compatible = "ethernet-phy-id5043.0eb0",
> "ethernet-phy-ieee802.3-c22";
> */
> 					reg = <0xff>;  /* no PHY connected */
> 					speed = <1000>;
> 					duplex = <1>;
> 				};
> 
> /*				phy1: ethernet-phy at 1 {
> 					reg = <0x1>;
> 				};
> */
> 			};
> 
> 			ethernet at 70000 {
> 				status = "okay";
> 				phy = <&phy0>;
> 				phy-mode = "sgmii";
> 			};
> 
> /*			ethernet at 74000 {
> 				status = "okay";
> 				phy = <&phy1>;
> 				phy-mode = "rgmii-id";
> 			};
> */
> 			mvsdio at d4000 {
> 				pinctrl-0 = <&sdio_pins1>;
> 				pinctrl-names = "default";
> 				status = "okay";
> 				/* No CD or WP GPIOs */
> 				broken-cd;
> 			};
> 
> 			usb at 50000 {
> 				status = "okay";
> 			};
> 
> 
> /*			usb at 51000 {
> 				status = "okay";
> 			};
> */
> 			spi0: spi at 10600 {
>                                 status = "okay";
>                                 };
> 
> 			i2c at 11000 {
>                                 pinctrl-0 = <&i2c0_pins>;
>                                 pinctrl-names = "default";
>                                 clock-frequency = <100000>;
>                                 status = "okay";
>                         };
> 
> 			nand at d0000 {
> 				status = "okay";
> 				num-cs = <1>;
> 				marvell,nand-keep-config;
> 				marvell,nand-enable-arbiter;
> 				nand-on-flash-bbt;
> 
> 				partition at 0 {
> 					label = "U-Boot";
> 					reg = <0 0x800000>;
> 				};
> 				partition at 800000 {
> 					label = "Linux";
> 					reg = <0x800000 0x800000>;
> 				};
> 				partition at 1000000 {
> 					label = "Filesystem";
> 					reg = <0x1000000 0x3f000000>;
> 				};
> 			};
> 		};
> 	};
> 
> 	dsa at 0 {
>                	compatible = "marvell,dsa";
>                #address-cells = <2>;
>                 #size-cells = <0>;
>                	dsa,ethernet = <&eth0>;
>                 dsa,mii-bus = <&mdio_bus>;
> 
>        	        switch at 0 {
>                	        #address-cells = <1>;
>                        	#size-cells = <0>;
> 
> 			reg = <0 0>;
> 
>        	                port at 0 {
>                	                reg = <0>;
>                        	        label = "lan1";
>                         };
> 
>        	                port at 1 {
>                	                reg = <1>;
>                        	        label = "lan2";
>                         };
> 
>        	                port at 2 {
>                	                reg = <2>;
>                        	        label = "lan3";
>                         };
> 
>        	                port at 3 {
>                	                reg = <3>;
>                        	        label = "lan4";
>                         };
> 
>        	                port at 5 {
>                	                reg = <5>;
>                        	        label = "cpu";
>                         };
> 
> 			port at 6 {
> 				reg = <6>;
> 				label = "lan6";
> 			};
> 	 	};
> 	};
> 
>  };
> 
> 
> nand: device found, Manufacturer ID: 0x2c, Chip ID: 0x38
> nand: Micron MT29F8G08ABABAWP
> nand: 1024MiB, SLC, page size: 4096, OOB size: 224
> pxa3xx-nand f10d0000.nand: ECC strength 16, ECC step size 2048
> Bad block table found at page 262016, version 0x01
> Bad block table found at page 261888, version 0x01
> 3 ofpart partitions found on MTD device pxa3xx_nand-0
> Creating 3 MTD partitions on "pxa3xx_nand-0":
> 0x000000000000-0x000000800000 : "U-Boot"
> 0x000000800000-0x000001000000 : "Linux"
> 0x000001000000-0x000040000000 : "Filesystem"
> mdiobus register device_node: mdio
> libphy: orion_mdio_bus: probed
> mdio_bus f1072004.mdio-mi: /soc/internal-regs/mdio/ethernet-phy at ff
> PHY address 255 is too large
> mvneta_probe: ethernet device: eth%d
> mvneta_probe: phy_node: ethernet-phy
> mvneta f1070000.ethernet eth0: Using hardware mac address
> 00:50:43:02:02:00
> ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
> ehci-pci: EHCI PCI platform driver
> ehci-orion: EHCI orion driver
> orion-ehci f1050000.usb: EHCI Host Controller
> orion-ehci f1050000.usb: new USB bus registered, assigned bus number 1
> orion-ehci f1050000.usb: irq 26, io mem 0xf1050000
> orion-ehci f1050000.usb: USB 2.0 started, EHCI 1.00
> hub 1-0:1.0: USB hub found
> hub 1-0:1.0: 1 port detected
> usbcore: registered new interface driver usb-storage
> mousedev: PS/2 mouse device common for all mice
> rtc-mv f1010300.rtc: internal RTC not ticking
> orion_wdt: Initial timeout 229 sec
> usbcore: registered new interface driver usbhid
> usbhid: USB HID core driver
> TCP: cubic registered
> Distributed Switch Architecture driver version 0.1
> eth0[0]: detected a Marvell 88E6352 switch
> libphy: dsa slave smi: probed
> ThumbEE CPU extension supported.
> drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
> mvneta_mdio_probe: mvneta_probe: ethernet-phy
> mvneta f1070000.ethernet eth0: could not find the PHY
> mvneta f1070000.ethernet eth0: cannot probe MDIO bus
> IP-Config: Failed to open eth0
> IP-Config: Failed to open lan1
> IP-Config: Failed to open lan2
> IP-Config: Failed to open lan3
> IP-Config: Failed to open lan4
> IP-Config: Failed to open lan6
> IP-Config: No network devices available
> 
> 
> 
> 
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-13 10:14 ARMADA 370 - Distributed Switch Architecture (dsa) - device tree post at twien.net
  2014-10-13 11:19 ` Jason Cooper
@ 2014-10-13 13:19 ` Andrew Lunn
  2014-10-13 18:25 ` Guenter Roeck
  2014-10-14  2:08 ` Florian Fainelli
  3 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2014-10-13 13:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 13, 2014 at 12:14:41PM +0200, post at twien.net wrote:
> Dear all,
> I have a custom board equipped with an ARMADA 370 SoC (88f6W11) and
> a Marvell switch chip (88e6352) (I have written a device driver for
> the latter).

Hi Tormon

I think this is the first board anybody has tried DSA with the mvmeta
driver. So there could be issues there. You also need to be a little
bit careful with the kirkwood examples. Until recently, they were
broken.

You dsa node in your DT tree looks good. The dmesg output also seems
O.K. in terms of DSA. It has found the switch, meaning communication
through the ethernet mdio bus is working.

I think the issue is either in your mdio node, or the mvneta driver.

I'm currently working on a D-LINK DIR665, with a DSA setup. This is
kirkwood. My mdio node is simply:

&mdio {
        status = "okay";
};

And the speed and duplex goes into the ethernet node:

&eth0 {
	status = "okay";

	ethernet0-port at 0 {
                speed = <1000>;
                duplex = <1>;
        };
};

The Ethernet node does not have a phandle to a phy node.

Can you try something similar?

    Andrew

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-13 10:14 ARMADA 370 - Distributed Switch Architecture (dsa) - device tree post at twien.net
  2014-10-13 11:19 ` Jason Cooper
  2014-10-13 13:19 ` Andrew Lunn
@ 2014-10-13 18:25 ` Guenter Roeck
  2014-10-14  6:05   ` post at twien.net
  2014-10-14 11:35   ` Richard Cochran
  2014-10-14  2:08 ` Florian Fainelli
  3 siblings, 2 replies; 19+ messages in thread
From: Guenter Roeck @ 2014-10-13 18:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 13, 2014 at 12:14:41PM +0200, post at twien.net wrote:
> Dear all,
> I have a custom board equipped with an ARMADA 370 SoC (88f6W11) and
> a Marvell switch chip (88e6352) (I have written a device driver for
> the latter).

Hi Tormod,

coincidentially, I have a DSA driver for 88e6352 almost ready for submitting it
upstream. What are your plans for your driver ? Do you plan to submit it
upstream ? Either case, it would be great if you could share a pointer to it
so we can make sure that it works for both our use cases.

I have made my patch set available in the 'dsa' branch of
https://git.kernel.org/cgit/linux/kernel/git/groeck/linux-staging.git
in case you are interested.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-13 10:14 ARMADA 370 - Distributed Switch Architecture (dsa) - device tree post at twien.net
                   ` (2 preceding siblings ...)
  2014-10-13 18:25 ` Guenter Roeck
@ 2014-10-14  2:08 ` Florian Fainelli
  2014-10-14 11:14   ` post at twien.net
  3 siblings, 1 reply; 19+ messages in thread
From: Florian Fainelli @ 2014-10-14  2:08 UTC (permalink / raw)
  To: linux-arm-kernel

2014-10-13 3:14 GMT-07:00  <post@twien.net>:
> Dear all,
> I have a custom board equipped with an ARMADA 370 SoC (88f6W11) and a
> Marvell switch chip (88e6352) (I have written a device driver for the
> latter).
> My question is how to set up a proper device tree specification for the
> board. The device tree specification is listed below. This is based on a
> similar .dts-file for the kirkwood SoC.
> Further down is a excerpt of the start up sequence. I would imagine the
> switch would be installed as the "PHY" for eth0 (which seems not to be the
> case). I added some additional printout messages, and from what I can see a
> generic device driver is loaded, and eventually the mvneta_open/-probe
> function states that the PHY can not be found. I have read the "examples" in
> the ../boot/dts directory and also read the documentation. There are some
> confusing things, for example the "dsa,mii-bus;" specification where I
> eventually put in "dsa,mii-bus = <&mdio_bus>;". From both the examples and
> the documentation it seemed I should specify a device on the mdio_bus, e.g.
> "phy0", but when I did the whole thing crashed.
> So specifying "mdio_bus" at least got me running a bit further, and the dsa
> driver was detected and the proper switch device was identified.
> What I would like to achieve is to get eth0 to connect to port 5 on the
> switch using SGMII.
> Any advice on how to proceed would  be appreciated.

At this point, what I would do is create a fixed-phy Device Tree node
for mvneta to hardcode the link indication/speed/duplex, and specify
the 'phy-mode' property to be "sgmii", and of course, remove the
'phy-handle' property such that the fixed PHY is used instead.

Right now, DSA drivers are not created as regular PHY drivers (which
is something on my TODO list), such that they do not provide link
indication towards the CPU Ethernet MAC. Except for the front-panel
external ports, Ethernet switches does not report standardized link
parameters through the standard MII registers for the CPU port, which
is why we have to find another way to do that.

In case that helps, I could copy/paste a Device Tree source for a
Broadcom SoC I use which has both of its DSA switch driver (bcm_sf2)
and Ethernet MAC (bcmsysport) drivers mainline.

Please note that, in order to boot from the network with DSA-enabled
devices, you need such a patch:
http://patchwork.ozlabs.org/patch/354293/

which I should re-submit eventually


>
>
> +---------+
> |         |           +--------+
> |         |   SGMII   |        |----- p0
> |     eth0|-----------|p5      |  .    .
> |         |           |        |----- p4
> +---------+           +--------+
> ARMADA 370             88e6352
>
>
> Tormod
>
>
>
> /*
>  * Device Tree file for Marvell Armada 370 Ethernet Prototype board
>  * ()
>  *
>  *  Copied from arch/arm/boot/dts/armada-370-rd.dts
>  *
>  *  Copyright (C) 2014 ...
>  *
>  * This file is licensed under the terms of the GNU General Public
>  * License version 2.  This program is licensed "as is" without any
>  * warranty of any kind, whether express or implied.
>  */
>
> /dts-v1/;
> #include <dt-bindings/input/input.h>
> #include <dt-bindings/gpio/gpio.h>
> #include "armada-370.dtsi"
>
> / {
>         model = "Marvell Armada 370 Ethernet Prototype";
>         compatible = "marvell,armada370", "marvell,armada-370-xp";
>
>         chosen {
>                 bootargs = "console=ttyS0,115200 earlyprintk";
>         };
>
>         memory {
>                 device_type = "memory";
>                 reg = <0x00000000 0x40000000>; /* 1 GB */
>         };
>
>         soc {
>                 ranges = <MBUS_ID(0xf0, 0x01) 0 0xf1000000 0x100000
>                           MBUS_ID(0x01, 0xe0) 0 0xfff00000 0x100000>;
>
>
>                 pcie-controller {
>                         status = "okay";
>
>                         /* Internal mini-PCIe connector */
>                         pcie at 1,0 {
>                                 /* Port 0, Lane 0 */
>                                 status = "okay";
>                         };
>
>                         /* Internal mini-PCIe connector */
>                         pcie at 2,0 {
>                                 /* Port 1, Lane 0 */
>                                 status = "okay";
>                         };
>                 };
>
>                 internal-regs {
>                         serial at 12000 {
>                                 status = "okay";
>                         };
>
>                         mdio_bus: mdio {
>                                 phy0: ethernet-phy at ff {
> /*                                      compatible =
> "ethernet-phy-id5043.0eb0", "ethernet-phy-ieee802.3-c22";
> */
>                                         reg = <0xff>;  /* no PHY connected
> */
>                                         speed = <1000>;
>                                         duplex = <1>;
>                                 };
>
> /*                              phy1: ethernet-phy at 1 {
>                                         reg = <0x1>;
>                                 };
> */
>                         };
>
>                         ethernet at 70000 {
>                                 status = "okay";
>                                 phy = <&phy0>;
>                                 phy-mode = "sgmii";
>                         };
>
> /*                      ethernet at 74000 {
>                                 status = "okay";
>                                 phy = <&phy1>;
>                                 phy-mode = "rgmii-id";
>                         };
> */
>                         mvsdio at d4000 {
>                                 pinctrl-0 = <&sdio_pins1>;
>                                 pinctrl-names = "default";
>                                 status = "okay";
>                                 /* No CD or WP GPIOs */
>                                 broken-cd;
>                         };
>
>                         usb at 50000 {
>                                 status = "okay";
>                         };
>
>
> /*                      usb at 51000 {
>                                 status = "okay";
>                         };
> */
>                         spi0: spi at 10600 {
>                                 status = "okay";
>                                 };
>
>                         i2c at 11000 {
>                                 pinctrl-0 = <&i2c0_pins>;
>                                 pinctrl-names = "default";
>                                 clock-frequency = <100000>;
>                                 status = "okay";
>                         };
>
>                         nand at d0000 {
>                                 status = "okay";
>                                 num-cs = <1>;
>                                 marvell,nand-keep-config;
>                                 marvell,nand-enable-arbiter;
>                                 nand-on-flash-bbt;
>
>                                 partition at 0 {
>                                         label = "U-Boot";
>                                         reg = <0 0x800000>;
>                                 };
>                                 partition at 800000 {
>                                         label = "Linux";
>                                         reg = <0x800000 0x800000>;
>                                 };
>                                 partition at 1000000 {
>                                         label = "Filesystem";
>                                         reg = <0x1000000 0x3f000000>;
>                                 };
>                         };
>                 };
>         };
>
>         dsa at 0 {
>                 compatible = "marvell,dsa";
>                #address-cells = <2>;
>                 #size-cells = <0>;
>                 dsa,ethernet = <&eth0>;
>                 dsa,mii-bus = <&mdio_bus>;
>
>                 switch at 0 {
>                         #address-cells = <1>;
>                         #size-cells = <0>;
>
>                         reg = <0 0>;
>
>                         port at 0 {
>                                 reg = <0>;
>                                 label = "lan1";
>                         };
>
>                         port at 1 {
>                                 reg = <1>;
>                                 label = "lan2";
>                         };
>
>                         port at 2 {
>                                 reg = <2>;
>                                 label = "lan3";
>                         };
>
>                         port at 3 {
>                                 reg = <3>;
>                                 label = "lan4";
>                         };
>
>                         port at 5 {
>                                 reg = <5>;
>                                 label = "cpu";
>                         };
>
>                         port at 6 {
>                                 reg = <6>;
>                                 label = "lan6";
>                         };
>                 };
>         };
>
>  };
>
>
> nand: device found, Manufacturer ID: 0x2c, Chip ID: 0x38
> nand: Micron MT29F8G08ABABAWP
> nand: 1024MiB, SLC, page size: 4096, OOB size: 224
> pxa3xx-nand f10d0000.nand: ECC strength 16, ECC step size 2048
> Bad block table found at page 262016, version 0x01
> Bad block table found at page 261888, version 0x01
> 3 ofpart partitions found on MTD device pxa3xx_nand-0
> Creating 3 MTD partitions on "pxa3xx_nand-0":
> 0x000000000000-0x000000800000 : "U-Boot"
> 0x000000800000-0x000001000000 : "Linux"
> 0x000001000000-0x000040000000 : "Filesystem"
> mdiobus register device_node: mdio
> libphy: orion_mdio_bus: probed
> mdio_bus f1072004.mdio-mi: /soc/internal-regs/mdio/ethernet-phy at ff PHY
> address 255 is too large
> mvneta_probe: ethernet device: eth%d
> mvneta_probe: phy_node: ethernet-phy
> mvneta f1070000.ethernet eth0: Using hardware mac address 00:50:43:02:02:00
> ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
> ehci-pci: EHCI PCI platform driver
> ehci-orion: EHCI orion driver
> orion-ehci f1050000.usb: EHCI Host Controller
> orion-ehci f1050000.usb: new USB bus registered, assigned bus number 1
> orion-ehci f1050000.usb: irq 26, io mem 0xf1050000
> orion-ehci f1050000.usb: USB 2.0 started, EHCI 1.00
> hub 1-0:1.0: USB hub found
> hub 1-0:1.0: 1 port detected
> usbcore: registered new interface driver usb-storage
> mousedev: PS/2 mouse device common for all mice
> rtc-mv f1010300.rtc: internal RTC not ticking
> orion_wdt: Initial timeout 229 sec
> usbcore: registered new interface driver usbhid
> usbhid: USB HID core driver
> TCP: cubic registered
> Distributed Switch Architecture driver version 0.1
> eth0[0]: detected a Marvell 88E6352 switch
> libphy: dsa slave smi: probed
> ThumbEE CPU extension supported.
> drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
> mvneta_mdio_probe: mvneta_probe: ethernet-phy
> mvneta f1070000.ethernet eth0: could not find the PHY
> mvneta f1070000.ethernet eth0: cannot probe MDIO bus
> IP-Config: Failed to open eth0
> IP-Config: Failed to open lan1
> IP-Config: Failed to open lan2
> IP-Config: Failed to open lan3
> IP-Config: Failed to open lan4
> IP-Config: Failed to open lan6
> IP-Config: No network devices available
>
>
>
>
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel



-- 
Florian

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-13 18:25 ` Guenter Roeck
@ 2014-10-14  6:05   ` post at twien.net
  2014-10-14 13:30     ` Guenter Roeck
  2014-10-14 11:35   ` Richard Cochran
  1 sibling, 1 reply; 19+ messages in thread
From: post at twien.net @ 2014-10-14  6:05 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Guenter,
I'm doing this for my employer and have currently no plans for 
submitting this upstream. Not that I think we will not be willing to, 
but it's still very premature and I have so far not been able to test 
this. Am basically struggling to get 'dsa' up and working.
Best,
Tormod

On 2014-10-13 20:25, Guenter Roeck wrote:
> On Mon, Oct 13, 2014 at 12:14:41PM +0200, post at twien.net wrote:
>> Dear all,
>> I have a custom board equipped with an ARMADA 370 SoC (88f6W11) and
>> a Marvell switch chip (88e6352) (I have written a device driver for
>> the latter).
> 
> Hi Tormod,
> 
> coincidentially, I have a DSA driver for 88e6352 almost ready for 
> submitting it
> upstream. What are your plans for your driver ? Do you plan to submit 
> it
> upstream ? Either case, it would be great if you could share a pointer 
> to it
> so we can make sure that it works for both our use cases.
> 
> I have made my patch set available in the 'dsa' branch of
> https://git.kernel.org/cgit/linux/kernel/git/groeck/linux-staging.git
> in case you are interested.
> 
> Thanks,
> Guenter

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-14  2:08 ` Florian Fainelli
@ 2014-10-14 11:14   ` post at twien.net
  2014-10-14 16:14     ` Florian Fainelli
  0 siblings, 1 reply; 19+ messages in thread
From: post at twien.net @ 2014-10-14 11:14 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Florian,
Thanks for the tip. If you wouldn't mind share your Device Tree source I 
would be pleased.
Best,
Tormod

On 2014-10-14 04:08, Florian Fainelli wrote:
> 2014-10-13 3:14 GMT-07:00  <post@twien.net>:
>> Dear all,
>> I have a custom board equipped with an ARMADA 370 SoC (88f6W11) and a
>> Marvell switch chip (88e6352) (I have written a device driver for the
>> latter).
>> My question is how to set up a proper device tree specification for 
>> the
>> board. The device tree specification is listed below. This is based on 
>> a
>> similar .dts-file for the kirkwood SoC.
>> Further down is a excerpt of the start up sequence. I would imagine 
>> the
>> switch would be installed as the "PHY" for eth0 (which seems not to be 
>> the
>> case). I added some additional printout messages, and from what I can 
>> see a
>> generic device driver is loaded, and eventually the mvneta_open/-probe
>> function states that the PHY can not be found. I have read the 
>> "examples" in
>> the ../boot/dts directory and also read the documentation. There are 
>> some
>> confusing things, for example the "dsa,mii-bus;" specification where I
>> eventually put in "dsa,mii-bus = <&mdio_bus>;". From both the examples 
>> and
>> the documentation it seemed I should specify a device on the mdio_bus, 
>> e.g.
>> "phy0", but when I did the whole thing crashed.
>> So specifying "mdio_bus" at least got me running a bit further, and 
>> the dsa
>> driver was detected and the proper switch device was identified.
>> What I would like to achieve is to get eth0 to connect to port 5 on 
>> the
>> switch using SGMII.
>> Any advice on how to proceed would  be appreciated.
> 
> At this point, what I would do is create a fixed-phy Device Tree node
> for mvneta to hardcode the link indication/speed/duplex, and specify
> the 'phy-mode' property to be "sgmii", and of course, remove the
> 'phy-handle' property such that the fixed PHY is used instead.
> 
> Right now, DSA drivers are not created as regular PHY drivers (which
> is something on my TODO list), such that they do not provide link
> indication towards the CPU Ethernet MAC. Except for the front-panel
> external ports, Ethernet switches does not report standardized link
> parameters through the standard MII registers for the CPU port, which
> is why we have to find another way to do that.
> 
> In case that helps, I could copy/paste a Device Tree source for a
> Broadcom SoC I use which has both of its DSA switch driver (bcm_sf2)
> and Ethernet MAC (bcmsysport) drivers mainline.
> 
> Please note that, in order to boot from the network with DSA-enabled
> devices, you need such a patch:
> http://patchwork.ozlabs.org/patch/354293/
> 
> which I should re-submit eventually
> 
> 
>> 
>> 
>> +---------+
>> |         |           +--------+
>> |         |   SGMII   |        |----- p0
>> |     eth0|-----------|p5      |  .    .
>> |         |           |        |----- p4
>> +---------+           +--------+
>> ARMADA 370             88e6352
>> 
>> 
>> Tormod
>> 
>> 
>> 
>> /*
>>  * Device Tree file for Marvell Armada 370 Ethernet Prototype board
>>  * ()
>>  *
>>  *  Copied from arch/arm/boot/dts/armada-370-rd.dts
>>  *
>>  *  Copyright (C) 2014 ...
>>  *
>>  * This file is licensed under the terms of the GNU General Public
>>  * License version 2.  This program is licensed "as is" without any
>>  * warranty of any kind, whether express or implied.
>>  */
>> 
>> /dts-v1/;
>> #include <dt-bindings/input/input.h>
>> #include <dt-bindings/gpio/gpio.h>
>> #include "armada-370.dtsi"
>> 
>> / {
>>         model = "Marvell Armada 370 Ethernet Prototype";
>>         compatible = "marvell,armada370", "marvell,armada-370-xp";
>> 
>>         chosen {
>>                 bootargs = "console=ttyS0,115200 earlyprintk";
>>         };
>> 
>>         memory {
>>                 device_type = "memory";
>>                 reg = <0x00000000 0x40000000>; /* 1 GB */
>>         };
>> 
>>         soc {
>>                 ranges = <MBUS_ID(0xf0, 0x01) 0 0xf1000000 0x100000
>>                           MBUS_ID(0x01, 0xe0) 0 0xfff00000 0x100000>;
>> 
>> 
>>                 pcie-controller {
>>                         status = "okay";
>> 
>>                         /* Internal mini-PCIe connector */
>>                         pcie at 1,0 {
>>                                 /* Port 0, Lane 0 */
>>                                 status = "okay";
>>                         };
>> 
>>                         /* Internal mini-PCIe connector */
>>                         pcie at 2,0 {
>>                                 /* Port 1, Lane 0 */
>>                                 status = "okay";
>>                         };
>>                 };
>> 
>>                 internal-regs {
>>                         serial at 12000 {
>>                                 status = "okay";
>>                         };
>> 
>>                         mdio_bus: mdio {
>>                                 phy0: ethernet-phy at ff {
>> /*                                      compatible =
>> "ethernet-phy-id5043.0eb0", "ethernet-phy-ieee802.3-c22";
>> */
>>                                         reg = <0xff>;  /* no PHY 
>> connected
>> */
>>                                         speed = <1000>;
>>                                         duplex = <1>;
>>                                 };
>> 
>> /*                              phy1: ethernet-phy at 1 {
>>                                         reg = <0x1>;
>>                                 };
>> */
>>                         };
>> 
>>                         ethernet at 70000 {
>>                                 status = "okay";
>>                                 phy = <&phy0>;
>>                                 phy-mode = "sgmii";
>>                         };
>> 
>> /*                      ethernet at 74000 {
>>                                 status = "okay";
>>                                 phy = <&phy1>;
>>                                 phy-mode = "rgmii-id";
>>                         };
>> */
>>                         mvsdio at d4000 {
>>                                 pinctrl-0 = <&sdio_pins1>;
>>                                 pinctrl-names = "default";
>>                                 status = "okay";
>>                                 /* No CD or WP GPIOs */
>>                                 broken-cd;
>>                         };
>> 
>>                         usb at 50000 {
>>                                 status = "okay";
>>                         };
>> 
>> 
>> /*                      usb at 51000 {
>>                                 status = "okay";
>>                         };
>> */
>>                         spi0: spi at 10600 {
>>                                 status = "okay";
>>                                 };
>> 
>>                         i2c at 11000 {
>>                                 pinctrl-0 = <&i2c0_pins>;
>>                                 pinctrl-names = "default";
>>                                 clock-frequency = <100000>;
>>                                 status = "okay";
>>                         };
>> 
>>                         nand at d0000 {
>>                                 status = "okay";
>>                                 num-cs = <1>;
>>                                 marvell,nand-keep-config;
>>                                 marvell,nand-enable-arbiter;
>>                                 nand-on-flash-bbt;
>> 
>>                                 partition at 0 {
>>                                         label = "U-Boot";
>>                                         reg = <0 0x800000>;
>>                                 };
>>                                 partition at 800000 {
>>                                         label = "Linux";
>>                                         reg = <0x800000 0x800000>;
>>                                 };
>>                                 partition at 1000000 {
>>                                         label = "Filesystem";
>>                                         reg = <0x1000000 0x3f000000>;
>>                                 };
>>                         };
>>                 };
>>         };
>> 
>>         dsa at 0 {
>>                 compatible = "marvell,dsa";
>>                #address-cells = <2>;
>>                 #size-cells = <0>;
>>                 dsa,ethernet = <&eth0>;
>>                 dsa,mii-bus = <&mdio_bus>;
>> 
>>                 switch at 0 {
>>                         #address-cells = <1>;
>>                         #size-cells = <0>;
>> 
>>                         reg = <0 0>;
>> 
>>                         port at 0 {
>>                                 reg = <0>;
>>                                 label = "lan1";
>>                         };
>> 
>>                         port at 1 {
>>                                 reg = <1>;
>>                                 label = "lan2";
>>                         };
>> 
>>                         port at 2 {
>>                                 reg = <2>;
>>                                 label = "lan3";
>>                         };
>> 
>>                         port at 3 {
>>                                 reg = <3>;
>>                                 label = "lan4";
>>                         };
>> 
>>                         port at 5 {
>>                                 reg = <5>;
>>                                 label = "cpu";
>>                         };
>> 
>>                         port at 6 {
>>                                 reg = <6>;
>>                                 label = "lan6";
>>                         };
>>                 };
>>         };
>> 
>>  };
>> 
>> 
>> nand: device found, Manufacturer ID: 0x2c, Chip ID: 0x38
>> nand: Micron MT29F8G08ABABAWP
>> nand: 1024MiB, SLC, page size: 4096, OOB size: 224
>> pxa3xx-nand f10d0000.nand: ECC strength 16, ECC step size 2048
>> Bad block table found at page 262016, version 0x01
>> Bad block table found at page 261888, version 0x01
>> 3 ofpart partitions found on MTD device pxa3xx_nand-0
>> Creating 3 MTD partitions on "pxa3xx_nand-0":
>> 0x000000000000-0x000000800000 : "U-Boot"
>> 0x000000800000-0x000001000000 : "Linux"
>> 0x000001000000-0x000040000000 : "Filesystem"
>> mdiobus register device_node: mdio
>> libphy: orion_mdio_bus: probed
>> mdio_bus f1072004.mdio-mi: /soc/internal-regs/mdio/ethernet-phy at ff PHY
>> address 255 is too large
>> mvneta_probe: ethernet device: eth%d
>> mvneta_probe: phy_node: ethernet-phy
>> mvneta f1070000.ethernet eth0: Using hardware mac address 
>> 00:50:43:02:02:00
>> ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
>> ehci-pci: EHCI PCI platform driver
>> ehci-orion: EHCI orion driver
>> orion-ehci f1050000.usb: EHCI Host Controller
>> orion-ehci f1050000.usb: new USB bus registered, assigned bus number 1
>> orion-ehci f1050000.usb: irq 26, io mem 0xf1050000
>> orion-ehci f1050000.usb: USB 2.0 started, EHCI 1.00
>> hub 1-0:1.0: USB hub found
>> hub 1-0:1.0: 1 port detected
>> usbcore: registered new interface driver usb-storage
>> mousedev: PS/2 mouse device common for all mice
>> rtc-mv f1010300.rtc: internal RTC not ticking
>> orion_wdt: Initial timeout 229 sec
>> usbcore: registered new interface driver usbhid
>> usbhid: USB HID core driver
>> TCP: cubic registered
>> Distributed Switch Architecture driver version 0.1
>> eth0[0]: detected a Marvell 88E6352 switch
>> libphy: dsa slave smi: probed
>> ThumbEE CPU extension supported.
>> drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
>> mvneta_mdio_probe: mvneta_probe: ethernet-phy
>> mvneta f1070000.ethernet eth0: could not find the PHY
>> mvneta f1070000.ethernet eth0: cannot probe MDIO bus
>> IP-Config: Failed to open eth0
>> IP-Config: Failed to open lan1
>> IP-Config: Failed to open lan2
>> IP-Config: Failed to open lan3
>> IP-Config: Failed to open lan4
>> IP-Config: Failed to open lan6
>> IP-Config: No network devices available
>> 
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-13 18:25 ` Guenter Roeck
  2014-10-14  6:05   ` post at twien.net
@ 2014-10-14 11:35   ` Richard Cochran
  2014-10-14 13:24     ` Guenter Roeck
  1 sibling, 1 reply; 19+ messages in thread
From: Richard Cochran @ 2014-10-14 11:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 13, 2014 at 11:25:17AM -0700, Guenter Roeck wrote:
> On Mon, Oct 13, 2014 at 12:14:41PM +0200, post at twien.net wrote:
> > Dear all,
> > I have a custom board equipped with an ARMADA 370 SoC (88f6W11) and
> > a Marvell switch chip (88e6352) (I have written a device driver for
> > the latter).
> 
> Hi Tormod,
> 
> coincidentially, I have a DSA driver for 88e6352 almost ready for submitting it
> upstream. What are your plans for your driver ? Do you plan to submit it
> upstream ? Either case, it would be great if you could share a pointer to it
> so we can make sure that it works for both our use cases.
> 
> I have made my patch set available in the 'dsa' branch of
> https://git.kernel.org/cgit/linux/kernel/git/groeck/linux-staging.git
> in case you are interested.

I am working on a driver for the 88E6350/88E6351 (similar to 6352?),
especially to enable the PTP functionality. It should be done in about
four weeks.

In order to move away from all of the hardcoded numbers for register
access in the current dsa drivers, I have started to make macros for
the various registers, bits, and fields. If you are interested, I
could share that already...

Thanks,
Richard

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-14 11:35   ` Richard Cochran
@ 2014-10-14 13:24     ` Guenter Roeck
  2014-10-23  8:32       ` Richard Cochran
  0 siblings, 1 reply; 19+ messages in thread
From: Guenter Roeck @ 2014-10-14 13:24 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/14/2014 04:35 AM, Richard Cochran wrote:
> On Mon, Oct 13, 2014 at 11:25:17AM -0700, Guenter Roeck wrote:
>> On Mon, Oct 13, 2014 at 12:14:41PM +0200, post at twien.net wrote:
>>> Dear all,
>>> I have a custom board equipped with an ARMADA 370 SoC (88f6W11) and
>>> a Marvell switch chip (88e6352) (I have written a device driver for
>>> the latter).
>>
>> Hi Tormod,
>>
>> coincidentially, I have a DSA driver for 88e6352 almost ready for submitting it
>> upstream. What are your plans for your driver ? Do you plan to submit it
>> upstream ? Either case, it would be great if you could share a pointer to it
>> so we can make sure that it works for both our use cases.
>>
>> I have made my patch set available in the 'dsa' branch of
>> https://git.kernel.org/cgit/linux/kernel/git/groeck/linux-staging.git
>> in case you are interested.
>
> I am working on a driver for the 88E6350/88E6351 (similar to 6352?),
> especially to enable the PTP functionality. It should be done in about
> four weeks.
>
> In order to move away from all of the hardcoded numbers for register
> access in the current dsa drivers, I have started to make macros for
> the various registers, bits, and fields. If you are interested, I
> could share that already...
>
Hi Richard,

Sure, that would be great.

I can not really tell if they are similar; I don't have the datasheet
for the 6350/6351. The datasheet for the 6352 covers a couple of other
switches, but not those two. The 6352 does support PTP; I can see that
much in its datasheet. You could check if my 6352 driver works for you ;-).

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-14  6:05   ` post at twien.net
@ 2014-10-14 13:30     ` Guenter Roeck
  0 siblings, 0 replies; 19+ messages in thread
From: Guenter Roeck @ 2014-10-14 13:30 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/13/2014 11:05 PM, post at twien.net wrote:
> Hi Guenter,
> I'm doing this for my employer and have currently no plans for submitting this upstream. Not that I think we will not be willing to, but it's still very premature and I have so far not been able to test this. Am basically struggling to get 'dsa' up and working.

Hah, yes, that has its own challenges. Took me a while too.
I can send you a working platform file if you think it would help,
though that would be for x86, not for devicetree use.

Also, I could publish a branch with my 6352 driver on top of
the 3.14 kernel (which is where it is currently used) if it helps.

Guenter

> Best,
> Tormod
>
> On 2014-10-13 20:25, Guenter Roeck wrote:
>> On Mon, Oct 13, 2014 at 12:14:41PM +0200, post at twien.net wrote:
>>> Dear all,
>>> I have a custom board equipped with an ARMADA 370 SoC (88f6W11) and
>>> a Marvell switch chip (88e6352) (I have written a device driver for
>>> the latter).
>>
>> Hi Tormod,
>>
>> coincidentially, I have a DSA driver for 88e6352 almost ready for submitting it
>> upstream. What are your plans for your driver ? Do you plan to submit it
>> upstream ? Either case, it would be great if you could share a pointer to it
>> so we can make sure that it works for both our use cases.
>>
>> I have made my patch set available in the 'dsa' branch of
>> https://git.kernel.org/cgit/linux/kernel/git/groeck/linux-staging.git
>> in case you are interested.
>>
>> Thanks,
>> Guenter
>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-14 11:14   ` post at twien.net
@ 2014-10-14 16:14     ` Florian Fainelli
  2014-10-15 13:42       ` post at twien.net
  0 siblings, 1 reply; 19+ messages in thread
From: Florian Fainelli @ 2014-10-14 16:14 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/14/2014 04:14 AM, post at twien.net wrote:
> Hello Florian,
> Thanks for the tip. If you wouldn't mind share your Device Tree source I
> would be pleased.

Here is the DTS for the network controller:

                ethernet at f04a0000 {
                        local-mac-address = [ 00 10 18 a2 23 7b ];
                        systemport,num-txq = <0x20>;
                        #size-cells = <0x1>;
                        systemport,num-rxq = <0x1>;
                        systemport,num-tier2-arb = <0x1>;
                        device_type = "network";
                        fixed-link = <0x0 0x1 0x3e8 0x0 0x0>;
                        phy-mode = "gmii";
                        compatible = "brcm,systemport-v1.00",
"brcm,systemport";
                        systemport,num-tier1-arb = <0x4>;
                        #address-cells = <0x1>;
                        reg = <0xf04a0000 0x4650>;
                        interrupts = <0x0 0x16 0x0 0x0 0x17 0x0>;
                        interrupts-extended = <0x1 0x0 0x16 0x0 0x1 0x0
0x17 0x0 0x9 0x7>;
                        interrupt-names = "systemport_0",
"systemport_1", "wol_systemport";
                        clocks = <0x1a 0x1b>;
                        clock-names = "sw_sysport", "sw_sysportwol";
                        linux,phandle = <0x1c>;
                        phandle = <0x1c>;
                };


Here is the DTS for the switch, it's a little complex, but the node with
"brcm,bcm7445-switch-v4.0" is the one we match in net/dsa/dsa.c.

                switch_top at f0b00000 {
                        compatible = "brcm,bcm7445-switch-top-v2.0",
"simple-bus";
                        #size-cells = <0x1>;
                        #address-cells = <0x1>;
                        ranges = <0x0 0xf0b00000 0x40804>;

                        ethernet_switch at 0 {
                                dsa,ethernet = <0x1c>;
                                brcm,num-gphy = <0x1>;
                                compatible = "brcm,bcm7445-switch-v4.0",
"brcm,bcm53012";
                                brcm,num-rgmii-ports = <0x2>;
                                #address-cells = <0x2>;
                                brcm,num-acb-queues = <0x40>;
                                #size-cells = <0x0>;
                                dsa,mii-bus = <0x1d>;
                                reg = <0x0 0x40000 0x40000 0x110 0x40340
0x30 0x40380 0x30 0x40400 0x34 0x40600 0x208>;
                                reg-names = "core", "reg", "intrl2_0",
"intrl2_1", "fcb", "acb";
                                interrupts = <0x0 0x18 0x0 0x0 0x19 0x0>;
                                interrupt-names = "switch_0", "switch_1";
                                brcm,fcb-pause-override;
                                brcm,acb-packets-inflight;
                                clocks = <0x1e 0x1f>;
                                clock-names = "sw_switch", "sw_switch_mdiv";

                                switch at 0 {
                                        #size-cells = <0x0>;
                                        reg = <0x0 0x0>;
                                        #address-cells = <0x1>;

                                        port at 0 {
                                                phy-mode = "internal";
                                                phy-handle = <0x8c>;
                                                linux,phandle = <0x8a>;
                                                phandle = <0x8a>;
                                                reg = <0x0>;
                                                label = "gphy";
                                        };

                                        port at 1 {
                                                phy-mode = "rgmii-txid";
                                                phy-handle = <0x8e>;
                                                linux,phandle = <0x8d>;
                                                phandle = <0x8d>;
                                                reg = <0x1>;
                                                label = "rgmii_1";
                                        };

                                        port at 2 {
                                                phy-mode = "rgmii-txid";
                                                fixed-link = <0x2 0x1
0x3e8 0x0 0x0>;
                                                linux,phandle = <0x8f>;
                                                phandle = <0x8f>;
                                                reg = <0x2>;
                                                label = "rgmii_2";
                                        };

                                        port at 7 {
                                                phy-mode = "moca";
                                                fixed-link = <0x7 0x1
0x3e8 0x0 0x0>;
                                                linux,phandle = <0x90>;
                                                phandle = <0x90>;
                                                reg = <0x7>;
                                                label = "moca";
                                        };

                                        port at 8 {
                                                linux,phandle = <0x91>;
                                                phandle = <0x91>;
                                                reg = <0x8>;
                                                label = "cpu";
                                        };
                                };
                        };

                        mdio at 403c0 {
                                reg = <0x403c0 0x8 0x40300 0x18>;
                                #size-cells = <0x1>;
                                compatible = "brcm,bcm7445-mdio-v4.0",
"brcm,unimac-mdio";
                                reg-names = "mdio", "mdio_indir_rw";
                                #address-cells = <0x0>;
                                linux,phandle = <0x1d>;
                                phandle = <0x1d>;

                                phy0: ethernet-phy at 0 {
                                        linux,phandle = <0x8e>;
                                        phandle = <0x8e>;
                                        device_type = "ethernet-phy";
                                        max-speed = <0x3e8>;
                                        reg = <0x0>;
                                        compatible = "brcm,bcm53125",
"ethernet-phy-ieee802.3-c22";
                                };

                                phy5: ethernet-phy at 5 {
                                        linux,phandle = <0x8c>;
                                        phandle = <0x8c>;
                                        clock-names = "sw_gphy";
                                        clocks = <0x8b>;
                                        device_type = "ethernet-phy";
                                        max-speed = <0x3e8>;
                                        reg = <0x5>;
                                        compatible = "brcm,28nm-gphy",
"ethernet-phy-ieee802.3-c22";
                                };
                        };
                };

> Best,
> Tormod
> 
> On 2014-10-14 04:08, Florian Fainelli wrote:
>> 2014-10-13 3:14 GMT-07:00  <post@twien.net>:
>>> Dear all,
>>> I have a custom board equipped with an ARMADA 370 SoC (88f6W11) and a
>>> Marvell switch chip (88e6352) (I have written a device driver for the
>>> latter).
>>> My question is how to set up a proper device tree specification for the
>>> board. The device tree specification is listed below. This is based on a
>>> similar .dts-file for the kirkwood SoC.
>>> Further down is a excerpt of the start up sequence. I would imagine the
>>> switch would be installed as the "PHY" for eth0 (which seems not to
>>> be the
>>> case). I added some additional printout messages, and from what I can
>>> see a
>>> generic device driver is loaded, and eventually the mvneta_open/-probe
>>> function states that the PHY can not be found. I have read the
>>> "examples" in
>>> the ../boot/dts directory and also read the documentation. There are
>>> some
>>> confusing things, for example the "dsa,mii-bus;" specification where I
>>> eventually put in "dsa,mii-bus = <&mdio_bus>;". From both the
>>> examples and
>>> the documentation it seemed I should specify a device on the
>>> mdio_bus, e.g.
>>> "phy0", but when I did the whole thing crashed.
>>> So specifying "mdio_bus" at least got me running a bit further, and
>>> the dsa
>>> driver was detected and the proper switch device was identified.
>>> What I would like to achieve is to get eth0 to connect to port 5 on the
>>> switch using SGMII.
>>> Any advice on how to proceed would  be appreciated.
>>
>> At this point, what I would do is create a fixed-phy Device Tree node
>> for mvneta to hardcode the link indication/speed/duplex, and specify
>> the 'phy-mode' property to be "sgmii", and of course, remove the
>> 'phy-handle' property such that the fixed PHY is used instead.
>>
>> Right now, DSA drivers are not created as regular PHY drivers (which
>> is something on my TODO list), such that they do not provide link
>> indication towards the CPU Ethernet MAC. Except for the front-panel
>> external ports, Ethernet switches does not report standardized link
>> parameters through the standard MII registers for the CPU port, which
>> is why we have to find another way to do that.
>>
>> In case that helps, I could copy/paste a Device Tree source for a
>> Broadcom SoC I use which has both of its DSA switch driver (bcm_sf2)
>> and Ethernet MAC (bcmsysport) drivers mainline.
>>
>> Please note that, in order to boot from the network with DSA-enabled
>> devices, you need such a patch:
>> http://patchwork.ozlabs.org/patch/354293/
>>
>> which I should re-submit eventually
>>
>>
>>>
>>>
>>> +---------+
>>> |         |           +--------+
>>> |         |   SGMII   |        |----- p0
>>> |     eth0|-----------|p5      |  .    .
>>> |         |           |        |----- p4
>>> +---------+           +--------+
>>> ARMADA 370             88e6352
>>>
>>>
>>> Tormod
>>>
>>>
>>>
>>> /*
>>>  * Device Tree file for Marvell Armada 370 Ethernet Prototype board
>>>  * ()
>>>  *
>>>  *  Copied from arch/arm/boot/dts/armada-370-rd.dts
>>>  *
>>>  *  Copyright (C) 2014 ...
>>>  *
>>>  * This file is licensed under the terms of the GNU General Public
>>>  * License version 2.  This program is licensed "as is" without any
>>>  * warranty of any kind, whether express or implied.
>>>  */
>>>
>>> /dts-v1/;
>>> #include <dt-bindings/input/input.h>
>>> #include <dt-bindings/gpio/gpio.h>
>>> #include "armada-370.dtsi"
>>>
>>> / {
>>>         model = "Marvell Armada 370 Ethernet Prototype";
>>>         compatible = "marvell,armada370", "marvell,armada-370-xp";
>>>
>>>         chosen {
>>>                 bootargs = "console=ttyS0,115200 earlyprintk";
>>>         };
>>>
>>>         memory {
>>>                 device_type = "memory";
>>>                 reg = <0x00000000 0x40000000>; /* 1 GB */
>>>         };
>>>
>>>         soc {
>>>                 ranges = <MBUS_ID(0xf0, 0x01) 0 0xf1000000 0x100000
>>>                           MBUS_ID(0x01, 0xe0) 0 0xfff00000 0x100000>;
>>>
>>>
>>>                 pcie-controller {
>>>                         status = "okay";
>>>
>>>                         /* Internal mini-PCIe connector */
>>>                         pcie at 1,0 {
>>>                                 /* Port 0, Lane 0 */
>>>                                 status = "okay";
>>>                         };
>>>
>>>                         /* Internal mini-PCIe connector */
>>>                         pcie at 2,0 {
>>>                                 /* Port 1, Lane 0 */
>>>                                 status = "okay";
>>>                         };
>>>                 };
>>>
>>>                 internal-regs {
>>>                         serial at 12000 {
>>>                                 status = "okay";
>>>                         };
>>>
>>>                         mdio_bus: mdio {
>>>                                 phy0: ethernet-phy at ff {
>>> /*                                      compatible =
>>> "ethernet-phy-id5043.0eb0", "ethernet-phy-ieee802.3-c22";
>>> */
>>>                                         reg = <0xff>;  /* no PHY
>>> connected
>>> */
>>>                                         speed = <1000>;
>>>                                         duplex = <1>;
>>>                                 };
>>>
>>> /*                              phy1: ethernet-phy at 1 {
>>>                                         reg = <0x1>;
>>>                                 };
>>> */
>>>                         };
>>>
>>>                         ethernet at 70000 {
>>>                                 status = "okay";
>>>                                 phy = <&phy0>;
>>>                                 phy-mode = "sgmii";
>>>                         };
>>>
>>> /*                      ethernet at 74000 {
>>>                                 status = "okay";
>>>                                 phy = <&phy1>;
>>>                                 phy-mode = "rgmii-id";
>>>                         };
>>> */
>>>                         mvsdio at d4000 {
>>>                                 pinctrl-0 = <&sdio_pins1>;
>>>                                 pinctrl-names = "default";
>>>                                 status = "okay";
>>>                                 /* No CD or WP GPIOs */
>>>                                 broken-cd;
>>>                         };
>>>
>>>                         usb at 50000 {
>>>                                 status = "okay";
>>>                         };
>>>
>>>
>>> /*                      usb at 51000 {
>>>                                 status = "okay";
>>>                         };
>>> */
>>>                         spi0: spi at 10600 {
>>>                                 status = "okay";
>>>                                 };
>>>
>>>                         i2c at 11000 {
>>>                                 pinctrl-0 = <&i2c0_pins>;
>>>                                 pinctrl-names = "default";
>>>                                 clock-frequency = <100000>;
>>>                                 status = "okay";
>>>                         };
>>>
>>>                         nand at d0000 {
>>>                                 status = "okay";
>>>                                 num-cs = <1>;
>>>                                 marvell,nand-keep-config;
>>>                                 marvell,nand-enable-arbiter;
>>>                                 nand-on-flash-bbt;
>>>
>>>                                 partition at 0 {
>>>                                         label = "U-Boot";
>>>                                         reg = <0 0x800000>;
>>>                                 };
>>>                                 partition at 800000 {
>>>                                         label = "Linux";
>>>                                         reg = <0x800000 0x800000>;
>>>                                 };
>>>                                 partition at 1000000 {
>>>                                         label = "Filesystem";
>>>                                         reg = <0x1000000 0x3f000000>;
>>>                                 };
>>>                         };
>>>                 };
>>>         };
>>>
>>>         dsa at 0 {
>>>                 compatible = "marvell,dsa";
>>>                #address-cells = <2>;
>>>                 #size-cells = <0>;
>>>                 dsa,ethernet = <&eth0>;
>>>                 dsa,mii-bus = <&mdio_bus>;
>>>
>>>                 switch at 0 {
>>>                         #address-cells = <1>;
>>>                         #size-cells = <0>;
>>>
>>>                         reg = <0 0>;
>>>
>>>                         port at 0 {
>>>                                 reg = <0>;
>>>                                 label = "lan1";
>>>                         };
>>>
>>>                         port at 1 {
>>>                                 reg = <1>;
>>>                                 label = "lan2";
>>>                         };
>>>
>>>                         port at 2 {
>>>                                 reg = <2>;
>>>                                 label = "lan3";
>>>                         };
>>>
>>>                         port at 3 {
>>>                                 reg = <3>;
>>>                                 label = "lan4";
>>>                         };
>>>
>>>                         port at 5 {
>>>                                 reg = <5>;
>>>                                 label = "cpu";
>>>                         };
>>>
>>>                         port at 6 {
>>>                                 reg = <6>;
>>>                                 label = "lan6";
>>>                         };
>>>                 };
>>>         };
>>>
>>>  };
>>>
>>>
>>> nand: device found, Manufacturer ID: 0x2c, Chip ID: 0x38
>>> nand: Micron MT29F8G08ABABAWP
>>> nand: 1024MiB, SLC, page size: 4096, OOB size: 224
>>> pxa3xx-nand f10d0000.nand: ECC strength 16, ECC step size 2048
>>> Bad block table found at page 262016, version 0x01
>>> Bad block table found at page 261888, version 0x01
>>> 3 ofpart partitions found on MTD device pxa3xx_nand-0
>>> Creating 3 MTD partitions on "pxa3xx_nand-0":
>>> 0x000000000000-0x000000800000 : "U-Boot"
>>> 0x000000800000-0x000001000000 : "Linux"
>>> 0x000001000000-0x000040000000 : "Filesystem"
>>> mdiobus register device_node: mdio
>>> libphy: orion_mdio_bus: probed
>>> mdio_bus f1072004.mdio-mi: /soc/internal-regs/mdio/ethernet-phy at ff PHY
>>> address 255 is too large
>>> mvneta_probe: ethernet device: eth%d
>>> mvneta_probe: phy_node: ethernet-phy
>>> mvneta f1070000.ethernet eth0: Using hardware mac address
>>> 00:50:43:02:02:00
>>> ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
>>> ehci-pci: EHCI PCI platform driver
>>> ehci-orion: EHCI orion driver
>>> orion-ehci f1050000.usb: EHCI Host Controller
>>> orion-ehci f1050000.usb: new USB bus registered, assigned bus number 1
>>> orion-ehci f1050000.usb: irq 26, io mem 0xf1050000
>>> orion-ehci f1050000.usb: USB 2.0 started, EHCI 1.00
>>> hub 1-0:1.0: USB hub found
>>> hub 1-0:1.0: 1 port detected
>>> usbcore: registered new interface driver usb-storage
>>> mousedev: PS/2 mouse device common for all mice
>>> rtc-mv f1010300.rtc: internal RTC not ticking
>>> orion_wdt: Initial timeout 229 sec
>>> usbcore: registered new interface driver usbhid
>>> usbhid: USB HID core driver
>>> TCP: cubic registered
>>> Distributed Switch Architecture driver version 0.1
>>> eth0[0]: detected a Marvell 88E6352 switch
>>> libphy: dsa slave smi: probed
>>> ThumbEE CPU extension supported.
>>> drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
>>> mvneta_mdio_probe: mvneta_probe: ethernet-phy
>>> mvneta f1070000.ethernet eth0: could not find the PHY
>>> mvneta f1070000.ethernet eth0: cannot probe MDIO bus
>>> IP-Config: Failed to open eth0
>>> IP-Config: Failed to open lan1
>>> IP-Config: Failed to open lan2
>>> IP-Config: Failed to open lan3
>>> IP-Config: Failed to open lan4
>>> IP-Config: Failed to open lan6
>>> IP-Config: No network devices available
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> linux-arm-kernel mailing list
>>> linux-arm-kernel at lists.infradead.org
>>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-14 16:14     ` Florian Fainelli
@ 2014-10-15 13:42       ` post at twien.net
  2014-10-15 13:47         ` Guenter Roeck
  0 siblings, 1 reply; 19+ messages in thread
From: post at twien.net @ 2014-10-15 13:42 UTC (permalink / raw)
  To: linux-arm-kernel

Thanks, using the fixed-link option made me "talk" to the switch.
Now I have to work on 88e6352 driver :-)
Tormod


On 2014-10-14 18:14, Florian Fainelli wrote:
> On 10/14/2014 04:14 AM, post at twien.net wrote:
>> Hello Florian,
>> Thanks for the tip. If you wouldn't mind share your Device Tree source 
>> I
>> would be pleased.
> 
> Here is the DTS for the network controller:
> 
>                 ethernet at f04a0000 {
>                         local-mac-address = [ 00 10 18 a2 23 7b ];
>                         systemport,num-txq = <0x20>;
>                         #size-cells = <0x1>;
>                         systemport,num-rxq = <0x1>;
>                         systemport,num-tier2-arb = <0x1>;
>                         device_type = "network";
>                         fixed-link = <0x0 0x1 0x3e8 0x0 0x0>;
>                         phy-mode = "gmii";
>                         compatible = "brcm,systemport-v1.00",
> "brcm,systemport";
>                         systemport,num-tier1-arb = <0x4>;
>                         #address-cells = <0x1>;
>                         reg = <0xf04a0000 0x4650>;
>                         interrupts = <0x0 0x16 0x0 0x0 0x17 0x0>;
>                         interrupts-extended = <0x1 0x0 0x16 0x0 0x1 0x0
> 0x17 0x0 0x9 0x7>;
>                         interrupt-names = "systemport_0",
> "systemport_1", "wol_systemport";
>                         clocks = <0x1a 0x1b>;
>                         clock-names = "sw_sysport", "sw_sysportwol";
>                         linux,phandle = <0x1c>;
>                         phandle = <0x1c>;
>                 };
> 
> 
> Here is the DTS for the switch, it's a little complex, but the node 
> with
> "brcm,bcm7445-switch-v4.0" is the one we match in net/dsa/dsa.c.
> 
>                 switch_top at f0b00000 {
>                         compatible = "brcm,bcm7445-switch-top-v2.0",
> "simple-bus";
>                         #size-cells = <0x1>;
>                         #address-cells = <0x1>;
>                         ranges = <0x0 0xf0b00000 0x40804>;
> 
>                         ethernet_switch at 0 {
>                                 dsa,ethernet = <0x1c>;
>                                 brcm,num-gphy = <0x1>;
>                                 compatible = 
> "brcm,bcm7445-switch-v4.0",
> "brcm,bcm53012";
>                                 brcm,num-rgmii-ports = <0x2>;
>                                 #address-cells = <0x2>;
>                                 brcm,num-acb-queues = <0x40>;
>                                 #size-cells = <0x0>;
>                                 dsa,mii-bus = <0x1d>;
>                                 reg = <0x0 0x40000 0x40000 0x110 
> 0x40340
> 0x30 0x40380 0x30 0x40400 0x34 0x40600 0x208>;
>                                 reg-names = "core", "reg", "intrl2_0",
> "intrl2_1", "fcb", "acb";
>                                 interrupts = <0x0 0x18 0x0 0x0 0x19 
> 0x0>;
>                                 interrupt-names = "switch_0", 
> "switch_1";
>                                 brcm,fcb-pause-override;
>                                 brcm,acb-packets-inflight;
>                                 clocks = <0x1e 0x1f>;
>                                 clock-names = "sw_switch", 
> "sw_switch_mdiv";
> 
>                                 switch at 0 {
>                                         #size-cells = <0x0>;
>                                         reg = <0x0 0x0>;
>                                         #address-cells = <0x1>;
> 
>                                         port at 0 {
>                                                 phy-mode = "internal";
>                                                 phy-handle = <0x8c>;
>                                                 linux,phandle = <0x8a>;
>                                                 phandle = <0x8a>;
>                                                 reg = <0x0>;
>                                                 label = "gphy";
>                                         };
> 
>                                         port at 1 {
>                                                 phy-mode = 
> "rgmii-txid";
>                                                 phy-handle = <0x8e>;
>                                                 linux,phandle = <0x8d>;
>                                                 phandle = <0x8d>;
>                                                 reg = <0x1>;
>                                                 label = "rgmii_1";
>                                         };
> 
>                                         port at 2 {
>                                                 phy-mode = 
> "rgmii-txid";
>                                                 fixed-link = <0x2 0x1
> 0x3e8 0x0 0x0>;
>                                                 linux,phandle = <0x8f>;
>                                                 phandle = <0x8f>;
>                                                 reg = <0x2>;
>                                                 label = "rgmii_2";
>                                         };
> 
>                                         port at 7 {
>                                                 phy-mode = "moca";
>                                                 fixed-link = <0x7 0x1
> 0x3e8 0x0 0x0>;
>                                                 linux,phandle = <0x90>;
>                                                 phandle = <0x90>;
>                                                 reg = <0x7>;
>                                                 label = "moca";
>                                         };
> 
>                                         port at 8 {
>                                                 linux,phandle = <0x91>;
>                                                 phandle = <0x91>;
>                                                 reg = <0x8>;
>                                                 label = "cpu";
>                                         };
>                                 };
>                         };
> 
>                         mdio at 403c0 {
>                                 reg = <0x403c0 0x8 0x40300 0x18>;
>                                 #size-cells = <0x1>;
>                                 compatible = "brcm,bcm7445-mdio-v4.0",
> "brcm,unimac-mdio";
>                                 reg-names = "mdio", "mdio_indir_rw";
>                                 #address-cells = <0x0>;
>                                 linux,phandle = <0x1d>;
>                                 phandle = <0x1d>;
> 
>                                 phy0: ethernet-phy at 0 {
>                                         linux,phandle = <0x8e>;
>                                         phandle = <0x8e>;
>                                         device_type = "ethernet-phy";
>                                         max-speed = <0x3e8>;
>                                         reg = <0x0>;
>                                         compatible = "brcm,bcm53125",
> "ethernet-phy-ieee802.3-c22";
>                                 };
> 
>                                 phy5: ethernet-phy at 5 {
>                                         linux,phandle = <0x8c>;
>                                         phandle = <0x8c>;
>                                         clock-names = "sw_gphy";
>                                         clocks = <0x8b>;
>                                         device_type = "ethernet-phy";
>                                         max-speed = <0x3e8>;
>                                         reg = <0x5>;
>                                         compatible = "brcm,28nm-gphy",
> "ethernet-phy-ieee802.3-c22";
>                                 };
>                         };
>                 };
> 
>> Best,
>> Tormod
>> 
>> On 2014-10-14 04:08, Florian Fainelli wrote:
>>> 2014-10-13 3:14 GMT-07:00  <post@twien.net>:
>>>> Dear all,
>>>> I have a custom board equipped with an ARMADA 370 SoC (88f6W11) and 
>>>> a
>>>> Marvell switch chip (88e6352) (I have written a device driver for 
>>>> the
>>>> latter).
>>>> My question is how to set up a proper device tree specification for 
>>>> the
>>>> board. The device tree specification is listed below. This is based 
>>>> on a
>>>> similar .dts-file for the kirkwood SoC.
>>>> Further down is a excerpt of the start up sequence. I would imagine 
>>>> the
>>>> switch would be installed as the "PHY" for eth0 (which seems not to
>>>> be the
>>>> case). I added some additional printout messages, and from what I 
>>>> can
>>>> see a
>>>> generic device driver is loaded, and eventually the 
>>>> mvneta_open/-probe
>>>> function states that the PHY can not be found. I have read the
>>>> "examples" in
>>>> the ../boot/dts directory and also read the documentation. There are
>>>> some
>>>> confusing things, for example the "dsa,mii-bus;" specification where 
>>>> I
>>>> eventually put in "dsa,mii-bus = <&mdio_bus>;". From both the
>>>> examples and
>>>> the documentation it seemed I should specify a device on the
>>>> mdio_bus, e.g.
>>>> "phy0", but when I did the whole thing crashed.
>>>> So specifying "mdio_bus" at least got me running a bit further, and
>>>> the dsa
>>>> driver was detected and the proper switch device was identified.
>>>> What I would like to achieve is to get eth0 to connect to port 5 on 
>>>> the
>>>> switch using SGMII.
>>>> Any advice on how to proceed would  be appreciated.
>>> 
>>> At this point, what I would do is create a fixed-phy Device Tree node
>>> for mvneta to hardcode the link indication/speed/duplex, and specify
>>> the 'phy-mode' property to be "sgmii", and of course, remove the
>>> 'phy-handle' property such that the fixed PHY is used instead.
>>> 
>>> Right now, DSA drivers are not created as regular PHY drivers (which
>>> is something on my TODO list), such that they do not provide link
>>> indication towards the CPU Ethernet MAC. Except for the front-panel
>>> external ports, Ethernet switches does not report standardized link
>>> parameters through the standard MII registers for the CPU port, which
>>> is why we have to find another way to do that.
>>> 
>>> In case that helps, I could copy/paste a Device Tree source for a
>>> Broadcom SoC I use which has both of its DSA switch driver (bcm_sf2)
>>> and Ethernet MAC (bcmsysport) drivers mainline.
>>> 
>>> Please note that, in order to boot from the network with DSA-enabled
>>> devices, you need such a patch:
>>> http://patchwork.ozlabs.org/patch/354293/
>>> 
>>> which I should re-submit eventually
>>> 
>>> 
>>>> 
>>>> 
>>>> +---------+
>>>> |         |           +--------+
>>>> |         |   SGMII   |        |----- p0
>>>> |     eth0|-----------|p5      |  .    .
>>>> |         |           |        |----- p4
>>>> +---------+           +--------+
>>>> ARMADA 370             88e6352
>>>> 
>>>> 
>>>> Tormod
>>>> 
>>>> 
>>>> 
>>>> /*
>>>>  * Device Tree file for Marvell Armada 370 Ethernet Prototype board
>>>>  * ()
>>>>  *
>>>>  *  Copied from arch/arm/boot/dts/armada-370-rd.dts
>>>>  *
>>>>  *  Copyright (C) 2014 ...
>>>>  *
>>>>  * This file is licensed under the terms of the GNU General Public
>>>>  * License version 2.  This program is licensed "as is" without any
>>>>  * warranty of any kind, whether express or implied.
>>>>  */
>>>> 
>>>> /dts-v1/;
>>>> #include <dt-bindings/input/input.h>
>>>> #include <dt-bindings/gpio/gpio.h>
>>>> #include "armada-370.dtsi"
>>>> 
>>>> / {
>>>>         model = "Marvell Armada 370 Ethernet Prototype";
>>>>         compatible = "marvell,armada370", "marvell,armada-370-xp";
>>>> 
>>>>         chosen {
>>>>                 bootargs = "console=ttyS0,115200 earlyprintk";
>>>>         };
>>>> 
>>>>         memory {
>>>>                 device_type = "memory";
>>>>                 reg = <0x00000000 0x40000000>; /* 1 GB */
>>>>         };
>>>> 
>>>>         soc {
>>>>                 ranges = <MBUS_ID(0xf0, 0x01) 0 0xf1000000 0x100000
>>>>                           MBUS_ID(0x01, 0xe0) 0 0xfff00000 
>>>> 0x100000>;
>>>> 
>>>> 
>>>>                 pcie-controller {
>>>>                         status = "okay";
>>>> 
>>>>                         /* Internal mini-PCIe connector */
>>>>                         pcie at 1,0 {
>>>>                                 /* Port 0, Lane 0 */
>>>>                                 status = "okay";
>>>>                         };
>>>> 
>>>>                         /* Internal mini-PCIe connector */
>>>>                         pcie at 2,0 {
>>>>                                 /* Port 1, Lane 0 */
>>>>                                 status = "okay";
>>>>                         };
>>>>                 };
>>>> 
>>>>                 internal-regs {
>>>>                         serial at 12000 {
>>>>                                 status = "okay";
>>>>                         };
>>>> 
>>>>                         mdio_bus: mdio {
>>>>                                 phy0: ethernet-phy at ff {
>>>> /*                                      compatible =
>>>> "ethernet-phy-id5043.0eb0", "ethernet-phy-ieee802.3-c22";
>>>> */
>>>>                                         reg = <0xff>;  /* no PHY
>>>> connected
>>>> */
>>>>                                         speed = <1000>;
>>>>                                         duplex = <1>;
>>>>                                 };
>>>> 
>>>> /*                              phy1: ethernet-phy at 1 {
>>>>                                         reg = <0x1>;
>>>>                                 };
>>>> */
>>>>                         };
>>>> 
>>>>                         ethernet at 70000 {
>>>>                                 status = "okay";
>>>>                                 phy = <&phy0>;
>>>>                                 phy-mode = "sgmii";
>>>>                         };
>>>> 
>>>> /*                      ethernet at 74000 {
>>>>                                 status = "okay";
>>>>                                 phy = <&phy1>;
>>>>                                 phy-mode = "rgmii-id";
>>>>                         };
>>>> */
>>>>                         mvsdio at d4000 {
>>>>                                 pinctrl-0 = <&sdio_pins1>;
>>>>                                 pinctrl-names = "default";
>>>>                                 status = "okay";
>>>>                                 /* No CD or WP GPIOs */
>>>>                                 broken-cd;
>>>>                         };
>>>> 
>>>>                         usb at 50000 {
>>>>                                 status = "okay";
>>>>                         };
>>>> 
>>>> 
>>>> /*                      usb at 51000 {
>>>>                                 status = "okay";
>>>>                         };
>>>> */
>>>>                         spi0: spi at 10600 {
>>>>                                 status = "okay";
>>>>                                 };
>>>> 
>>>>                         i2c at 11000 {
>>>>                                 pinctrl-0 = <&i2c0_pins>;
>>>>                                 pinctrl-names = "default";
>>>>                                 clock-frequency = <100000>;
>>>>                                 status = "okay";
>>>>                         };
>>>> 
>>>>                         nand at d0000 {
>>>>                                 status = "okay";
>>>>                                 num-cs = <1>;
>>>>                                 marvell,nand-keep-config;
>>>>                                 marvell,nand-enable-arbiter;
>>>>                                 nand-on-flash-bbt;
>>>> 
>>>>                                 partition at 0 {
>>>>                                         label = "U-Boot";
>>>>                                         reg = <0 0x800000>;
>>>>                                 };
>>>>                                 partition at 800000 {
>>>>                                         label = "Linux";
>>>>                                         reg = <0x800000 0x800000>;
>>>>                                 };
>>>>                                 partition at 1000000 {
>>>>                                         label = "Filesystem";
>>>>                                         reg = <0x1000000 
>>>> 0x3f000000>;
>>>>                                 };
>>>>                         };
>>>>                 };
>>>>         };
>>>> 
>>>>         dsa at 0 {
>>>>                 compatible = "marvell,dsa";
>>>>                #address-cells = <2>;
>>>>                 #size-cells = <0>;
>>>>                 dsa,ethernet = <&eth0>;
>>>>                 dsa,mii-bus = <&mdio_bus>;
>>>> 
>>>>                 switch at 0 {
>>>>                         #address-cells = <1>;
>>>>                         #size-cells = <0>;
>>>> 
>>>>                         reg = <0 0>;
>>>> 
>>>>                         port at 0 {
>>>>                                 reg = <0>;
>>>>                                 label = "lan1";
>>>>                         };
>>>> 
>>>>                         port at 1 {
>>>>                                 reg = <1>;
>>>>                                 label = "lan2";
>>>>                         };
>>>> 
>>>>                         port at 2 {
>>>>                                 reg = <2>;
>>>>                                 label = "lan3";
>>>>                         };
>>>> 
>>>>                         port at 3 {
>>>>                                 reg = <3>;
>>>>                                 label = "lan4";
>>>>                         };
>>>> 
>>>>                         port at 5 {
>>>>                                 reg = <5>;
>>>>                                 label = "cpu";
>>>>                         };
>>>> 
>>>>                         port at 6 {
>>>>                                 reg = <6>;
>>>>                                 label = "lan6";
>>>>                         };
>>>>                 };
>>>>         };
>>>> 
>>>>  };
>>>> 
>>>> 
>>>> nand: device found, Manufacturer ID: 0x2c, Chip ID: 0x38
>>>> nand: Micron MT29F8G08ABABAWP
>>>> nand: 1024MiB, SLC, page size: 4096, OOB size: 224
>>>> pxa3xx-nand f10d0000.nand: ECC strength 16, ECC step size 2048
>>>> Bad block table found at page 262016, version 0x01
>>>> Bad block table found at page 261888, version 0x01
>>>> 3 ofpart partitions found on MTD device pxa3xx_nand-0
>>>> Creating 3 MTD partitions on "pxa3xx_nand-0":
>>>> 0x000000000000-0x000000800000 : "U-Boot"
>>>> 0x000000800000-0x000001000000 : "Linux"
>>>> 0x000001000000-0x000040000000 : "Filesystem"
>>>> mdiobus register device_node: mdio
>>>> libphy: orion_mdio_bus: probed
>>>> mdio_bus f1072004.mdio-mi: /soc/internal-regs/mdio/ethernet-phy at ff 
>>>> PHY
>>>> address 255 is too large
>>>> mvneta_probe: ethernet device: eth%d
>>>> mvneta_probe: phy_node: ethernet-phy
>>>> mvneta f1070000.ethernet eth0: Using hardware mac address
>>>> 00:50:43:02:02:00
>>>> ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
>>>> ehci-pci: EHCI PCI platform driver
>>>> ehci-orion: EHCI orion driver
>>>> orion-ehci f1050000.usb: EHCI Host Controller
>>>> orion-ehci f1050000.usb: new USB bus registered, assigned bus number 
>>>> 1
>>>> orion-ehci f1050000.usb: irq 26, io mem 0xf1050000
>>>> orion-ehci f1050000.usb: USB 2.0 started, EHCI 1.00
>>>> hub 1-0:1.0: USB hub found
>>>> hub 1-0:1.0: 1 port detected
>>>> usbcore: registered new interface driver usb-storage
>>>> mousedev: PS/2 mouse device common for all mice
>>>> rtc-mv f1010300.rtc: internal RTC not ticking
>>>> orion_wdt: Initial timeout 229 sec
>>>> usbcore: registered new interface driver usbhid
>>>> usbhid: USB HID core driver
>>>> TCP: cubic registered
>>>> Distributed Switch Architecture driver version 0.1
>>>> eth0[0]: detected a Marvell 88E6352 switch
>>>> libphy: dsa slave smi: probed
>>>> ThumbEE CPU extension supported.
>>>> drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
>>>> mvneta_mdio_probe: mvneta_probe: ethernet-phy
>>>> mvneta f1070000.ethernet eth0: could not find the PHY
>>>> mvneta f1070000.ethernet eth0: cannot probe MDIO bus
>>>> IP-Config: Failed to open eth0
>>>> IP-Config: Failed to open lan1
>>>> IP-Config: Failed to open lan2
>>>> IP-Config: Failed to open lan3
>>>> IP-Config: Failed to open lan4
>>>> IP-Config: Failed to open lan6
>>>> IP-Config: No network devices available
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> _______________________________________________
>>>> linux-arm-kernel mailing list
>>>> linux-arm-kernel at lists.infradead.org
>>>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-15 13:42       ` post at twien.net
@ 2014-10-15 13:47         ` Guenter Roeck
  0 siblings, 0 replies; 19+ messages in thread
From: Guenter Roeck @ 2014-10-15 13:47 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/15/2014 06:42 AM, post at twien.net wrote:
> Thanks, using the fixed-link option made me "talk" to the switch.
> Now I have to work on 88e6352 driver :-)

Or just take the one I wrote :-)

Guenter

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-14 13:24     ` Guenter Roeck
@ 2014-10-23  8:32       ` Richard Cochran
  0 siblings, 0 replies; 19+ messages in thread
From: Richard Cochran @ 2014-10-23  8:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Oct 14, 2014 at 06:24:32AM -0700, Guenter Roeck wrote:
> I can not really tell if they are similar; I don't have the datasheet
> for the 6350/6351. The datasheet for the 6352 covers a couple of other
> switches, but not those two. The 6352 does support PTP; I can see that
> much in its datasheet. You could check if my 6352 driver works for you ;-).

(Sorry for the delay in replying.)

Here is my current set of definitions. Probably you can see whether
the 6352 is similar enough or not. I keep a text file with register
definitions, and a little tool to format the C-code output. If you
like this approach, we can add any other fields or bits you may need.

Using the macros, you can code like this.

	u16 management, upstream = dsa_upstream_port(ds);

	management = REG_READ(REG_GLOBAL2, SW_MANAGEMENT);
	management |= RSVD_2_CPU;
	REG_WRITE(REG_GLOBAL2, SW_MANAGEMENT, management);

	REG_WRITE(REG_GLOBAL, MONITOR_DEST,
		  (upstream & CPU_DST_MASK) << CPU_DST_SHIFT);

That mostly eliminates the need for comment blocks explaining the
hardcoded numbers.

Thanks,
Richard

---
/* mv88e635x_reg.h
 * Generated by regen.tcl on Tue Oct 14 19:39:45 CEST 2014
 */
#ifndef HAVE_MV88E635X_REGISTERS
#define HAVE_MV88E635X_REGISTERS

#define PORT_REGISTERS             0x0010
#define PORT_STATUS                0x0000
#define PHYSICAL_CONTROL           0x0001
#define JAMMING_CONTROL            0x0002
#define SWITCH_IDENTIFIER          0x0003
#define PORT_CONTROL               0x0004
#define PORT_CONTROL_1             0x0005
#define PORT_BASED_VLAN_MAP        0x0006
#define PORT_VLAN_ID_PRI           0x0007
#define PORT_CONTROL_2             0x0008
#define EGRESS_RATE_CTRL           0x0009
#define EGRESS_RATE_CTRL_2         0x000a
#define PORT_ASSOC_VECTOR          0x000b
#define PORT_ATU_CONTROL           0x000c
#define PRIORITY_OVERRIDE          0x000d
#define POLICY_CONTROL             0x000e
#define PORT_ETHERTYPE             0x000f

#define GLOBAL_1_REGISTERS         0x001b
#define GLOBAL_STATUS              0x0000
#define ATU_FID                    0x0001
#define VTU_FID                    0x0002
#define VTU_SID                    0x0003
#define GLOBAL_CONTROL             0x0004
#define VTU_OPERATION              0x0005
#define VTU_VID                    0x0006
#define VTU_DATA_PORTS_30          0x0007
#define VTU_DATA_PORTS_74          0x0008
#define VTU_DATA_PORTS_A8          0x0009
#define ATU_CONTROL                0x000a
#define ATU_OPERATION              0x000b
#define ATU_DATA                   0x000c
#define ATU_MAC_01                 0x000d
#define ATU_MAC_23                 0x000e
#define ATU_MAC_45                 0x000f
#define IEEE_TAG_PRIORITY          0x0018
#define IP_PRI_MAPPING             0x0019
#define MONITOR_DEST               0x001a
#define FREE_POOL                  0x001b
#define GLOBAL_CONTROL_2           0x001c
#define STATS_OPERATION            0x001d
#define STATS_DATA_32              0x001e
#define STATS_DATA_10              0x001f

#define GLOBAL_2_REGISTERS         0x001c
#define INTERRUPT_SOURCE           0x0000
#define INTERRUPT_MASK             0x0001
#define MGMT_ENABLES_2X            0x0002
#define MGMT_ENABLES_0X            0x0003
#define FLOW_CONTROL_DELAYS        0x0004
#define SW_MANAGEMENT              0x0005
#define DEVICE_MAPPING             0x0006
#define TRUNK_MASK                 0x0007
#define TRUNK_MAPPING              0x0008
#define INGRESS_RATE_CMD           0x0009
#define INGRESS_RATE_DATA          0x000a
#define CROSSPORT_VLAN_ADDR        0x000b
#define CROSSPORT_VLAN_DATA        0x000c
#define SWITCH_MAC                 0x000d
#define ATU_STATS                  0x000e
#define PRIORITY_OVERRIDES         0x000f
#define EEPROM_CMD                 0x0014
#define EEPROM_DATA                0x0015
#define AVB_CMD                    0x0016
#define AVB_DATA                   0x0017
#define SMI_PHY_COMMAND            0x0018
#define SMI_PHY_DATA               0x0019
#define SCRATCH                    0x001a
#define WATCH_DOG_CONTROL          0x001b
#define QOS_WEIGHTS                0x001c

#define PTP_PORT_REGISTERS         0x0000
#define PTP_PORT_CONFIG_0          0x0000
#define PTP_PORT_CONFIG_1          0x0001
#define PTP_PORT_CONFIG_2          0x0002
#define PTP_ARR0_STATUS            0x0008
#define PTP_ARR0_TIME_LOW          0x0009 /* Receive time stamp 0 [15:0] */
#define PTP_ARR0_TIME_HIGH         0x000a /* Receive time stamp 0 [31:16] */
#define PTP_ARR0_SEQID             0x000b /* Receive time stamp 0 sequence ID */
#define PTP_ARR1_STATUS            0x000c
#define PTP_ARR1_TIME_LOW          0x000d /* Receive time stamp 1 [15:0] */
#define PTP_ARR1_TIME_HIGH         0x000e /* Receive time stamp 1 [31:16] */
#define PTP_ARR1_SEQID             0x000f /* Receive time stamp 1 sequence ID */
#define PTP_DEP_STATUS             0x0010
#define PTP_DEP_TIME_LOW           0x0011 /* Transmit time stamp [15:0] */
#define PTP_DEP_TIME_HIGH          0x0012 /* Transmit time stamp [31:16] */
#define PTP_DEP_SEQID              0x0013 /* Transmit time stamp sequence ID */
#define PTP_PORT_DIS_CTRS          0x0015

#define TAI_GLOBAL_REGISTERS       0x000e
#define TAI_GLOBAL_CONFIG_0        0x0000
#define TSCLKPER                   0x0001 /* Clock period in picoseconds */
#define TRIG_GEN_AMT_LOW           0x0002 /* Trig. generation amount [15:0] */
#define TRIG_GEN_AMT_HIGH          0x0003 /* Trig. generation amount [31:16] */
#define TRIG_CLK_COMP              0x0004 /* Addend in picoseconds */
#define TAI_GLOBAL_CONFIG_1        0x0005
#define TRIG_GEN_INT_STATUS        0x0008
#define EVENT_STATUS               0x0009
#define EVENT_TIME_LOW             0x000a
#define EVENT_TIME_HIGH            0x000b
#define PTP_TIME_LOW               0x000e
#define PTP_TIME_HIGH              0x000f

#define PTP_GLOBAL_REGISTERS       0x000f
#define PTP_ETHERTYPE              0x0000 /* PTP Ethertype */
#define MSG_ID_TS_EN               0x0001 /* Message ID time stamp enable */
#define TS_ARR_PTR                 0x0002 /* Rx time stamp slot */
#define PTP_INT                    0x0008 /* Per port PTP interrupt */

/* Bit definitions for the SWITCH_IDENTIFIER register */
#define PRODUCT_NUM_SHIFT          (4)     /* Product number or identifier */
#define PRODUCT_NUM_MASK           (0xfff)
#define REV_IDENTIFIER_SHIFT       (0)
#define REV_IDENTIFIER_MASK        (0xf)

/* Bit definitions for the PORT_CONTROL register */
#define SA_FILTERING_SHIFT         (14)    /* Source address filter control */
#define SA_FILTERING_MASK          (0x3)
#define EGRESS_MODE_SHIFT          (12)
#define EGRESS_MODE_MASK           (0x3)
#define HEADER_MODE                (1<<11) /* Ingress/egress header mode */
#define IGMP_MLD_SNOOP             (1<<10)
#define FRAME_MODE_SHIFT           (8)
#define FRAME_MODE_MASK            (0x3)
#define VLAN_TUNNEL                (1<<7)
#define TAG_IF_BOTH                (1<<6)
#define INITIAL_PRI_SHIFT          (4)
#define INITIAL_PRI_MASK           (0x3)
#define EGRESS_FLOODS_SHIFT        (2)
#define EGRESS_FLOODS_MASK         (0x3)
#define PORT_STATE_SHIFT           (0)
#define PORT_STATE_MASK            (0x3)

/* Bit definitions for the ATU_OPERATION register */
#define ATU_BUSY                   (1<<15) /* Address Translation Unit Busy */
#define ATU_OP_SHIFT               (12)    /* Address Translation Unit Opcode */
#define ATU_OP_MASK                (0x7)
#define MAC_PRI_SHIFT              (8)     /* MAC Priority bits */
#define MAC_PRI_MASK               (0x7)
#define AGEOUT_VIOLATION           (1<<7)
#define MEMBER_VIOLATION           (1<<6)
#define MISS_VIOLATION             (1<<5)
#define ATUFULL_VIOLATION          (1<<4)

/* Bit definitions for the ATU_DATA register */
#define TRUNK                      (1<<15) /* Trunk Mapped Address */
#define PORT_VEC_SHIFT             (4)     /* Port Vector */
#define PORT_VEC_MASK              (0xff)
#define ENTRY_STATE_SHIFT          (0)     /* ATU Entry State */
#define ENTRY_STATE_MASK           (0xf)

/* Bit definitions for the MONITOR_DEST register */
#define INGRESS_MON_DST_SHIFT      (12)    /* Ingress monitor destination */
#define INGRESS_MON_DST_MASK       (0xf)
#define EGRESS_MON_DST_SHIFT       (8)     /* Egress monitor destination */
#define EGRESS_MON_DST_MASK        (0xf)
#define CPU_DST_SHIFT              (4)     /* CPU destination port */
#define CPU_DST_MASK               (0xf)
#define MIRROR_DST_SHIFT           (0)     /* Mirror destination port */
#define MIRROR_DST_MASK            (0xf)

/* Bit definitions for the SW_MANAGEMENT register */
#define LOOPBACK_FILTER            (1<<15)
#define FLOW_CTRL_MSG              (1<<13)
#define FLOOD_BC                   (1<<12)
#define REMOVE_1P_TAG              (1<<11)
#define ATU_AGE_INT_EN             (1<<10)
#define TAG_FLOW_CONTROL           (1<<9)
#define FORCE_FLOW_CTRL_PRI        (1<<7)
#define FC_PRI_SHIFT               (4)     /* Flow control priority */
#define FC_PRI_MASK                (0x7)
#define RSVD_2_CPU                 (1<<3)
#define MGMT_PRI_SHIFT             (0)
#define MGMT_PRI_MASK              (0x7)

/* Bit definitions for the AVB_CMD register */
#define AVB_BUSY                   (1<<15)
#define AVB_OP_SHIFT               (12)    /* AVB unit operation code */
#define AVB_OP_MASK                (0x7)
#define AVB_PORT_SHIFT             (8)     /* Port index or 0xf for globals */
#define AVB_PORT_MASK              (0xf)
#define AVB_BLOCK_SHIFT            (5)     /* Address block */
#define AVB_BLOCK_MASK             (0x7)
#define AVB_ADDR_SHIFT             (0)
#define AVB_ADDR_MASK              (0x1f)

/* Bit definitions for the PTP_PORT_CONFIG_0 register */
#define TRANS_SPEC_SHIFT           (12)    /* Transport specific value */
#define TRANS_SPEC_MASK            (0xf)
#define DIS_TSPEC_CHECK            (1<<11) /* Disable transport check */
#define DIS_TS_OVERWRITE           (1<<1)  /* Disable time stamp overwriting */
#define DIS_PTP                    (1<<0)  /* Disable time stamp logic */

/* Bit definitions for the PTP_PORT_CONFIG_1 register */
#define IP_JUMP_SHIFT              (8)     /* Internet Protocol jump */
#define IP_JUMP_MASK               (0x3f)
#define ET_JUMP_SHIFT              (0)     /* Ethertype jump */
#define ET_JUMP_MASK               (0x1f)

/* Bit definitions for the PTP_PORT_CONFIG_2 register */
#define PTP_DEP_INT_EN             (1<<1)  /* Transmit interrupt enable */
#define PTP_ARR_INT_EN             (1<<0)  /* Receive interrupt enable */

/* Bit definitions for the PTP_ARR0_STATUS register */
#define PTP_INT_STATUS_SHIFT       (1)     /* Time stamp interrupt status */
#define PTP_INT_STATUS_MASK        (0x3)
#define PTP_TS_TIMEVALID           (1<<0)  /* Indicates time stamp valid */

/* Bit definitions for the PTP_PORT_DIS_CTRS register */
#define PTP_TS_DEPDISCTR_SHIFT     (12)    /* Tx event message discard count */
#define PTP_TS_DEPDISCTR_MASK      (0xf)
#define PTP_NTS_DEPDISCTR_SHIFT    (8)     /* Tx general msg discard count */
#define PTP_NTS_DEPDISCTR_MASK     (0xf)
#define PTP_TS_ARRDISCTR_SHIFT     (4)     /* Rx event message discard count */
#define PTP_TS_ARRDISCTR_MASK      (0xf)
#define PTP_NTS_ARRDISCTR_SHIFT    (0)     /* Rx general msg discard count */
#define PTP_NTS_ARRDISCTR_MASK     (0xf)

/* Bit definitions for the TAI_GLOBAL_CONFIG_0 register */
#define EVENT_CAP_OV               (1<<15) /* Event capture overwrite */
#define EVENT_CTR_START            (1<<14) /* Event counter start */
#define TRIG_GEN_INT_EN            (1<<9)  /* Trigger interrupt enable */
#define EVENT_CAP_INT_EN           (1<<8)  /* Event interrupt enable */
#define TIME_INC_DEC_EN            (1<<3)  /* Enable time adjustment */
#define MULTIPTP_SYNCMODE          (1<<2)  /* Multiple device sync mode */
#define TRIG_MODE                  (1<<1)  /* Trigger Mode */
#define TRIG_GEN_REQ               (1<<0)  /* Trigger generation request */

/* Bit definitions for the TAI_GLOBAL_CONFIG_1 register */
#define PULSE_WIDTH_SHIFT          (12)    /* Pulse width in TSCLKPER units */
#define PULSE_WIDTH_MASK           (0xf)
#define TIME_INC_DEC_OP            (1<<11) /* Sign for TIME_INC_DEC_AMT */
#define TIME_INC_DEC_AMT_SHIFT     (0)     /* Time adjustment amount */
#define TIME_INC_DEC_AMT_MASK      (0x7ff)

/* Bit definitions for the TRIG_GEN_INT_STATUS register */
#define TRIG_GEN_INT               (1<<15) /* Trigger generation interrupt */

/* Bit definitions for the EVENT_STATUS register */
#define EVENT_INT                  (1<<15) /* Event capture interrupt */
#define EVENT_CAP_ERR              (1<<9)  /* Event capture error */
#define EVENT_CAP_VALID            (1<<8)  /* Event capture valid */
#define EVENT_CAP_CTR_SHIFT        (0)     /* Event capture counter */
#define EVENT_CAP_CTR_MASK         (0xff)

/* Bit definitions for the MSG_ID_TS_EN register */
#define SYNC                       (1<<0)
#define DELAY_REQ                  (1<<1)
#define PDELAY_REQ                 (1<<2)
#define PDELAY_RESP                (1<<3)
#define FOLLOW_UP                  (1<<8)
#define DELAY_RESP                 (1<<9)
#define PDELAY_RESP_FUP            (1<<10)
#define ANNOUNCE                   (1<<11)
#define SIGNALING                  (1<<12)
#define MANAGEMENT                 (1<<13)

#endif

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-13 11:19 ` Jason Cooper
@ 2014-10-23  9:20   ` Thomas Petazzoni
  2014-10-23 12:10     ` Jason Cooper
  0 siblings, 1 reply; 19+ messages in thread
From: Thomas Petazzoni @ 2014-10-23  9:20 UTC (permalink / raw)
  To: linux-arm-kernel

Hello all,

I'm catching up on some past e-mails. Has this DSA issue been resolved?
I thought Andrew has done some DSA related work at some point? If not,
we could also involve Florian Fainelli in the loop, as he has done
quite a bit of DSA related stuff if I remember correctly.

Best regards,

Thomas

On Mon, 13 Oct 2014 07:19:04 -0400, Jason Cooper wrote:
> Tormod,
> 
> Sorry, I don't have time to reply atm.  However, I'm adding the mvebu
> devs and maintainers to the Cc.  You can also hit us up at #mvlinux on
> freenode.
> 
> thx,
> 
> Jason.
> 
> On Mon, Oct 13, 2014 at 12:14:41PM +0200, post at twien.net wrote:
> > Dear all,
> > I have a custom board equipped with an ARMADA 370 SoC (88f6W11) and
> > a Marvell switch chip (88e6352) (I have written a device driver for
> > the latter).
> > My question is how to set up a proper device tree specification for
> > the board. The device tree specification is listed below. This is
> > based on a similar .dts-file for the kirkwood SoC.
> > Further down is a excerpt of the start up sequence. I would imagine
> > the switch would be installed as the "PHY" for eth0 (which seems not
> > to be the case). I added some additional printout messages, and from
> > what I can see a generic device driver is loaded, and eventually the
> > mvneta_open/-probe function states that the PHY can not be found. I
> > have read the "examples" in the ../boot/dts directory and also read
> > the documentation. There are some confusing things, for example the
> > "dsa,mii-bus;" specification where I eventually put in "dsa,mii-bus
> > = <&mdio_bus>;". From both the examples and the documentation it
> > seemed I should specify a device on the mdio_bus, e.g. "phy0", but
> > when I did the whole thing crashed.
> > So specifying "mdio_bus" at least got me running a bit further, and
> > the dsa driver was detected and the proper switch device was
> > identified.
> > What I would like to achieve is to get eth0 to connect to port 5 on
> > the switch using SGMII.
> > Any advice on how to proceed would  be appreciated.
> > 
> > 
> > +---------+
> > |         |           +--------+
> > |         |   SGMII   |        |----- p0
> > |     eth0|-----------|p5      |  .    .
> > |         |           |        |----- p4
> > +---------+           +--------+
> > ARMADA 370             88e6352
> > 
> > 
> > Tormod
> > 
> > 
> > 
> > /*
> >  * Device Tree file for Marvell Armada 370 Ethernet Prototype board
> >  * ()
> >  *
> >  *  Copied from arch/arm/boot/dts/armada-370-rd.dts
> >  *
> >  *  Copyright (C) 2014 ...
> >  *
> >  * This file is licensed under the terms of the GNU General Public
> >  * License version 2.  This program is licensed "as is" without any
> >  * warranty of any kind, whether express or implied.
> >  */
> > 
> > /dts-v1/;
> > #include <dt-bindings/input/input.h>
> > #include <dt-bindings/gpio/gpio.h>
> > #include "armada-370.dtsi"
> > 
> > / {
> > 	model = "Marvell Armada 370 Ethernet Prototype";
> > 	compatible = "marvell,armada370", "marvell,armada-370-xp";
> > 
> > 	chosen {
> > 		bootargs = "console=ttyS0,115200 earlyprintk";
> > 	};
> > 
> > 	memory {
> > 		device_type = "memory";
> > 		reg = <0x00000000 0x40000000>; /* 1 GB */
> > 	};
> > 
> > 	soc {
> > 		ranges = <MBUS_ID(0xf0, 0x01) 0 0xf1000000 0x100000
> > 			  MBUS_ID(0x01, 0xe0) 0 0xfff00000 0x100000>;
> > 
> > 
> >                 pcie-controller {
> >                         status = "okay";
> > 
> >                         /* Internal mini-PCIe connector */
> >                         pcie at 1,0 {
> >                                 /* Port 0, Lane 0 */
> >                                 status = "okay";
> >                         };
> > 
> >                         /* Internal mini-PCIe connector */
> >                         pcie at 2,0 {
> >                                 /* Port 1, Lane 0 */
> >                                 status = "okay";
> >                         };
> >                 };
> > 
> > 		internal-regs {
> > 			serial at 12000 {
> > 				status = "okay";
> > 			};
> > 
> > 			mdio_bus: mdio {
> > 				phy0: ethernet-phy at ff {
> > /*					compatible = "ethernet-phy-id5043.0eb0",
> > "ethernet-phy-ieee802.3-c22";
> > */
> > 					reg = <0xff>;  /* no PHY connected */
> > 					speed = <1000>;
> > 					duplex = <1>;
> > 				};
> > 
> > /*				phy1: ethernet-phy at 1 {
> > 					reg = <0x1>;
> > 				};
> > */
> > 			};
> > 
> > 			ethernet at 70000 {
> > 				status = "okay";
> > 				phy = <&phy0>;
> > 				phy-mode = "sgmii";
> > 			};
> > 
> > /*			ethernet at 74000 {
> > 				status = "okay";
> > 				phy = <&phy1>;
> > 				phy-mode = "rgmii-id";
> > 			};
> > */
> > 			mvsdio at d4000 {
> > 				pinctrl-0 = <&sdio_pins1>;
> > 				pinctrl-names = "default";
> > 				status = "okay";
> > 				/* No CD or WP GPIOs */
> > 				broken-cd;
> > 			};
> > 
> > 			usb at 50000 {
> > 				status = "okay";
> > 			};
> > 
> > 
> > /*			usb at 51000 {
> > 				status = "okay";
> > 			};
> > */
> > 			spi0: spi at 10600 {
> >                                 status = "okay";
> >                                 };
> > 
> > 			i2c at 11000 {
> >                                 pinctrl-0 = <&i2c0_pins>;
> >                                 pinctrl-names = "default";
> >                                 clock-frequency = <100000>;
> >                                 status = "okay";
> >                         };
> > 
> > 			nand at d0000 {
> > 				status = "okay";
> > 				num-cs = <1>;
> > 				marvell,nand-keep-config;
> > 				marvell,nand-enable-arbiter;
> > 				nand-on-flash-bbt;
> > 
> > 				partition at 0 {
> > 					label = "U-Boot";
> > 					reg = <0 0x800000>;
> > 				};
> > 				partition at 800000 {
> > 					label = "Linux";
> > 					reg = <0x800000 0x800000>;
> > 				};
> > 				partition at 1000000 {
> > 					label = "Filesystem";
> > 					reg = <0x1000000 0x3f000000>;
> > 				};
> > 			};
> > 		};
> > 	};
> > 
> > 	dsa at 0 {
> >                	compatible = "marvell,dsa";
> >                #address-cells = <2>;
> >                 #size-cells = <0>;
> >                	dsa,ethernet = <&eth0>;
> >                 dsa,mii-bus = <&mdio_bus>;
> > 
> >        	        switch at 0 {
> >                	        #address-cells = <1>;
> >                        	#size-cells = <0>;
> > 
> > 			reg = <0 0>;
> > 
> >        	                port at 0 {
> >                	                reg = <0>;
> >                        	        label = "lan1";
> >                         };
> > 
> >        	                port at 1 {
> >                	                reg = <1>;
> >                        	        label = "lan2";
> >                         };
> > 
> >        	                port at 2 {
> >                	                reg = <2>;
> >                        	        label = "lan3";
> >                         };
> > 
> >        	                port at 3 {
> >                	                reg = <3>;
> >                        	        label = "lan4";
> >                         };
> > 
> >        	                port at 5 {
> >                	                reg = <5>;
> >                        	        label = "cpu";
> >                         };
> > 
> > 			port at 6 {
> > 				reg = <6>;
> > 				label = "lan6";
> > 			};
> > 	 	};
> > 	};
> > 
> >  };
> > 
> > 
> > nand: device found, Manufacturer ID: 0x2c, Chip ID: 0x38
> > nand: Micron MT29F8G08ABABAWP
> > nand: 1024MiB, SLC, page size: 4096, OOB size: 224
> > pxa3xx-nand f10d0000.nand: ECC strength 16, ECC step size 2048
> > Bad block table found at page 262016, version 0x01
> > Bad block table found at page 261888, version 0x01
> > 3 ofpart partitions found on MTD device pxa3xx_nand-0
> > Creating 3 MTD partitions on "pxa3xx_nand-0":
> > 0x000000000000-0x000000800000 : "U-Boot"
> > 0x000000800000-0x000001000000 : "Linux"
> > 0x000001000000-0x000040000000 : "Filesystem"
> > mdiobus register device_node: mdio
> > libphy: orion_mdio_bus: probed
> > mdio_bus f1072004.mdio-mi: /soc/internal-regs/mdio/ethernet-phy at ff
> > PHY address 255 is too large
> > mvneta_probe: ethernet device: eth%d
> > mvneta_probe: phy_node: ethernet-phy
> > mvneta f1070000.ethernet eth0: Using hardware mac address
> > 00:50:43:02:02:00
> > ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
> > ehci-pci: EHCI PCI platform driver
> > ehci-orion: EHCI orion driver
> > orion-ehci f1050000.usb: EHCI Host Controller
> > orion-ehci f1050000.usb: new USB bus registered, assigned bus number 1
> > orion-ehci f1050000.usb: irq 26, io mem 0xf1050000
> > orion-ehci f1050000.usb: USB 2.0 started, EHCI 1.00
> > hub 1-0:1.0: USB hub found
> > hub 1-0:1.0: 1 port detected
> > usbcore: registered new interface driver usb-storage
> > mousedev: PS/2 mouse device common for all mice
> > rtc-mv f1010300.rtc: internal RTC not ticking
> > orion_wdt: Initial timeout 229 sec
> > usbcore: registered new interface driver usbhid
> > usbhid: USB HID core driver
> > TCP: cubic registered
> > Distributed Switch Architecture driver version 0.1
> > eth0[0]: detected a Marvell 88E6352 switch
> > libphy: dsa slave smi: probed
> > ThumbEE CPU extension supported.
> > drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
> > mvneta_mdio_probe: mvneta_probe: ethernet-phy
> > mvneta f1070000.ethernet eth0: could not find the PHY
> > mvneta f1070000.ethernet eth0: cannot probe MDIO bus
> > IP-Config: Failed to open eth0
> > IP-Config: Failed to open lan1
> > IP-Config: Failed to open lan2
> > IP-Config: Failed to open lan3
> > IP-Config: Failed to open lan4
> > IP-Config: Failed to open lan6
> > IP-Config: No network devices available
> > 
> > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel at lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> > 



-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-23  9:20   ` Thomas Petazzoni
@ 2014-10-23 12:10     ` Jason Cooper
  2014-10-23 12:57       ` post at twien.net
  0 siblings, 1 reply; 19+ messages in thread
From: Jason Cooper @ 2014-10-23 12:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Oct 23, 2014 at 11:20:02AM +0200, Thomas Petazzoni wrote:
> Hello all,
> 
> I'm catching up on some past e-mails. Has this DSA issue been resolved?
> I thought Andrew has done some DSA related work at some point? If not,
> we could also involve Florian Fainelli in the loop, as he has done
> quite a bit of DSA related stuff if I remember correctly.

The discussion is slow, but ongoing, but not underneath this email I
sent out.  Parent is here:

  https://lkml.kernel.org/r/f1e8d1ba750bfb63f84471d0ec7de988 at twien.net

thx,

Jason.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-23 12:10     ` Jason Cooper
@ 2014-10-23 12:57       ` post at twien.net
  2014-10-23 14:05         ` Andrew Lunn
  0 siblings, 1 reply; 19+ messages in thread
From: post at twien.net @ 2014-10-23 12:57 UTC (permalink / raw)
  To: linux-arm-kernel

Hello all,
It's progressing. Have had little time to work on it lately, but have 
got the 6352 switch up and running except for port 6 (the one with 
external PHY). It's currently commented out in my device tree 
specification. Enabling port 6 in the .dts file causes the dsa setup to 
fail (error -5).
BR,
Tormod

On 2014-10-23 14:10, Jason Cooper wrote:
> On Thu, Oct 23, 2014 at 11:20:02AM +0200, Thomas Petazzoni wrote:
>> Hello all,
>> 
>> I'm catching up on some past e-mails. Has this DSA issue been 
>> resolved?
>> I thought Andrew has done some DSA related work at some point? If not,
>> we could also involve Florian Fainelli in the loop, as he has done
>> quite a bit of DSA related stuff if I remember correctly.
> 
> The discussion is slow, but ongoing, but not underneath this email I
> sent out.  Parent is here:
> 
>   https://lkml.kernel.org/r/f1e8d1ba750bfb63f84471d0ec7de988 at twien.net
> 
> thx,
> 
> Jason.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-23 12:57       ` post at twien.net
@ 2014-10-23 14:05         ` Andrew Lunn
  2014-10-23 14:19           ` post at twien.net
  0 siblings, 1 reply; 19+ messages in thread
From: Andrew Lunn @ 2014-10-23 14:05 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Oct 23, 2014 at 02:57:45PM +0200, post at twien.net wrote:
> Hello all,
> It's progressing. Have had little time to work on it lately, but
> have got the 6352 switch up and running except for port 6 (the one
> with external PHY). It's currently commented out in my device tree
> specification. Enabling port 6 in the .dts file causes the dsa setup
> to fail (error -5).

What kernel version are you using?

I recently swapped to 3.18-rc1 and my DIR665 is no longer doing
correct auto-negotiation. The interfaces come up 10/half duplex, and i
need to restart autoneg with ethtool before i get full Gbps.  So it
looks like there is something wrong with phys somewhere.

      Andrew

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ARMADA 370 - Distributed Switch Architecture (dsa) - device tree
  2014-10-23 14:05         ` Andrew Lunn
@ 2014-10-23 14:19           ` post at twien.net
  0 siblings, 0 replies; 19+ messages in thread
From: post at twien.net @ 2014-10-23 14:19 UTC (permalink / raw)
  To: linux-arm-kernel

3.16.3
Tormod

On 2014-10-23 16:05, Andrew Lunn wrote:
> On Thu, Oct 23, 2014 at 02:57:45PM +0200, post at twien.net wrote:
>> Hello all,
>> It's progressing. Have had little time to work on it lately, but
>> have got the 6352 switch up and running except for port 6 (the one
>> with external PHY). It's currently commented out in my device tree
>> specification. Enabling port 6 in the .dts file causes the dsa setup
>> to fail (error -5).
> 
> What kernel version are you using?
> 
> I recently swapped to 3.18-rc1 and my DIR665 is no longer doing
> correct auto-negotiation. The interfaces come up 10/half duplex, and i
> need to restart autoneg with ethtool before i get full Gbps.  So it
> looks like there is something wrong with phys somewhere.
> 
>       Andrew

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2014-10-23 14:19 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-13 10:14 ARMADA 370 - Distributed Switch Architecture (dsa) - device tree post at twien.net
2014-10-13 11:19 ` Jason Cooper
2014-10-23  9:20   ` Thomas Petazzoni
2014-10-23 12:10     ` Jason Cooper
2014-10-23 12:57       ` post at twien.net
2014-10-23 14:05         ` Andrew Lunn
2014-10-23 14:19           ` post at twien.net
2014-10-13 13:19 ` Andrew Lunn
2014-10-13 18:25 ` Guenter Roeck
2014-10-14  6:05   ` post at twien.net
2014-10-14 13:30     ` Guenter Roeck
2014-10-14 11:35   ` Richard Cochran
2014-10-14 13:24     ` Guenter Roeck
2014-10-23  8:32       ` Richard Cochran
2014-10-14  2:08 ` Florian Fainelli
2014-10-14 11:14   ` post at twien.net
2014-10-14 16:14     ` Florian Fainelli
2014-10-15 13:42       ` post at twien.net
2014-10-15 13:47         ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.