get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/293290/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 293290,
    "url": "http://patchwork.ozlabs.org/api/patches/293290/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1385086116-10972-3-git-send-email-alistair@popple.id.au/",
    "project": {
        "id": 2,
        "url": "http://patchwork.ozlabs.org/api/projects/2/?format=api",
        "name": "Linux PPC development",
        "link_name": "linuxppc-dev",
        "list_id": "linuxppc-dev.lists.ozlabs.org",
        "list_email": "linuxppc-dev@lists.ozlabs.org",
        "web_url": "https://github.com/linuxppc/wiki/wiki",
        "scm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git",
        "webscm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/",
        "list_archive_url": "https://lore.kernel.org/linuxppc-dev/",
        "list_archive_url_format": "https://lore.kernel.org/linuxppc-dev/{}/",
        "commit_url_format": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"
    },
    "msgid": "<1385086116-10972-3-git-send-email-alistair@popple.id.au>",
    "list_archive_url": "https://lore.kernel.org/linuxppc-dev/1385086116-10972-3-git-send-email-alistair@popple.id.au/",
    "date": "2013-11-22T02:08:31",
    "name": "[3/8] IBM Akebono: Add support for a new PHY interface to the IBM emac driver",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": false,
    "hash": "fa48186306733db05f90d2386fe3cf83a2d5ea14",
    "submitter": {
        "id": 24781,
        "url": "http://patchwork.ozlabs.org/api/people/24781/?format=api",
        "name": "Alistair Popple",
        "email": "alistair@popple.id.au"
    },
    "delegate": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/users/14/?format=api",
        "username": "benh",
        "first_name": "Benjamin",
        "last_name": "Herrenschmidt",
        "email": "benh@kernel.crashing.org"
    },
    "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1385086116-10972-3-git-send-email-alistair@popple.id.au/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/293290/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/293290/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>",
        "X-Original-To": "patchwork-incoming@ozlabs.org",
        "Delivered-To": [
            "patchwork-incoming@ozlabs.org",
            "linuxppc-dev@ozlabs.org"
        ],
        "Received": [
            "from ozlabs.org (localhost [IPv6:::1])\n\tby ozlabs.org (Postfix) with ESMTP id BBD002C03C9\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 22 Nov 2013 13:10:27 +1100 (EST)",
            "by ozlabs.org (Postfix)\n\tid CDA472C020A; Fri, 22 Nov 2013 13:08:47 +1100 (EST)",
            "from ipmail04.adl6.internode.on.net (ipmail04.adl6.internode.on.net\n\t[IPv6:2001:44b8:8060:ff02:300:1:6:4])\n\tby ozlabs.org (Postfix) with ESMTP id B3DEC2C0479\n\tfor <linuxppc-dev@ozlabs.org>; Fri, 22 Nov 2013 13:08:47 +1100 (EST)",
            "from ibmaus65.lnk.telstra.net (HELO localhost) ([165.228.126.9])\n\tby ipmail04.adl6.internode.on.net with ESMTP;\n\t22 Nov 2013 12:38:47 +1030"
        ],
        "X-IronPort-Anti-Spam-Filtered": "true",
        "X-IronPort-Anti-Spam-Result": "AhoEANK7jlKl5H4JgWdsb2JhbABZwEmBOg4BARYmKIImAQUnTQUQCElXGYgBwQ0XjjNOB4QyA5gSk3qBUig",
        "From": "Alistair Popple <alistair@popple.id.au>",
        "To": "benh@kernel.crashing.org",
        "Subject": "[PATCH 3/8] IBM Akebono: Add support for a new PHY interface to the\n\tIBM emac driver",
        "Date": "Fri, 22 Nov 2013 13:08:31 +1100",
        "Message-Id": "<1385086116-10972-3-git-send-email-alistair@popple.id.au>",
        "X-Mailer": "git-send-email 1.7.10.4",
        "In-Reply-To": "<1385086057-10884-1-git-send-email-alistair@popple.id.au>",
        "References": "<1385086057-10884-1-git-send-email-alistair@popple.id.au>",
        "Cc": "linuxppc-dev@ozlabs.org, netdev@vger.kernel.org,\n\t\"David S. Miller\" <davem@davemloft.net>,\n\tAlistair Popple <alistair@popple.id.au>",
        "X-BeenThere": "linuxppc-dev@lists.ozlabs.org",
        "X-Mailman-Version": "2.1.16rc2",
        "Precedence": "list",
        "List-Id": "Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>",
        "List-Unsubscribe": "<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.ozlabs.org/pipermail/linuxppc-dev/>",
        "List-Post": "<mailto:linuxppc-dev@lists.ozlabs.org>",
        "List-Help": "<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>",
        "List-Subscribe": "<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org",
        "Sender": "\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"
    },
    "content": "The IBM PPC476GTR SoC that is used on the Akebono board uses a\ndifferent ethernet PHY interface that has wake on lan (WOL) support\nwith the IBM emac. This patch adds support to the IBM emac driver for\nthis new PHY interface.\n\nAt this stage the wake on lan functionality has not been implemented.\n\nSigned-off-by: Alistair Popple <alistair@popple.id.au>\nCc: \"David S. Miller\" <davem@davemloft.net>\nCc: netdev@vger.kernel.org\n---\n .../devicetree/bindings/powerpc/4xx/emac.txt       |    9 +\n drivers/net/ethernet/ibm/emac/Kconfig              |    4 +\n drivers/net/ethernet/ibm/emac/Makefile             |    1 +\n drivers/net/ethernet/ibm/emac/core.c               |   50 +++-\n drivers/net/ethernet/ibm/emac/core.h               |   12 +\n drivers/net/ethernet/ibm/emac/rgmii_wol.c          |  243 ++++++++++++++++++++\n drivers/net/ethernet/ibm/emac/rgmii_wol.h          |   62 +++++\n 7 files changed, 375 insertions(+), 6 deletions(-)\n create mode 100644 drivers/net/ethernet/ibm/emac/rgmii_wol.c\n create mode 100644 drivers/net/ethernet/ibm/emac/rgmii_wol.h",
    "diff": "diff --git a/Documentation/devicetree/bindings/powerpc/4xx/emac.txt b/Documentation/devicetree/bindings/powerpc/4xx/emac.txt\nindex 712baf6..9928d9d 100644\n--- a/Documentation/devicetree/bindings/powerpc/4xx/emac.txt\n+++ b/Documentation/devicetree/bindings/powerpc/4xx/emac.txt\n@@ -61,6 +61,8 @@\n \t\t\t  Fox Axon: present, whatever value is appropriate for each\n \t\t\t  EMAC, that is the content of the current (bogus) \"phy-port\"\n \t\t\t  property.\n+    - rgmii-wol-device  : 1 cell, required iff conntect to a RGMII in the WKUP\n+                          power domain. phandle of the RGMII-WOL device node.\n \n     Optional properties:\n     - phy-address       : 1 cell, optional, MDIO address of the PHY. If absent,\n@@ -146,3 +148,10 @@\n \t\t\t   available.\n \t\t\t   For Axon: 0x0000012a\n \n+      iv) RGMII-WOL node\n+\n+    Required properties:\n+    - compatible         : compatible list, containing 2 entries, first is\n+\t\t\t   \"ibm,rgmii-wol-CHIP\" where CHIP is the host ASIC (like\n+\t\t\t   EMAC) and the second is \"ibm,rgmii-wol\".\n+    - reg                : <registers mapping>\ndiff --git a/drivers/net/ethernet/ibm/emac/Kconfig b/drivers/net/ethernet/ibm/emac/Kconfig\nindex 3f44a30..56ea346 100644\n--- a/drivers/net/ethernet/ibm/emac/Kconfig\n+++ b/drivers/net/ethernet/ibm/emac/Kconfig\n@@ -55,6 +55,10 @@ config IBM_EMAC_RGMII\n \tbool\n \tdefault n\n \n+config IBM_EMAC_RGMII_WOL\n+\tbool \"IBM EMAC RGMII wake-on-LAN support\" if COMPILE_TEST\n+\tdefault n\n+\n config IBM_EMAC_TAH\n \tbool\n \tdefault n\ndiff --git a/drivers/net/ethernet/ibm/emac/Makefile b/drivers/net/ethernet/ibm/emac/Makefile\nindex eba2183..8843803 100644\n--- a/drivers/net/ethernet/ibm/emac/Makefile\n+++ b/drivers/net/ethernet/ibm/emac/Makefile\n@@ -7,5 +7,6 @@ obj-$(CONFIG_IBM_EMAC) += ibm_emac.o\n ibm_emac-y := mal.o core.o phy.o\n ibm_emac-$(CONFIG_IBM_EMAC_ZMII) += zmii.o\n ibm_emac-$(CONFIG_IBM_EMAC_RGMII) += rgmii.o\n+ibm_emac-$(CONFIG_IBM_EMAC_RGMII_WOL) += rgmii_wol.o\n ibm_emac-$(CONFIG_IBM_EMAC_TAH) += tah.o\n ibm_emac-$(CONFIG_IBM_EMAC_DEBUG) += debug.o\ndiff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c\nindex 6b5c722..fc1a775 100644\n--- a/drivers/net/ethernet/ibm/emac/core.c\n+++ b/drivers/net/ethernet/ibm/emac/core.c\n@@ -630,6 +630,8 @@ static int emac_configure(struct emac_instance *dev)\n \tif (emac_has_feature(dev, EMAC_FTR_HAS_RGMII))\n \t\trgmii_set_speed(dev->rgmii_dev, dev->rgmii_port,\n \t\t\t\tdev->phy.speed);\n+\tif (emac_has_feature(dev, EMAC_FTR_HAS_RGMII_WOL))\n+\t\trgmii_wol_set_speed(dev->rgmii_wol_dev, dev->phy.speed);\n \tif (emac_has_feature(dev, EMAC_FTR_HAS_ZMII))\n \t\tzmii_set_speed(dev->zmii_dev, dev->zmii_port, dev->phy.speed);\n \n@@ -797,6 +799,8 @@ static int __emac_mdio_read(struct emac_instance *dev, u8 id, u8 reg)\n \t\tzmii_get_mdio(dev->zmii_dev, dev->zmii_port);\n \tif (emac_has_feature(dev, EMAC_FTR_HAS_RGMII))\n \t\trgmii_get_mdio(dev->rgmii_dev, dev->rgmii_port);\n+\tif (emac_has_feature(dev, EMAC_FTR_HAS_RGMII_WOL))\n+\t\trgmii_wol_get_mdio(dev->rgmii_wol_dev);\n \n \t/* Wait for management interface to become idle */\n \tn = 20;\n@@ -844,6 +848,8 @@ static int __emac_mdio_read(struct emac_instance *dev, u8 id, u8 reg)\n \tDBG2(dev, \"mdio_read -> %04x\" NL, r);\n \terr = 0;\n  bail:\n+\tif (emac_has_feature(dev, EMAC_FTR_HAS_RGMII_WOL))\n+\t\trgmii_wol_put_mdio(dev->rgmii_wol_dev);\n \tif (emac_has_feature(dev, EMAC_FTR_HAS_RGMII))\n \t\trgmii_put_mdio(dev->rgmii_dev, dev->rgmii_port);\n \tif (emac_has_feature(dev, EMAC_FTR_HAS_ZMII))\n@@ -869,6 +875,8 @@ static void __emac_mdio_write(struct emac_instance *dev, u8 id, u8 reg,\n \t\tzmii_get_mdio(dev->zmii_dev, dev->zmii_port);\n \tif (emac_has_feature(dev, EMAC_FTR_HAS_RGMII))\n \t\trgmii_get_mdio(dev->rgmii_dev, dev->rgmii_port);\n+\tif (emac_has_feature(dev, EMAC_FTR_HAS_RGMII_WOL))\n+\t\trgmii_wol_get_mdio(dev->rgmii_wol_dev);\n \n \t/* Wait for management interface to be idle */\n \tn = 20;\n@@ -907,6 +915,8 @@ static void __emac_mdio_write(struct emac_instance *dev, u8 id, u8 reg,\n \t}\n \terr = 0;\n  bail:\n+\tif (emac_has_feature(dev, EMAC_FTR_HAS_RGMII_WOL))\n+\t\trgmii_wol_put_mdio(dev->rgmii_wol_dev);\n \tif (emac_has_feature(dev, EMAC_FTR_HAS_RGMII))\n \t\trgmii_put_mdio(dev->rgmii_dev, dev->rgmii_port);\n \tif (emac_has_feature(dev, EMAC_FTR_HAS_ZMII))\n@@ -2275,10 +2285,11 @@ struct emac_depentry {\n #define\tEMAC_DEP_MAL_IDX\t0\n #define\tEMAC_DEP_ZMII_IDX\t1\n #define\tEMAC_DEP_RGMII_IDX\t2\n-#define\tEMAC_DEP_TAH_IDX\t3\n-#define\tEMAC_DEP_MDIO_IDX\t4\n-#define\tEMAC_DEP_PREV_IDX\t5\n-#define\tEMAC_DEP_COUNT\t\t6\n+#define EMAC_DEP_RGMII_WOL_IDX  3\n+#define\tEMAC_DEP_TAH_IDX\t4\n+#define\tEMAC_DEP_MDIO_IDX\t5\n+#define\tEMAC_DEP_PREV_IDX\t6\n+#define\tEMAC_DEP_COUNT\t\t7\n \n static int emac_check_deps(struct emac_instance *dev,\n \t\t\t   struct emac_depentry *deps)\n@@ -2356,6 +2367,7 @@ static int emac_wait_deps(struct emac_instance *dev)\n \tdeps[EMAC_DEP_MAL_IDX].phandle = dev->mal_ph;\n \tdeps[EMAC_DEP_ZMII_IDX].phandle = dev->zmii_ph;\n \tdeps[EMAC_DEP_RGMII_IDX].phandle = dev->rgmii_ph;\n+\tdeps[EMAC_DEP_RGMII_WOL_IDX].phandle = dev->rgmii_wol_ph;\n \tif (dev->tah_ph)\n \t\tdeps[EMAC_DEP_TAH_IDX].phandle = dev->tah_ph;\n \tif (dev->mdio_ph)\n@@ -2378,6 +2390,7 @@ static int emac_wait_deps(struct emac_instance *dev)\n \t\tdev->mal_dev = deps[EMAC_DEP_MAL_IDX].ofdev;\n \t\tdev->zmii_dev = deps[EMAC_DEP_ZMII_IDX].ofdev;\n \t\tdev->rgmii_dev = deps[EMAC_DEP_RGMII_IDX].ofdev;\n+\t\tdev->rgmii_wol_dev = deps[EMAC_DEP_RGMII_WOL_IDX].ofdev;\n \t\tdev->tah_dev = deps[EMAC_DEP_TAH_IDX].ofdev;\n \t\tdev->mdio_dev = deps[EMAC_DEP_MDIO_IDX].ofdev;\n \t}\n@@ -2583,6 +2596,8 @@ static int emac_init_config(struct emac_instance *dev)\n \t\tdev->rgmii_ph = 0;\n \tif (emac_read_uint_prop(np, \"rgmii-channel\", &dev->rgmii_port, 0))\n \t\tdev->rgmii_port = 0xffffffff;\n+\tif (emac_read_uint_prop(np, \"rgmii-wol-device\", &dev->rgmii_wol_ph, 0))\n+\t\tdev->rgmii_wol_ph = 0;\n \tif (emac_read_uint_prop(np, \"fifo-entry-size\", &dev->fifo_entry_size, 0))\n \t\tdev->fifo_entry_size = 16;\n \tif (emac_read_uint_prop(np, \"mal-burst-size\", &dev->mal_burst_size, 0))\n@@ -2669,6 +2684,16 @@ static int emac_init_config(struct emac_instance *dev)\n #endif\n \t}\n \n+\tif (dev->rgmii_wol_ph != 0) {\n+#ifdef CONFIG_IBM_EMAC_RGMII_WOL\n+\t\tdev->features |= EMAC_FTR_HAS_RGMII_WOL;\n+#else\n+\t\tprintk(KERN_ERR \"%s: RGMII WOL support not enabled !\\n\",\n+\t\t       np->full_name);\n+\t\treturn -ENXIO;\n+#endif\n+\t}\n+\n \t/* Read MAC-address */\n \tp = of_get_property(np, \"local-mac-address\", NULL);\n \tif (p == NULL) {\n@@ -2842,10 +2867,15 @@ static int emac_probe(struct platform_device *ofdev)\n \t    (err = rgmii_attach(dev->rgmii_dev, dev->rgmii_port, dev->phy_mode)) != 0)\n \t\tgoto err_detach_zmii;\n \n+\t/* Attach to RGMII_WOL, if needed */\n+\tif (emac_has_feature(dev, EMAC_FTR_HAS_RGMII_WOL) &&\n+\t    (err = rgmii_wol_attach(dev->rgmii_wol_dev, dev->phy_mode)) != 0)\n+\t\tgoto err_detach_rgmii;\n+\n \t/* Attach to TAH, if needed */\n \tif (emac_has_feature(dev, EMAC_FTR_HAS_TAH) &&\n \t    (err = tah_attach(dev->tah_dev, dev->tah_port)) != 0)\n-\t\tgoto err_detach_rgmii;\n+\t\tgoto err_detach_rgmii_wol;\n \n \t/* Set some link defaults before we can find out real parameters */\n \tdev->phy.speed = SPEED_100;\n@@ -2918,6 +2948,9 @@ static int emac_probe(struct platform_device *ofdev)\n  err_detach_tah:\n \tif (emac_has_feature(dev, EMAC_FTR_HAS_TAH))\n \t\ttah_detach(dev->tah_dev, dev->tah_port);\n+ err_detach_rgmii_wol:\n+\tif (emac_has_feature(dev, EMAC_FTR_HAS_RGMII_WOL))\n+\t\trgmii_wol_detach(dev->rgmii_wol_dev);\n  err_detach_rgmii:\n \tif (emac_has_feature(dev, EMAC_FTR_HAS_RGMII))\n \t\trgmii_detach(dev->rgmii_dev, dev->rgmii_port);\n@@ -3079,12 +3112,17 @@ static int __init emac_init(void)\n \trc = tah_init();\n \tif (rc)\n \t\tgoto err_rgmii;\n-\trc = platform_driver_register(&emac_driver);\n+\trc = rgmii_wol_init();\n \tif (rc)\n \t\tgoto err_tah;\n+\trc = platform_driver_register(&emac_driver);\n+\tif (rc)\n+\t\tgoto err_rgmii_wol;\n \n \treturn 0;\n \n+ err_rgmii_wol:\n+\trgmii_wol_exit();\n  err_tah:\n \ttah_exit();\n  err_rgmii:\ndiff --git a/drivers/net/ethernet/ibm/emac/core.h b/drivers/net/ethernet/ibm/emac/core.h\nindex 7007479..930a6f6 100644\n--- a/drivers/net/ethernet/ibm/emac/core.h\n+++ b/drivers/net/ethernet/ibm/emac/core.h\n@@ -43,6 +43,7 @@\n #include \"phy.h\"\n #include \"zmii.h\"\n #include \"rgmii.h\"\n+#include \"rgmii_wol.h\"\n #include \"mal.h\"\n #include \"tah.h\"\n #include \"debug.h\"\n@@ -210,6 +211,10 @@ struct emac_instance {\n \tu32\t\t\t\trgmii_port;\n \tstruct platform_device\t\t*rgmii_dev;\n \n+\t/* RGMII WOL infos if any */\n+\tu32\t\t\t\trgmii_wol_ph;\n+\tstruct platform_device\t\t*rgmii_wol_dev;\n+\n \t/* TAH infos if any */\n \tu32\t\t\t\ttah_ph;\n \tu32\t\t\t\ttah_port;\n@@ -333,6 +338,10 @@ struct emac_instance {\n  * APM821xx does not support Half Duplex mode\n  */\n #define EMAC_FTR_APM821XX_NO_HALF_DUPLEX\t0x00001000\n+/*\n+ * Set if we have a RGMII with wake on LAN.\n+ */\n+#define EMAC_FTR_HAS_RGMII_WOL\t\t0x00020000\n \n /* Right now, we don't quite handle the always/possible masks on the\n  * most optimal way as we don't have a way to say something like\n@@ -356,6 +365,9 @@ enum {\n #ifdef CONFIG_IBM_EMAC_RGMII\n \t    EMAC_FTR_HAS_RGMII\t|\n #endif\n+#ifdef CONFIG_IBM_EMAC_RGMII_WOL\n+\t    EMAC_FTR_HAS_RGMII_WOL\t|\n+#endif\n #ifdef CONFIG_IBM_EMAC_NO_FLOW_CTRL\n \t    EMAC_FTR_NO_FLOW_CONTROL_40x |\n #endif\ndiff --git a/drivers/net/ethernet/ibm/emac/rgmii_wol.c b/drivers/net/ethernet/ibm/emac/rgmii_wol.c\nnew file mode 100644\nindex 0000000..aeeb5dd\n--- /dev/null\n+++ b/drivers/net/ethernet/ibm/emac/rgmii_wol.c\n@@ -0,0 +1,243 @@\n+/* drivers/net/ethernet/ibm/emac/rgmii_wol.c\n+ *\n+ * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge with\n+ * wake on LAN support.\n+ *\n+ * Copyright 2013 Alistair Popple, IBM Corp.\n+ *                <alistair@popple.id.au>\n+ *\n+ * Based on rgmii.h:\n+ * Copyright 2007 Benjamin Herrenschmidt, IBM Corp.\n+ *                <benh@kernel.crashing.org>\n+ *\n+ * This program is free software; you can redistribute  it and/or modify it\n+ * under  the terms of  the GNU General  Public License as published by the\n+ * Free Software Foundation;  either version 2 of the  License, or (at your\n+ * option) any later version.\n+ */\n+#include <linux/slab.h>\n+#include <linux/kernel.h>\n+#include <linux/ethtool.h>\n+#include <linux/io.h>\n+\n+#include \"emac.h\"\n+#include \"debug.h\"\n+\n+/* RGMII_WOL_REG */\n+\n+#define WKUP_ETH_RGSPD      0xC0000000\n+#define WKUP_ETH_FCSEN      0x20000000\n+#define WKUP_ETH_CRSEN      0x02000000\n+#define WKUP_ETH_COLEN      0x01000000\n+#define WKUP_ETH_TX_OE      0x00040000\n+#define WKUP_ETH_RX_IE      0x00020000\n+#define WKUP_ETH_RGMIIEN    0x00010000\n+\n+#define WKUP_ETH_RGSPD_10   0x00000000\n+#define WKUP_ETH_RGSPD_100  0x40000000\n+#define WKUP_ETH_RGSPD_1000 0x80000000\n+\n+/* RGMII bridge supports only GMII/TBI and RGMII/RTBI PHYs */\n+static inline int rgmii_valid_mode(int phy_mode)\n+{\n+\treturn  phy_mode == PHY_MODE_GMII ||\n+\t\tphy_mode == PHY_MODE_MII ||\n+\t\tphy_mode == PHY_MODE_RGMII ||\n+\t\tphy_mode == PHY_MODE_TBI ||\n+\t\tphy_mode == PHY_MODE_RTBI;\n+}\n+\n+int rgmii_wol_attach(struct platform_device *ofdev, int mode)\n+{\n+\tstruct rgmii_wol_instance *dev = platform_get_drvdata(ofdev);\n+\n+\tdev_dbg(&ofdev->dev, \"attach\\n\");\n+\n+\t/* Check if we need to attach to a RGMII */\n+\tif (!rgmii_valid_mode(mode)) {\n+\t\tdev_err(&ofdev->dev, \"unsupported settings !\\n\");\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tmutex_lock(&dev->lock);\n+\n+\t/* Enable this input */\n+\tout_be32(dev->reg, in_be32(dev->reg) | WKUP_ETH_RGMIIEN\n+\t\t | WKUP_ETH_TX_OE | WKUP_ETH_RX_IE);\n+\n+\t++dev->users;\n+\n+\tmutex_unlock(&dev->lock);\n+\n+\treturn 0;\n+}\n+\n+void rgmii_wol_set_speed(struct platform_device *ofdev, int speed)\n+{\n+\tstruct rgmii_wol_instance *dev = platform_get_drvdata(ofdev);\n+\tu32 reg;\n+\n+\tmutex_lock(&dev->lock);\n+\n+\treg = in_be32(dev->reg) & ~WKUP_ETH_RGSPD;\n+\n+\tdev_dbg(&ofdev->dev, \"speed(%d)\\n\", speed);\n+\n+\tswitch (speed) {\n+\tcase SPEED_1000:\n+\t\treg |= WKUP_ETH_RGSPD_1000;\n+\t\tbreak;\n+\tcase SPEED_100:\n+\t\treg |= WKUP_ETH_RGSPD_100;\n+\t\tbreak;\n+\tcase SPEED_10:\n+\t\treg |= WKUP_ETH_RGSPD_10;\n+\t\tbreak;\n+\tdefault:\n+\t\tdev_err(&ofdev->dev, \"invalid speed set!\\n\");\n+\t}\n+\n+\tout_be32(dev->reg, reg);\n+\n+\tmutex_unlock(&dev->lock);\n+}\n+\n+void rgmii_wol_get_mdio(struct platform_device *ofdev)\n+{\n+\t/* MDIO is always enabled when RGMII_WOL is enabled, so we\n+\t * don't have to do anything here.\n+\t */\n+\tdev_dbg(&ofdev->dev, \"get_mdio\\n\");\n+}\n+\n+void rgmii_wol_put_mdio(struct platform_device *ofdev)\n+{\n+\tdev_dbg(&ofdev->dev, \"put_mdio\\n\");\n+}\n+\n+void rgmii_wol_detach(struct platform_device *ofdev)\n+{\n+\tstruct rgmii_wol_instance *dev = platform_get_drvdata(ofdev);\n+\n+\tBUG_ON(!dev || dev->users == 0);\n+\n+\tmutex_lock(&dev->lock);\n+\n+\tdev_dbg(&ofdev->dev, \"detach\\n\");\n+\n+\t/* Disable this input */\n+\tout_be32(dev->reg, 0);\n+\n+\t--dev->users;\n+\n+\tmutex_unlock(&dev->lock);\n+}\n+\n+int rgmii_wol_get_regs_len(struct platform_device *ofdev)\n+{\n+\treturn sizeof(struct emac_ethtool_regs_subhdr) +\n+\t\tsizeof(u32);\n+}\n+\n+void *rgmii_wol_dump_regs(struct platform_device *ofdev, void *buf)\n+{\n+\tstruct rgmii_wol_instance *dev = platform_get_drvdata(ofdev);\n+\tstruct emac_ethtool_regs_subhdr *hdr = buf;\n+\tu32 *regs = (u32 *)(hdr + 1);\n+\n+\thdr->version = 0;\n+\thdr->index = 0; /* for now, are there chips with more than one\n+\t\t\t * rgmii ? if yes, then we'll add a cell_index\n+\t\t\t * like we do for emac\n+\t\t\t */\n+\tmemcpy_fromio(regs, dev->reg, sizeof(u32));\n+\treturn regs + 1;\n+}\n+\n+\n+static int rgmii_wol_probe(struct platform_device *ofdev)\n+{\n+\tstruct device_node *np = ofdev->dev.of_node;\n+\tstruct rgmii_wol_instance *dev;\n+\tint rc;\n+\n+\trc = -ENOMEM;\n+\tdev = kzalloc(sizeof(struct rgmii_wol_instance), GFP_KERNEL);\n+\tif (dev == NULL)\n+\t\tgoto err_gone;\n+\n+\tmutex_init(&dev->lock);\n+\n+\tdev->reg = of_iomap(np, 0);\n+\tif (!dev->reg) {\n+\t\tdev_err(&ofdev->dev, \"Can't map registers\\n\");\n+\t\trc = -ENXIO;\n+\t\tgoto err_free;\n+\t}\n+\n+\t/* Check for RGMII flags */\n+\tif (of_get_property(ofdev->dev.of_node, \"has-mdio\", NULL))\n+\t\tdev->flags |= EMAC_RGMII_FLAG_HAS_MDIO;\n+\n+\tdev_dbg(&ofdev->dev, \" Boot REG = 0x%08x\\n\", in_be32(dev->reg));\n+\n+\t/* Disable all inputs by default */\n+\tout_be32(dev->reg, 0);\n+\n+\tdev_info(&ofdev->dev,\n+\t       \"RGMII %s initialized with%s MDIO support\\n\",\n+\t       ofdev->dev.of_node->full_name,\n+\t       (dev->flags & EMAC_RGMII_FLAG_HAS_MDIO) ? \"\" : \"out\");\n+\n+\twmb();\n+\tplatform_set_drvdata(ofdev, dev);\n+\n+\treturn 0;\n+\n+ err_free:\n+\tkfree(dev);\n+ err_gone:\n+\treturn rc;\n+}\n+\n+static int rgmii_wol_remove(struct platform_device *ofdev)\n+{\n+\tstruct rgmii_wol_instance *dev = platform_get_drvdata(ofdev);\n+\n+\tWARN_ON(dev->users != 0);\n+\n+\tiounmap(dev->reg);\n+\tkfree(dev);\n+\n+\treturn 0;\n+}\n+\n+static struct of_device_id rgmii_wol_match[] = {\n+\t{\n+\t\t.compatible\t= \"ibm,rgmii-wol\",\n+\t},\n+\t{\n+\t\t.type\t\t= \"emac-rgmii-wol\",\n+\t},\n+\t{},\n+};\n+\n+static struct platform_driver rgmii_wol_driver = {\n+\t.driver = {\n+\t\t.name = \"emac-rgmii-wol\",\n+\t\t.owner = THIS_MODULE,\n+\t\t.of_match_table = rgmii_wol_match,\n+\t},\n+\t.probe = rgmii_wol_probe,\n+\t.remove = rgmii_wol_remove,\n+};\n+\n+int __init rgmii_wol_init(void)\n+{\n+\treturn platform_driver_register(&rgmii_wol_driver);\n+}\n+\n+void rgmii_wol_exit(void)\n+{\n+\tplatform_driver_unregister(&rgmii_wol_driver);\n+}\ndiff --git a/drivers/net/ethernet/ibm/emac/rgmii_wol.h b/drivers/net/ethernet/ibm/emac/rgmii_wol.h\nnew file mode 100644\nindex 0000000..9f0b589\n--- /dev/null\n+++ b/drivers/net/ethernet/ibm/emac/rgmii_wol.h\n@@ -0,0 +1,62 @@\n+/* drivers/net/ethernet/ibm/emac/rgmii_wol.h\n+ *\n+ * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge with\n+ * wake on LAN support.\n+ *\n+ * Copyright 2013 Alistair Popple, IBM Corp.\n+ *                <alistair@popple.id.au>\n+ *\n+ * Based on rgmii.h:\n+ * Copyright 2007 Benjamin Herrenschmidt, IBM Corp.\n+ *                <benh@kernel.crashing.org>\n+ *\n+ * This program is free software; you can redistribute  it and/or modify it\n+ * under  the terms of  the GNU General  Public License as published by the\n+ * Free Software Foundation;  either version 2 of the  License, or (at your\n+ * option) any later version.\n+ */\n+\n+#ifndef __IBM_NEWEMAC_RGMII_WOL_H\n+#define __IBM_NEWEMAC_RGMII_WOL_H\n+\n+/* RGMII device */\n+struct rgmii_wol_instance {\n+\tu32 __iomem\t\t\t*reg;\n+\n+\t/* RGMII bridge flags */\n+\tint\t\t\t\tflags;\n+#define EMAC_RGMII_FLAG_HAS_MDIO\t0x00000001\n+\n+\t/* Only one EMAC whacks us at a time */\n+\tstruct mutex\t\t\tlock;\n+\n+\t/* number of EMACs using this RGMII bridge */\n+\tint\t\t\t\tusers;\n+};\n+\n+#ifdef CONFIG_IBM_EMAC_RGMII_WOL\n+\n+extern int rgmii_wol_init(void);\n+extern void rgmii_wol_exit(void);\n+extern int rgmii_wol_attach(struct platform_device *ofdev, int mode);\n+extern void rgmii_wol_detach(struct platform_device *ofdev);\n+extern void rgmii_wol_get_mdio(struct platform_device *ofdev);\n+extern void rgmii_wol_put_mdio(struct platform_device *ofdev);\n+extern void rgmii_wol_set_speed(struct platform_device *ofdev, int speed);\n+extern int rgmii_wol_get_regs_len(struct platform_device *ofdev);\n+extern void *rgmii_wol_dump_regs(struct platform_device *ofdev, void *buf);\n+\n+#else\n+\n+# define rgmii_wol_init()\t\t0\n+# define rgmii_wol_exit()\t\tdo { } while (0)\n+# define rgmii_wol_attach(x, y)\t\t(-ENXIO)\n+# define rgmii_wol_detach(x)\t\tdo { } while (0)\n+# define rgmii_wol_get_mdio(o)\t\tdo { } while (0)\n+# define rgmii_wol_put_mdio(o)\t\tdo { } while (0)\n+# define rgmii_wol_set_speed(x, y)\tdo { } while (0)\n+# define rgmii_wol_get_regs_len(x)\t0\n+# define rgmii_wol_dump_regs(x, buf)\t(buf)\n+#endif\t\t\t\t/* !CONFIG_IBM_EMAC_RGMII_WOL */\n+\n+#endif /* __IBM_NEWEMAC_RGMII_WOL_H */\n",
    "prefixes": [
        "3/8"
    ]
}