Background: The Octeon family of SOCs has a variety of on-chip
controllers for Ethernet, MDIO, I2C, and several other I/O devices.
These chips are used on boards with a great variety of different
configurations. To date, the configuration and bus topology
information has been hard coded in the drivers and support code.
To facilitate supporting new chips and boards, we would like to make
use use the Device Tree to encode the configuration information.
I would like to get some feedback on the current code I am working
with. The migration approach is as follows:
o Several device tree templates are statically linked into the kernel
image. Based on SOC type and board type one of these is selected in
early boot. Legacy configuration probing code is used to prune and
patch the device tree template.
o New SOCs and boards will directly use a device tree passed by the
bootloader (This patch set doesn't actually implement this, but it
is trivial to add).
01/10 - Move configuration code to common place for use by Device Tree
pruning and patching code.
02/10 - Add the statically linked Device Tree templates.
03/10 - Remove unused arch/mips/prom.c code that conflicts with
following patches.
04/10 - irq_create_of_mapping() function.
05/10 - Rearrange legacy configuration code for following patch.
06/10 - Fix up Device Tree template for current environment.
07/10 - Convert I2C driver to use Device Tree.
08/10 - Convert MDIO driver to use Device Tree.
09/10 - Convert Ethernet mgmt driver to use Device Tree.
10/10 - Convert Octeon Ethernet driver to use Device Tree.
David Daney (10):
MIPS: Octeon: Move some Ethernet support files out of staging.
MIPS: Octeon: Add device tree source files.
MIPS: Prune some target specific code out of prom.c
MIPS: Octeon: Add a irq_create_of_mapping() implementation.
MIPS: Octeon: Rearrance CVMX files in preperation for device tree
MIPS: Octeon: Initialize and fixup device tree.
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.
arch/mips/Kconfig | 2 +
arch/mips/cavium-octeon/.gitignore | 2 +
arch/mips/cavium-octeon/Makefile | 13 +
arch/mips/cavium-octeon/executive/Makefile | 5 +
.../mips/cavium-octeon/executive}/cvmx-cmd-queue.c | 8 +-
.../mips/cavium-octeon/executive}/cvmx-fpa.c | 0
.../cavium-octeon/executive}/cvmx-helper-board.c | 18 +-
.../cavium-octeon/executive}/cvmx-helper-fpa.c | 0
.../cavium-octeon/executive}/cvmx-helper-loop.c | 6 +-
.../cavium-octeon/executive}/cvmx-helper-npi.c | 6 +-
.../cavium-octeon/executive}/cvmx-helper-rgmii.c | 17 +-
.../cavium-octeon/executive}/cvmx-helper-sgmii.c | 18 +-
.../cavium-octeon/executive}/cvmx-helper-spi.c | 20 +-
.../cavium-octeon/executive}/cvmx-helper-util.c | 16 +-
.../cavium-octeon/executive}/cvmx-helper-xaui.c | 32 +-
.../mips/cavium-octeon/executive}/cvmx-helper.c | 120 ++++--
.../executive}/cvmx-interrupt-decodes.c | 10 +-
.../cavium-octeon/executive}/cvmx-interrupt-rsl.c | 4 +-
.../mips/cavium-octeon/executive}/cvmx-pko.c | 6 +-
.../mips/cavium-octeon/executive}/cvmx-spi.c | 12 +-
arch/mips/cavium-octeon/octeon-irq.c | 25 ++
arch/mips/cavium-octeon/octeon-platform.c | 456 ++++++++++++--------
arch/mips/cavium-octeon/octeon_3xxx.dts | 314 ++++++++++++++
arch/mips/cavium-octeon/octeon_68xx.dts | 99 +++++
arch/mips/cavium-octeon/setup.c | 17 +
.../mips/include/asm}/octeon/cvmx-address.h | 0
.../mips/include/asm}/octeon/cvmx-asxx-defs.h | 0
.../mips/include/asm}/octeon/cvmx-cmd-queue.h | 0
.../mips/include/asm}/octeon/cvmx-config.h | 0
.../mips/include/asm}/octeon/cvmx-dbg-defs.h | 0
.../mips/include/asm}/octeon/cvmx-fau.h | 0
.../mips/include/asm}/octeon/cvmx-fpa-defs.h | 0
.../mips/include/asm}/octeon/cvmx-fpa.h | 0
.../mips/include/asm}/octeon/cvmx-gmxx-defs.h | 0
.../mips/include/asm}/octeon/cvmx-helper-board.h | 0
.../mips/include/asm}/octeon/cvmx-helper-fpa.h | 0
.../mips/include/asm}/octeon/cvmx-helper-loop.h | 1 +
.../mips/include/asm}/octeon/cvmx-helper-npi.h | 1 +
.../mips/include/asm}/octeon/cvmx-helper-rgmii.h | 1 +
.../mips/include/asm}/octeon/cvmx-helper-sgmii.h | 1 +
.../mips/include/asm}/octeon/cvmx-helper-spi.h | 1 +
.../mips/include/asm}/octeon/cvmx-helper-util.h | 0
.../mips/include/asm}/octeon/cvmx-helper-xaui.h | 1 +
.../mips/include/asm}/octeon/cvmx-helper.h | 1 +
.../mips/include/asm}/octeon/cvmx-ipd.h | 0
.../mips/include/asm}/octeon/cvmx-mdio.h | 0
.../mips/include/asm}/octeon/cvmx-pcsx-defs.h | 0
.../mips/include/asm}/octeon/cvmx-pcsxx-defs.h | 0
.../mips/include/asm}/octeon/cvmx-pip-defs.h | 0
.../mips/include/asm}/octeon/cvmx-pip.h | 0
.../mips/include/asm}/octeon/cvmx-pko-defs.h | 0
.../mips/include/asm}/octeon/cvmx-pko.h | 0
.../mips/include/asm}/octeon/cvmx-pow.h | 0
.../mips/include/asm}/octeon/cvmx-scratch.h | 0
.../mips/include/asm}/octeon/cvmx-spi.h | 0
.../mips/include/asm}/octeon/cvmx-spxx-defs.h | 0
.../mips/include/asm}/octeon/cvmx-srxx-defs.h | 0
.../mips/include/asm}/octeon/cvmx-stxx-defs.h | 0
.../mips/include/asm}/octeon/cvmx-wqe.h | 0
arch/mips/include/asm/octeon/octeon.h | 5 -
arch/mips/kernel/prom.c | 49 ---
drivers/i2c/busses/i2c-octeon.c | 88 ++--
drivers/net/octeon/octeon_mgmt.c | 265 +++++++-----
drivers/net/phy/mdio-octeon.c | 73 ++--
drivers/staging/octeon/Makefile | 5 -
drivers/staging/octeon/cvmx-packet.h | 65 ---
drivers/staging/octeon/cvmx-smix-defs.h | 178 --------
drivers/staging/octeon/ethernet-defines.h | 2 +-
drivers/staging/octeon/ethernet-mdio.c | 31 +-
drivers/staging/octeon/ethernet-mem.c | 2 +-
drivers/staging/octeon/ethernet-rgmii.c | 4 +-
drivers/staging/octeon/ethernet-rx.c | 14 +-
drivers/staging/octeon/ethernet-rx.h | 2 +-
drivers/staging/octeon/ethernet-sgmii.c | 4 +-
drivers/staging/octeon/ethernet-spi.c | 6 +-
drivers/staging/octeon/ethernet-tx.c | 12 +-
drivers/staging/octeon/ethernet-xaui.c | 4 +-
drivers/staging/octeon/ethernet.c | 115 +++--
drivers/staging/octeon/octeon-ethernet.h | 3 +
79 files changed, 1308 insertions(+), 852 deletions(-)
create mode 100644 arch/mips/cavium-octeon/.gitignore
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-cmd-queue.c (98%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-fpa.c (100%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-board.c (98%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-fpa.c (100%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-loop.c (95%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-npi.c (96%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-rgmii.c (97%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-sgmii.c (98%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-spi.c (94%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-util.c (97%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-xaui.c (97%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper.c (93%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-interrupt-decodes.c (98%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-interrupt-rsl.c (97%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-pko.c (99%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-spi.c (99%)
create mode 100644 arch/mips/cavium-octeon/octeon_3xxx.dts
create mode 100644 arch/mips/cavium-octeon/octeon_68xx.dts
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-address.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-asxx-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-cmd-queue.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-config.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-dbg-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-fau.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-fpa-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-fpa.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-gmxx-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-board.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-fpa.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-loop.h (96%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-npi.h (96%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-rgmii.h (98%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-sgmii.h (98%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-spi.h (98%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-util.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-xaui.h (98%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper.h (99%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-ipd.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-mdio.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pcsx-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pcsxx-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pip-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pip.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pko-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pko.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pow.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-scratch.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-spi.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-spxx-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-srxx-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-stxx-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-wqe.h (100%)
delete mode 100644 drivers/staging/octeon/cvmx-packet.h
delete mode 100644 drivers/staging/octeon/cvmx-smix-defs.h
--
1.7.2.3
Signed-off-by: David Daney <[email protected]>
---
arch/mips/Kconfig | 2 +
arch/mips/cavium-octeon/octeon-platform.c | 280 +++++++++++++++++++++++++++++
arch/mips/cavium-octeon/setup.c | 17 ++
3 files changed, 299 insertions(+), 0 deletions(-)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 4baf7f2..a8fc970 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -699,6 +699,7 @@ config CAVIUM_OCTEON_SIMULATOR
select SYS_SUPPORTS_HIGHMEM
select SYS_SUPPORTS_HOTPLUG_CPU
select SYS_HAS_CPU_CAVIUM_OCTEON
+ select OF_DYNAMIC
help
The Octeon simulator is software performance model of the Cavium
Octeon Processor. It supports simulating Octeon processors on x86
@@ -715,6 +716,7 @@ config CAVIUM_OCTEON_REFERENCE_BOARD
select SYS_SUPPORTS_HOTPLUG_CPU
select SYS_HAS_EARLY_PRINTK
select SYS_HAS_CPU_CAVIUM_OCTEON
+ select OF_DYNAMIC
select SWAP_IO_SPACE
select HW_HAS_PCI
select ARCH_SUPPORTS_MSI
diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
index cecaf62..428de0d 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -13,10 +13,14 @@
#include <linux/usb.h>
#include <linux/dma-mapping.h>
#include <linux/module.h>
+#include <linux/slab.h>
#include <linux/platform_device.h>
+#include <linux/of_platform.h>
#include <asm/octeon/octeon.h>
#include <asm/octeon/cvmx-rnm-defs.h>
+#include <asm/octeon/cvmx-helper.h>
+#include <asm/octeon/cvmx-helper-board.h>
static struct octeon_cf_data octeon_cf_data;
@@ -440,6 +444,282 @@ device_initcall(octeon_ohci_device_init);
#endif /* CONFIG_USB */
+static struct of_device_id __initdata octeon_ids[] = {
+ { .type = "soc", },
+ { .compatible = "simple-bus", },
+ {},
+};
+
+static int __init set_phy_addr_prop(struct device_node *n, int phy)
+{
+ u32 *vp;
+ struct property *old_p;
+ struct property *p = kzalloc(sizeof(struct device_node) + sizeof(u32), GFP_KERNEL);
+ if (!p)
+ return -ENOMEM;
+ /* The value will immediatly follow the node in memory. */
+ vp = (u32 *)(&p[1]);
+ p->name = "reg";
+ p->length = sizeof(u32);
+ p->value = vp;
+
+ *vp = cpu_to_be32((u32)phy);
+
+ old_p = of_find_property(n, "reg", NULL);
+ if (old_p)
+ prom_remove_property(n, old_p);
+ return prom_add_property(n, p);
+}
+
+static int __init set_mac_addr_prop(struct device_node *n, u64 mac)
+{
+ u8 *vp;
+ struct property *old_p;
+ struct property *p = kzalloc(sizeof(struct device_node) + 6, GFP_KERNEL);
+ if (!p)
+ return -ENOMEM;
+ /* The value will immediatly follow the node in memory. */
+ vp = (u8 *)(&p[1]);
+ p->name = "local-mac-address";
+ p->length = 6;
+ p->value = vp;
+
+ vp[0] = (mac >> 40) & 0xff;
+ vp[1] = (mac >> 32) & 0xff;
+ vp[2] = (mac >> 24) & 0xff;
+ vp[3] = (mac >> 16) & 0xff;
+ vp[4] = (mac >> 8) & 0xff;
+ vp[5] = mac & 0xff;
+
+ old_p = of_find_property(n, "local-mac-address", NULL);
+ if (old_p)
+ prom_remove_property(n, old_p);
+ return prom_add_property(n, p);
+}
+
+static struct device_node * __init octeon_of_get_child(const struct device_node *parent,
+ int reg_val)
+{
+ struct device_node *node = NULL;
+ int size;
+ const __be32 *addr;
+
+ for (;;) {
+ node = of_get_next_child(parent, node);
+ if (!node)
+ break;
+ addr = of_get_property(node, "reg", &size);
+ if (addr && (be32_to_cpu(*addr) == reg_val))
+ break;
+ }
+ return node;
+}
+
+int __init octeon_prune_device_tree(void)
+{
+ int i, p, max_port;
+ const char *node_path;
+ char name_buffer[20];
+ struct device_node *aliases;
+ struct device_node *pip;
+ struct device_node *iface;
+ struct device_node *eth;
+ struct device_node *node;
+
+ aliases = of_find_node_by_path("/aliases");
+ if (!aliases) {
+ pr_err("Error: No /aliases node in device tree.");
+ return -EINVAL;
+ }
+
+ if (OCTEON_IS_MODEL(OCTEON_CN52XX) || OCTEON_IS_MODEL(OCTEON_CN63XX))
+ max_port = 2;
+ else if (OCTEON_IS_MODEL(OCTEON_CN56XX))
+ max_port = 1;
+ else
+ max_port = 0;
+
+ for (i = 0; i < 2; i++) {
+ struct device_node *mgmt;
+ snprintf(name_buffer, sizeof(name_buffer),
+ "ethernet-mgmt%d", i);
+ node_path = of_get_property(aliases, name_buffer, NULL);
+ if (node_path) {
+ mgmt = of_find_node_by_path(node_path);
+ if (!mgmt)
+ continue;
+ if (i >= max_port) {
+ pr_notice("Deleting mgmt%d\n", i);
+ node = of_parse_phandle(mgmt, "phy-handle", 0);
+ if (node) {
+ of_detach_node(node);
+ of_node_put(node);
+ }
+ of_node_put(node);
+
+ of_detach_node(mgmt);
+ of_node_put(mgmt);
+ }
+ of_node_put(mgmt);
+ }
+ }
+
+ node_path = of_get_property(aliases, "pip", NULL);
+ if (node_path && (pip = of_find_node_by_path(node_path))) {
+ for (i = 0; i < 4; i++) {
+ cvmx_helper_interface_enumerate(i);
+ iface = octeon_of_get_child(pip, i);
+ if (!iface)
+ continue;
+ for (p = 0; p < 4; p++) {
+ eth = octeon_of_get_child(iface, p);
+ if (!eth)
+ continue;
+ node = of_parse_phandle(eth, "phy-handle", 0);
+ if (p < cvmx_helper_ports_on_interface(i)) {
+ int phy = cvmx_helper_board_get_mii_address(16 * i + p);
+ if (node && phy < 0) {
+ struct property *p = of_find_property(eth, "phy-handle", NULL);
+ of_detach_node(node);
+ of_node_put(node);
+ prom_remove_property(eth, p);
+ }
+ } else {
+ pr_notice("Deleting Ethernet %x:%x\n", i, p);
+ if (node) {
+ of_detach_node(node);
+ of_node_put(node);
+ }
+ of_detach_node(eth);
+ of_node_put(eth);
+ }
+ of_node_put(node);
+ of_node_put(eth);
+ }
+ of_node_put(iface);
+ }
+ of_node_put(pip);
+ }
+
+ /* I2C */
+ if (OCTEON_IS_MODEL(OCTEON_CN52XX) ||
+ OCTEON_IS_MODEL(OCTEON_CN63XX) ||
+ OCTEON_IS_MODEL(OCTEON_CN56XX))
+ max_port = 2;
+ else
+ max_port = 1;
+
+ for (i = 0; i < 2; i++) {
+ struct device_node *i2c;
+ snprintf(name_buffer, sizeof(name_buffer),
+ "i2c%d", i);
+ node_path = of_get_property(aliases, name_buffer, NULL);
+ if (node_path) {
+ i2c = of_find_node_by_path(node_path);
+ if (!i2c)
+ continue;
+ if (i >= max_port) {
+ pr_notice("Deleting i2c%d\n", i);
+
+ of_detach_node(i2c);
+ of_node_put(i2c);
+ }
+ of_node_put(i2c);
+ }
+ }
+
+ of_node_put(aliases);
+ return 0;
+}
+
+int __init octeon_fix_device_tree(void)
+{
+ int i, p;
+ int rv;
+ const char *node_path;
+ char name_buffer[20];
+ u64 mac_addr_base;
+ struct device_node *aliases;
+ struct device_node *pip;
+ struct device_node *iface;
+ struct device_node *eth;
+ struct device_node *node;
+
+ /*
+ * Edit the device tree to reflect known board
+ * configurations.
+ */
+ mac_addr_base =
+ ((octeon_bootinfo->mac_addr_base[0] & 0xffull)) << 40 |
+ ((octeon_bootinfo->mac_addr_base[1] & 0xffull)) << 32 |
+ ((octeon_bootinfo->mac_addr_base[2] & 0xffull)) << 24 |
+ ((octeon_bootinfo->mac_addr_base[3] & 0xffull)) << 16 |
+ ((octeon_bootinfo->mac_addr_base[4] & 0xffull)) << 8 |
+ (octeon_bootinfo->mac_addr_base[5] & 0xffull);
+
+ aliases = of_find_node_by_path("/aliases");
+ if (!aliases) {
+ pr_err("Error: No /aliases node in device tree.");
+ return -EINVAL;
+ }
+
+ for (i = 0; i < 2; i++) {
+ struct device_node *mgmt;
+ snprintf(name_buffer, sizeof(name_buffer),
+ "ethernet-mgmt%d", i);
+ node_path = of_get_property(aliases, name_buffer, NULL);
+ if (node_path) {
+ mgmt = of_find_node_by_path(node_path);
+ if (!mgmt)
+ continue;
+ /* Set the ethernet address */
+ rv = set_mac_addr_prop(mgmt, mac_addr_base);
+ if (rv)
+ goto err;
+ mac_addr_base++;
+
+ of_node_put(mgmt);
+ }
+ }
+
+ node_path = of_get_property(aliases, "pip", NULL);
+ if (node_path && (pip = of_find_node_by_path(node_path))) {
+ for (i = 0; i < 4; i++) {
+ iface = octeon_of_get_child(pip, i);
+ if (!iface)
+ continue;
+ for (p = 0; p < 4; p++) {
+ int phy = cvmx_helper_board_get_mii_address(16 * i + p);
+ eth = octeon_of_get_child(iface, p);
+ if (!eth)
+ continue;
+ node = of_parse_phandle(eth, "phy-handle", 0);
+ rv = set_mac_addr_prop(eth, mac_addr_base);
+ mac_addr_base++;
+ if (node && phy >= 0)
+ set_phy_addr_prop(node, cvmx_helper_board_get_mii_address(16 * i + p));
+ of_node_put(node);
+ of_node_put(eth);
+ }
+ of_node_put(iface);
+ }
+ of_node_put(pip);
+ }
+
+ of_node_put(aliases);
+ return 0;
+err:
+ return rv;
+}
+arch_initcall(octeon_fix_device_tree);
+
+static int __init octeon_publish_devices(void)
+{
+ return of_platform_bus_probe(NULL, octeon_ids, NULL);
+}
+device_initcall(octeon_publish_devices);
+
+
MODULE_AUTHOR("David Daney <[email protected]>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Platform driver for Octeon SOC");
diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
index ab1a106..818f66d5 100644
--- a/arch/mips/cavium-octeon/setup.c
+++ b/arch/mips/cavium-octeon/setup.c
@@ -20,6 +20,7 @@
#include <linux/platform_device.h>
#include <linux/serial_core.h>
#include <linux/serial_8250.h>
+#include <linux/of_fdt.h>
#ifdef CONFIG_BLK_DEV_INITRD
#include <linux/initrd.h>
#endif
@@ -797,3 +798,19 @@ void prom_free_prom_memory(void)
}
#endif
}
+
+int octeon_prune_device_tree(void);
+
+extern const char __dtb_octeon_3xxx_begin;
+extern const char __dtb_octeon_3xxx_end;
+void __init device_tree_init(void)
+{
+ int dt_size = &__dtb_octeon_3xxx_end - &__dtb_octeon_3xxx_begin;
+ /* Copy the default tree from init memory. */
+ initial_boot_params = early_init_dt_alloc_memory_arch(dt_size, 8);
+ if (initial_boot_params == NULL)
+ panic("Could not allocate initial_boot_params\n");
+ memcpy(initial_boot_params, &__dtb_octeon_3xxx_begin, dt_size);
+ unflatten_device_tree();
+ octeon_prune_device_tree();
+}
--
1.7.2.3
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.
Signed-off-by: David Daney <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
---
arch/mips/cavium-octeon/octeon-platform.c | 62 -------
drivers/net/octeon/octeon_mgmt.c | 265 +++++++++++++++++------------
2 files changed, 160 insertions(+), 167 deletions(-)
diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
index a33dcf9..3a3867b 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -166,68 +166,6 @@ out:
}
device_initcall(octeon_rng_device_init);
-/* Octeon mgmt port Ethernet interface. */
-static int __init octeon_mgmt_device_init(void)
-{
- struct platform_device *pd;
- int ret = 0;
- int port, num_ports;
-
- struct resource mgmt_port_resource = {
- .flags = IORESOURCE_IRQ,
- .start = -1,
- .end = -1
- };
-
- if (!OCTEON_IS_MODEL(OCTEON_CN56XX) && !OCTEON_IS_MODEL(OCTEON_CN52XX))
- return 0;
-
- if (OCTEON_IS_MODEL(OCTEON_CN56XX))
- num_ports = 1;
- else
- num_ports = 2;
-
- for (port = 0; port < num_ports; port++) {
- pd = platform_device_alloc("octeon_mgmt", port);
- if (!pd) {
- ret = -ENOMEM;
- goto out;
- }
- /* No DMA restrictions */
- pd->dev.coherent_dma_mask = DMA_BIT_MASK(64);
- pd->dev.dma_mask = &pd->dev.coherent_dma_mask;
-
- switch (port) {
- case 0:
- mgmt_port_resource.start = OCTEON_IRQ_MII0;
- break;
- case 1:
- mgmt_port_resource.start = OCTEON_IRQ_MII1;
- break;
- default:
- BUG();
- }
- mgmt_port_resource.end = mgmt_port_resource.start;
-
- ret = platform_device_add_resources(pd, &mgmt_port_resource, 1);
-
- if (ret)
- goto fail;
-
- ret = platform_device_add(pd);
- if (ret)
- goto fail;
- }
- return ret;
-fail:
- platform_device_put(pd);
-
-out:
- return ret;
-
-}
-device_initcall(octeon_mgmt_device_init);
-
#ifdef CONFIG_USB
static int __init octeon_ehci_device_init(void)
diff --git a/drivers/net/octeon/octeon_mgmt.c b/drivers/net/octeon/octeon_mgmt.c
index b264f0f..6c301c7 100644
--- a/drivers/net/octeon/octeon_mgmt.c
+++ b/drivers/net/octeon/octeon_mgmt.c
@@ -6,16 +6,21 @@
* Copyright (C) 2009 Cavium Networks
*/
-#include <linux/capability.h>
-#include <linux/dma-mapping.h>
-#include <linux/init.h>
#include <linux/platform_device.h>
-#include <linux/netdevice.h>
+#include <linux/dma-mapping.h>
#include <linux/etherdevice.h>
+#include <linux/of_platform.h>
+#include <linux/capability.h>
+#include <linux/of_address.h>
+#include <linux/netdevice.h>
+#include <linux/spinlock.h>
#include <linux/if_vlan.h>
+#include <linux/of_mdio.h>
+#include <linux/of_irq.h>
+#include <linux/of_net.h>
+#include <linux/init.h>
#include <linux/slab.h>
#include <linux/phy.h>
-#include <linux/spinlock.h>
#include <asm/octeon/octeon.h>
#include <asm/octeon/cvmx-mixx-defs.h>
@@ -55,8 +60,56 @@ union mgmt_port_ring_entry {
} s;
};
+#define MIX_ORING1 0x0
+#define MIX_ORING2 0x8
+#define MIX_IRING1 0x10
+#define MIX_IRING2 0x18
+#define MIX_CTL 0x20
+#define MIX_IRHWM 0x28
+#define MIX_IRCNT 0x30
+#define MIX_ORHWM 0x38
+#define MIX_ORCNT 0x40
+#define MIX_ISR 0x48
+#define MIX_INTENA 0x50
+#define MIX_REMCNT 0x58
+#define MIX_BIST 0x78
+
+#define AGL_GMX_PRT_CFG 0x10
+#define AGL_GMX_RX_FRM_CTL 0x18
+#define AGL_GMX_RX_FRM_MAX 0x30
+#define AGL_GMX_RX_JABBER 0x38
+#define AGL_GMX_RX_STATS_CTL 0x50
+
+#define AGL_GMX_RX_STATS_PKTS_DRP 0xb0
+#define AGL_GMX_RX_STATS_OCTS_DRP 0xb8
+#define AGL_GMX_RX_STATS_PKTS_BAD 0xc0
+
+#define AGL_GMX_RX_ADR_CTL 0x100
+#define AGL_GMX_RX_ADR_CAM_EN 0x108
+#define AGL_GMX_RX_ADR_CAM0 0x180
+#define AGL_GMX_RX_ADR_CAM1 0x188
+#define AGL_GMX_RX_ADR_CAM2 0x190
+#define AGL_GMX_RX_ADR_CAM3 0x198
+#define AGL_GMX_RX_ADR_CAM4 0x1a0
+#define AGL_GMX_RX_ADR_CAM5 0x1a8
+
+#define AGL_GMX_TX_STATS_CTL 0x268
+#define AGL_GMX_TX_CTL 0x270
+#define AGL_GMX_TX_STAT0 0x280
+#define AGL_GMX_TX_STAT1 0x288
+#define AGL_GMX_TX_STAT2 0x290
+#define AGL_GMX_TX_STAT3 0x298
+#define AGL_GMX_TX_STAT4 0x2a0
+#define AGL_GMX_TX_STAT5 0x2a8
+#define AGL_GMX_TX_STAT6 0x2b0
+#define AGL_GMX_TX_STAT7 0x2b8
+#define AGL_GMX_TX_STAT8 0x2c0
+#define AGL_GMX_TX_STAT9 0x2c8
+
struct octeon_mgmt {
struct net_device *netdev;
+ u64 mix;
+ u64 agl;
int port;
int irq;
u64 *tx_ring;
@@ -82,31 +135,30 @@ struct octeon_mgmt {
struct napi_struct napi;
struct tasklet_struct tx_clean_tasklet;
struct phy_device *phydev;
+ struct device_node *phy_np;
};
static void octeon_mgmt_set_rx_irq(struct octeon_mgmt *p, int enable)
{
- int port = p->port;
union cvmx_mixx_intena mix_intena;
unsigned long flags;
spin_lock_irqsave(&p->lock, flags);
- mix_intena.u64 = cvmx_read_csr(CVMX_MIXX_INTENA(port));
+ mix_intena.u64 = cvmx_read_csr(p->mix + MIX_INTENA);
mix_intena.s.ithena = enable ? 1 : 0;
- cvmx_write_csr(CVMX_MIXX_INTENA(port), mix_intena.u64);
+ cvmx_write_csr(p->mix + MIX_INTENA, mix_intena.u64);
spin_unlock_irqrestore(&p->lock, flags);
}
static void octeon_mgmt_set_tx_irq(struct octeon_mgmt *p, int enable)
{
- int port = p->port;
union cvmx_mixx_intena mix_intena;
unsigned long flags;
spin_lock_irqsave(&p->lock, flags);
- mix_intena.u64 = cvmx_read_csr(CVMX_MIXX_INTENA(port));
+ mix_intena.u64 = cvmx_read_csr(p->mix + MIX_INTENA);
mix_intena.s.othena = enable ? 1 : 0;
- cvmx_write_csr(CVMX_MIXX_INTENA(port), mix_intena.u64);
+ cvmx_write_csr(p->mix + MIX_INTENA, mix_intena.u64);
spin_unlock_irqrestore(&p->lock, flags);
}
@@ -143,7 +195,6 @@ static unsigned int ring_size_to_bytes(unsigned int ring_size)
static void octeon_mgmt_rx_fill_ring(struct net_device *netdev)
{
struct octeon_mgmt *p = netdev_priv(netdev);
- int port = p->port;
while (p->rx_current_fill < ring_max_fill(OCTEON_MGMT_RX_RING_SIZE)) {
unsigned int size;
@@ -174,24 +225,23 @@ static void octeon_mgmt_rx_fill_ring(struct net_device *netdev)
(p->rx_next_fill + 1) % OCTEON_MGMT_RX_RING_SIZE;
p->rx_current_fill++;
/* Ring the bell. */
- cvmx_write_csr(CVMX_MIXX_IRING2(port), 1);
+ cvmx_write_csr(p->mix + MIX_IRING2, 1);
}
}
static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p)
{
- int port = p->port;
union cvmx_mixx_orcnt mix_orcnt;
union mgmt_port_ring_entry re;
struct sk_buff *skb;
int cleaned = 0;
unsigned long flags;
- mix_orcnt.u64 = cvmx_read_csr(CVMX_MIXX_ORCNT(port));
+ mix_orcnt.u64 = cvmx_read_csr(p->mix + MIX_ORCNT);
while (mix_orcnt.s.orcnt) {
spin_lock_irqsave(&p->tx_list.lock, flags);
- mix_orcnt.u64 = cvmx_read_csr(CVMX_MIXX_ORCNT(port));
+ mix_orcnt.u64 = cvmx_read_csr(p->mix + MIX_ORCNT);
if (mix_orcnt.s.orcnt == 0) {
spin_unlock_irqrestore(&p->tx_list.lock, flags);
@@ -211,7 +261,7 @@ static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p)
mix_orcnt.s.orcnt = 1;
/* Acknowledge to hardware that we have the buffer. */
- cvmx_write_csr(CVMX_MIXX_ORCNT(port), mix_orcnt.u64);
+ cvmx_write_csr(p->mix + MIX_ORCNT, mix_orcnt.u64);
p->tx_current_fill--;
spin_unlock_irqrestore(&p->tx_list.lock, flags);
@@ -221,7 +271,7 @@ static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p)
dev_kfree_skb_any(skb);
cleaned++;
- mix_orcnt.u64 = cvmx_read_csr(CVMX_MIXX_ORCNT(port));
+ mix_orcnt.u64 = cvmx_read_csr(p->mix + MIX_ORCNT);
}
if (cleaned && netif_queue_stopped(p->netdev))
@@ -238,13 +288,12 @@ static void octeon_mgmt_clean_tx_tasklet(unsigned long arg)
static void octeon_mgmt_update_rx_stats(struct net_device *netdev)
{
struct octeon_mgmt *p = netdev_priv(netdev);
- int port = p->port;
unsigned long flags;
u64 drop, bad;
/* These reads also clear the count registers. */
- drop = cvmx_read_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_DRP(port));
- bad = cvmx_read_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_BAD(port));
+ drop = cvmx_read_csr(p->agl + AGL_GMX_RX_STATS_PKTS_DRP);
+ bad = cvmx_read_csr(p->agl + AGL_GMX_RX_STATS_PKTS_BAD);
if (drop || bad) {
/* Do an atomic update. */
@@ -258,15 +307,14 @@ static void octeon_mgmt_update_rx_stats(struct net_device *netdev)
static void octeon_mgmt_update_tx_stats(struct net_device *netdev)
{
struct octeon_mgmt *p = netdev_priv(netdev);
- int port = p->port;
unsigned long flags;
union cvmx_agl_gmx_txx_stat0 s0;
union cvmx_agl_gmx_txx_stat1 s1;
/* These reads also clear the count registers. */
- s0.u64 = cvmx_read_csr(CVMX_AGL_GMX_TXX_STAT0(port));
- s1.u64 = cvmx_read_csr(CVMX_AGL_GMX_TXX_STAT1(port));
+ s0.u64 = cvmx_read_csr(p->agl + AGL_GMX_TX_STAT0);
+ s1.u64 = cvmx_read_csr(p->agl + AGL_GMX_TX_STAT1);
if (s0.s.xsdef || s0.s.xscol || s1.s.scol || s1.s.mcol) {
/* Do an atomic update. */
@@ -305,7 +353,6 @@ static u64 octeon_mgmt_dequeue_rx_buffer(struct octeon_mgmt *p,
static int octeon_mgmt_receive_one(struct octeon_mgmt *p)
{
- int port = p->port;
struct net_device *netdev = p->netdev;
union cvmx_mixx_ircnt mix_ircnt;
union mgmt_port_ring_entry re;
@@ -378,18 +425,17 @@ done:
/* Tell the hardware we processed a packet. */
mix_ircnt.u64 = 0;
mix_ircnt.s.ircnt = 1;
- cvmx_write_csr(CVMX_MIXX_IRCNT(port), mix_ircnt.u64);
+ cvmx_write_csr(p->mix + MIX_IRCNT, mix_ircnt.u64);
return rc;
}
static int octeon_mgmt_receive_packets(struct octeon_mgmt *p, int budget)
{
- int port = p->port;
unsigned int work_done = 0;
union cvmx_mixx_ircnt mix_ircnt;
int rc;
- mix_ircnt.u64 = cvmx_read_csr(CVMX_MIXX_IRCNT(port));
+ mix_ircnt.u64 = cvmx_read_csr(p->mix + MIX_IRCNT);
while (work_done < budget && mix_ircnt.s.ircnt) {
rc = octeon_mgmt_receive_one(p);
@@ -397,7 +443,7 @@ static int octeon_mgmt_receive_packets(struct octeon_mgmt *p, int budget)
work_done++;
/* Check for more packets. */
- mix_ircnt.u64 = cvmx_read_csr(CVMX_MIXX_IRCNT(port));
+ mix_ircnt.u64 = cvmx_read_csr(p->mix + MIX_IRCNT);
}
octeon_mgmt_rx_fill_ring(p->netdev);
@@ -431,16 +477,16 @@ static void octeon_mgmt_reset_hw(struct octeon_mgmt *p)
union cvmx_agl_gmx_bist agl_gmx_bist;
mix_ctl.u64 = 0;
- cvmx_write_csr(CVMX_MIXX_CTL(p->port), mix_ctl.u64);
+ cvmx_write_csr(p->mix + MIX_CTL, mix_ctl.u64);
do {
- mix_ctl.u64 = cvmx_read_csr(CVMX_MIXX_CTL(p->port));
+ mix_ctl.u64 = cvmx_read_csr(p->mix + MIX_CTL);
} while (mix_ctl.s.busy);
mix_ctl.s.reset = 1;
- cvmx_write_csr(CVMX_MIXX_CTL(p->port), mix_ctl.u64);
- cvmx_read_csr(CVMX_MIXX_CTL(p->port));
+ cvmx_write_csr(p->mix + MIX_CTL, mix_ctl.u64);
+ cvmx_read_csr(p->mix + MIX_CTL);
cvmx_wait(64);
- mix_bist.u64 = cvmx_read_csr(CVMX_MIXX_BIST(p->port));
+ mix_bist.u64 = cvmx_read_csr(p->mix + MIX_BIST);
if (mix_bist.u64)
dev_warn(p->dev, "MIX failed BIST (0x%016llx)\n",
(unsigned long long)mix_bist.u64);
@@ -471,7 +517,6 @@ static void octeon_mgmt_cam_state_add(struct octeon_mgmt_cam_state *cs,
static void octeon_mgmt_set_rx_filtering(struct net_device *netdev)
{
struct octeon_mgmt *p = netdev_priv(netdev);
- int port = p->port;
union cvmx_agl_gmx_rxx_adr_ctl adr_ctl;
union cvmx_agl_gmx_prtx_cfg agl_gmx_prtx;
unsigned long flags;
@@ -517,29 +562,29 @@ static void octeon_mgmt_set_rx_filtering(struct net_device *netdev)
spin_lock_irqsave(&p->lock, flags);
/* Disable packet I/O. */
- agl_gmx_prtx.u64 = cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
+ agl_gmx_prtx.u64 = cvmx_read_csr(p->agl + AGL_GMX_PRT_CFG);
prev_packet_enable = agl_gmx_prtx.s.en;
agl_gmx_prtx.s.en = 0;
- cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), agl_gmx_prtx.u64);
+ cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, agl_gmx_prtx.u64);
adr_ctl.u64 = 0;
adr_ctl.s.cam_mode = cam_mode;
adr_ctl.s.mcst = multicast_mode;
adr_ctl.s.bcst = 1; /* Allow broadcast */
- cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CTL(port), adr_ctl.u64);
+ cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CTL, adr_ctl.u64);
- cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM0(port), cam_state.cam[0]);
- cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM1(port), cam_state.cam[1]);
- cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM2(port), cam_state.cam[2]);
- cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM3(port), cam_state.cam[3]);
- cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM4(port), cam_state.cam[4]);
- cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM5(port), cam_state.cam[5]);
- cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM_EN(port), cam_state.cam_mask);
+ cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM0, cam_state.cam[0]);
+ cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM1, cam_state.cam[1]);
+ cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM2, cam_state.cam[2]);
+ cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM3, cam_state.cam[3]);
+ cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM4, cam_state.cam[4]);
+ cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM5, cam_state.cam[5]);
+ cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM_EN, cam_state.cam_mask);
/* Restore packet I/O. */
agl_gmx_prtx.s.en = prev_packet_enable;
- cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), agl_gmx_prtx.u64);
+ cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, agl_gmx_prtx.u64);
spin_unlock_irqrestore(&p->lock, flags);
}
@@ -561,7 +606,6 @@ static int octeon_mgmt_set_mac_address(struct net_device *netdev, void *addr)
static int octeon_mgmt_change_mtu(struct net_device *netdev, int new_mtu)
{
struct octeon_mgmt *p = netdev_priv(netdev);
- int port = p->port;
int size_without_fcs = new_mtu + OCTEON_MGMT_RX_HEADROOM;
/*
@@ -577,8 +621,8 @@ static int octeon_mgmt_change_mtu(struct net_device *netdev, int new_mtu)
netdev->mtu = new_mtu;
- cvmx_write_csr(CVMX_AGL_GMX_RXX_FRM_MAX(port), size_without_fcs);
- cvmx_write_csr(CVMX_AGL_GMX_RXX_JABBER(port),
+ cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_MAX, size_without_fcs);
+ cvmx_write_csr(p->agl + AGL_GMX_RX_JABBER,
(size_without_fcs + 7) & 0xfff8);
return 0;
@@ -588,14 +632,13 @@ static irqreturn_t octeon_mgmt_interrupt(int cpl, void *dev_id)
{
struct net_device *netdev = dev_id;
struct octeon_mgmt *p = netdev_priv(netdev);
- int port = p->port;
union cvmx_mixx_isr mixx_isr;
- mixx_isr.u64 = cvmx_read_csr(CVMX_MIXX_ISR(port));
+ mixx_isr.u64 = cvmx_read_csr(p->mix + MIX_ISR);
/* Clear any pending interrupts */
- cvmx_write_csr(CVMX_MIXX_ISR(port), mixx_isr.u64);
- cvmx_read_csr(CVMX_MIXX_ISR(port));
+ cvmx_write_csr(p->mix + MIX_ISR, mixx_isr.u64);
+ cvmx_read_csr(p->mix + MIX_ISR);
if (mixx_isr.s.irthresh) {
octeon_mgmt_disable_rx_irq(p);
@@ -626,7 +669,6 @@ static int octeon_mgmt_ioctl(struct net_device *netdev,
static void octeon_mgmt_adjust_link(struct net_device *netdev)
{
struct octeon_mgmt *p = netdev_priv(netdev);
- int port = p->port;
union cvmx_agl_gmx_prtx_cfg prtx_cfg;
unsigned long flags;
int link_changed = 0;
@@ -637,11 +679,9 @@ static void octeon_mgmt_adjust_link(struct net_device *netdev)
link_changed = 1;
if (p->last_duplex != p->phydev->duplex) {
p->last_duplex = p->phydev->duplex;
- prtx_cfg.u64 =
- cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
+ prtx_cfg.u64 = cvmx_read_csr(p->agl + AGL_GMX_PRT_CFG);
prtx_cfg.s.duplex = p->phydev->duplex;
- cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port),
- prtx_cfg.u64);
+ cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, prtx_cfg.u64);
}
} else {
if (p->last_link)
@@ -667,18 +707,16 @@ static void octeon_mgmt_adjust_link(struct net_device *netdev)
static int octeon_mgmt_init_phy(struct net_device *netdev)
{
struct octeon_mgmt *p = netdev_priv(netdev);
- char phy_id[20];
- if (octeon_is_simulation()) {
+ if (octeon_is_simulation() || p->phy_np == NULL) {
/* No PHYs in the simulator. */
netif_carrier_on(netdev);
return 0;
}
- snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, "0", p->port);
-
- p->phydev = phy_connect(netdev, phy_id, octeon_mgmt_adjust_link, 0,
- PHY_INTERFACE_MODE_MII);
+ p->phydev = of_phy_connect(netdev, p->phy_np,
+ octeon_mgmt_adjust_link, 0,
+ PHY_INTERFACE_MODE_MII);
if (IS_ERR(p->phydev)) {
p->phydev = NULL;
@@ -734,14 +772,14 @@ static int octeon_mgmt_open(struct net_device *netdev)
octeon_mgmt_reset_hw(p);
- mix_ctl.u64 = cvmx_read_csr(CVMX_MIXX_CTL(port));
+ mix_ctl.u64 = cvmx_read_csr(p->mix + MIX_CTL);
/* Bring it out of reset if needed. */
if (mix_ctl.s.reset) {
mix_ctl.s.reset = 0;
- cvmx_write_csr(CVMX_MIXX_CTL(port), mix_ctl.u64);
+ cvmx_write_csr(p->mix + MIX_CTL, mix_ctl.u64);
do {
- mix_ctl.u64 = cvmx_read_csr(CVMX_MIXX_CTL(port));
+ mix_ctl.u64 = cvmx_read_csr(p->mix + MIX_CTL);
} while (mix_ctl.s.reset);
}
@@ -752,17 +790,17 @@ static int octeon_mgmt_open(struct net_device *netdev)
oring1.u64 = 0;
oring1.s.obase = p->tx_ring_handle >> 3;
oring1.s.osize = OCTEON_MGMT_TX_RING_SIZE;
- cvmx_write_csr(CVMX_MIXX_ORING1(port), oring1.u64);
+ cvmx_write_csr(p->mix + MIX_ORING1, oring1.u64);
iring1.u64 = 0;
iring1.s.ibase = p->rx_ring_handle >> 3;
iring1.s.isize = OCTEON_MGMT_RX_RING_SIZE;
- cvmx_write_csr(CVMX_MIXX_IRING1(port), iring1.u64);
+ cvmx_write_csr(p->mix + MIX_IRING1, iring1.u64);
/* Disable packet I/O. */
- prtx_cfg.u64 = cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
+ prtx_cfg.u64 = cvmx_read_csr(p->agl + AGL_GMX_PRT_CFG);
prtx_cfg.s.en = 0;
- cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), prtx_cfg.u64);
+ cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, prtx_cfg.u64);
memcpy(sa.sa_data, netdev->dev_addr, ETH_ALEN);
octeon_mgmt_set_mac_address(netdev, &sa);
@@ -779,7 +817,7 @@ static int octeon_mgmt_open(struct net_device *netdev)
mix_ctl.s.nbtarb = 0; /* Arbitration mode */
/* MII CB-request FIFO programmable high watermark */
mix_ctl.s.mrq_hwm = 1;
- cvmx_write_csr(CVMX_MIXX_CTL(port), mix_ctl.u64);
+ cvmx_write_csr(p->mix + MIX_CTL, mix_ctl.u64);
if (OCTEON_IS_MODEL(OCTEON_CN56XX_PASS1_X)
|| OCTEON_IS_MODEL(OCTEON_CN52XX_PASS1_X)) {
@@ -806,16 +844,16 @@ static int octeon_mgmt_open(struct net_device *netdev)
/* Clear statistics. */
/* Clear on read. */
- cvmx_write_csr(CVMX_AGL_GMX_RXX_STATS_CTL(port), 1);
- cvmx_write_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_DRP(port), 0);
- cvmx_write_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_BAD(port), 0);
+ cvmx_write_csr(p->agl + AGL_GMX_RX_STATS_CTL, 1);
+ cvmx_write_csr(p->agl + AGL_GMX_RX_STATS_PKTS_DRP, 0);
+ cvmx_write_csr(p->agl + AGL_GMX_RX_STATS_PKTS_BAD, 0);
- cvmx_write_csr(CVMX_AGL_GMX_TXX_STATS_CTL(port), 1);
- cvmx_write_csr(CVMX_AGL_GMX_TXX_STAT0(port), 0);
- cvmx_write_csr(CVMX_AGL_GMX_TXX_STAT1(port), 0);
+ cvmx_write_csr(p->agl + AGL_GMX_TX_STATS_CTL, 1);
+ cvmx_write_csr(p->agl + AGL_GMX_TX_STAT0, 0);
+ cvmx_write_csr(p->agl + AGL_GMX_TX_STAT1, 0);
/* Clear any pending interrupts */
- cvmx_write_csr(CVMX_MIXX_ISR(port), cvmx_read_csr(CVMX_MIXX_ISR(port)));
+ cvmx_write_csr(p->mix + MIX_ISR, cvmx_read_csr(p->mix + MIX_ISR));
if (request_irq(p->irq, octeon_mgmt_interrupt, 0, netdev->name,
netdev)) {
@@ -826,18 +864,18 @@ static int octeon_mgmt_open(struct net_device *netdev)
/* Interrupt every single RX packet */
mix_irhwm.u64 = 0;
mix_irhwm.s.irhwm = 0;
- cvmx_write_csr(CVMX_MIXX_IRHWM(port), mix_irhwm.u64);
+ cvmx_write_csr(p->mix + MIX_IRHWM, mix_irhwm.u64);
/* Interrupt when we have 1 or more packets to clean. */
mix_orhwm.u64 = 0;
mix_orhwm.s.orhwm = 1;
- cvmx_write_csr(CVMX_MIXX_ORHWM(port), mix_orhwm.u64);
+ cvmx_write_csr(p->mix + MIX_ORHWM, mix_orhwm.u64);
/* Enable receive and transmit interrupts */
mix_intena.u64 = 0;
mix_intena.s.ithena = 1;
mix_intena.s.othena = 1;
- cvmx_write_csr(CVMX_MIXX_INTENA(port), mix_intena.u64);
+ cvmx_write_csr(p->mix + MIX_INTENA, mix_intena.u64);
/* Enable packet I/O. */
@@ -868,7 +906,7 @@ static int octeon_mgmt_open(struct net_device *netdev)
* frame. GMX checks that the PREAMBLE is sent correctly.
*/
rxx_frm_ctl.s.pre_chk = 1;
- cvmx_write_csr(CVMX_AGL_GMX_RXX_FRM_CTL(port), rxx_frm_ctl.u64);
+ cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_CTL, rxx_frm_ctl.u64);
/* Enable the AGL block */
agl_gmx_inf_mode.u64 = 0;
@@ -876,13 +914,13 @@ static int octeon_mgmt_open(struct net_device *netdev)
cvmx_write_csr(CVMX_AGL_GMX_INF_MODE, agl_gmx_inf_mode.u64);
/* Configure the port duplex and enables */
- prtx_cfg.u64 = cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
+ prtx_cfg.u64 = cvmx_read_csr(p->agl + AGL_GMX_PRT_CFG);
prtx_cfg.s.tx_en = 1;
prtx_cfg.s.rx_en = 1;
prtx_cfg.s.en = 1;
p->last_duplex = 1;
prtx_cfg.s.duplex = p->last_duplex;
- cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), prtx_cfg.u64);
+ cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, prtx_cfg.u64);
p->last_link = 0;
netif_carrier_off(netdev);
@@ -946,7 +984,6 @@ static int octeon_mgmt_stop(struct net_device *netdev)
static int octeon_mgmt_xmit(struct sk_buff *skb, struct net_device *netdev)
{
struct octeon_mgmt *p = netdev_priv(netdev);
- int port = p->port;
union mgmt_port_ring_entry re;
unsigned long flags;
int rv = NETDEV_TX_BUSY;
@@ -990,7 +1027,7 @@ static int octeon_mgmt_xmit(struct sk_buff *skb, struct net_device *netdev)
netdev->stats.tx_bytes += skb->len;
/* Ring the bell. */
- cvmx_write_csr(CVMX_MIXX_ORING2(port), 1);
+ cvmx_write_csr(p->mix + MIX_ORING2, 1);
rv = NETDEV_TX_OK;
out:
@@ -1067,12 +1104,14 @@ static const struct net_device_ops octeon_mgmt_ops = {
#endif
};
-static int __devinit octeon_mgmt_probe(struct platform_device *pdev)
+static int __devinit octeon_mgmt_probe(struct platform_device *pdev,
+ const struct of_device_id *match)
{
- struct resource *res_irq;
struct net_device *netdev;
struct octeon_mgmt *p;
- int i;
+ const __be32 *data;
+ const u8 *mac;
+ int len;
netdev = alloc_etherdev(sizeof(struct octeon_mgmt));
if (netdev == NULL)
@@ -1086,14 +1125,21 @@ static int __devinit octeon_mgmt_probe(struct platform_device *pdev)
p->netdev = netdev;
p->dev = &pdev->dev;
- p->port = pdev->id;
+ data = of_get_property(pdev->dev.of_node, "unit-number", &len);
+ if (data && len == sizeof(*data))
+ p->port = be32_to_cpup(data);
+ else
+ p->port = 0;
+
snprintf(netdev->name, IFNAMSIZ, "mgmt%d", p->port);
- res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
- if (!res_irq)
+ p->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
+ if (!p->irq)
goto err;
- p->irq = res_irq->start;
+ p->mix = (u64)of_iomap(pdev->dev.of_node, 0);
+ p->agl = (u64)of_iomap(pdev->dev.of_node, 1);
+
spin_lock_init(&p->lock);
skb_queue_head_init(&p->tx_list);
@@ -1104,15 +1150,15 @@ static int __devinit octeon_mgmt_probe(struct platform_device *pdev)
netdev->netdev_ops = &octeon_mgmt_ops;
netdev->ethtool_ops = &octeon_mgmt_ethtool_ops;
- /* The mgmt ports get the first N MACs. */
- for (i = 0; i < 6; i++)
- netdev->dev_addr[i] = octeon_bootinfo->mac_addr_base[i];
- netdev->dev_addr[5] += p->port;
+ mac = of_get_mac_address(pdev->dev.of_node);
+
+ if (mac)
+ memcpy(netdev->dev_addr, mac, 6);
- if (p->port >= octeon_bootinfo->mac_addr_count)
- dev_err(&pdev->dev,
- "Error %s: Using MAC outside of the assigned range: %pM\n",
- netdev->name, netdev->dev_addr);
+ p->phy_np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
+
+ pdev->dev.coherent_dma_mask = DMA_BIT_MASK(64);
+ pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
if (register_netdev(netdev))
goto err;
@@ -1133,10 +1179,19 @@ static int __devexit octeon_mgmt_remove(struct platform_device *pdev)
return 0;
}
-static struct platform_driver octeon_mgmt_driver = {
+static struct of_device_id octeon_mgmt_match[] = {
+ {
+ .compatible = "octeon,mgmt",
+ },
+ {},
+};
+MODULE_DEVICE_TABLE(of, octeon_mgmt_match);
+
+static struct of_platform_driver octeon_mgmt_driver = {
.driver = {
.name = "octeon_mgmt",
.owner = THIS_MODULE,
+ .of_match_table = octeon_mgmt_match,
},
.probe = octeon_mgmt_probe,
.remove = __devexit_p(octeon_mgmt_remove),
@@ -1148,12 +1203,12 @@ static int __init octeon_mgmt_mod_init(void)
{
/* Force our mdiobus driver module to be loaded first. */
octeon_mdiobus_force_mod_depencency();
- return platform_driver_register(&octeon_mgmt_driver);
+ return of_register_platform_driver(&octeon_mgmt_driver);
}
static void __exit octeon_mgmt_mod_exit(void)
{
- platform_driver_unregister(&octeon_mgmt_driver);
+ of_unregister_platform_driver(&octeon_mgmt_driver);
}
module_init(octeon_mgmt_mod_init);
--
1.7.2.3
Get MAC address and PHY connection from the device tree.
Signed-off-by: David Daney <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
---
drivers/staging/octeon/ethernet-mdio.c | 27 +++++----
drivers/staging/octeon/ethernet.c | 101 +++++++++++++++++++-----------
drivers/staging/octeon/octeon-ethernet.h | 3 +
3 files changed, 82 insertions(+), 49 deletions(-)
diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c
index 0e5dab7..38a0153 100644
--- a/drivers/staging/octeon/ethernet-mdio.c
+++ b/drivers/staging/octeon/ethernet-mdio.c
@@ -27,6 +27,7 @@
#include <linux/kernel.h>
#include <linux/ethtool.h>
#include <linux/phy.h>
+#include <linux/of_mdio.h>
#include <net/dst.h>
@@ -162,22 +163,24 @@ 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[20];
+ if (!priv->of_node)
+ return 0;
- snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, "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 (IS_ERR(priv->phydev)) {
- priv->phydev = NULL;
- return -1;
- }
- 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;
}
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
index 042adf7..87f8956 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -31,6 +31,7 @@
#include <linux/etherdevice.h>
#include <linux/phy.h>
#include <linux/slab.h>
+#include <linux/of_net.h>
#include <net/dst.h>
@@ -112,15 +113,6 @@ int rx_napi_weight = 32;
module_param(rx_napi_weight, int, 0444);
MODULE_PARM_DESC(rx_napi_weight, "The NAPI WEIGHT parameter.");
-/*
- * The offset from mac_addr_base that should be used for the next port
- * that is configured. By convention, if any mgmt ports exist on the
- * chip, they get the first mac addresses, The ports controlled by
- * this driver are numbered sequencially following any mgmt addresses
- * that may exist.
- */
-static unsigned int cvm_oct_mac_addr_offset;
-
/**
* cvm_oct_poll_queue - Workqueue for polling operations.
*/
@@ -447,26 +439,13 @@ static int cvm_oct_common_set_mac_address(struct net_device *dev, void *addr)
int cvm_oct_common_init(struct net_device *dev)
{
struct octeon_ethernet *priv = netdev_priv(dev);
- struct sockaddr sa;
- u64 mac = ((u64)(octeon_bootinfo->mac_addr_base[0] & 0xff) << 40) |
- ((u64)(octeon_bootinfo->mac_addr_base[1] & 0xff) << 32) |
- ((u64)(octeon_bootinfo->mac_addr_base[2] & 0xff) << 24) |
- ((u64)(octeon_bootinfo->mac_addr_base[3] & 0xff) << 16) |
- ((u64)(octeon_bootinfo->mac_addr_base[4] & 0xff) << 8) |
- (u64)(octeon_bootinfo->mac_addr_base[5] & 0xff);
-
- mac += cvm_oct_mac_addr_offset;
- sa.sa_data[0] = (mac >> 40) & 0xff;
- sa.sa_data[1] = (mac >> 32) & 0xff;
- sa.sa_data[2] = (mac >> 24) & 0xff;
- sa.sa_data[3] = (mac >> 16) & 0xff;
- sa.sa_data[4] = (mac >> 8) & 0xff;
- sa.sa_data[5] = mac & 0xff;
-
- if (cvm_oct_mac_addr_offset >= octeon_bootinfo->mac_addr_count)
- printk(KERN_DEBUG "%s: Using MAC outside of the assigned range:"
- " %pM\n", dev->name, sa.sa_data);
- cvm_oct_mac_addr_offset++;
+ struct sockaddr sa = {0};
+
+ if (priv->of_node) {
+ const u8 *mac = of_get_mac_address(priv->of_node);
+ if (mac)
+ memcpy(sa.sa_data, mac, 6);
+ }
/*
* Force the interface to use the POW send if always_use_pow
@@ -594,22 +573,68 @@ static const struct net_device_ops cvm_oct_pow_netdev_ops = {
extern void octeon_mdiobus_force_mod_depencency(void);
+static struct device_node * __init cvm_oct_of_get_child(const struct device_node *parent,
+ int reg_val)
+{
+ struct device_node *node = NULL;
+ int size;
+ const __be32 *addr;
+
+ for (;;) {
+ node = of_get_next_child(parent, node);
+ if (!node)
+ break;
+ addr = of_get_property(node, "reg", &size);
+ if (addr && (be32_to_cpu(*addr) == reg_val))
+ break;
+ }
+ return node;
+}
+
+static struct device_node * __init cvm_oct_node_for_port(struct device_node *pip,
+ int interface, int port)
+{
+ struct device_node *ni, *np;
+
+ ni = cvm_oct_of_get_child(pip, interface);
+ if (!ni)
+ return NULL;
+
+ np = cvm_oct_of_get_child(ni, port);
+ of_node_put(ni);
+
+ return np;
+}
+
static int __init cvm_oct_init_module(void)
{
int num_interfaces;
int interface;
int fau = FAU_NUM_PACKET_BUFFERS_TO_FREE;
int qos;
+ struct device_node *aliases;
+ const char *node_path;
+ struct device_node *pip;
octeon_mdiobus_force_mod_depencency();
pr_notice("cavium-ethernet %s\n", OCTEON_ETHERNET_VERSION);
- if (OCTEON_IS_MODEL(OCTEON_CN52XX))
- cvm_oct_mac_addr_offset = 2; /* First two are the mgmt ports. */
- else if (OCTEON_IS_MODEL(OCTEON_CN56XX))
- cvm_oct_mac_addr_offset = 1; /* First one is the mgmt port. */
- else
- cvm_oct_mac_addr_offset = 0;
+
+ aliases = of_find_node_by_path("/aliases");
+ if (!aliases) {
+ pr_err("Error: No /aliases node in device tree.");
+ return -EINVAL;
+ }
+ node_path = of_get_property(aliases, "pip", NULL);
+ if (!node_path) {
+ pr_err("Error: No /aliases/pip node in device tree.");
+ return -EINVAL;
+ }
+ pip = of_find_node_by_path(node_path);
+ if (!pip) {
+ pr_err("Error: No %s in device tree.", node_path);
+ return -EINVAL;
+ }
cvm_oct_poll_queue = create_singlethread_workqueue("octeon-ethernet");
if (cvm_oct_poll_queue == NULL) {
@@ -688,10 +713,11 @@ static int __init cvm_oct_init_module(void)
cvmx_helper_interface_get_mode(interface);
int num_ports = cvmx_helper_ports_on_interface(interface);
int port;
+ int port_index;
- for (port = cvmx_helper_get_ipd_port(interface, 0);
+ for (port_index = 0, port = cvmx_helper_get_ipd_port(interface, 0);
port < cvmx_helper_get_ipd_port(interface, num_ports);
- port++) {
+ port_index++, port++) {
struct octeon_ethernet *priv;
struct net_device *dev =
alloc_etherdev(sizeof(struct octeon_ethernet));
@@ -702,6 +728,7 @@ static int __init cvm_oct_init_module(void)
/* Initialize the device private structure. */
priv = netdev_priv(dev);
+ priv->of_node = cvm_oct_node_for_port(pip, interface, port_index);
INIT_DELAYED_WORK(&priv->port_periodic_work,
cvm_oct_periodic_worker);
diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h
index d581925..9360e22 100644
--- a/drivers/staging/octeon/octeon-ethernet.h
+++ b/drivers/staging/octeon/octeon-ethernet.h
@@ -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);
--
1.7.2.3
Signed-off-by: David Daney <[email protected]>
Cc: "Jean Delvare (PC drivers, core)" <[email protected]>
Cc: "Ben Dooks (embedded platforms)" <[email protected]>
Cc: [email protected]
---
arch/mips/cavium-octeon/octeon-platform.c | 84 ---------------------------
arch/mips/include/asm/octeon/octeon.h | 5 --
drivers/i2c/busses/i2c-octeon.c | 88 +++++++++++++---------------
3 files changed, 41 insertions(+), 136 deletions(-)
diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
index 428de0d..f148324 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -166,90 +166,6 @@ out:
}
device_initcall(octeon_rng_device_init);
-static struct i2c_board_info __initdata octeon_i2c_devices[] = {
- {
- I2C_BOARD_INFO("ds1337", 0x68),
- },
-};
-
-static int __init octeon_i2c_devices_init(void)
-{
- return i2c_register_board_info(0, octeon_i2c_devices,
- ARRAY_SIZE(octeon_i2c_devices));
-}
-arch_initcall(octeon_i2c_devices_init);
-
-#define OCTEON_I2C_IO_BASE 0x1180000001000ull
-#define OCTEON_I2C_IO_UNIT_OFFSET 0x200
-
-static struct octeon_i2c_data octeon_i2c_data[2];
-
-static int __init octeon_i2c_device_init(void)
-{
- struct platform_device *pd;
- int ret = 0;
- int port, num_ports;
-
- struct resource i2c_resources[] = {
- {
- .flags = IORESOURCE_MEM,
- }, {
- .flags = IORESOURCE_IRQ,
- }
- };
-
- if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX))
- num_ports = 2;
- else
- num_ports = 1;
-
- for (port = 0; port < num_ports; port++) {
- octeon_i2c_data[port].sys_freq = octeon_get_io_clock_rate();
- /*FIXME: should be examined. At the moment is set for 100Khz */
- octeon_i2c_data[port].i2c_freq = 100000;
-
- pd = platform_device_alloc("i2c-octeon", port);
- if (!pd) {
- ret = -ENOMEM;
- goto out;
- }
-
- pd->dev.platform_data = octeon_i2c_data + port;
-
- i2c_resources[0].start =
- OCTEON_I2C_IO_BASE + (port * OCTEON_I2C_IO_UNIT_OFFSET);
- i2c_resources[0].end = i2c_resources[0].start + 0x1f;
- switch (port) {
- case 0:
- i2c_resources[1].start = OCTEON_IRQ_TWSI;
- i2c_resources[1].end = OCTEON_IRQ_TWSI;
- break;
- case 1:
- i2c_resources[1].start = OCTEON_IRQ_TWSI2;
- i2c_resources[1].end = OCTEON_IRQ_TWSI2;
- break;
- default:
- BUG();
- }
-
- ret = platform_device_add_resources(pd,
- i2c_resources,
- ARRAY_SIZE(i2c_resources));
- if (ret)
- goto fail;
-
- ret = platform_device_add(pd);
- if (ret)
- goto fail;
- }
- return ret;
-fail:
- platform_device_put(pd);
-out:
- return ret;
-}
-device_initcall(octeon_i2c_device_init);
-
/* Octeon SMI/MDIO interface. */
static int __init octeon_mdiobus_device_init(void)
{
diff --git a/arch/mips/include/asm/octeon/octeon.h b/arch/mips/include/asm/octeon/octeon.h
index f72f768..1e2486e 100644
--- a/arch/mips/include/asm/octeon/octeon.h
+++ b/arch/mips/include/asm/octeon/octeon.h
@@ -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);
diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c
index 56dbe54..99a20c6 100644
--- a/drivers/i2c/busses/i2c-octeon.c
+++ b/drivers/i2c/busses/i2c-octeon.c
@@ -11,17 +11,21 @@
* warranty of any kind, whether express or implied.
*/
+#include <linux/platform_device.h>
+#include <linux/of_platform.h>
+#include <linux/of_address.h>
+#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/of_irq.h>
+#include <linux/of_i2c.h>
+#include <linux/delay.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/init.h>
-
-#include <linux/io.h>
#include <linux/i2c.h>
-#include <linux/interrupt.h>
-#include <linux/delay.h>
-#include <linux/platform_device.h>
+#include <linux/io.h>
+#include <linux/of.h>
#include <asm/octeon/octeon.h>
@@ -67,9 +71,7 @@ struct octeon_i2c {
int irq;
int twsi_freq;
int sys_freq;
- resource_size_t twsi_phys;
void __iomem *twsi_base;
- resource_size_t regsize;
struct device *dev;
};
@@ -511,17 +513,18 @@ static int __devinit octeon_i2c_initlowlevel(struct octeon_i2c *i2c)
return -EIO;
}
-static int __devinit octeon_i2c_probe(struct platform_device *pdev)
+static int __devinit octeon_i2c_probe(struct platform_device *pdev,
+ const struct of_device_id *match)
{
int irq, result = 0;
struct octeon_i2c *i2c;
- struct octeon_i2c_data *i2c_data;
- struct resource *res_mem;
+ const __be32 *data;
+ int len;
/* All adaptors have an irq. */
- irq = platform_get_irq(pdev, 0);
- if (irq < 0)
- return irq;
+ irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
+ if (!irq)
+ return -ENXIO;
i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
if (!i2c) {
@@ -530,32 +533,16 @@ static int __devinit octeon_i2c_probe(struct platform_device *pdev)
goto out;
}
i2c->dev = &pdev->dev;
- i2c_data = pdev->dev.platform_data;
-
- res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
- if (res_mem == NULL) {
- dev_err(i2c->dev, "found no memory resource\n");
- result = -ENXIO;
- goto fail_region;
- }
- if (i2c_data == NULL) {
- dev_err(i2c->dev, "no I2C frequency data\n");
- result = -ENXIO;
- goto fail_region;
- }
+ data = of_get_property(pdev->dev.of_node, "clock-rate", &len);
+ if (data && len == sizeof(*data))
+ i2c->twsi_freq = be32_to_cpup(data);
+ else
+ i2c->twsi_freq = 100000;
- i2c->twsi_phys = res_mem->start;
- i2c->regsize = resource_size(res_mem);
- i2c->twsi_freq = i2c_data->i2c_freq;
- i2c->sys_freq = i2c_data->sys_freq;
+ i2c->sys_freq = octeon_get_io_clock_rate();
- if (!request_mem_region(i2c->twsi_phys, i2c->regsize, res_mem->name)) {
- dev_err(i2c->dev, "request_mem_region failed\n");
- goto fail_region;
- }
- i2c->twsi_base = ioremap(i2c->twsi_phys, i2c->regsize);
+ i2c->twsi_base = of_iomap(pdev->dev.of_node, 0);
init_waitqueue_head(&i2c->queue);
@@ -581,27 +568,27 @@ static int __devinit octeon_i2c_probe(struct platform_device *pdev)
i2c->adap = octeon_i2c_ops;
i2c->adap.dev.parent = &pdev->dev;
- i2c->adap.nr = pdev->id >= 0 ? pdev->id : 0;
+ i2c->adap.dev.of_node = pdev->dev.of_node;
i2c_set_adapdata(&i2c->adap, i2c);
platform_set_drvdata(pdev, i2c);
- result = i2c_add_numbered_adapter(&i2c->adap);
+ result = i2c_add_adapter(&i2c->adap);
if (result < 0) {
dev_err(i2c->dev, "failed to add adapter\n");
goto fail_add;
}
-
dev_info(i2c->dev, "version %s\n", DRV_VERSION);
- return result;
+ of_i2c_register_devices(&i2c->adap);
+
+ return 0;
fail_add:
platform_set_drvdata(pdev, NULL);
free_irq(i2c->irq, i2c);
fail_irq:
iounmap(i2c->twsi_base);
- release_mem_region(i2c->twsi_phys, i2c->regsize);
-fail_region:
+
kfree(i2c);
out:
return result;
@@ -615,17 +602,25 @@ static int __devexit octeon_i2c_remove(struct platform_device *pdev)
platform_set_drvdata(pdev, NULL);
free_irq(i2c->irq, i2c);
iounmap(i2c->twsi_base);
- release_mem_region(i2c->twsi_phys, i2c->regsize);
kfree(i2c);
return 0;
};
-static struct platform_driver octeon_i2c_driver = {
+static struct of_device_id octeon_i2c_match[] = {
+ {
+ .compatible = "octeon,twsi",
+ },
+ {},
+};
+MODULE_DEVICE_TABLE(of, octeon_i2c_match);
+
+static struct of_platform_driver octeon_i2c_driver = {
.probe = octeon_i2c_probe,
.remove = __devexit_p(octeon_i2c_remove),
.driver = {
.owner = THIS_MODULE,
.name = DRV_NAME,
+ .of_match_table = octeon_i2c_match,
},
};
@@ -633,20 +628,19 @@ static int __init octeon_i2c_init(void)
{
int rv;
- rv = platform_driver_register(&octeon_i2c_driver);
+ rv = of_register_platform_driver(&octeon_i2c_driver);
return rv;
}
static void __exit octeon_i2c_exit(void)
{
- platform_driver_unregister(&octeon_i2c_driver);
+ of_unregister_platform_driver(&octeon_i2c_driver);
}
MODULE_AUTHOR("Michael Lawnick <[email protected]>");
MODULE_DESCRIPTION("I2C-Bus adapter for Cavium OCTEON processors");
MODULE_LICENSE("GPL");
MODULE_VERSION(DRV_VERSION);
-MODULE_ALIAS("platform:" DRV_NAME);
module_init(octeon_i2c_init);
module_exit(octeon_i2c_exit);
--
1.7.2.3
Get the MDIO bus controller addresses from the device tree.
Signed-off-by: David Daney <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
---
arch/mips/cavium-octeon/octeon-platform.c | 30 ------------
drivers/net/phy/mdio-octeon.c | 73 +++++++++++++++++------------
2 files changed, 43 insertions(+), 60 deletions(-)
diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
index f148324..a33dcf9 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -166,36 +166,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)
{
diff --git a/drivers/net/phy/mdio-octeon.c b/drivers/net/phy/mdio-octeon.c
index bd12ba9..b04c18c 100644
--- a/drivers/net/phy/mdio-octeon.c
+++ b/drivers/net/phy/mdio-octeon.c
@@ -6,10 +6,14 @@
* Copyright (C) 2009 Cavium Networks
*/
-#include <linux/gfp.h>
-#include <linux/init.h>
-#include <linux/module.h>
#include <linux/platform_device.h>
+#include <linux/of_platform.h>
+#include <linux/of_address.h>
+#include <linux/of_mdio.h>
+#include <linux/delay.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/gfp.h>
#include <linux/phy.h>
#include <asm/octeon/octeon.h>
@@ -18,9 +22,15 @@
#define DRV_VERSION "1.0"
#define DRV_DESCRIPTION "Cavium Networks Octeon SMI/MDIO driver"
+#define SMI_CMD 0x0
+#define SMI_WR_DAT 0x8
+#define SMI_RD_DAT 0x10
+#define SMI_CLK 0x18
+#define SMI_EN 0x20
+
struct octeon_mdiobus {
struct mii_bus *mii_bus;
- int unit;
+ u64 register_base;
int phy_irq[PHY_MAX_ADDR];
};
@@ -35,15 +45,15 @@ static int octeon_mdiobus_read(struct mii_bus *bus, int phy_id, int regnum)
smi_cmd.s.phy_op = 1; /* MDIO_CLAUSE_22_READ */
smi_cmd.s.phy_adr = phy_id;
smi_cmd.s.reg_adr = regnum;
- cvmx_write_csr(CVMX_SMIX_CMD(p->unit), smi_cmd.u64);
+ cvmx_write_csr(p->register_base + SMI_CMD, smi_cmd.u64);
do {
/*
* Wait 1000 clocks so we don't saturate the RSL bus
* doing reads.
*/
- cvmx_wait(1000);
- smi_rd.u64 = cvmx_read_csr(CVMX_SMIX_RD_DAT(p->unit));
+ __delay(1000);
+ smi_rd.u64 = cvmx_read_csr(p->register_base + SMI_RD_DAT);
} while (smi_rd.s.pending && --timeout);
if (smi_rd.s.val)
@@ -62,21 +72,21 @@ static int octeon_mdiobus_write(struct mii_bus *bus, int phy_id,
smi_wr.u64 = 0;
smi_wr.s.dat = val;
- cvmx_write_csr(CVMX_SMIX_WR_DAT(p->unit), smi_wr.u64);
+ cvmx_write_csr(p->register_base + SMI_WR_DAT, smi_wr.u64);
smi_cmd.u64 = 0;
smi_cmd.s.phy_op = 0; /* MDIO_CLAUSE_22_WRITE */
smi_cmd.s.phy_adr = phy_id;
smi_cmd.s.reg_adr = regnum;
- cvmx_write_csr(CVMX_SMIX_CMD(p->unit), smi_cmd.u64);
+ cvmx_write_csr(p->register_base + SMI_CMD, smi_cmd.u64);
do {
/*
* Wait 1000 clocks so we don't saturate the RSL bus
* doing reads.
*/
- cvmx_wait(1000);
- smi_wr.u64 = cvmx_read_csr(CVMX_SMIX_WR_DAT(p->unit));
+ __delay(1000);
+ smi_wr.u64 = cvmx_read_csr(p->register_base + SMI_WR_DAT);
} while (smi_wr.s.pending && --timeout);
if (timeout <= 0)
@@ -85,11 +95,11 @@ static int octeon_mdiobus_write(struct mii_bus *bus, int phy_id,
return 0;
}
-static int __devinit octeon_mdiobus_probe(struct platform_device *pdev)
+static int __devinit octeon_mdiobus_probe(struct platform_device *pdev,
+ const struct of_device_id *match)
{
struct octeon_mdiobus *bus;
union cvmx_smix_en smi_en;
- int i;
int err = -ENOENT;
bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL);
@@ -97,8 +107,7 @@ static int __devinit octeon_mdiobus_probe(struct platform_device *pdev)
return -ENOMEM;
/* The platform_device id is our unit number. */
- bus->unit = pdev->id;
-
+ bus->register_base = (u64)of_iomap(pdev->dev.of_node, 0);
bus->mii_bus = mdiobus_alloc();
if (!bus->mii_bus)
@@ -106,19 +115,13 @@ static int __devinit octeon_mdiobus_probe(struct platform_device *pdev)
smi_en.u64 = 0;
smi_en.s.en = 1;
- cvmx_write_csr(CVMX_SMIX_EN(bus->unit), smi_en.u64);
+ cvmx_write_csr(bus->register_base + SMI_EN, smi_en.u64);
- /*
- * Standard Octeon evaluation boards don't support phy
- * interrupts, we need to poll.
- */
- for (i = 0; i < PHY_MAX_ADDR; i++)
- bus->phy_irq[i] = PHY_POLL;
bus->mii_bus->priv = bus;
bus->mii_bus->irq = bus->phy_irq;
bus->mii_bus->name = "mdio-octeon";
- snprintf(bus->mii_bus->id, MII_BUS_ID_SIZE, "%x", bus->unit);
+ snprintf(bus->mii_bus->id, MII_BUS_ID_SIZE, "%llx", bus->register_base);
bus->mii_bus->parent = &pdev->dev;
bus->mii_bus->read = octeon_mdiobus_read;
@@ -126,7 +129,7 @@ static int __devinit octeon_mdiobus_probe(struct platform_device *pdev)
dev_set_drvdata(&pdev->dev, bus);
- err = mdiobus_register(bus->mii_bus);
+ err = of_mdiobus_register(bus->mii_bus, pdev->dev.of_node);
if (err)
goto err_register;
@@ -137,9 +140,9 @@ err_register:
mdiobus_free(bus->mii_bus);
err:
- devm_kfree(&pdev->dev, bus);
smi_en.u64 = 0;
- cvmx_write_csr(CVMX_SMIX_EN(bus->unit), smi_en.u64);
+ cvmx_write_csr(bus->register_base + SMI_EN, smi_en.u64);
+ devm_kfree(&pdev->dev, bus);
return err;
}
@@ -153,14 +156,24 @@ static int __devexit octeon_mdiobus_remove(struct platform_device *pdev)
mdiobus_unregister(bus->mii_bus);
mdiobus_free(bus->mii_bus);
smi_en.u64 = 0;
- cvmx_write_csr(CVMX_SMIX_EN(bus->unit), smi_en.u64);
+ cvmx_write_csr(bus->register_base + SMI_EN, smi_en.u64);
+ devm_kfree(&pdev->dev, bus);
return 0;
}
-static struct platform_driver octeon_mdiobus_driver = {
+static struct of_device_id octeon_mdiobus_match[] = {
+ {
+ .compatible = "octeon,mdio",
+ },
+ {},
+};
+MODULE_DEVICE_TABLE(of, octeon_mdiobus_match);
+
+static struct of_platform_driver octeon_mdiobus_driver = {
.driver = {
.name = "mdio-octeon",
.owner = THIS_MODULE,
+ .of_match_table = octeon_mdiobus_match,
},
.probe = octeon_mdiobus_probe,
.remove = __devexit_p(octeon_mdiobus_remove),
@@ -174,12 +187,12 @@ EXPORT_SYMBOL(octeon_mdiobus_force_mod_depencency);
static int __init octeon_mdiobus_mod_init(void)
{
- return platform_driver_register(&octeon_mdiobus_driver);
+ return of_register_platform_driver(&octeon_mdiobus_driver);
}
static void __exit octeon_mdiobus_mod_exit(void)
{
- platform_driver_unregister(&octeon_mdiobus_driver);
+ of_unregister_platform_driver(&octeon_mdiobus_driver);
}
module_init(octeon_mdiobus_mod_init);
--
1.7.2.3
Signed-off-by: David Daney <[email protected]>
---
arch/mips/cavium-octeon/.gitignore | 2 +
arch/mips/cavium-octeon/Makefile | 13 ++
arch/mips/cavium-octeon/octeon_3xxx.dts | 314 +++++++++++++++++++++++++++++++
arch/mips/cavium-octeon/octeon_68xx.dts | 99 ++++++++++
4 files changed, 428 insertions(+), 0 deletions(-)
create mode 100644 arch/mips/cavium-octeon/.gitignore
create mode 100644 arch/mips/cavium-octeon/octeon_3xxx.dts
create mode 100644 arch/mips/cavium-octeon/octeon_68xx.dts
diff --git a/arch/mips/cavium-octeon/.gitignore b/arch/mips/cavium-octeon/.gitignore
new file mode 100644
index 0000000..39c9686
--- /dev/null
+++ b/arch/mips/cavium-octeon/.gitignore
@@ -0,0 +1,2 @@
+*.dtb.S
+*.dtb
diff --git a/arch/mips/cavium-octeon/Makefile b/arch/mips/cavium-octeon/Makefile
index 19eb043..5e25dce 100644
--- a/arch/mips/cavium-octeon/Makefile
+++ b/arch/mips/cavium-octeon/Makefile
@@ -15,3 +15,16 @@ obj-y += octeon-memcpy.o
obj-y += executive/
obj-$(CONFIG_SMP) += smp.o
+
+DTS_FILES = octeon_3xxx.dts octeon_68xx.dts
+DTB_FILES = $(patsubst %.dts, %.dtb, $(DTS_FILES))
+
+obj-y += $(patsubst %.dts, %.dtb.o, $(DTS_FILES))
+
+$(obj)/%.dtb: $(src)/%.dts
+ $(call cmd,dtc)
+
+# Let's keep the .dtb files around in case we want to look at them.
+.SECONDARY: $(addprefix $(obj)/, $(DTB_FILES))
+
+clean-files += $(DTB_FILES) $(patsubst %.dtb, %.dtb.S, $(DTB_FILES))
diff --git a/arch/mips/cavium-octeon/octeon_3xxx.dts b/arch/mips/cavium-octeon/octeon_3xxx.dts
new file mode 100644
index 0000000..ad0feaa
--- /dev/null
+++ b/arch/mips/cavium-octeon/octeon_3xxx.dts
@@ -0,0 +1,314 @@
+/dts-v1/;
+/* OCTEON 3XXX, 5XXX, 63XX device tree skeleton. */
+/ {
+ model = "OCTEON";
+ compatible = "octeon,octeon";
+ #address-cells = <2>;
+ #size-cells = <2>;
+
+ soc@0 {
+ device_type = "soc";
+ compatible = "simple-bus";
+ #address-cells = <2>;
+ #size-cells = <2>;
+ ranges; /* Direct mapping */
+
+ ciu: ciu-3xxx@1070000000000 {
+ compatible = "octeon,ciu-3xxx";
+ interrupt-controller;
+ #address-cells = <0>;
+ #interrupt-cells = <2>;
+ reg = <0x10700 0x00000000 0x0 0x7000>;
+ };
+
+ /* SMI0 */
+ mdio0: mdio@1180000001800 {
+ compatible = "octeon,mdio";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x11800 0x00001800 0x0 0x40>;
+ device_type = "mdio";
+
+ phy0: ethernet-phy@0 {
+ reg = <0>;
+ };
+
+ phy1: ethernet-phy@1 {
+ reg = <1>;
+ };
+
+ phy2: ethernet-phy@2 {
+ reg = <2>;
+ marvell,reg-init = <3 0x10 0 0x5777>,
+ <3 0x11 0 0x00aa>,
+ <3 0x12 0 0x4105>,
+ <3 0x13 0 0x0a60>;
+ };
+ phy3: ethernet-phy@3 {
+ reg = <3>;
+ marvell,reg-init = <3 0x10 0 0x5777>,
+ <3 0x11 0 0x00aa>,
+ <3 0x12 0 0x4105>,
+ <3 0x13 0 0x0a60>;
+ };
+ phy4: ethernet-phy@4 {
+ reg = <4>;
+ marvell,reg-init = <3 0x10 0 0x5777>,
+ <3 0x11 0 0x00aa>,
+ <3 0x12 0 0x4105>,
+ <3 0x13 0 0x0a60>;
+ };
+ phy5: ethernet-phy@5 {
+ reg = <5>;
+ marvell,reg-init = <3 0x10 0 0x5777>,
+ <3 0x11 0 0x00aa>,
+ <3 0x12 0 0x4105>,
+ <3 0x13 0 0x0a60>;
+ };
+
+ phy6: ethernet-phy@6 {
+ reg = <6>;
+ marvell,reg-init = <3 0x10 0 0x5777>,
+ <3 0x11 0 0x00aa>,
+ <3 0x12 0 0x4105>,
+ <3 0x13 0 0x0a60>;
+ };
+ phy7: ethernet-phy@7 {
+ reg = <7>;
+ marvell,reg-init = <3 0x10 0 0x5777>,
+ <3 0x11 0 0x00aa>,
+ <3 0x12 0 0x4105>,
+ <3 0x13 0 0x0a60>;
+ };
+ phy8: ethernet-phy@8 {
+ reg = <8>;
+ marvell,reg-init = <3 0x10 0 0x5777>,
+ <3 0x11 0 0x00aa>,
+ <3 0x12 0 0x4105>,
+ <3 0x13 0 0x0a60>;
+ };
+ phy9: ethernet-phy@9 {
+ reg = <9>;
+ marvell,reg-init = <3 0x10 0 0x5777>,
+ <3 0x11 0 0x00aa>,
+ <3 0x12 0 0x4105>,
+ <3 0x13 0 0x0a60>;
+ };
+ };
+
+ /* SMI1 */
+ mdio1: mdio@1180000001900 {
+ compatible = "octeon,mdio";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x11800 0x00001900 0x0 0x40>;
+ device_type = "mdio";
+ };
+
+ mgmt0: ethernet@1070000100000 {
+ compatible = "octeon,mgmt";
+ device_type = "network";
+ model = "mgmt";
+ reg = <0x10700 0x00100000 0x0 0x100>, /* MIX */
+ <0x11800 0xE0000000 0x0 0x300>, /* AGL */
+ <0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */
+ <0x11800 0xE0002000 0x0 0x8>; /* AGL_PRT_CTL */
+ unit-number = <0>;
+ interrupt-parent = <&ciu>;
+ interrupts = <0 62>, <1 46>;
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ phy-handle = <&phy0>;
+ };
+
+ mgmt1: ethernet@1070000100800 {
+ compatible = "octeon,mgmt";
+ device_type = "network";
+ model = "mgmt";
+ reg = <0x10700 0x00100800 0x0 0x100>, /* MIX */
+ <0x11800 0xE0000800 0x0 0x300>, /* AGL */
+ <0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */
+ <0x11800 0xE0002008 0x0 0x8>; /* AGL_PRT_CTL */
+ unit-number = <1>;
+ interrupt-parent = <&ciu>;
+ interrupts = <1 18>, < 1 46>;
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ phy-handle = <&phy1>;
+ };
+
+ pip: pip@11800a0000000 {
+ compatible = "octeon,pip";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x11800 0xa0000000 0x0 0x2000>;
+
+ interface@0 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0>; /* interface */
+
+ ethernet@0 {
+ device_type = "network";
+ model = "pip";
+ reg = <0x0>; /* Port */
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ phy-handle = <&phy2>;
+ };
+ ethernet@1 {
+ device_type = "network";
+ model = "pip";
+ reg = <0x1>; /* Port */
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ phy-handle = <&phy3>;
+ };
+ ethernet@2 {
+ device_type = "network";
+ model = "pip";
+ reg = <0x2>; /* Port */
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ phy-handle = <&phy4>;
+ };
+ ethernet@3 {
+ device_type = "network";
+ model = "pip";
+ reg = <0x3>; /* Port */
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ phy-handle = <&phy5>;
+ };
+ };
+
+ interface@1 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <1>; /* interface */
+
+ ethernet@0 {
+ device_type = "network";
+ model = "pip";
+ reg = <0x0>; /* Port */
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ phy-handle = <&phy6>;
+ };
+ ethernet@1 {
+ device_type = "network";
+ model = "pip";
+ reg = <0x1>; /* Port */
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ phy-handle = <&phy7>;
+ };
+ ethernet@2 {
+ device_type = "network";
+ model = "pip";
+ reg = <0x2>; /* Port */
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ phy-handle = <&phy8>;
+ };
+ ethernet@3 {
+ device_type = "network";
+ model = "pip";
+ reg = <0x3>; /* Port */
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ phy-handle = <&phy9>;
+ };
+ };
+
+ interface@2 { /* DPI interface. */
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <2>; /* interface */
+
+ ethernet@0 {
+ device_type = "network";
+ model = "pip";
+ reg = <0x0>; /* Port */
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ };
+ ethernet@1 {
+ device_type = "network";
+ model = "pip";
+ reg = <0x1>; /* Port */
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ };
+ ethernet@2 {
+ device_type = "network";
+ model = "pip";
+ reg = <0x2>; /* Port */
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ };
+ ethernet@3 {
+ device_type = "network";
+ model = "pip";
+ reg = <0x3>; /* Port */
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ };
+ };
+
+ interface@3 { /* Loop interface. */
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <3>; /* interface */
+
+ ethernet@0 {
+ device_type = "network";
+ model = "pip";
+ reg = <0x0>; /* Port */
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ };
+ ethernet@1 {
+ device_type = "network";
+ model = "pip";
+ reg = <0x1>; /* Port */
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ };
+ ethernet@2 {
+ device_type = "network";
+ model = "pip";
+ reg = <0x2>; /* Port */
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ };
+ ethernet@3 {
+ device_type = "network";
+ model = "pip";
+ reg = <0x3>; /* Port */
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ };
+ };
+ };
+
+ /* TWSI 0 */
+ i2c0: i2c@1180000001000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "octeon,twsi";
+ reg = <0x11800 0x00001000 0x0 0x200>;
+ interrupt-parent = <&ciu>;
+ interrupts = <0 45>;
+ clock-rate = <100000>;
+
+ rtc@68 {
+ compatible = "dallas,ds1337";
+ reg = <0x68>;
+ };
+ };
+
+ /* TWSI 1 */
+ i2c1: i2c@1180000001200 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "octeon,twsi";
+ reg = <0x11800 0x00001200 0x0 0x200>;
+ interrupt-parent = <&ciu>;
+ interrupts = <0 59>;
+ clock-rate = <100000>;
+ };
+ };
+
+ aliases {
+ ethernet-mgmt0 = &mgmt0;
+ ethernet-mgmt1 = &mgmt1;
+ pip = &pip;
+ mdio0 = &mdio0;
+ mdio1 = &mdio1;
+ i2c0 = &i2c0;
+ i2c1 = &i2c1;
+ };
+};
diff --git a/arch/mips/cavium-octeon/octeon_68xx.dts b/arch/mips/cavium-octeon/octeon_68xx.dts
new file mode 100644
index 0000000..31dbd39
--- /dev/null
+++ b/arch/mips/cavium-octeon/octeon_68xx.dts
@@ -0,0 +1,99 @@
+/dts-v1/;
+/* OCTEON 68XX device tree skeleton. */
+/ {
+ model = "OCTEON";
+ compatible = "octeon,octeon";
+ #address-cells = <2>;
+ #size-cells = <2>;
+
+ soc@0 {
+ device_type = "soc";
+ compatible = "simple-bus";
+ #address-cells = <2>;
+ #size-cells = <2>;
+ ranges; /* Direct mapping */
+
+ ciu: ciu-68xx@1070100000000 {
+ compatible = "octeon,ciu-68xx";
+ interrupt-controller;
+ #address-cells = <0>;
+ #interrupt-cells = <2>;
+ reg = <0x10701 0x00000000 0x0 0x4000000>;
+ };
+
+ /* SMI0 */
+ mdio0: mdio@1180000003800 {
+ compatible = "octeon,mdio";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x11800 0x00003800 0x0 0x40>;
+ device_type = "mdio";
+
+ phy0: ethernet-phy@0 {
+ reg = <0>;
+ device_type = "ethernet-phy";
+ };
+
+ phy1: ethernet-phy@1 {
+ reg = <1>;
+ device_type = "ethernet-phy";
+ };
+
+ phy3: ethernet-phy@3 {
+ reg = <3>;
+ device_type = "ethernet-phy";
+ };
+ };
+
+ /* SMI1 */
+ mdio1: mdio@1180000003880 {
+ compatible = "octeon,mdio";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x11800 0x00003880 0x0 0x40>;
+ device_type = "mdio";
+ };
+
+ /* SMI2 */
+ mdio2: mdio@1180000003900 {
+ compatible = "octeon,mdio";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x11800 0x00003900 0x0 0x40>;
+ device_type = "mdio";
+ };
+
+ /* SMI3 */
+ mdio3: mdio@1180000003980 {
+ compatible = "octeon,mdio";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x11800 0x00003980 0x0 0x40>;
+ device_type = "mdio";
+ };
+
+ mgmt0: ethernet@1070000100000 {
+ compatible = "octeon,mgmt";
+ device_type = "network";
+ model = "mgmt";
+ /* Register banks: MIX AGL AGL_SHARED AGL_PRT_CTL*/
+ reg = <0x10700 0x00100000 0x0 0x100>, /* MIX */
+ <0x11800 0xE0000000 0x0 0x300>, /* AGL */
+ <0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */
+ <0x11800 0xE0002000 0x0 0x8>; /* AGL_PRT_CTL */
+ unit-number = <0>;
+ interrupt-parent = <&ciu>;
+ interrupts = <6 40>, <6 32>;
+ local-mac-address = [ 00 00 00 00 00 00 ];
+ phy-handle = <&phy0>;
+ };
+
+ };
+ aliases {
+ ethernet-mgmt0 = &mgmt0;
+ mdio0 = &mdio0;
+ mdio1 = &mdio1;
+ mdio2 = &mdio2;
+ mdio3 = &mdio3;
+ };
+};
--
1.7.2.3
This code is not common enough to be in a shared file. It is also not
used by any existing boards, so just remove it.
Signed-off-by: David Daney <[email protected]>
---
arch/mips/kernel/prom.c | 49 -----------------------------------------------
1 files changed, 0 insertions(+), 49 deletions(-)
diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c
index a19811e9..a07b6f1 100644
--- a/arch/mips/kernel/prom.c
+++ b/arch/mips/kernel/prom.c
@@ -59,52 +59,3 @@ void __init early_init_dt_setup_initrd_arch(unsigned long start,
initrd_below_start_ok = 1;
}
#endif
-
-/*
- * irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq#
- *
- * Currently the mapping mechanism is trivial; simple flat hwirq numbers are
- * mapped 1:1 onto Linux irq numbers. Cascaded irq controllers are not
- * supported.
- */
-unsigned int irq_create_of_mapping(struct device_node *controller,
- const u32 *intspec, unsigned int intsize)
-{
- return intspec[0];
-}
-EXPORT_SYMBOL_GPL(irq_create_of_mapping);
-
-void __init early_init_devtree(void *params)
-{
- /* Setup flat device-tree pointer */
- initial_boot_params = params;
-
- /* Retrieve various informations from the /chosen node of the
- * device-tree, including the platform type, initrd location and
- * size, and more ...
- */
- of_scan_flat_dt(early_init_dt_scan_chosen, NULL);
-
- /* Scan memory nodes */
- of_scan_flat_dt(early_init_dt_scan_root, NULL);
- of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL);
-}
-
-void __init device_tree_init(void)
-{
- unsigned long base, size;
-
- if (!initial_boot_params)
- return;
-
- base = virt_to_phys((void *)initial_boot_params);
- size = be32_to_cpu(initial_boot_params->totalsize);
-
- /* Before we do anything, lets reserve the dt blob */
- reserve_mem_mach(base, size);
-
- unflatten_device_tree();
-
- /* free the space reserved for the dt blob */
- free_mem_mach(base, size);
-}
--
1.7.2.3
Signed-off-by: David Daney <[email protected]>
---
.../cavium-octeon/executive/cvmx-helper-sgmii.c | 6 +-
.../mips/cavium-octeon/executive/cvmx-helper-spi.c | 10 ++
.../cavium-octeon/executive/cvmx-helper-xaui.c | 22 +++--
arch/mips/cavium-octeon/executive/cvmx-helper.c | 93 ++++++++++++++++---
arch/mips/include/asm/octeon/cvmx-helper-loop.h | 1 +
arch/mips/include/asm/octeon/cvmx-helper-npi.h | 1 +
arch/mips/include/asm/octeon/cvmx-helper-rgmii.h | 1 +
arch/mips/include/asm/octeon/cvmx-helper-sgmii.h | 1 +
arch/mips/include/asm/octeon/cvmx-helper-spi.h | 1 +
arch/mips/include/asm/octeon/cvmx-helper-xaui.h | 1 +
arch/mips/include/asm/octeon/cvmx-helper.h | 1 +
11 files changed, 114 insertions(+), 24 deletions(-)
diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c b/arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c
index 464347f..0c0bf5d 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c
@@ -326,6 +326,10 @@ static int __cvmx_helper_sgmii_hardware_init(int interface, int num_ports)
return 0;
}
+int __cvmx_helper_sgmii_enumerate(int interface)
+{
+ return 4;
+}
/**
* Probe a SGMII interface and determine the number of ports
* connected to it. The SGMII interface should still be down after
@@ -347,7 +351,7 @@ int __cvmx_helper_sgmii_probe(int interface)
mode.u64 = cvmx_read_csr(CVMX_GMXX_INF_MODE(interface));
mode.s.en = 1;
cvmx_write_csr(CVMX_GMXX_INF_MODE(interface), mode.u64);
- return 4;
+ return __cvmx_helper_sgmii_enumerate(interface);
}
/**
diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper-spi.c b/arch/mips/cavium-octeon/executive/cvmx-helper-spi.c
index 02a4442..2830e4b 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-helper-spi.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-spi.c
@@ -51,6 +51,16 @@ void __cvmx_interrupt_stxx_int_msk_enable(int index);
#define CVMX_HELPER_SPI_TIMEOUT 10
#endif
+int __cvmx_helper_spi_enumerate(int interface)
+{
+ if ((cvmx_sysinfo_get()->board_type != CVMX_BOARD_TYPE_SIM) &&
+ cvmx_spi4000_is_present(interface)) {
+ return 10;
+ } else {
+ return 16;
+ }
+}
+
/**
* Probe a SPI interface and determine the number of ports
* connected to it. The SPI interface should still be down after
diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper-xaui.c b/arch/mips/cavium-octeon/executive/cvmx-helper-xaui.c
index 667a8e3..1723248e 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-helper-xaui.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-xaui.c
@@ -44,6 +44,19 @@
void __cvmx_interrupt_gmxx_enable(int interface);
void __cvmx_interrupt_pcsx_intx_en_reg_enable(int index, int block);
void __cvmx_interrupt_pcsxx_int_en_reg_enable(int index);
+
+int __cvmx_helper_xaui_enumerate(int interface)
+{
+ union cvmx_gmxx_hg2_control gmx_hg2_control;
+
+ /* If HiGig2 is enabled return 16 ports, otherwise return 1 port */
+ gmx_hg2_control.u64 = cvmx_read_csr(CVMX_GMXX_HG2_CONTROL(interface));
+ if (gmx_hg2_control.s.hg2tx_en)
+ return 16;
+ else
+ return 1;
+}
+
/**
* Probe a XAUI interface and determine the number of ports
* connected to it. The XAUI interface should still be down
@@ -56,7 +69,6 @@ void __cvmx_interrupt_pcsxx_int_en_reg_enable(int index);
int __cvmx_helper_xaui_probe(int interface)
{
int i;
- union cvmx_gmxx_hg2_control gmx_hg2_control;
union cvmx_gmxx_inf_mode mode;
/*
@@ -90,13 +102,7 @@ int __cvmx_helper_xaui_probe(int interface)
pko_mem_port_ptrs.s.pid = interface * 16 + i;
cvmx_write_csr(CVMX_PKO_MEM_PORT_PTRS, pko_mem_port_ptrs.u64);
}
-
- /* If HiGig2 is enabled return 16 ports, otherwise return 1 port */
- gmx_hg2_control.u64 = cvmx_read_csr(CVMX_GMXX_HG2_CONTROL(interface));
- if (gmx_hg2_control.s.hg2tx_en)
- return 16;
- else
- return 1;
+ return __cvmx_helper_xaui_enumerate(interface);
}
/**
diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper.c b/arch/mips/cavium-octeon/executive/cvmx-helper.c
index 6238a22..bea6ab6 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-helper.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper.c
@@ -234,21 +234,16 @@ static int __cvmx_helper_port_setup_ipd(int ipd_port)
}
/**
- * This function probes an interface to determine the actual
- * number of hardware ports connected to it. It doesn't setup the
- * ports or enable them. The main goal here is to set the global
- * interface_port_count[interface] correctly. Hardware setup of the
- * ports will be performed later.
+ * This function sets the interface_port_count[interface] correctly,
+ * without modifying any hardware configuration. Hardware setup of
+ * the ports will be performed later.
*
* @interface: Interface to probe
*
* Returns Zero on success, negative on failure
*/
-int cvmx_helper_interface_probe(int interface)
+int cvmx_helper_interface_enumerate(int interface)
{
- /* At this stage in the game we don't want packets to be moving yet.
- The following probe calls should perform hardware setup
- needed to determine port counts. Receive must still be disabled */
switch (cvmx_helper_interface_get_mode(interface)) {
/* These types don't support ports to IPD/PKO */
case CVMX_HELPER_INTERFACE_MODE_DISABLED:
@@ -258,7 +253,7 @@ int cvmx_helper_interface_probe(int interface)
/* XAUI is a single high speed port */
case CVMX_HELPER_INTERFACE_MODE_XAUI:
interface_port_count[interface] =
- __cvmx_helper_xaui_probe(interface);
+ __cvmx_helper_xaui_enumerate(interface);
break;
/*
* RGMII/GMII/MII are all treated about the same. Most
@@ -267,7 +262,7 @@ int cvmx_helper_interface_probe(int interface)
case CVMX_HELPER_INTERFACE_MODE_RGMII:
case CVMX_HELPER_INTERFACE_MODE_GMII:
interface_port_count[interface] =
- __cvmx_helper_rgmii_probe(interface);
+ __cvmx_helper_rgmii_enumerate(interface);
break;
/*
* SPI4 can have 1-16 ports depending on the device at
@@ -275,7 +270,7 @@ int cvmx_helper_interface_probe(int interface)
*/
case CVMX_HELPER_INTERFACE_MODE_SPI:
interface_port_count[interface] =
- __cvmx_helper_spi_probe(interface);
+ __cvmx_helper_spi_enumerate(interface);
break;
/*
* SGMII can have 1-4 ports depending on how many are
@@ -284,12 +279,12 @@ int cvmx_helper_interface_probe(int interface)
case CVMX_HELPER_INTERFACE_MODE_SGMII:
case CVMX_HELPER_INTERFACE_MODE_PICMG:
interface_port_count[interface] =
- __cvmx_helper_sgmii_probe(interface);
+ __cvmx_helper_sgmii_enumerate(interface);
break;
/* PCI target Network Packet Interface */
case CVMX_HELPER_INTERFACE_MODE_NPI:
interface_port_count[interface] =
- __cvmx_helper_npi_probe(interface);
+ __cvmx_helper_npi_enumerate(interface);
break;
/*
* Special loopback only ports. These are not the same
@@ -297,7 +292,7 @@ int cvmx_helper_interface_probe(int interface)
*/
case CVMX_HELPER_INTERFACE_MODE_LOOP:
interface_port_count[interface] =
- __cvmx_helper_loop_probe(interface);
+ __cvmx_helper_loop_enumerate(interface);
break;
}
@@ -313,6 +308,74 @@ int cvmx_helper_interface_probe(int interface)
}
/**
+ * This function probes an interface to determine the actual
+ * number of hardware ports connected to it. It doesn't setup the
+ * ports or enable them. The main goal here is to set the global
+ * interface_port_count[interface] correctly. Hardware setup of the
+ * ports will be performed later.
+ *
+ * @interface: Interface to probe
+ *
+ * Returns Zero on success, negative on failure
+ */
+int cvmx_helper_interface_probe(int interface)
+{
+ cvmx_helper_interface_enumerate(interface);
+ /* At this stage in the game we don't want packets to be moving yet.
+ The following probe calls should perform hardware setup
+ needed to determine port counts. Receive must still be disabled */
+ switch (cvmx_helper_interface_get_mode(interface)) {
+ /* These types don't support ports to IPD/PKO */
+ case CVMX_HELPER_INTERFACE_MODE_DISABLED:
+ case CVMX_HELPER_INTERFACE_MODE_PCIE:
+ break;
+ /* XAUI is a single high speed port */
+ case CVMX_HELPER_INTERFACE_MODE_XAUI:
+ __cvmx_helper_xaui_probe(interface);
+ break;
+ /*
+ * RGMII/GMII/MII are all treated about the same. Most
+ * functions refer to these ports as RGMII.
+ */
+ case CVMX_HELPER_INTERFACE_MODE_RGMII:
+ case CVMX_HELPER_INTERFACE_MODE_GMII:
+ __cvmx_helper_rgmii_probe(interface);
+ break;
+ /*
+ * SPI4 can have 1-16 ports depending on the device at
+ * the other end.
+ */
+ case CVMX_HELPER_INTERFACE_MODE_SPI:
+ __cvmx_helper_spi_probe(interface);
+ break;
+ /*
+ * SGMII can have 1-4 ports depending on how many are
+ * hooked up.
+ */
+ case CVMX_HELPER_INTERFACE_MODE_SGMII:
+ case CVMX_HELPER_INTERFACE_MODE_PICMG:
+ __cvmx_helper_sgmii_probe(interface);
+ break;
+ /* PCI target Network Packet Interface */
+ case CVMX_HELPER_INTERFACE_MODE_NPI:
+ __cvmx_helper_npi_probe(interface);
+ break;
+ /*
+ * Special loopback only ports. These are not the same
+ * as other ports in loopback mode.
+ */
+ case CVMX_HELPER_INTERFACE_MODE_LOOP:
+ __cvmx_helper_loop_probe(interface);
+ break;
+ }
+
+ /* Make sure all global variables propagate to other cores */
+ CVMX_SYNCWS;
+
+ return 0;
+}
+
+/**
* Setup the IPD/PIP for the ports on an interface. Packet
* classification and tagging are set for every port on the
* interface. The number of ports on the interface must already
diff --git a/arch/mips/include/asm/octeon/cvmx-helper-loop.h b/arch/mips/include/asm/octeon/cvmx-helper-loop.h
index e646a6c..0a2488e 100644
--- a/arch/mips/include/asm/octeon/cvmx-helper-loop.h
+++ b/arch/mips/include/asm/octeon/cvmx-helper-loop.h
@@ -44,6 +44,7 @@
* Returns Number of ports on the interface. Zero to disable.
*/
extern int __cvmx_helper_loop_probe(int interface);
+static inline int __cvmx_helper_loop_enumerate(int interface) {return 4;}
/**
* Bringup and enable a LOOP interface. After this call packet
diff --git a/arch/mips/include/asm/octeon/cvmx-helper-npi.h b/arch/mips/include/asm/octeon/cvmx-helper-npi.h
index 908e7b0..8df4c7f 100644
--- a/arch/mips/include/asm/octeon/cvmx-helper-npi.h
+++ b/arch/mips/include/asm/octeon/cvmx-helper-npi.h
@@ -45,6 +45,7 @@
* Returns Number of ports on the interface. Zero to disable.
*/
extern int __cvmx_helper_npi_probe(int interface);
+#define __cvmx_helper_npi_enumerate __cvmx_helper_npi_probe
/**
* Bringup and enable a NPI interface. After this call packet
diff --git a/arch/mips/include/asm/octeon/cvmx-helper-rgmii.h b/arch/mips/include/asm/octeon/cvmx-helper-rgmii.h
index ea26526..78295ba 100644
--- a/arch/mips/include/asm/octeon/cvmx-helper-rgmii.h
+++ b/arch/mips/include/asm/octeon/cvmx-helper-rgmii.h
@@ -43,6 +43,7 @@
* Returns Number of RGMII/GMII/MII ports (0-4).
*/
extern int __cvmx_helper_rgmii_probe(int interface);
+#define __cvmx_helper_rgmii_enumerate __cvmx_helper_rgmii_probe
/**
* Put an RGMII interface in loopback mode. Internal packets sent
diff --git a/arch/mips/include/asm/octeon/cvmx-helper-sgmii.h b/arch/mips/include/asm/octeon/cvmx-helper-sgmii.h
index 19b48d6..9a9b6c1 100644
--- a/arch/mips/include/asm/octeon/cvmx-helper-sgmii.h
+++ b/arch/mips/include/asm/octeon/cvmx-helper-sgmii.h
@@ -45,6 +45,7 @@
* Returns Number of ports on the interface. Zero to disable.
*/
extern int __cvmx_helper_sgmii_probe(int interface);
+extern int __cvmx_helper_sgmii_enumerate(int interface);
/**
* Bringup and enable a SGMII interface. After this call packet
diff --git a/arch/mips/include/asm/octeon/cvmx-helper-spi.h b/arch/mips/include/asm/octeon/cvmx-helper-spi.h
index 69bac03..9f1c6b9 100644
--- a/arch/mips/include/asm/octeon/cvmx-helper-spi.h
+++ b/arch/mips/include/asm/octeon/cvmx-helper-spi.h
@@ -42,6 +42,7 @@
* Returns Number of ports on the interface. Zero to disable.
*/
extern int __cvmx_helper_spi_probe(int interface);
+extern int __cvmx_helper_spi_enumerate(int interface);
/**
* Bringup and enable a SPI interface. After this call packet I/O
diff --git a/arch/mips/include/asm/octeon/cvmx-helper-xaui.h b/arch/mips/include/asm/octeon/cvmx-helper-xaui.h
index 4b4db2f..f6fbc4f 100644
--- a/arch/mips/include/asm/octeon/cvmx-helper-xaui.h
+++ b/arch/mips/include/asm/octeon/cvmx-helper-xaui.h
@@ -45,6 +45,7 @@
* Returns Number of ports on the interface. Zero to disable.
*/
extern int __cvmx_helper_xaui_probe(int interface);
+extern int __cvmx_helper_xaui_enumerate(int interface);
/**
* Bringup and enable a XAUI interface. After this call packet
diff --git a/arch/mips/include/asm/octeon/cvmx-helper.h b/arch/mips/include/asm/octeon/cvmx-helper.h
index 51916f3..3169cd7 100644
--- a/arch/mips/include/asm/octeon/cvmx-helper.h
+++ b/arch/mips/include/asm/octeon/cvmx-helper.h
@@ -207,6 +207,7 @@ extern int cvmx_helper_link_set(int ipd_port,
* Returns Zero on success, negative on failure
*/
extern int cvmx_helper_interface_probe(int interface);
+extern int cvmx_helper_interface_enumerate(int interface);
/**
* Configure a port for internal and/or external loopback. Internal loopback
--
1.7.2.3
Signed-off-by: David Daney <[email protected]>
---
arch/mips/cavium-octeon/executive/Makefile | 5 +
.../mips/cavium-octeon/executive}/cvmx-cmd-queue.c | 8 +-
.../mips/cavium-octeon/executive}/cvmx-fpa.c | 0
.../cavium-octeon/executive}/cvmx-helper-board.c | 18 +--
.../cavium-octeon/executive}/cvmx-helper-fpa.c | 0
.../cavium-octeon/executive}/cvmx-helper-loop.c | 6 +-
.../cavium-octeon/executive}/cvmx-helper-npi.c | 6 +-
.../cavium-octeon/executive}/cvmx-helper-rgmii.c | 17 +-
.../cavium-octeon/executive}/cvmx-helper-sgmii.c | 12 +-
.../cavium-octeon/executive}/cvmx-helper-spi.c | 10 +-
.../cavium-octeon/executive}/cvmx-helper-util.c | 16 +-
.../cavium-octeon/executive}/cvmx-helper-xaui.c | 10 +-
.../mips/cavium-octeon/executive}/cvmx-helper.c | 27 ++--
.../executive}/cvmx-interrupt-decodes.c | 10 +-
.../cavium-octeon/executive}/cvmx-interrupt-rsl.c | 4 +-
.../mips/cavium-octeon/executive}/cvmx-pko.c | 6 +-
.../mips/cavium-octeon/executive}/cvmx-spi.c | 12 +-
.../mips/include/asm}/octeon/cvmx-address.h | 0
.../mips/include/asm}/octeon/cvmx-asxx-defs.h | 0
.../mips/include/asm}/octeon/cvmx-cmd-queue.h | 0
.../mips/include/asm}/octeon/cvmx-config.h | 0
.../mips/include/asm}/octeon/cvmx-dbg-defs.h | 0
.../mips/include/asm}/octeon/cvmx-fau.h | 0
.../mips/include/asm}/octeon/cvmx-fpa-defs.h | 0
.../mips/include/asm}/octeon/cvmx-fpa.h | 0
.../mips/include/asm}/octeon/cvmx-gmxx-defs.h | 0
.../mips/include/asm}/octeon/cvmx-helper-board.h | 0
.../mips/include/asm}/octeon/cvmx-helper-fpa.h | 0
.../mips/include/asm}/octeon/cvmx-helper-loop.h | 0
.../mips/include/asm}/octeon/cvmx-helper-npi.h | 0
.../mips/include/asm}/octeon/cvmx-helper-rgmii.h | 0
.../mips/include/asm}/octeon/cvmx-helper-sgmii.h | 0
.../mips/include/asm}/octeon/cvmx-helper-spi.h | 0
.../mips/include/asm}/octeon/cvmx-helper-util.h | 0
.../mips/include/asm}/octeon/cvmx-helper-xaui.h | 0
.../mips/include/asm}/octeon/cvmx-helper.h | 0
.../mips/include/asm}/octeon/cvmx-ipd.h | 0
.../mips/include/asm}/octeon/cvmx-mdio.h | 0
.../mips/include/asm}/octeon/cvmx-pcsx-defs.h | 0
.../mips/include/asm}/octeon/cvmx-pcsxx-defs.h | 0
.../mips/include/asm}/octeon/cvmx-pip-defs.h | 0
.../mips/include/asm}/octeon/cvmx-pip.h | 0
.../mips/include/asm}/octeon/cvmx-pko-defs.h | 0
.../mips/include/asm}/octeon/cvmx-pko.h | 0
.../mips/include/asm}/octeon/cvmx-pow.h | 0
.../mips/include/asm}/octeon/cvmx-scratch.h | 0
.../mips/include/asm}/octeon/cvmx-spi.h | 0
.../mips/include/asm}/octeon/cvmx-spxx-defs.h | 0
.../mips/include/asm}/octeon/cvmx-srxx-defs.h | 0
.../mips/include/asm}/octeon/cvmx-stxx-defs.h | 0
.../mips/include/asm}/octeon/cvmx-wqe.h | 0
drivers/staging/octeon/Makefile | 5 -
drivers/staging/octeon/cvmx-packet.h | 65 -------
drivers/staging/octeon/cvmx-smix-defs.h | 178 --------------------
drivers/staging/octeon/ethernet-defines.h | 2 +-
drivers/staging/octeon/ethernet-mdio.c | 4 +-
drivers/staging/octeon/ethernet-mem.c | 2 +-
drivers/staging/octeon/ethernet-rgmii.c | 4 +-
drivers/staging/octeon/ethernet-rx.c | 14 +-
drivers/staging/octeon/ethernet-rx.h | 2 +-
drivers/staging/octeon/ethernet-sgmii.c | 4 +-
drivers/staging/octeon/ethernet-spi.c | 6 +-
drivers/staging/octeon/ethernet-tx.c | 12 +-
drivers/staging/octeon/ethernet-xaui.c | 4 +-
drivers/staging/octeon/ethernet.c | 14 +-
65 files changed, 116 insertions(+), 367 deletions(-)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-cmd-queue.c (98%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-fpa.c (100%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-board.c (98%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-fpa.c (100%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-loop.c (95%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-npi.c (96%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-rgmii.c (97%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-sgmii.c (98%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-spi.c (97%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-util.c (97%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-xaui.c (98%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper.c (98%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-interrupt-decodes.c (98%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-interrupt-rsl.c (97%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-pko.c (99%)
rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-spi.c (99%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-address.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-asxx-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-cmd-queue.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-config.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-dbg-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-fau.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-fpa-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-fpa.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-gmxx-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-board.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-fpa.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-loop.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-npi.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-rgmii.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-sgmii.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-spi.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-util.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-xaui.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-ipd.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-mdio.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pcsx-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pcsxx-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pip-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pip.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pko-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pko.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pow.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-scratch.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-spi.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-spxx-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-srxx-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-stxx-defs.h (100%)
rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-wqe.h (100%)
delete mode 100644 drivers/staging/octeon/cvmx-packet.h
delete mode 100644 drivers/staging/octeon/cvmx-smix-defs.h
diff --git a/arch/mips/cavium-octeon/executive/Makefile b/arch/mips/cavium-octeon/executive/Makefile
index 7f41c5b..eec0b88 100644
--- a/arch/mips/cavium-octeon/executive/Makefile
+++ b/arch/mips/cavium-octeon/executive/Makefile
@@ -10,5 +10,10 @@
#
obj-y += cvmx-bootmem.o cvmx-l2c.o cvmx-sysinfo.o octeon-model.o
+obj-y += cvmx-pko.o cvmx-spi.o cvmx-cmd-queue.o \
+ cvmx-helper-board.o cvmx-helper.o cvmx-helper-xaui.o \
+ cvmx-helper-rgmii.o cvmx-helper-sgmii.o cvmx-helper-npi.o \
+ cvmx-helper-loop.o cvmx-helper-spi.o cvmx-helper-util.o \
+ cvmx-interrupt-decodes.o cvmx-interrupt-rsl.o
obj-$(CONFIG_CAVIUM_OCTEON_HELPER) += cvmx-helper-errata.o cvmx-helper-jtag.o
diff --git a/drivers/staging/octeon/cvmx-cmd-queue.c b/arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c
similarity index 98%
rename from drivers/staging/octeon/cvmx-cmd-queue.c
rename to arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c
index e9809d3..132bccc 100644
--- a/drivers/staging/octeon/cvmx-cmd-queue.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c
@@ -34,13 +34,13 @@
#include <asm/octeon/octeon.h>
-#include "cvmx-config.h"
-#include "cvmx-fpa.h"
-#include "cvmx-cmd-queue.h"
+#include <asm/octeon/cvmx-config.h>
+#include <asm/octeon/cvmx-fpa.h>
+#include <asm/octeon/cvmx-cmd-queue.h>
#include <asm/octeon/cvmx-npei-defs.h>
#include <asm/octeon/cvmx-pexp-defs.h>
-#include "cvmx-pko-defs.h"
+#include <asm/octeon/cvmx-pko-defs.h>
/**
* This application uses this pointer to access the global queue
diff --git a/drivers/staging/octeon/cvmx-fpa.c b/arch/mips/cavium-octeon/executive/cvmx-fpa.c
similarity index 100%
rename from drivers/staging/octeon/cvmx-fpa.c
rename to arch/mips/cavium-octeon/executive/cvmx-fpa.c
diff --git a/drivers/staging/octeon/cvmx-helper-board.c b/arch/mips/cavium-octeon/executive/cvmx-helper-board.c
similarity index 98%
rename from drivers/staging/octeon/cvmx-helper-board.c
rename to arch/mips/cavium-octeon/executive/cvmx-helper-board.c
index 57d35dc..71590a3 100644
--- a/drivers/staging/octeon/cvmx-helper-board.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-board.c
@@ -34,16 +34,16 @@
#include <asm/octeon/octeon.h>
#include <asm/octeon/cvmx-bootinfo.h>
-#include "cvmx-config.h"
+#include <asm/octeon/cvmx-config.h>
-#include "cvmx-mdio.h"
+#include <asm/octeon/cvmx-mdio.h>
-#include "cvmx-helper.h"
-#include "cvmx-helper-util.h"
-#include "cvmx-helper-board.h"
+#include <asm/octeon/cvmx-helper.h>
+#include <asm/octeon/cvmx-helper-util.h>
+#include <asm/octeon/cvmx-helper-board.h>
-#include "cvmx-gmxx-defs.h"
-#include "cvmx-asxx-defs.h"
+#include <asm/octeon/cvmx-gmxx-defs.h>
+#include <asm/octeon/cvmx-asxx-defs.h>
/**
* cvmx_override_board_link_get(int ipd_port) is a function
@@ -493,7 +493,6 @@ int cvmx_helper_board_link_set_phy(int phy_addr,
cvmx_mdio_phy_reg_control_t reg_control;
cvmx_mdio_phy_reg_status_t reg_status;
cvmx_mdio_phy_reg_autoneg_adver_t reg_autoneg_adver;
- cvmx_mdio_phy_reg_extended_status_t reg_extended_status;
cvmx_mdio_phy_reg_control_1000_t reg_control_1000;
reg_status.u16 =
@@ -508,9 +507,6 @@ int cvmx_helper_board_link_set_phy(int phy_addr,
reg_autoneg_adver.s.advert_100base_tx_full = 0;
reg_autoneg_adver.s.advert_100base_tx_half = 0;
if (reg_status.s.capable_extended_status) {
- reg_extended_status.u16 =
- cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff,
- CVMX_MDIO_PHY_REG_EXTENDED_STATUS);
reg_control_1000.u16 =
cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff,
CVMX_MDIO_PHY_REG_CONTROL_1000);
diff --git a/drivers/staging/octeon/cvmx-helper-fpa.c b/arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c
similarity index 100%
rename from drivers/staging/octeon/cvmx-helper-fpa.c
rename to arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c
diff --git a/drivers/staging/octeon/cvmx-helper-loop.c b/arch/mips/cavium-octeon/executive/cvmx-helper-loop.c
similarity index 95%
rename from drivers/staging/octeon/cvmx-helper-loop.c
rename to arch/mips/cavium-octeon/executive/cvmx-helper-loop.c
index 55a571a..bfbd461 100644
--- a/drivers/staging/octeon/cvmx-helper-loop.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-loop.c
@@ -31,10 +31,10 @@
*/
#include <asm/octeon/octeon.h>
-#include "cvmx-config.h"
+#include <asm/octeon/cvmx-config.h>
-#include "cvmx-helper.h"
-#include "cvmx-pip-defs.h"
+#include <asm/octeon/cvmx-helper.h>
+#include <asm/octeon/cvmx-pip-defs.h>
/**
* Probe a LOOP interface and determine the number of ports
diff --git a/drivers/staging/octeon/cvmx-helper-npi.c b/arch/mips/cavium-octeon/executive/cvmx-helper-npi.c
similarity index 96%
rename from drivers/staging/octeon/cvmx-helper-npi.c
rename to arch/mips/cavium-octeon/executive/cvmx-helper-npi.c
index 7388a1e..cc94cfa 100644
--- a/drivers/staging/octeon/cvmx-helper-npi.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-npi.c
@@ -31,11 +31,11 @@
*/
#include <asm/octeon/octeon.h>
-#include "cvmx-config.h"
+#include <asm/octeon/cvmx-config.h>
-#include "cvmx-helper.h"
+#include <asm/octeon/cvmx-helper.h>
-#include "cvmx-pip-defs.h"
+#include <asm/octeon/cvmx-pip-defs.h>
/**
* Probe a NPI interface and determine the number of ports
diff --git a/drivers/staging/octeon/cvmx-helper-rgmii.c b/arch/mips/cavium-octeon/executive/cvmx-helper-rgmii.c
similarity index 97%
rename from drivers/staging/octeon/cvmx-helper-rgmii.c
rename to arch/mips/cavium-octeon/executive/cvmx-helper-rgmii.c
index aa2d5d7..82b2184 100644
--- a/drivers/staging/octeon/cvmx-helper-rgmii.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-rgmii.c
@@ -31,18 +31,18 @@
*/
#include <asm/octeon/octeon.h>
-#include "cvmx-config.h"
+#include <asm/octeon/cvmx-config.h>
-#include "cvmx-mdio.h"
-#include "cvmx-pko.h"
-#include "cvmx-helper.h"
-#include "cvmx-helper-board.h"
+#include <asm/octeon/cvmx-mdio.h>
+#include <asm/octeon/cvmx-pko.h>
+#include <asm/octeon/cvmx-helper.h>
+#include <asm/octeon/cvmx-helper-board.h>
#include <asm/octeon/cvmx-npi-defs.h>
-#include "cvmx-gmxx-defs.h"
-#include "cvmx-asxx-defs.h"
-#include "cvmx-dbg-defs.h"
+#include <asm/octeon/cvmx-gmxx-defs.h>
+#include <asm/octeon/cvmx-asxx-defs.h>
+#include <asm/octeon/cvmx-dbg-defs.h>
void __cvmx_interrupt_gmxx_enable(int interface);
void __cvmx_interrupt_asxx_enable(int block);
@@ -326,6 +326,7 @@ int __cvmx_helper_rgmii_link_set(int ipd_port,
cvmx_read_csr(CVMX_ASXX_RX_PRT_EN(interface)) &
~(1 << index));
+ memset(pko_mem_queue_qos_save, 0, sizeof(pko_mem_queue_qos_save));
/* Disable all queues so that TX should become idle */
for (i = 0; i < cvmx_pko_get_num_queues(ipd_port); i++) {
int queue = cvmx_pko_get_base_queue(ipd_port) + i;
diff --git a/drivers/staging/octeon/cvmx-helper-sgmii.c b/arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c
similarity index 98%
rename from drivers/staging/octeon/cvmx-helper-sgmii.c
rename to arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c
index 6214e3b..464347f 100644
--- a/drivers/staging/octeon/cvmx-helper-sgmii.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c
@@ -32,14 +32,14 @@
#include <asm/octeon/octeon.h>
-#include "cvmx-config.h"
+#include <asm/octeon/cvmx-config.h>
-#include "cvmx-mdio.h"
-#include "cvmx-helper.h"
-#include "cvmx-helper-board.h"
+#include <asm/octeon/cvmx-mdio.h>
+#include <asm/octeon/cvmx-helper.h>
+#include <asm/octeon/cvmx-helper-board.h>
-#include "cvmx-gmxx-defs.h"
-#include "cvmx-pcsx-defs.h"
+#include <asm/octeon/cvmx-gmxx-defs.h>
+#include <asm/octeon/cvmx-pcsx-defs.h>
void __cvmx_interrupt_gmxx_enable(int interface);
void __cvmx_interrupt_pcsx_intx_en_reg_enable(int index, int block);
diff --git a/drivers/staging/octeon/cvmx-helper-spi.c b/arch/mips/cavium-octeon/executive/cvmx-helper-spi.c
similarity index 97%
rename from drivers/staging/octeon/cvmx-helper-spi.c
rename to arch/mips/cavium-octeon/executive/cvmx-helper-spi.c
index 8ba6c83..02a4442 100644
--- a/drivers/staging/octeon/cvmx-helper-spi.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-spi.c
@@ -35,12 +35,12 @@ void __cvmx_interrupt_stxx_int_msk_enable(int index);
*/
#include <asm/octeon/octeon.h>
-#include "cvmx-config.h"
-#include "cvmx-spi.h"
-#include "cvmx-helper.h"
+#include <asm/octeon/cvmx-config.h>
+#include <asm/octeon/cvmx-spi.h>
+#include <asm/octeon/cvmx-helper.h>
-#include "cvmx-pip-defs.h"
-#include "cvmx-pko-defs.h"
+#include <asm/octeon/cvmx-pip-defs.h>
+#include <asm/octeon/cvmx-pko-defs.h>
/*
* CVMX_HELPER_SPI_TIMEOUT is used to determine how long the SPI
diff --git a/drivers/staging/octeon/cvmx-helper-util.c b/arch/mips/cavium-octeon/executive/cvmx-helper-util.c
similarity index 97%
rename from drivers/staging/octeon/cvmx-helper-util.c
rename to arch/mips/cavium-octeon/executive/cvmx-helper-util.c
index 41ef8a4..8c98a22 100644
--- a/drivers/staging/octeon/cvmx-helper-util.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-util.c
@@ -32,16 +32,16 @@
#include <asm/octeon/octeon.h>
-#include "cvmx-config.h"
+#include <asm/octeon/cvmx-config.h>
-#include "cvmx-fpa.h"
-#include "cvmx-pip.h"
-#include "cvmx-pko.h"
-#include "cvmx-ipd.h"
-#include "cvmx-spi.h"
+#include <asm/octeon/cvmx-fpa.h>
+#include <asm/octeon/cvmx-pip.h>
+#include <asm/octeon/cvmx-pko.h>
+#include <asm/octeon/cvmx-ipd.h>
+#include <asm/octeon/cvmx-spi.h>
-#include "cvmx-helper.h"
-#include "cvmx-helper-util.h"
+#include <asm/octeon/cvmx-helper.h>
+#include <asm/octeon/cvmx-helper-util.h>
#include <asm/octeon/cvmx-ipd-defs.h>
diff --git a/drivers/staging/octeon/cvmx-helper-xaui.c b/arch/mips/cavium-octeon/executive/cvmx-helper-xaui.c
similarity index 98%
rename from drivers/staging/octeon/cvmx-helper-xaui.c
rename to arch/mips/cavium-octeon/executive/cvmx-helper-xaui.c
index a11e676..667a8e3 100644
--- a/drivers/staging/octeon/cvmx-helper-xaui.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper-xaui.c
@@ -33,13 +33,13 @@
#include <asm/octeon/octeon.h>
-#include "cvmx-config.h"
+#include <asm/octeon/cvmx-config.h>
-#include "cvmx-helper.h"
+#include <asm/octeon/cvmx-helper.h>
-#include "cvmx-pko-defs.h"
-#include "cvmx-gmxx-defs.h"
-#include "cvmx-pcsxx-defs.h"
+#include <asm/octeon/cvmx-pko-defs.h>
+#include <asm/octeon/cvmx-gmxx-defs.h>
+#include <asm/octeon/cvmx-pcsxx-defs.h>
void __cvmx_interrupt_gmxx_enable(int interface);
void __cvmx_interrupt_pcsx_intx_en_reg_enable(int index, int block);
diff --git a/drivers/staging/octeon/cvmx-helper.c b/arch/mips/cavium-octeon/executive/cvmx-helper.c
similarity index 98%
rename from drivers/staging/octeon/cvmx-helper.c
rename to arch/mips/cavium-octeon/executive/cvmx-helper.c
index 5915066..6238a22 100644
--- a/drivers/staging/octeon/cvmx-helper.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-helper.c
@@ -32,19 +32,19 @@
*/
#include <asm/octeon/octeon.h>
-#include "cvmx-config.h"
+#include <asm/octeon/cvmx-config.h>
-#include "cvmx-fpa.h"
-#include "cvmx-pip.h"
-#include "cvmx-pko.h"
-#include "cvmx-ipd.h"
-#include "cvmx-spi.h"
-#include "cvmx-helper.h"
-#include "cvmx-helper-board.h"
+#include <asm/octeon/cvmx-fpa.h>
+#include <asm/octeon/cvmx-pip.h>
+#include <asm/octeon/cvmx-pko.h>
+#include <asm/octeon/cvmx-ipd.h>
+#include <asm/octeon/cvmx-spi.h>
+#include <asm/octeon/cvmx-helper.h>
+#include <asm/octeon/cvmx-helper-board.h>
-#include "cvmx-pip-defs.h"
-#include "cvmx-smix-defs.h"
-#include "cvmx-asxx-defs.h"
+#include <asm/octeon/cvmx-pip-defs.h>
+#include <asm/octeon/cvmx-smix-defs.h>
+#include <asm/octeon/cvmx-asxx-defs.h>
/**
* cvmx_override_pko_queue_priority(int ipd_port, uint64_t
@@ -548,7 +548,6 @@ int __cvmx_helper_errata_fix_ipd_ptr_alignment(void)
union cvmx_gmxx_prtx_cfg gmx_cfg;
int retry_cnt;
int retry_loop_cnt;
- int mtu;
int i;
cvmx_helper_link_info_t link_info;
@@ -662,10 +661,6 @@ int __cvmx_helper_errata_fix_ipd_ptr_alignment(void)
cvmx_write_csr(CVMX_ASXX_RX_PRT_EN(INTERFACE(FIX_IPD_OUTPORT)),
1 << INDEX(FIX_IPD_OUTPORT));
- mtu =
- cvmx_read_csr(CVMX_GMXX_RXX_JABBER
- (INDEX(FIX_IPD_OUTPORT),
- INTERFACE(FIX_IPD_OUTPORT)));
cvmx_write_csr(CVMX_GMXX_RXX_JABBER
(INDEX(FIX_IPD_OUTPORT),
INTERFACE(FIX_IPD_OUTPORT)), 65392 - 14 - 4);
diff --git a/drivers/staging/octeon/cvmx-interrupt-decodes.c b/arch/mips/cavium-octeon/executive/cvmx-interrupt-decodes.c
similarity index 98%
rename from drivers/staging/octeon/cvmx-interrupt-decodes.c
rename to arch/mips/cavium-octeon/executive/cvmx-interrupt-decodes.c
index a3337e3..e59d1b7 100644
--- a/drivers/staging/octeon/cvmx-interrupt-decodes.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-interrupt-decodes.c
@@ -34,11 +34,11 @@
#include <asm/octeon/octeon.h>
-#include "cvmx-gmxx-defs.h"
-#include "cvmx-pcsx-defs.h"
-#include "cvmx-pcsxx-defs.h"
-#include "cvmx-spxx-defs.h"
-#include "cvmx-stxx-defs.h"
+#include <asm/octeon/cvmx-gmxx-defs.h>
+#include <asm/octeon/cvmx-pcsx-defs.h>
+#include <asm/octeon/cvmx-pcsxx-defs.h>
+#include <asm/octeon/cvmx-spxx-defs.h>
+#include <asm/octeon/cvmx-stxx-defs.h>
#ifndef PRINT_ERROR
#define PRINT_ERROR(format, ...)
diff --git a/drivers/staging/octeon/cvmx-interrupt-rsl.c b/arch/mips/cavium-octeon/executive/cvmx-interrupt-rsl.c
similarity index 97%
rename from drivers/staging/octeon/cvmx-interrupt-rsl.c
rename to arch/mips/cavium-octeon/executive/cvmx-interrupt-rsl.c
index df50048..bea7538 100644
--- a/drivers/staging/octeon/cvmx-interrupt-rsl.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-interrupt-rsl.c
@@ -32,8 +32,8 @@
#include <asm/octeon/octeon.h>
-#include "cvmx-asxx-defs.h"
-#include "cvmx-gmxx-defs.h"
+#include <asm/octeon/cvmx-asxx-defs.h>
+#include <asm/octeon/cvmx-gmxx-defs.h>
#ifndef PRINT_ERROR
#define PRINT_ERROR(format, ...)
diff --git a/drivers/staging/octeon/cvmx-pko.c b/arch/mips/cavium-octeon/executive/cvmx-pko.c
similarity index 99%
rename from drivers/staging/octeon/cvmx-pko.c
rename to arch/mips/cavium-octeon/executive/cvmx-pko.c
index 00db915..f557084 100644
--- a/drivers/staging/octeon/cvmx-pko.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-pko.c
@@ -31,9 +31,9 @@
#include <asm/octeon/octeon.h>
-#include "cvmx-config.h"
-#include "cvmx-pko.h"
-#include "cvmx-helper.h"
+#include <asm/octeon/cvmx-config.h>
+#include <asm/octeon/cvmx-pko.h>
+#include <asm/octeon/cvmx-helper.h>
/**
* Internal state of packet output
diff --git a/drivers/staging/octeon/cvmx-spi.c b/arch/mips/cavium-octeon/executive/cvmx-spi.c
similarity index 99%
rename from drivers/staging/octeon/cvmx-spi.c
rename to arch/mips/cavium-octeon/executive/cvmx-spi.c
index 82794d9..74afb17 100644
--- a/drivers/staging/octeon/cvmx-spi.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-spi.c
@@ -31,14 +31,14 @@
*/
#include <asm/octeon/octeon.h>
-#include "cvmx-config.h"
+#include <asm/octeon/cvmx-config.h>
-#include "cvmx-pko.h"
-#include "cvmx-spi.h"
+#include <asm/octeon/cvmx-pko.h>
+#include <asm/octeon/cvmx-spi.h>
-#include "cvmx-spxx-defs.h"
-#include "cvmx-stxx-defs.h"
-#include "cvmx-srxx-defs.h"
+#include <asm/octeon/cvmx-spxx-defs.h>
+#include <asm/octeon/cvmx-stxx-defs.h>
+#include <asm/octeon/cvmx-srxx-defs.h>
#define INVOKE_CB(function_p, args...) \
do { \
diff --git a/drivers/staging/octeon/cvmx-address.h b/arch/mips/include/asm/octeon/cvmx-address.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-address.h
rename to arch/mips/include/asm/octeon/cvmx-address.h
diff --git a/drivers/staging/octeon/cvmx-asxx-defs.h b/arch/mips/include/asm/octeon/cvmx-asxx-defs.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-asxx-defs.h
rename to arch/mips/include/asm/octeon/cvmx-asxx-defs.h
diff --git a/drivers/staging/octeon/cvmx-cmd-queue.h b/arch/mips/include/asm/octeon/cvmx-cmd-queue.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-cmd-queue.h
rename to arch/mips/include/asm/octeon/cvmx-cmd-queue.h
diff --git a/drivers/staging/octeon/cvmx-config.h b/arch/mips/include/asm/octeon/cvmx-config.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-config.h
rename to arch/mips/include/asm/octeon/cvmx-config.h
diff --git a/drivers/staging/octeon/cvmx-dbg-defs.h b/arch/mips/include/asm/octeon/cvmx-dbg-defs.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-dbg-defs.h
rename to arch/mips/include/asm/octeon/cvmx-dbg-defs.h
diff --git a/drivers/staging/octeon/cvmx-fau.h b/arch/mips/include/asm/octeon/cvmx-fau.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-fau.h
rename to arch/mips/include/asm/octeon/cvmx-fau.h
diff --git a/drivers/staging/octeon/cvmx-fpa-defs.h b/arch/mips/include/asm/octeon/cvmx-fpa-defs.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-fpa-defs.h
rename to arch/mips/include/asm/octeon/cvmx-fpa-defs.h
diff --git a/drivers/staging/octeon/cvmx-fpa.h b/arch/mips/include/asm/octeon/cvmx-fpa.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-fpa.h
rename to arch/mips/include/asm/octeon/cvmx-fpa.h
diff --git a/drivers/staging/octeon/cvmx-gmxx-defs.h b/arch/mips/include/asm/octeon/cvmx-gmxx-defs.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-gmxx-defs.h
rename to arch/mips/include/asm/octeon/cvmx-gmxx-defs.h
diff --git a/drivers/staging/octeon/cvmx-helper-board.h b/arch/mips/include/asm/octeon/cvmx-helper-board.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-helper-board.h
rename to arch/mips/include/asm/octeon/cvmx-helper-board.h
diff --git a/drivers/staging/octeon/cvmx-helper-fpa.h b/arch/mips/include/asm/octeon/cvmx-helper-fpa.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-helper-fpa.h
rename to arch/mips/include/asm/octeon/cvmx-helper-fpa.h
diff --git a/drivers/staging/octeon/cvmx-helper-loop.h b/arch/mips/include/asm/octeon/cvmx-helper-loop.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-helper-loop.h
rename to arch/mips/include/asm/octeon/cvmx-helper-loop.h
diff --git a/drivers/staging/octeon/cvmx-helper-npi.h b/arch/mips/include/asm/octeon/cvmx-helper-npi.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-helper-npi.h
rename to arch/mips/include/asm/octeon/cvmx-helper-npi.h
diff --git a/drivers/staging/octeon/cvmx-helper-rgmii.h b/arch/mips/include/asm/octeon/cvmx-helper-rgmii.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-helper-rgmii.h
rename to arch/mips/include/asm/octeon/cvmx-helper-rgmii.h
diff --git a/drivers/staging/octeon/cvmx-helper-sgmii.h b/arch/mips/include/asm/octeon/cvmx-helper-sgmii.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-helper-sgmii.h
rename to arch/mips/include/asm/octeon/cvmx-helper-sgmii.h
diff --git a/drivers/staging/octeon/cvmx-helper-spi.h b/arch/mips/include/asm/octeon/cvmx-helper-spi.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-helper-spi.h
rename to arch/mips/include/asm/octeon/cvmx-helper-spi.h
diff --git a/drivers/staging/octeon/cvmx-helper-util.h b/arch/mips/include/asm/octeon/cvmx-helper-util.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-helper-util.h
rename to arch/mips/include/asm/octeon/cvmx-helper-util.h
diff --git a/drivers/staging/octeon/cvmx-helper-xaui.h b/arch/mips/include/asm/octeon/cvmx-helper-xaui.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-helper-xaui.h
rename to arch/mips/include/asm/octeon/cvmx-helper-xaui.h
diff --git a/drivers/staging/octeon/cvmx-helper.h b/arch/mips/include/asm/octeon/cvmx-helper.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-helper.h
rename to arch/mips/include/asm/octeon/cvmx-helper.h
diff --git a/drivers/staging/octeon/cvmx-ipd.h b/arch/mips/include/asm/octeon/cvmx-ipd.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-ipd.h
rename to arch/mips/include/asm/octeon/cvmx-ipd.h
diff --git a/drivers/staging/octeon/cvmx-mdio.h b/arch/mips/include/asm/octeon/cvmx-mdio.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-mdio.h
rename to arch/mips/include/asm/octeon/cvmx-mdio.h
diff --git a/drivers/staging/octeon/cvmx-pcsx-defs.h b/arch/mips/include/asm/octeon/cvmx-pcsx-defs.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-pcsx-defs.h
rename to arch/mips/include/asm/octeon/cvmx-pcsx-defs.h
diff --git a/drivers/staging/octeon/cvmx-pcsxx-defs.h b/arch/mips/include/asm/octeon/cvmx-pcsxx-defs.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-pcsxx-defs.h
rename to arch/mips/include/asm/octeon/cvmx-pcsxx-defs.h
diff --git a/drivers/staging/octeon/cvmx-pip-defs.h b/arch/mips/include/asm/octeon/cvmx-pip-defs.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-pip-defs.h
rename to arch/mips/include/asm/octeon/cvmx-pip-defs.h
diff --git a/drivers/staging/octeon/cvmx-pip.h b/arch/mips/include/asm/octeon/cvmx-pip.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-pip.h
rename to arch/mips/include/asm/octeon/cvmx-pip.h
diff --git a/drivers/staging/octeon/cvmx-pko-defs.h b/arch/mips/include/asm/octeon/cvmx-pko-defs.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-pko-defs.h
rename to arch/mips/include/asm/octeon/cvmx-pko-defs.h
diff --git a/drivers/staging/octeon/cvmx-pko.h b/arch/mips/include/asm/octeon/cvmx-pko.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-pko.h
rename to arch/mips/include/asm/octeon/cvmx-pko.h
diff --git a/drivers/staging/octeon/cvmx-pow.h b/arch/mips/include/asm/octeon/cvmx-pow.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-pow.h
rename to arch/mips/include/asm/octeon/cvmx-pow.h
diff --git a/drivers/staging/octeon/cvmx-scratch.h b/arch/mips/include/asm/octeon/cvmx-scratch.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-scratch.h
rename to arch/mips/include/asm/octeon/cvmx-scratch.h
diff --git a/drivers/staging/octeon/cvmx-spi.h b/arch/mips/include/asm/octeon/cvmx-spi.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-spi.h
rename to arch/mips/include/asm/octeon/cvmx-spi.h
diff --git a/drivers/staging/octeon/cvmx-spxx-defs.h b/arch/mips/include/asm/octeon/cvmx-spxx-defs.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-spxx-defs.h
rename to arch/mips/include/asm/octeon/cvmx-spxx-defs.h
diff --git a/drivers/staging/octeon/cvmx-srxx-defs.h b/arch/mips/include/asm/octeon/cvmx-srxx-defs.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-srxx-defs.h
rename to arch/mips/include/asm/octeon/cvmx-srxx-defs.h
diff --git a/drivers/staging/octeon/cvmx-stxx-defs.h b/arch/mips/include/asm/octeon/cvmx-stxx-defs.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-stxx-defs.h
rename to arch/mips/include/asm/octeon/cvmx-stxx-defs.h
diff --git a/drivers/staging/octeon/cvmx-wqe.h b/arch/mips/include/asm/octeon/cvmx-wqe.h
similarity index 100%
rename from drivers/staging/octeon/cvmx-wqe.h
rename to arch/mips/include/asm/octeon/cvmx-wqe.h
diff --git a/drivers/staging/octeon/Makefile b/drivers/staging/octeon/Makefile
index fc850ba..9012dee 100644
--- a/drivers/staging/octeon/Makefile
+++ b/drivers/staging/octeon/Makefile
@@ -20,9 +20,4 @@ octeon-ethernet-y += ethernet-sgmii.o
octeon-ethernet-y += ethernet-spi.o
octeon-ethernet-y += ethernet-tx.o
octeon-ethernet-y += ethernet-xaui.o
-octeon-ethernet-y += cvmx-pko.o cvmx-spi.o cvmx-cmd-queue.o \
- cvmx-helper-board.o cvmx-helper.o cvmx-helper-xaui.o \
- cvmx-helper-rgmii.o cvmx-helper-sgmii.o cvmx-helper-npi.o \
- cvmx-helper-loop.o cvmx-helper-spi.o cvmx-helper-util.o \
- cvmx-interrupt-decodes.o cvmx-interrupt-rsl.o
diff --git a/drivers/staging/octeon/cvmx-packet.h b/drivers/staging/octeon/cvmx-packet.h
deleted file mode 100644
index 62ffe78..0000000
--- a/drivers/staging/octeon/cvmx-packet.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/***********************license start***************
- * Author: Cavium Networks
- *
- * Contact: [email protected]
- * This file is part of the OCTEON SDK
- *
- * Copyright (c) 2003-2008 Cavium Networks
- *
- * This file is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, Version 2, as
- * published by the Free Software Foundation.
- *
- * This file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
- ***********************license end**************************************/
-
-/**
- *
- * Packet buffer defines.
- */
-
-#ifndef __CVMX_PACKET_H__
-#define __CVMX_PACKET_H__
-
-/**
- * This structure defines a buffer pointer on Octeon
- */
-union cvmx_buf_ptr {
- void *ptr;
- uint64_t u64;
- struct {
- /*
- * if set, invert the "free" pick of the overall
- * packet. HW always sets this bit to 0 on inbound
- * packet
- */
- uint64_t i:1;
- /*
- * Indicates the amount to back up to get to the
- * buffer start in cache lines. In most cases this is
- * less than one complete cache line, so the value is
- * zero.
- */
- uint64_t back:4;
- /* The pool that the buffer came from / goes to */
- uint64_t pool:3;
- /* The size of the segment pointed to by addr (in bytes) */
- uint64_t size:16;
- /* Pointer to the first byte of the data, NOT buffer */
- uint64_t addr:40;
- } s;
-};
-
-#endif /* __CVMX_PACKET_H__ */
diff --git a/drivers/staging/octeon/cvmx-smix-defs.h b/drivers/staging/octeon/cvmx-smix-defs.h
deleted file mode 100644
index 9ae45fc..0000000
--- a/drivers/staging/octeon/cvmx-smix-defs.h
+++ /dev/null
@@ -1,178 +0,0 @@
-/***********************license start***************
- * Author: Cavium Networks
- *
- * Contact: [email protected]
- * This file is part of the OCTEON SDK
- *
- * Copyright (c) 2003-2008 Cavium Networks
- *
- * This file is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, Version 2, as
- * published by the Free Software Foundation.
- *
- * This file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
- ***********************license end**************************************/
-
-#ifndef __CVMX_SMIX_DEFS_H__
-#define __CVMX_SMIX_DEFS_H__
-
-#define CVMX_SMIX_CLK(offset) \
- CVMX_ADD_IO_SEG(0x0001180000001818ull + (((offset) & 1) * 256))
-#define CVMX_SMIX_CMD(offset) \
- CVMX_ADD_IO_SEG(0x0001180000001800ull + (((offset) & 1) * 256))
-#define CVMX_SMIX_EN(offset) \
- CVMX_ADD_IO_SEG(0x0001180000001820ull + (((offset) & 1) * 256))
-#define CVMX_SMIX_RD_DAT(offset) \
- CVMX_ADD_IO_SEG(0x0001180000001810ull + (((offset) & 1) * 256))
-#define CVMX_SMIX_WR_DAT(offset) \
- CVMX_ADD_IO_SEG(0x0001180000001808ull + (((offset) & 1) * 256))
-
-union cvmx_smix_clk {
- uint64_t u64;
- struct cvmx_smix_clk_s {
- uint64_t reserved_25_63:39;
- uint64_t mode:1;
- uint64_t reserved_21_23:3;
- uint64_t sample_hi:5;
- uint64_t sample_mode:1;
- uint64_t reserved_14_14:1;
- uint64_t clk_idle:1;
- uint64_t preamble:1;
- uint64_t sample:4;
- uint64_t phase:8;
- } s;
- struct cvmx_smix_clk_cn30xx {
- uint64_t reserved_21_63:43;
- uint64_t sample_hi:5;
- uint64_t reserved_14_15:2;
- uint64_t clk_idle:1;
- uint64_t preamble:1;
- uint64_t sample:4;
- uint64_t phase:8;
- } cn30xx;
- struct cvmx_smix_clk_cn30xx cn31xx;
- struct cvmx_smix_clk_cn30xx cn38xx;
- struct cvmx_smix_clk_cn30xx cn38xxp2;
- struct cvmx_smix_clk_cn50xx {
- uint64_t reserved_25_63:39;
- uint64_t mode:1;
- uint64_t reserved_21_23:3;
- uint64_t sample_hi:5;
- uint64_t reserved_14_15:2;
- uint64_t clk_idle:1;
- uint64_t preamble:1;
- uint64_t sample:4;
- uint64_t phase:8;
- } cn50xx;
- struct cvmx_smix_clk_s cn52xx;
- struct cvmx_smix_clk_cn50xx cn52xxp1;
- struct cvmx_smix_clk_s cn56xx;
- struct cvmx_smix_clk_cn50xx cn56xxp1;
- struct cvmx_smix_clk_cn30xx cn58xx;
- struct cvmx_smix_clk_cn30xx cn58xxp1;
-};
-
-union cvmx_smix_cmd {
- uint64_t u64;
- struct cvmx_smix_cmd_s {
- uint64_t reserved_18_63:46;
- uint64_t phy_op:2;
- uint64_t reserved_13_15:3;
- uint64_t phy_adr:5;
- uint64_t reserved_5_7:3;
- uint64_t reg_adr:5;
- } s;
- struct cvmx_smix_cmd_cn30xx {
- uint64_t reserved_17_63:47;
- uint64_t phy_op:1;
- uint64_t reserved_13_15:3;
- uint64_t phy_adr:5;
- uint64_t reserved_5_7:3;
- uint64_t reg_adr:5;
- } cn30xx;
- struct cvmx_smix_cmd_cn30xx cn31xx;
- struct cvmx_smix_cmd_cn30xx cn38xx;
- struct cvmx_smix_cmd_cn30xx cn38xxp2;
- struct cvmx_smix_cmd_s cn50xx;
- struct cvmx_smix_cmd_s cn52xx;
- struct cvmx_smix_cmd_s cn52xxp1;
- struct cvmx_smix_cmd_s cn56xx;
- struct cvmx_smix_cmd_s cn56xxp1;
- struct cvmx_smix_cmd_cn30xx cn58xx;
- struct cvmx_smix_cmd_cn30xx cn58xxp1;
-};
-
-union cvmx_smix_en {
- uint64_t u64;
- struct cvmx_smix_en_s {
- uint64_t reserved_1_63:63;
- uint64_t en:1;
- } s;
- struct cvmx_smix_en_s cn30xx;
- struct cvmx_smix_en_s cn31xx;
- struct cvmx_smix_en_s cn38xx;
- struct cvmx_smix_en_s cn38xxp2;
- struct cvmx_smix_en_s cn50xx;
- struct cvmx_smix_en_s cn52xx;
- struct cvmx_smix_en_s cn52xxp1;
- struct cvmx_smix_en_s cn56xx;
- struct cvmx_smix_en_s cn56xxp1;
- struct cvmx_smix_en_s cn58xx;
- struct cvmx_smix_en_s cn58xxp1;
-};
-
-union cvmx_smix_rd_dat {
- uint64_t u64;
- struct cvmx_smix_rd_dat_s {
- uint64_t reserved_18_63:46;
- uint64_t pending:1;
- uint64_t val:1;
- uint64_t dat:16;
- } s;
- struct cvmx_smix_rd_dat_s cn30xx;
- struct cvmx_smix_rd_dat_s cn31xx;
- struct cvmx_smix_rd_dat_s cn38xx;
- struct cvmx_smix_rd_dat_s cn38xxp2;
- struct cvmx_smix_rd_dat_s cn50xx;
- struct cvmx_smix_rd_dat_s cn52xx;
- struct cvmx_smix_rd_dat_s cn52xxp1;
- struct cvmx_smix_rd_dat_s cn56xx;
- struct cvmx_smix_rd_dat_s cn56xxp1;
- struct cvmx_smix_rd_dat_s cn58xx;
- struct cvmx_smix_rd_dat_s cn58xxp1;
-};
-
-union cvmx_smix_wr_dat {
- uint64_t u64;
- struct cvmx_smix_wr_dat_s {
- uint64_t reserved_18_63:46;
- uint64_t pending:1;
- uint64_t val:1;
- uint64_t dat:16;
- } s;
- struct cvmx_smix_wr_dat_s cn30xx;
- struct cvmx_smix_wr_dat_s cn31xx;
- struct cvmx_smix_wr_dat_s cn38xx;
- struct cvmx_smix_wr_dat_s cn38xxp2;
- struct cvmx_smix_wr_dat_s cn50xx;
- struct cvmx_smix_wr_dat_s cn52xx;
- struct cvmx_smix_wr_dat_s cn52xxp1;
- struct cvmx_smix_wr_dat_s cn56xx;
- struct cvmx_smix_wr_dat_s cn56xxp1;
- struct cvmx_smix_wr_dat_s cn58xx;
- struct cvmx_smix_wr_dat_s cn58xxp1;
-};
-
-#endif
diff --git a/drivers/staging/octeon/ethernet-defines.h b/drivers/staging/octeon/ethernet-defines.h
index 6a2cd50..bdaec8d 100644
--- a/drivers/staging/octeon/ethernet-defines.h
+++ b/drivers/staging/octeon/ethernet-defines.h
@@ -59,7 +59,7 @@
#ifndef __ETHERNET_DEFINES_H__
#define __ETHERNET_DEFINES_H__
-#include "cvmx-config.h"
+#include <asm/octeon/cvmx-config.h>
#define OCTEON_ETHERNET_VERSION "1.9"
diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c
index 10a82ef..0e5dab7 100644
--- a/drivers/staging/octeon/ethernet-mdio.c
+++ b/drivers/staging/octeon/ethernet-mdio.c
@@ -37,9 +37,9 @@
#include "ethernet-mdio.h"
#include "ethernet-util.h"
-#include "cvmx-helper-board.h"
+#include <asm/octeon/cvmx-helper-board.h>
-#include "cvmx-smix-defs.h"
+#include <asm/octeon/cvmx-smix-defs.h>
static void cvm_oct_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
diff --git a/drivers/staging/octeon/ethernet-mem.c b/drivers/staging/octeon/ethernet-mem.c
index 635bb86..78b6cb7 100644
--- a/drivers/staging/octeon/ethernet-mem.c
+++ b/drivers/staging/octeon/ethernet-mem.c
@@ -32,7 +32,7 @@
#include "ethernet-defines.h"
-#include "cvmx-fpa.h"
+#include <asm/octeon/cvmx-fpa.h>
/**
* cvm_oct_fill_hw_skbuff - fill the supplied hardware pool with skbuffs
diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c
index a0d4d4b..849af10 100644
--- a/drivers/staging/octeon/ethernet-rgmii.c
+++ b/drivers/staging/octeon/ethernet-rgmii.c
@@ -35,11 +35,11 @@
#include "octeon-ethernet.h"
#include "ethernet-util.h"
-#include "cvmx-helper.h"
+#include <asm/octeon/cvmx-helper.h>
#include <asm/octeon/cvmx-ipd-defs.h>
#include <asm/octeon/cvmx-npi-defs.h>
-#include "cvmx-gmxx-defs.h"
+#include <asm/octeon/cvmx-gmxx-defs.h>
DEFINE_SPINLOCK(global_register_lock);
diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
index cb38f9e..d830393 100644
--- a/drivers/staging/octeon/ethernet-rx.c
+++ b/drivers/staging/octeon/ethernet-rx.c
@@ -51,14 +51,14 @@
#include "octeon-ethernet.h"
#include "ethernet-util.h"
-#include "cvmx-helper.h"
-#include "cvmx-wqe.h"
-#include "cvmx-fau.h"
-#include "cvmx-pow.h"
-#include "cvmx-pip.h"
-#include "cvmx-scratch.h"
-
-#include "cvmx-gmxx-defs.h"
+#include <asm/octeon/cvmx-helper.h>
+#include <asm/octeon/cvmx-wqe.h>
+#include <asm/octeon/cvmx-fau.h>
+#include <asm/octeon/cvmx-pow.h>
+#include <asm/octeon/cvmx-pip.h>
+#include <asm/octeon/cvmx-scratch.h>
+
+#include <asm/octeon/cvmx-gmxx-defs.h>
struct cvm_napi_wrapper {
struct napi_struct napi;
diff --git a/drivers/staging/octeon/ethernet-rx.h b/drivers/staging/octeon/ethernet-rx.h
index a0743b8..9240c85 100644
--- a/drivers/staging/octeon/ethernet-rx.h
+++ b/drivers/staging/octeon/ethernet-rx.h
@@ -24,7 +24,7 @@
* This file may also be available under a different license from Cavium.
* Contact Cavium Networks for more information
*********************************************************************/
-#include "cvmx-fau.h"
+#include <asm/octeon/cvmx-fau.h>
void cvm_oct_poll_controller(struct net_device *dev);
void cvm_oct_rx_initialize(void);
diff --git a/drivers/staging/octeon/ethernet-sgmii.c b/drivers/staging/octeon/ethernet-sgmii.c
index 2d8589e..d102277 100644
--- a/drivers/staging/octeon/ethernet-sgmii.c
+++ b/drivers/staging/octeon/ethernet-sgmii.c
@@ -34,9 +34,9 @@
#include "octeon-ethernet.h"
#include "ethernet-util.h"
-#include "cvmx-helper.h"
+#include <asm/octeon/cvmx-helper.h>
-#include "cvmx-gmxx-defs.h"
+#include <asm/octeon/cvmx-gmxx-defs.h>
int cvm_oct_sgmii_open(struct net_device *dev)
{
diff --git a/drivers/staging/octeon/ethernet-spi.c b/drivers/staging/octeon/ethernet-spi.c
index 9708254..2ce9135 100644
--- a/drivers/staging/octeon/ethernet-spi.c
+++ b/drivers/staging/octeon/ethernet-spi.c
@@ -34,11 +34,11 @@
#include "octeon-ethernet.h"
#include "ethernet-util.h"
-#include "cvmx-spi.h"
+#include <asm/octeon/cvmx-spi.h>
#include <asm/octeon/cvmx-npi-defs.h>
-#include "cvmx-spxx-defs.h"
-#include "cvmx-stxx-defs.h"
+#include <asm/octeon/cvmx-spxx-defs.h>
+#include <asm/octeon/cvmx-stxx-defs.h>
static int number_spi_ports;
static int need_retrain[2] = { 0, 0 };
diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c
index afc2b73..1f03eb6 100644
--- a/drivers/staging/octeon/ethernet-tx.c
+++ b/drivers/staging/octeon/ethernet-tx.c
@@ -46,13 +46,13 @@
#include "ethernet-tx.h"
#include "ethernet-util.h"
-#include "cvmx-wqe.h"
-#include "cvmx-fau.h"
-#include "cvmx-pip.h"
-#include "cvmx-pko.h"
-#include "cvmx-helper.h"
+#include <asm/octeon/cvmx-wqe.h>
+#include <asm/octeon/cvmx-fau.h>
+#include <asm/octeon/cvmx-pip.h>
+#include <asm/octeon/cvmx-pko.h>
+#include <asm/octeon/cvmx-helper.h>
-#include "cvmx-gmxx-defs.h"
+#include <asm/octeon/cvmx-gmxx-defs.h>
#define CVM_OCT_SKB_CB(skb) ((u64 *)((skb)->cb))
diff --git a/drivers/staging/octeon/ethernet-xaui.c b/drivers/staging/octeon/ethernet-xaui.c
index 3fca1cc..321fafc 100644
--- a/drivers/staging/octeon/ethernet-xaui.c
+++ b/drivers/staging/octeon/ethernet-xaui.c
@@ -34,9 +34,9 @@
#include "octeon-ethernet.h"
#include "ethernet-util.h"
-#include "cvmx-helper.h"
+#include <asm/octeon/cvmx-helper.h>
-#include "cvmx-gmxx-defs.h"
+#include <asm/octeon/cvmx-gmxx-defs.h>
int cvm_oct_xaui_open(struct net_device *dev)
{
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
index a8f780e..042adf7 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -44,14 +44,14 @@
#include "ethernet-mdio.h"
#include "ethernet-util.h"
-#include "cvmx-pip.h"
-#include "cvmx-pko.h"
-#include "cvmx-fau.h"
-#include "cvmx-ipd.h"
-#include "cvmx-helper.h"
-
-#include "cvmx-gmxx-defs.h"
-#include "cvmx-smix-defs.h"
+#include <asm/octeon/cvmx-pip.h>
+#include <asm/octeon/cvmx-pko.h>
+#include <asm/octeon/cvmx-fau.h>
+#include <asm/octeon/cvmx-ipd.h>
+#include <asm/octeon/cvmx-helper.h>
+
+#include <asm/octeon/cvmx-gmxx-defs.h>
+#include <asm/octeon/cvmx-smix-defs.h>
#if defined(CONFIG_CAVIUM_OCTEON_NUM_PACKET_BUFFERS) \
&& CONFIG_CAVIUM_OCTEON_NUM_PACKET_BUFFERS
--
1.7.2.3
This is needed for Octeon to use the Device Tree.
Signed-off-by: David Daney <[email protected]>
---
arch/mips/cavium-octeon/octeon-irq.c | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c
index b365710..b0a9261 100644
--- a/arch/mips/cavium-octeon/octeon-irq.c
+++ b/arch/mips/cavium-octeon/octeon-irq.c
@@ -8,7 +8,9 @@
#include <linux/interrupt.h>
#include <linux/bitops.h>
+#include <linux/module.h>
#include <linux/percpu.h>
+#include <linux/of_irq.h>
#include <linux/irq.h>
#include <linux/smp.h>
@@ -64,6 +66,29 @@ static void __init octeon_irq_set_ciu_mapping(int irq, int line, int bit,
octeon_irq_ciu_to_irq[line][bit] = irq;
}
+/*
+ * irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq#
+ *
+ * Octeon irq maps are a pair of indexes. The first selects either
+ * ciu0 or ciu1, the second is the bit within the ciu register.
+ */
+unsigned int irq_create_of_mapping(struct device_node *controller,
+ const u32 *intspec, unsigned int intsize)
+{
+ int ciu, bit;
+ unsigned int irq = 0;
+
+ ciu = be32_to_cpup(intspec);
+ bit = be32_to_cpup(intspec + 1);
+
+ if (ciu < 8 && bit < 64)
+ irq = octeon_irq_ciu_to_irq[ciu][bit];
+
+ return irq;
+}
+EXPORT_SYMBOL_GPL(irq_create_of_mapping);
+
+
static int octeon_coreid_for_cpu(int cpu)
{
#ifdef CONFIG_SMP
--
1.7.2.3
On Tue, Feb 22, 2011 at 12:57:46PM -0800, David Daney wrote:
> Signed-off-by: David Daney <[email protected]>
> ---
> arch/mips/cavium-octeon/.gitignore | 2 +
> arch/mips/cavium-octeon/Makefile | 13 ++
> arch/mips/cavium-octeon/octeon_3xxx.dts | 314 +++++++++++++++++++++++++++++++
> arch/mips/cavium-octeon/octeon_68xx.dts | 99 ++++++++++
> 4 files changed, 428 insertions(+), 0 deletions(-)
> create mode 100644 arch/mips/cavium-octeon/.gitignore
> create mode 100644 arch/mips/cavium-octeon/octeon_3xxx.dts
> create mode 100644 arch/mips/cavium-octeon/octeon_68xx.dts
>
> diff --git a/arch/mips/cavium-octeon/.gitignore b/arch/mips/cavium-octeon/.gitignore
> new file mode 100644
> index 0000000..39c9686
> --- /dev/null
> +++ b/arch/mips/cavium-octeon/.gitignore
> @@ -0,0 +1,2 @@
> +*.dtb.S
.dtb.S?
[snip]
> +/dts-v1/;
> +/* OCTEON 3XXX, 5XXX, 63XX device tree skeleton. */
> +/ {
> + model = "OCTEON";
1 tab indents are the usual convention for device trees.
> + compatible = "octeon,octeon";
There's no model number at all for this board?
> + #address-cells = <2>;
> + #size-cells = <2>;
> +
> + soc@0 {
> + device_type = "soc";
Drop this device_type.
> + compatible = "simple-bus";
> + #address-cells = <2>;
> + #size-cells = <2>;
> + ranges; /* Direct mapping */
> +
> + ciu: ciu-3xxx@1070000000000 {
> + compatible = "octeon,ciu-3xxx";
So, names or compatible values with "wildcards" like 3xxx should be
avoided. Instead, use the specific model number of this device, then
future devices can claim compatibility with the earlier one.
But, in addition the generic names convention means that the node name
should be "interrupt-controller" rather than something model specific.
> + interrupt-controller;
> + #address-cells = <0>;
> + #interrupt-cells = <2>;
> + reg = <0x10700 0x00000000 0x0 0x7000>;
> + };
> +
> + /* SMI0 */
> + mdio0: mdio@1180000001800 {
If SMI0 is the name generally used in the documentation, using that in
the label instead of mdio0 might be more useful.
> + compatible = "octeon,mdio";
No model or revision number?
> + #address-cells = <1>;
> + #size-cells = <0>;
> + reg = <0x11800 0x00001800 0x0 0x40>;
> + device_type = "mdio";
Drop this device_type.
> +
> + phy0: ethernet-phy@0 {
> + reg = <0>;
> + };
> +
> + phy1: ethernet-phy@1 {
> + reg = <1>;
> + };
> +
> + phy2: ethernet-phy@2 {
> + reg = <2>;
> + marvell,reg-init = <3 0x10 0 0x5777>,
> + <3 0x11 0 0x00aa>,
> + <3 0x12 0 0x4105>,
> + <3 0x13 0 0x0a60>;
> + };
> + phy3: ethernet-phy@3 {
> + reg = <3>;
> + marvell,reg-init = <3 0x10 0 0x5777>,
> + <3 0x11 0 0x00aa>,
> + <3 0x12 0 0x4105>,
> + <3 0x13 0 0x0a60>;
> + };
> + phy4: ethernet-phy@4 {
> + reg = <4>;
> + marvell,reg-init = <3 0x10 0 0x5777>,
> + <3 0x11 0 0x00aa>,
> + <3 0x12 0 0x4105>,
> + <3 0x13 0 0x0a60>;
> + };
> + phy5: ethernet-phy@5 {
> + reg = <5>;
> + marvell,reg-init = <3 0x10 0 0x5777>,
> + <3 0x11 0 0x00aa>,
> + <3 0x12 0 0x4105>,
> + <3 0x13 0 0x0a60>;
> + };
> +
> + phy6: ethernet-phy@6 {
> + reg = <6>;
> + marvell,reg-init = <3 0x10 0 0x5777>,
> + <3 0x11 0 0x00aa>,
> + <3 0x12 0 0x4105>,
> + <3 0x13 0 0x0a60>;
> + };
> + phy7: ethernet-phy@7 {
> + reg = <7>;
> + marvell,reg-init = <3 0x10 0 0x5777>,
> + <3 0x11 0 0x00aa>,
> + <3 0x12 0 0x4105>,
> + <3 0x13 0 0x0a60>;
> + };
> + phy8: ethernet-phy@8 {
> + reg = <8>;
> + marvell,reg-init = <3 0x10 0 0x5777>,
> + <3 0x11 0 0x00aa>,
> + <3 0x12 0 0x4105>,
> + <3 0x13 0 0x0a60>;
> + };
> + phy9: ethernet-phy@9 {
> + reg = <9>;
> + marvell,reg-init = <3 0x10 0 0x5777>,
> + <3 0x11 0 0x00aa>,
> + <3 0x12 0 0x4105>,
> + <3 0x13 0 0x0a60>;
> + };
> + };
> +
> + /* SMI1 */
> + mdio1: mdio@1180000001900 {
> + compatible = "octeon,mdio";
> + #address-cells = <1>;
> + #size-cells = <0>;
> + reg = <0x11800 0x00001900 0x0 0x40>;
> + device_type = "mdio";
> + };
> +
> + mgmt0: ethernet@1070000100000 {
> + compatible = "octeon,mgmt";
> + device_type = "network";
> + model = "mgmt";
> + reg = <0x10700 0x00100000 0x0 0x100>, /* MIX */
> + <0x11800 0xE0000000 0x0 0x300>, /* AGL */
> + <0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */
> + <0x11800 0xE0002000 0x0 0x8>; /* AGL_PRT_CTL */
> + unit-number = <0>;
What is this 'unit-number' property for?
> + interrupt-parent = <&ciu>;
> + interrupts = <0 62>, <1 46>;
> + local-mac-address = [ 00 00 00 00 00 00 ];
That's not a valid MAC address of course. If this has to be patched
in by the bootloader / later processing, you should add a comment to
that effect.
> + phy-handle = <&phy0>;
> + };
> +
> + mgmt1: ethernet@1070000100800 {
> + compatible = "octeon,mgmt";
> + device_type = "network";
> + model = "mgmt";
> + reg = <0x10700 0x00100800 0x0 0x100>, /* MIX */
> + <0x11800 0xE0000800 0x0 0x300>, /* AGL */
> + <0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */
> + <0x11800 0xE0002008 0x0 0x8>; /* AGL_PRT_CTL */
> + unit-number = <1>;
> + interrupt-parent = <&ciu>;
> + interrupts = <1 18>, < 1 46>;
> + local-mac-address = [ 00 00 00 00 00 00 ];
> + phy-handle = <&phy1>;
> + };
> +
> + pip: pip@11800a0000000 {
> + compatible = "octeon,pip";
> + #address-cells = <1>;
> + #size-cells = <0>;
> + reg = <0x11800 0xa0000000 0x0 0x2000>;
> +
> + interface@0 {
These subnodes and subsubnodes should have compatible values too, even
if it's just "octeon,pip-interface" and "octeon,pip-ethernet".
> + #address-cells = <1>;
> + #size-cells = <0>;
> + reg = <0>; /* interface */
> +
> + ethernet@0 {
> + device_type = "network";
> + model = "pip";
This model property doesn't look very useful.
[snip]
> + /* TWSI 0 */
> + i2c0: i2c@1180000001000 {
> + #address-cells = <1>;
> + #size-cells = <0>;
> + compatible = "octeon,twsi";
> + reg = <0x11800 0x00001000 0x0 0x200>;
> + interrupt-parent = <&ciu>;
> + interrupts = <0 45>;
> + clock-rate = <100000>;
> +
> + rtc@68 {
> + compatible = "dallas,ds1337";
> + reg = <0x68>;
> + };
> + };
> +
> + /* TWSI 1 */
> + i2c1: i2c@1180000001200 {
> + #address-cells = <1>;
> + #size-cells = <0>;
> + compatible = "octeon,twsi";
> + reg = <0x11800 0x00001200 0x0 0x200>;
> + interrupt-parent = <&ciu>;
> + interrupts = <0 59>;
> + clock-rate = <100000>;
> + };
> + };
Uh.. where are the CPUs?
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[snip]
> +}
> +
> +static int __init set_mac_addr_prop(struct device_node *n, u64 mac)
> +{
> + u8 *vp;
> + struct property *old_p;
> + struct property *p = kzalloc(sizeof(struct device_node) + 6, GFP_KERNEL);
> + if (!p)
> + return -ENOMEM;
> + /* The value will immediatly follow the node in memory. */
> + vp = (u8 *)(&p[1]);
> + p->name = "local-mac-address";
> + p->length = 6;
> + p->value = vp;
> +
> + vp[0] = (mac >> 40) & 0xff;
> + vp[1] = (mac >> 32) & 0xff;
> + vp[2] = (mac >> 24) & 0xff;
> + vp[3] = (mac >> 16) & 0xff;
> + vp[4] = (mac >> 8) & 0xff;
> + vp[5] = mac & 0xff;
> +
> + old_p = of_find_property(n, "local-mac-address", NULL);
> + if (old_p)
> + prom_remove_property(n, old_p);
> + return prom_add_property(n, p);
Hrm, since you entirely remove and replace the local-mac-address
property here, I don't see much point to having the property with a
bogus value in the .dts.
[snip]
> +int __init octeon_prune_device_tree(void)
> +{
> + int i, p, max_port;
> + const char *node_path;
> + char name_buffer[20];
> + struct device_node *aliases;
> + struct device_node *pip;
> + struct device_node *iface;
> + struct device_node *eth;
> + struct device_node *node;
> +
> + aliases = of_find_node_by_path("/aliases");
> + if (!aliases) {
> + pr_err("Error: No /aliases node in device tree.");
> + return -EINVAL;
> + }
Ok, I think the .dts could do with some more comments indicating that
it will be subject to extensive pruning before use.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
On Wed, Feb 23, 2011 at 11:07:59AM +1100, David Gibson wrote:
> Uh.. where are the CPUs?
CPUs are probed the old style way on MIPS. There is a large number of
varieties of CPUs - things like cache size, cache line size, architectural
extension and many small details of behaviour differ. If we'd fully
honor DT CPU configuration information a kernel would need to have fairly
full blown generic CPU support for anything under the sun. But there
already is a scheme that allows platform support code to select permanet
enablement, disablement or runtime probe for every CPU feature under the
sun for significant code savings and performance gain.
Ralf
On Tue, Feb 22, 2011 at 12:57:45PM -0800, David Daney wrote:
> Signed-off-by: David Daney <[email protected]>
If this is an Ethernet driver, then it belongs in drivers/net and you
should cc both netdev and Dave Miller.
g.
> ---
> arch/mips/cavium-octeon/executive/Makefile | 5 +
> .../mips/cavium-octeon/executive}/cvmx-cmd-queue.c | 8 +-
> .../mips/cavium-octeon/executive}/cvmx-fpa.c | 0
> .../cavium-octeon/executive}/cvmx-helper-board.c | 18 +--
> .../cavium-octeon/executive}/cvmx-helper-fpa.c | 0
> .../cavium-octeon/executive}/cvmx-helper-loop.c | 6 +-
> .../cavium-octeon/executive}/cvmx-helper-npi.c | 6 +-
> .../cavium-octeon/executive}/cvmx-helper-rgmii.c | 17 +-
> .../cavium-octeon/executive}/cvmx-helper-sgmii.c | 12 +-
> .../cavium-octeon/executive}/cvmx-helper-spi.c | 10 +-
> .../cavium-octeon/executive}/cvmx-helper-util.c | 16 +-
> .../cavium-octeon/executive}/cvmx-helper-xaui.c | 10 +-
> .../mips/cavium-octeon/executive}/cvmx-helper.c | 27 ++--
> .../executive}/cvmx-interrupt-decodes.c | 10 +-
> .../cavium-octeon/executive}/cvmx-interrupt-rsl.c | 4 +-
> .../mips/cavium-octeon/executive}/cvmx-pko.c | 6 +-
> .../mips/cavium-octeon/executive}/cvmx-spi.c | 12 +-
> .../mips/include/asm}/octeon/cvmx-address.h | 0
> .../mips/include/asm}/octeon/cvmx-asxx-defs.h | 0
> .../mips/include/asm}/octeon/cvmx-cmd-queue.h | 0
> .../mips/include/asm}/octeon/cvmx-config.h | 0
> .../mips/include/asm}/octeon/cvmx-dbg-defs.h | 0
> .../mips/include/asm}/octeon/cvmx-fau.h | 0
> .../mips/include/asm}/octeon/cvmx-fpa-defs.h | 0
> .../mips/include/asm}/octeon/cvmx-fpa.h | 0
> .../mips/include/asm}/octeon/cvmx-gmxx-defs.h | 0
> .../mips/include/asm}/octeon/cvmx-helper-board.h | 0
> .../mips/include/asm}/octeon/cvmx-helper-fpa.h | 0
> .../mips/include/asm}/octeon/cvmx-helper-loop.h | 0
> .../mips/include/asm}/octeon/cvmx-helper-npi.h | 0
> .../mips/include/asm}/octeon/cvmx-helper-rgmii.h | 0
> .../mips/include/asm}/octeon/cvmx-helper-sgmii.h | 0
> .../mips/include/asm}/octeon/cvmx-helper-spi.h | 0
> .../mips/include/asm}/octeon/cvmx-helper-util.h | 0
> .../mips/include/asm}/octeon/cvmx-helper-xaui.h | 0
> .../mips/include/asm}/octeon/cvmx-helper.h | 0
> .../mips/include/asm}/octeon/cvmx-ipd.h | 0
> .../mips/include/asm}/octeon/cvmx-mdio.h | 0
> .../mips/include/asm}/octeon/cvmx-pcsx-defs.h | 0
> .../mips/include/asm}/octeon/cvmx-pcsxx-defs.h | 0
> .../mips/include/asm}/octeon/cvmx-pip-defs.h | 0
> .../mips/include/asm}/octeon/cvmx-pip.h | 0
> .../mips/include/asm}/octeon/cvmx-pko-defs.h | 0
> .../mips/include/asm}/octeon/cvmx-pko.h | 0
> .../mips/include/asm}/octeon/cvmx-pow.h | 0
> .../mips/include/asm}/octeon/cvmx-scratch.h | 0
> .../mips/include/asm}/octeon/cvmx-spi.h | 0
> .../mips/include/asm}/octeon/cvmx-spxx-defs.h | 0
> .../mips/include/asm}/octeon/cvmx-srxx-defs.h | 0
> .../mips/include/asm}/octeon/cvmx-stxx-defs.h | 0
> .../mips/include/asm}/octeon/cvmx-wqe.h | 0
> drivers/staging/octeon/Makefile | 5 -
> drivers/staging/octeon/cvmx-packet.h | 65 -------
> drivers/staging/octeon/cvmx-smix-defs.h | 178 --------------------
> drivers/staging/octeon/ethernet-defines.h | 2 +-
> drivers/staging/octeon/ethernet-mdio.c | 4 +-
> drivers/staging/octeon/ethernet-mem.c | 2 +-
> drivers/staging/octeon/ethernet-rgmii.c | 4 +-
> drivers/staging/octeon/ethernet-rx.c | 14 +-
> drivers/staging/octeon/ethernet-rx.h | 2 +-
> drivers/staging/octeon/ethernet-sgmii.c | 4 +-
> drivers/staging/octeon/ethernet-spi.c | 6 +-
> drivers/staging/octeon/ethernet-tx.c | 12 +-
> drivers/staging/octeon/ethernet-xaui.c | 4 +-
> drivers/staging/octeon/ethernet.c | 14 +-
> 65 files changed, 116 insertions(+), 367 deletions(-)
> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-cmd-queue.c (98%)
> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-fpa.c (100%)
> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-board.c (98%)
> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-fpa.c (100%)
> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-loop.c (95%)
> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-npi.c (96%)
> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-rgmii.c (97%)
> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-sgmii.c (98%)
> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-spi.c (97%)
> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-util.c (97%)
> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-xaui.c (98%)
> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper.c (98%)
> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-interrupt-decodes.c (98%)
> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-interrupt-rsl.c (97%)
> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-pko.c (99%)
> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-spi.c (99%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-address.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-asxx-defs.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-cmd-queue.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-config.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-dbg-defs.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-fau.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-fpa-defs.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-fpa.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-gmxx-defs.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-board.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-fpa.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-loop.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-npi.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-rgmii.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-sgmii.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-spi.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-util.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-xaui.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-ipd.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-mdio.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pcsx-defs.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pcsxx-defs.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pip-defs.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pip.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pko-defs.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pko.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pow.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-scratch.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-spi.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-spxx-defs.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-srxx-defs.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-stxx-defs.h (100%)
> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-wqe.h (100%)
> delete mode 100644 drivers/staging/octeon/cvmx-packet.h
> delete mode 100644 drivers/staging/octeon/cvmx-smix-defs.h
>
> diff --git a/arch/mips/cavium-octeon/executive/Makefile b/arch/mips/cavium-octeon/executive/Makefile
> index 7f41c5b..eec0b88 100644
> --- a/arch/mips/cavium-octeon/executive/Makefile
> +++ b/arch/mips/cavium-octeon/executive/Makefile
> @@ -10,5 +10,10 @@
> #
>
> obj-y += cvmx-bootmem.o cvmx-l2c.o cvmx-sysinfo.o octeon-model.o
> +obj-y += cvmx-pko.o cvmx-spi.o cvmx-cmd-queue.o \
> + cvmx-helper-board.o cvmx-helper.o cvmx-helper-xaui.o \
> + cvmx-helper-rgmii.o cvmx-helper-sgmii.o cvmx-helper-npi.o \
> + cvmx-helper-loop.o cvmx-helper-spi.o cvmx-helper-util.o \
> + cvmx-interrupt-decodes.o cvmx-interrupt-rsl.o
>
> obj-$(CONFIG_CAVIUM_OCTEON_HELPER) += cvmx-helper-errata.o cvmx-helper-jtag.o
> diff --git a/drivers/staging/octeon/cvmx-cmd-queue.c b/arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c
> similarity index 98%
> rename from drivers/staging/octeon/cvmx-cmd-queue.c
> rename to arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c
> index e9809d3..132bccc 100644
> --- a/drivers/staging/octeon/cvmx-cmd-queue.c
> +++ b/arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c
> @@ -34,13 +34,13 @@
>
> #include <asm/octeon/octeon.h>
>
> -#include "cvmx-config.h"
> -#include "cvmx-fpa.h"
> -#include "cvmx-cmd-queue.h"
> +#include <asm/octeon/cvmx-config.h>
> +#include <asm/octeon/cvmx-fpa.h>
> +#include <asm/octeon/cvmx-cmd-queue.h>
>
> #include <asm/octeon/cvmx-npei-defs.h>
> #include <asm/octeon/cvmx-pexp-defs.h>
> -#include "cvmx-pko-defs.h"
> +#include <asm/octeon/cvmx-pko-defs.h>
>
> /**
> * This application uses this pointer to access the global queue
> diff --git a/drivers/staging/octeon/cvmx-fpa.c b/arch/mips/cavium-octeon/executive/cvmx-fpa.c
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-fpa.c
> rename to arch/mips/cavium-octeon/executive/cvmx-fpa.c
> diff --git a/drivers/staging/octeon/cvmx-helper-board.c b/arch/mips/cavium-octeon/executive/cvmx-helper-board.c
> similarity index 98%
> rename from drivers/staging/octeon/cvmx-helper-board.c
> rename to arch/mips/cavium-octeon/executive/cvmx-helper-board.c
> index 57d35dc..71590a3 100644
> --- a/drivers/staging/octeon/cvmx-helper-board.c
> +++ b/arch/mips/cavium-octeon/executive/cvmx-helper-board.c
> @@ -34,16 +34,16 @@
> #include <asm/octeon/octeon.h>
> #include <asm/octeon/cvmx-bootinfo.h>
>
> -#include "cvmx-config.h"
> +#include <asm/octeon/cvmx-config.h>
>
> -#include "cvmx-mdio.h"
> +#include <asm/octeon/cvmx-mdio.h>
>
> -#include "cvmx-helper.h"
> -#include "cvmx-helper-util.h"
> -#include "cvmx-helper-board.h"
> +#include <asm/octeon/cvmx-helper.h>
> +#include <asm/octeon/cvmx-helper-util.h>
> +#include <asm/octeon/cvmx-helper-board.h>
>
> -#include "cvmx-gmxx-defs.h"
> -#include "cvmx-asxx-defs.h"
> +#include <asm/octeon/cvmx-gmxx-defs.h>
> +#include <asm/octeon/cvmx-asxx-defs.h>
>
> /**
> * cvmx_override_board_link_get(int ipd_port) is a function
> @@ -493,7 +493,6 @@ int cvmx_helper_board_link_set_phy(int phy_addr,
> cvmx_mdio_phy_reg_control_t reg_control;
> cvmx_mdio_phy_reg_status_t reg_status;
> cvmx_mdio_phy_reg_autoneg_adver_t reg_autoneg_adver;
> - cvmx_mdio_phy_reg_extended_status_t reg_extended_status;
> cvmx_mdio_phy_reg_control_1000_t reg_control_1000;
>
> reg_status.u16 =
> @@ -508,9 +507,6 @@ int cvmx_helper_board_link_set_phy(int phy_addr,
> reg_autoneg_adver.s.advert_100base_tx_full = 0;
> reg_autoneg_adver.s.advert_100base_tx_half = 0;
> if (reg_status.s.capable_extended_status) {
> - reg_extended_status.u16 =
> - cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff,
> - CVMX_MDIO_PHY_REG_EXTENDED_STATUS);
> reg_control_1000.u16 =
> cvmx_mdio_read(phy_addr >> 8, phy_addr & 0xff,
> CVMX_MDIO_PHY_REG_CONTROL_1000);
> diff --git a/drivers/staging/octeon/cvmx-helper-fpa.c b/arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-helper-fpa.c
> rename to arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c
> diff --git a/drivers/staging/octeon/cvmx-helper-loop.c b/arch/mips/cavium-octeon/executive/cvmx-helper-loop.c
> similarity index 95%
> rename from drivers/staging/octeon/cvmx-helper-loop.c
> rename to arch/mips/cavium-octeon/executive/cvmx-helper-loop.c
> index 55a571a..bfbd461 100644
> --- a/drivers/staging/octeon/cvmx-helper-loop.c
> +++ b/arch/mips/cavium-octeon/executive/cvmx-helper-loop.c
> @@ -31,10 +31,10 @@
> */
> #include <asm/octeon/octeon.h>
>
> -#include "cvmx-config.h"
> +#include <asm/octeon/cvmx-config.h>
>
> -#include "cvmx-helper.h"
> -#include "cvmx-pip-defs.h"
> +#include <asm/octeon/cvmx-helper.h>
> +#include <asm/octeon/cvmx-pip-defs.h>
>
> /**
> * Probe a LOOP interface and determine the number of ports
> diff --git a/drivers/staging/octeon/cvmx-helper-npi.c b/arch/mips/cavium-octeon/executive/cvmx-helper-npi.c
> similarity index 96%
> rename from drivers/staging/octeon/cvmx-helper-npi.c
> rename to arch/mips/cavium-octeon/executive/cvmx-helper-npi.c
> index 7388a1e..cc94cfa 100644
> --- a/drivers/staging/octeon/cvmx-helper-npi.c
> +++ b/arch/mips/cavium-octeon/executive/cvmx-helper-npi.c
> @@ -31,11 +31,11 @@
> */
> #include <asm/octeon/octeon.h>
>
> -#include "cvmx-config.h"
> +#include <asm/octeon/cvmx-config.h>
>
> -#include "cvmx-helper.h"
> +#include <asm/octeon/cvmx-helper.h>
>
> -#include "cvmx-pip-defs.h"
> +#include <asm/octeon/cvmx-pip-defs.h>
>
> /**
> * Probe a NPI interface and determine the number of ports
> diff --git a/drivers/staging/octeon/cvmx-helper-rgmii.c b/arch/mips/cavium-octeon/executive/cvmx-helper-rgmii.c
> similarity index 97%
> rename from drivers/staging/octeon/cvmx-helper-rgmii.c
> rename to arch/mips/cavium-octeon/executive/cvmx-helper-rgmii.c
> index aa2d5d7..82b2184 100644
> --- a/drivers/staging/octeon/cvmx-helper-rgmii.c
> +++ b/arch/mips/cavium-octeon/executive/cvmx-helper-rgmii.c
> @@ -31,18 +31,18 @@
> */
> #include <asm/octeon/octeon.h>
>
> -#include "cvmx-config.h"
> +#include <asm/octeon/cvmx-config.h>
>
>
> -#include "cvmx-mdio.h"
> -#include "cvmx-pko.h"
> -#include "cvmx-helper.h"
> -#include "cvmx-helper-board.h"
> +#include <asm/octeon/cvmx-mdio.h>
> +#include <asm/octeon/cvmx-pko.h>
> +#include <asm/octeon/cvmx-helper.h>
> +#include <asm/octeon/cvmx-helper-board.h>
>
> #include <asm/octeon/cvmx-npi-defs.h>
> -#include "cvmx-gmxx-defs.h"
> -#include "cvmx-asxx-defs.h"
> -#include "cvmx-dbg-defs.h"
> +#include <asm/octeon/cvmx-gmxx-defs.h>
> +#include <asm/octeon/cvmx-asxx-defs.h>
> +#include <asm/octeon/cvmx-dbg-defs.h>
>
> void __cvmx_interrupt_gmxx_enable(int interface);
> void __cvmx_interrupt_asxx_enable(int block);
> @@ -326,6 +326,7 @@ int __cvmx_helper_rgmii_link_set(int ipd_port,
> cvmx_read_csr(CVMX_ASXX_RX_PRT_EN(interface)) &
> ~(1 << index));
>
> + memset(pko_mem_queue_qos_save, 0, sizeof(pko_mem_queue_qos_save));
> /* Disable all queues so that TX should become idle */
> for (i = 0; i < cvmx_pko_get_num_queues(ipd_port); i++) {
> int queue = cvmx_pko_get_base_queue(ipd_port) + i;
> diff --git a/drivers/staging/octeon/cvmx-helper-sgmii.c b/arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c
> similarity index 98%
> rename from drivers/staging/octeon/cvmx-helper-sgmii.c
> rename to arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c
> index 6214e3b..464347f 100644
> --- a/drivers/staging/octeon/cvmx-helper-sgmii.c
> +++ b/arch/mips/cavium-octeon/executive/cvmx-helper-sgmii.c
> @@ -32,14 +32,14 @@
>
> #include <asm/octeon/octeon.h>
>
> -#include "cvmx-config.h"
> +#include <asm/octeon/cvmx-config.h>
>
> -#include "cvmx-mdio.h"
> -#include "cvmx-helper.h"
> -#include "cvmx-helper-board.h"
> +#include <asm/octeon/cvmx-mdio.h>
> +#include <asm/octeon/cvmx-helper.h>
> +#include <asm/octeon/cvmx-helper-board.h>
>
> -#include "cvmx-gmxx-defs.h"
> -#include "cvmx-pcsx-defs.h"
> +#include <asm/octeon/cvmx-gmxx-defs.h>
> +#include <asm/octeon/cvmx-pcsx-defs.h>
>
> void __cvmx_interrupt_gmxx_enable(int interface);
> void __cvmx_interrupt_pcsx_intx_en_reg_enable(int index, int block);
> diff --git a/drivers/staging/octeon/cvmx-helper-spi.c b/arch/mips/cavium-octeon/executive/cvmx-helper-spi.c
> similarity index 97%
> rename from drivers/staging/octeon/cvmx-helper-spi.c
> rename to arch/mips/cavium-octeon/executive/cvmx-helper-spi.c
> index 8ba6c83..02a4442 100644
> --- a/drivers/staging/octeon/cvmx-helper-spi.c
> +++ b/arch/mips/cavium-octeon/executive/cvmx-helper-spi.c
> @@ -35,12 +35,12 @@ void __cvmx_interrupt_stxx_int_msk_enable(int index);
> */
> #include <asm/octeon/octeon.h>
>
> -#include "cvmx-config.h"
> -#include "cvmx-spi.h"
> -#include "cvmx-helper.h"
> +#include <asm/octeon/cvmx-config.h>
> +#include <asm/octeon/cvmx-spi.h>
> +#include <asm/octeon/cvmx-helper.h>
>
> -#include "cvmx-pip-defs.h"
> -#include "cvmx-pko-defs.h"
> +#include <asm/octeon/cvmx-pip-defs.h>
> +#include <asm/octeon/cvmx-pko-defs.h>
>
> /*
> * CVMX_HELPER_SPI_TIMEOUT is used to determine how long the SPI
> diff --git a/drivers/staging/octeon/cvmx-helper-util.c b/arch/mips/cavium-octeon/executive/cvmx-helper-util.c
> similarity index 97%
> rename from drivers/staging/octeon/cvmx-helper-util.c
> rename to arch/mips/cavium-octeon/executive/cvmx-helper-util.c
> index 41ef8a4..8c98a22 100644
> --- a/drivers/staging/octeon/cvmx-helper-util.c
> +++ b/arch/mips/cavium-octeon/executive/cvmx-helper-util.c
> @@ -32,16 +32,16 @@
>
> #include <asm/octeon/octeon.h>
>
> -#include "cvmx-config.h"
> +#include <asm/octeon/cvmx-config.h>
>
> -#include "cvmx-fpa.h"
> -#include "cvmx-pip.h"
> -#include "cvmx-pko.h"
> -#include "cvmx-ipd.h"
> -#include "cvmx-spi.h"
> +#include <asm/octeon/cvmx-fpa.h>
> +#include <asm/octeon/cvmx-pip.h>
> +#include <asm/octeon/cvmx-pko.h>
> +#include <asm/octeon/cvmx-ipd.h>
> +#include <asm/octeon/cvmx-spi.h>
>
> -#include "cvmx-helper.h"
> -#include "cvmx-helper-util.h"
> +#include <asm/octeon/cvmx-helper.h>
> +#include <asm/octeon/cvmx-helper-util.h>
>
> #include <asm/octeon/cvmx-ipd-defs.h>
>
> diff --git a/drivers/staging/octeon/cvmx-helper-xaui.c b/arch/mips/cavium-octeon/executive/cvmx-helper-xaui.c
> similarity index 98%
> rename from drivers/staging/octeon/cvmx-helper-xaui.c
> rename to arch/mips/cavium-octeon/executive/cvmx-helper-xaui.c
> index a11e676..667a8e3 100644
> --- a/drivers/staging/octeon/cvmx-helper-xaui.c
> +++ b/arch/mips/cavium-octeon/executive/cvmx-helper-xaui.c
> @@ -33,13 +33,13 @@
>
> #include <asm/octeon/octeon.h>
>
> -#include "cvmx-config.h"
> +#include <asm/octeon/cvmx-config.h>
>
> -#include "cvmx-helper.h"
> +#include <asm/octeon/cvmx-helper.h>
>
> -#include "cvmx-pko-defs.h"
> -#include "cvmx-gmxx-defs.h"
> -#include "cvmx-pcsxx-defs.h"
> +#include <asm/octeon/cvmx-pko-defs.h>
> +#include <asm/octeon/cvmx-gmxx-defs.h>
> +#include <asm/octeon/cvmx-pcsxx-defs.h>
>
> void __cvmx_interrupt_gmxx_enable(int interface);
> void __cvmx_interrupt_pcsx_intx_en_reg_enable(int index, int block);
> diff --git a/drivers/staging/octeon/cvmx-helper.c b/arch/mips/cavium-octeon/executive/cvmx-helper.c
> similarity index 98%
> rename from drivers/staging/octeon/cvmx-helper.c
> rename to arch/mips/cavium-octeon/executive/cvmx-helper.c
> index 5915066..6238a22 100644
> --- a/drivers/staging/octeon/cvmx-helper.c
> +++ b/arch/mips/cavium-octeon/executive/cvmx-helper.c
> @@ -32,19 +32,19 @@
> */
> #include <asm/octeon/octeon.h>
>
> -#include "cvmx-config.h"
> +#include <asm/octeon/cvmx-config.h>
>
> -#include "cvmx-fpa.h"
> -#include "cvmx-pip.h"
> -#include "cvmx-pko.h"
> -#include "cvmx-ipd.h"
> -#include "cvmx-spi.h"
> -#include "cvmx-helper.h"
> -#include "cvmx-helper-board.h"
> +#include <asm/octeon/cvmx-fpa.h>
> +#include <asm/octeon/cvmx-pip.h>
> +#include <asm/octeon/cvmx-pko.h>
> +#include <asm/octeon/cvmx-ipd.h>
> +#include <asm/octeon/cvmx-spi.h>
> +#include <asm/octeon/cvmx-helper.h>
> +#include <asm/octeon/cvmx-helper-board.h>
>
> -#include "cvmx-pip-defs.h"
> -#include "cvmx-smix-defs.h"
> -#include "cvmx-asxx-defs.h"
> +#include <asm/octeon/cvmx-pip-defs.h>
> +#include <asm/octeon/cvmx-smix-defs.h>
> +#include <asm/octeon/cvmx-asxx-defs.h>
>
> /**
> * cvmx_override_pko_queue_priority(int ipd_port, uint64_t
> @@ -548,7 +548,6 @@ int __cvmx_helper_errata_fix_ipd_ptr_alignment(void)
> union cvmx_gmxx_prtx_cfg gmx_cfg;
> int retry_cnt;
> int retry_loop_cnt;
> - int mtu;
> int i;
> cvmx_helper_link_info_t link_info;
>
> @@ -662,10 +661,6 @@ int __cvmx_helper_errata_fix_ipd_ptr_alignment(void)
> cvmx_write_csr(CVMX_ASXX_RX_PRT_EN(INTERFACE(FIX_IPD_OUTPORT)),
> 1 << INDEX(FIX_IPD_OUTPORT));
>
> - mtu =
> - cvmx_read_csr(CVMX_GMXX_RXX_JABBER
> - (INDEX(FIX_IPD_OUTPORT),
> - INTERFACE(FIX_IPD_OUTPORT)));
> cvmx_write_csr(CVMX_GMXX_RXX_JABBER
> (INDEX(FIX_IPD_OUTPORT),
> INTERFACE(FIX_IPD_OUTPORT)), 65392 - 14 - 4);
> diff --git a/drivers/staging/octeon/cvmx-interrupt-decodes.c b/arch/mips/cavium-octeon/executive/cvmx-interrupt-decodes.c
> similarity index 98%
> rename from drivers/staging/octeon/cvmx-interrupt-decodes.c
> rename to arch/mips/cavium-octeon/executive/cvmx-interrupt-decodes.c
> index a3337e3..e59d1b7 100644
> --- a/drivers/staging/octeon/cvmx-interrupt-decodes.c
> +++ b/arch/mips/cavium-octeon/executive/cvmx-interrupt-decodes.c
> @@ -34,11 +34,11 @@
>
> #include <asm/octeon/octeon.h>
>
> -#include "cvmx-gmxx-defs.h"
> -#include "cvmx-pcsx-defs.h"
> -#include "cvmx-pcsxx-defs.h"
> -#include "cvmx-spxx-defs.h"
> -#include "cvmx-stxx-defs.h"
> +#include <asm/octeon/cvmx-gmxx-defs.h>
> +#include <asm/octeon/cvmx-pcsx-defs.h>
> +#include <asm/octeon/cvmx-pcsxx-defs.h>
> +#include <asm/octeon/cvmx-spxx-defs.h>
> +#include <asm/octeon/cvmx-stxx-defs.h>
>
> #ifndef PRINT_ERROR
> #define PRINT_ERROR(format, ...)
> diff --git a/drivers/staging/octeon/cvmx-interrupt-rsl.c b/arch/mips/cavium-octeon/executive/cvmx-interrupt-rsl.c
> similarity index 97%
> rename from drivers/staging/octeon/cvmx-interrupt-rsl.c
> rename to arch/mips/cavium-octeon/executive/cvmx-interrupt-rsl.c
> index df50048..bea7538 100644
> --- a/drivers/staging/octeon/cvmx-interrupt-rsl.c
> +++ b/arch/mips/cavium-octeon/executive/cvmx-interrupt-rsl.c
> @@ -32,8 +32,8 @@
>
> #include <asm/octeon/octeon.h>
>
> -#include "cvmx-asxx-defs.h"
> -#include "cvmx-gmxx-defs.h"
> +#include <asm/octeon/cvmx-asxx-defs.h>
> +#include <asm/octeon/cvmx-gmxx-defs.h>
>
> #ifndef PRINT_ERROR
> #define PRINT_ERROR(format, ...)
> diff --git a/drivers/staging/octeon/cvmx-pko.c b/arch/mips/cavium-octeon/executive/cvmx-pko.c
> similarity index 99%
> rename from drivers/staging/octeon/cvmx-pko.c
> rename to arch/mips/cavium-octeon/executive/cvmx-pko.c
> index 00db915..f557084 100644
> --- a/drivers/staging/octeon/cvmx-pko.c
> +++ b/arch/mips/cavium-octeon/executive/cvmx-pko.c
> @@ -31,9 +31,9 @@
>
> #include <asm/octeon/octeon.h>
>
> -#include "cvmx-config.h"
> -#include "cvmx-pko.h"
> -#include "cvmx-helper.h"
> +#include <asm/octeon/cvmx-config.h>
> +#include <asm/octeon/cvmx-pko.h>
> +#include <asm/octeon/cvmx-helper.h>
>
> /**
> * Internal state of packet output
> diff --git a/drivers/staging/octeon/cvmx-spi.c b/arch/mips/cavium-octeon/executive/cvmx-spi.c
> similarity index 99%
> rename from drivers/staging/octeon/cvmx-spi.c
> rename to arch/mips/cavium-octeon/executive/cvmx-spi.c
> index 82794d9..74afb17 100644
> --- a/drivers/staging/octeon/cvmx-spi.c
> +++ b/arch/mips/cavium-octeon/executive/cvmx-spi.c
> @@ -31,14 +31,14 @@
> */
> #include <asm/octeon/octeon.h>
>
> -#include "cvmx-config.h"
> +#include <asm/octeon/cvmx-config.h>
>
> -#include "cvmx-pko.h"
> -#include "cvmx-spi.h"
> +#include <asm/octeon/cvmx-pko.h>
> +#include <asm/octeon/cvmx-spi.h>
>
> -#include "cvmx-spxx-defs.h"
> -#include "cvmx-stxx-defs.h"
> -#include "cvmx-srxx-defs.h"
> +#include <asm/octeon/cvmx-spxx-defs.h>
> +#include <asm/octeon/cvmx-stxx-defs.h>
> +#include <asm/octeon/cvmx-srxx-defs.h>
>
> #define INVOKE_CB(function_p, args...) \
> do { \
> diff --git a/drivers/staging/octeon/cvmx-address.h b/arch/mips/include/asm/octeon/cvmx-address.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-address.h
> rename to arch/mips/include/asm/octeon/cvmx-address.h
> diff --git a/drivers/staging/octeon/cvmx-asxx-defs.h b/arch/mips/include/asm/octeon/cvmx-asxx-defs.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-asxx-defs.h
> rename to arch/mips/include/asm/octeon/cvmx-asxx-defs.h
> diff --git a/drivers/staging/octeon/cvmx-cmd-queue.h b/arch/mips/include/asm/octeon/cvmx-cmd-queue.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-cmd-queue.h
> rename to arch/mips/include/asm/octeon/cvmx-cmd-queue.h
> diff --git a/drivers/staging/octeon/cvmx-config.h b/arch/mips/include/asm/octeon/cvmx-config.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-config.h
> rename to arch/mips/include/asm/octeon/cvmx-config.h
> diff --git a/drivers/staging/octeon/cvmx-dbg-defs.h b/arch/mips/include/asm/octeon/cvmx-dbg-defs.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-dbg-defs.h
> rename to arch/mips/include/asm/octeon/cvmx-dbg-defs.h
> diff --git a/drivers/staging/octeon/cvmx-fau.h b/arch/mips/include/asm/octeon/cvmx-fau.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-fau.h
> rename to arch/mips/include/asm/octeon/cvmx-fau.h
> diff --git a/drivers/staging/octeon/cvmx-fpa-defs.h b/arch/mips/include/asm/octeon/cvmx-fpa-defs.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-fpa-defs.h
> rename to arch/mips/include/asm/octeon/cvmx-fpa-defs.h
> diff --git a/drivers/staging/octeon/cvmx-fpa.h b/arch/mips/include/asm/octeon/cvmx-fpa.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-fpa.h
> rename to arch/mips/include/asm/octeon/cvmx-fpa.h
> diff --git a/drivers/staging/octeon/cvmx-gmxx-defs.h b/arch/mips/include/asm/octeon/cvmx-gmxx-defs.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-gmxx-defs.h
> rename to arch/mips/include/asm/octeon/cvmx-gmxx-defs.h
> diff --git a/drivers/staging/octeon/cvmx-helper-board.h b/arch/mips/include/asm/octeon/cvmx-helper-board.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-helper-board.h
> rename to arch/mips/include/asm/octeon/cvmx-helper-board.h
> diff --git a/drivers/staging/octeon/cvmx-helper-fpa.h b/arch/mips/include/asm/octeon/cvmx-helper-fpa.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-helper-fpa.h
> rename to arch/mips/include/asm/octeon/cvmx-helper-fpa.h
> diff --git a/drivers/staging/octeon/cvmx-helper-loop.h b/arch/mips/include/asm/octeon/cvmx-helper-loop.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-helper-loop.h
> rename to arch/mips/include/asm/octeon/cvmx-helper-loop.h
> diff --git a/drivers/staging/octeon/cvmx-helper-npi.h b/arch/mips/include/asm/octeon/cvmx-helper-npi.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-helper-npi.h
> rename to arch/mips/include/asm/octeon/cvmx-helper-npi.h
> diff --git a/drivers/staging/octeon/cvmx-helper-rgmii.h b/arch/mips/include/asm/octeon/cvmx-helper-rgmii.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-helper-rgmii.h
> rename to arch/mips/include/asm/octeon/cvmx-helper-rgmii.h
> diff --git a/drivers/staging/octeon/cvmx-helper-sgmii.h b/arch/mips/include/asm/octeon/cvmx-helper-sgmii.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-helper-sgmii.h
> rename to arch/mips/include/asm/octeon/cvmx-helper-sgmii.h
> diff --git a/drivers/staging/octeon/cvmx-helper-spi.h b/arch/mips/include/asm/octeon/cvmx-helper-spi.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-helper-spi.h
> rename to arch/mips/include/asm/octeon/cvmx-helper-spi.h
> diff --git a/drivers/staging/octeon/cvmx-helper-util.h b/arch/mips/include/asm/octeon/cvmx-helper-util.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-helper-util.h
> rename to arch/mips/include/asm/octeon/cvmx-helper-util.h
> diff --git a/drivers/staging/octeon/cvmx-helper-xaui.h b/arch/mips/include/asm/octeon/cvmx-helper-xaui.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-helper-xaui.h
> rename to arch/mips/include/asm/octeon/cvmx-helper-xaui.h
> diff --git a/drivers/staging/octeon/cvmx-helper.h b/arch/mips/include/asm/octeon/cvmx-helper.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-helper.h
> rename to arch/mips/include/asm/octeon/cvmx-helper.h
> diff --git a/drivers/staging/octeon/cvmx-ipd.h b/arch/mips/include/asm/octeon/cvmx-ipd.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-ipd.h
> rename to arch/mips/include/asm/octeon/cvmx-ipd.h
> diff --git a/drivers/staging/octeon/cvmx-mdio.h b/arch/mips/include/asm/octeon/cvmx-mdio.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-mdio.h
> rename to arch/mips/include/asm/octeon/cvmx-mdio.h
> diff --git a/drivers/staging/octeon/cvmx-pcsx-defs.h b/arch/mips/include/asm/octeon/cvmx-pcsx-defs.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-pcsx-defs.h
> rename to arch/mips/include/asm/octeon/cvmx-pcsx-defs.h
> diff --git a/drivers/staging/octeon/cvmx-pcsxx-defs.h b/arch/mips/include/asm/octeon/cvmx-pcsxx-defs.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-pcsxx-defs.h
> rename to arch/mips/include/asm/octeon/cvmx-pcsxx-defs.h
> diff --git a/drivers/staging/octeon/cvmx-pip-defs.h b/arch/mips/include/asm/octeon/cvmx-pip-defs.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-pip-defs.h
> rename to arch/mips/include/asm/octeon/cvmx-pip-defs.h
> diff --git a/drivers/staging/octeon/cvmx-pip.h b/arch/mips/include/asm/octeon/cvmx-pip.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-pip.h
> rename to arch/mips/include/asm/octeon/cvmx-pip.h
> diff --git a/drivers/staging/octeon/cvmx-pko-defs.h b/arch/mips/include/asm/octeon/cvmx-pko-defs.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-pko-defs.h
> rename to arch/mips/include/asm/octeon/cvmx-pko-defs.h
> diff --git a/drivers/staging/octeon/cvmx-pko.h b/arch/mips/include/asm/octeon/cvmx-pko.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-pko.h
> rename to arch/mips/include/asm/octeon/cvmx-pko.h
> diff --git a/drivers/staging/octeon/cvmx-pow.h b/arch/mips/include/asm/octeon/cvmx-pow.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-pow.h
> rename to arch/mips/include/asm/octeon/cvmx-pow.h
> diff --git a/drivers/staging/octeon/cvmx-scratch.h b/arch/mips/include/asm/octeon/cvmx-scratch.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-scratch.h
> rename to arch/mips/include/asm/octeon/cvmx-scratch.h
> diff --git a/drivers/staging/octeon/cvmx-spi.h b/arch/mips/include/asm/octeon/cvmx-spi.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-spi.h
> rename to arch/mips/include/asm/octeon/cvmx-spi.h
> diff --git a/drivers/staging/octeon/cvmx-spxx-defs.h b/arch/mips/include/asm/octeon/cvmx-spxx-defs.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-spxx-defs.h
> rename to arch/mips/include/asm/octeon/cvmx-spxx-defs.h
> diff --git a/drivers/staging/octeon/cvmx-srxx-defs.h b/arch/mips/include/asm/octeon/cvmx-srxx-defs.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-srxx-defs.h
> rename to arch/mips/include/asm/octeon/cvmx-srxx-defs.h
> diff --git a/drivers/staging/octeon/cvmx-stxx-defs.h b/arch/mips/include/asm/octeon/cvmx-stxx-defs.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-stxx-defs.h
> rename to arch/mips/include/asm/octeon/cvmx-stxx-defs.h
> diff --git a/drivers/staging/octeon/cvmx-wqe.h b/arch/mips/include/asm/octeon/cvmx-wqe.h
> similarity index 100%
> rename from drivers/staging/octeon/cvmx-wqe.h
> rename to arch/mips/include/asm/octeon/cvmx-wqe.h
> diff --git a/drivers/staging/octeon/Makefile b/drivers/staging/octeon/Makefile
> index fc850ba..9012dee 100644
> --- a/drivers/staging/octeon/Makefile
> +++ b/drivers/staging/octeon/Makefile
> @@ -20,9 +20,4 @@ octeon-ethernet-y += ethernet-sgmii.o
> octeon-ethernet-y += ethernet-spi.o
> octeon-ethernet-y += ethernet-tx.o
> octeon-ethernet-y += ethernet-xaui.o
> -octeon-ethernet-y += cvmx-pko.o cvmx-spi.o cvmx-cmd-queue.o \
> - cvmx-helper-board.o cvmx-helper.o cvmx-helper-xaui.o \
> - cvmx-helper-rgmii.o cvmx-helper-sgmii.o cvmx-helper-npi.o \
> - cvmx-helper-loop.o cvmx-helper-spi.o cvmx-helper-util.o \
> - cvmx-interrupt-decodes.o cvmx-interrupt-rsl.o
>
> diff --git a/drivers/staging/octeon/cvmx-packet.h b/drivers/staging/octeon/cvmx-packet.h
> deleted file mode 100644
> index 62ffe78..0000000
> --- a/drivers/staging/octeon/cvmx-packet.h
> +++ /dev/null
> @@ -1,65 +0,0 @@
> -/***********************license start***************
> - * Author: Cavium Networks
> - *
> - * Contact: [email protected]
> - * This file is part of the OCTEON SDK
> - *
> - * Copyright (c) 2003-2008 Cavium Networks
> - *
> - * This file is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License, Version 2, as
> - * published by the Free Software Foundation.
> - *
> - * This file is distributed in the hope that it will be useful, but
> - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
> - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
> - * NONINFRINGEMENT. See the GNU General Public License for more
> - * details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this file; if not, write to the Free Software
> - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> - * or visit http://www.gnu.org/licenses/.
> - *
> - * This file may also be available under a different license from Cavium.
> - * Contact Cavium Networks for more information
> - ***********************license end**************************************/
> -
> -/**
> - *
> - * Packet buffer defines.
> - */
> -
> -#ifndef __CVMX_PACKET_H__
> -#define __CVMX_PACKET_H__
> -
> -/**
> - * This structure defines a buffer pointer on Octeon
> - */
> -union cvmx_buf_ptr {
> - void *ptr;
> - uint64_t u64;
> - struct {
> - /*
> - * if set, invert the "free" pick of the overall
> - * packet. HW always sets this bit to 0 on inbound
> - * packet
> - */
> - uint64_t i:1;
> - /*
> - * Indicates the amount to back up to get to the
> - * buffer start in cache lines. In most cases this is
> - * less than one complete cache line, so the value is
> - * zero.
> - */
> - uint64_t back:4;
> - /* The pool that the buffer came from / goes to */
> - uint64_t pool:3;
> - /* The size of the segment pointed to by addr (in bytes) */
> - uint64_t size:16;
> - /* Pointer to the first byte of the data, NOT buffer */
> - uint64_t addr:40;
> - } s;
> -};
> -
> -#endif /* __CVMX_PACKET_H__ */
> diff --git a/drivers/staging/octeon/cvmx-smix-defs.h b/drivers/staging/octeon/cvmx-smix-defs.h
> deleted file mode 100644
> index 9ae45fc..0000000
> --- a/drivers/staging/octeon/cvmx-smix-defs.h
> +++ /dev/null
> @@ -1,178 +0,0 @@
> -/***********************license start***************
> - * Author: Cavium Networks
> - *
> - * Contact: [email protected]
> - * This file is part of the OCTEON SDK
> - *
> - * Copyright (c) 2003-2008 Cavium Networks
> - *
> - * This file is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License, Version 2, as
> - * published by the Free Software Foundation.
> - *
> - * This file is distributed in the hope that it will be useful, but
> - * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
> - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
> - * NONINFRINGEMENT. See the GNU General Public License for more
> - * details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this file; if not, write to the Free Software
> - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> - * or visit http://www.gnu.org/licenses/.
> - *
> - * This file may also be available under a different license from Cavium.
> - * Contact Cavium Networks for more information
> - ***********************license end**************************************/
> -
> -#ifndef __CVMX_SMIX_DEFS_H__
> -#define __CVMX_SMIX_DEFS_H__
> -
> -#define CVMX_SMIX_CLK(offset) \
> - CVMX_ADD_IO_SEG(0x0001180000001818ull + (((offset) & 1) * 256))
> -#define CVMX_SMIX_CMD(offset) \
> - CVMX_ADD_IO_SEG(0x0001180000001800ull + (((offset) & 1) * 256))
> -#define CVMX_SMIX_EN(offset) \
> - CVMX_ADD_IO_SEG(0x0001180000001820ull + (((offset) & 1) * 256))
> -#define CVMX_SMIX_RD_DAT(offset) \
> - CVMX_ADD_IO_SEG(0x0001180000001810ull + (((offset) & 1) * 256))
> -#define CVMX_SMIX_WR_DAT(offset) \
> - CVMX_ADD_IO_SEG(0x0001180000001808ull + (((offset) & 1) * 256))
> -
> -union cvmx_smix_clk {
> - uint64_t u64;
> - struct cvmx_smix_clk_s {
> - uint64_t reserved_25_63:39;
> - uint64_t mode:1;
> - uint64_t reserved_21_23:3;
> - uint64_t sample_hi:5;
> - uint64_t sample_mode:1;
> - uint64_t reserved_14_14:1;
> - uint64_t clk_idle:1;
> - uint64_t preamble:1;
> - uint64_t sample:4;
> - uint64_t phase:8;
> - } s;
> - struct cvmx_smix_clk_cn30xx {
> - uint64_t reserved_21_63:43;
> - uint64_t sample_hi:5;
> - uint64_t reserved_14_15:2;
> - uint64_t clk_idle:1;
> - uint64_t preamble:1;
> - uint64_t sample:4;
> - uint64_t phase:8;
> - } cn30xx;
> - struct cvmx_smix_clk_cn30xx cn31xx;
> - struct cvmx_smix_clk_cn30xx cn38xx;
> - struct cvmx_smix_clk_cn30xx cn38xxp2;
> - struct cvmx_smix_clk_cn50xx {
> - uint64_t reserved_25_63:39;
> - uint64_t mode:1;
> - uint64_t reserved_21_23:3;
> - uint64_t sample_hi:5;
> - uint64_t reserved_14_15:2;
> - uint64_t clk_idle:1;
> - uint64_t preamble:1;
> - uint64_t sample:4;
> - uint64_t phase:8;
> - } cn50xx;
> - struct cvmx_smix_clk_s cn52xx;
> - struct cvmx_smix_clk_cn50xx cn52xxp1;
> - struct cvmx_smix_clk_s cn56xx;
> - struct cvmx_smix_clk_cn50xx cn56xxp1;
> - struct cvmx_smix_clk_cn30xx cn58xx;
> - struct cvmx_smix_clk_cn30xx cn58xxp1;
> -};
> -
> -union cvmx_smix_cmd {
> - uint64_t u64;
> - struct cvmx_smix_cmd_s {
> - uint64_t reserved_18_63:46;
> - uint64_t phy_op:2;
> - uint64_t reserved_13_15:3;
> - uint64_t phy_adr:5;
> - uint64_t reserved_5_7:3;
> - uint64_t reg_adr:5;
> - } s;
> - struct cvmx_smix_cmd_cn30xx {
> - uint64_t reserved_17_63:47;
> - uint64_t phy_op:1;
> - uint64_t reserved_13_15:3;
> - uint64_t phy_adr:5;
> - uint64_t reserved_5_7:3;
> - uint64_t reg_adr:5;
> - } cn30xx;
> - struct cvmx_smix_cmd_cn30xx cn31xx;
> - struct cvmx_smix_cmd_cn30xx cn38xx;
> - struct cvmx_smix_cmd_cn30xx cn38xxp2;
> - struct cvmx_smix_cmd_s cn50xx;
> - struct cvmx_smix_cmd_s cn52xx;
> - struct cvmx_smix_cmd_s cn52xxp1;
> - struct cvmx_smix_cmd_s cn56xx;
> - struct cvmx_smix_cmd_s cn56xxp1;
> - struct cvmx_smix_cmd_cn30xx cn58xx;
> - struct cvmx_smix_cmd_cn30xx cn58xxp1;
> -};
> -
> -union cvmx_smix_en {
> - uint64_t u64;
> - struct cvmx_smix_en_s {
> - uint64_t reserved_1_63:63;
> - uint64_t en:1;
> - } s;
> - struct cvmx_smix_en_s cn30xx;
> - struct cvmx_smix_en_s cn31xx;
> - struct cvmx_smix_en_s cn38xx;
> - struct cvmx_smix_en_s cn38xxp2;
> - struct cvmx_smix_en_s cn50xx;
> - struct cvmx_smix_en_s cn52xx;
> - struct cvmx_smix_en_s cn52xxp1;
> - struct cvmx_smix_en_s cn56xx;
> - struct cvmx_smix_en_s cn56xxp1;
> - struct cvmx_smix_en_s cn58xx;
> - struct cvmx_smix_en_s cn58xxp1;
> -};
> -
> -union cvmx_smix_rd_dat {
> - uint64_t u64;
> - struct cvmx_smix_rd_dat_s {
> - uint64_t reserved_18_63:46;
> - uint64_t pending:1;
> - uint64_t val:1;
> - uint64_t dat:16;
> - } s;
> - struct cvmx_smix_rd_dat_s cn30xx;
> - struct cvmx_smix_rd_dat_s cn31xx;
> - struct cvmx_smix_rd_dat_s cn38xx;
> - struct cvmx_smix_rd_dat_s cn38xxp2;
> - struct cvmx_smix_rd_dat_s cn50xx;
> - struct cvmx_smix_rd_dat_s cn52xx;
> - struct cvmx_smix_rd_dat_s cn52xxp1;
> - struct cvmx_smix_rd_dat_s cn56xx;
> - struct cvmx_smix_rd_dat_s cn56xxp1;
> - struct cvmx_smix_rd_dat_s cn58xx;
> - struct cvmx_smix_rd_dat_s cn58xxp1;
> -};
> -
> -union cvmx_smix_wr_dat {
> - uint64_t u64;
> - struct cvmx_smix_wr_dat_s {
> - uint64_t reserved_18_63:46;
> - uint64_t pending:1;
> - uint64_t val:1;
> - uint64_t dat:16;
> - } s;
> - struct cvmx_smix_wr_dat_s cn30xx;
> - struct cvmx_smix_wr_dat_s cn31xx;
> - struct cvmx_smix_wr_dat_s cn38xx;
> - struct cvmx_smix_wr_dat_s cn38xxp2;
> - struct cvmx_smix_wr_dat_s cn50xx;
> - struct cvmx_smix_wr_dat_s cn52xx;
> - struct cvmx_smix_wr_dat_s cn52xxp1;
> - struct cvmx_smix_wr_dat_s cn56xx;
> - struct cvmx_smix_wr_dat_s cn56xxp1;
> - struct cvmx_smix_wr_dat_s cn58xx;
> - struct cvmx_smix_wr_dat_s cn58xxp1;
> -};
> -
> -#endif
> diff --git a/drivers/staging/octeon/ethernet-defines.h b/drivers/staging/octeon/ethernet-defines.h
> index 6a2cd50..bdaec8d 100644
> --- a/drivers/staging/octeon/ethernet-defines.h
> +++ b/drivers/staging/octeon/ethernet-defines.h
> @@ -59,7 +59,7 @@
> #ifndef __ETHERNET_DEFINES_H__
> #define __ETHERNET_DEFINES_H__
>
> -#include "cvmx-config.h"
> +#include <asm/octeon/cvmx-config.h>
>
>
> #define OCTEON_ETHERNET_VERSION "1.9"
> diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c
> index 10a82ef..0e5dab7 100644
> --- a/drivers/staging/octeon/ethernet-mdio.c
> +++ b/drivers/staging/octeon/ethernet-mdio.c
> @@ -37,9 +37,9 @@
> #include "ethernet-mdio.h"
> #include "ethernet-util.h"
>
> -#include "cvmx-helper-board.h"
> +#include <asm/octeon/cvmx-helper-board.h>
>
> -#include "cvmx-smix-defs.h"
> +#include <asm/octeon/cvmx-smix-defs.h>
>
> static void cvm_oct_get_drvinfo(struct net_device *dev,
> struct ethtool_drvinfo *info)
> diff --git a/drivers/staging/octeon/ethernet-mem.c b/drivers/staging/octeon/ethernet-mem.c
> index 635bb86..78b6cb7 100644
> --- a/drivers/staging/octeon/ethernet-mem.c
> +++ b/drivers/staging/octeon/ethernet-mem.c
> @@ -32,7 +32,7 @@
>
> #include "ethernet-defines.h"
>
> -#include "cvmx-fpa.h"
> +#include <asm/octeon/cvmx-fpa.h>
>
> /**
> * cvm_oct_fill_hw_skbuff - fill the supplied hardware pool with skbuffs
> diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c
> index a0d4d4b..849af10 100644
> --- a/drivers/staging/octeon/ethernet-rgmii.c
> +++ b/drivers/staging/octeon/ethernet-rgmii.c
> @@ -35,11 +35,11 @@
> #include "octeon-ethernet.h"
> #include "ethernet-util.h"
>
> -#include "cvmx-helper.h"
> +#include <asm/octeon/cvmx-helper.h>
>
> #include <asm/octeon/cvmx-ipd-defs.h>
> #include <asm/octeon/cvmx-npi-defs.h>
> -#include "cvmx-gmxx-defs.h"
> +#include <asm/octeon/cvmx-gmxx-defs.h>
>
> DEFINE_SPINLOCK(global_register_lock);
>
> diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
> index cb38f9e..d830393 100644
> --- a/drivers/staging/octeon/ethernet-rx.c
> +++ b/drivers/staging/octeon/ethernet-rx.c
> @@ -51,14 +51,14 @@
> #include "octeon-ethernet.h"
> #include "ethernet-util.h"
>
> -#include "cvmx-helper.h"
> -#include "cvmx-wqe.h"
> -#include "cvmx-fau.h"
> -#include "cvmx-pow.h"
> -#include "cvmx-pip.h"
> -#include "cvmx-scratch.h"
> -
> -#include "cvmx-gmxx-defs.h"
> +#include <asm/octeon/cvmx-helper.h>
> +#include <asm/octeon/cvmx-wqe.h>
> +#include <asm/octeon/cvmx-fau.h>
> +#include <asm/octeon/cvmx-pow.h>
> +#include <asm/octeon/cvmx-pip.h>
> +#include <asm/octeon/cvmx-scratch.h>
> +
> +#include <asm/octeon/cvmx-gmxx-defs.h>
>
> struct cvm_napi_wrapper {
> struct napi_struct napi;
> diff --git a/drivers/staging/octeon/ethernet-rx.h b/drivers/staging/octeon/ethernet-rx.h
> index a0743b8..9240c85 100644
> --- a/drivers/staging/octeon/ethernet-rx.h
> +++ b/drivers/staging/octeon/ethernet-rx.h
> @@ -24,7 +24,7 @@
> * This file may also be available under a different license from Cavium.
> * Contact Cavium Networks for more information
> *********************************************************************/
> -#include "cvmx-fau.h"
> +#include <asm/octeon/cvmx-fau.h>
>
> void cvm_oct_poll_controller(struct net_device *dev);
> void cvm_oct_rx_initialize(void);
> diff --git a/drivers/staging/octeon/ethernet-sgmii.c b/drivers/staging/octeon/ethernet-sgmii.c
> index 2d8589e..d102277 100644
> --- a/drivers/staging/octeon/ethernet-sgmii.c
> +++ b/drivers/staging/octeon/ethernet-sgmii.c
> @@ -34,9 +34,9 @@
> #include "octeon-ethernet.h"
> #include "ethernet-util.h"
>
> -#include "cvmx-helper.h"
> +#include <asm/octeon/cvmx-helper.h>
>
> -#include "cvmx-gmxx-defs.h"
> +#include <asm/octeon/cvmx-gmxx-defs.h>
>
> int cvm_oct_sgmii_open(struct net_device *dev)
> {
> diff --git a/drivers/staging/octeon/ethernet-spi.c b/drivers/staging/octeon/ethernet-spi.c
> index 9708254..2ce9135 100644
> --- a/drivers/staging/octeon/ethernet-spi.c
> +++ b/drivers/staging/octeon/ethernet-spi.c
> @@ -34,11 +34,11 @@
> #include "octeon-ethernet.h"
> #include "ethernet-util.h"
>
> -#include "cvmx-spi.h"
> +#include <asm/octeon/cvmx-spi.h>
>
> #include <asm/octeon/cvmx-npi-defs.h>
> -#include "cvmx-spxx-defs.h"
> -#include "cvmx-stxx-defs.h"
> +#include <asm/octeon/cvmx-spxx-defs.h>
> +#include <asm/octeon/cvmx-stxx-defs.h>
>
> static int number_spi_ports;
> static int need_retrain[2] = { 0, 0 };
> diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c
> index afc2b73..1f03eb6 100644
> --- a/drivers/staging/octeon/ethernet-tx.c
> +++ b/drivers/staging/octeon/ethernet-tx.c
> @@ -46,13 +46,13 @@
> #include "ethernet-tx.h"
> #include "ethernet-util.h"
>
> -#include "cvmx-wqe.h"
> -#include "cvmx-fau.h"
> -#include "cvmx-pip.h"
> -#include "cvmx-pko.h"
> -#include "cvmx-helper.h"
> +#include <asm/octeon/cvmx-wqe.h>
> +#include <asm/octeon/cvmx-fau.h>
> +#include <asm/octeon/cvmx-pip.h>
> +#include <asm/octeon/cvmx-pko.h>
> +#include <asm/octeon/cvmx-helper.h>
>
> -#include "cvmx-gmxx-defs.h"
> +#include <asm/octeon/cvmx-gmxx-defs.h>
>
> #define CVM_OCT_SKB_CB(skb) ((u64 *)((skb)->cb))
>
> diff --git a/drivers/staging/octeon/ethernet-xaui.c b/drivers/staging/octeon/ethernet-xaui.c
> index 3fca1cc..321fafc 100644
> --- a/drivers/staging/octeon/ethernet-xaui.c
> +++ b/drivers/staging/octeon/ethernet-xaui.c
> @@ -34,9 +34,9 @@
> #include "octeon-ethernet.h"
> #include "ethernet-util.h"
>
> -#include "cvmx-helper.h"
> +#include <asm/octeon/cvmx-helper.h>
>
> -#include "cvmx-gmxx-defs.h"
> +#include <asm/octeon/cvmx-gmxx-defs.h>
>
> int cvm_oct_xaui_open(struct net_device *dev)
> {
> diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
> index a8f780e..042adf7 100644
> --- a/drivers/staging/octeon/ethernet.c
> +++ b/drivers/staging/octeon/ethernet.c
> @@ -44,14 +44,14 @@
> #include "ethernet-mdio.h"
> #include "ethernet-util.h"
>
> -#include "cvmx-pip.h"
> -#include "cvmx-pko.h"
> -#include "cvmx-fau.h"
> -#include "cvmx-ipd.h"
> -#include "cvmx-helper.h"
> -
> -#include "cvmx-gmxx-defs.h"
> -#include "cvmx-smix-defs.h"
> +#include <asm/octeon/cvmx-pip.h>
> +#include <asm/octeon/cvmx-pko.h>
> +#include <asm/octeon/cvmx-fau.h>
> +#include <asm/octeon/cvmx-ipd.h>
> +#include <asm/octeon/cvmx-helper.h>
> +
> +#include <asm/octeon/cvmx-gmxx-defs.h>
> +#include <asm/octeon/cvmx-smix-defs.h>
>
> #if defined(CONFIG_CAVIUM_OCTEON_NUM_PACKET_BUFFERS) \
> && CONFIG_CAVIUM_OCTEON_NUM_PACKET_BUFFERS
> --
> 1.7.2.3
>
On Tue, Feb 22, 2011 at 12:57:51PM -0800, David Daney wrote:
> Signed-off-by: David Daney <[email protected]>
> Cc: "Jean Delvare (PC drivers, core)" <[email protected]>
> Cc: "Ben Dooks (embedded platforms)" <[email protected]>
> Cc: [email protected]
> ---
> arch/mips/cavium-octeon/octeon-platform.c | 84 ---------------------------
> arch/mips/include/asm/octeon/octeon.h | 5 --
> drivers/i2c/busses/i2c-octeon.c | 88 +++++++++++++---------------
> 3 files changed, 41 insertions(+), 136 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c
> index 56dbe54..99a20c6 100644
> --- a/drivers/i2c/busses/i2c-octeon.c
> +++ b/drivers/i2c/busses/i2c-octeon.c
> @@ -11,17 +11,21 @@
> * warranty of any kind, whether express or implied.
> */
>
> +#include <linux/platform_device.h>
> +#include <linux/of_platform.h>
> +#include <linux/of_address.h>
> +#include <linux/interrupt.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> +#include <linux/of_irq.h>
> +#include <linux/of_i2c.h>
Nit: generally the of_*.h headers are kept together. Also this patch
probably won't need of_address.h or of_irq.h after addressing my
comments below.
> +#include <linux/delay.h>
> #include <linux/sched.h>
> #include <linux/slab.h>
> #include <linux/init.h>
> -
> -#include <linux/io.h>
> #include <linux/i2c.h>
> -#include <linux/interrupt.h>
> -#include <linux/delay.h>
> -#include <linux/platform_device.h>
> +#include <linux/io.h>
> +#include <linux/of.h>
>
> #include <asm/octeon/octeon.h>
>
> @@ -67,9 +71,7 @@ struct octeon_i2c {
> int irq;
> int twsi_freq;
> int sys_freq;
> - resource_size_t twsi_phys;
> void __iomem *twsi_base;
> - resource_size_t regsize;
> struct device *dev;
> };
>
> @@ -511,17 +513,18 @@ static int __devinit octeon_i2c_initlowlevel(struct octeon_i2c *i2c)
> return -EIO;
> }
>
> -static int __devinit octeon_i2c_probe(struct platform_device *pdev)
> +static int __devinit octeon_i2c_probe(struct platform_device *pdev,
> + const struct of_device_id *match)
> {
> int irq, result = 0;
> struct octeon_i2c *i2c;
> - struct octeon_i2c_data *i2c_data;
> - struct resource *res_mem;
> + const __be32 *data;
> + int len;
>
> /* All adaptors have an irq. */
> - irq = platform_get_irq(pdev, 0);
> - if (irq < 0)
> - return irq;
> + irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
> + if (!irq)
> + return -ENXIO;
Platform_get_irq() works for dt registered devices, this hunk can be
dropped.
>
> i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
> if (!i2c) {
> @@ -530,32 +533,16 @@ static int __devinit octeon_i2c_probe(struct platform_device *pdev)
> goto out;
> }
> i2c->dev = &pdev->dev;
> - i2c_data = pdev->dev.platform_data;
> -
> - res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -
> - if (res_mem == NULL) {
> - dev_err(i2c->dev, "found no memory resource\n");
> - result = -ENXIO;
> - goto fail_region;
> - }
Ditto for platform_get_resource()
>
> - if (i2c_data == NULL) {
> - dev_err(i2c->dev, "no I2C frequency data\n");
> - result = -ENXIO;
> - goto fail_region;
> - }
> + data = of_get_property(pdev->dev.of_node, "clock-rate", &len);
> + if (data && len == sizeof(*data))
> + i2c->twsi_freq = be32_to_cpup(data);
> + else
> + i2c->twsi_freq = 100000;
Seems to me that if the clock-rate (although it should be called
clock-frequency) property is not present, the driver should complain
loudly and refuse to load. Don't fudge it.
>
> - i2c->twsi_phys = res_mem->start;
> - i2c->regsize = resource_size(res_mem);
> - i2c->twsi_freq = i2c_data->i2c_freq;
> - i2c->sys_freq = i2c_data->sys_freq;
> + i2c->sys_freq = octeon_get_io_clock_rate();
>
> - if (!request_mem_region(i2c->twsi_phys, i2c->regsize, res_mem->name)) {
> - dev_err(i2c->dev, "request_mem_region failed\n");
> - goto fail_region;
> - }
> - i2c->twsi_base = ioremap(i2c->twsi_phys, i2c->regsize);
> + i2c->twsi_base = of_iomap(pdev->dev.of_node, 0);
This hunk can also be dropped.
>
> init_waitqueue_head(&i2c->queue);
>
> @@ -581,27 +568,27 @@ static int __devinit octeon_i2c_probe(struct platform_device *pdev)
>
> i2c->adap = octeon_i2c_ops;
> i2c->adap.dev.parent = &pdev->dev;
> - i2c->adap.nr = pdev->id >= 0 ? pdev->id : 0;
> + i2c->adap.dev.of_node = pdev->dev.of_node;
> i2c_set_adapdata(&i2c->adap, i2c);
> platform_set_drvdata(pdev, i2c);
>
> - result = i2c_add_numbered_adapter(&i2c->adap);
> + result = i2c_add_adapter(&i2c->adap);
> if (result < 0) {
> dev_err(i2c->dev, "failed to add adapter\n");
> goto fail_add;
> }
> -
> dev_info(i2c->dev, "version %s\n", DRV_VERSION);
>
> - return result;
> + of_i2c_register_devices(&i2c->adap);
> +
> + return 0;
>
> fail_add:
> platform_set_drvdata(pdev, NULL);
> free_irq(i2c->irq, i2c);
> fail_irq:
> iounmap(i2c->twsi_base);
> - release_mem_region(i2c->twsi_phys, i2c->regsize);
> -fail_region:
> +
> kfree(i2c);
> out:
> return result;
> @@ -615,17 +602,25 @@ static int __devexit octeon_i2c_remove(struct platform_device *pdev)
> platform_set_drvdata(pdev, NULL);
> free_irq(i2c->irq, i2c);
> iounmap(i2c->twsi_base);
> - release_mem_region(i2c->twsi_phys, i2c->regsize);
> kfree(i2c);
> return 0;
> };
>
> -static struct platform_driver octeon_i2c_driver = {
> +static struct of_device_id octeon_i2c_match[] = {
> + {
> + .compatible = "octeon,twsi",
Need documentation for this binding added to
Documentation/devicetree/bindings. Compatible values for SoC devices
should generally be in the form "<vendor>,<soc-name>-<device-name>".
> + },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, octeon_i2c_match);
> +
> +static struct of_platform_driver octeon_i2c_driver = {
of_platform_driver is deprecated. As long as the .of_match_table is
populated, a normal platform_driver will just work.
> .probe = octeon_i2c_probe,
> .remove = __devexit_p(octeon_i2c_remove),
> .driver = {
> .owner = THIS_MODULE,
> .name = DRV_NAME,
> + .of_match_table = octeon_i2c_match,
> },
> };
>
> @@ -633,20 +628,19 @@ static int __init octeon_i2c_init(void)
> {
> int rv;
>
> - rv = platform_driver_register(&octeon_i2c_driver);
> + rv = of_register_platform_driver(&octeon_i2c_driver);
Drop this change.
On that note, this routine is typically simplified to:
+ {
+ return platform_driver_register(&octeon_i2c_driver);
+ }
>
> static void __exit octeon_i2c_exit(void)
> {
> - platform_driver_unregister(&octeon_i2c_driver);
> + of_unregister_platform_driver(&octeon_i2c_driver);
Drop this hunk.
> }
>
> MODULE_AUTHOR("Michael Lawnick <[email protected]>");
> MODULE_DESCRIPTION("I2C-Bus adapter for Cavium OCTEON processors");
> MODULE_LICENSE("GPL");
> MODULE_VERSION(DRV_VERSION);
> -MODULE_ALIAS("platform:" DRV_NAME);
>
> module_init(octeon_i2c_init);
> module_exit(octeon_i2c_exit);
> --
> 1.7.2.3
>
On Tue, Feb 22, 2011 at 12:57:53PM -0800, David Daney wrote:
> 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.
>
> Signed-off-by: David Daney <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: [email protected]
> ---
> arch/mips/cavium-octeon/octeon-platform.c | 62 -------
> drivers/net/octeon/octeon_mgmt.c | 265 +++++++++++++++++------------
> 2 files changed, 160 insertions(+), 167 deletions(-)
>
> diff --git a/drivers/net/octeon/octeon_mgmt.c b/drivers/net/octeon/octeon_mgmt.c
> index b264f0f..6c301c7 100644
> --- a/drivers/net/octeon/octeon_mgmt.c
> +++ b/drivers/net/octeon/octeon_mgmt.c
> @@ -6,16 +6,21 @@
> * Copyright (C) 2009 Cavium Networks
> */
>
> -#include <linux/capability.h>
> -#include <linux/dma-mapping.h>
> -#include <linux/init.h>
> #include <linux/platform_device.h>
> -#include <linux/netdevice.h>
> +#include <linux/dma-mapping.h>
> #include <linux/etherdevice.h>
> +#include <linux/of_platform.h>
> +#include <linux/capability.h>
> +#include <linux/of_address.h>
> +#include <linux/netdevice.h>
> +#include <linux/spinlock.h>
> #include <linux/if_vlan.h>
> +#include <linux/of_mdio.h>
> +#include <linux/of_irq.h>
> +#include <linux/of_net.h>
> +#include <linux/init.h>
> #include <linux/slab.h>
> #include <linux/phy.h>
> -#include <linux/spinlock.h>
>
> #include <asm/octeon/octeon.h>
> #include <asm/octeon/cvmx-mixx-defs.h>
> @@ -55,8 +60,56 @@ union mgmt_port_ring_entry {
> } s;
> };
>
> +#define MIX_ORING1 0x0
> +#define MIX_ORING2 0x8
> +#define MIX_IRING1 0x10
> +#define MIX_IRING2 0x18
> +#define MIX_CTL 0x20
> +#define MIX_IRHWM 0x28
> +#define MIX_IRCNT 0x30
> +#define MIX_ORHWM 0x38
> +#define MIX_ORCNT 0x40
> +#define MIX_ISR 0x48
> +#define MIX_INTENA 0x50
> +#define MIX_REMCNT 0x58
> +#define MIX_BIST 0x78
> +
> +#define AGL_GMX_PRT_CFG 0x10
> +#define AGL_GMX_RX_FRM_CTL 0x18
> +#define AGL_GMX_RX_FRM_MAX 0x30
> +#define AGL_GMX_RX_JABBER 0x38
> +#define AGL_GMX_RX_STATS_CTL 0x50
> +
> +#define AGL_GMX_RX_STATS_PKTS_DRP 0xb0
> +#define AGL_GMX_RX_STATS_OCTS_DRP 0xb8
> +#define AGL_GMX_RX_STATS_PKTS_BAD 0xc0
> +
> +#define AGL_GMX_RX_ADR_CTL 0x100
> +#define AGL_GMX_RX_ADR_CAM_EN 0x108
> +#define AGL_GMX_RX_ADR_CAM0 0x180
> +#define AGL_GMX_RX_ADR_CAM1 0x188
> +#define AGL_GMX_RX_ADR_CAM2 0x190
> +#define AGL_GMX_RX_ADR_CAM3 0x198
> +#define AGL_GMX_RX_ADR_CAM4 0x1a0
> +#define AGL_GMX_RX_ADR_CAM5 0x1a8
> +
> +#define AGL_GMX_TX_STATS_CTL 0x268
> +#define AGL_GMX_TX_CTL 0x270
> +#define AGL_GMX_TX_STAT0 0x280
> +#define AGL_GMX_TX_STAT1 0x288
> +#define AGL_GMX_TX_STAT2 0x290
> +#define AGL_GMX_TX_STAT3 0x298
> +#define AGL_GMX_TX_STAT4 0x2a0
> +#define AGL_GMX_TX_STAT5 0x2a8
> +#define AGL_GMX_TX_STAT6 0x2b0
> +#define AGL_GMX_TX_STAT7 0x2b8
> +#define AGL_GMX_TX_STAT8 0x2c0
> +#define AGL_GMX_TX_STAT9 0x2c8
> +
> struct octeon_mgmt {
> struct net_device *netdev;
> + u64 mix;
> + u64 agl;
> int port;
> int irq;
> u64 *tx_ring;
> @@ -82,31 +135,30 @@ struct octeon_mgmt {
> struct napi_struct napi;
> struct tasklet_struct tx_clean_tasklet;
> struct phy_device *phydev;
> + struct device_node *phy_np;
> };
>
> static void octeon_mgmt_set_rx_irq(struct octeon_mgmt *p, int enable)
> {
> - int port = p->port;
> union cvmx_mixx_intena mix_intena;
> unsigned long flags;
>
> spin_lock_irqsave(&p->lock, flags);
> - mix_intena.u64 = cvmx_read_csr(CVMX_MIXX_INTENA(port));
> + mix_intena.u64 = cvmx_read_csr(p->mix + MIX_INTENA);
> mix_intena.s.ithena = enable ? 1 : 0;
> - cvmx_write_csr(CVMX_MIXX_INTENA(port), mix_intena.u64);
> + cvmx_write_csr(p->mix + MIX_INTENA, mix_intena.u64);
> spin_unlock_irqrestore(&p->lock, flags);
> }
>
> static void octeon_mgmt_set_tx_irq(struct octeon_mgmt *p, int enable)
> {
> - int port = p->port;
> union cvmx_mixx_intena mix_intena;
> unsigned long flags;
>
> spin_lock_irqsave(&p->lock, flags);
> - mix_intena.u64 = cvmx_read_csr(CVMX_MIXX_INTENA(port));
> + mix_intena.u64 = cvmx_read_csr(p->mix + MIX_INTENA);
> mix_intena.s.othena = enable ? 1 : 0;
> - cvmx_write_csr(CVMX_MIXX_INTENA(port), mix_intena.u64);
> + cvmx_write_csr(p->mix + MIX_INTENA, mix_intena.u64);
> spin_unlock_irqrestore(&p->lock, flags);
> }
>
> @@ -143,7 +195,6 @@ static unsigned int ring_size_to_bytes(unsigned int ring_size)
> static void octeon_mgmt_rx_fill_ring(struct net_device *netdev)
> {
> struct octeon_mgmt *p = netdev_priv(netdev);
> - int port = p->port;
>
> while (p->rx_current_fill < ring_max_fill(OCTEON_MGMT_RX_RING_SIZE)) {
> unsigned int size;
> @@ -174,24 +225,23 @@ static void octeon_mgmt_rx_fill_ring(struct net_device *netdev)
> (p->rx_next_fill + 1) % OCTEON_MGMT_RX_RING_SIZE;
> p->rx_current_fill++;
> /* Ring the bell. */
> - cvmx_write_csr(CVMX_MIXX_IRING2(port), 1);
> + cvmx_write_csr(p->mix + MIX_IRING2, 1);
> }
> }
>
> static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p)
> {
> - int port = p->port;
> union cvmx_mixx_orcnt mix_orcnt;
> union mgmt_port_ring_entry re;
> struct sk_buff *skb;
> int cleaned = 0;
> unsigned long flags;
>
> - mix_orcnt.u64 = cvmx_read_csr(CVMX_MIXX_ORCNT(port));
> + mix_orcnt.u64 = cvmx_read_csr(p->mix + MIX_ORCNT);
> while (mix_orcnt.s.orcnt) {
> spin_lock_irqsave(&p->tx_list.lock, flags);
>
> - mix_orcnt.u64 = cvmx_read_csr(CVMX_MIXX_ORCNT(port));
> + mix_orcnt.u64 = cvmx_read_csr(p->mix + MIX_ORCNT);
>
> if (mix_orcnt.s.orcnt == 0) {
> spin_unlock_irqrestore(&p->tx_list.lock, flags);
> @@ -211,7 +261,7 @@ static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p)
> mix_orcnt.s.orcnt = 1;
>
> /* Acknowledge to hardware that we have the buffer. */
> - cvmx_write_csr(CVMX_MIXX_ORCNT(port), mix_orcnt.u64);
> + cvmx_write_csr(p->mix + MIX_ORCNT, mix_orcnt.u64);
> p->tx_current_fill--;
>
> spin_unlock_irqrestore(&p->tx_list.lock, flags);
> @@ -221,7 +271,7 @@ static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p)
> dev_kfree_skb_any(skb);
> cleaned++;
>
> - mix_orcnt.u64 = cvmx_read_csr(CVMX_MIXX_ORCNT(port));
> + mix_orcnt.u64 = cvmx_read_csr(p->mix + MIX_ORCNT);
> }
>
> if (cleaned && netif_queue_stopped(p->netdev))
> @@ -238,13 +288,12 @@ static void octeon_mgmt_clean_tx_tasklet(unsigned long arg)
> static void octeon_mgmt_update_rx_stats(struct net_device *netdev)
> {
> struct octeon_mgmt *p = netdev_priv(netdev);
> - int port = p->port;
> unsigned long flags;
> u64 drop, bad;
>
> /* These reads also clear the count registers. */
> - drop = cvmx_read_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_DRP(port));
> - bad = cvmx_read_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_BAD(port));
> + drop = cvmx_read_csr(p->agl + AGL_GMX_RX_STATS_PKTS_DRP);
> + bad = cvmx_read_csr(p->agl + AGL_GMX_RX_STATS_PKTS_BAD);
>
> if (drop || bad) {
> /* Do an atomic update. */
> @@ -258,15 +307,14 @@ static void octeon_mgmt_update_rx_stats(struct net_device *netdev)
> static void octeon_mgmt_update_tx_stats(struct net_device *netdev)
> {
> struct octeon_mgmt *p = netdev_priv(netdev);
> - int port = p->port;
> unsigned long flags;
>
> union cvmx_agl_gmx_txx_stat0 s0;
> union cvmx_agl_gmx_txx_stat1 s1;
>
> /* These reads also clear the count registers. */
> - s0.u64 = cvmx_read_csr(CVMX_AGL_GMX_TXX_STAT0(port));
> - s1.u64 = cvmx_read_csr(CVMX_AGL_GMX_TXX_STAT1(port));
> + s0.u64 = cvmx_read_csr(p->agl + AGL_GMX_TX_STAT0);
> + s1.u64 = cvmx_read_csr(p->agl + AGL_GMX_TX_STAT1);
>
> if (s0.s.xsdef || s0.s.xscol || s1.s.scol || s1.s.mcol) {
> /* Do an atomic update. */
> @@ -305,7 +353,6 @@ static u64 octeon_mgmt_dequeue_rx_buffer(struct octeon_mgmt *p,
>
> static int octeon_mgmt_receive_one(struct octeon_mgmt *p)
> {
> - int port = p->port;
> struct net_device *netdev = p->netdev;
> union cvmx_mixx_ircnt mix_ircnt;
> union mgmt_port_ring_entry re;
> @@ -378,18 +425,17 @@ done:
> /* Tell the hardware we processed a packet. */
> mix_ircnt.u64 = 0;
> mix_ircnt.s.ircnt = 1;
> - cvmx_write_csr(CVMX_MIXX_IRCNT(port), mix_ircnt.u64);
> + cvmx_write_csr(p->mix + MIX_IRCNT, mix_ircnt.u64);
> return rc;
> }
>
> static int octeon_mgmt_receive_packets(struct octeon_mgmt *p, int budget)
> {
> - int port = p->port;
> unsigned int work_done = 0;
> union cvmx_mixx_ircnt mix_ircnt;
> int rc;
>
> - mix_ircnt.u64 = cvmx_read_csr(CVMX_MIXX_IRCNT(port));
> + mix_ircnt.u64 = cvmx_read_csr(p->mix + MIX_IRCNT);
> while (work_done < budget && mix_ircnt.s.ircnt) {
>
> rc = octeon_mgmt_receive_one(p);
> @@ -397,7 +443,7 @@ static int octeon_mgmt_receive_packets(struct octeon_mgmt *p, int budget)
> work_done++;
>
> /* Check for more packets. */
> - mix_ircnt.u64 = cvmx_read_csr(CVMX_MIXX_IRCNT(port));
> + mix_ircnt.u64 = cvmx_read_csr(p->mix + MIX_IRCNT);
> }
>
> octeon_mgmt_rx_fill_ring(p->netdev);
> @@ -431,16 +477,16 @@ static void octeon_mgmt_reset_hw(struct octeon_mgmt *p)
> union cvmx_agl_gmx_bist agl_gmx_bist;
>
> mix_ctl.u64 = 0;
> - cvmx_write_csr(CVMX_MIXX_CTL(p->port), mix_ctl.u64);
> + cvmx_write_csr(p->mix + MIX_CTL, mix_ctl.u64);
> do {
> - mix_ctl.u64 = cvmx_read_csr(CVMX_MIXX_CTL(p->port));
> + mix_ctl.u64 = cvmx_read_csr(p->mix + MIX_CTL);
> } while (mix_ctl.s.busy);
> mix_ctl.s.reset = 1;
> - cvmx_write_csr(CVMX_MIXX_CTL(p->port), mix_ctl.u64);
> - cvmx_read_csr(CVMX_MIXX_CTL(p->port));
> + cvmx_write_csr(p->mix + MIX_CTL, mix_ctl.u64);
> + cvmx_read_csr(p->mix + MIX_CTL);
> cvmx_wait(64);
>
> - mix_bist.u64 = cvmx_read_csr(CVMX_MIXX_BIST(p->port));
> + mix_bist.u64 = cvmx_read_csr(p->mix + MIX_BIST);
> if (mix_bist.u64)
> dev_warn(p->dev, "MIX failed BIST (0x%016llx)\n",
> (unsigned long long)mix_bist.u64);
> @@ -471,7 +517,6 @@ static void octeon_mgmt_cam_state_add(struct octeon_mgmt_cam_state *cs,
> static void octeon_mgmt_set_rx_filtering(struct net_device *netdev)
> {
> struct octeon_mgmt *p = netdev_priv(netdev);
> - int port = p->port;
> union cvmx_agl_gmx_rxx_adr_ctl adr_ctl;
> union cvmx_agl_gmx_prtx_cfg agl_gmx_prtx;
> unsigned long flags;
> @@ -517,29 +562,29 @@ static void octeon_mgmt_set_rx_filtering(struct net_device *netdev)
> spin_lock_irqsave(&p->lock, flags);
>
> /* Disable packet I/O. */
> - agl_gmx_prtx.u64 = cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
> + agl_gmx_prtx.u64 = cvmx_read_csr(p->agl + AGL_GMX_PRT_CFG);
> prev_packet_enable = agl_gmx_prtx.s.en;
> agl_gmx_prtx.s.en = 0;
> - cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), agl_gmx_prtx.u64);
> + cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, agl_gmx_prtx.u64);
>
> adr_ctl.u64 = 0;
> adr_ctl.s.cam_mode = cam_mode;
> adr_ctl.s.mcst = multicast_mode;
> adr_ctl.s.bcst = 1; /* Allow broadcast */
>
> - cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CTL(port), adr_ctl.u64);
> + cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CTL, adr_ctl.u64);
>
> - cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM0(port), cam_state.cam[0]);
> - cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM1(port), cam_state.cam[1]);
> - cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM2(port), cam_state.cam[2]);
> - cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM3(port), cam_state.cam[3]);
> - cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM4(port), cam_state.cam[4]);
> - cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM5(port), cam_state.cam[5]);
> - cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM_EN(port), cam_state.cam_mask);
> + cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM0, cam_state.cam[0]);
> + cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM1, cam_state.cam[1]);
> + cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM2, cam_state.cam[2]);
> + cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM3, cam_state.cam[3]);
> + cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM4, cam_state.cam[4]);
> + cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM5, cam_state.cam[5]);
> + cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM_EN, cam_state.cam_mask);
>
> /* Restore packet I/O. */
> agl_gmx_prtx.s.en = prev_packet_enable;
> - cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), agl_gmx_prtx.u64);
> + cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, agl_gmx_prtx.u64);
>
> spin_unlock_irqrestore(&p->lock, flags);
> }
> @@ -561,7 +606,6 @@ static int octeon_mgmt_set_mac_address(struct net_device *netdev, void *addr)
> static int octeon_mgmt_change_mtu(struct net_device *netdev, int new_mtu)
> {
> struct octeon_mgmt *p = netdev_priv(netdev);
> - int port = p->port;
> int size_without_fcs = new_mtu + OCTEON_MGMT_RX_HEADROOM;
>
> /*
> @@ -577,8 +621,8 @@ static int octeon_mgmt_change_mtu(struct net_device *netdev, int new_mtu)
>
> netdev->mtu = new_mtu;
>
> - cvmx_write_csr(CVMX_AGL_GMX_RXX_FRM_MAX(port), size_without_fcs);
> - cvmx_write_csr(CVMX_AGL_GMX_RXX_JABBER(port),
> + cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_MAX, size_without_fcs);
> + cvmx_write_csr(p->agl + AGL_GMX_RX_JABBER,
> (size_without_fcs + 7) & 0xfff8);
>
> return 0;
> @@ -588,14 +632,13 @@ static irqreturn_t octeon_mgmt_interrupt(int cpl, void *dev_id)
> {
> struct net_device *netdev = dev_id;
> struct octeon_mgmt *p = netdev_priv(netdev);
> - int port = p->port;
> union cvmx_mixx_isr mixx_isr;
>
> - mixx_isr.u64 = cvmx_read_csr(CVMX_MIXX_ISR(port));
> + mixx_isr.u64 = cvmx_read_csr(p->mix + MIX_ISR);
>
> /* Clear any pending interrupts */
> - cvmx_write_csr(CVMX_MIXX_ISR(port), mixx_isr.u64);
> - cvmx_read_csr(CVMX_MIXX_ISR(port));
> + cvmx_write_csr(p->mix + MIX_ISR, mixx_isr.u64);
> + cvmx_read_csr(p->mix + MIX_ISR);
>
> if (mixx_isr.s.irthresh) {
> octeon_mgmt_disable_rx_irq(p);
> @@ -626,7 +669,6 @@ static int octeon_mgmt_ioctl(struct net_device *netdev,
> static void octeon_mgmt_adjust_link(struct net_device *netdev)
> {
> struct octeon_mgmt *p = netdev_priv(netdev);
> - int port = p->port;
> union cvmx_agl_gmx_prtx_cfg prtx_cfg;
> unsigned long flags;
> int link_changed = 0;
> @@ -637,11 +679,9 @@ static void octeon_mgmt_adjust_link(struct net_device *netdev)
> link_changed = 1;
> if (p->last_duplex != p->phydev->duplex) {
> p->last_duplex = p->phydev->duplex;
> - prtx_cfg.u64 =
> - cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
> + prtx_cfg.u64 = cvmx_read_csr(p->agl + AGL_GMX_PRT_CFG);
> prtx_cfg.s.duplex = p->phydev->duplex;
> - cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port),
> - prtx_cfg.u64);
> + cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, prtx_cfg.u64);
> }
> } else {
> if (p->last_link)
> @@ -667,18 +707,16 @@ static void octeon_mgmt_adjust_link(struct net_device *netdev)
> static int octeon_mgmt_init_phy(struct net_device *netdev)
> {
> struct octeon_mgmt *p = netdev_priv(netdev);
> - char phy_id[20];
>
> - if (octeon_is_simulation()) {
> + if (octeon_is_simulation() || p->phy_np == NULL) {
> /* No PHYs in the simulator. */
> netif_carrier_on(netdev);
> return 0;
> }
>
> - snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, "0", p->port);
> -
> - p->phydev = phy_connect(netdev, phy_id, octeon_mgmt_adjust_link, 0,
> - PHY_INTERFACE_MODE_MII);
> + p->phydev = of_phy_connect(netdev, p->phy_np,
> + octeon_mgmt_adjust_link, 0,
> + PHY_INTERFACE_MODE_MII);
>
> if (IS_ERR(p->phydev)) {
> p->phydev = NULL;
> @@ -734,14 +772,14 @@ static int octeon_mgmt_open(struct net_device *netdev)
>
> octeon_mgmt_reset_hw(p);
>
> - mix_ctl.u64 = cvmx_read_csr(CVMX_MIXX_CTL(port));
> + mix_ctl.u64 = cvmx_read_csr(p->mix + MIX_CTL);
>
> /* Bring it out of reset if needed. */
> if (mix_ctl.s.reset) {
> mix_ctl.s.reset = 0;
> - cvmx_write_csr(CVMX_MIXX_CTL(port), mix_ctl.u64);
> + cvmx_write_csr(p->mix + MIX_CTL, mix_ctl.u64);
> do {
> - mix_ctl.u64 = cvmx_read_csr(CVMX_MIXX_CTL(port));
> + mix_ctl.u64 = cvmx_read_csr(p->mix + MIX_CTL);
> } while (mix_ctl.s.reset);
> }
>
> @@ -752,17 +790,17 @@ static int octeon_mgmt_open(struct net_device *netdev)
> oring1.u64 = 0;
> oring1.s.obase = p->tx_ring_handle >> 3;
> oring1.s.osize = OCTEON_MGMT_TX_RING_SIZE;
> - cvmx_write_csr(CVMX_MIXX_ORING1(port), oring1.u64);
> + cvmx_write_csr(p->mix + MIX_ORING1, oring1.u64);
>
> iring1.u64 = 0;
> iring1.s.ibase = p->rx_ring_handle >> 3;
> iring1.s.isize = OCTEON_MGMT_RX_RING_SIZE;
> - cvmx_write_csr(CVMX_MIXX_IRING1(port), iring1.u64);
> + cvmx_write_csr(p->mix + MIX_IRING1, iring1.u64);
>
> /* Disable packet I/O. */
> - prtx_cfg.u64 = cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
> + prtx_cfg.u64 = cvmx_read_csr(p->agl + AGL_GMX_PRT_CFG);
> prtx_cfg.s.en = 0;
> - cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), prtx_cfg.u64);
> + cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, prtx_cfg.u64);
>
> memcpy(sa.sa_data, netdev->dev_addr, ETH_ALEN);
> octeon_mgmt_set_mac_address(netdev, &sa);
> @@ -779,7 +817,7 @@ static int octeon_mgmt_open(struct net_device *netdev)
> mix_ctl.s.nbtarb = 0; /* Arbitration mode */
> /* MII CB-request FIFO programmable high watermark */
> mix_ctl.s.mrq_hwm = 1;
> - cvmx_write_csr(CVMX_MIXX_CTL(port), mix_ctl.u64);
> + cvmx_write_csr(p->mix + MIX_CTL, mix_ctl.u64);
>
> if (OCTEON_IS_MODEL(OCTEON_CN56XX_PASS1_X)
> || OCTEON_IS_MODEL(OCTEON_CN52XX_PASS1_X)) {
> @@ -806,16 +844,16 @@ static int octeon_mgmt_open(struct net_device *netdev)
>
> /* Clear statistics. */
> /* Clear on read. */
> - cvmx_write_csr(CVMX_AGL_GMX_RXX_STATS_CTL(port), 1);
> - cvmx_write_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_DRP(port), 0);
> - cvmx_write_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_BAD(port), 0);
> + cvmx_write_csr(p->agl + AGL_GMX_RX_STATS_CTL, 1);
> + cvmx_write_csr(p->agl + AGL_GMX_RX_STATS_PKTS_DRP, 0);
> + cvmx_write_csr(p->agl + AGL_GMX_RX_STATS_PKTS_BAD, 0);
>
> - cvmx_write_csr(CVMX_AGL_GMX_TXX_STATS_CTL(port), 1);
> - cvmx_write_csr(CVMX_AGL_GMX_TXX_STAT0(port), 0);
> - cvmx_write_csr(CVMX_AGL_GMX_TXX_STAT1(port), 0);
> + cvmx_write_csr(p->agl + AGL_GMX_TX_STATS_CTL, 1);
> + cvmx_write_csr(p->agl + AGL_GMX_TX_STAT0, 0);
> + cvmx_write_csr(p->agl + AGL_GMX_TX_STAT1, 0);
>
> /* Clear any pending interrupts */
> - cvmx_write_csr(CVMX_MIXX_ISR(port), cvmx_read_csr(CVMX_MIXX_ISR(port)));
> + cvmx_write_csr(p->mix + MIX_ISR, cvmx_read_csr(p->mix + MIX_ISR));
>
> if (request_irq(p->irq, octeon_mgmt_interrupt, 0, netdev->name,
> netdev)) {
> @@ -826,18 +864,18 @@ static int octeon_mgmt_open(struct net_device *netdev)
> /* Interrupt every single RX packet */
> mix_irhwm.u64 = 0;
> mix_irhwm.s.irhwm = 0;
> - cvmx_write_csr(CVMX_MIXX_IRHWM(port), mix_irhwm.u64);
> + cvmx_write_csr(p->mix + MIX_IRHWM, mix_irhwm.u64);
>
> /* Interrupt when we have 1 or more packets to clean. */
> mix_orhwm.u64 = 0;
> mix_orhwm.s.orhwm = 1;
> - cvmx_write_csr(CVMX_MIXX_ORHWM(port), mix_orhwm.u64);
> + cvmx_write_csr(p->mix + MIX_ORHWM, mix_orhwm.u64);
>
> /* Enable receive and transmit interrupts */
> mix_intena.u64 = 0;
> mix_intena.s.ithena = 1;
> mix_intena.s.othena = 1;
> - cvmx_write_csr(CVMX_MIXX_INTENA(port), mix_intena.u64);
> + cvmx_write_csr(p->mix + MIX_INTENA, mix_intena.u64);
>
>
> /* Enable packet I/O. */
> @@ -868,7 +906,7 @@ static int octeon_mgmt_open(struct net_device *netdev)
> * frame. GMX checks that the PREAMBLE is sent correctly.
> */
> rxx_frm_ctl.s.pre_chk = 1;
> - cvmx_write_csr(CVMX_AGL_GMX_RXX_FRM_CTL(port), rxx_frm_ctl.u64);
> + cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_CTL, rxx_frm_ctl.u64);
>
> /* Enable the AGL block */
> agl_gmx_inf_mode.u64 = 0;
> @@ -876,13 +914,13 @@ static int octeon_mgmt_open(struct net_device *netdev)
> cvmx_write_csr(CVMX_AGL_GMX_INF_MODE, agl_gmx_inf_mode.u64);
>
> /* Configure the port duplex and enables */
> - prtx_cfg.u64 = cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
> + prtx_cfg.u64 = cvmx_read_csr(p->agl + AGL_GMX_PRT_CFG);
> prtx_cfg.s.tx_en = 1;
> prtx_cfg.s.rx_en = 1;
> prtx_cfg.s.en = 1;
> p->last_duplex = 1;
> prtx_cfg.s.duplex = p->last_duplex;
> - cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), prtx_cfg.u64);
> + cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, prtx_cfg.u64);
>
> p->last_link = 0;
> netif_carrier_off(netdev);
> @@ -946,7 +984,6 @@ static int octeon_mgmt_stop(struct net_device *netdev)
> static int octeon_mgmt_xmit(struct sk_buff *skb, struct net_device *netdev)
> {
> struct octeon_mgmt *p = netdev_priv(netdev);
> - int port = p->port;
> union mgmt_port_ring_entry re;
> unsigned long flags;
> int rv = NETDEV_TX_BUSY;
> @@ -990,7 +1027,7 @@ static int octeon_mgmt_xmit(struct sk_buff *skb, struct net_device *netdev)
> netdev->stats.tx_bytes += skb->len;
>
> /* Ring the bell. */
> - cvmx_write_csr(CVMX_MIXX_ORING2(port), 1);
> + cvmx_write_csr(p->mix + MIX_ORING2, 1);
>
> rv = NETDEV_TX_OK;
> out:
> @@ -1067,12 +1104,14 @@ static const struct net_device_ops octeon_mgmt_ops = {
> #endif
> };
>
> -static int __devinit octeon_mgmt_probe(struct platform_device *pdev)
> +static int __devinit octeon_mgmt_probe(struct platform_device *pdev,
> + const struct of_device_id *match)
Same as my comments on the i2c patch; this driver does *not* need to
be converted into an of_platform_driver. Normal platform_driver will
work just fine.
> {
> - struct resource *res_irq;
> struct net_device *netdev;
> struct octeon_mgmt *p;
> - int i;
> + const __be32 *data;
> + const u8 *mac;
> + int len;
>
> netdev = alloc_etherdev(sizeof(struct octeon_mgmt));
> if (netdev == NULL)
> @@ -1086,14 +1125,21 @@ static int __devinit octeon_mgmt_probe(struct platform_device *pdev)
> p->netdev = netdev;
> p->dev = &pdev->dev;
>
> - p->port = pdev->id;
> + data = of_get_property(pdev->dev.of_node, "unit-number", &len);
> + if (data && len == sizeof(*data))
> + p->port = be32_to_cpup(data);
> + else
> + p->port = 0;
Port numbers should be dynamically assigned. If you *really* want to
assign logical names to devices, then add properties to the /aliases
node. unit-number is the sort of thing that causes problems in the
future.
> +
> snprintf(netdev->name, IFNAMSIZ, "mgmt%d", p->port);
>
> - res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> - if (!res_irq)
> + p->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
> + if (!p->irq)
> goto err;
Drop this hunk
>
> - p->irq = res_irq->start;
> + p->mix = (u64)of_iomap(pdev->dev.of_node, 0);
> + p->agl = (u64)of_iomap(pdev->dev.of_node, 1);
> +
> spin_lock_init(&p->lock);
>
> skb_queue_head_init(&p->tx_list);
> @@ -1104,15 +1150,15 @@ static int __devinit octeon_mgmt_probe(struct platform_device *pdev)
> netdev->netdev_ops = &octeon_mgmt_ops;
> netdev->ethtool_ops = &octeon_mgmt_ethtool_ops;
>
> - /* The mgmt ports get the first N MACs. */
> - for (i = 0; i < 6; i++)
> - netdev->dev_addr[i] = octeon_bootinfo->mac_addr_base[i];
> - netdev->dev_addr[5] += p->port;
> + mac = of_get_mac_address(pdev->dev.of_node);
> +
> + if (mac)
> + memcpy(netdev->dev_addr, mac, 6);
>
> - if (p->port >= octeon_bootinfo->mac_addr_count)
> - dev_err(&pdev->dev,
> - "Error %s: Using MAC outside of the assigned range: %pM\n",
> - netdev->name, netdev->dev_addr);
> + p->phy_np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
> +
> + pdev->dev.coherent_dma_mask = DMA_BIT_MASK(64);
> + pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
>
> if (register_netdev(netdev))
> goto err;
> @@ -1133,10 +1179,19 @@ static int __devexit octeon_mgmt_remove(struct platform_device *pdev)
> return 0;
> }
>
> -static struct platform_driver octeon_mgmt_driver = {
> +static struct of_device_id octeon_mgmt_match[] = {
> + {
> + .compatible = "octeon,mgmt",
Ditto to the i2c comment. Compatible value should be in the form
<vendor>,<soc-part-number>-<device>, and it needs to be documented in
Documentation/devicetree/bindings
> + },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, octeon_mgmt_match);
> +
> +static struct of_platform_driver octeon_mgmt_driver = {
of_platform_driver is deprecated; just stick with a normal
platform_driver.
> .driver = {
> .name = "octeon_mgmt",
> .owner = THIS_MODULE,
> + .of_match_table = octeon_mgmt_match,
> },
> .probe = octeon_mgmt_probe,
> .remove = __devexit_p(octeon_mgmt_remove),
> @@ -1148,12 +1203,12 @@ static int __init octeon_mgmt_mod_init(void)
> {
> /* Force our mdiobus driver module to be loaded first. */
> octeon_mdiobus_force_mod_depencency();
> - return platform_driver_register(&octeon_mgmt_driver);
> + return of_register_platform_driver(&octeon_mgmt_driver);
Drop this hunk
> }
>
> static void __exit octeon_mgmt_mod_exit(void)
> {
> - platform_driver_unregister(&octeon_mgmt_driver);
> + of_unregister_platform_driver(&octeon_mgmt_driver);
Ditto
> }
>
> module_init(octeon_mgmt_mod_init);
> --
> 1.7.2.3
>
On 02/22/2011 04:07 PM, David Gibson wrote:
> On Tue, Feb 22, 2011 at 12:57:46PM -0800, David Daney wrote:
>> Signed-off-by: David Daney<[email protected]>
>> ---
>> arch/mips/cavium-octeon/.gitignore | 2 +
>> arch/mips/cavium-octeon/Makefile | 13 ++
>> arch/mips/cavium-octeon/octeon_3xxx.dts | 314 +++++++++++++++++++++++++++++++
>> arch/mips/cavium-octeon/octeon_68xx.dts | 99 ++++++++++
>> 4 files changed, 428 insertions(+), 0 deletions(-)
>> create mode 100644 arch/mips/cavium-octeon/.gitignore
>> create mode 100644 arch/mips/cavium-octeon/octeon_3xxx.dts
>> create mode 100644 arch/mips/cavium-octeon/octeon_68xx.dts
>>
[...]
>> + };
>> + };
>
> Uh.. where are the CPUs?
>
The number and type of CPUs can be (and is) probed. There is an
existing mechanism for the bootloader to communicate which CPUs should
be used.
Likewise for memory, there is an existing mechanism for the bootloader
to communicate which memory should be used.
It is possible that in the future, we would want to put CPUs and Memory
in the Device Tree. If we do, we can add that without having to disturb
the 'soc' device bindings.
My main motivation for this first patch set is to get sane bindings for
all the 'soc' devices And to that end, your feedback has been quite useful.
Thanks,
David Daney
On 02/23/2011 06:48 AM, Grant Likely wrote:
> On Tue, Feb 22, 2011 at 12:57:45PM -0800, David Daney wrote:
>> Signed-off-by: David Daney<[email protected]>
>
> If this is an Ethernet driver, then it belongs in drivers/net and you
> should cc both netdev and Dave Miller.
>
Eventually the files need to go somewhere other than drivers/staging.
They are not all Ethernet related, so sorting out exactly where they all
go is not so simple. This subject has been a thorn in my side for quite
some time.
For the sake of getting the Device Tree patching code working and to
generate Device Tree related feedback, I moved them to be with their kin
in arch/mips/cavium-octeon/executive.
In the context of this patch set, I consider this to be a somewhat minor
detail.
David Daney
> g.
>
>> ---
>> arch/mips/cavium-octeon/executive/Makefile | 5 +
>> .../mips/cavium-octeon/executive}/cvmx-cmd-queue.c | 8 +-
>> .../mips/cavium-octeon/executive}/cvmx-fpa.c | 0
>> .../cavium-octeon/executive}/cvmx-helper-board.c | 18 +--
>> .../cavium-octeon/executive}/cvmx-helper-fpa.c | 0
>> .../cavium-octeon/executive}/cvmx-helper-loop.c | 6 +-
>> .../cavium-octeon/executive}/cvmx-helper-npi.c | 6 +-
>> .../cavium-octeon/executive}/cvmx-helper-rgmii.c | 17 +-
>> .../cavium-octeon/executive}/cvmx-helper-sgmii.c | 12 +-
>> .../cavium-octeon/executive}/cvmx-helper-spi.c | 10 +-
>> .../cavium-octeon/executive}/cvmx-helper-util.c | 16 +-
>> .../cavium-octeon/executive}/cvmx-helper-xaui.c | 10 +-
>> .../mips/cavium-octeon/executive}/cvmx-helper.c | 27 ++--
>> .../executive}/cvmx-interrupt-decodes.c | 10 +-
>> .../cavium-octeon/executive}/cvmx-interrupt-rsl.c | 4 +-
>> .../mips/cavium-octeon/executive}/cvmx-pko.c | 6 +-
>> .../mips/cavium-octeon/executive}/cvmx-spi.c | 12 +-
>> .../mips/include/asm}/octeon/cvmx-address.h | 0
>> .../mips/include/asm}/octeon/cvmx-asxx-defs.h | 0
>> .../mips/include/asm}/octeon/cvmx-cmd-queue.h | 0
>> .../mips/include/asm}/octeon/cvmx-config.h | 0
>> .../mips/include/asm}/octeon/cvmx-dbg-defs.h | 0
>> .../mips/include/asm}/octeon/cvmx-fau.h | 0
>> .../mips/include/asm}/octeon/cvmx-fpa-defs.h | 0
>> .../mips/include/asm}/octeon/cvmx-fpa.h | 0
>> .../mips/include/asm}/octeon/cvmx-gmxx-defs.h | 0
>> .../mips/include/asm}/octeon/cvmx-helper-board.h | 0
>> .../mips/include/asm}/octeon/cvmx-helper-fpa.h | 0
>> .../mips/include/asm}/octeon/cvmx-helper-loop.h | 0
>> .../mips/include/asm}/octeon/cvmx-helper-npi.h | 0
>> .../mips/include/asm}/octeon/cvmx-helper-rgmii.h | 0
>> .../mips/include/asm}/octeon/cvmx-helper-sgmii.h | 0
>> .../mips/include/asm}/octeon/cvmx-helper-spi.h | 0
>> .../mips/include/asm}/octeon/cvmx-helper-util.h | 0
>> .../mips/include/asm}/octeon/cvmx-helper-xaui.h | 0
>> .../mips/include/asm}/octeon/cvmx-helper.h | 0
>> .../mips/include/asm}/octeon/cvmx-ipd.h | 0
>> .../mips/include/asm}/octeon/cvmx-mdio.h | 0
>> .../mips/include/asm}/octeon/cvmx-pcsx-defs.h | 0
>> .../mips/include/asm}/octeon/cvmx-pcsxx-defs.h | 0
>> .../mips/include/asm}/octeon/cvmx-pip-defs.h | 0
>> .../mips/include/asm}/octeon/cvmx-pip.h | 0
>> .../mips/include/asm}/octeon/cvmx-pko-defs.h | 0
>> .../mips/include/asm}/octeon/cvmx-pko.h | 0
>> .../mips/include/asm}/octeon/cvmx-pow.h | 0
>> .../mips/include/asm}/octeon/cvmx-scratch.h | 0
>> .../mips/include/asm}/octeon/cvmx-spi.h | 0
>> .../mips/include/asm}/octeon/cvmx-spxx-defs.h | 0
>> .../mips/include/asm}/octeon/cvmx-srxx-defs.h | 0
>> .../mips/include/asm}/octeon/cvmx-stxx-defs.h | 0
>> .../mips/include/asm}/octeon/cvmx-wqe.h | 0
>> drivers/staging/octeon/Makefile | 5 -
>> drivers/staging/octeon/cvmx-packet.h | 65 -------
>> drivers/staging/octeon/cvmx-smix-defs.h | 178 --------------------
>> drivers/staging/octeon/ethernet-defines.h | 2 +-
>> drivers/staging/octeon/ethernet-mdio.c | 4 +-
>> drivers/staging/octeon/ethernet-mem.c | 2 +-
>> drivers/staging/octeon/ethernet-rgmii.c | 4 +-
>> drivers/staging/octeon/ethernet-rx.c | 14 +-
>> drivers/staging/octeon/ethernet-rx.h | 2 +-
>> drivers/staging/octeon/ethernet-sgmii.c | 4 +-
>> drivers/staging/octeon/ethernet-spi.c | 6 +-
>> drivers/staging/octeon/ethernet-tx.c | 12 +-
>> drivers/staging/octeon/ethernet-xaui.c | 4 +-
>> drivers/staging/octeon/ethernet.c | 14 +-
>> 65 files changed, 116 insertions(+), 367 deletions(-)
>> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-cmd-queue.c (98%)
>> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-fpa.c (100%)
>> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-board.c (98%)
>> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-fpa.c (100%)
>> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-loop.c (95%)
>> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-npi.c (96%)
>> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-rgmii.c (97%)
>> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-sgmii.c (98%)
>> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-spi.c (97%)
>> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-util.c (97%)
>> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper-xaui.c (98%)
>> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-helper.c (98%)
>> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-interrupt-decodes.c (98%)
>> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-interrupt-rsl.c (97%)
>> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-pko.c (99%)
>> rename {drivers/staging/octeon => arch/mips/cavium-octeon/executive}/cvmx-spi.c (99%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-address.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-asxx-defs.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-cmd-queue.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-config.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-dbg-defs.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-fau.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-fpa-defs.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-fpa.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-gmxx-defs.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-board.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-fpa.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-loop.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-npi.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-rgmii.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-sgmii.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-spi.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-util.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper-xaui.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-helper.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-ipd.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-mdio.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pcsx-defs.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pcsxx-defs.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pip-defs.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pip.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pko-defs.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pko.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-pow.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-scratch.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-spi.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-spxx-defs.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-srxx-defs.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-stxx-defs.h (100%)
>> rename {drivers/staging => arch/mips/include/asm}/octeon/cvmx-wqe.h (100%)
>> delete mode 100644 drivers/staging/octeon/cvmx-packet.h
>> delete mode 100644 drivers/staging/octeon/cvmx-smix-defs.h
>>
On Tue, Feb 22, 2011 at 12:57:50PM -0800, David Daney wrote:
> Signed-off-by: David Daney <[email protected]>
> ---
> arch/mips/Kconfig | 2 +
> arch/mips/cavium-octeon/octeon-platform.c | 280 +++++++++++++++++++++++++++++
> arch/mips/cavium-octeon/setup.c | 17 ++
> 3 files changed, 299 insertions(+), 0 deletions(-)
I've got an odd feeling of foreboding about this patch. It makes me
nervous, but I can't articulate why yet. Gut-wise I'd rather see the
device tree pruned/fixed up before it gets unflattened, or for the
kernel to have a separate .dtb linked in for each legacy platform. I
need to think about this some more....
I've made some comments below anyway.
>
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index 4baf7f2..a8fc970 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -699,6 +699,7 @@ config CAVIUM_OCTEON_SIMULATOR
> select SYS_SUPPORTS_HIGHMEM
> select SYS_SUPPORTS_HOTPLUG_CPU
> select SYS_HAS_CPU_CAVIUM_OCTEON
> + select OF_DYNAMIC
> help
> The Octeon simulator is software performance model of the Cavium
> Octeon Processor. It supports simulating Octeon processors on x86
> @@ -715,6 +716,7 @@ config CAVIUM_OCTEON_REFERENCE_BOARD
> select SYS_SUPPORTS_HOTPLUG_CPU
> select SYS_HAS_EARLY_PRINTK
> select SYS_HAS_CPU_CAVIUM_OCTEON
> + select OF_DYNAMIC
> select SWAP_IO_SPACE
> select HW_HAS_PCI
> select ARCH_SUPPORTS_MSI
> diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
> index cecaf62..428de0d 100644
> --- a/arch/mips/cavium-octeon/octeon-platform.c
> +++ b/arch/mips/cavium-octeon/octeon-platform.c
> @@ -13,10 +13,14 @@
> #include <linux/usb.h>
> #include <linux/dma-mapping.h>
> #include <linux/module.h>
> +#include <linux/slab.h>
> #include <linux/platform_device.h>
> +#include <linux/of_platform.h>
>
> #include <asm/octeon/octeon.h>
> #include <asm/octeon/cvmx-rnm-defs.h>
> +#include <asm/octeon/cvmx-helper.h>
> +#include <asm/octeon/cvmx-helper-board.h>
>
> static struct octeon_cf_data octeon_cf_data;
>
> @@ -440,6 +444,282 @@ device_initcall(octeon_ohci_device_init);
>
> #endif /* CONFIG_USB */
>
> +static struct of_device_id __initdata octeon_ids[] = {
> + { .type = "soc", },
> + { .compatible = "simple-bus", },
> + {},
> +};
> +
> +static int __init set_phy_addr_prop(struct device_node *n, int phy)
> +{
> + u32 *vp;
> + struct property *old_p;
> + struct property *p = kzalloc(sizeof(struct device_node) + sizeof(u32), GFP_KERNEL);
> + if (!p)
> + return -ENOMEM;
> + /* The value will immediatly follow the node in memory. */
> + vp = (u32 *)(&p[1]);
This is unsafe (I was on the losing end of an argument when I tried to
do exactly the same thing). If you want to allocate 2 things with one
appended to the other, then you need to define a structure
with the two element in it and allocate the size of that structure.
> + p->name = "reg";
> + p->length = sizeof(u32);
> + p->value = vp;
> +
> + *vp = cpu_to_be32((u32)phy);
phy is already an integer. Why the cast?
> +
> + old_p = of_find_property(n, "reg", NULL);
> + if (old_p)
> + prom_remove_property(n, old_p);
> + return prom_add_property(n, p);
Would it not be more efficient to change the value in the existing reg
property instead of doing this allocation song-and-dance?
> +}
> +
> +static int __init set_mac_addr_prop(struct device_node *n, u64 mac)
> +{
> + u8 *vp;
> + struct property *old_p;
> + struct property *p = kzalloc(sizeof(struct device_node) + 6, GFP_KERNEL);
> + if (!p)
> + return -ENOMEM;
> + /* The value will immediatly follow the node in memory. */
> + vp = (u8 *)(&p[1]);
> + p->name = "local-mac-address";
> + p->length = 6;
> + p->value = vp;
> +
> + vp[0] = (mac >> 40) & 0xff;
> + vp[1] = (mac >> 32) & 0xff;
> + vp[2] = (mac >> 24) & 0xff;
> + vp[3] = (mac >> 16) & 0xff;
> + vp[4] = (mac >> 8) & 0xff;
> + vp[5] = mac & 0xff;
> +
> + old_p = of_find_property(n, "local-mac-address", NULL);
> + if (old_p)
> + prom_remove_property(n, old_p);
> + return prom_add_property(n, p);
Same comments apply to this function.
> +}
> +
> +static struct device_node * __init octeon_of_get_child(const struct device_node *parent,
> + int reg_val)
> +{
> + struct device_node *node = NULL;
> + int size;
> + const __be32 *addr;
> +
> + for (;;) {
> + node = of_get_next_child(parent, node);
Use for_each_child_of_node() here.
> + if (!node)
> + break;
> + addr = of_get_property(node, "reg", &size);
> + if (addr && (be32_to_cpu(*addr) == reg_val))
be32_to_cpup(addr)
> + break;
> + }
> + return node;
> +}
> +
> +int __init octeon_prune_device_tree(void)
> +{
> + int i, p, max_port;
> + const char *node_path;
> + char name_buffer[20];
> + struct device_node *aliases;
> + struct device_node *pip;
> + struct device_node *iface;
> + struct device_node *eth;
> + struct device_node *node;
> +
> + aliases = of_find_node_by_path("/aliases");
> + if (!aliases) {
> + pr_err("Error: No /aliases node in device tree.");
> + return -EINVAL;
> + }
> +
> + if (OCTEON_IS_MODEL(OCTEON_CN52XX) || OCTEON_IS_MODEL(OCTEON_CN63XX))
> + max_port = 2;
> + else if (OCTEON_IS_MODEL(OCTEON_CN56XX))
> + max_port = 1;
> + else
> + max_port = 0;
> +
> + for (i = 0; i < 2; i++) {
> + struct device_node *mgmt;
> + snprintf(name_buffer, sizeof(name_buffer),
> + "ethernet-mgmt%d", i);
> + node_path = of_get_property(aliases, name_buffer, NULL);
> + if (node_path) {
> + mgmt = of_find_node_by_path(node_path);
of_find_node_by_path() needs to be fixed to also accept alias values
so that a string that starts with a '/' is a full path, but no leading
'/' means start with an alias. This code will lose a level of
indentation if you can make that change to the common code.
> + if (!mgmt)
> + continue;
> + if (i >= max_port) {
> + pr_notice("Deleting mgmt%d\n", i);
> + node = of_parse_phandle(mgmt, "phy-handle", 0);
> + if (node) {
> + of_detach_node(node);
> + of_node_put(node);
> + }
> + of_node_put(node);
> +
> + of_detach_node(mgmt);
> + of_node_put(mgmt);
> + }
> + of_node_put(mgmt);
> + }
> + }
> +
> + node_path = of_get_property(aliases, "pip", NULL);
> + if (node_path && (pip = of_find_node_by_path(node_path))) {
> + for (i = 0; i < 4; i++) {
> + cvmx_helper_interface_enumerate(i);
> + iface = octeon_of_get_child(pip, i);
> + if (!iface)
> + continue;
> + for (p = 0; p < 4; p++) {
> + eth = octeon_of_get_child(iface, p);
> + if (!eth)
> + continue;
> + node = of_parse_phandle(eth, "phy-handle", 0);
> + if (p < cvmx_helper_ports_on_interface(i)) {
> + int phy = cvmx_helper_board_get_mii_address(16 * i + p);
> + if (node && phy < 0) {
> + struct property *p = of_find_property(eth, "phy-handle", NULL);
> + of_detach_node(node);
> + of_node_put(node);
> + prom_remove_property(eth, p);
> + }
There is a lot of nesting here; could this be refactored?
> + } else {
> + pr_notice("Deleting Ethernet %x:%x\n", i, p);
> + if (node) {
> + of_detach_node(node);
> + of_node_put(node);
> + }
> + of_detach_node(eth);
> + of_node_put(eth);
> + }
> + of_node_put(node);
> + of_node_put(eth);
> + }
> + of_node_put(iface);
> + }
> + of_node_put(pip);
> + }
> +
> + /* I2C */
> + if (OCTEON_IS_MODEL(OCTEON_CN52XX) ||
> + OCTEON_IS_MODEL(OCTEON_CN63XX) ||
> + OCTEON_IS_MODEL(OCTEON_CN56XX))
> + max_port = 2;
> + else
> + max_port = 1;
> +
> + for (i = 0; i < 2; i++) {
> + struct device_node *i2c;
> + snprintf(name_buffer, sizeof(name_buffer),
> + "i2c%d", i);
> + node_path = of_get_property(aliases, name_buffer, NULL);
> + if (node_path) {
> + i2c = of_find_node_by_path(node_path);
> + if (!i2c)
> + continue;
> + if (i >= max_port) {
> + pr_notice("Deleting i2c%d\n", i);
> +
> + of_detach_node(i2c);
> + of_node_put(i2c);
> + }
> + of_node_put(i2c);
> + }
> + }
> +
> + of_node_put(aliases);
> + return 0;
> +}
> +
> +int __init octeon_fix_device_tree(void)
> +{
> + int i, p;
> + int rv;
> + const char *node_path;
> + char name_buffer[20];
> + u64 mac_addr_base;
> + struct device_node *aliases;
> + struct device_node *pip;
> + struct device_node *iface;
> + struct device_node *eth;
> + struct device_node *node;
> +
> + /*
> + * Edit the device tree to reflect known board
> + * configurations.
> + */
> + mac_addr_base =
> + ((octeon_bootinfo->mac_addr_base[0] & 0xffull)) << 40 |
> + ((octeon_bootinfo->mac_addr_base[1] & 0xffull)) << 32 |
> + ((octeon_bootinfo->mac_addr_base[2] & 0xffull)) << 24 |
> + ((octeon_bootinfo->mac_addr_base[3] & 0xffull)) << 16 |
> + ((octeon_bootinfo->mac_addr_base[4] & 0xffull)) << 8 |
> + (octeon_bootinfo->mac_addr_base[5] & 0xffull);
> +
> + aliases = of_find_node_by_path("/aliases");
> + if (!aliases) {
> + pr_err("Error: No /aliases node in device tree.");
> + return -EINVAL;
> + }
> +
> + for (i = 0; i < 2; i++) {
> + struct device_node *mgmt;
> + snprintf(name_buffer, sizeof(name_buffer),
> + "ethernet-mgmt%d", i);
> + node_path = of_get_property(aliases, name_buffer, NULL);
> + if (node_path) {
Ditto here to comment above.
> + mgmt = of_find_node_by_path(node_path);
> + if (!mgmt)
> + continue;
> + /* Set the ethernet address */
> + rv = set_mac_addr_prop(mgmt, mac_addr_base);
> + if (rv)
> + goto err;
> + mac_addr_base++;
> +
> + of_node_put(mgmt);
> + }
> + }
> +
> + node_path = of_get_property(aliases, "pip", NULL);
> + if (node_path && (pip = of_find_node_by_path(node_path))) {
> + for (i = 0; i < 4; i++) {
> + iface = octeon_of_get_child(pip, i);
> + if (!iface)
> + continue;
> + for (p = 0; p < 4; p++) {
> + int phy = cvmx_helper_board_get_mii_address(16 * i + p);
> + eth = octeon_of_get_child(iface, p);
> + if (!eth)
> + continue;
> + node = of_parse_phandle(eth, "phy-handle", 0);
> + rv = set_mac_addr_prop(eth, mac_addr_base);
> + mac_addr_base++;
> + if (node && phy >= 0)
> + set_phy_addr_prop(node, cvmx_helper_board_get_mii_address(16 * i + p));
> + of_node_put(node);
> + of_node_put(eth);
> + }
> + of_node_put(iface);
> + }
> + of_node_put(pip);
> + }
> +
> + of_node_put(aliases);
> + return 0;
> +err:
> + return rv;
> +}
> +arch_initcall(octeon_fix_device_tree);
Calling this from an initcall really makes me nervous. I'm worried
about ordering issues. Why can this code not be part of the prune
routine above?
> +
> +static int __init octeon_publish_devices(void)
> +{
> + return of_platform_bus_probe(NULL, octeon_ids, NULL);
> +}
> +device_initcall(octeon_publish_devices);
> +
> +
> MODULE_AUTHOR("David Daney <[email protected]>");
> MODULE_LICENSE("GPL");
> MODULE_DESCRIPTION("Platform driver for Octeon SOC");
> diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
> index ab1a106..818f66d5 100644
> --- a/arch/mips/cavium-octeon/setup.c
> +++ b/arch/mips/cavium-octeon/setup.c
> @@ -20,6 +20,7 @@
> #include <linux/platform_device.h>
> #include <linux/serial_core.h>
> #include <linux/serial_8250.h>
> +#include <linux/of_fdt.h>
> #ifdef CONFIG_BLK_DEV_INITRD
> #include <linux/initrd.h>
> #endif
> @@ -797,3 +798,19 @@ void prom_free_prom_memory(void)
> }
> #endif
> }
> +
> +int octeon_prune_device_tree(void);
> +
> +extern const char __dtb_octeon_3xxx_begin;
> +extern const char __dtb_octeon_3xxx_end;
> +void __init device_tree_init(void)
> +{
> + int dt_size = &__dtb_octeon_3xxx_end - &__dtb_octeon_3xxx_begin;
> + /* Copy the default tree from init memory. */
> + initial_boot_params = early_init_dt_alloc_memory_arch(dt_size, 8);
> + if (initial_boot_params == NULL)
> + panic("Could not allocate initial_boot_params\n");
> + memcpy(initial_boot_params, &__dtb_octeon_3xxx_begin, dt_size);
> + unflatten_device_tree();
> + octeon_prune_device_tree();
> +}
> --
> 1.7.2.3
>
On 02/23/2011 09:41 AM, Grant Likely wrote:
> On Tue, Feb 22, 2011 at 12:57:50PM -0800, David Daney wrote:
>> Signed-off-by: David Daney<[email protected]>
>> ---
>> arch/mips/Kconfig | 2 +
>> arch/mips/cavium-octeon/octeon-platform.c | 280 +++++++++++++++++++++++++++++
>> arch/mips/cavium-octeon/setup.c | 17 ++
>> 3 files changed, 299 insertions(+), 0 deletions(-)
>
> I've got an odd feeling of foreboding about this patch. It makes me
> nervous, but I can't articulate why yet. Gut-wise I'd rather see the
> device tree pruned/fixed up before it gets unflattened,
I chose to work on the unflattened form because there were already
functions to do it. I didn't see anything that would make manipulating
the flattened form easy.
I agree that working on the unflattened form would be best. At a minium
the /proc/device-tree structure would better reflect reality.
What do you think about adding some helper functions to drivers/of/fdt.c
for the manipulation of the flattened form?
> or for the
> kernel to have a separate .dtb linked in for each legacy platform.
I think there are too many variants to make this viable.
> I
> need to think about this some more....
>
> I've made some comments below anyway.
And I will respond. Although if I end up modifying the flattened form,
it will all change.
>
[...]
>> +
>> +static int __init set_phy_addr_prop(struct device_node *n, int phy)
>> +{
>> + u32 *vp;
>> + struct property *old_p;
>> + struct property *p = kzalloc(sizeof(struct device_node) + sizeof(u32), GFP_KERNEL);
>> + if (!p)
>> + return -ENOMEM;
>> + /* The value will immediatly follow the node in memory. */
>> + vp = (u32 *)(&p[1]);
>
> This is unsafe (I was on the losing end of an argument when I tried to
> do exactly the same thing). If you want to allocate 2 things with one
> appended to the other, then you need to define a structure
> with the two element in it and allocate the size of that structure.
Weird. alloc_netdev() does this, so it is not unheard of.
>
>> + p->name = "reg";
>> + p->length = sizeof(u32);
>> + p->value = vp;
>> +
>> + *vp = cpu_to_be32((u32)phy);
>
> phy is already an integer. Why the cast?
>
An oversight.
>> +
>> + old_p = of_find_property(n, "reg", NULL);
>> + if (old_p)
>> + prom_remove_property(n, old_p);
>> + return prom_add_property(n, p);
>
> Would it not be more efficient to change the value in the existing reg
> property instead of doing this allocation song-and-dance?
>
I think I did it this way to try to get /proc/device-tree to reflect the
new value.
>> +}
>> +
>> +static int __init set_mac_addr_prop(struct device_node *n, u64 mac)
>> +{
>> + u8 *vp;
>> + struct property *old_p;
>> + struct property *p = kzalloc(sizeof(struct device_node) + 6, GFP_KERNEL);
>> + if (!p)
>> + return -ENOMEM;
>> + /* The value will immediatly follow the node in memory. */
>> + vp = (u8 *)(&p[1]);
>> + p->name = "local-mac-address";
>> + p->length = 6;
>> + p->value = vp;
>> +
>> + vp[0] = (mac>> 40)& 0xff;
>> + vp[1] = (mac>> 32)& 0xff;
>> + vp[2] = (mac>> 24)& 0xff;
>> + vp[3] = (mac>> 16)& 0xff;
>> + vp[4] = (mac>> 8)& 0xff;
>> + vp[5] = mac& 0xff;
>> +
>> + old_p = of_find_property(n, "local-mac-address", NULL);
>> + if (old_p)
>> + prom_remove_property(n, old_p);
>> + return prom_add_property(n, p);
>
> Same comments apply to this function.
>
>> +}
>> +
>> +static struct device_node * __init octeon_of_get_child(const struct device_node *parent,
>> + int reg_val)
>> +{
>> + struct device_node *node = NULL;
>> + int size;
>> + const __be32 *addr;
>> +
>> + for (;;) {
>> + node = of_get_next_child(parent, node);
>
> Use for_each_child_of_node() here.
OK.
>
>> + if (!node)
>> + break;
>> + addr = of_get_property(node, "reg",&size);
>> + if (addr&& (be32_to_cpu(*addr) == reg_val))
>
> be32_to_cpup(addr)
>
Right.
>> + break;
>> + }
>> + return node;
>> +}
>> +
>> +int __init octeon_prune_device_tree(void)
>> +{
>> + int i, p, max_port;
>> + const char *node_path;
>> + char name_buffer[20];
>> + struct device_node *aliases;
>> + struct device_node *pip;
>> + struct device_node *iface;
>> + struct device_node *eth;
>> + struct device_node *node;
>> +
>> + aliases = of_find_node_by_path("/aliases");
>> + if (!aliases) {
>> + pr_err("Error: No /aliases node in device tree.");
>> + return -EINVAL;
>> + }
>> +
>> + if (OCTEON_IS_MODEL(OCTEON_CN52XX) || OCTEON_IS_MODEL(OCTEON_CN63XX))
>> + max_port = 2;
>> + else if (OCTEON_IS_MODEL(OCTEON_CN56XX))
>> + max_port = 1;
>> + else
>> + max_port = 0;
>> +
>> + for (i = 0; i< 2; i++) {
>> + struct device_node *mgmt;
>> + snprintf(name_buffer, sizeof(name_buffer),
>> + "ethernet-mgmt%d", i);
>> + node_path = of_get_property(aliases, name_buffer, NULL);
>> + if (node_path) {
>> + mgmt = of_find_node_by_path(node_path);
>
> of_find_node_by_path() needs to be fixed to also accept alias values
> so that a string that starts with a '/' is a full path, but no leading
> '/' means start with an alias. This code will lose a level of
> indentation if you can make that change to the common code.
>
I will consider making that change.
>> + if (!mgmt)
>> + continue;
>> + if (i>= max_port) {
>> + pr_notice("Deleting mgmt%d\n", i);
>> + node = of_parse_phandle(mgmt, "phy-handle", 0);
>> + if (node) {
>> + of_detach_node(node);
>> + of_node_put(node);
>> + }
>> + of_node_put(node);
>> +
>> + of_detach_node(mgmt);
>> + of_node_put(mgmt);
>> + }
>> + of_node_put(mgmt);
>> + }
>> + }
>> +
>> + node_path = of_get_property(aliases, "pip", NULL);
>> + if (node_path&& (pip = of_find_node_by_path(node_path))) {
>> + for (i = 0; i< 4; i++) {
>> + cvmx_helper_interface_enumerate(i);
>> + iface = octeon_of_get_child(pip, i);
>> + if (!iface)
>> + continue;
>> + for (p = 0; p< 4; p++) {
>> + eth = octeon_of_get_child(iface, p);
>> + if (!eth)
>> + continue;
>> + node = of_parse_phandle(eth, "phy-handle", 0);
>> + if (p< cvmx_helper_ports_on_interface(i)) {
>> + int phy = cvmx_helper_board_get_mii_address(16 * i + p);
>> + if (node&& phy< 0) {
>> + struct property *p = of_find_property(eth, "phy-handle", NULL);
>> + of_detach_node(node);
>> + of_node_put(node);
>> + prom_remove_property(eth, p);
>> + }
>
> There is a lot of nesting here; could this be refactored?
Perhaps. It really is a three deep nesting though.
>
>> + } else {
[...]
>> +}
>> +arch_initcall(octeon_fix_device_tree);
>
> Calling this from an initcall really makes me nervous. I'm worried
> about ordering issues. Why can this code not be part of the prune
> routine above?
>
Again, done to try to make /proc/device-tree reflect reality.
Thanks for looking at it. I will generate another version of the patches.
David Daney
On Wed, Feb 23, 2011 at 10:40:32AM -0800, David Daney wrote:
> On 02/23/2011 09:41 AM, Grant Likely wrote:
> >On Tue, Feb 22, 2011 at 12:57:50PM -0800, David Daney wrote:
> >>Signed-off-by: David Daney<[email protected]>
> >>---
> >> arch/mips/Kconfig | 2 +
> >> arch/mips/cavium-octeon/octeon-platform.c | 280 +++++++++++++++++++++++++++++
> >> arch/mips/cavium-octeon/setup.c | 17 ++
> >> 3 files changed, 299 insertions(+), 0 deletions(-)
> >
> >I've got an odd feeling of foreboding about this patch. It makes me
> >nervous, but I can't articulate why yet. Gut-wise I'd rather see the
> >device tree pruned/fixed up before it gets unflattened,
>
> I chose to work on the unflattened form because there were already
> functions to do it. I didn't see anything that would make
> manipulating the flattened form easy.
>
> I agree that working on the unflattened form would be best. At a
> minium the /proc/device-tree structure would better reflect reality.
>
> What do you think about adding some helper functions to
> drivers/of/fdt.c for the manipulation of the flattened form?
It would probably be easier/safer to link libfdt into the kernel
proper. It's already used in the powerpc bootwrapper, and there has
been talk about replacing some of fdt.c with libfdt. See
scripts/dtc/libfdt
>
> >or for the
> >kernel to have a separate .dtb linked in for each legacy platform.
>
> I think there are too many variants to make this viable.
Out of curiosity, how many variants?
btw, did you know about the dtc '/include/' functionality? It is
possible to set up .dts include files that represent a SoC and can be
modified by the .dts files that include them. See
arch/powerpc/boot/dts/*5200*.dts
>
> > I
> >need to think about this some more....
> >
> >I've made some comments below anyway.
>
> And I will respond. Although if I end up modifying the flattened
> form, it will all change.
>
> >
> [...]
> >>+
> >>+static int __init set_phy_addr_prop(struct device_node *n, int phy)
> >>+{
> >>+ u32 *vp;
> >>+ struct property *old_p;
> >>+ struct property *p = kzalloc(sizeof(struct device_node) + sizeof(u32), GFP_KERNEL);
> >>+ if (!p)
> >>+ return -ENOMEM;
> >>+ /* The value will immediatly follow the node in memory. */
> >>+ vp = (u32 *)(&p[1]);
> >
> >This is unsafe (I was on the losing end of an argument when I tried to
> >do exactly the same thing). If you want to allocate 2 things with one
> >appended to the other, then you need to define a structure
> >with the two element in it and allocate the size of that structure.
>
> Weird. alloc_netdev() does this, so it is not unheard of.
Not unheard of, but still bad practise.
> >>+ old_p = of_find_property(n, "reg", NULL);
> >>+ if (old_p)
> >>+ prom_remove_property(n, old_p);
> >>+ return prom_add_property(n, p);
> >
> >Would it not be more efficient to change the value in the existing reg
> >property instead of doing this allocation song-and-dance?
> >
>
> I think I did it this way to try to get /proc/device-tree to reflect
> the new value.
Sounds like a bug in /proc/device-tree. :-) /proc/device-tree should
be pointing directly at the device tree property itself. I'd be
surprised if modifying the data of 'reg' didn't show up there.
> >>+}
> >>+arch_initcall(octeon_fix_device_tree);
> >
> >Calling this from an initcall really makes me nervous. I'm worried
> >about ordering issues. Why can this code not be part of the prune
> >routine above?
> >
>
> Again, done to try to make /proc/device-tree reflect reality.
yeah, /proc/device-tree should not be driving design decisions. Let's
try to fix it instead.
g.
On 02/22/2011 04:07 PM, David Gibson wrote:
> On Tue, Feb 22, 2011 at 12:57:46PM -0800, David Daney wrote:
>> Signed-off-by: David Daney<[email protected]>
>> ---
>> arch/mips/cavium-octeon/.gitignore | 2 +
>> arch/mips/cavium-octeon/Makefile | 13 ++
>> arch/mips/cavium-octeon/octeon_3xxx.dts | 314 +++++++++++++++++++++++++++++++
>> arch/mips/cavium-octeon/octeon_68xx.dts | 99 ++++++++++
>> 4 files changed, 428 insertions(+), 0 deletions(-)
>> create mode 100644 arch/mips/cavium-octeon/.gitignore
>> create mode 100644 arch/mips/cavium-octeon/octeon_3xxx.dts
>> create mode 100644 arch/mips/cavium-octeon/octeon_68xx.dts
>>
>> diff --git a/arch/mips/cavium-octeon/.gitignore b/arch/mips/cavium-octeon/.gitignore
>> new file mode 100644
>> index 0000000..39c9686
>> --- /dev/null
>> +++ b/arch/mips/cavium-octeon/.gitignore
>> @@ -0,0 +1,2 @@
>> +*.dtb.S
>
> .dtb.S?
I think I have the correct .gitignore syntax.
>
> [snip]
>> +/dts-v1/;
>> +/* OCTEON 3XXX, 5XXX, 63XX device tree skeleton. */
>> +/ {
>> + model = "OCTEON";
>
> 1 tab indents are the usual convention for device trees.
OK.
>
>> + compatible = "octeon,octeon";
>
> There's no model number at all for this board?
I think it should be:
compatible = "octeon,octeon-3860";
>
>> + #address-cells =<2>;
>> + #size-cells =<2>;
>> +
>> + soc@0 {
>> + device_type = "soc";
>
> Drop this device_type.
OK.
>
>> + compatible = "simple-bus";
>> + #address-cells =<2>;
>> + #size-cells =<2>;
>> + ranges; /* Direct mapping */
>> +
>> + ciu: ciu-3xxx@1070000000000 {
>> + compatible = "octeon,ciu-3xxx";
>
> So, names or compatible values with "wildcards" like 3xxx should be
> avoided. Instead, use the specific model number of this device, then
> future devices can claim compatibility with the earlier one.
>
> But, in addition the generic names convention means that the node name
> should be "interrupt-controller" rather than something model specific.
Let's try:
ciu: interrupt-controller@1070000000000 {
compatible = "octeon,octeon-3860-ciu";
>
>> + interrupt-controller;
>> + #address-cells =<0>;
>> + #interrupt-cells =<2>;
>> + reg =<0x10700 0x00000000 0x0 0x7000>;
>> + };
>> +
>> + /* SMI0 */
>> + mdio0: mdio@1180000001800 {
>
> If SMI0 is the name generally used in the documentation, using that in
> the label instead of mdio0 might be more useful.
>
>> + compatible = "octeon,mdio";
>
> No model or revision number?
>
Let's try:
smi0: mdio@1180000001800 {
compatible = "octeon,octeon-3860-mdio";
>> + #address-cells =<1>;
>> + #size-cells =<0>;
>> + reg =<0x11800 0x00001800 0x0 0x40>;
>> + device_type = "mdio";
>
> Drop this device_type.
OK.
>
[...]
>> + mgmt0: ethernet@1070000100000 {
>> + compatible = "octeon,mgmt";
This becomes:
mgmt0: ethernet@1070000100000 {
compatible = "octeon,octeon-5230-mii";
>> + device_type = "network";
>> + model = "mgmt";
>> + reg =<0x10700 0x00100000 0x0 0x100>, /* MIX */
>> +<0x11800 0xE0000000 0x0 0x300>, /* AGL */
>> +<0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */
>> +<0x11800 0xE0002000 0x0 0x8>; /* AGL_PRT_CTL */
>> + unit-number =<0>;
>
> What is this 'unit-number' property for?
>
The AGL_SHARED register bank is shared among all the octeon-5230-mii
devices. the 'unit-number' indicates the bit-field index that this
device should use within those registers.
>> + interrupt-parent =<&ciu>;
>> + interrupts =<0 62>,<1 46>;
>> + local-mac-address = [ 00 00 00 00 00 00 ];
>
> That's not a valid MAC address of course. If this has to be patched
> in by the bootloader / later processing, you should add a comment to
> that effect.
>
Right.
>> + phy-handle =<&phy0>;
>> + };
>> +
>> + mgmt1: ethernet@1070000100800 {
>> + compatible = "octeon,mgmt";
>> + device_type = "network";
>> + model = "mgmt";
>> + reg =<0x10700 0x00100800 0x0 0x100>, /* MIX */
>> +<0x11800 0xE0000800 0x0 0x300>, /* AGL */
>> +<0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */
>> +<0x11800 0xE0002008 0x0 0x8>; /* AGL_PRT_CTL */
>> + unit-number =<1>;
>> + interrupt-parent =<&ciu>;
>> + interrupts =<1 18>,< 1 46>;
>> + local-mac-address = [ 00 00 00 00 00 00 ];
>> + phy-handle =<&phy1>;
>> + };
>> +
>> + pip: pip@11800a0000000 {
>> + compatible = "octeon,pip";
>> + #address-cells =<1>;
>> + #size-cells =<0>;
>> + reg =<0x11800 0xa0000000 0x0 0x2000>;
>> +
>> + interface@0 {
>
> These subnodes and subsubnodes should have compatible values too, even
> if it's just "octeon,pip-interface" and "octeon,pip-ethernet".
>
OK.
>> + #address-cells =<1>;
>> + #size-cells =<0>;
>> + reg =<0>; /* interface */
>> +
>> + ethernet@0 {
>> + device_type = "network";
>> + model = "pip";
>
> This model property doesn't look very useful.
>
I will remove it.
> [snip]
>
> Uh.. where are the CPUs?
>
Answered in other e-mail.
Thanks,
David Daney
On 02/23/2011 10:51 AM, Grant Likely wrote:
> On Wed, Feb 23, 2011 at 10:40:32AM -0800, David Daney wrote:
>> On 02/23/2011 09:41 AM, Grant Likely wrote:
>>> On Tue, Feb 22, 2011 at 12:57:50PM -0800, David Daney wrote:
>>>> Signed-off-by: David Daney<[email protected]>
>>>> ---
>>>> arch/mips/Kconfig | 2 +
>>>> arch/mips/cavium-octeon/octeon-platform.c | 280 +++++++++++++++++++++++++++++
>>>> arch/mips/cavium-octeon/setup.c | 17 ++
>>>> 3 files changed, 299 insertions(+), 0 deletions(-)
>>>
>>> I've got an odd feeling of foreboding about this patch. It makes me
>>> nervous, but I can't articulate why yet. Gut-wise I'd rather see the
>>> device tree pruned/fixed up before it gets unflattened,
>>
>> I chose to work on the unflattened form because there were already
>> functions to do it. I didn't see anything that would make
>> manipulating the flattened form easy.
>>
>> I agree that working on the unflattened form would be best. At a
>> minium the /proc/device-tree structure would better reflect reality.
>>
>> What do you think about adding some helper functions to
>> drivers/of/fdt.c for the manipulation of the flattened form?
>
> It would probably be easier/safer to link libfdt into the kernel
> proper. It's already used in the powerpc bootwrapper, and there has
> been talk about replacing some of fdt.c with libfdt. See
> scripts/dtc/libfdt
>
I will take a look at that approach.
>>
>>> or for the
>>> kernel to have a separate .dtb linked in for each legacy platform.
>>
>> I think there are too many variants to make this viable.
>
> Out of curiosity, how many variants?
>
I don't know exactly, but for the sake of argument let's say at least
twenty we support in-house. That is not counting close to 100 customer
boards. Some of these boards have modular I/O connections (SPI-4.2 vs.
XAIU vs. 4xSGMII, etc. across several different ports.), so the hardware
configuration may be different each time they are powered on.
The existing legacy code handles these, so using it to configure the
Device Tree has a certain appeal. I would hope that moving forward a
correct device tree is obtained from the bootloader, but for existing
boards...
> btw, did you know about the dtc '/include/' functionality? It is
> possible to set up .dts include files that represent a SoC and can be
> modified by the .dts files that include them. See
> arch/powerpc/boot/dts/*5200*.dts
Yes.
Thanks,
David Daney
Grant, please do not quote hundreds of lines of the patch which
you are not commenting on, just to make comments on a few small
hunks.
Thanks.
On Wed, Feb 23, 2011 at 11:06:30AM -0800, David Daney wrote:
> On 02/22/2011 04:07 PM, David Gibson wrote:
> >On Tue, Feb 22, 2011 at 12:57:46PM -0800, David Daney wrote:
> >>Signed-off-by: David Daney<[email protected]>
> >>---
> >> arch/mips/cavium-octeon/.gitignore | 2 +
> >> arch/mips/cavium-octeon/Makefile | 13 ++
> >> arch/mips/cavium-octeon/octeon_3xxx.dts | 314 +++++++++++++++++++++++++++++++
> >> arch/mips/cavium-octeon/octeon_68xx.dts | 99 ++++++++++
> >> 4 files changed, 428 insertions(+), 0 deletions(-)
> >> create mode 100644 arch/mips/cavium-octeon/.gitignore
> >> create mode 100644 arch/mips/cavium-octeon/octeon_3xxx.dts
> >> create mode 100644 arch/mips/cavium-octeon/octeon_68xx.dts
> >>
> >>diff --git a/arch/mips/cavium-octeon/.gitignore b/arch/mips/cavium-octeon/.gitignore
> >>new file mode 100644
> >>index 0000000..39c9686
> >>--- /dev/null
> >>+++ b/arch/mips/cavium-octeon/.gitignore
> >>@@ -0,0 +1,2 @@
> >>+*.dtb.S
> >
> >.dtb.S?
>
> I think I have the correct .gitignore syntax.
What I meant was, where are you generating .dtb.S files that you need
to ignore them?
> >>+ compatible = "octeon,octeon";
> >
> >There's no model number at all for this board?
>
>
> I think it should be:
>
> compatible = "octeon,octeon-3860";
That looks better.
Also, the part before the comma is generally the vendor, so I would
have expected cavium,XXX throughout rather than octeon,XXX.
[snip]
> >So, names or compatible values with "wildcards" like 3xxx should be
> >avoided. Instead, use the specific model number of this device, then
> >future devices can claim compatibility with the earlier one.
> >
> >But, in addition the generic names convention means that the node name
> >should be "interrupt-controller" rather than something model specific.
>
> Let's try:
>
> ciu: interrupt-controller@1070000000000 {
> compatible = "octeon,octeon-3860-ciu";
That looks better.
[snip]
> >>+ device_type = "network";
> >>+ model = "mgmt";
> >>+ reg =<0x10700 0x00100000 0x0 0x100>, /* MIX */
> >>+<0x11800 0xE0000000 0x0 0x300>, /* AGL */
> >>+<0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */
> >>+<0x11800 0xE0002000 0x0 0x8>; /* AGL_PRT_CTL */
> >>+ unit-number =<0>;
> >
> >What is this 'unit-number' property for?
>
> The AGL_SHARED register bank is shared among all the octeon-5230-mii
> devices. the 'unit-number' indicates the bit-field index that this
> device should use within those registers.
Ok. 'cell-index' is the normal property name for this sort of
purpose.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
On 02/23/2011 03:49 PM, David Gibson wrote:
> On Wed, Feb 23, 2011 at 11:06:30AM -0800, David Daney wrote:
>> On 02/22/2011 04:07 PM, David Gibson wrote:
>>> On Tue, Feb 22, 2011 at 12:57:46PM -0800, David Daney wrote:
>>>> Signed-off-by: David Daney<[email protected]>
>>>> ---
>>>> arch/mips/cavium-octeon/.gitignore | 2 +
>>>> arch/mips/cavium-octeon/Makefile | 13 ++
>>>> arch/mips/cavium-octeon/octeon_3xxx.dts | 314 +++++++++++++++++++++++++++++++
>>>> arch/mips/cavium-octeon/octeon_68xx.dts | 99 ++++++++++
>>>> 4 files changed, 428 insertions(+), 0 deletions(-)
>>>> create mode 100644 arch/mips/cavium-octeon/.gitignore
>>>> create mode 100644 arch/mips/cavium-octeon/octeon_3xxx.dts
>>>> create mode 100644 arch/mips/cavium-octeon/octeon_68xx.dts
>>>>
>>>> diff --git a/arch/mips/cavium-octeon/.gitignore b/arch/mips/cavium-octeon/.gitignore
>>>> new file mode 100644
>>>> index 0000000..39c9686
>>>> --- /dev/null
>>>> +++ b/arch/mips/cavium-octeon/.gitignore
>>>> @@ -0,0 +1,2 @@
>>>> +*.dtb.S
>>>
>>> .dtb.S?
>>
>> I think I have the correct .gitignore syntax.
>
> What I meant was, where are you generating .dtb.S files that you need
> to ignore them?
>
They are a byproduct of $(call cmd,dtc).
Normally make removes them automatically, but if you abort at just the
right time, they can be left around.
If it is objectionable, I can just remove that .gitignore bit.
>>>> + compatible = "octeon,octeon";
>>>
>>> There's no model number at all for this board?
>>
>>
>> I think it should be:
>>
>> compatible = "octeon,octeon-3860";
>
> That looks better.
>
> Also, the part before the comma is generally the vendor, so I would
> have expected cavium,XXX throughout rather than octeon,XXX.
OK, I will do that instead.
[...]
>>>> + device_type = "network";
>>>> + model = "mgmt";
>>>> + reg =<0x10700 0x00100000 0x0 0x100>, /* MIX */
>>>> +<0x11800 0xE0000000 0x0 0x300>, /* AGL */
>>>> +<0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */
>>>> +<0x11800 0xE0002000 0x0 0x8>; /* AGL_PRT_CTL */
>>>> + unit-number =<0>;
>>>
>>> What is this 'unit-number' property for?
>>
>> The AGL_SHARED register bank is shared among all the octeon-5230-mii
>> devices. the 'unit-number' indicates the bit-field index that this
>> device should use within those registers.
>
> Ok. 'cell-index' is the normal property name for this sort of
> purpose.
Thanks, I will use 'cell-index'.
David Daney
On Wed, Feb 23, 2011 at 05:57:43PM -0800, David Daney wrote:
> On 02/23/2011 03:49 PM, David Gibson wrote:
> >On Wed, Feb 23, 2011 at 11:06:30AM -0800, David Daney wrote:
> >>On 02/22/2011 04:07 PM, David Gibson wrote:
> >>>On Tue, Feb 22, 2011 at 12:57:46PM -0800, David Daney wrote:
> >>>>Signed-off-by: David Daney<[email protected]>
> >>>>---
> >>>> arch/mips/cavium-octeon/.gitignore | 2 +
> >>>> arch/mips/cavium-octeon/Makefile | 13 ++
> >>>> arch/mips/cavium-octeon/octeon_3xxx.dts | 314 +++++++++++++++++++++++++++++++
> >>>> arch/mips/cavium-octeon/octeon_68xx.dts | 99 ++++++++++
> >>>> 4 files changed, 428 insertions(+), 0 deletions(-)
> >>>> create mode 100644 arch/mips/cavium-octeon/.gitignore
> >>>> create mode 100644 arch/mips/cavium-octeon/octeon_3xxx.dts
> >>>> create mode 100644 arch/mips/cavium-octeon/octeon_68xx.dts
> >>>>
> >>>>diff --git a/arch/mips/cavium-octeon/.gitignore b/arch/mips/cavium-octeon/.gitignore
> >>>>new file mode 100644
> >>>>index 0000000..39c9686
> >>>>--- /dev/null
> >>>>+++ b/arch/mips/cavium-octeon/.gitignore
> >>>>@@ -0,0 +1,2 @@
> >>>>+*.dtb.S
> >>>
> >>>.dtb.S?
> >>
> >>I think I have the correct .gitignore syntax.
> >
> >What I meant was, where are you generating .dtb.S files that you need
> >to ignore them?
> >
>
> They are a byproduct of $(call cmd,dtc).
>
> Normally make removes them automatically, but if you abort at just
> the right time, they can be left around.
>
> If it is objectionable, I can just remove that .gitignore bit.
No, if they're byproducts of cmd,dtc they should be there. I'm just a
bit baffled as to why cmd,dtc would produce such byproducts. dtc
itself will convert dts -> dtb without any extraneous intermediate
steps.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
On 02/23/2011 06:14 PM, David Gibson wrote:
> On Wed, Feb 23, 2011 at 05:57:43PM -0800, David Daney wrote:
>> On 02/23/2011 03:49 PM, David Gibson wrote:
>>> On Wed, Feb 23, 2011 at 11:06:30AM -0800, David Daney wrote:
>>>> On 02/22/2011 04:07 PM, David Gibson wrote:
>>>>> On Tue, Feb 22, 2011 at 12:57:46PM -0800, David Daney wrote:
>>>>>> Signed-off-by: David Daney<[email protected]>
>>>>>> ---
>>>>>> arch/mips/cavium-octeon/.gitignore | 2 +
>>>>>> arch/mips/cavium-octeon/Makefile | 13 ++
>>>>>> arch/mips/cavium-octeon/octeon_3xxx.dts | 314 +++++++++++++++++++++++++++++++
>>>>>> arch/mips/cavium-octeon/octeon_68xx.dts | 99 ++++++++++
>>>>>> 4 files changed, 428 insertions(+), 0 deletions(-)
>>>>>> create mode 100644 arch/mips/cavium-octeon/.gitignore
>>>>>> create mode 100644 arch/mips/cavium-octeon/octeon_3xxx.dts
>>>>>> create mode 100644 arch/mips/cavium-octeon/octeon_68xx.dts
>>>>>>
>>>>>> diff --git a/arch/mips/cavium-octeon/.gitignore b/arch/mips/cavium-octeon/.gitignore
>>>>>> new file mode 100644
>>>>>> index 0000000..39c9686
>>>>>> --- /dev/null
>>>>>> +++ b/arch/mips/cavium-octeon/.gitignore
>>>>>> @@ -0,0 +1,2 @@
>>>>>> +*.dtb.S
>>>>>
>>>>> .dtb.S?
>>>>
>>>> I think I have the correct .gitignore syntax.
>>>
>>> What I meant was, where are you generating .dtb.S files that you need
>>> to ignore them?
>>>
>>
>> They are a byproduct of $(call cmd,dtc).
>>
>> Normally make removes them automatically, but if you abort at just
>> the right time, they can be left around.
>>
>> If it is objectionable, I can just remove that .gitignore bit.
>
> No, if they're byproducts of cmd,dtc they should be there. I'm just a
> bit baffled as to why cmd,dtc would produce such byproducts. dtc
> itself will convert dts -> dtb without any extraneous intermediate
> steps.
>
I misspoke.
$(call cmd,dtc) does indeed just do the direct conversion. There are
other rules in scripts/Makefile.lib that convert the .dtb into a .dtb.o
file that generate the .dtb.S files.
David Daney
On Wed, Feb 23, 2011 at 08:59:29AM -0800, David Daney wrote:
> On 02/22/2011 04:07 PM, David Gibson wrote:
> >On Tue, Feb 22, 2011 at 12:57:46PM -0800, David Daney wrote:
> >>Signed-off-by: David Daney<[email protected]>
> >>---
> >> arch/mips/cavium-octeon/.gitignore | 2 +
> >> arch/mips/cavium-octeon/Makefile | 13 ++
> >> arch/mips/cavium-octeon/octeon_3xxx.dts | 314 +++++++++++++++++++++++++++++++
> >> arch/mips/cavium-octeon/octeon_68xx.dts | 99 ++++++++++
> >> 4 files changed, 428 insertions(+), 0 deletions(-)
> >> create mode 100644 arch/mips/cavium-octeon/.gitignore
> >> create mode 100644 arch/mips/cavium-octeon/octeon_3xxx.dts
> >> create mode 100644 arch/mips/cavium-octeon/octeon_68xx.dts
> >>
> [...]
>
> >>+ };
> >>+ };
> >
> >Uh.. where are the CPUs?
> >
>
> The number and type of CPUs can be (and is) probed. There is an
> existing mechanism for the bootloader to communicate which CPUs
> should be used.
Hrm, ok.
Grant,
We've seen this now on both MIPS and ARM - dts files with no cpus, on
the grounds that those can be runtime probed. I guess it makes sense,
although a dts without cpus looks very, very odd to me. What are your
thoughts on this?
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[cc'ing Ben Herrenschmidt, Rob Herring and Kevin Hilman]
On Thu, Feb 24, 2011 at 4:19 PM, David Gibson
<[email protected]> wrote:
> On Wed, Feb 23, 2011 at 08:59:29AM -0800, David Daney wrote:
>> On 02/22/2011 04:07 PM, David Gibson wrote:
>> >On Tue, Feb 22, 2011 at 12:57:46PM -0800, David Daney wrote:
>> >>Signed-off-by: David Daney<[email protected]>
>> >>---
>> >> ?arch/mips/cavium-octeon/.gitignore ? ? ?| ? ?2 +
>> >> ?arch/mips/cavium-octeon/Makefile ? ? ? ?| ? 13 ++
>> >> ?arch/mips/cavium-octeon/octeon_3xxx.dts | ?314 +++++++++++++++++++++++++++++++
>> >> ?arch/mips/cavium-octeon/octeon_68xx.dts | ? 99 ++++++++++
>> >> ?4 files changed, 428 insertions(+), 0 deletions(-)
>> >> ?create mode 100644 arch/mips/cavium-octeon/.gitignore
>> >> ?create mode 100644 arch/mips/cavium-octeon/octeon_3xxx.dts
>> >> ?create mode 100644 arch/mips/cavium-octeon/octeon_68xx.dts
>> >>
>> [...]
>>
>> >>+ ? ?};
>> >>+ ?};
>> >
>> >Uh.. where are the CPUs?
>> >
>>
>> The number and type of CPUs can be (and is) probed. ?There is an
>> existing mechanism for the bootloader to communicate which CPUs
>> should be used.
>
> Hrm, ok.
>
> Grant,
>
> We've seen this now on both MIPS and ARM - dts files with no cpus, on
> the grounds that those can be runtime probed. ?I guess it makes sense,
> although a dts without cpus looks very, very odd to me. ?What are your
> thoughts on this?
Yeah, it looks odd, but you and I have been looking at device trees,
and .dts file specifically for a lot longer and so are probably a
little set in our ways.
Generally I've applied the argument that it's a good idea to populate
the /cpus node as an anchor for future things that might require it.
For example, a theoretical hypervisor which doesn't allow the guest
access to all the CPUs would use cpu nodes to tell the OS 'hands off'.
Or possibly more likely, and AMP scenario where Linux would certainly
detect all the CPUs, but is supposed to leave some of them alone. It
would also be an anchor for anything NUMA-like which is also
theoretical, but may become more likely in some of the larger ARM
designs that I've been hearing about.
For the same reason I've been recommending to SoC port authors to
populate the .dts will all the devices in the SoC, even for devices
that don't need any configuration data. I2C and SPI busses are no
brainers because they need child nodes to describe the contents of the
bus, but there is no obvious configuration data for, say, an on chip
timer. However, describing it in the tree still provides an anchor
for stuff like disabling devices that the OS should ignore for other
reasons, or for allowing other devices to hold a phandle reference to
it.
There is also the convenience factor of not needing to maintain a
table of platform_devices for each SoC if they are described in the
dt, but in the arm world the kernel still needs to support non-dt
board ports so it will have those tables regardless (unless an SoC
converts wholesale to dt). It is valuable to share init code for both
dt and non-dt use cases.
Given that we've been very explicit that the device tree is for
describing things that aren't probable, the argument that it is not
necessary to populate the cpus node probably holds some water. If
there are no special considerations (ie. disabled CPUs or NUMA) and
nothing holds a phandle to a specific cpu node, then it is probably
okay to omit. In that case the lack of /cpus node would mean simply,
"detect the cpus", and /cpus could be populated to override the
detected behaviour.
Picking up on something David Daney said...
>> The number and type of CPUs can be (and is) probed. There is an
>> existing mechanism for the bootloader to communicate which CPUs
>> should be used.
I do get a little nervous about this (the bootloader communication
bit). For ARM, I had an argument with Nicolas Pitre about preserving
the existing ATAGs mechanism and adding DT on top vs. replacing ATAGs
entirely with DT. I wanted to keep ATAGs, but Nicolas was concerned
about how to handle ambiguity about which data to use when the ATAGs
and DT disagree. In hindsight Nicolas was 100% right and I'm glad he
pushed back. The ARM DT support now detects if ATAGs or a .dtb were
passed at boot (one or the other), and it is *so* much cleaner. All
configuration data lives in the same place and is manipulated in the
same way. Plus it means that the dt usage model is the same for
multiple architectures, arm, powerpc and microblaze.
g.
On Fri, 2011-02-25 at 08:22 -0700, Grant Likely wrote:
>
> Generally I've applied the argument that it's a good idea to populate
> the /cpus node as an anchor for future things that might require it.
> For example, a theoretical hypervisor which doesn't allow the guest
> access to all the CPUs would use cpu nodes to tell the OS 'hands off'.
> Or possibly more likely, and AMP scenario where Linux would certainly
> detect all the CPUs, but is supposed to leave some of them alone. It
> would also be an anchor for anything NUMA-like which is also
> theoretical, but may become more likely in some of the larger ARM
> designs that I've been hearing about.
It also allows to bring other informations in there such as clock
frequencies etc... In some kind, binding to a reset GPIO used to soft
reset secondaries (ie on Macs we have something like that)...
> Given that we've been very explicit that the device tree is for
> describing things that aren't probable, the argument that it is not
> necessary to populate the cpus node probably holds some water. If
> there are no special considerations (ie. disabled CPUs or NUMA) and
> nothing holds a phandle to a specific cpu node, then it is probably
> okay to omit. In that case the lack of /cpus node would mean simply,
> "detect the cpus", and /cpus could be populated to override the
> detected behaviour.
Well... I tend to recommend putting things that are soldered on the mobo
in the device-tree, simply because that allows to pass all sort of
additional informations that can be useful. For example, if you have a
PCI2PCI bridge on the mobo, it allows you to provide proper slot names
for the slots below it, or if devices have oddly routed interrupts (not
the standard INTA...D with swizzling), which happens on embedded a lot,
the device-tree can convey that more easily.
Other things like clock frequencies or in general clock relationships,
or even location codes, MAC addresses, etc...
But you don't -have- to. It's just a recommendation.
> Picking up on something David Daney said...
> >> The number and type of CPUs can be (and is) probed. There is an
> >> existing mechanism for the bootloader to communicate which CPUs
> >> should be used.
>
> I do get a little nervous about this (the bootloader communication
> bit). For ARM, I had an argument with Nicolas Pitre about preserving
> the existing ATAGs mechanism and adding DT on top vs. replacing ATAGs
> entirely with DT. I wanted to keep ATAGs, but Nicolas was concerned
> about how to handle ambiguity about which data to use when the ATAGs
> and DT disagree. In hindsight Nicolas was 100% right and I'm glad he
> pushed back. The ARM DT support now detects if ATAGs or a .dtb were
> passed at boot (one or the other), and it is *so* much cleaner. All
> configuration data lives in the same place and is manipulated in the
> same way. Plus it means that the dt usage model is the same for
> multiple architectures, arm, powerpc and microblaze.
I think doing a "blend" of existing bootloader channels + device-tree is
bad. The device-tree should convey all of the informations that were
previously passed using a different mechanism, or hell will freeze over
in the long run.
Cheers,
Ben.