From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755457AbdKGHjk (ORCPT ); Tue, 7 Nov 2017 02:39:40 -0500 Received: from mail-sn1nam02on0066.outbound.protection.outlook.com ([104.47.36.66]:51931 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753543AbdKGHjd (ORCPT ); Tue, 7 Nov 2017 02:39:33 -0500 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; From: Ran Wang To: , , , , Felipe Balbi CC: , , , , , , , , , , , Shawn Guo , Sriram Dash , Li Yang , Hongtao Jia , Ran Wang Subject: [PATCH v2 1/3] drivers: usb: phy: Add qoriq usb 3.0 phy driver support Date: Tue, 7 Nov 2017 15:20:53 +0800 Message-ID: <20171107072055.26945-1-ran.wang_1@nxp.com> X-Mailer: git-send-email 2.14.1 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131545139716297075;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(7966004)(336005)(39380400002)(376002)(346002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(106466001)(498600001)(6666003)(50226002)(8656006)(8676002)(47776003)(105606002)(8936002)(81156014)(81166006)(5003940100001)(316002)(575784001)(86362001)(39060400002)(4326008)(53936002)(5660300001)(16586007)(68736007)(110136005)(54906003)(2201001)(33646002)(48376002)(305945005)(50466002)(77096006)(104016004)(36756003)(85426001)(7416002)(1076002)(356003)(2906002)(97736004)(50986999)(189998001)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR03MB2697;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD043;1:alUm5fAd7UprFWsPc1BO6LSjsak6FNof+je06tCjDHhD22UXf9OiYxyrdVBmCyXjgbkCw5V0o1rB2m708TpwBpPEctuy3r68CzC+to+mHrnqKso5dRnlimscTAxgBpeg MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 31266c5c-9692-4cef-b012-08d525b2af2c X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(4534020)(4628075)(201703131517081)(2017052603199);SRVR:DM5PR03MB2697; X-Microsoft-Exchange-Diagnostics: 1;DM5PR03MB2697;3:uU7TFjEgGHM/43OrfItMoAEXuXMq7+aDWnqwuf4E9IPtOGxmhtb34fJMOqhZE491OS6Jo0ArtGahK0bV1Ngv1s2+eVsPnvQsLC9AaIH+hjE8drwf69+FcxLCRTUd0aPDQXKUJ1jUz4ac4FBM60ON86aryFm0iWsNqbf/2WMjNGAvkJ6Xvt8bzOlpFZX10lp5E+e688ljmHs8bLLoIWzCkT+c5+b4V1W7QsrPeXdKellTfKgfuVCT5CO9asaOFjwzkakmbtlVHPSzrxj7sj+2qbEFFTT3+AhY6z7yRs3hNJDfBFyeDCWJ+INKrTSblG+XYPlzK7w4xV7w15yPg+xpqSupxzcYYFZ5QBSbCJZinkM=;25:YWQ4cF7Cpv9eLzZVjeoNEjkcy4Wo4CigetPIU6bSoRs0XDlqaUXv5Qzjjg2KkGHB+mGw9CH93w53QPglAd8oE9NxI0gbkxO/PQzE8fYwNHu9oSqHVeprIaOgTYm244PJh4l6kYbDK+pLJEPsLFZB4i9erm6XErmOqnzp3RiVExD/hd4pLwYl9x8bXScG0TNh67xmixoUoVoQbroQvth/OEZeQJ2LCJXnc2HOWlsm/IWWIjWyNTGm9eWW+JW2zE+skhFYJigiVqhP49uOp643bAOK/b0NMIgrLFqK9Xw0OhIbqTODpvFztVoDe+ppik7ATBbg2VrlIc90mYZZOqBoBg== X-MS-TrafficTypeDiagnostic: DM5PR03MB2697: X-Microsoft-Exchange-Diagnostics: 1;DM5PR03MB2697;31:DHKiFsZ4IKkKwuiwn2NHBxRDgDY2T09Xl77cexBDfhwmM5TBEDzCPPNPDENQytYIouUcNcJbajZQwFO0K+bHvm1LMub0ieL6eRz1hiFHPAiVvo0i/b3OjR9t2tKZxG8CFFlEXyVkBn7QrZML1n86tQGDin2UdhKsfxZdBpG92UumZxP/Yiwe/Zjn+Y3l8ah5Kv1BHl4tjN9kjiAIZOKFr2ekatwv0Rr/oWzJO+cUv+s=;4:U8E37HtWlBWo8J5TanVA3xGbUx8crodsGxO9hb/FxDtFO0U2QVTRoEd/i1dx+IUImlYqwrfPVmo4Aq9nREJTzMctBPxBQVcPH2iJnGFZicub3Nxmi7whh96ed7+Z+wE7hTeXmbA+rXkPW+SRIBE3t8ZK4715ztdECaTccm6xCMnaeGoXd7cDR4ashYXhmX5VKoY2/uFHHELrFaoB/aVXc9nXZp6Txhx7J4+2T60OEhAoW9SGDGhytIdL+HLck1o28ZJ5wL4M6M/Euqj19GRr0QwqZ1StTZsGRasy30kQYcqJTPj9AvQm9tCYPdtxJN1mVdERKDjURbIbmpdhU4XQ/Q== X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(788757137089); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(3231021)(6055026)(2017110403001)(6096035)(20161123556025)(20161123563025)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123561025)(20161123559100)(20161123565025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM5PR03MB2697;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM5PR03MB2697; X-Forefront-PRVS: 0484063412 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM5PR03MB2697;23:J0WFUzXYSdMGkV2IhjSnPUBdEa5tYKWrA9jUoxNrX?= =?us-ascii?Q?HJsyYtzLzNdiVuUP/29SvTU6L3h53kGnte4+BIGmLk3rY7ivwFIDQ2gxJqPb?= =?us-ascii?Q?ye5g7NKZA9vU6uDeQC01Zu9rRKqstQa1WwShr1oH3FrgLaQ9KiQjCqfVn4/L?= =?us-ascii?Q?v8N2G3CiGruXbPxImiyYndX+MyLteuSYTr98BHRjQbf77b0b9LWv7xEFd2B4?= =?us-ascii?Q?ngJmOkvD7eZRpaWDH0/Hl1t9Of3Lqy3JyiJLYqkl9TLX2fx4x+FCRzlVZy2e?= =?us-ascii?Q?XTMV5Dg5KGXRQPvtpxx73hmuKdHi0wGh0KHxtCCAPw4D6k46JVDfujDS+ZZC?= =?us-ascii?Q?ysyAKszgISg79FhIK8zhc5LzGBeEURQ00DT69s5o5VY8jflWqki7QMMHvyR0?= =?us-ascii?Q?DPTy5d6ZqPJZ6jfNvqbdqhEg9LLIzW/fHgWEOzxSTJnlLi+DVPDlar6+RK25?= =?us-ascii?Q?Hpk39/b/p5U4flfE0xGLqA2EMpKBDl+0Vv0xGCm+8euxCFTO5ZYf98kl0NEZ?= =?us-ascii?Q?BQggkPl29NaBE8614ac1QvHT3MsOirXUjRbEXcYKxC3wcz5nZo7dytW4Cn1H?= =?us-ascii?Q?P7Z2a3WYcJzCPVhNk3mFkRexgEZgzSOJm3lBxu1S42BWyB5vOlEd9mzIsUTN?= =?us-ascii?Q?RpP1+Ph8zdnMbEPzqzN68uycRPIPRDjo1qdHltjzOXctf7ZUJ1VEPw1IX5EC?= =?us-ascii?Q?Fn37LtFmhMc0Z39zEZGpeRphxXCERF1V61BNpPXUyrrmNR0kzBHAk5L1/hwV?= =?us-ascii?Q?xfPoDfIyuFr1lA0SqduwyrrcOWuIUb5ZkX9tXqSosbFqr4UwxWiY6Tfv5DqV?= =?us-ascii?Q?566vTIKY/pG3zIJ9E83hulDcYAkLfT4gLl/fqEM66sxjxgcyxxk3LxmHvuCt?= =?us-ascii?Q?AGx4A44xx3Emhe3tpyPQc+3UcyX2Fhv+Ev9iJg9o5wztUhLgeAx55s8D9NGm?= =?us-ascii?Q?9tk2/p59/C04FLLLSCZwEVdVb7tDgxFKta8khSe+QfZh70j3KR3RP18BnP69?= =?us-ascii?Q?22TuJUvA2gP4F3O7JR+BffJZ8j37uahuNrBC4Uh0yVzCV9TDRpUgPiXaNN6b?= =?us-ascii?Q?yZmRG9WYC5gqwlLztm6cR6jq9lB3wK5iW+Rx8ATXXkrobghiSOdVJHRfblyH?= =?us-ascii?Q?NNnPBzrqgMpyKFZrvHRzqNnDwftNRfLuxC6F7oEsSv3KrI0AFCWk2M+/NFvK?= =?us-ascii?Q?LeyrUhD6D4izYQe5GdhLIHqPFmg/qHuG+AS5VSBBAW92yFXQytmcW3oHrDGa?= =?us-ascii?Q?uv5KZl7vyhB/y1E1kw=3D?= X-Microsoft-Exchange-Diagnostics: 1;DM5PR03MB2697;6:mcz6+g6ZzfvTTpu25JtO72p8CI7blSCIwdRhqhSPIEEQvJYWGhcK8z1EYnI5tTy6Agyef2a1g4l5WwmcVbzMQxKg+rSt1SM2KStmbbbS3zwTlSOzhIzhfzMsct9q1vW2Vp2bRXlr89fL07YVfjFU/J7AueOVt0RhztkMNwafOBXYh+LJZJpHglYSlYLVqEojqRqkTxDZV7sX5BeoF/9eMcFHwPk2NWNjho+qP8i1zOVHlavRw43sbeX162SkeeybHaen0xeTwJscnrZwIiNzprD1Mu2UyPyzq5caw5I+CxxiaWvvYJ++XA7IwB+62BDxe296JeMvOsXB/p03bj8hWtIA5UIKfknT9vAdJVEEsqg=;5:U//kchr84U+oafub2DHiTarx5IfDmgca9lAMlEuqpLI7wtNJHZ+Aw3vGrS1kuViw75Ius6PTJF7tDPIh5CIpyIO5fwAPBex/r0Jl0wi33sLdnRPqBkBqeJrCa9xk76S6qsH4SPHOqA6fIDNjE1XKNISJZZEhEA8Hyscr/ZzJhzA=;24:QFjDbp7LSVWctBf/5RJ2F0lFJ/d/wGmsBM5n53oIiHBfaLFdLx9Q6x4LTdeocpivCODqp4hU5EJsIRAZnJ/dAwHGcPozLI6ODJSEIJBrvbg=;7:giPOlJPiaWVWh2drjLI9zpFtUpEQ0vc8JFll1jVNyKZE+Mas0XftiYlvd23fVr7rNH5My0ON52/O3NwTssHTji9ascXBs/SAl+WbZyAY3lTfO0spyLFSdj5ZO1+ZHXN8WBTuOE2TrTFNbfvYVo3//EAjRychNHWwISXgNI2YmgIyAj+DNXR1lQHbcYIaYmB25lrOPl7xDX/R8AKxfFmSJI/g0yVsX62MrjkUTBk0WWJPRO0zZEhTtX7RArdEEG7t SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2017 07:39:31.3333 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 31266c5c-9692-4cef-b012-08d525b2af2c X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2697 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adds qoriq usb 3.0 phy driver to implement erratum related workaround for qoriq SoC. Signed-off-by: Sriram Dash Signed-off-by: Ran Wang --- Change in v2: - Replace funciont __raw_writel() by iowrite32be() - Remove qoriq_usb3_phy_read() and qoriq_usb3_phy_write() - Remove USB3PRM1CR_VAL define, use numbers directly - Use C-style numeric constants on 32'h27672B2A in annotation - Add prefix 'static' to struct qoriq_usb3_phy_erratum .../devicetree/bindings/phy/phy-qoriq-usb3.txt | 36 ++++ drivers/phy/Kconfig | 9 + drivers/phy/Makefile | 1 + drivers/phy/phy-qoriq-usb3.c | 191 +++++++++++++++++++++ 4 files changed, 237 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-qoriq-usb3.txt create mode 100644 drivers/phy/phy-qoriq-usb3.c diff --git a/Documentation/devicetree/bindings/phy/phy-qoriq-usb3.txt b/Documentation/devicetree/bindings/phy/phy-qoriq-usb3.txt new file mode 100644 index 000000000000..d956f9c89fbf --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-qoriq-usb3.txt @@ -0,0 +1,36 @@ +Driver for Freescale USB 3.0 PHY + +Required properties: + +- compatible : fsl,qoriq-usb3-phy +- reg : register mappings for Parameter Configuration Register + and Phy base offset. +- reg-names : "param_ctrl" and "phy_base" +- phy_type : For multi port host USB controllers, should be one of + "ulpi", or "serial". For dual role USB controllers, + should be one of "ulpi", "utmi", "utmi_wide", or "serial". + +Example: + usbphy0: usb-phy@084F0000 { + compatible = "fsl,qoriq-usb3-phy"; + reg = <0x0 0x01570070 0x0 0xC>, <0x0 0x084F0000 0x0 0x5000>; + reg-names = "param_ctrl", "phy_base"; + #phy-cells = <0>; + phy_type = "utmi"; + }; + + usbphy1: usb-phy@08500000 { + compatible = "fsl,qoriq-usb3-phy"; + reg = <0x0 0x0157007C 0x0 0xC>, <0x0 0x08500000 0x0 0x5000>; + reg-names = "param_ctrl", "phy_base"; + #phy-cells = <0>; + phy_type = "utmi"; + }; + + usbphy2: usb-phy@08510000 { + compatible = "fsl,qoriq-usb3-phy"; + reg = <0x0 0x01570088 0x0 0xC>, <0x0 0x08510000 0x0 0x5000>; + reg-names = "param_ctrl", "phy_base"; + #phy-cells = <0>; + phy_type = "utmi"; + }; diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index c1807d4a0079..077e6765d2df 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -41,6 +41,15 @@ config PHY_PISTACHIO_USB help Enable this to support the USB2.0 PHY on the IMG Pistachio SoC. + +config PHY_QORIQ_USB3 + tristate "Freescale QorIQ USB 3.0 PHY driver" + depends on ARCH_LAYERSCAPE + depends on OF + select GENERIC_PHY + help + Enable this to support the USB3.0 PHY on the QorIQ SoC. + config PHY_XGENE tristate "APM X-Gene 15Gbps PHY support" depends on HAS_IOMEM && OF && (ARM64 || COMPILE_TEST) diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index f252201e0ec9..94712e066cde 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -21,3 +21,4 @@ obj-y += broadcom/ \ samsung/ \ st/ \ ti/ +obj-$(CONFIG_PHY_QORIQ_USB3) += phy-qoriq-usb3.o diff --git a/drivers/phy/phy-qoriq-usb3.c b/drivers/phy/phy-qoriq-usb3.c new file mode 100644 index 000000000000..f9302fc59f05 --- /dev/null +++ b/drivers/phy/phy-qoriq-usb3.c @@ -0,0 +1,191 @@ +/* + * Freescale QorIQ USB3 phy driver + * + * Copyright 2016 Freescale Semiconductor, Inc. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Author: Sriram Dash + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/* Parameter control */ +#define USB3PRM1CR 0x000 + +/* + * struct qoriq_usb3_phy - driver data for USB 3.0 PHY + * @dev: pointer to device instance of this platform device + * @param_ctrl: usb3 phy parameter control register base + * @phy_base: usb3 phy register memory base + * @has_erratum_flag: keeps track of erratum applicable on device + */ +struct qoriq_usb3_phy { + struct device *dev; + void __iomem *param_ctrl; + void __iomem *phy_base; + u32 has_erratum_flag; +}; + +/* + * Erratum A008751 + * SCFG USB3PRM1CR has incorrect default value + * SCFG USB3PRM1CR reset value should be 0x27672B2A instead of 32'h25E72B2A. + */ +static void erratum_a008751(struct qoriq_usb3_phy *phy) +{ + iowrite32be(0x27672B2A, phy->param_ctrl + USB3PRM1CR); +} + +/* + * qoriq_usb3_phy_erratum - List of phy erratum + * @qoriq_phy_erratum - erratum application + * @prop - string of property name for erratum + */ + +struct qoriq_usb3_phy_erratum { + void (*qoriq_phy_erratum)(struct qoriq_usb3_phy *phy); + char *prop; +}; + +/* Erratum list */ +static struct qoriq_usb3_phy_erratum phy_erratum_tbl[] = { + {erratum_a008751, "fsl,usb-erratum-a008751"}, + /* Add init time erratum here */ +}; + +static int qoriq_usb3_phy_init(struct phy *x) +{ + struct qoriq_usb3_phy *phy = phy_get_drvdata(x); + int i; + + for (i = 0; i < ARRAY_SIZE(phy_erratum_tbl); i++) + if (phy->has_erratum_flag & 1 << i) + phy_erratum_tbl[i].qoriq_phy_erratum(phy); + + return 0; +} + +static const struct phy_ops ops = { + .init = qoriq_usb3_phy_init, + .owner = THIS_MODULE, +}; + +static int qoriq_usb3_phy_probe(struct platform_device *pdev) +{ + struct qoriq_usb3_phy *phy; + struct phy *generic_phy; + struct phy_provider *phy_provider; + const struct of_device_id *of_id; + struct device *dev = &pdev->dev; + struct resource *res; + int i, ret; + + phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); + if (!phy) + return -ENOMEM; + phy->dev = dev; + + of_id = of_match_device(dev->driver->of_match_table, dev); + if (!of_id) { + dev_err(dev, "failed to get device match\n"); + ret = -EINVAL; + goto err_out; + } + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "param_ctrl"); + if (!res) { + dev_err(dev, "failed to get param_ctrl memory\n"); + ret = -ENOENT; + goto err_out; + } + + phy->param_ctrl = devm_ioremap_resource(dev, res); + if (!phy->param_ctrl) { + dev_err(dev, "failed to remap param_ctrl memory\n"); + ret = -ENOMEM; + goto err_out; + } + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy_base"); + if (!res) { + dev_err(dev, "failed to get phy_base memory\n"); + ret = -ENOENT; + goto err_out; + } + + phy->phy_base = devm_ioremap_resource(dev, res); + if (!phy->phy_base) { + dev_err(dev, "failed to remap phy_base memory\n"); + ret = -ENOMEM; + goto err_out; + } + + phy->has_erratum_flag = 0; + for (i = 0; i < ARRAY_SIZE(phy_erratum_tbl); i++) { + phy->has_erratum_flag |= device_property_read_bool(dev, + phy_erratum_tbl[i].prop) << i; + } + + platform_set_drvdata(pdev, phy); + + generic_phy = devm_phy_create(dev, NULL, &ops); + if (IS_ERR(generic_phy)) + return PTR_ERR(generic_phy); + + phy_set_drvdata(generic_phy, phy); + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return PTR_ERR(phy_provider); + + return 0; +err_out: + return ret; +} + +static const struct of_device_id qoriq_usb3_phy_dt_ids[] = { + { + .compatible = "fsl,qoriq-usb3-phy" + }, + {} +}; +MODULE_DEVICE_TABLE(of, qoriq_usb3_phy_dt_ids); + +static struct platform_driver qoriq_usb3_phy_driver = { + .probe = qoriq_usb3_phy_probe, + .driver = { + .name = "qoriq_usb3_phy", + .of_match_table = qoriq_usb3_phy_dt_ids, + }, +}; + +module_platform_driver(qoriq_usb3_phy_driver); + +MODULE_ALIAS("platform:qoriq_usb3_phy"); +MODULE_AUTHOR("Sriram Dash "); +MODULE_DESCRIPTION("Freescale QorIQ USB3 phy driver"); +MODULE_LICENSE("GPL v2"); -- 2.14.1 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ran Wang Subject: [PATCH v2 1/3] drivers: usb: phy: Add qoriq usb 3.0 phy driver support Date: Tue, 7 Nov 2017 15:20:53 +0800 Message-ID: <20171107072055.26945-1-ran.wang_1@nxp.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Sender: linux-kernel-owner@vger.kernel.org To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Felipe Balbi Cc: robh+dt@kernel.org, mark.rutland@arm.com, kishon@ti.com, catalin.marinas@arm.com, will.deacon@arm.com, stern@rowland.harvard.edu, pku.leo@gmail.com, mathias.nyman@intel.com, gregkh@linuxfoundation.org, suresh.gupta@nxp.com, felipe.balbi@linux.intel.com, Shawn Guo , Sriram Dash , Li Yang , Hongtao Jia , Ran Wang List-Id: devicetree@vger.kernel.org Adds qoriq usb 3.0 phy driver to implement erratum related workaround for qoriq SoC. Signed-off-by: Sriram Dash Signed-off-by: Ran Wang --- Change in v2: - Replace funciont __raw_writel() by iowrite32be() - Remove qoriq_usb3_phy_read() and qoriq_usb3_phy_write() - Remove USB3PRM1CR_VAL define, use numbers directly - Use C-style numeric constants on 32'h27672B2A in annotation - Add prefix 'static' to struct qoriq_usb3_phy_erratum .../devicetree/bindings/phy/phy-qoriq-usb3.txt | 36 ++++ drivers/phy/Kconfig | 9 + drivers/phy/Makefile | 1 + drivers/phy/phy-qoriq-usb3.c | 191 +++++++++++++++++++++ 4 files changed, 237 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-qoriq-usb3.txt create mode 100644 drivers/phy/phy-qoriq-usb3.c diff --git a/Documentation/devicetree/bindings/phy/phy-qoriq-usb3.txt b/Documentation/devicetree/bindings/phy/phy-qoriq-usb3.txt new file mode 100644 index 000000000000..d956f9c89fbf --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-qoriq-usb3.txt @@ -0,0 +1,36 @@ +Driver for Freescale USB 3.0 PHY + +Required properties: + +- compatible : fsl,qoriq-usb3-phy +- reg : register mappings for Parameter Configuration Register + and Phy base offset. +- reg-names : "param_ctrl" and "phy_base" +- phy_type : For multi port host USB controllers, should be one of + "ulpi", or "serial". For dual role USB controllers, + should be one of "ulpi", "utmi", "utmi_wide", or "serial". + +Example: + usbphy0: usb-phy@084F0000 { + compatible = "fsl,qoriq-usb3-phy"; + reg = <0x0 0x01570070 0x0 0xC>, <0x0 0x084F0000 0x0 0x5000>; + reg-names = "param_ctrl", "phy_base"; + #phy-cells = <0>; + phy_type = "utmi"; + }; + + usbphy1: usb-phy@08500000 { + compatible = "fsl,qoriq-usb3-phy"; + reg = <0x0 0x0157007C 0x0 0xC>, <0x0 0x08500000 0x0 0x5000>; + reg-names = "param_ctrl", "phy_base"; + #phy-cells = <0>; + phy_type = "utmi"; + }; + + usbphy2: usb-phy@08510000 { + compatible = "fsl,qoriq-usb3-phy"; + reg = <0x0 0x01570088 0x0 0xC>, <0x0 0x08510000 0x0 0x5000>; + reg-names = "param_ctrl", "phy_base"; + #phy-cells = <0>; + phy_type = "utmi"; + }; diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index c1807d4a0079..077e6765d2df 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -41,6 +41,15 @@ config PHY_PISTACHIO_USB help Enable this to support the USB2.0 PHY on the IMG Pistachio SoC. + +config PHY_QORIQ_USB3 + tristate "Freescale QorIQ USB 3.0 PHY driver" + depends on ARCH_LAYERSCAPE + depends on OF + select GENERIC_PHY + help + Enable this to support the USB3.0 PHY on the QorIQ SoC. + config PHY_XGENE tristate "APM X-Gene 15Gbps PHY support" depends on HAS_IOMEM && OF && (ARM64 || COMPILE_TEST) diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index f252201e0ec9..94712e066cde 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -21,3 +21,4 @@ obj-y += broadcom/ \ samsung/ \ st/ \ ti/ +obj-$(CONFIG_PHY_QORIQ_USB3) += phy-qoriq-usb3.o diff --git a/drivers/phy/phy-qoriq-usb3.c b/drivers/phy/phy-qoriq-usb3.c new file mode 100644 index 000000000000..f9302fc59f05 --- /dev/null +++ b/drivers/phy/phy-qoriq-usb3.c @@ -0,0 +1,191 @@ +/* + * Freescale QorIQ USB3 phy driver + * + * Copyright 2016 Freescale Semiconductor, Inc. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Author: Sriram Dash + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/* Parameter control */ +#define USB3PRM1CR 0x000 + +/* + * struct qoriq_usb3_phy - driver data for USB 3.0 PHY + * @dev: pointer to device instance of this platform device + * @param_ctrl: usb3 phy parameter control register base + * @phy_base: usb3 phy register memory base + * @has_erratum_flag: keeps track of erratum applicable on device + */ +struct qoriq_usb3_phy { + struct device *dev; + void __iomem *param_ctrl; + void __iomem *phy_base; + u32 has_erratum_flag; +}; + +/* + * Erratum A008751 + * SCFG USB3PRM1CR has incorrect default value + * SCFG USB3PRM1CR reset value should be 0x27672B2A instead of 32'h25E72B2A. + */ +static void erratum_a008751(struct qoriq_usb3_phy *phy) +{ + iowrite32be(0x27672B2A, phy->param_ctrl + USB3PRM1CR); +} + +/* + * qoriq_usb3_phy_erratum - List of phy erratum + * @qoriq_phy_erratum - erratum application + * @prop - string of property name for erratum + */ + +struct qoriq_usb3_phy_erratum { + void (*qoriq_phy_erratum)(struct qoriq_usb3_phy *phy); + char *prop; +}; + +/* Erratum list */ +static struct qoriq_usb3_phy_erratum phy_erratum_tbl[] = { + {erratum_a008751, "fsl,usb-erratum-a008751"}, + /* Add init time erratum here */ +}; + +static int qoriq_usb3_phy_init(struct phy *x) +{ + struct qoriq_usb3_phy *phy = phy_get_drvdata(x); + int i; + + for (i = 0; i < ARRAY_SIZE(phy_erratum_tbl); i++) + if (phy->has_erratum_flag & 1 << i) + phy_erratum_tbl[i].qoriq_phy_erratum(phy); + + return 0; +} + +static const struct phy_ops ops = { + .init = qoriq_usb3_phy_init, + .owner = THIS_MODULE, +}; + +static int qoriq_usb3_phy_probe(struct platform_device *pdev) +{ + struct qoriq_usb3_phy *phy; + struct phy *generic_phy; + struct phy_provider *phy_provider; + const struct of_device_id *of_id; + struct device *dev = &pdev->dev; + struct resource *res; + int i, ret; + + phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); + if (!phy) + return -ENOMEM; + phy->dev = dev; + + of_id = of_match_device(dev->driver->of_match_table, dev); + if (!of_id) { + dev_err(dev, "failed to get device match\n"); + ret = -EINVAL; + goto err_out; + } + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "param_ctrl"); + if (!res) { + dev_err(dev, "failed to get param_ctrl memory\n"); + ret = -ENOENT; + goto err_out; + } + + phy->param_ctrl = devm_ioremap_resource(dev, res); + if (!phy->param_ctrl) { + dev_err(dev, "failed to remap param_ctrl memory\n"); + ret = -ENOMEM; + goto err_out; + } + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy_base"); + if (!res) { + dev_err(dev, "failed to get phy_base memory\n"); + ret = -ENOENT; + goto err_out; + } + + phy->phy_base = devm_ioremap_resource(dev, res); + if (!phy->phy_base) { + dev_err(dev, "failed to remap phy_base memory\n"); + ret = -ENOMEM; + goto err_out; + } + + phy->has_erratum_flag = 0; + for (i = 0; i < ARRAY_SIZE(phy_erratum_tbl); i++) { + phy->has_erratum_flag |= device_property_read_bool(dev, + phy_erratum_tbl[i].prop) << i; + } + + platform_set_drvdata(pdev, phy); + + generic_phy = devm_phy_create(dev, NULL, &ops); + if (IS_ERR(generic_phy)) + return PTR_ERR(generic_phy); + + phy_set_drvdata(generic_phy, phy); + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return PTR_ERR(phy_provider); + + return 0; +err_out: + return ret; +} + +static const struct of_device_id qoriq_usb3_phy_dt_ids[] = { + { + .compatible = "fsl,qoriq-usb3-phy" + }, + {} +}; +MODULE_DEVICE_TABLE(of, qoriq_usb3_phy_dt_ids); + +static struct platform_driver qoriq_usb3_phy_driver = { + .probe = qoriq_usb3_phy_probe, + .driver = { + .name = "qoriq_usb3_phy", + .of_match_table = qoriq_usb3_phy_dt_ids, + }, +}; + +module_platform_driver(qoriq_usb3_phy_driver); + +MODULE_ALIAS("platform:qoriq_usb3_phy"); +MODULE_AUTHOR("Sriram Dash "); +MODULE_DESCRIPTION("Freescale QorIQ USB3 phy driver"); +MODULE_LICENSE("GPL v2"); -- 2.14.1 From mboxrd@z Thu Jan 1 00:00:00 1970 From: ran.wang_1@nxp.com (Ran Wang) Date: Tue, 7 Nov 2017 15:20:53 +0800 Subject: [PATCH v2 1/3] drivers: usb: phy: Add qoriq usb 3.0 phy driver support Message-ID: <20171107072055.26945-1-ran.wang_1@nxp.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Adds qoriq usb 3.0 phy driver to implement erratum related workaround for qoriq SoC. Signed-off-by: Sriram Dash Signed-off-by: Ran Wang --- Change in v2: - Replace funciont __raw_writel() by iowrite32be() - Remove qoriq_usb3_phy_read() and qoriq_usb3_phy_write() - Remove USB3PRM1CR_VAL define, use numbers directly - Use C-style numeric constants on 32'h27672B2A in annotation - Add prefix 'static' to struct qoriq_usb3_phy_erratum .../devicetree/bindings/phy/phy-qoriq-usb3.txt | 36 ++++ drivers/phy/Kconfig | 9 + drivers/phy/Makefile | 1 + drivers/phy/phy-qoriq-usb3.c | 191 +++++++++++++++++++++ 4 files changed, 237 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-qoriq-usb3.txt create mode 100644 drivers/phy/phy-qoriq-usb3.c diff --git a/Documentation/devicetree/bindings/phy/phy-qoriq-usb3.txt b/Documentation/devicetree/bindings/phy/phy-qoriq-usb3.txt new file mode 100644 index 000000000000..d956f9c89fbf --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-qoriq-usb3.txt @@ -0,0 +1,36 @@ +Driver for Freescale USB 3.0 PHY + +Required properties: + +- compatible : fsl,qoriq-usb3-phy +- reg : register mappings for Parameter Configuration Register + and Phy base offset. +- reg-names : "param_ctrl" and "phy_base" +- phy_type : For multi port host USB controllers, should be one of + "ulpi", or "serial". For dual role USB controllers, + should be one of "ulpi", "utmi", "utmi_wide", or "serial". + +Example: + usbphy0: usb-phy at 084F0000 { + compatible = "fsl,qoriq-usb3-phy"; + reg = <0x0 0x01570070 0x0 0xC>, <0x0 0x084F0000 0x0 0x5000>; + reg-names = "param_ctrl", "phy_base"; + #phy-cells = <0>; + phy_type = "utmi"; + }; + + usbphy1: usb-phy at 08500000 { + compatible = "fsl,qoriq-usb3-phy"; + reg = <0x0 0x0157007C 0x0 0xC>, <0x0 0x08500000 0x0 0x5000>; + reg-names = "param_ctrl", "phy_base"; + #phy-cells = <0>; + phy_type = "utmi"; + }; + + usbphy2: usb-phy at 08510000 { + compatible = "fsl,qoriq-usb3-phy"; + reg = <0x0 0x01570088 0x0 0xC>, <0x0 0x08510000 0x0 0x5000>; + reg-names = "param_ctrl", "phy_base"; + #phy-cells = <0>; + phy_type = "utmi"; + }; diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index c1807d4a0079..077e6765d2df 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -41,6 +41,15 @@ config PHY_PISTACHIO_USB help Enable this to support the USB2.0 PHY on the IMG Pistachio SoC. + +config PHY_QORIQ_USB3 + tristate "Freescale QorIQ USB 3.0 PHY driver" + depends on ARCH_LAYERSCAPE + depends on OF + select GENERIC_PHY + help + Enable this to support the USB3.0 PHY on the QorIQ SoC. + config PHY_XGENE tristate "APM X-Gene 15Gbps PHY support" depends on HAS_IOMEM && OF && (ARM64 || COMPILE_TEST) diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index f252201e0ec9..94712e066cde 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -21,3 +21,4 @@ obj-y += broadcom/ \ samsung/ \ st/ \ ti/ +obj-$(CONFIG_PHY_QORIQ_USB3) += phy-qoriq-usb3.o diff --git a/drivers/phy/phy-qoriq-usb3.c b/drivers/phy/phy-qoriq-usb3.c new file mode 100644 index 000000000000..f9302fc59f05 --- /dev/null +++ b/drivers/phy/phy-qoriq-usb3.c @@ -0,0 +1,191 @@ +/* + * Freescale QorIQ USB3 phy driver + * + * Copyright 2016 Freescale Semiconductor, Inc. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Author: Sriram Dash + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/* Parameter control */ +#define USB3PRM1CR 0x000 + +/* + * struct qoriq_usb3_phy - driver data for USB 3.0 PHY + * @dev: pointer to device instance of this platform device + * @param_ctrl: usb3 phy parameter control register base + * @phy_base: usb3 phy register memory base + * @has_erratum_flag: keeps track of erratum applicable on device + */ +struct qoriq_usb3_phy { + struct device *dev; + void __iomem *param_ctrl; + void __iomem *phy_base; + u32 has_erratum_flag; +}; + +/* + * Erratum A008751 + * SCFG USB3PRM1CR has incorrect default value + * SCFG USB3PRM1CR reset value should be 0x27672B2A instead of 32'h25E72B2A. + */ +static void erratum_a008751(struct qoriq_usb3_phy *phy) +{ + iowrite32be(0x27672B2A, phy->param_ctrl + USB3PRM1CR); +} + +/* + * qoriq_usb3_phy_erratum - List of phy erratum + * @qoriq_phy_erratum - erratum application + * @prop - string of property name for erratum + */ + +struct qoriq_usb3_phy_erratum { + void (*qoriq_phy_erratum)(struct qoriq_usb3_phy *phy); + char *prop; +}; + +/* Erratum list */ +static struct qoriq_usb3_phy_erratum phy_erratum_tbl[] = { + {erratum_a008751, "fsl,usb-erratum-a008751"}, + /* Add init time erratum here */ +}; + +static int qoriq_usb3_phy_init(struct phy *x) +{ + struct qoriq_usb3_phy *phy = phy_get_drvdata(x); + int i; + + for (i = 0; i < ARRAY_SIZE(phy_erratum_tbl); i++) + if (phy->has_erratum_flag & 1 << i) + phy_erratum_tbl[i].qoriq_phy_erratum(phy); + + return 0; +} + +static const struct phy_ops ops = { + .init = qoriq_usb3_phy_init, + .owner = THIS_MODULE, +}; + +static int qoriq_usb3_phy_probe(struct platform_device *pdev) +{ + struct qoriq_usb3_phy *phy; + struct phy *generic_phy; + struct phy_provider *phy_provider; + const struct of_device_id *of_id; + struct device *dev = &pdev->dev; + struct resource *res; + int i, ret; + + phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); + if (!phy) + return -ENOMEM; + phy->dev = dev; + + of_id = of_match_device(dev->driver->of_match_table, dev); + if (!of_id) { + dev_err(dev, "failed to get device match\n"); + ret = -EINVAL; + goto err_out; + } + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "param_ctrl"); + if (!res) { + dev_err(dev, "failed to get param_ctrl memory\n"); + ret = -ENOENT; + goto err_out; + } + + phy->param_ctrl = devm_ioremap_resource(dev, res); + if (!phy->param_ctrl) { + dev_err(dev, "failed to remap param_ctrl memory\n"); + ret = -ENOMEM; + goto err_out; + } + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy_base"); + if (!res) { + dev_err(dev, "failed to get phy_base memory\n"); + ret = -ENOENT; + goto err_out; + } + + phy->phy_base = devm_ioremap_resource(dev, res); + if (!phy->phy_base) { + dev_err(dev, "failed to remap phy_base memory\n"); + ret = -ENOMEM; + goto err_out; + } + + phy->has_erratum_flag = 0; + for (i = 0; i < ARRAY_SIZE(phy_erratum_tbl); i++) { + phy->has_erratum_flag |= device_property_read_bool(dev, + phy_erratum_tbl[i].prop) << i; + } + + platform_set_drvdata(pdev, phy); + + generic_phy = devm_phy_create(dev, NULL, &ops); + if (IS_ERR(generic_phy)) + return PTR_ERR(generic_phy); + + phy_set_drvdata(generic_phy, phy); + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return PTR_ERR(phy_provider); + + return 0; +err_out: + return ret; +} + +static const struct of_device_id qoriq_usb3_phy_dt_ids[] = { + { + .compatible = "fsl,qoriq-usb3-phy" + }, + {} +}; +MODULE_DEVICE_TABLE(of, qoriq_usb3_phy_dt_ids); + +static struct platform_driver qoriq_usb3_phy_driver = { + .probe = qoriq_usb3_phy_probe, + .driver = { + .name = "qoriq_usb3_phy", + .of_match_table = qoriq_usb3_phy_dt_ids, + }, +}; + +module_platform_driver(qoriq_usb3_phy_driver); + +MODULE_ALIAS("platform:qoriq_usb3_phy"); +MODULE_AUTHOR("Sriram Dash "); +MODULE_DESCRIPTION("Freescale QorIQ USB3 phy driver"); +MODULE_LICENSE("GPL v2"); -- 2.14.1