{"id":765980,"url":"http://patchwork.ozlabs.org/api/patches/765980/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/1495546425-753-1-git-send-email-jteki@openedev.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1495546425-753-1-git-send-email-jteki@openedev.com>","list_archive_url":null,"date":"2017-05-23T13:33:45","name":"[U-Boot,v8,14/17] net: fec_mxc: Add fec_phy_reset support","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"4ac9dfe47240aef0f52878700c56861b3b5eac91","submitter":{"id":20045,"url":"http://patchwork.ozlabs.org/api/people/20045/?format=json","name":"Jagan Teki","email":"jagannadh.teki@gmail.com"},"delegate":{"id":1693,"url":"http://patchwork.ozlabs.org/api/users/1693/?format=json","username":"sbabic","first_name":"Stefano","last_name":"Babic","email":"sbabic@denx.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/1495546425-753-1-git-send-email-jteki@openedev.com/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/765980/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/765980/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3wXGjf56Tlz9sPJ\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 23 May 2017 23:35:01 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 6508EC21CC8; Tue, 23 May 2017 13:34:57 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id B90F4C21C4E;\n\tTue, 23 May 2017 13:34:53 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid E2CFCC21C4E; Tue, 23 May 2017 13:34:52 +0000 (UTC)","from mail-pf0-f193.google.com (mail-pf0-f193.google.com\n\t[209.85.192.193])\n\tby lists.denx.de (Postfix) with ESMTPS id 2E3BAC21C35\n\tfor <u-boot@lists.denx.de>; Tue, 23 May 2017 13:34:52 +0000 (UTC)","by mail-pf0-f193.google.com with SMTP id f27so27714489pfe.0\n\tfor <u-boot@lists.denx.de>; Tue, 23 May 2017 06:34:52 -0700 (PDT)","from localhost.localdomain ([59.95.77.114])\n\tby smtp.gmail.com with ESMTPSA id\n\tz21sm1589072pgc.15.2017.05.23.06.34.46\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tTue, 23 May 2017 06:34:49 -0700 (PDT)"],"Authentication-Results":"ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"iwvaG9he\"; dkim-atps=neutral","X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=0.0 required=5.0 tests=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,\n\tT_DKIM_INVALID autolearn=unavailable\n\tautolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id;\n\tbh=jvW/cPrpY/fOq3fEtv9IAxEwITudZR1YGtYOxrtc5Gw=;\n\tb=iwvaG9heyVVQie3IoA63whzqclxA6XWfg3uKDrmhoixx2T2lnWWORF/z7J11yXKde4\n\teI8DDHrYn1UuOew8egeSgXvwTn1EmbhYxHJ6A56+mg6IJDiVRXvKtbW/PEupug2oNzB+\n\tenOh5n2+PHDdHpChznrwmihXAM1waYq10jAK/Eu1jWT3f7jMh/vWxatOGFFR3+9tuk0t\n\tIocGqii8HBfW0jGXTGTwVuArv10b4x7ObmvNsvbAHo0RyM+Y2ITAWFpt94boMFJ0hVf/\n\tvfi3+3UvGkzBVGN9eZ98YaYOfN7jYE+//OrqgaLdmcyyYfpKqpCMMOIWYI4EnkjhQRWN\n\t2P+w==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id;\n\tbh=jvW/cPrpY/fOq3fEtv9IAxEwITudZR1YGtYOxrtc5Gw=;\n\tb=WP0yGQWj9raHI/hBE6C8UhChVTJs2mprB4prdcq4hZOHIKHu7wfY5cyWR8tjOCXcWK\n\tErPmJNZNFbZz5wt45O54Br0mpXzOWA8ftq4pzCYnt7ovWwiBvMwL8dKglAeWhMAL9HwM\n\tZgqsGbe1jiA30s/M18SU6ko5F0TegiBP8n8Hwj6OXJgEWNh5VEMKHcF06HxvYoUzP1n/\n\t0sXx++x3S6mEIOEjnvQvSDokWLs4ZXiIXspL5Q0+F9wVhzsaVVV+luQpldtEAZIAa7ad\n\te+biPHV/Ej2ienX4sC9MxFYHL3nkYfinXAl9yVfCttvkv0/QKTbCVZjyHVzo7DK+N6YS\n\tn9zw==","X-Gm-Message-State":"AODbwcCpXWQusbJD6fMiavGH2B/QvZ8xTisBFhIY4g0y2VehfA1rZbVm\n\tBtvphoc7n202WA==","X-Received":"by 10.98.16.215 with SMTP id 84mr31422291pfq.210.1495546490383; \n\tTue, 23 May 2017 06:34:50 -0700 (PDT)","From":"Jagan Teki <jagannadh.teki@gmail.com>","X-Google-Original-From":"Jagan Teki <jteki@openedev.com>","To":"Stefano Babic <sbabic@denx.de>","Date":"Tue, 23 May 2017 19:03:45 +0530","Message-Id":"<1495546425-753-1-git-send-email-jteki@openedev.com>","X-Mailer":"git-send-email 2.7.4","Cc":"Fabio Estevam <fabio.estevam@nxp.com>, u-boot@lists.denx.de,\n\tJagan Teki <jagan@openedev.com>, Joe Hershberger <joe.hershberger@ni.com>","Subject":"[U-Boot] [PATCH v8 14/17] net: fec_mxc: Add fec_phy_reset support","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"From: Jagan Teki <jagan@openedev.com>\n\nphy-reset-gpios and phy-reset-duration properties are\nneeded for adding mii_dev reset bus operation,\nso the board code not take care of phy_reset anymore\nif it use DM_ETH.\n\nCc: Joe Hershberger <joe.hershberger@ni.com>\nCc: Fabio Estevam <fabio.estevam@nxp.com>\nSigned-off-by: Jagan Teki <jagan@openedev.com>\n---\nChanges for v8:\n- Add 'phy-reset-duration' property support\n\n drivers/net/fec_mxc.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++-----\n drivers/net/fec_mxc.h |  9 ++++++\n include/netdev.h      |  5 ++++\n 3 files changed, 89 insertions(+), 8 deletions(-)","diff":"diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c\nindex 08bea8b..17fe27f 100644\n--- a/drivers/net/fec_mxc.c\n+++ b/drivers/net/fec_mxc.c\n@@ -180,13 +180,27 @@ static int fec_mdio_write(struct ethernet_regs *eth, uint8_t phyaddr,\n static int fec_phy_read(struct mii_dev *bus, int phyaddr, int dev_addr,\n \t\t\tint regaddr)\n {\n-\treturn fec_mdio_read(bus->priv, phyaddr, regaddr);\n+#ifdef CONFIG_DM_ETH\n+\tstruct fec_priv *priv = dev_get_priv((struct udevice *)bus->priv);\n+\tstruct ethernet_regs *eth = priv->eth;\n+#else\n+\tstruct ethernet_regs *eth = bus->priv;\n+#endif\n+\n+\treturn fec_mdio_read(eth, phyaddr, regaddr);\n }\n \n static int fec_phy_write(struct mii_dev *bus, int phyaddr, int dev_addr,\n \t\t\t int regaddr, u16 data)\n {\n-\treturn fec_mdio_write(bus->priv, phyaddr, regaddr, data);\n+#ifdef CONFIG_DM_ETH\n+\tstruct fec_priv *priv = dev_get_priv((struct udevice *)bus->priv);\n+\tstruct ethernet_regs *eth = priv->eth;\n+#else\n+\tstruct ethernet_regs *eth = bus->priv;\n+#endif\n+\n+\treturn fec_mdio_write(eth, phyaddr, regaddr, data);\n }\n \n #ifndef CONFIG_PHYLIB\n@@ -985,9 +999,44 @@ static void fec_free_descs(struct fec_priv *fec)\n \tfree(fec->tbd_base);\n }\n \n+#if defined(CONFIG_DM_ETH) && defined(CONFIG_DM_GPIO)\n+static int fec_phy_reset(struct mii_dev *bus)\n+{\n+\tstruct fec_priv *priv = dev_get_priv((struct udevice *)bus->priv);\n+\tint ret;\n+\n+\tif (!dm_gpio_is_valid(&priv->reset_gpio))\n+\t\treturn 0;\n+\n+\t/* phy reset */\n+\tret = dm_gpio_set_value(&priv->reset_gpio, 0);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tmdelay(priv->reset_duration);\n+\n+\tret = dm_gpio_set_value(&priv->reset_gpio, 1);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tmdelay(priv->reset_duration);\n+\n+\treturn 0;\n+}\n+#endif\n+\n+#ifdef CONFIG_DM_ETH\n+struct mii_dev *fec_get_miibus(struct udevice *dev, int dev_id)\n+#else\n struct mii_dev *fec_get_miibus(uint32_t base_addr, int dev_id)\n+#endif\n {\n+#ifdef CONFIG_DM_ETH\n+\tstruct fec_priv *priv = dev_get_priv(dev);\n+\tstruct ethernet_regs *eth = priv->eth;\n+#else\n \tstruct ethernet_regs *eth = (struct ethernet_regs *)base_addr;\n+#endif\n \tstruct mii_dev *bus;\n \tint ret;\n \n@@ -998,7 +1047,14 @@ struct mii_dev *fec_get_miibus(uint32_t base_addr, int dev_id)\n \t}\n \tbus->read = fec_phy_read;\n \tbus->write = fec_phy_write;\n+#ifdef CONFIG_DM_ETH\n+\tbus->priv = dev;\n+# ifdef CONFIG_DM_GPIO\n+\tbus->reset = fec_phy_reset;\n+# endif\n+#else\n \tbus->priv = eth;\n+#endif\n \tfec_set_dev_name(bus->name, dev_id);\n \n \tret = mdio_register(bus);\n@@ -1223,7 +1279,7 @@ static int fecmxc_probe(struct udevice *dev)\n \tif (ret)\n \t\treturn ret;\n \n-\tbus = fec_get_miibus((uint32_t)priv->eth, dev_id);\n+\tbus = fec_get_miibus(dev, dev_id);\n \tif (!bus)\n \t\tgoto err_mii;\n \n@@ -1278,6 +1334,7 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)\n \tstruct eth_pdata *pdata = dev_get_platdata(dev);\n \tstruct fec_priv *priv = dev_get_priv(dev);\n \tconst char *phy_mode;\n+\tint ret = 0;\n \n \tpdata->iobase = (phys_addr_t)dev_get_addr(dev);\n \tpriv->eth = (struct ethernet_regs *)pdata->iobase;\n@@ -1292,12 +1349,22 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)\n \t\treturn -EINVAL;\n \t}\n \n-\t/* TODO\n-\t * Need to get the reset-gpio and related properties from DT\n-\t * and implemet the enet reset code on .probe call\n-\t */\n+#ifdef CONFIG_DM_GPIO\n+\t/* phy reset gpio */\n+\tret = gpio_request_by_name(dev, \"phy-reset-gpios\", 0,\n+\t\t\t\t   &priv->reset_gpio, GPIOD_IS_OUT);\n+\tif (ret == 0) {\n+\t\tpriv->reset_duration = fdtdec_get_int(gd->fdt_blob,\n+\t\t\t\t\t\t      dev_of_offset(dev),\n+\t\t\t\t\t\t      \"phy-reset-duration\", 1);\n+\t\t/* A sane reset duration should not be longer than 1s */\n+\t\tif (priv->reset_duration > 1000)\n+\t\t\tpriv->reset_duration = 1;\n+\t\tret = 0;\n+\t}\n+#endif\n \n-\treturn 0;\n+\treturn ret;\n }\n \n static const struct udevice_id fecmxc_ids[] = {\ndiff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h\nindex 43a7d7b..fd51d6d 100644\n--- a/drivers/net/fec_mxc.h\n+++ b/drivers/net/fec_mxc.h\n@@ -17,6 +17,10 @@\n #ifndef __FEC_MXC_H\n #define __FEC_MXC_H\n \n+#ifdef CONFIG_DM_GPIO\n+# include <asm-generic/gpio.h>\n+#endif\n+\n /* Layout description of the FEC */\n struct ethernet_regs {\n \t/* [10:2]addr = 00 */\n@@ -254,6 +258,11 @@ struct fec_priv {\n \n #ifdef CONFIG_DM_ETH\n \tu32 interface;\n+\n+# ifdef CONFIG_DM_GPIO\n+\tstruct gpio_desc reset_gpio;\n+\tu32 reset_duration;\n+# endif\n #endif\n };\n \ndiff --git a/include/netdev.h b/include/netdev.h\nindex 8eb8b46..e5668f4 100644\n--- a/include/netdev.h\n+++ b/include/netdev.h\n@@ -133,7 +133,12 @@ static inline int pci_eth_init(bd_t *bis)\n \treturn num;\n }\n \n+#ifdef CONFIG_DM_ETH\n+struct mii_dev *fec_get_miibus(struct udevice *dev, int dev_id);\n+#else\n struct mii_dev *fec_get_miibus(uint32_t base_addr, int dev_id);\n+#endif\n+\n #ifdef CONFIG_PHYLIB\n struct phy_device;\n int fec_probe(bd_t *bd, int dev_id, uint32_t base_addr,\n","prefixes":["U-Boot","v8","14/17"]}