netdev/phy: 10G PHY support.
Subsystems (7)
cover netdev/phy: 10G PHY support.
From: David Daney <[email protected]>
The existing PHY driver infrastructure supports IEEE 802.3 Clause 22 PHYs used with 10/100/1000MB Ethernet. For 10G Ethernet, many PHYs use 802.3 Clause 45. These patches attempt to add core support for this as well as drivers for several different 10G PHY devices.
This is reworked from patches I send about 9 months ago:
http://marc.info/?l=linux-netdev&m=131844282403852
Several of the patches have device tree bindings in them, so the device tree people get to enjoy them too.
David Daney (5):
netdev/phy: Handle IEEE802.3 clause 45 Ethernet PHYs netdev/phy/of: Handle IEEE802.3 clause 45 Ethernet PHYs in
of_mdiobus_register()
netdev/phy/of: Add more methods for binding PHY devices to drivers. netdev/phy: Add driver for Broadcom BCM87XX 10G Ethernet PHYs netdev/phy: Add driver for Cortina cs4321 quad 10G PHY.
.../devicetree/bindings/net/broadcom-bcm87xx.txt | 29 + .../devicetree/bindings/net/cortina-cs4321.txt | 27 + Documentation/devicetree/bindings/net/phy.txt | 12 +- drivers/net/phy/Kconfig | 11 + drivers/net/phy/Makefile | 2 + drivers/net/phy/bcm87xx.c | 237 ++ drivers/net/phy/cs4321-ucode.h | 4378 ++++++++++++++++++++ drivers/net/phy/cs4321.c | 1147 +++++ drivers/net/phy/mdio_bus.c | 7 + drivers/net/phy/phy_device.c | 110 +- drivers/of/of_mdio.c | 14 +- include/linux/phy.h | 32 +- 12 files changed, 5993 insertions(+), 13 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/broadcom-bcm87xx.txt create mode 100644 Documentation/devicetree/bindings/net/cortina-cs4321.txt create mode 100644 drivers/net/phy/bcm87xx.c create mode 100644 drivers/net/phy/cs4321-ucode.h create mode 100644 drivers/net/phy/cs4321.c
Signature · 1 line
1.7.2.3
PATCH 1/5 netdev/phy: Handle IEEE802.3 clause 45 Ethernet PHYs
From: David Daney <[email protected]>
The IEEE802.3 clause 45 MDIO bus protocol allows for directly addressing PHY registers using a 21 bit address, and is used by many 10G Ethernet PHYS. Already existing is the ability of MDIO bus drivers to use clause 45, with the MII_ADDR_C45 flag. Here we add struct phy_c45_device_ids to hold the device identifier registers present in clause 45. struct phy_device gets a couple of new fields:c45_ids to hold the identifiers and is_c45 to signal that it is clause 45.
Normally the MII_ADDR_C45 flag is ORed with the register address to indicate a clause 45 transaction. Here we also use this flag in the *device* address passed to get_phy_device() to indicate that probing should be done with clause 45 transactions.
EXPORT phy_device_create() so that the follow-on patch to of_mdio.c can use it to create phy devices for PHYs, that have non-standard device identifier registers, based on the device tree bindings.
--- drivers/net/phy/phy_device.c | 110 +++++++++++++++++++++++++++++++++++++++--- include/linux/phy.h | 25 +++++++++- 2 files changed, 126 insertions(+), 9 deletions(-)
drivers/net/phy/phy_device.c +103 -7
@@ -149,8 +149,8 @@ int phy_scan_fixups(struct phy_device *phydev) }EXPORT_SYMBOL (phy_scan_fixups); -static struct phy_device *phy_device_create (struct mii_bus *bus, -int addr,int phy_id) +struct phy_device *phy_device_create (struct mii_bus *bus,int addr,int phy_id, +struct phy_c45_device_ids *c45_ids) {struct phy_device *dev;
@@ -171,8 +171,12 @@ static struct phy_device* phy_device_create(struct mii_bus *bus, dev->autoneg =AUTONEG_ENABLE ; + dev->is_c45 = (addr &MII_ADDR_C45 ) !=0 ; + addr &= ~MII_ADDR_C45 ; dev->addr = addr; dev->phy_id = phy_id; +if (c45_ids) + dev->c45_ids = *c45_ids; dev->bus = bus; dev->dev.parent = bus->parent; dev->dev.bus = &mdio_bus_type;
@@ -197,20 +201,104 @@ static struct phy_device* phy_device_create(struct mii_bus *bus,return dev; } +EXPORT_SYMBOL (phy_device_create); + +/** +* get_phy_c45_ids - reads the specified addr for its 802.3-c45 IDs. +* @bus: the target MII bus +* @addr: PHY address on the MII bus +* @phy_id: where to store the ID retrieved. +* @c45_ids: where to store the c45 ID information. +* +* If the PHY devices-in-package appears to be valid, it and the +* corresponding identifiers are stored in @c45_ids, zero is stored +* in @phy_id. Otherwise 0xffffffff is stored in @phy_id. Returns +* zero on success. +* +*/ +static int get_phy_c45_ids (struct mii_bus *bus,int addr,u32 *phy_id, +struct phy_c45_device_ids *c45_ids) { +int phy_reg; +int i, reg_addr; + +/* +* Find first non-zero Devices In package. Device +* zero is reserved, so don't probe it. +*/ +for (i =1 ; + i <ARRAY_SIZE (c45_ids->device_ids) && + c45_ids->devices_in_package ==0 ; + i++) { + reg_addr =MII_ADDR_C45 | i <<16 |6 ; + phy_reg =mdiobus_read (bus, addr, reg_addr); +if (phy_reg <0 ) +return -EIO ; + c45_ids->devices_in_package = (phy_reg &0xffff ) <<16 ; + + + reg_addr =MII_ADDR_C45 | i <<16 |5 ; + phy_reg =mdiobus_read (bus, addr, reg_addr); +if (phy_reg <0 ) +return -EIO ; + c45_ids->devices_in_package |= (phy_reg &0xffff ); + +/* +* If mostly Fs, there is no device there, +* let's get out of here. +*/ +if ((c45_ids->devices_in_package &0x1fffffff ) ==0x1fffffff ) { + *phy_id =0xffffffff ; +return 0 ; + } + } + +/* Now probe Device Identifiers for each device present. */ +for (i =1 ; i <ARRAY_SIZE (c45_ids->device_ids); i++) { +if (!(c45_ids->devices_in_package & (1 << i))) +continue ; + + reg_addr =MII_ADDR_C45 | i <<16 |MII_PHYSID1 ; + phy_reg =mdiobus_read (bus, addr, reg_addr); +if (phy_reg <0 ) +return -EIO ; + c45_ids->device_ids[i] = (phy_reg &0xffff ) <<16 ; + + + reg_addr =MII_ADDR_C45 | i <<16 |MII_PHYSID2 ; + phy_reg =mdiobus_read (bus, addr, reg_addr); +if (phy_reg <0 ) +return -EIO ; + c45_ids->device_ids[i] |= (phy_reg &0xffff ); + } + *phy_id =0 ; +return 0 ; +}/** * get_phy_id - reads the specified addr for its ID. * @bus: the target MII bus * @addr: PHY address on the MII bus * @phy_id: where to store the ID retrieved. +* @c45_ids: where to store the c45 ID information. +* +* Description: In the case of a 802.3-c22 PHY, reads the ID registers +* of the PHY at @addr on the @bus, stores it in @phy_id and returns +* zero on success. +* +* In the case of a 802.3-c45 PHY, get_phy_c45_ids() is invoked, and +* its return value is in turn returned. * -* Description: Reads the ID registers of the PHY at @addr on the -* @bus, stores it in @phy_id and returns zero on success. */ -static int get_phy_id (struct mii_bus *bus,int addr,u32 *phy_id) +static int get_phy_id (struct mii_bus *bus,int addr,u32 *phy_id, +struct phy_c45_device_ids *c45_ids) {int phy_reg; +if (addr &MII_ADDR_C45 ) { + addr &= ~MII_ADDR_C45 ; + +return get_phy_c45_ids (bus, addr, phy_id, c45_ids); + }/* Grab the bits from PHYIR1, and put them * in the upper half */ phy_reg =mdiobus_read (bus, addr,MII_PHYSID1 );
@@ -238,14 +326,17 @@ static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id)* * Description: Reads the ID registers of the PHY at @addr on the * @bus, then allocates and returns the phy_device to represent it. +* If @addr & MII_ADDR_C45 is not zero, the PHY is assumed to be +* 802.3-c45. */ struct phy_device *get_phy_device (struct mii_bus *bus,int addr) {struct phy_device *dev =NULL ;u32 phy_id; +struct phy_c45_device_ids c45_ids = {0 };int r; - r =get_phy_id (bus, addr, &phy_id); + r =get_phy_id (bus, addr, &phy_id, &c45_ids);if (r)return ERR_PTR (r);
@@ -253,7 +344,7 @@ struct phy_device * get_phy_device(struct mii_bus *bus, int addr)if ((phy_id &0x1fffffff ) ==0x1fffffff )return NULL ; - dev =phy_device_create (bus, addr, phy_id); + dev =phy_device_create (bus, addr, phy_id, &c45_ids);return dev; }
@@ -446,6 +537,11 @@ static int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,/* Assume that if there is no driver, that it doesn't * exist, and we should use the genphy driver. */ if (NULL == d->driver) { +if (phydev->is_c45) { +pr_err ("No driver for phy %x\n" , phydev->phy_id); +return -ENODEV ; + } + d->driver = &genphy_driver.driver; err = d->driver->probe (d);
include/linux/phy.h +23 -2
@@ -83,8 +83,12 @@ typedef enum {*/ #define MII_BUS_ID_SIZE (20 - 3) -/* Or MII_ADDR_C45 into regnum for read/write on mii_bus to enable the 21 bit -IEEE 802.3ae clause 45 addressing mode used by 10GIGE phy chips. */ +/* +* Or MII_ADDR_C45 into regnum for read/write on mii_bus to enable the +* 21 bit IEEE 802.3ae clause 45 addressing mode used by 10GIGE phy +* chips. Also may be ORed into the device address in +* get_phy_device(). +*/ #define MII_ADDR_C45 (1<<30)struct device ;
@@ -243,6 +247,16 @@ enum phy_state { PHY_RESUMING }; +/* +* phy_c45_device_ids: 802.3-c45 Device Identifiers +* +* devices_in_package: Bit vector of devices present. +* device_ids: The device identifer for each present device. +*/ +struct phy_c45_device_ids { +u32 devices_in_package; +u32 device_ids[8 ]; +};/* phy_device: An instance of a PHY *
@@ -250,6 +264,8 @@ enum phy_state {* bus: Pointer to the bus this PHY is on * dev: driver model device structure for this PHY * phy_id: UID for this device found during discovery +* c45_ids: 802.3-c45 Device Identifers if is_c45. +* is_c45: Set to true if this phy uses clause 45 addressing. * state: state of the PHY for management purposes * dev_flags: Device-specific flags used by the PHY driver. * addr: Bus address of PHY
@@ -285,6 +301,9 @@ struct phy_device {u32 phy_id; +struct phy_c45_device_ids c45_ids; +bool is_c45; +enum phy_state state;u32 dev_flags;
@@ -477,6 +496,8 @@ static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)return mdiobus_write (phydev->bus, phydev->addr, regnum, val); } +struct phy_device *phy_device_create (struct mii_bus *bus,int addr,int phy_id, +struct phy_c45_device_ids *c45_ids);struct phy_device *get_phy_device (struct mii_bus *bus,int addr);int phy_device_register (struct phy_device *phy);int phy_init_hw (struct phy_device *phydev);
Signature · 1 line
1.7.2.3
PATCH 2/5 netdev/phy/of: Handle IEEE802.3 clause 45 Ethernet PHYs in of_mdiobus_register()
In reply to David DaneyFrom: David Daney <[email protected]>
Define two new "compatible" values for Ethernet
PHYs. "ethernet-phy-ieee802.3-c22" and "ethernet-phy-ieee802.3-c45" are used to indicate a PHY uses the corresponding protocol.
If a PHY is "compatible" with "ethernet-phy-ieee802.3-c45", we indicate this so that get_phy_device() can properly probe the device.
If get_phy_device() fails, it was probably due to failing the probe of the PHY identifier registers. Since we have the device tree telling us the PHY exists, go ahead and add it anyhow with a phy_id of zero. There may be a driver match based on the "compatible" property.
--- Documentation/devicetree/bindings/net/phy.txt | 12 +++++++++++- drivers/of/of_mdio.c | 14 +++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/net/phy.txt +11 -1
@@ -14,10 +14,20 @@ Required properties: - linux,phandle : phandle for this node; likely referenced by an ethernet controller node. +Optional Properties: + +- compatible: Compatible list, may contain + "ethernet-phy-ieee802.3-c22" or "ethernet-phy-ieee802.3-c45" for + PHYs that implement IEEE802.3 clause 22 or IEEE802.3 clause 45 + specifications. If neither of these are specified, the default is to + assume clause 22. The compatible list may also contain other + elements. + Example: ethernet-phy@0 { - linux,phandle = <2452000> + compatible = "ethernet-phy-ieee802.3-c22"; + linux,phandle = <2452000>; interrupt-parent = <40000>; interrupts = <35 1>; reg = <0>;
drivers/of/of_mdio.c +11 -3
@@ -79,11 +79,19 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) mdio->irq[addr] =PHY_POLL ; } +if (of_device_is_compatible (child, +"ethernet-phy-ieee802.3-c45" )) + addr |=MII_ADDR_C45 ; + phy =get_phy_device (mdio, addr);if (!phy ||IS_ERR (phy)) { -dev_err (&mdio->dev,"error probing PHY at address %i\n" , - addr); -continue ; + phy =phy_device_create (mdio, addr,0 ,NULL ); +if (!phy ||IS_ERR (phy)) { +dev_err (&mdio->dev, +"error creating PHY at address %i\n" , + addr); +continue ; + } }/* Associate the OF node with the device structure so it
Signature · 1 line
1.7.2.3
PATCH 3/5 netdev/phy/of: Add more methods for binding PHY devices to drivers.
In reply to David DaneyFrom: David Daney <david.daney-YGCgFSpz5w/[email protected]>
Allow PHY drivers to supply their own device matching function (match_phy_device()), or to be matched OF compatible properties.
PHYs following IEEE802.3 clause 45 have more than one device identifier constants, which breaks the default device matching code. Other 10G PHYs don't follow the standard manufacturer/device identifier register layout standards, but they do use the standard MDIO bus protocols for register access. Both of these require adjustments to the PHY driver to device matching code.
If the there is an of_node associated with such a PHY, we can match it to its driver using the "compatible" properties, just as we do with certain platform devices. If the "compatible" property match fails, first check if there is a driver supplied matching function, and if not fall back to the existing identifier matching rules.
--- drivers/net/phy/mdio_bus.c | 7 +++++++ include/linux/phy.h | 7 +++++++ 2 files changed, 14 insertions(+), 0 deletions(-)
drivers/net/phy/mdio_bus.c +7 -0
@@ -22,6 +22,7 @@#include <linux/init.h> #include <linux/delay.h> #include <linux/device.h> +#include <linux/of_device.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/skbuff.h>
@@ -305,6 +306,12 @@ static int mdio_bus_match(struct device *dev, struct device_driver *drv)struct phy_device *phydev =to_phy_device (dev);struct phy_driver *phydrv =to_phy_driver (drv); +if (of_driver_match_device (dev, drv)) +return 1 ; + +if (phydrv->match_phy_device) +return phydrv->match_phy_device (phydev); +return ((phydrv->phy_id & phydrv->phy_id_mask) == (phydev->phy_id & phydrv->phy_id_mask)); }
include/linux/phy.h +7 -0
@@ -431,6 +431,13 @@ struct phy_driver {/* Clears up any memory if needed */ void (*remove)(struct phy_device *phydev); +/* +* Returns true if this is a suitable driver for the given +* phydev. If NULL, matching is based on phy_id and +* phy_id_mask. +*/ +int (*match_phy_device)(struct phy_device *phydev); +/* Handles SIOCSHWTSTAMP ioctl for hardware time stamping. */ int (*hwtstamp)(struct phy_device *phydev,struct ifreq *ifr);
Signature · 1 line
1.7.2.3
PATCH 4/5 netdev/phy: Add driver for Broadcom BCM87XX 10G Ethernet PHYs
In reply to David DaneyFrom: David Daney <[email protected]>
Add a driver for BCM8706 and BCM8727 devices. These are a 10Gig PHYs which use MII_ADDR_C45 addressing. They are always 10G full duplex, so there is no autonegotiation. All we do is report link state and send interrupts when it changes.
If the PHY has a device tree of_node associated with it, the "broadcom,c45-reg-init" property is used to supply register initialization values when config_init() is called.
--- .../devicetree/bindings/net/broadcom-bcm87xx.txt | 29 +++ drivers/net/phy/Kconfig | 5 + drivers/net/phy/Makefile | 1 + drivers/net/phy/bcm87xx.c | 237 ++++++++++++++++++++ 4 files changed, 272 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/broadcom-bcm87xx.txt create mode 100644 drivers/net/phy/bcm87xx.c
Documentation/devicetree/bindings/net/broadcom-bcm87xx.txt new file +29 -0
@@ -0,0 +1,29 @@ +The Broadcom BCM87XX devices are a family of 10G Ethernet PHYs. They +have these bindings in addition to the standard PHY bindings. + +Compatible: Should contain "broadcom,bcm8706" or "broadcom,bcm8727" and + "ethernet-phy-ieee802.3-c45" + +Optional Properties: + +- broadcom,c45-reg-init : one of more sets of 4 cells. The first cell + is the MDIO Manageable Device (MMD) address, the second a register + address within the MMD, the third cell contains a mask to be ANDed + with the existing register value, and the fourth cell is ORed with + he result to yield the new register value. If the third cell has a + value of zero, no read of the existing value is performed. + +Example: + + ethernet-phy@5 { + reg = <5>; + compatible = "broadcom,bcm8706", "ethernet-phy-ieee802.3-c45"; + interrupt-parent = <&gpio>; + interrupts = <12 8>; /* Pin 12, active low */ + /* + * Set PMD Digital Control Register for + * GPIO[1] Tx/Rx + * GPIO[0] R64 Sync Acquired + */ + broadcom,c45-reg-init = <1 0xc808 0xff8f 0x70>; + };
drivers/net/phy/Kconfig +5 -0
@@ -67,6 +67,11 @@ config BCM63XX_PHY ---help--- Currently supports the 6348 and 6358 PHYs. +config BCM87XX_PHY + tristate "Driver for Broadcom BCM8706 and BCM8727 PHYs" + help + Currently supports the BCM8706 and BCM8727 10G Ethernet PHYs. + config ICPLUS_PHY tristate "Drivers for ICPlus PHYs" ---help---
drivers/net/phy/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_SMSC_PHY) += smsc.o obj-$(CONFIG_VITESSE_PHY) += vitesse.o obj-$(CONFIG_BROADCOM_PHY) += broadcom.o obj-$(CONFIG_BCM63XX_PHY) += bcm63xx.o +obj-$(CONFIG_BCM87XX_PHY) += bcm87xx.o obj-$(CONFIG_ICPLUS_PHY) += icplus.o obj-$(CONFIG_REALTEK_PHY) += realtek.o obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o
drivers/net/phy/bcm87xx.c new file +237 -0
237 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 5/5 netdev/phy: Add driver for Cortina cs4321 quad 10G PHY.
In reply to David DaneyFrom: David Daney <[email protected]>
These phys do *not* implement the standard IEEE 802.3 clause 45 registers. PHY to driver matching is done with OF compatible properties.
--- .../devicetree/bindings/net/cortina-cs4321.txt | 27 + drivers/net/phy/Kconfig | 6 + drivers/net/phy/Makefile | 1 + drivers/net/phy/cs4321-ucode.h | 4378 ++++++++++++++++++++ drivers/net/phy/cs4321.c | 1147 +++++ 5 files changed, 5559 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/cortina-cs4321.txt create mode 100644 drivers/net/phy/cs4321-ucode.h create mode 100644 drivers/net/phy/cs4321.c
Documentation/devicetree/bindings/net/cortina-cs4321.txt new file +27 -0
@@ -0,0 +1,27 @@ +Cortina CS4321 dual RXAIU/quad XAUI 10G Ethernet PHYs. Each PHY +within the package is mostly independent and has the following +properties. These phys do *not* implement the standard IEEE 802.3 +clause 45 registers. + +Required Properties: + +- compatible : "cortina,cs4321" or "cortina,cs4318". +- reg : The address on the system management bus (MDIO/I2C/SPI address) +- cortina,host-mode : Either "rxaui" or "xaui", the protocol used to + communicate with the Ethernet MAC. + +Optional Properties: + +- interrupts : One set of cells (per the interrupt-parent) for the + interrupt line. +- interrupt-parent : Standard interrupt-parent property for the interrupt. + +Example: + + phy0: ethernet-phy@4 { + reg = <0x04>; + compatible = "cortina,cs4318"; + interrupt-parent = <&gpio>; + interrupts = <11 8>; /* Pin 11, active low */ + cortina,host-mode = "rxaui"; + };
drivers/net/phy/Kconfig +6 -0
@@ -72,6 +72,12 @@ config BCM87XX_PHY help Currently supports the BCM8706 and BCM8727 10G Ethernet PHYs. +config CS4318_PHY + tristate "Driver for Cortina cs4318 quad-10G Ethernet PHY" + help + Currently supports only the Cortina cs4318 PHY. This may be + configured as either a quad-RXAUI or dual-XAUI device. + config ICPLUS_PHY tristate "Drivers for ICPlus PHYs" ---help---
drivers/net/phy/Makefile +1 -0
@@ -13,6 +13,7 @@ obj-$(CONFIG_VITESSE_PHY) += vitesse.o obj-$(CONFIG_BROADCOM_PHY) += broadcom.o obj-$(CONFIG_BCM63XX_PHY) += bcm63xx.o obj-$(CONFIG_BCM87XX_PHY) += bcm87xx.o +obj-$(CONFIG_CS4318_PHY) += cs4321.o obj-$(CONFIG_ICPLUS_PHY) += icplus.o obj-$(CONFIG_REALTEK_PHY) += realtek.o obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o
drivers/net/phy/cs4321-ucode.h new file +4378 -0
2,954 lines not on this page · raw message
drivers/net/phy/cs4321.c new file +1147 -0
1,147 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.2.3
Part of the diff is not shown here. View the raw message.
Re: [PATCH 4/5] netdev/phy: Add driver for Broadcom BCM87XX 10G Ethernet PHYs
In reply to David DaneyQuoted 1 line · David Daney
From: David Daney <[email protected]>
trivia:
drivers/net/phy/bcm87xx.c
Quoted 1 line
drivers/net/phy/bcm87xx.c +0
-0
[]
Quoted 13 lines
drivers/net/phy/bcm87xx.c +11
-0@@ -0,0 +1,237 @@ +static int bcm87xx_of_reg_init (struct phy_device *phydev) +{ +const __be32 *paddr; +int len, i, ret; + +if (!phydev->dev.of_node) +return 0 ; + + paddr =of_get_property (phydev->dev.of_node, +"broadcom,c45-reg-init" , &len); +if (!paddr || len < (4 *sizeof (*paddr)))
drivers/net/phy/bcm87xx.c line 58
Quoted 10 lines
drivers/net/phy/bcm87xx.c +10
-0+return 0 ; + + ret =0 ; + len /=sizeof (*paddr); +for (i =0 ; i < len -3 ; i +=4 ) { +u16 devid =be32_to_cpup (paddr + i); +u16 reg =be32_to_cpup (paddr + i +1 ); +u16 mask =be32_to_cpup (paddr + i +2 ); +u16 val_bits =be32_to_cpup (paddr + i +3 ); +int val;
These might read better as
len /= 4;
for (i = 0; i < len; i++) {
u16 devid = be32_to_cpu(*paddr++);
u16 reg = be32_to_cpu(*paddr++);
u16 mask = be32_to_cpu(*paddr++);
u16 val_bits = be32_to_cpu(*paddr++);
...
}Re: [PATCH 4/5] netdev/phy: Add driver for Broadcom BCM87XX 10G Ethernet PHYs
Quoted 4 lines · Joe Perches
Quoted 1 line · David Daney
From: David Daney<[email protected]>
trivia:
As long as we are splitting hairs...
Quoted 29 lines
drivers/net/phy/bcm87xx.c
Quoted 2 lines
drivers/net/phy/bcm87xx.c +0
-0[]
Quoted 13 lines
drivers/net/phy/bcm87xx.c +11
-0@@ -0,0 +1,237 @@ +static int bcm87xx_of_reg_init (struct phy_device *phydev) +{ +const __be32 *paddr; +int len, i, ret; + +if (!phydev->dev.of_node) +return 0 ; + + paddr =of_get_property (phydev->dev.of_node, +"broadcom,c45-reg-init" ,&len); +if (!paddr || len< (4 *sizeof (*paddr)))drivers/net/phy/bcm87xx.c line 58
Quoted 10 lines
drivers/net/phy/bcm87xx.c +10
-0+return 0 ; + + ret =0 ; + len /=sizeof (*paddr); +for (i =0 ; i< len -3 ; i +=4 ) { +u16 devid =be32_to_cpup (paddr + i); +u16 reg =be32_to_cpup (paddr + i +1 ); +u16 mask =be32_to_cpup (paddr + i +2 ); +u16 val_bits =be32_to_cpup (paddr + i +3 ); +int val;These might read better as
Quoted 1 line
len /= 4;
Where did the magic value of 4 come from?
Quoted 5 lines
for (i = 0; i< len; i++) {
u16 devid = be32_to_cpu(*paddr++);
u16 reg = be32_to_cpu(*paddr++);
u16 mask = be32_to_cpu(*paddr++);
u16 val_bits = be32_to_cpu(*paddr++);Is the main problem that they didn't align, or that the index was explicit instead of implicit?
Re: [PATCH 4/5] netdev/phy: Add driver for Broadcom BCM87XX 10G Ethernet PHYs
Quoted 7 lines · David Daney
Quoted 4 lines · Joe Perches
Quoted 1 line · David Daney
From: David Daney<[email protected]>
trivia:
As long as we are splitting hairs...
and zooming in and enhancing...
Quoted 29 lines
Quoted 29 lines
drivers/net/phy/bcm87xx.c
Quoted 2 lines
drivers/net/phy/bcm87xx.c +0
-0[]
Quoted 13 lines
drivers/net/phy/bcm87xx.c +11
-0@@ -0,0 +1,237 @@ +static int bcm87xx_of_reg_init (struct phy_device *phydev) +{ +const __be32 *paddr; +int len, i, ret; + +if (!phydev->dev.of_node) +return 0 ; + + paddr =of_get_property (phydev->dev.of_node, +"broadcom,c45-reg-init" ,&len); +if (!paddr || len< (4 *sizeof (*paddr)))drivers/net/phy/bcm87xx.c line 58
Quoted 10 lines
drivers/net/phy/bcm87xx.c +10
-0+return 0 ; + + ret =0 ; + len /=sizeof (*paddr); +for (i =0 ; i< len -3 ; i +=4 ) { +u16 devid =be32_to_cpup (paddr + i); +u16 reg =be32_to_cpup (paddr + i +1 ); +u16 mask =be32_to_cpup (paddr + i +2 ); +u16 val_bits =be32_to_cpup (paddr + i +3 ); +int val;These might read better as
Quoted 3 lines
Quoted 1 line
len /= 4;Where did the magic value of 4 come from?
equivalence to the original for loop
for (i = 0; i < len - 3; i += 4) {Quoted 9 lines
Quoted 6 lines
for (i = 0; i< len; i++) { u16 devid = be32_to_cpu(*paddr++); u16 reg = be32_to_cpu(*paddr++); u16 mask = be32_to_cpu(*paddr++); u16 val_bits = be32_to_cpu(*paddr++);Is the main problem that they didn't align, or that the index was explicit instead of implicit?
There's no real problem, it's just that
i++, be32_to_cpu and *addr++ is a bit
more common and perhaps more easily read.
The alignment's just a visual nicety.
Ignore it if you choose.
cheers, Joe
Re: [PATCH 5/5] netdev/phy: Add driver for Cortina cs4321 quad 10G PHY.
In reply to David DaneyOn Tue, May 22, 2012 at 10:59:52AM -0700, David Daney wrote:
[...]
Quoted 7 lines
drivers/net/phy/cs4321-ucode.h new file +4
-0@@ -0,0 +1,4378 @@ +/* +* Copyright (C) 2011 by Cortina Systems, Inc. +* +* This program is free software; you can redistribute it and/or modify
drivers/net/phy/cs4321-ucode.h line 14
Quoted 10 lines
drivers/net/phy/cs4321-ucode.h new file +10
-0+* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/
[...]
So where's the real source code for it?
If you won't (or can't) provide source code for the microcode then it should instead be submitted to linux-firmware with a binary redistribution licence, and the driver should load it with request_firmware().
Ben.
Signature · 3 lines
Ben Hutchings
We get into the habit of living before acquiring the habit of thinking.
- Albert CamusDavid Miller
maintainerAs mentioned the other day in my announement, right now it is inappropriate to submit new feature patches.
You will need to resend these changes when the net-next tree opens back up, please monitor the netdev list to learn when that has happened.
Re: [PATCH 5/5] netdev/phy: Add driver for Cortina cs4321 quad 10G PHY.
In reply to Ben HutchingsQuoted 21 lines · Ben Hutchings
On Tue, May 22, 2012 at 10:59:52AM -0700, David Daney wrote:
[...]Quoted 17 lines
drivers/net/phy/cs4321-ucode.h new file +14
-0@@ -0,0 +1,4378 @@ +/* +* Copyright (C) 2011 by Cortina Systems, Inc. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ [...]
Quoted 1 line
So where's the real source code for it?
I wish I knew. The vendor released the array of random numbers as GPL to us. :-(
Quoted 5 lines
If you won't (or can't) provide source code for the microcode then it should instead be submitted to linux-firmware with a binary redistribution licence, and the driver should load it with
request_firmware().
I will attempt to do that.
The .c file contains plenty of other pseudo-random numbers, but those cannot really be considered 'firmware'
David Daney