[{"id":1776214,"web_url":"http://patchwork.ozlabs.org/comment/1776214/","msgid":"<E1dx941-0001PT-0G@mail.theobroma-systems.com>","list_archive_url":null,"date":"2017-09-27T09:55:33","subject":"Re: [U-Boot] [U-Boot,\n\t6/6] rockchip: gmac_rockchip: Add gmac support for rv1108","submitter":{"id":53488,"url":"http://patchwork.ozlabs.org/api/people/53488/","name":"Philipp Tomsich","email":"philipp.tomsich@theobroma-systems.com"},"content":"> The rv1108 mac only support rmii interface, so need to add the\n> set_rmii() ops. Use the phy current interface to set rmii or\n> rgmii ops.\n> \n> Signed-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(-)\n> \n\nAcked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>","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 3y2DQN67h0z9tXF\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 27 Sep 2017 20:22:04 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 82E38C21E2F; Wed, 27 Sep 2017 10:22:02 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id C42ECC21E33;\n\tWed, 27 Sep 2017 09:56:56 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 05855C21E50; Wed, 27 Sep 2017 09:56:54 +0000 (UTC)","from mail.theobroma-systems.com (vegas.theobroma-systems.com\n\t[144.76.126.164])\n\tby lists.denx.de (Postfix) with ESMTPS id 2C877C21E33\n\tfor <u-boot@lists.denx.de>; Wed, 27 Sep 2017 09:55:35 +0000 (UTC)","from 89-104-28-141.customer.bnet.at ([89.104.28.141]:60984\n\thelo=vpn-10-11-0-14.lan) by mail.theobroma-systems.com with esmtpsa\n\t(TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80)\n\t(envelope-from <philipp.tomsich@theobroma-systems.com>)\n\tid 1dx941-0001PT-0G; Wed, 27 Sep 2017 11:55:33 +0200"],"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=none autolearn=unavailable\n\tautolearn_force=no version=3.4.0","MIME-Version":"1.0","From":"Philipp Tomsich <philipp.tomsich@theobroma-systems.com>","To":"David Wu <david.wu@rock-chips.com>","In-Reply-To":"<1506003867-34811-1-git-send-email-david.wu@rock-chips.com>","References":"<1506003867-34811-1-git-send-email-david.wu@rock-chips.com>","Message-Id":"<E1dx941-0001PT-0G@mail.theobroma-systems.com>","Date":"Wed, 27 Sep 2017 11:55:33 +0200","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":"Re: [U-Boot] [U-Boot,\n\t6/6] rockchip: gmac_rockchip: Add gmac support for rv1108","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>","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>"}},{"id":1781398,"web_url":"http://patchwork.ozlabs.org/comment/1781398/","msgid":"<alpine.OSX.2.21.1710061207040.20491@vpn-10-11-0-14.lan>","list_archive_url":null,"date":"2017-10-06T10:09:50","subject":"Re: [U-Boot] [U-Boot,\n\t6/6] rockchip: gmac_rockchip: Add gmac support for rv1108","submitter":{"id":53488,"url":"http://patchwork.ozlabs.org/api/people/53488/","name":"Philipp Tomsich","email":"philipp.tomsich@theobroma-systems.com"},"content":"On Thu, 21 Sep 2017, David Wu wrote:\n\n> The rv1108 mac only support rmii interface, so need to add the\n> set_rmii() ops. Use the phy current interface to set rmii or\n> rgmii ops.\n>\n> Signed-off-by: David Wu <david.wu@rock-chips.com>\n> Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>\n\nSee below for required changes.\n\n> ---\n>\n> drivers/net/gmac_rockchip.c | 67 +++++++++++++++++++++++++++++++++++++++++++--\n> 1 file changed, 65 insertions(+), 2 deletions(-)\n>\n> diff --git a/drivers/net/gmac_rockchip.c b/drivers/net/gmac_rockchip.c\n> index 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\nIf we have multiple functions and some are optional (e.g. the set_to_rmii\nis only ever set to anything other than NULL for the RV1108), we need to\ncheck whether this is a valid function pointer and emit an error otherwise.\nWith the current code, we'll end up in a SEGV/SYNC-ABORT eventually...\n\nPlease protect dispatches through a function pointer, if these pointers \ncould be NULL.\n\n> +\telse\n> +\t\tdebug(\"NO interface defined!\\n\");\n\nLooks like a case for a switch statement.\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>","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 3y7lkN5JBZz9t48\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  6 Oct 2017 21:10:04 +1100 (AEDT)","by lists.denx.de (Postfix, from userid 105)\n\tid 821F8C21DC3; Fri,  6 Oct 2017 10:10:00 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 404DBC21C40;\n\tFri,  6 Oct 2017 10:09:58 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 61EAFC21C40; Fri,  6 Oct 2017 10:09:56 +0000 (UTC)","from mail.theobroma-systems.com (vegas.theobroma-systems.com\n\t[144.76.126.164])\n\tby lists.denx.de (Postfix) with ESMTPS id 23158C21C3F\n\tfor <u-boot@lists.denx.de>; Fri,  6 Oct 2017 10:09:56 +0000 (UTC)","from [86.59.122.178] (port=51518 helo=android.lan)\n\tby mail.theobroma-systems.com with esmtps\n\t(TLS1.2:RSA_AES_128_CBC_SHA1:128)\n\t(Exim 4.80) (envelope-from <philipp.tomsich@theobroma-systems.com>)\n\tid 1e0PZq-00049k-AO; Fri, 06 Oct 2017 12:09:54 +0200","from [10.11.0.14] (helo=vpn-10-11-0-14.lan)\n\tby android.lan with esmtp (Exim 4.84_2)\n\t(envelope-from <philipp.tomsich@theobroma-systems.com>)\n\tid 1e0PZp-000FG6-Vd; Fri, 06 Oct 2017 12:09:54 +0200"],"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=none autolearn=unavailable\n\tautolearn_force=no version=3.4.0","Date":"Fri, 6 Oct 2017 12:09:50 +0200 (CEST)","From":"Philipp Tomsich <philipp.tomsich@theobroma-systems.com>","X-X-Sender":"ptomsich@vpn-10-11-0-14.lan","To":"David Wu <david.wu@rock-chips.com>","In-Reply-To":"<1506003867-34811-1-git-send-email-david.wu@rock-chips.com>","Message-ID":"<alpine.OSX.2.21.1710061207040.20491@vpn-10-11-0-14.lan>","References":"<1506003867-34811-1-git-send-email-david.wu@rock-chips.com>","User-Agent":"Alpine 2.21 (OSX 202 2017-01-01)","MIME-Version":"1.0","Cc":"huangtao@rock-chips.com, u-boot@lists.denx.de, andy.yan@rock-chips.com, \n\tchenjh@rock-chips.com","Subject":"Re: [U-Boot] [U-Boot,\n\t6/6] rockchip: gmac_rockchip: Add gmac support for rv1108","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>","Content-Transfer-Encoding":"base64","Content-Type":"text/plain; charset=\"utf-8\"; Format=\"flowed\"","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}}]