[{"id":1767785,"web_url":"http://patchwork.ozlabs.org/comment/1767785/","msgid":"<d778a8a5-639f-268f-fe43-2cf654fdbe23@denx.de>","list_archive_url":null,"date":"2017-09-13T10:46:14","subject":"Re: [U-Boot] [PATCH v2 11/14] musb: sunxi: switch to the device\n\tmodel","submitter":{"id":70701,"url":"http://patchwork.ozlabs.org/api/people/70701/","name":"Lukasz Majewski","email":"lukma@denx.de"},"content":"On 09/12/2017 09:01 PM, Maxime Ripard wrote:\n> The device model was implemented so far using a hook that needed to be\n> called from the board support, without DT support and only for the host.\n> \n> Switch to probing both in peripheral and host mode through the DT.\n> \n> Reviewed-by: Simon Glass <sjg@chromium.org>\n> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>\n> ---\n>   arch/arm/include/asm/arch-sunxi/usb_phy.h |  7 +---\n>   board/sunxi/board.c                       |  1 +-\n>   drivers/usb/musb-new/sunxi.c              | 56 +++++++++++-------------\n>   3 files changed, 27 insertions(+), 37 deletions(-)\n> \n> diff --git a/arch/arm/include/asm/arch-sunxi/usb_phy.h b/arch/arm/include/asm/arch-sunxi/usb_phy.h\n> index cef6c985bc8d..5a9cacb6f4a3 100644\n> --- a/arch/arm/include/asm/arch-sunxi/usb_phy.h\n> +++ b/arch/arm/include/asm/arch-sunxi/usb_phy.h\n> @@ -19,10 +19,3 @@ void sunxi_usb_phy_power_off(int index);\n>   int sunxi_usb_phy_vbus_detect(int index);\n>   int sunxi_usb_phy_id_detect(int index);\n>   void sunxi_usb_phy_enable_squelch_detect(int index, int enable);\n> -\n> -/* Not really phy related, but we have to declare this somewhere ... */\n> -#if defined(CONFIG_USB_MUSB_HOST) || defined(CONFIG_USB_MUSB_GADGET)\n> -void sunxi_musb_board_init(void);\n> -#else\n> -#define sunxi_musb_board_init()\n> -#endif\n> diff --git a/board/sunxi/board.c b/board/sunxi/board.c\n> index 70e01437c4f4..f9224360d758 100644\n> --- a/board/sunxi/board.c\n> +++ b/board/sunxi/board.c\n> @@ -736,7 +736,6 @@ int misc_init_r(void)\n>   \tif (ret)\n>   \t\treturn ret;\n>   #endif\n> -\tsunxi_musb_board_init();\n>   \n>   \treturn 0;\n>   }\n> diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c\n> index 5c1a902e42dc..7ee44ea91900 100644\n> --- a/drivers/usb/musb-new/sunxi.c\n> +++ b/drivers/usb/musb-new/sunxi.c\n> @@ -308,9 +308,6 @@ static struct musb_hdrc_platform_data musb_plat = {\n>   \t.platform_ops\t= &sunxi_musb_ops,\n>   };\n>   \n> -#ifdef CONFIG_USB_MUSB_HOST\n> -static int musb_usb_remove(struct udevice *dev);\n> -\n>   static int musb_usb_probe(struct udevice *dev)\n>   {\n>   \tstruct musb_host_data *host = dev_get_priv(dev);\n> @@ -319,16 +316,20 @@ static int musb_usb_probe(struct udevice *dev)\n>   \n>   \tpriv->desc_before_addr = true;\n>   \n> +#ifdef CONFIG_USB_MUSB_HOST\n>   \thost->host = musb_init_controller(&musb_plat, NULL,\n>   \t\t\t\t\t  (void *)SUNXI_USB0_BASE);\n>   \tif (!host->host)\n>   \t\treturn -EIO;\n>   \n>   \tret = musb_lowlevel_init(host);\n> -\tif (ret == 0)\n> -\t\tprintf(\"MUSB OTG\\n\");\n> -\telse\n> -\t\tmusb_usb_remove(dev);\n> +\tif (!ret)\n> +\t\tprintf(\"Allwinner mUSB OTG (Host)\\n\");\n> +#else\n> +\tret = musb_register(&musb_plat, NULL, (void *)SUNXI_USB0_BASE);\n> +\tif (!ret)\n> +\t\tprintf(\"Allwinner mUSB OTG (Peripheral)\\n\");\n> +#endif\n>   \n>   \treturn ret;\n>   }\n> @@ -352,30 +353,27 @@ static int musb_usb_remove(struct udevice *dev)\n>   \treturn 0;\n>   }\n>   \n> -U_BOOT_DRIVER(usb_musb) = {\n> -\t.name\t= \"sunxi-musb\",\n> -\t.id\t= UCLASS_USB,\n> -\t.probe = musb_usb_probe,\n> -\t.remove = musb_usb_remove,\n> -\t.ops\t= &musb_usb_ops,\n> -\t.platdata_auto_alloc_size = sizeof(struct usb_platdata),\n> -\t.priv_auto_alloc_size = sizeof(struct musb_host_data),\n> +static const struct udevice_id sunxi_musb_ids[] = {\n> +\t{ .compatible = \"allwinner,sun4i-a10-musb\" },\n> +\t{ .compatible = \"allwinner,sun6i-a31-musb\" },\n> +\t{ .compatible = \"allwinner,sun8i-a33-musb\" },\n> +\t{ .compatible = \"allwinner,sun8i-h3-musb\" },\n> +\t{ }\n>   };\n> -#endif\n>   \n> -void sunxi_musb_board_init(void)\n> -{\n> +U_BOOT_DRIVER(usb_musb) = {\n> +\t.name\t\t= \"sunxi-musb\",\n>   #ifdef CONFIG_USB_MUSB_HOST\n> -\tstruct udevice *dev;\n> -\n> -\t/*\n> -\t * Bind the driver directly for now as musb linux kernel support is\n> -\t * still pending upstream so our dts files do not have the necessary\n> -\t * nodes yet. TODO: Remove this as soon as the dts nodes are in place\n> -\t * and bind by compatible instead.\n> -\t */\n> -\tdevice_bind_driver(dm_root(), \"sunxi-musb\", \"sunxi-musb\", &dev);\n> +\t.id\t\t= UCLASS_USB,\n>   #else\n> -\tmusb_register(&musb_plat, NULL, (void *)SUNXI_USB0_BASE);\n> +\t.id\t\t= UCLASS_USB_DEV_GENERIC,\n>   #endif\n> -}\n> +\t.of_match\t= sunxi_musb_ids,\n> +\t.probe\t\t= musb_usb_probe,\n> +\t.remove\t\t= musb_usb_remove,\n> +#ifdef CONFIG_USB_MUSB_HOST\n> +\t.ops\t\t= &musb_usb_ops,\n> +#endif\n> +\t.platdata_auto_alloc_size = sizeof(struct usb_platdata),\n> +\t.priv_auto_alloc_size = sizeof(struct musb_host_data),\n> +};\n> \n\nReviewed-by: Łukasz Majewski <lukma@denx.de>","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 3xsdd46DMFz9sPk\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 13 Sep 2017 20:46:32 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 602D6C2255D; Wed, 13 Sep 2017 10:46:22 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 5CDA9C2255D;\n\tWed, 13 Sep 2017 10:46:19 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 1CEFBC2255D; Wed, 13 Sep 2017 10:46:18 +0000 (UTC)","from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9])\n\tby lists.denx.de (Postfix) with ESMTPS id 9F403C22369\n\tfor <u-boot@lists.denx.de>; Wed, 13 Sep 2017 10:46:17 +0000 (UTC)","from frontend03.mail.m-online.net (unknown [192.168.6.182])\n\tby mail-out.m-online.net (Postfix) with ESMTP id 3xsdcm6F7sz1qsT1;\n\tWed, 13 Sep 2017 12:46:16 +0200 (CEST)","from localhost (dynscan3.mnet-online.de [192.168.6.84])\n\tby mail.m-online.net (Postfix) with ESMTP id 3xsdcm61RWz1qqkS;\n\tWed, 13 Sep 2017 12:46:16 +0200 (CEST)","from mail.mnet-online.de ([192.168.8.182])\n\tby localhost (dynscan3.mail.m-online.net [192.168.6.84]) (amavisd-new,\n\tport 10024)\n\twith ESMTP id t7bD5EG9kqiu; Wed, 13 Sep 2017 12:46:15 +0200 (CEST)","from [192.168.2.222] (89-64-27-66.dynamic.chello.pl [89.64.27.66])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby mail.mnet-online.de (Postfix) with ESMTPSA;\n\tWed, 13 Sep 2017 12:46:15 +0200 (CEST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,\n\tRCVD_IN_MSPIKE_H3,\n\tRCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no\n\tversion=3.4.0","X-Virus-Scanned":"amavisd-new at mnet-online.de","X-Auth-Info":"HTOxLKyGPgrJYiRM/enKfIC/F5/pNsgBJD9QyebTk0c=","To":"Maxime Ripard <maxime.ripard@free-electrons.com>,\n\tTom Rini <trini@konsulko.com>, Jagan Teki <jagan@openedev.com>","References":"<cover.afe89ac52a0b82d1c12952c3cb82bb3762c85fa8.1505242834.git-series.maxime.ripard@free-electrons.com>\n\t<b866ade7c8b89137a593a603ecba0d8cfedb1224.1505242834.git-series.maxime.ripard@free-electrons.com>","From":"=?utf-8?q?=C5=81ukasz_Majewski?= <lukma@denx.de>","Organization":"DENX","Message-ID":"<d778a8a5-639f-268f-fe43-2cf654fdbe23@denx.de>","Date":"Wed, 13 Sep 2017 12:46:14 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<b866ade7c8b89137a593a603ecba0d8cfedb1224.1505242834.git-series.maxime.ripard@free-electrons.com>","Content-Language":"en-US","Cc":"Thomas Petazzoni <thomas.petazzoni@free-electrons.com>, marex@denx.de,\n\tu-boot@lists.denx.de","Subject":"Re: [U-Boot] [PATCH v2 11/14] musb: sunxi: switch to the device\n\tmodel","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>"}}]