{"id":816891,"url":"http://patchwork.ozlabs.org/api/patches/816891/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/1506003867-34811-1-git-send-email-david.wu@rock-chips.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":"<1506003867-34811-1-git-send-email-david.wu@rock-chips.com>","list_archive_url":null,"date":"2017-09-21T14:24:27","name":"[U-Boot,6/6] rockchip: gmac_rockchip: Add gmac support for rv1108","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"1df30f1d59f040e703b9c9e0fb103dcc1e0f6243","submitter":{"id":68083,"url":"http://patchwork.ozlabs.org/api/people/68083/?format=json","name":"David Wu","email":"david.wu@rock-chips.com"},"delegate":{"id":69486,"url":"http://patchwork.ozlabs.org/api/users/69486/?format=json","username":"ptomsich","first_name":"Philipp","last_name":"Tomsich","email":"philipp.tomsich@theobroma-systems.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/1506003867-34811-1-git-send-email-david.wu@rock-chips.com/mbox/","series":[{"id":4397,"url":"http://patchwork.ozlabs.org/api/series/4397/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=4397","date":"2017-09-21T14:17:45","name":"Add gmac support for rk3399-evb and rv1108-evb","version":1,"mbox":"http://patchwork.ozlabs.org/series/4397/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/816891/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/816891/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","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xyf5m5pRlz9s7g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 22 Sep 2017 00:25:16 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 779C0C21E26; Thu, 21 Sep 2017 14:25:13 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id A6C05C21E13;\n\tThu, 21 Sep 2017 14:25:11 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 242C6C21E0A; Thu, 21 Sep 2017 14:25:10 +0000 (UTC)","from lucky1.263xmail.com (lucky1.263xmail.com [211.157.147.134])\n\tby lists.denx.de (Postfix) with ESMTPS id 795E4C21E0A\n\tfor <u-boot@lists.denx.de>; Thu, 21 Sep 2017 14:25:09 +0000 (UTC)","from david.wu?rock-chips.com (unknown [192.168.167.233])\n\tby lucky1.263xmail.com (Postfix) with ESMTP id 57F2F1822;\n\tThu, 21 Sep 2017 22:25:06 +0800 (CST)","from localhost.localdomain (localhost [127.0.0.1])\n\tby smtp.263.net (Postfix) with ESMTPA id 21FF1383;\n\tThu, 21 Sep 2017 22:25:06 +0800 (CST)","from localhost.localdomain (unknown [58.22.7.114])\n\tby smtp.263.net (Postfix) whith ESMTP id 17713OKMU3M;\n\tThu, 21 Sep 2017 22:25:07 +0800 (CST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"**","X-Spam-Status":"No, score=3.0 required=5.0 tests=RCVD_IN_MSPIKE_BL,\n\tRCVD_IN_MSPIKE_L5,RCVD_IN_SORBS_WEB autolearn=no autolearn_force=no\n\tversion=3.4.0","X-263anti-spam":"KSV:0;","X-MAIL-GRAY":"1","X-MAIL-DELIVERY":"0","X-KSVirus-check":"0","X-ABS-CHECKED":"4","X-RL-SENDER":"david.wu@rock-chips.com","X-FST-TO":"philipp.tomsich@theobroma-systems.com","X-SENDER-IP":"58.22.7.114","X-LOGIN-NAME":"david.wu@rock-chips.com","X-UNIQUE-TAG":"<cc2ad7584141f342d1a7b802aaf6c4ab>","X-ATTACHMENT-NUM":"0","X-SENDER":"wdc@rock-chips.com","X-DNS-TYPE":"0","From":"David Wu <david.wu@rock-chips.com>","To":"philipp.tomsich@theobroma-systems.com,\n\tsjg@chromium.org","Date":"Thu, 21 Sep 2017 22:24:27 +0800","Message-Id":"<1506003867-34811-1-git-send-email-david.wu@rock-chips.com>","X-Mailer":"git-send-email 2.7.4","In-Reply-To":"<1506003471-34551-1-git-send-email-david.wu@rock-chips.com>","References":"<1506003471-34551-1-git-send-email-david.wu@rock-chips.com>","Cc":"huangtao@rock-chips.com, u-boot@lists.denx.de,\n\tDavid Wu <david.wu@rock-chips.com>, andy.yan@rock-chips.com,\n\tchenjh@rock-chips.com","Subject":"[U-Boot] [PATCH 6/6] rockchip: gmac_rockchip: Add gmac support for\n\trv1108","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":"The rv1108 mac only support rmii interface, so need to add the\nset_rmii() ops. Use the phy current interface to set rmii or\nrgmii ops.\n\nSigned-off-by: David Wu <david.wu@rock-chips.com>\n---\n\n drivers/net/gmac_rockchip.c | 67 +++++++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 65 insertions(+), 2 deletions(-)","diff":"diff --git a/drivers/net/gmac_rockchip.c b/drivers/net/gmac_rockchip.c\nindex 26f7a96..16b8c2b 100644\n--- a/drivers/net/gmac_rockchip.c\n+++ b/drivers/net/gmac_rockchip.c\n@@ -37,6 +37,7 @@ struct gmac_rockchip_platdata {\n struct rk_gmac_ops {\n \tint (*fix_mac_speed)(struct gmac_rockchip_platdata *pdata,\n \t\t\t     struct dw_eth_dev *priv);\n+\tvoid (*set_to_rmii)(struct gmac_rockchip_platdata *pdata);\n \tvoid (*set_to_rgmii)(struct gmac_rockchip_platdata *pdata);\n };\n \n@@ -177,6 +178,40 @@ static int rk3399_gmac_fix_mac_speed(struct gmac_rockchip_platdata *pdata,\n \treturn 0;\n }\n \n+static int rv1108_set_rmii_speed(struct gmac_rockchip_platdata *pdata,\n+\t\t\t\t struct dw_eth_dev *priv)\n+{\n+\tint clk, speed;\n+\tenum {\n+\t\tRV1108_GMAC_SPEED_MASK\t\t= BIT(2),\n+\t\tRV1108_GMAC_SPEED_10M\t\t= 0 << 2,\n+\t\tRV1108_GMAC_SPEED_100M\t\t= 1 << 2,\n+\t\tRV1108_GMAC_CLK_SEL_MASK\t= BIT(7),\n+\t\tRV1108_GMAC_CLK_SEL_2_5M\t= 0 << 7,\n+\t\tRV1108_GMAC_CLK_SEL_25M\t\t= 1 << 7,\n+\t};\n+\n+\tswitch (priv->phydev->speed) {\n+\tcase 10:\n+\t\tclk = RV1108_GMAC_CLK_SEL_2_5M;\n+\t\tspeed = RV1108_GMAC_SPEED_10M;\n+\t\tbreak;\n+\tcase 100:\n+\t\tclk = RV1108_GMAC_CLK_SEL_25M;\n+\t\tspeed = RV1108_GMAC_SPEED_100M;\n+\t\tbreak;\n+\tdefault:\n+\t\tdebug(\"Unknown phy speed: %d\\n\", priv->phydev->speed);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\trk_clrsetreg(pdata->grf,\n+\t\t     RV1108_GMAC_CLK_SEL_MASK | RV1108_GMAC_SPEED_MASK,\n+\t\t     clk | speed);\n+\n+\treturn 0;\n+}\n+\n static void rk3288_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata)\n {\n \tstruct rk3288_mac_grf *grf = (struct rk3288_mac_grf *)pdata->grf;\n@@ -292,6 +327,18 @@ static void rk3399_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata)\n \t\t     pdata->tx_delay << RK3399_CLK_TX_DL_CFG_GMAC_SHIFT);\n }\n \n+static void rv1108_gmac_set_to_rmii(struct gmac_rockchip_platdata *pdata)\n+{\n+\tenum {\n+\t\tRV1108_GMAC_PHY_INTF_SEL_MASK  = GENMASK(6, 4),\n+\t\tRV1108_GMAC_PHY_INTF_SEL_RMII  = 4 << 4,\n+\t};\n+\n+\trk_clrsetreg(pdata->grf,\n+\t\t     RV1108_GMAC_PHY_INTF_SEL_MASK,\n+\t\t     RV1108_GMAC_PHY_INTF_SEL_RMII);\n+}\n+\n static int gmac_rockchip_probe(struct udevice *dev)\n {\n \tstruct gmac_rockchip_platdata *pdata = dev_get_platdata(dev);\n@@ -325,8 +372,12 @@ static int gmac_rockchip_probe(struct udevice *dev)\n \tpdata->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF) +\n \t\t     data->grf_offset;\n \n-\t/* Set to RGMII mode */\n-\tops->set_to_rgmii(pdata);\n+\tif (eth_pdata->phy_interface == PHY_INTERFACE_MODE_RGMII)\n+\t\tops->set_to_rgmii(pdata);\n+\telse if (eth_pdata->phy_interface == PHY_INTERFACE_MODE_RMII)\n+\t\tops->set_to_rmii(pdata);\n+\telse\n+\t\tdebug(\"NO interface defined!\\n\");\n \n \treturn designware_eth_probe(dev);\n }\n@@ -392,6 +443,16 @@ const struct gmac_rockchip_driver_data rk3399_gmac_data = {\n \t.grf_offset\t= 0xc214,\n };\n \n+const struct rk_gmac_ops rv1108_gmac_ops = {\n+\t.fix_mac_speed = rv1108_set_rmii_speed,\n+\t.set_to_rmii = rv1108_gmac_set_to_rmii,\n+};\n+\n+const struct gmac_rockchip_driver_data rv1108_gmac_data = {\n+\t.ops\t\t= &rv1108_gmac_ops,\n+\t.grf_offset\t= 0x900,\n+};\n+\n static const struct udevice_id rockchip_gmac_ids[] = {\n \t{ .compatible = \"rockchip,rk3288-gmac\",\n \t  .data = (ulong)&rk3288_gmac_data },\n@@ -399,6 +460,8 @@ static const struct udevice_id rockchip_gmac_ids[] = {\n \t  .data = (ulong)&rk3368_gmac_data },\n \t{ .compatible = \"rockchip,rk3399-gmac\",\n \t  .data = (ulong)&rk3399_gmac_data },\n+\t{ .compatible = \"rockchip,rv1108-gmac\",\n+\t  .data = (ulong)&rv1108_gmac_data },\n \t{ }\n };\n \n","prefixes":["U-Boot","6/6"]}