From patchwork Thu Mar 19 01:19:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 6044771 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3E4999F444 for ; Thu, 19 Mar 2015 01:24:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4303520465 for ; Thu, 19 Mar 2015 01:24:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C3E3820444 for ; Thu, 19 Mar 2015 01:24:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YYP9s-0005L4-SP; Thu, 19 Mar 2015 01:22:01 +0000 Received: from mail-bl2on0125.outbound.protection.outlook.com ([65.55.169.125] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YYP8j-0004sA-2H for linux-arm-kernel@lists.infradead.org; Thu, 19 Mar 2015 01:20:51 +0000 Received: from DM2PR03CA0023.namprd03.prod.outlook.com (10.141.96.22) by DM2PR0301MB0863.namprd03.prod.outlook.com (25.160.215.149) with Microsoft SMTP Server (TLS) id 15.1.112.16; Thu, 19 Mar 2015 01:20:38 +0000 Received: from BY2FFO11FD040.protection.gbl (2a01:111:f400:7c0c::168) by DM2PR03CA0023.outlook.office365.com (2a01:111:e400:2428::22) with Microsoft SMTP Server (TLS) id 15.1.118.21 via Frontend Transport; Thu, 19 Mar 2015 01:20:37 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD040.mail.protection.outlook.com (10.1.14.225) with Microsoft SMTP Server (TLS) id 15.1.125.13 via Frontend Transport; Thu, 19 Mar 2015 01:20:37 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t2J1KGff031896; Wed, 18 Mar 2015 18:20:34 -0700 From: Peter Chen To: , Subject: [PATCH 05/12] usb: chipidea: introduce ci_platform_config Date: Thu, 19 Mar 2015 09:19:16 +0800 Message-ID: <1426727963-32280-6-git-send-email-peter.chen@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1426727963-32280-1-git-send-email-peter.chen@freescale.com> References: <1426727963-32280-1-git-send-email-peter.chen@freescale.com> X-EOPAttributedMessage: 0 Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=peter.chen@freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; BMV:1; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(189002)(199003)(86362001)(19580395003)(19580405001)(6806004)(92566002)(97736003)(85426001)(50466002)(33646002)(36756003)(104016003)(48376002)(87936001)(2950100001)(229853001)(50226001)(77156002)(62966003)(106466001)(68736005)(46102003)(77096005)(76176999)(50986999)(105606002)(47776003)(64706001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM2PR0301MB0863; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0863; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5002010)(5005006); SRVR:DM2PR0301MB0863; BCL:0; PCL:0; RULEID:; SRVR:DM2PR0301MB0863; X-Forefront-PRVS: 052017CAF1 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2015 01:20:37.5337 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB0863 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150318_182049_240575_B6179211 X-CRM114-Status: GOOD ( 11.26 ) X-Spam-Score: -0.0 (/) Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, pawel.moll@arm.com, robh+dt@kernel.org, Peter Chen , kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is used to configure controller parameters according to platform data, like speed, interrupt threshold, stream mode, etc. Signed-off-by: Peter Chen --- drivers/usb/chipidea/ci.h | 2 ++ drivers/usb/chipidea/core.c | 57 +++++++++++++++++++++++++++++++-------------- drivers/usb/chipidea/host.c | 6 +---- 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index aeec5f0..888606b 100644 --- a/drivers/usb/chipidea/ci.h +++ b/drivers/usb/chipidea/ci.h @@ -426,4 +426,6 @@ u8 hw_port_test_get(struct ci_hdrc *ci); int hw_wait_reg(struct ci_hdrc *ci, enum ci_hw_regs reg, u32 mask, u32 value, unsigned int timeout_ms); +void ci_platform_config(struct ci_hdrc *ci, int usb_mode); + #endif /* __DRIVERS_USB_CHIPIDEA_CI_H */ diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 4d79392..f713e32 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -403,6 +403,44 @@ static int ci_usb_phy_init(struct ci_hdrc *ci) return ret; } + +/** + * ci_platform_config: do controller configure + * @ci: the controller + * @usb_mode: the usb mode + * + */ +void ci_platform_config(struct ci_hdrc *ci, int usb_mode) +{ + if (usb_mode == USBMODE_CM_DC) { + if (ci->platdata->flags & CI_HDRC_DISABLE_DEVICE_STREAMING) + hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, + USBMODE_CI_SDIS); + + /* + * Set interrupt interval for device mode + * host set ITC according to ehci-hcd module + * parameter log2_irq_thresh + */ + hw_write(ci, OP_USBCMD, 0xff0000, + ci->platdata->gadget_itc_setting << 16); + } else if (usb_mode == USBMODE_CM_HC) { + if (ci->platdata->flags & CI_HDRC_DISABLE_HOST_STREAMING) + hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, + USBMODE_CI_SDIS); + } else { + dev_warn(ci->dev, "USB mode in still not set\n"); + } + + if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED) { + if (ci->hw_bank.lpm) + hw_write(ci, OP_DEVLC, DEVLC_PFSC, DEVLC_PFSC); + else + hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC); + } + +} + /** * hw_controller_reset: do controller reset * @ci: the controller @@ -447,35 +485,20 @@ int hw_device_reset(struct ci_hdrc *ci) ci->platdata->notify_event(ci, CI_HDRC_CONTROLLER_RESET_EVENT); - if (ci->platdata->flags & CI_HDRC_DISABLE_DEVICE_STREAMING) - hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS); - - if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED) { - if (ci->hw_bank.lpm) - hw_write(ci, OP_DEVLC, DEVLC_PFSC, DEVLC_PFSC); - else - hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC); - } - /* USBMODE should be configured step by step */ hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_IDLE); hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_DC); /* HW >= 2.3 */ hw_write(ci, OP_USBMODE, USBMODE_SLOM, USBMODE_SLOM); - /* - * Set interrupt interval for device mode - * host set ITC according to ehci-hcd module parameter log2_irq_thresh - */ - hw_write(ci, OP_USBCMD, 0xff0000, - ci->platdata->gadget_itc_setting << 16); - if (hw_read(ci, OP_USBMODE, USBMODE_CM) != USBMODE_CM_DC) { pr_err("cannot enter in %s device mode", ci_role(ci)->name); pr_err("lpm = %i", ci->hw_bank.lpm); return -ENODEV; } + ci_platform_config(ci, USBMODE_CM_DC); + return 0; } diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index b262c1c..c4f76b7 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -141,11 +141,7 @@ static int host_start(struct ci_hdrc *ci) } } - if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED) - hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC); - - if (ci->platdata->flags & CI_HDRC_DISABLE_HOST_STREAMING) - hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS); + ci_platform_config(ci, USBMODE_CM_HC); return ret;