MIPS: OCTEON: Convert some device to use Device Tree.
Subsystems (6)
v3 cover MIPS: OCTEON: Convert some device to use Device Tree.
From: David Daney <[email protected]>
This patch set depends on the previous set to add Device Tree to OCTEON. That set can be found among other places here:
http://www.linux-mips.org/archives/linux-mips/2012-06/msg00081.html
For v3:
No functional changes, Added more Acked-bys, rebased to avoid merge conflicts.
For v2:
No functional changes, but minor clean-ups to use some new device tree helper functions.
Some Acked-bys added.
I am suggesting that all these go via Ralf's linux-mips.org tree as they depend on other patches in that tree.
Quoted 1 line
From v1:
The patches are for drivers scattered throughout the tree, but there is an order dependency as well as the dependency mentioned above, so it may be preferable to merge them all via Ralf's linux-mips.org tree rather that separately via the various device sub-system maintainers.
The mdio-octeon.c and octeon_mgmt patches were already Acked-by davem.
The i2c has been seen before, but to my knowledge was never acked.
The octeon_ethernet patch is in staging and has also been seen before.
The serial patch is new.
David Daney (5):
i2c: Convert i2c-octeon.c to use device tree.
netdev: mdio-octeon.c: Convert to use device tree.
netdev: octeon_mgmt: Convert to use device tree.
staging: octeon_ethernet: Convert to use device tree.
MIPS: Octeon: Use device tree to register serial ports.
arch/mips/cavium-octeon/octeon-irq.c | 8 - arch/mips/cavium-octeon/octeon-platform.c | 176 ---------------- arch/mips/cavium-octeon/serial.c | 134 +++++-------- arch/mips/include/asm/octeon/octeon.h | 5 - drivers/i2c/busses/i2c-octeon.c | 92 +++++---- drivers/net/ethernet/octeon/octeon_mgmt.c | 312 +++++++++++++++++++---------- drivers/net/phy/mdio-octeon.c | 92 ++++++--- drivers/staging/octeon/ethernet-mdio.c | 28 ++-- drivers/staging/octeon/ethernet.c | 153 +++++++++----- drivers/staging/octeon/octeon-ethernet.h | 3 + 10 files changed, 484 insertions(+), 519 deletions(-)
Signature · 1 line
1.7.2.3
PATCH v3 1/5 i2c: Convert i2c-octeon.c to use device tree.
From: David Daney <david.daney-YGCgFSpz5w/[email protected]>
There are three parts to this:
1) Remove the definitions of OCTEON_IRQ_TWSI and OCTEON_IRQ_TWSI2. The interrupts are specified by the device tree and these hard coded irq numbers block the used of the irq lines by the irq_domain code.
2) Remove platform device setup code from octeon-platform.c, it is now unused.
3) Convert i2c-octeon.c to use device tree. Part of this includes using the devm_* functions instead of the raw counterparts, thus simplifying error handling. No functionality is changed.
--- arch/mips/cavium-octeon/octeon-irq.c | 2 - arch/mips/cavium-octeon/octeon-platform.c | 84 -------------------------- arch/mips/include/asm/octeon/octeon.h | 5 -- drivers/i2c/busses/i2c-octeon.c | 92 +++++++++++++++------------- 4 files changed, 49 insertions(+), 134 deletions(-)
arch/mips/cavium-octeon/octeon-irq.c +0 -2
@@ -1192,13 +1192,11 @@ static void __init octeon_irq_init_ciu(void)for (i =0 ; i <4 ; i++)octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_PCI_MSI0 ,0 , i +40 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_TWSI ,0 ,45 , chip, handle_level_irq);octeon_irq_set_ciu_mapping (OCTEON_IRQ_RML ,0 ,46 , chip, handle_level_irq);for (i =0 ; i <4 ; i++)octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_TIMER0 ,0 , i +52 , chip, handle_edge_irq);octeon_irq_set_ciu_mapping (OCTEON_IRQ_USB0 ,0 ,56 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_TWSI2 ,0 ,59 , chip, handle_level_irq);octeon_irq_set_ciu_mapping (OCTEON_IRQ_MII0 ,0 ,62 , chip, handle_level_irq);octeon_irq_set_ciu_mapping (OCTEON_IRQ_BOOTDMA ,0 ,63 , chip, handle_level_irq);
arch/mips/cavium-octeon/octeon-platform.c +0 -84
90 lines not on this page · raw message
arch/mips/include/asm/octeon/octeon.h +0 -5
@@ -215,11 +215,6 @@ struct octeon_cf_data {int dma_engine;/* -1 for no DMA */ }; -struct octeon_i2c_data { -unsigned int sys_freq; -unsigned int i2c_freq; -}; -extern void octeon_write_lcd (const char *s);extern void octeon_check_cpu_bist (void );extern int octeon_get_boot_debug_flag (void );
drivers/i2c/busses/i2c-octeon.c +49 -43
206 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH v3 2/5 netdev: mdio-octeon.c: Convert to use device tree.
In reply to David DaneyFrom: David Daney <[email protected]>
Get the MDIO bus controller addresses from the device tree, small clean up in use of devm_*
Remove, now unused, platform device setup code.
--- arch/mips/cavium-octeon/octeon-platform.c | 30 --------- drivers/net/phy/mdio-octeon.c | 92 ++++++++++++++++++----------- 2 files changed, 58 insertions(+), 64 deletions(-)
arch/mips/cavium-octeon/octeon-platform.c +0 -30
@@ -168,36 +168,6 @@ out: }device_initcall (octeon_rng_device_init); -/* Octeon SMI/MDIO interface. */ -static int __init octeon_mdiobus_device_init (void ) -{ -struct platform_device *pd; -int ret =0 ; - -if (octeon_is_simulation ()) -return 0 ;/* No mdio in the simulator. */ - -/* The bus number is the platform_device id. */ - pd =platform_device_alloc ("mdio-octeon" ,0 ); -if (!pd) { - ret = -ENOMEM ; - goto out; - } - - ret =platform_device_add (pd); -if (ret) - goto fail; - -return ret; -fail: -platform_device_put (pd); - -out: -return ret; - -} -device_initcall (octeon_mdiobus_device_init); -/* Octeon mgmt port Ethernet interface. */ static int __init octeon_mgmt_device_init (void ) {
drivers/net/phy/mdio-octeon.c +58 -34
189 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH v3 3/5 netdev: octeon_mgmt: Convert to use device tree.
In reply to David DaneyFrom: David Daney <[email protected]>
The device tree will supply the register bank base addresses, make register addressing relative to those. PHY connection is now described by the device tree.
The OCTEON_IRQ_MII{0,1} symbols are also removed as they are now unused and interfere with the irq_domain used for device tree irq mapping.
--- arch/mips/cavium-octeon/octeon-irq.c | 2 - arch/mips/cavium-octeon/octeon-platform.c | 62 ------ drivers/net/ethernet/octeon/octeon_mgmt.c | 312 +++++++++++++++++++---------- 3 files changed, 207 insertions(+), 169 deletions(-)
arch/mips/cavium-octeon/octeon-irq.c +0 -2
@@ -1197,7 +1197,6 @@ static void __init octeon_irq_init_ciu(void)octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_TIMER0 ,0 , i +52 , chip, handle_edge_irq);octeon_irq_set_ciu_mapping (OCTEON_IRQ_USB0 ,0 ,56 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_MII0 ,0 ,62 , chip, handle_level_irq);octeon_irq_set_ciu_mapping (OCTEON_IRQ_BOOTDMA ,0 ,63 , chip, handle_level_irq);/* CIU_1 */
@@ -1206,7 +1205,6 @@ static void __init octeon_irq_init_ciu(void)octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART2 ,1 ,16 , chip, handle_level_irq);octeon_irq_set_ciu_mapping (OCTEON_IRQ_USB1 ,1 ,17 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_MII1 ,1 ,18 , chip, handle_level_irq); gpio_node =of_find_compatible_node (NULL ,NULL ,"cavium,octeon-3860-gpio" );if (gpio_node) {
arch/mips/cavium-octeon/octeon-platform.c +0 -62
68 lines not on this page · raw message
drivers/net/ethernet/octeon/octeon_mgmt.c +207 -105
651 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH v3 4/5 staging: octeon_ethernet: Convert to use device tree.
In reply to David DaneyFrom: David Daney <[email protected]>
Get MAC address and PHY connection from the device tree. The driver is converted to a platform driver.
--- drivers/staging/octeon/ethernet-mdio.c | 28 +++--- drivers/staging/octeon/ethernet.c | 153 +++++++++++++++++++----------- drivers/staging/octeon/octeon-ethernet.h | 3 + 3 files changed, 117 insertions(+), 67 deletions(-)
drivers/staging/octeon/ethernet-mdio.c +15 -13
@@ -28,6 +28,7 @@#include <linux/ethtool.h> #include <linux/phy.h> #include <linux/ratelimit.h> +#include <linux/of_mdio.h> #include <net/dst.h>
@@ -161,22 +162,23 @@ static void cvm_oct_adjust_link(struct net_device *dev)int cvm_oct_phy_setup_device (struct net_device *dev) {struct octeon_ethernet *priv =netdev_priv (dev); +struct device_node *phy_node; -int phy_addr =cvmx_helper_board_get_mii_address (priv->port); -if (phy_addr !=-1 ) { -char phy_id[MII_BUS_ID_SIZE +3 ]; +if (!priv->of_node) +return 0 ; -snprintf (phy_id,sizeof (phy_id),PHY_ID_FMT ,"mdio-octeon-0" , phy_addr); + phy_node =of_parse_phandle (priv->of_node,"phy-handle" ,0 ); +if (!phy_node) +return 0 ; - priv->phydev =phy_connect (dev, phy_id, cvm_oct_adjust_link,0 , -PHY_INTERFACE_MODE_GMII ); + priv->phydev =of_phy_connect (dev, phy_node, cvm_oct_adjust_link,0 , +PHY_INTERFACE_MODE_GMII ); + +if (priv->phydev ==NULL ) +return -ENODEV ; + + priv->last_link =0 ; +phy_start_aneg (priv->phydev); -if (IS_ERR (priv->phydev)) { - priv->phydev =NULL ; -return -1 ; - } - priv->last_link =0 ; -phy_start_aneg (priv->phydev); - }return 0 ; }
drivers/staging/octeon/ethernet.c +99 -54
267 lines not on this page · raw message
drivers/staging/octeon/octeon-ethernet.h +3 -0
@@ -31,6 +31,8 @@#ifndef OCTEON_ETHERNET_H #define OCTEON_ETHERNET_H +#include <linux/of.h> +/** * This is the definition of the Ethernet driver's private * driver state stored in netdev_priv(dev).
@@ -59,6 +61,7 @@ struct octeon_ethernet {void (*poll) (struct net_device *dev);struct delayed_work port_periodic_work;struct work_struct port_work;/* may be unused. */ +struct device_node *of_node; };int cvm_oct_free_work (void *work_queue_entry);
Signature · 1 line
1.7.2.3
PATCH v3 5/5 MIPS: Octeon: Use device tree to register serial ports.
In reply to David DaneyFrom: David Daney <[email protected]>
Switch to using the device tree to register serial ports.
Add all the ports with compatible = "cavium,octeon-3860-uart". Octeon serial ports have their own device type, required port flags, and I/O functions, so using of_serial.c is not indicated.
We need to do this as late_initcall, as the 8250 driver must be initialized before we add any ports. 8250 initialization is done at device_initcall time.
The OCTEON_IRQ_UART{0,1,2} symbols are removed as they are now unused and interfere with irq_domain used by the device tree code.
--- arch/mips/cavium-octeon/octeon-irq.c | 4 - arch/mips/cavium-octeon/serial.c | 134 +++++++++++++-------------------- 2 files changed, 53 insertions(+), 85 deletions(-)
arch/mips/cavium-octeon/octeon-irq.c +0 -4
@@ -1184,9 +1184,6 @@ static void __init octeon_irq_init_ciu(void)octeon_irq_set_ciu_mapping (OCTEON_IRQ_MBOX0 ,0 ,32 , chip_mbox, handle_percpu_irq);octeon_irq_set_ciu_mapping (OCTEON_IRQ_MBOX1 ,0 ,33 , chip_mbox, handle_percpu_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART0 ,0 ,34 , chip, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART1 ,0 ,35 , chip, handle_level_irq); -for (i =0 ; i <4 ; i++)octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_PCI_INT0 ,0 , i +36 , chip, handle_level_irq);for (i =0 ; i <4 ; i++)
@@ -1203,7 +1200,6 @@ static void __init octeon_irq_init_ciu(void)for (i =0 ; i <16 ; i++)octeon_irq_set_ciu_mapping (i +OCTEON_IRQ_WDOG0 ,1 , i +0 , chip_wd, handle_level_irq); -octeon_irq_set_ciu_mapping (OCTEON_IRQ_UART2 ,1 ,16 , chip, handle_level_irq);octeon_irq_set_ciu_mapping (OCTEON_IRQ_USB1 ,1 ,17 , chip, handle_level_irq); gpio_node =of_find_compatible_node (NULL ,NULL ,"cavium,octeon-3860-gpio" );
arch/mips/cavium-octeon/serial.c +53 -81
148 lines not on this page · raw message
Signature · 1 line
1.7.2.3