Skip to contentSkip to conversation

MIPS: OCTEON: Convert some device to use Device Tree.

PATCH Superseded David Daney 3 participants 11 messages Apr 27, 2012 – May 19, 2012

Subsystems (7)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 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://marc.info/?l=linux-kernel&m=133548781607480

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(-)
Cc Greg Kroah-Hartman <[email protected]>
Cc David S. Miller <[email protected]>
Cc "Jean Delvare (PC drivers, core)" <[email protected]>
Cc "Ben Dooks (embedded platforms)" <[email protected]>
Cc "Wolfram Sang (embedded platforms)" <[email protected]>
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH v2 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.

Cc "Jean Delvare (PC drivers, core)" <[email protected]>
Cc "Ben Dooks (embedded platforms)" <[email protected]>
Cc "Wolfram Sang (embedded platforms)" <[email protected]>
---
 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
index fc40d0b..c6b0b41 100644
@@ -1183,13 +1183,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
index f72f768..1e2486e 100644
@@ -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
#4 lore raw

PATCH v2 2/5 netdev: mdio-octeon.c: Convert to use device tree.

In reply to David Daney

From: David Daney <david.daney-YGCgFSpz5w/[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
index f62a40f..66cabc2 100644
@@ -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
#6 lore raw

PATCH v2 3/5 netdev: octeon_mgmt: Convert to use device tree.

In reply to David Daney

From: 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
index c6b0b41..a729728 100644
@@ -1188,7 +1188,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 */
@@ -1197,7 +1196,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
#7 lore raw

PATCH v2 4/5 staging: octeon_ethernet: Convert to use device tree.

In reply to David Daney

From: 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
index e31949c..f15b31b 100644
@@ -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
index d581925..9360e22 100644
@@ -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
#9 lore raw

PATCH v2 5/5 MIPS: Octeon: Use device tree to register serial ports.

In reply to David Daney

From: 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
index a729728..f3d27ec 100644
@@ -1175,9 +1175,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++)
@@ -1194,7 +1191,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
Acked-by on v2 1/5
#2 lore raw

Re: [PATCH v2 1/5] i2c: Convert i2c-octeon.c to use device tree.

In reply to David Daney
Quoted 16 lines · David Daney

From: David Daney <[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.

Quoted 6 lines
Cc "Jean Delvare (PC drivers, core)" <[email protected]>
Cc "Ben Dooks (embedded platforms)" <[email protected]>
Cc "Wolfram Sang (embedded platforms)" <[email protected]>

I2C changes look okay. I'd think this goes in via MIPS-tree?

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#3 lore raw

Re: [PATCH v2 1/5] i2c: Convert i2c-octeon.c to use device tree.

In reply to David Daney
Quoted 12 lines · David Daney

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.

Quoted 6 lines

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.

Is the DT binding for this device documented?

Otherwise the code looks good. Please make sure the binding documentation is in place before merging.

g.

#5 lore raw

Re: [PATCH v2 2/5] netdev: mdio-octeon.c: Convert to use device tree.

In reply to David Daney
Quoted 6 lines · David Daney

From: David Daney <david.daney-YGCgFSpz5w/[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.

Ditto on this one (and the others); make sure the new compatible value is documented. Otherwise looks good.

g.

Acked-by on v2 4/5
#8 lore raw

Re: [PATCH v2 4/5] staging: octeon_ethernet: Convert to use device tree.

In reply to David Daney
Quoted 10 lines · David Daney

From: David Daney <[email protected]>

Get MAC address and PHY connection from the device tree. The driver is converted to a platform driver.

Acked-by on v2 5/5
#10 lore raw

Re: [PATCH v2 5/5] MIPS: Octeon: Use device tree to register serial ports.

In reply to David Daney
Quoted 8 lines · David Daney

From: 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.

Quoted 8 lines

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.