[{"id":1745982,"web_url":"http://patchwork.ozlabs.org/comment/1745982/","msgid":"<CAPnjgZ1R6kFFVx9jfoq1CixH_ODeeqVEQR1Z=+JKk2NbBES3GQ@mail.gmail.com>","list_archive_url":null,"date":"2017-08-13T21:35:55","subject":"Re: [U-Boot] [PATCH 3/3] rockchip: evb-rv1108: add usb init\n\tfunction for dwc2 gadget","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/people/6170/","name":"Simon Glass","email":"sjg@chromium.org"},"content":"On 8 August 2017 at 21:36, William Wu <william.wu@rock-chips.com> wrote:\n> This patch implements board_usb_init() for dwc2 gadget, it\n> generally called from do_fastboot to do dwc2 udc probe and\n> support fastboot over USB.\n>\n> Signed-off-by: William Wu <william.wu@rock-chips.com>\n> ---\n>  board/rockchip/evb_rv1108/evb_rv1108.c | 47 ++++++++++++++++++++++++++++++++++\n>  1 file changed, 47 insertions(+)\n>\n> diff --git a/board/rockchip/evb_rv1108/evb_rv1108.c b/board/rockchip/evb_rv1108/evb_rv1108.c\n> index fe37eac..8ca5ee6 100644\n> --- a/board/rockchip/evb_rv1108/evb_rv1108.c\n> +++ b/board/rockchip/evb_rv1108/evb_rv1108.c\n> @@ -50,3 +50,50 @@ int dram_init_banksize(void)\n>\n>         return 0;\n>  }\n> +\n> +#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)\n> +#include <usb.h>\n> +#include <usb/dwc2_udc.h>\n> +\n> +static struct dwc2_plat_otg_data rv1108_otg_data = {\n> +       .rx_fifo_sz     = 512,\n> +       .np_tx_fifo_sz  = 16,\n> +       .tx_fifo_sz     = 128,\n> +};\n> +\n> +int board_usb_init(int index, enum usb_init_type init)\n> +{\n> +       int node;\n> +       const char *mode;\n> +       bool matched = false;\n> +       const void *blob = gd->fdt_blob;\n> +\n> +       /* find the usb_otg node */\n> +       node = fdt_node_offset_by_compatible(blob, -1,\n> +                                       \"rockchip,rv1108-usb\");\n> +\n> +       while (node > 0) {\n> +               mode = fdt_getprop(blob, node, \"dr_mode\", NULL);\n> +               if (mode && strcmp(mode, \"otg\") == 0) {\n> +                       matched = true;\n> +                       break;\n> +               }\n> +\n> +               node = fdt_node_offset_by_compatible(blob, node,\n> +                                       \"rockchip,rv1108-usb\");\n> +       }\n> +       if (!matched) {\n> +               debug(\"Not found usb_otg device\\n\");\n> +               return -ENODEV;\n> +       }\n> +\n> +       rv1108_otg_data.regs_otg = fdtdec_get_addr(blob, node, \"reg\");\n> +\n> +       return dwc2_udc_probe(&rv1108_otg_data);\n\nThese USB init things have been bothering me for a while. Do you think\nthis could be changed into a driver that you could probe with\ndevice_probe()? Then much of the code in here would not be needed and\nit might be easier to tidy it up when we have proper driver-model\nsupport for USB device mode.\n\n> +}\n> +\n> +int board_usb_cleanup(int index, enum usb_init_type init)\n> +{\n> +       return 0;\n> +}\n> +#endif\n> --\n> 2.0.0\n\nRegards,\nSimon","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>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=google.com header.i=@google.com\n\theader.b=\"OUcg4sCS\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"eXAqiHLP\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xVssD6CFWz9sCZ\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 14 Aug 2017 07:52:00 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 94988C21DE3; Sun, 13 Aug 2017 21:41:29 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id ED524C21DCB;\n\tSun, 13 Aug 2017 21:38:16 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid A8FAAC21D94; Sun, 13 Aug 2017 21:36:29 +0000 (UTC)","from mail-vk0-f44.google.com (mail-vk0-f44.google.com\n\t[209.85.213.44])\n\tby lists.denx.de (Postfix) with ESMTPS id 86E91C21DC1\n\tfor <u-boot@lists.denx.de>; Sun, 13 Aug 2017 21:36:17 +0000 (UTC)","by mail-vk0-f44.google.com with SMTP id r199so26636520vke.4\n\tfor <u-boot@lists.denx.de>; Sun, 13 Aug 2017 14:36:17 -0700 (PDT)","by 10.176.85.207 with HTTP; Sun, 13 Aug 2017 14:35:55 -0700 (PDT)"],"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=RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_MSPIKE_H2,\n\tT_DKIM_INVALID autolearn=unavailable autolearn_force=no\n\tversion=3.4.0","DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=20161025; \n\th=mime-version:sender:in-reply-to:references:from:date:message-id\n\t:subject:to:cc;\n\tbh=PZv69zdsflOfKqvSkkNK+lidODx8daII7FH/pe0/vhs=;\n\tb=OUcg4sCSd2TZ4XSz0f4uawAxY7pVGu54Jdz1obtUM+reFBWe3BHnMtONNgpmq+swxi\n\tLxk3z5QvW3GCUZoNU8MnT65Cfsk7+JSedKEJkXT+BBCFzIDWhA109CV4LTgSqHxsBDLU\n\tmixntMjit6/GijzzEBM07uGEjHsI7AU7F8J0F20Js3DdvMGKPoxrRc70qy+MXnlVaiYJ\n\t8euKElK2iXpYUhAng77UpeJ/fEdTVCP4tJEtlTK8xIv4oxeiUlcNpsQpzl2hM6zVb6xG\n\tdFy6CU407pTcD+2mLHsyDlPxDzC9PCvsTT25pcdyz8qQhxqjeevSJKrX4o1TrPSWAA1Y\n\tGsHw==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:sender:in-reply-to:references:from:date:message-id\n\t:subject:to:cc;\n\tbh=PZv69zdsflOfKqvSkkNK+lidODx8daII7FH/pe0/vhs=;\n\tb=eXAqiHLPSWEbHTu5sAkqjXyo4M1V/JXj4A28+dFs2cfx9To1eN3iZaAu2v2LavJCKG\n\trdiOsxIwP36rQ77BgDEzhRy+NBgzrZAScUZ3hqXkKInYrRZMPMoxrVv/dIU1j4vp74zG\n\tpKEvTSx2U/Ahtohm+438iQewd6iP5MqcPP4HQ="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:sender:in-reply-to:references:from\n\t:date:message-id:subject:to:cc;\n\tbh=PZv69zdsflOfKqvSkkNK+lidODx8daII7FH/pe0/vhs=;\n\tb=HNKcUlJ0ErJ+wWNcY2CepWrYUeX55gF7VGuhTo5uopkruXdYsxQvydL8JeuLY7dT5J\n\tM5U6SnbGEJ9/xRbHLr1gAM0Y7c+L8n2/WpPChGqnkK9QqOAT53KWnU5DDyPwBgcI4fwN\n\tHrlOegAKC6uix0PBpKBZ2Pxo+kUMoZOB6xTrdlay5I13t2e9lHtmzwZNIntvUz2aKYoV\n\tqWHIvuC5z7eurK4QjiJYbdhGUFLzQDTu1NT4gWve9mTw4HdDAagRYfxwS3/56Ky5HV2B\n\t3v19K6UmRa3dPXwm4KxROvPuRUEHIsVWbgvct0UzVaQQzUQmmLIk1VOdCuqXp8KiFVki\n\tryYg==","X-Gm-Message-State":"AHYfb5i1Jl/t2Q4xiof3hYQCweDNwlb8syAWQIqdo3yocuCK1qsl6QMD\n\thn2k7pFW5A28icZeduPheMilMv03yihR","X-Received":"by 10.31.228.4 with SMTP id b4mr11875776vkh.49.1502660176271;\n\tSun, 13 Aug 2017 14:36:16 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<1502249789-11462-4-git-send-email-william.wu@rock-chips.com>","References":"<1502249789-11462-1-git-send-email-william.wu@rock-chips.com>\n\t<1502249789-11462-4-git-send-email-william.wu@rock-chips.com>","From":"Simon Glass <sjg@chromium.org>","Date":"Sun, 13 Aug 2017 15:35:55 -0600","X-Google-Sender-Auth":"lFLhxivEi3ILfoMgxCvARnX9x_M","Message-ID":"<CAPnjgZ1R6kFFVx9jfoq1CixH_ODeeqVEQR1Z=+JKk2NbBES3GQ@mail.gmail.com>","To":"William Wu <william.wu@rock-chips.com>","Cc":"U-Boot Mailing List <u-boot@lists.denx.de>","Subject":"Re: [U-Boot] [PATCH 3/3] rockchip: evb-rv1108: add usb init\n\tfunction for dwc2 gadget","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":1746285,"web_url":"http://patchwork.ozlabs.org/comment/1746285/","msgid":"<19f8cdc0-5408-bad2-433b-660736f7394b@rock-chips.com>","list_archive_url":null,"date":"2017-08-14T10:05:19","subject":"Re: [U-Boot] [PATCH 3/3] rockchip: evb-rv1108: add usb init\n\tfunction for dwc2 gadget","submitter":{"id":71447,"url":"http://patchwork.ozlabs.org/api/people/71447/","name":"wlf","email":"wulf@rock-chips.com"},"content":"Dear Simon,\n\n在 2017年08月14日 05:35, Simon Glass 写道:\n> On 8 August 2017 at 21:36, William Wu <william.wu@rock-chips.com> wrote:\n>> This patch implements board_usb_init() for dwc2 gadget, it\n>> generally called from do_fastboot to do dwc2 udc probe and\n>> support fastboot over USB.\n>>\n>> Signed-off-by: William Wu <william.wu@rock-chips.com>\n>> ---\n>>   board/rockchip/evb_rv1108/evb_rv1108.c | 47 ++++++++++++++++++++++++++++++++++\n>>   1 file changed, 47 insertions(+)\n>>\n>> diff --git a/board/rockchip/evb_rv1108/evb_rv1108.c b/board/rockchip/evb_rv1108/evb_rv1108.c\n>> index fe37eac..8ca5ee6 100644\n>> --- a/board/rockchip/evb_rv1108/evb_rv1108.c\n>> +++ b/board/rockchip/evb_rv1108/evb_rv1108.c\n>> @@ -50,3 +50,50 @@ int dram_init_banksize(void)\n>>\n>>          return 0;\n>>   }\n>> +\n>> +#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)\n>> +#include <usb.h>\n>> +#include <usb/dwc2_udc.h>\n>> +\n>> +static struct dwc2_plat_otg_data rv1108_otg_data = {\n>> +       .rx_fifo_sz     = 512,\n>> +       .np_tx_fifo_sz  = 16,\n>> +       .tx_fifo_sz     = 128,\n>> +};\n>> +\n>> +int board_usb_init(int index, enum usb_init_type init)\n>> +{\n>> +       int node;\n>> +       const char *mode;\n>> +       bool matched = false;\n>> +       const void *blob = gd->fdt_blob;\n>> +\n>> +       /* find the usb_otg node */\n>> +       node = fdt_node_offset_by_compatible(blob, -1,\n>> +                                       \"rockchip,rv1108-usb\");\n>> +\n>> +       while (node > 0) {\n>> +               mode = fdt_getprop(blob, node, \"dr_mode\", NULL);\n>> +               if (mode && strcmp(mode, \"otg\") == 0) {\n>> +                       matched = true;\n>> +                       break;\n>> +               }\n>> +\n>> +               node = fdt_node_offset_by_compatible(blob, node,\n>> +                                       \"rockchip,rv1108-usb\");\n>> +       }\n>> +       if (!matched) {\n>> +               debug(\"Not found usb_otg device\\n\");\n>> +               return -ENODEV;\n>> +       }\n>> +\n>> +       rv1108_otg_data.regs_otg = fdtdec_get_addr(blob, node, \"reg\");\n>> +\n>> +       return dwc2_udc_probe(&rv1108_otg_data);\n> These USB init things have been bothering me for a while. Do you think\n> this could be changed into a driver that you could probe with\n> device_probe()? Then much of the code in here would not be needed and\n> it might be easier to tidy it up when we have proper driver-model\n> support for USB device mode.\nYes,  on rockchip platforms, it did most of the same USB init things in \ndifferent board special drivers.\nI think may be we can try to optimize the code in two different ways.\n\nMethod1.\n1. Move the USB init things from board_usb_init(), just simply call \ndwc2_udc_probe().\n2. Create a new USB init  function in drivers/usb/gadget/dwc2_udc_otg.c，\n      and call it in dwc2_udc_probe().\n3. Use fdt (Flat Device Tree manipulation )  to parse the dts, and get \nthe regs_phy, regs_otg and so on.\n\nMethod2.\nJust like your  suggestion， use driver-model method to probe with \ndevice_probe,\nactually, I don't know much about the driver-model, as far as I know, we \nmay need\nto do the following work:\n1. Create a new uclass id for usb udc, and declare a new uclass_driver \nwith UCLASS_DRIVER,\n     and also need to create a  new U-boot driver for dwc2 controller \nwith U_BOOT_DRIVER.\n2. How to call device_probe()? Maybe it's better to create a new driver \n(like drivers/usb/host/usb-uclass.c)\n     in drivers/usb/gadget to match different usb gadget controllers, \nand wrap the device_probe()\n     to a new function (like udc_pre_probe()), and then different udc \ndriver can call it,\n     e.g.\n     dwc2_udc_probe() --> udc_pre_probe() --> device_probe()\n\nIn summary, method1 is easily to be done, but method2 is more generic.\n\nI hope I haven't misunderstood your proposal, and hope to get your reply.\nThank you!\n>\n>> +}\n>> +\n>> +int board_usb_cleanup(int index, enum usb_init_type init)\n>> +{\n>> +       return 0;\n>> +}\n>> +#endif\n>> --\n>> 2.0.0\n> Regards,\n> Simon\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 3xWC5y0m6mz9sRq\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 14 Aug 2017 20:49:07 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid BBF0EC21DE7; Mon, 14 Aug 2017 10:49:02 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id D38B1C21DA0;\n\tMon, 14 Aug 2017 10:48:59 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid F101BC21DD1; Mon, 14 Aug 2017 10:05:26 +0000 (UTC)","from regular1.263xmail.com (regular1.263xmail.com [211.150.99.138])\n\tby lists.denx.de (Postfix) with ESMTPS id DE3ADC21D5B\n\tfor <u-boot@lists.denx.de>; Mon, 14 Aug 2017 10:05:25 +0000 (UTC)","from wulf?rock-chips.com (unknown [192.168.167.110])\n\tby regular1.263xmail.com (Postfix) with ESMTP id 908ED7921;\n\tMon, 14 Aug 2017 18:05:19 +0800 (CST)","from [172.16.12.44] (localhost [127.0.0.1])\n\tby smtp.263.net (Postfix) with ESMTPA id 10BF6383;\n\tMon, 14 Aug 2017 18:05:19 +0800 (CST)","from [172.16.12.44] (unknown [58.22.7.114])\n\tby smtp.263.net (Postfix) whith ESMTP id 7367BYXWCK;\n\tMon, 14 Aug 2017 18:05:20 +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=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE\n\tautolearn=unavailable autolearn_force=no version=3.4.0","X-263anti-spam":"KSV:0;","X-MAIL-GRAY":"0","X-MAIL-DELIVERY":"1","X-KSVirus-check":"0","X-ABS-CHECKED":"4","X-RL-SENDER":"wulf@rock-chips.com","X-FST-TO":"u-boot@lists.denx.de","X-SENDER-IP":"58.22.7.114","X-LOGIN-NAME":"wulf@rock-chips.com","X-UNIQUE-TAG":"<d3de50afdacf3ac81cba45983f2c2b4d>","X-ATTACHMENT-NUM":"0","X-SENDER":"wulf@rock-chips.com","X-DNS-TYPE":"0","To":"Simon Glass <sjg@chromium.org>, William Wu <william.wu@rock-chips.com>","References":"<1502249789-11462-1-git-send-email-william.wu@rock-chips.com>\n\t<1502249789-11462-4-git-send-email-william.wu@rock-chips.com>\n\t<CAPnjgZ1R6kFFVx9jfoq1CixH_ODeeqVEQR1Z=+JKk2NbBES3GQ@mail.gmail.com>","From":"wlf <wulf@rock-chips.com>","Message-ID":"<19f8cdc0-5408-bad2-433b-660736f7394b@rock-chips.com>","Date":"Mon, 14 Aug 2017 18:05:19 +0800","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.1.1","MIME-Version":"1.0","In-Reply-To":"<CAPnjgZ1R6kFFVx9jfoq1CixH_ODeeqVEQR1Z=+JKk2NbBES3GQ@mail.gmail.com>","Content-Language":"en-US","X-Mailman-Approved-At":"Mon, 14 Aug 2017 10:48:58 +0000","Cc":"U-Boot Mailing List <u-boot@lists.denx.de>","Subject":"Re: [U-Boot] [PATCH 3/3] rockchip: evb-rv1108: add usb init\n\tfunction for dwc2 gadget","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>"}},{"id":1751273,"web_url":"http://patchwork.ozlabs.org/comment/1751273/","msgid":"<E1dijp5-0007rz-6m@mail.theobroma-systems.com>","list_archive_url":null,"date":"2017-08-18T16:08:35","subject":"Re: [U-Boot] [U-Boot,\n\t3/3] rockchip: evb-rv1108: add usb init function for dwc2 gadget","submitter":{"id":53488,"url":"http://patchwork.ozlabs.org/api/people/53488/","name":"Philipp Tomsich","email":"philipp.tomsich@theobroma-systems.com"},"content":"> This patch implements board_usb_init() for dwc2 gadget, it\n> generally called from do_fastboot to do dwc2 udc probe and\n> support fastboot over USB.\n> \n> Signed-off-by: William Wu <william.wu@rock-chips.com>\n> ---\n>  board/rockchip/evb_rv1108/evb_rv1108.c | 47 ++++++++++++++++++++++++++++++++++\n>  1 file changed, 47 insertions(+)\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 3xYp9Z08vhz9t2y\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 19 Aug 2017 02:16:18 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid D10EEC2209C; Fri, 18 Aug 2017 16:15:16 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 8D508C22073;\n\tFri, 18 Aug 2017 16:15:14 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid EFACFC22093; Fri, 18 Aug 2017 16:08:39 +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 0B295C2204D\n\tfor <u-boot@lists.denx.de>; Fri, 18 Aug 2017 16:08:36 +0000 (UTC)","from 89-104-28-141.customer.bnet.at ([89.104.28.141]:52943\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 1dijp5-0007rz-6m; Fri, 18 Aug 2017 18:08:35 +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":"William Wu <william.wu@rock-chips.com>","In-Reply-To":"<1502249789-11462-4-git-send-email-william.wu@rock-chips.com>","References":"<1502249789-11462-4-git-send-email-william.wu@rock-chips.com>","Message-Id":"<E1dijp5-0007rz-6m@mail.theobroma-systems.com>","Date":"Fri, 18 Aug 2017 18:08:35 +0200","Cc":"u-boot@lists.denx.de","Subject":"Re: [U-Boot] [U-Boot,\n\t3/3] rockchip: evb-rv1108: add usb init function for dwc2 gadget","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":1763193,"web_url":"http://patchwork.ozlabs.org/comment/1763193/","msgid":"<81759dae-cd23-8a1a-c6c2-e1d25452b4c9@rock-chips.com>","list_archive_url":null,"date":"2017-09-05T04:14:03","subject":"Re: [U-Boot] [PATCH 3/3] rockchip: evb-rv1108: add usb init\n\tfunction for dwc2 gadget","submitter":{"id":71447,"url":"http://patchwork.ozlabs.org/api/people/71447/","name":"wlf","email":"wulf@rock-chips.com"},"content":"Dear Simon,\n\n在 2017年08月14日 18:05, wlf 写道:\n> Dear Simon,\n>\n> 在 2017年08月14日 05:35, Simon Glass 写道:\n>> On 8 August 2017 at 21:36, William Wu <william.wu@rock-chips.com> wrote:\n>>> This patch implements board_usb_init() for dwc2 gadget, it\n>>> generally called from do_fastboot to do dwc2 udc probe and\n>>> support fastboot over USB.\n>>>\n>>> Signed-off-by: William Wu <william.wu@rock-chips.com>\n>>> ---\n>>>   board/rockchip/evb_rv1108/evb_rv1108.c | 47 \n>>> ++++++++++++++++++++++++++++++++++\n>>>   1 file changed, 47 insertions(+)\n>>>\n>>> diff --git a/board/rockchip/evb_rv1108/evb_rv1108.c \n>>> b/board/rockchip/evb_rv1108/evb_rv1108.c\n>>> index fe37eac..8ca5ee6 100644\n>>> --- a/board/rockchip/evb_rv1108/evb_rv1108.c\n>>> +++ b/board/rockchip/evb_rv1108/evb_rv1108.c\n>>> @@ -50,3 +50,50 @@ int dram_init_banksize(void)\n>>>\n>>>          return 0;\n>>>   }\n>>> +\n>>> +#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)\n>>> +#include <usb.h>\n>>> +#include <usb/dwc2_udc.h>\n>>> +\n>>> +static struct dwc2_plat_otg_data rv1108_otg_data = {\n>>> +       .rx_fifo_sz     = 512,\n>>> +       .np_tx_fifo_sz  = 16,\n>>> +       .tx_fifo_sz     = 128,\n>>> +};\n>>> +\n>>> +int board_usb_init(int index, enum usb_init_type init)\n>>> +{\n>>> +       int node;\n>>> +       const char *mode;\n>>> +       bool matched = false;\n>>> +       const void *blob = gd->fdt_blob;\n>>> +\n>>> +       /* find the usb_otg node */\n>>> +       node = fdt_node_offset_by_compatible(blob, -1,\n>>> + \"rockchip,rv1108-usb\");\n>>> +\n>>> +       while (node > 0) {\n>>> +               mode = fdt_getprop(blob, node, \"dr_mode\", NULL);\n>>> +               if (mode && strcmp(mode, \"otg\") == 0) {\n>>> +                       matched = true;\n>>> +                       break;\n>>> +               }\n>>> +\n>>> +               node = fdt_node_offset_by_compatible(blob, node,\n>>> + \"rockchip,rv1108-usb\");\n>>> +       }\n>>> +       if (!matched) {\n>>> +               debug(\"Not found usb_otg device\\n\");\n>>> +               return -ENODEV;\n>>> +       }\n>>> +\n>>> +       rv1108_otg_data.regs_otg = fdtdec_get_addr(blob, node, \"reg\");\n>>> +\n>>> +       return dwc2_udc_probe(&rv1108_otg_data);\n>> These USB init things have been bothering me for a while. Do you think\n>> this could be changed into a driver that you could probe with\n>> device_probe()? Then much of the code in here would not be needed and\n>> it might be easier to tidy it up when we have proper driver-model\n>> support for USB device mode.\n> Yes,  on rockchip platforms, it did most of the same USB init things \n> in different board special drivers.\n> I think may be we can try to optimize the code in two different ways.\n>\n> Method1.\n> 1. Move the USB init things from board_usb_init(), just simply call \n> dwc2_udc_probe().\n> 2. Create a new USB init  function in drivers/usb/gadget/dwc2_udc_otg.c，\n>      and call it in dwc2_udc_probe().\n> 3. Use fdt (Flat Device Tree manipulation )  to parse the dts, and get \n> the regs_phy, regs_otg and so on.\n>\n> Method2.\n> Just like your  suggestion， use driver-model method to probe with \n> device_probe,\n> actually, I don't know much about the driver-model, as far as I know, \n> we may need\n> to do the following work:\n> 1. Create a new uclass id for usb udc, and declare a new uclass_driver \n> with UCLASS_DRIVER,\n>     and also need to create a  new U-boot driver for dwc2 controller \n> with U_BOOT_DRIVER.\n> 2. How to call device_probe()? Maybe it's better to create a new \n> driver (like drivers/usb/host/usb-uclass.c)\n>     in drivers/usb/gadget to match different usb gadget controllers, \n> and wrap the device_probe()\n>     to a new function (like udc_pre_probe()), and then different udc \n> driver can call it,\n>     e.g.\n>     dwc2_udc_probe() --> udc_pre_probe() --> device_probe()\n>\n> In summary, method1 is easily to be done, but method2 is more generic.\n>\n> I hope I haven't misunderstood your proposal, and hope to get your reply.\n> Thank you!\nDo you have any idea about this USB init patch？\n\nThank you！\n>>\n>>> +}\n>>> +\n>>> +int board_usb_cleanup(int index, enum usb_init_type init)\n>>> +{\n>>> +       return 0;\n>>> +}\n>>> +#endif\n>>> -- \n>>> 2.0.0\n>> Regards,\n>> Simon\n>>\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 3xmjkH5Bkbz9s71\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue,  5 Sep 2017 20:33:59 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 7D1CDC21EB4; Tue,  5 Sep 2017 10:33:25 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 2AD00C21EEF;\n\tTue,  5 Sep 2017 10:32:53 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 5B1CDC21C41; Tue,  5 Sep 2017 04:14:10 +0000 (UTC)","from regular1.263xmail.com (regular1.263xmail.com [211.150.99.137])\n\tby lists.denx.de (Postfix) with ESMTPS id F103AC21C2B\n\tfor <u-boot@lists.denx.de>; Tue,  5 Sep 2017 04:14:08 +0000 (UTC)","from wulf?rock-chips.com (unknown [192.168.167.190])\n\tby regular1.263xmail.com (Postfix) with ESMTP id 19735DB7A;\n\tTue,  5 Sep 2017 12:14:03 +0800 (CST)","from [172.16.12.86] (localhost [127.0.0.1])\n\tby smtp.263.net (Postfix) with ESMTPA id 97CC239F;\n\tTue,  5 Sep 2017 12:14:03 +0800 (CST)","from [172.16.12.86] (unknown [58.22.7.114])\n\tby smtp.263.net (Postfix) whith ESMTP id 4234CU48Y5;\n\tTue, 05 Sep 2017 12:14:03 +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=1.9 required=5.0 tests=RCVD_IN_BL_SPAMCOP_NET,\n\tRCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,RCVD_IN_SORBS_WEB autolearn=no\n\tautolearn_force=no version=3.4.0","X-263anti-spam":"KSV:0;","X-MAIL-GRAY":"0","X-MAIL-DELIVERY":"1","X-KSVirus-check":"0","X-ABS-CHECKED":"4","X-RL-SENDER":"wulf@rock-chips.com","X-FST-TO":"u-boot@lists.denx.de","X-SENDER-IP":"58.22.7.114","X-LOGIN-NAME":"wulf@rock-chips.com","X-UNIQUE-TAG":"<fc6652a5d5270f2d1b14004995a80b81>","X-ATTACHMENT-NUM":"0","X-SENDER":"wulf@rock-chips.com","X-DNS-TYPE":"0","From":"wlf <wulf@rock-chips.com>","To":"Simon Glass <sjg@chromium.org>, William Wu <william.wu@rock-chips.com>","References":"<1502249789-11462-1-git-send-email-william.wu@rock-chips.com>\n\t<1502249789-11462-4-git-send-email-william.wu@rock-chips.com>\n\t<CAPnjgZ1R6kFFVx9jfoq1CixH_ODeeqVEQR1Z=+JKk2NbBES3GQ@mail.gmail.com>\n\t<19f8cdc0-5408-bad2-433b-660736f7394b@rock-chips.com>","Message-ID":"<81759dae-cd23-8a1a-c6c2-e1d25452b4c9@rock-chips.com>","Date":"Tue, 5 Sep 2017 12:14:03 +0800","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.1.1","MIME-Version":"1.0","In-Reply-To":"<19f8cdc0-5408-bad2-433b-660736f7394b@rock-chips.com>","Content-Language":"en-US","X-Mailman-Approved-At":"Tue, 05 Sep 2017 10:32:50 +0000","Cc":"U-Boot Mailing List <u-boot@lists.denx.de>","Subject":"Re: [U-Boot] [PATCH 3/3] rockchip: evb-rv1108: add usb init\n\tfunction for dwc2 gadget","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>"}},{"id":1765734,"web_url":"http://patchwork.ozlabs.org/comment/1765734/","msgid":"<CAPnjgZ1ETtM6dgk_0AU9dNuaiWRGNhnq4k77e8e+jWuWg37Z4A@mail.gmail.com>","list_archive_url":null,"date":"2017-09-09T04:54:45","subject":"Re: [U-Boot] [PATCH 3/3] rockchip: evb-rv1108: add usb init\n\tfunction for dwc2 gadget","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/people/6170/","name":"Simon Glass","email":"sjg@chromium.org"},"content":"Hi,\n\nOn 14 August 2017 at 04:05, wlf <wulf@rock-chips.com> wrote:\n> Dear Simon,\n>\n>\n> 在 2017年08月14日 05:35, Simon Glass 写道:\n>>\n>> On 8 August 2017 at 21:36, William Wu <william.wu@rock-chips.com> wrote:\n>>>\n>>> This patch implements board_usb_init() for dwc2 gadget, it\n>>> generally called from do_fastboot to do dwc2 udc probe and\n>>> support fastboot over USB.\n>>>\n>>> Signed-off-by: William Wu <william.wu@rock-chips.com>\n>>> ---\n>>>   board/rockchip/evb_rv1108/evb_rv1108.c | 47\n>>> ++++++++++++++++++++++++++++++++++\n>>>   1 file changed, 47 insertions(+)\n>>>\n>>> diff --git a/board/rockchip/evb_rv1108/evb_rv1108.c\n>>> b/board/rockchip/evb_rv1108/evb_rv1108.c\n>>> index fe37eac..8ca5ee6 100644\n>>> --- a/board/rockchip/evb_rv1108/evb_rv1108.c\n>>> +++ b/board/rockchip/evb_rv1108/evb_rv1108.c\n>>> @@ -50,3 +50,50 @@ int dram_init_banksize(void)\n>>>\n>>>          return 0;\n>>>   }\n>>> +\n>>> +#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)\n>>> +#include <usb.h>\n>>> +#include <usb/dwc2_udc.h>\n>>> +\n>>> +static struct dwc2_plat_otg_data rv1108_otg_data = {\n>>> +       .rx_fifo_sz     = 512,\n>>> +       .np_tx_fifo_sz  = 16,\n>>> +       .tx_fifo_sz     = 128,\n>>> +};\n>>> +\n>>> +int board_usb_init(int index, enum usb_init_type init)\n>>> +{\n>>> +       int node;\n>>> +       const char *mode;\n>>> +       bool matched = false;\n>>> +       const void *blob = gd->fdt_blob;\n>>> +\n>>> +       /* find the usb_otg node */\n>>> +       node = fdt_node_offset_by_compatible(blob, -1,\n>>> +                                       \"rockchip,rv1108-usb\");\n>>> +\n>>> +       while (node > 0) {\n>>> +               mode = fdt_getprop(blob, node, \"dr_mode\", NULL);\n>>> +               if (mode && strcmp(mode, \"otg\") == 0) {\n>>> +                       matched = true;\n>>> +                       break;\n>>> +               }\n>>> +\n>>> +               node = fdt_node_offset_by_compatible(blob, node,\n>>> +                                       \"rockchip,rv1108-usb\");\n>>> +       }\n>>> +       if (!matched) {\n>>> +               debug(\"Not found usb_otg device\\n\");\n>>> +               return -ENODEV;\n>>> +       }\n>>> +\n>>> +       rv1108_otg_data.regs_otg = fdtdec_get_addr(blob, node, \"reg\");\n>>> +\n>>> +       return dwc2_udc_probe(&rv1108_otg_data);\n>>\n>> These USB init things have been bothering me for a while. Do you think\n>> this could be changed into a driver that you could probe with\n>> device_probe()? Then much of the code in here would not be needed and\n>> it might be easier to tidy it up when we have proper driver-model\n>> support for USB device mode.\n>\n> Yes,  on rockchip platforms, it did most of the same USB init things in\n> different board special drivers.\n> I think may be we can try to optimize the code in two different ways.\n>\n> Method1.\n> 1. Move the USB init things from board_usb_init(), just simply call\n> dwc2_udc_probe().\n> 2. Create a new USB init  function in drivers/usb/gadget/dwc2_udc_otg.c，\n>      and call it in dwc2_udc_probe().\n> 3. Use fdt (Flat Device Tree manipulation )  to parse the dts, and get the\n> regs_phy, regs_otg and so on.\n>\n> Method2.\n> Just like your  suggestion， use driver-model method to probe with\n> device_probe,\n> actually, I don't know much about the driver-model, as far as I know, we may\n> need\n> to do the following work:\n> 1. Create a new uclass id for usb udc, and declare a new uclass_driver with\n> UCLASS_DRIVER,\n>     and also need to create a  new U-boot driver for dwc2 controller with\n> U_BOOT_DRIVER.\n> 2. How to call device_probe()? Maybe it's better to create a new driver\n> (like drivers/usb/host/usb-uclass.c)\n>     in drivers/usb/gadget to match different usb gadget controllers, and\n> wrap the device_probe()\n>     to a new function (like udc_pre_probe()), and then different udc driver\n> can call it,\n>     e.g.\n>     dwc2_udc_probe() --> udc_pre_probe() --> device_probe()\n>\n> In summary, method1 is easily to be done, but method2 is more generic.\n>\n> I hope I haven't misunderstood your proposal, and hope to get your reply.\n> Thank you!\n\nYes I think method 2 is better.\n\nYou will have to call device_probe() as you say. I think what you\nsuggest is reasonable, since something has to decide that the USB\ndevice mode should be started.\n\nRegards,\nSimon","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>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=google.com header.i=@google.com\n\theader.b=\"kthne7ik\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"nyLUSpbD\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xq2MG5ryXz9sBZ\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  9 Sep 2017 15:10:34 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 33B02C21F77; Sat,  9 Sep 2017 05:02:41 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id A8A43C21FBC;\n\tSat,  9 Sep 2017 04:57:27 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 828A8C21F44; Sat,  9 Sep 2017 04:56:33 +0000 (UTC)","from mail-qt0-f175.google.com (mail-qt0-f175.google.com\n\t[209.85.216.175])\n\tby lists.denx.de (Postfix) with ESMTPS id 3E295C21F38\n\tfor <u-boot@lists.denx.de>; Sat,  9 Sep 2017 04:55:07 +0000 (UTC)","by mail-qt0-f175.google.com with SMTP id q8so10591868qtb.5\n\tfor <u-boot@lists.denx.de>; Fri, 08 Sep 2017 21:55:07 -0700 (PDT)","by 10.200.37.200 with HTTP; Fri, 8 Sep 2017 21:54:45 -0700 (PDT)"],"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=RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\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=google.com;\n\ts=20161025; \n\th=mime-version:sender:in-reply-to:references:from:date:message-id\n\t:subject:to:cc:content-transfer-encoding;\n\tbh=p8LB4e/uzovNgO3XYEcD1BH1wlNdpfUoiMBzNBp6h1M=;\n\tb=kthne7ikt4G4emcUuqKHiMFLoOdwKf/N7wRealXiFlea0YPC4yF18vICYmWohIE6oP\n\tQqMH2QwHk7NRRaTSW0uUds0JTBVfgNh+m6xttDV2tTv+eeiMAjvM6Sh6KFKxNfEGTNMK\n\tCdRhfCnluVvYsQi/Rtsv68jgSI3mMx7OgXrtOhENoeCPjoXXN2S7zM0rszFEEEMoarbb\n\t8TAqxjejnFkujRyyTftHWvXQ6YX0c0Vu7+H+TmCcoIA+Xx0U2cWqKhEycN5ZU+RbV5dN\n\t/aOFfdTYOUbMCMsNrCTeoYfK92fFkW5nc3CTEkOP82pOmxEgGODu7rNrWZCzi9XfulsW\n\t3Wpw==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:sender:in-reply-to:references:from:date:message-id\n\t:subject:to:cc:content-transfer-encoding;\n\tbh=p8LB4e/uzovNgO3XYEcD1BH1wlNdpfUoiMBzNBp6h1M=;\n\tb=nyLUSpbDYG+A5FgYP4Kyo3QMPzyNPZGFPFm17u+mfLfgWgkW7oOoZZvmEaUOv9RN5y\n\tDjJwLdhwuKrOoCSpakL5WbB8OWjMqwEOL2jUGSjlzDooKqoad8MNC3ma7oG7Vid+5Hjt\n\txXyio56hITRRP+PpzSLZrwlEJlGMq90YPUjjA="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:sender:in-reply-to:references:from\n\t:date:message-id:subject:to:cc:content-transfer-encoding;\n\tbh=p8LB4e/uzovNgO3XYEcD1BH1wlNdpfUoiMBzNBp6h1M=;\n\tb=px2OPX8rX1ob4pm9qqcQZoacFidjiDbl9NUc9wKc60gdaE2yUPsEPVzWLdxDipwsGB\n\tNz3W0ASHlVUV1rLYpdcxmEF6pDOs8cea2HaFe278xCauvdBYeflZx1lWfE1FVZOijyDc\n\trfQG6AdX+QW71TzsWN2W9FnI5IrPCvFb6avdkJqDmRVWtcO29gs/3zyjOEs+9Igh5XcS\n\t2hvrxmadciJNFhWyVCk9inJb1IWUCc8oQzOrJOQge0GzYrTyd2OJNXVcFDm1R+g5JD4t\n\tMJpyiaiPSAPABFuT0/Jnuv/h+BzbiRbaNwCot5lOo4s3j8QgVkvFL/XQitObGCLp57M1\n\t4p3Q==","X-Gm-Message-State":"AHPjjUjbo2+f/p4U4ItC77lazD0QIaSfMinUvhyRvBzhioFTEuZxwjAO\n\toYV8G01W9C01nha1O4Aaq4HVkdqPv4A0awwFVkPx6Hid","X-Google-Smtp-Source":"AOwi7QAhS3o3lO0DVwkFlg/ikAkddNTIGRNS2Fy+Sf3fcZtne6R5/j4FuH99ZGfBmR7f8M1X98L8t0Mjsu1C39E55vw=","X-Received":"by 10.237.35.238 with SMTP id k43mr7438390qtc.214.1504932905897; \n\tFri, 08 Sep 2017 21:55:05 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<19f8cdc0-5408-bad2-433b-660736f7394b@rock-chips.com>","References":"<1502249789-11462-1-git-send-email-william.wu@rock-chips.com>\n\t<1502249789-11462-4-git-send-email-william.wu@rock-chips.com>\n\t<CAPnjgZ1R6kFFVx9jfoq1CixH_ODeeqVEQR1Z=+JKk2NbBES3GQ@mail.gmail.com>\n\t<19f8cdc0-5408-bad2-433b-660736f7394b@rock-chips.com>","From":"Simon Glass <sjg@chromium.org>","Date":"Fri, 8 Sep 2017 22:54:45 -0600","X-Google-Sender-Auth":"mc-_VZI7_JviqWXdy0LRPD-avps","Message-ID":"<CAPnjgZ1ETtM6dgk_0AU9dNuaiWRGNhnq4k77e8e+jWuWg37Z4A@mail.gmail.com>","To":"wlf <wulf@rock-chips.com>","Cc":"U-Boot Mailing List <u-boot@lists.denx.de>","Subject":"Re: [U-Boot] [PATCH 3/3] rockchip: evb-rv1108: add usb init\n\tfunction for dwc2 gadget","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":1766037,"web_url":"http://patchwork.ozlabs.org/comment/1766037/","msgid":"<c7663ab3-16a6-e494-f91e-4b02a45af0e4@rock-chips.com>","list_archive_url":null,"date":"2017-09-11T03:51:23","subject":"Re: [U-Boot] [PATCH 3/3] rockchip: evb-rv1108: add usb init\n\tfunction for dwc2 gadget","submitter":{"id":71447,"url":"http://patchwork.ozlabs.org/api/people/71447/","name":"wlf","email":"wulf@rock-chips.com"},"content":"Dear Simon,\n\n在 2017年09月09日 12:54, Simon Glass 写道:\n> Hi,\n>\n> On 14 August 2017 at 04:05, wlf <wulf@rock-chips.com> wrote:\n>> Dear Simon,\n>>\n>>\n>> 在 2017年08月14日 05:35, Simon Glass 写道:\n>>> On 8 August 2017 at 21:36, William Wu <william.wu@rock-chips.com> wrote:\n>>>> This patch implements board_usb_init() for dwc2 gadget, it\n>>>> generally called from do_fastboot to do dwc2 udc probe and\n>>>> support fastboot over USB.\n>>>>\n>>>> Signed-off-by: William Wu <william.wu@rock-chips.com>\n>>>> ---\n>>>>    board/rockchip/evb_rv1108/evb_rv1108.c | 47\n>>>> ++++++++++++++++++++++++++++++++++\n>>>>    1 file changed, 47 insertions(+)\n>>>>\n>>>> diff --git a/board/rockchip/evb_rv1108/evb_rv1108.c\n>>>> b/board/rockchip/evb_rv1108/evb_rv1108.c\n>>>> index fe37eac..8ca5ee6 100644\n>>>> --- a/board/rockchip/evb_rv1108/evb_rv1108.c\n>>>> +++ b/board/rockchip/evb_rv1108/evb_rv1108.c\n>>>> @@ -50,3 +50,50 @@ int dram_init_banksize(void)\n>>>>\n>>>>           return 0;\n>>>>    }\n>>>> +\n>>>> +#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)\n>>>> +#include <usb.h>\n>>>> +#include <usb/dwc2_udc.h>\n>>>> +\n>>>> +static struct dwc2_plat_otg_data rv1108_otg_data = {\n>>>> +       .rx_fifo_sz     = 512,\n>>>> +       .np_tx_fifo_sz  = 16,\n>>>> +       .tx_fifo_sz     = 128,\n>>>> +};\n>>>> +\n>>>> +int board_usb_init(int index, enum usb_init_type init)\n>>>> +{\n>>>> +       int node;\n>>>> +       const char *mode;\n>>>> +       bool matched = false;\n>>>> +       const void *blob = gd->fdt_blob;\n>>>> +\n>>>> +       /* find the usb_otg node */\n>>>> +       node = fdt_node_offset_by_compatible(blob, -1,\n>>>> +                                       \"rockchip,rv1108-usb\");\n>>>> +\n>>>> +       while (node > 0) {\n>>>> +               mode = fdt_getprop(blob, node, \"dr_mode\", NULL);\n>>>> +               if (mode && strcmp(mode, \"otg\") == 0) {\n>>>> +                       matched = true;\n>>>> +                       break;\n>>>> +               }\n>>>> +\n>>>> +               node = fdt_node_offset_by_compatible(blob, node,\n>>>> +                                       \"rockchip,rv1108-usb\");\n>>>> +       }\n>>>> +       if (!matched) {\n>>>> +               debug(\"Not found usb_otg device\\n\");\n>>>> +               return -ENODEV;\n>>>> +       }\n>>>> +\n>>>> +       rv1108_otg_data.regs_otg = fdtdec_get_addr(blob, node, \"reg\");\n>>>> +\n>>>> +       return dwc2_udc_probe(&rv1108_otg_data);\n>>> These USB init things have been bothering me for a while. Do you think\n>>> this could be changed into a driver that you could probe with\n>>> device_probe()? Then much of the code in here would not be needed and\n>>> it might be easier to tidy it up when we have proper driver-model\n>>> support for USB device mode.\n>> Yes,  on rockchip platforms, it did most of the same USB init things in\n>> different board special drivers.\n>> I think may be we can try to optimize the code in two different ways.\n>>\n>> Method1.\n>> 1. Move the USB init things from board_usb_init(), just simply call\n>> dwc2_udc_probe().\n>> 2. Create a new USB init  function in drivers/usb/gadget/dwc2_udc_otg.c，\n>>       and call it in dwc2_udc_probe().\n>> 3. Use fdt (Flat Device Tree manipulation )  to parse the dts, and get the\n>> regs_phy, regs_otg and so on.\n>>\n>> Method2.\n>> Just like your  suggestion， use driver-model method to probe with\n>> device_probe,\n>> actually, I don't know much about the driver-model, as far as I know, we may\n>> need\n>> to do the following work:\n>> 1. Create a new uclass id for usb udc, and declare a new uclass_driver with\n>> UCLASS_DRIVER,\n>>      and also need to create a  new U-boot driver for dwc2 controller with\n>> U_BOOT_DRIVER.\n>> 2. How to call device_probe()? Maybe it's better to create a new driver\n>> (like drivers/usb/host/usb-uclass.c)\n>>      in drivers/usb/gadget to match different usb gadget controllers, and\n>> wrap the device_probe()\n>>      to a new function (like udc_pre_probe()), and then different udc driver\n>> can call it,\n>>      e.g.\n>>      dwc2_udc_probe() --> udc_pre_probe() --> device_probe()\n>>\n>> In summary, method1 is easily to be done, but method2 is more generic.\n>>\n>> I hope I haven't misunderstood your proposal, and hope to get your reply.\n>> Thank you!\n> Yes I think method 2 is better.\n>\n> You will have to call device_probe() as you say. I think what you\n> suggest is reasonable, since something has to decide that the USB\n> device mode should be started.\nThanks for your reply.  I will try to update a new patch according to \nmethod 2.\n\n>\n> Regards,\n> Simon\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 3xrDWQ2BzKz9s7g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 11 Sep 2017 13:51:44 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid C7B69C21C71; Mon, 11 Sep 2017 03:51:36 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 7359CC21C58;\n\tMon, 11 Sep 2017 03:51:33 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid C8E5AC21C58; Mon, 11 Sep 2017 03:51:31 +0000 (UTC)","from regular1.263xmail.com (regular1.263xmail.com [211.150.99.137])\n\tby lists.denx.de (Postfix) with ESMTPS id B1D22C21C4C\n\tfor <u-boot@lists.denx.de>; Mon, 11 Sep 2017 03:51:30 +0000 (UTC)","from wulf?rock-chips.com (unknown [192.168.167.177])\n\tby regular1.263xmail.com (Postfix) with ESMTP id 8E3D6DB91;\n\tMon, 11 Sep 2017 11:51:25 +0800 (CST)","from [172.16.12.172] (localhost [127.0.0.1])\n\tby smtp.263.net (Postfix) with ESMTPA id 610183D9;\n\tMon, 11 Sep 2017 11:51:25 +0800 (CST)","from [172.16.12.172] (unknown [58.22.7.114])\n\tby smtp.263.net (Postfix) whith ESMTP id 26162Z1FB8C;\n\tMon, 11 Sep 2017 11:51:25 +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=0.6 required=5.0 tests=RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_MSPIKE_H2,RCVD_IN_SORBS_WEB autolearn=no autolearn_force=no\n\tversion=3.4.0","X-263anti-spam":"KSV:0;","X-MAIL-GRAY":"0","X-MAIL-DELIVERY":"1","X-KSVirus-check":"0","X-ABS-CHECKED":"4","X-RL-SENDER":"wulf@rock-chips.com","X-FST-TO":"u-boot@lists.denx.de","X-SENDER-IP":"58.22.7.114","X-LOGIN-NAME":"wulf@rock-chips.com","X-UNIQUE-TAG":"<4b76740fac1387e76b665065ddb7d76c>","X-ATTACHMENT-NUM":"0","X-SENDER":"wulf@rock-chips.com","X-DNS-TYPE":"0","To":"Simon Glass <sjg@chromium.org>","References":"<1502249789-11462-1-git-send-email-william.wu@rock-chips.com>\n\t<1502249789-11462-4-git-send-email-william.wu@rock-chips.com>\n\t<CAPnjgZ1R6kFFVx9jfoq1CixH_ODeeqVEQR1Z=+JKk2NbBES3GQ@mail.gmail.com>\n\t<19f8cdc0-5408-bad2-433b-660736f7394b@rock-chips.com>\n\t<CAPnjgZ1ETtM6dgk_0AU9dNuaiWRGNhnq4k77e8e+jWuWg37Z4A@mail.gmail.com>","From":"wlf <wulf@rock-chips.com>","Message-ID":"<c7663ab3-16a6-e494-f91e-4b02a45af0e4@rock-chips.com>","Date":"Mon, 11 Sep 2017 11:51:23 +0800","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.1.1","MIME-Version":"1.0","In-Reply-To":"<CAPnjgZ1ETtM6dgk_0AU9dNuaiWRGNhnq4k77e8e+jWuWg37Z4A@mail.gmail.com>","Content-Language":"en-US","Cc":"U-Boot Mailing List <u-boot@lists.denx.de>","Subject":"Re: [U-Boot] [PATCH 3/3] rockchip: evb-rv1108: add usb init\n\tfunction for dwc2 gadget","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>"}}]