[{"id":1766021,"web_url":"http://patchwork.ozlabs.org/comment/1766021/","msgid":"<c77a2acf-dabb-0363-55c3-654147284401@gmail.com>","list_archive_url":null,"date":"2017-09-10T23:05:14","subject":"Re: [LEDE-DEV] [PATCH] ar71xx: Chipidea USB device support for\n\tQCA953x","submitter":{"id":66900,"url":"http://patchwork.ozlabs.org/api/people/66900/","name":"Piotr Dymacz","email":"pepe2k@gmail.com"},"content":"Hello Sergey,\n\nOn 01.09.2017 06:16, adron@yapic.net wrote:\n> From: Sergey Sergeev <adron@yapic.net>\n> \n> Changes the platform to use the Chipidea driver instead of the\n> generic USB host driver which has support for both host and\n> device modes (selected on boot) for QCA953x based boards.\n> \n> It was tested on GL.iNet GL-AR300M with USB DEVICE mode config.\n> \n> More details is available here:\n> https://github.com/adron-s/QCA953x-usb-device-mode\n\nPlease, have a look at 'ar71xx_qca9k-usb-device-mode' branch in my \nstaging tree [1]. There is a slightly modified version of Felix's \n'ar71xx: rework chipidea usb controller patch' change, from his staging \ntree [2].\n\nI tested it successfully on AR9331, AR9344, QCA9531 and QCA9557 based \ndevices (I plan to make some tests on QCA956x later), with USB in device \nand host mode. I also dropped 'ar933x_usb_setup_ctrl_config()' function \nwhich was toggling 'HOST_ONLY' bit in 'USB_CONFIG' register as it wasn't \nmake any difference on all tested platforms.\n\n[1] https://git.lede-project.org/?p=lede/pepe2k/staging.git;a=summary\n[2] https://git.lede-project.org/?p=lede/nbd/staging.git;a=summary\n\n--\nCheers,\nPiotr\n\n> \n> Signed-off-by: Sergey Sergeev <adron@yapic.net>\n> ---\n>   ...940-usb-chipidea-QCA953x-platform-support.patch | 87 ++++++++++++++++++++++\n>   1 file changed, 87 insertions(+)\n>   create mode 100644 target/linux/ar71xx/patches-4.4/940-usb-chipidea-QCA953x-platform-support.patch\n> \n> diff --git a/target/linux/ar71xx/patches-4.4/940-usb-chipidea-QCA953x-platform-support.patch b/target/linux/ar71xx/patches-4.4/940-usb-chipidea-QCA953x-platform-support.patch\n> new file mode 100644\n> index 0000000..a3e2509\n> --- /dev/null\n> +++ b/target/linux/ar71xx/patches-4.4/940-usb-chipidea-QCA953x-platform-support.patch\n> @@ -0,0 +1,87 @@\n> +--- a/arch/mips/ath79/dev-usb.c\n> ++++ b/arch/mips/ath79/dev-usb.c\n> +@@ -286,6 +286,51 @@\n> + \t\t\t   &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));\n> + }\n> +\n> ++#if IS_ENABLED(CONFIG_USB_CHIPIDEA)\n> ++static void __init qca953x_usb_setup_ctrl_config(void)\n> ++{\n> ++\tvoid __iomem *usb_ctrl_base, *usb_config_reg;\n> ++\tu32 usb_config;\n> ++\n> ++\tusb_ctrl_base = ioremap(AR71XX_USB_CTRL_BASE, AR71XX_USB_CTRL_SIZE);\n> ++\tusb_config_reg = usb_ctrl_base + AR71XX_USB_CTRL_REG_CONFIG;\n> ++\tusb_config = __raw_readl(usb_config_reg);\n> ++\tusb_config &= ~QCA953X_USB_CONFIG_HOST_ONLY;\n> ++\t__raw_writel(usb_config, usb_config_reg);\n> ++\tiounmap(usb_ctrl_base);\n> ++}\n> ++\n> ++static void __init qca953x_ci_usb_setup(u32 bootstrap)\n> ++{\n> ++\tenum usb_dr_mode dr_mode;\n> ++\tstruct ci_hdrc_platform_data ci_pdata;\n> ++\n> ++\tif (bootstrap & QCA953X_BOOTSTRAP_USB_MODE_DEVICE) {\n> ++\t\tdr_mode = USB_DR_MODE_PERIPHERAL;\n> ++\t\tqca953x_usb_setup_ctrl_config();\n> ++\t} else {\n> ++\t\tdr_mode = USB_DR_MODE_HOST;\n> ++\t}\n> ++\n> ++\tmemset(&ci_pdata, 0, sizeof(ci_pdata));\n> ++\tci_pdata.name = \"ci_hdrc_qca953x\";\n> ++\tci_pdata.capoffset = DEF_CAPOFFSET;\n> ++\tci_pdata.dr_mode = dr_mode;\n> ++\tci_pdata.flags = CI_HDRC_DUAL_ROLE_NOT_OTG | CI_HDRC_DP_ALWAYS_PULLUP;\n> ++\tci_pdata.vbus_extcon.edev = ERR_PTR(-ENODEV);\n> ++\tci_pdata.id_extcon.edev = ERR_PTR(-ENODEV);\n> ++\tci_pdata.itc_setting = 1;\n> ++\n> ++\tplatform_device_register_simple(\"usb_phy_generic\",\n> ++\t\t\t\t\tPLATFORM_DEVID_AUTO, NULL, 0);\n> ++\n> ++\tath79_usb_register(\"ci_hdrc\", -1,\n> ++\t\t\t   QCA953X_EHCI_BASE, QCA953X_EHCI_SIZE,\n> ++\t\t\t   ATH79_CPU_IRQ(3),\n> ++\t\t\t   &ci_pdata, sizeof(ci_pdata));\n> ++}\n> ++#endif\n> ++\n> + static void __init qca953x_usb_setup(void)\n> + {\n> + \tu32 bootstrap;\n> +@@ -304,10 +349,14 @@\n> + \tath79_device_reset_clear(QCA953X_RESET_USB_HOST);\n> + \tudelay(1000);\n> +\n> ++#if IS_ENABLED(CONFIG_USB_CHIPIDEA)\n> ++\tqca953x_ci_usb_setup(bootstrap);\n> ++#else\n> + \tath79_usb_register(\"ehci-platform\", -1,\n> + \t\t\t   QCA953X_EHCI_BASE, QCA953X_EHCI_SIZE,\n> + \t\t\t   ATH79_CPU_IRQ(3),\n> + \t\t\t   &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));\n> ++#endif\n> + }\n> +\n> + static void qca955x_usb_reset_notifier(struct platform_device *pdev)\n> +--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h\n> ++++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h\n> +@@ -660,6 +660,7 @@\n> + #define AR933X_BOOTSTRAP_MDIO_GPIO_EN\tBIT(18)\n> + #define AR933X_BOOTSTRAP_EEPBUSY\tBIT(4)\n> + #define AR933X_BOOTSTRAP_USB_MODE_HOST\tBIT(3)\n> ++#define QCA953X_BOOTSTRAP_USB_MODE_DEVICE BIT(7)\n> + #define AR933X_BOOTSTRAP_REF_CLK_40\tBIT(0)\n> +\n> + #define AR934X_BOOTSTRAP_SW_OPTION8\tBIT(23)\n> +@@ -690,6 +691,7 @@\n> + #define QCA956X_BOOTSTRAP_REF_CLK_40\tBIT(2)\n> +\n> + #define AR933X_USB_CONFIG_HOST_ONLY   BIT(8)\n> ++#define QCA953X_USB_CONFIG_HOST_ONLY\tBIT(4)\n> +\n> + #define AR934X_PCIE_WMAC_INT_WMAC_MISC\t\tBIT(0)\n> + #define AR934X_PCIE_WMAC_INT_WMAC_TX\t\tBIT(1)\n>","headers":{"Return-Path":"<lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org; spf=none (mailfrom)\n\tsmtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133;\n\thelo=bombadil.infradead.org;\n\tenvelope-from=lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"gFJMTW9O\"; \n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"pJ6PW0nH\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xr69l0Rmvz9s5L\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 11 Sep 2017 09:06:00 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1drBIR-0003dy-RE; Sun, 10 Sep 2017 23:05:47 +0000","from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1drBIM-0003Wg-Gr\n\tfor lede-dev@lists.infradead.org; Sun, 10 Sep 2017 23:05:45 +0000","by mail-lf0-x242.google.com with SMTP id y15so3211195lfd.0\n\tfor <lede-dev@lists.infradead.org>;\n\tSun, 10 Sep 2017 16:05:18 -0700 (PDT)","from [192.168.55.103] (178235216171.warszawa.vectranet.pl.\n\t[178.235.216.171]) by smtp.gmail.com with ESMTPSA id\n\tb4sm120430lfg.90.2017.09.10.16.05.14\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSun, 10 Sep 2017 16:05:15 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type:\n\tContent-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive:\n\tList-Unsubscribe:List-Id:Subject:In-Reply-To:MIME-Version:Date:Message-ID:\n\tFrom:References:To:Reply-To:Content-ID:Content-Description:Resent-Date:\n\tResent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner;\n\tbh=WZ1B8bsegvpjsAmLRwBrx5vfwJLIdnjEbvz4sDNwUEQ=;\n\tb=gFJMTW9OCyu1s+RBY9mShaMwm\n\tMlot5tIg0tI4iE5lINjN0gebJeEXwQLPKW39Aast7DxFvK2uRa03NbpiRhRxpLz5i7vvFuqYMceIp\n\tnjyixUdmfNwHRc3ijIKAW2Kb3owSp8SebaKbYyJ6LvnE/cBmDwaF7iUfrwxqxlbLkmv5zP8/DDWoU\n\trUtHADfd6nEauoMijKu5/cJxZl5bBqFG/AfPWQoRvAbdA1L/I2818n+T0dXuSbCteJkDX09uIERpO\n\tDGsepy72xeNYpw4Ybre74ona79WoL36NBcLtiPS6JA2CK1Pff8s0yZ2SrtKpQVsQLfNPwjSs1L2wZ\n\tJ/UwGIH0w==;","v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=subject:to:references:cc:from:message-id:date:user-agent\n\t:mime-version:in-reply-to:content-language:content-transfer-encoding; \n\tbh=/RQc2XgGE+62IgDgSjAr0H0hIpRJtAxM0nwUq8fLKDU=;\n\tb=pJ6PW0nH+oq82MuydyMym6B5ukMOxzFYW5qrxEFqmE9o/dOT4Cb4NDJmNj91Oc+v6Y\n\tbWTB8dn+16ccs1OVtbTNolO6mSuTi7QWn9bu5pTXayRzqhbWr0qBD12CYKDOn8KL+yq8\n\tdukIxQV/R6t5C17gzAaTMbdm5W2t/eBCvSAkq5im9yyZEFPGZqHUxQYhL/ukvk7aGVg3\n\tH1HPPI+uUZ0JJo07ctLVd73goJvEoq0t8C6F+NtDKs4800x5yXR2A+t/MX94BF0Biq3n\n\tibldSxH/88rm3rQVXmw4kdeJgC+inSgnTD9EqDaxa48LmRGuCKtoBlhWFqvUhpEcruPs\n\twtxQ=="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:subject:to:references:cc:from:message-id:date\n\t:user-agent:mime-version:in-reply-to:content-language\n\t:content-transfer-encoding;\n\tbh=/RQc2XgGE+62IgDgSjAr0H0hIpRJtAxM0nwUq8fLKDU=;\n\tb=P3UeHFP2HIukHW7bhgxfMefeCNLNaQsyDf/y4ompDkDv2RabzylTzv2WKSkLl+TVeY\n\tzvairCCi3HUD7ZHAxacLe9tDfj8AfB44N4ZQIOfGAmgqi93A4gtpSV5JWbQq9CYevNnj\n\tAIrpQUag1FePWvOCOPUnd7f0BdZOhArkijz0DAmSglLBthx0QK6FmA7re522tDuMihEc\n\ttrkK2MUAioL+w9pLLg4hNDdDmA44xHxNFEzR/GgjKMTEIpM4oxJwzdP8MrywXFyhoQMK\n\tyl4dKtM9gd2MauDmS7D4RftuyZfr0Z//OGGrPDgiNLKGopLj3uMlj17ouxJXAKp5QF+T\n\tfeWA==","X-Gm-Message-State":"AHPjjUjdR6428GaSXSmSX2d7NAY0Li8alL9zrexj/ISkaUt89kg+SxA8\n\tTMR8sYfr2Qh0oGsn3Pc=","X-Google-Smtp-Source":"AOwi7QAEubHDdlvY0H2FG3k5c02chkULowOhpJo0kSox4myhz0NjqjOxSUbw7eYn7a1ywXLhqNU9yw==","X-Received":"by 10.25.229.74 with SMTP id c71mr3428335lfh.148.1505084716928; \n\tSun, 10 Sep 2017 16:05:16 -0700 (PDT)","To":"adron@yapic.net","References":"<1504239396-26149-1-git-send-email-adron@yapic.net>","From":"Piotr Dymacz <pepe2k@gmail.com>","Message-ID":"<c77a2acf-dabb-0363-55c3-654147284401@gmail.com>","Date":"Mon, 11 Sep 2017 01:05: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":"<1504239396-26149-1-git-send-email-adron@yapic.net>","Content-Language":"en-US","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170910_160542_794453_FAFE8B1D ","X-CRM114-Status":"GOOD (  17.07  )","X-Spam-Score":"-2.7 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.7 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/,\n\tlow\n\ttrust [2a00:1450:4010:c07:0:0:0:242 listed in] [list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\n\tprovider (pepe2k[at]gmail.com)\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain","Subject":"Re: [LEDE-DEV] [PATCH] ar71xx: Chipidea USB device support for\n\tQCA953x","X-BeenThere":"lede-dev@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<lede-dev.lists.infradead.org>","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/lede-dev>,\n\t<mailto:lede-dev-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/lede-dev/>","List-Post":"<mailto:lede-dev@lists.infradead.org>","List-Help":"<mailto:lede-dev-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/lede-dev>,\n\t<mailto:lede-dev-request@lists.infradead.org?subject=subscribe>","Cc":"lede-dev@lists.infradead.org, Felix Fietkau <nbd@nbd.name>","Content-Transfer-Encoding":"7bit","Content-Type":"text/plain; charset=\"us-ascii\"; Format=\"flowed\"","Sender":"\"Lede-dev\" <lede-dev-bounces@lists.infradead.org>","Errors-To":"lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org"}}]