{"id":811703,"url":"http://patchwork.ozlabs.org/api/1.2/patches/811703/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/fa22bb997123f4af7dd9b37ec1bb78fe0549d626.1504891631.git-series.maxime.ripard@free-electrons.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.2/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":"<fa22bb997123f4af7dd9b37ec1bb78fe0549d626.1504891631.git-series.maxime.ripard@free-electrons.com>","list_archive_url":null,"date":"2017-09-08T17:34:21","name":"[U-Boot,10/13] musb: sunxi: switch to the device model","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"aad9949853674024e4d8dd621de2ff88d973f0d9","submitter":{"id":12916,"url":"http://patchwork.ozlabs.org/api/1.2/people/12916/?format=json","name":"Maxime Ripard","email":"maxime.ripard@free-electrons.com"},"delegate":{"id":68827,"url":"http://patchwork.ozlabs.org/api/1.2/users/68827/?format=json","username":"lukma","first_name":"Lukasz","last_name":"Majewski","email":"lukma@denx.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/fa22bb997123f4af7dd9b37ec1bb78fe0549d626.1504891631.git-series.maxime.ripard@free-electrons.com/mbox/","series":[{"id":2256,"url":"http://patchwork.ozlabs.org/api/1.2/series/2256/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=2256","date":"2017-09-08T17:34:11","name":"sunxi: convert musb to the device model and enable usb_ether","version":1,"mbox":"http://patchwork.ozlabs.org/series/2256/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/811703/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/811703/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 3xpkzn1cQSz9s8J\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  9 Sep 2017 03:37:41 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid E8276C21ED6; Fri,  8 Sep 2017 17:35:43 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 77B24C21EE8;\n\tFri,  8 Sep 2017 17:34:37 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid D368EC21C60; Fri,  8 Sep 2017 17:34:32 +0000 (UTC)","from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54])\n\tby lists.denx.de (Postfix) with ESMTP id C7126C21C60\n\tfor <u-boot@lists.denx.de>; Fri,  8 Sep 2017 17:34:30 +0000 (UTC)","by mail.free-electrons.com (Postfix, from userid 110)\n\tid C691620F69; Fri,  8 Sep 2017 19:34:28 +0200 (CEST)","from localhost (LFbn-TOU-1-209-191.w86-201.abo.wanadoo.fr\n\t[86.201.56.191])\n\tby mail.free-electrons.com (Postfix) with ESMTPSA id 9D3F520882;\n\tFri,  8 Sep 2017 19:34:28 +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.0 required=5.0 tests=none autolearn=unavailable\n\tautolearn_force=no version=3.4.0","From":"Maxime Ripard <maxime.ripard@free-electrons.com>","To":"Tom Rini <trini@konsulko.com>,\n\tJagan Teki <jagan@openedev.com>","Date":"Fri,  8 Sep 2017 19:34:21 +0200","Message-Id":"<fa22bb997123f4af7dd9b37ec1bb78fe0549d626.1504891631.git-series.maxime.ripard@free-electrons.com>","X-Mailer":"git-send-email 2.13.5","In-Reply-To":["<cover.3b9463250a55d25afdf3b221b80a90b4e7811c1e.1504891631.git-series.maxime.ripard@free-electrons.com>","<cover.3b9463250a55d25afdf3b221b80a90b4e7811c1e.1504891631.git-series.maxime.ripard@free-electrons.com>"],"References":["<cover.3b9463250a55d25afdf3b221b80a90b4e7811c1e.1504891631.git-series.maxime.ripard@free-electrons.com>","<cover.3b9463250a55d25afdf3b221b80a90b4e7811c1e.1504891631.git-series.maxime.ripard@free-electrons.com>"],"Cc":"Thomas Petazzoni <thomas.petazzoni@free-electrons.com>, marex@denx.de,\n\tu-boot@lists.denx.de, Maxime Ripard <maxime.ripard@free-electrons.com>","Subject":"[U-Boot] [PATCH 10/13] musb: sunxi: switch to the device model","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 device model was implemented so far using a hook that needed to be\ncalled from the board support, without DT support and only for the host.\n\nSwitch to probing both in peripheral and host mode through the DT.\n\nSigned-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(-)","diff":"diff --git a/arch/arm/include/asm/arch-sunxi/usb_phy.h b/arch/arm/include/asm/arch-sunxi/usb_phy.h\nindex 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\ndiff --git a/board/sunxi/board.c b/board/sunxi/board.c\nindex 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 }\ndiff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c\nindex 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","prefixes":["U-Boot","10/13"]}