From patchwork Fri Aug 2 08:33:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 2837568 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5C19CBF535 for ; Fri, 2 Aug 2013 08:36:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3E4002022A for ; Fri, 2 Aug 2013 08:36:55 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D538820233 for ; Fri, 2 Aug 2013 08:36:53 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5Apv-0003kT-3D; Fri, 02 Aug 2013 08:35:48 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5ApR-0000sH-Oe; Fri, 02 Aug 2013 08:35:17 +0000 Received: from tx2ehsobe002.messaging.microsoft.com ([65.55.88.12] helo=tx2outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5ApC-0000lu-As for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2013 08:35:05 +0000 Received: from mail59-tx2-R.bigfish.com (10.9.14.254) by TX2EHSOBE009.bigfish.com (10.9.40.29) with Microsoft SMTP Server id 14.1.225.22; Fri, 2 Aug 2013 08:34:33 +0000 Received: from mail59-tx2 (localhost [127.0.0.1]) by mail59-tx2-R.bigfish.com (Postfix) with ESMTP id 9A4142E01EC; Fri, 2 Aug 2013 08:34:33 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 3 X-BigFish: VS3(zzc8kzz1f42h208ch1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6hzz1de098h8275bh1de097hz2dh2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h1354h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh1fb3h1d0ch1d2eh1d3fh1dfeh1dffh1e23h1155h) Received: from mail59-tx2 (localhost.localdomain [127.0.0.1]) by mail59-tx2 (MessageSwitch) id 1375432471973475_23371; Fri, 2 Aug 2013 08:34:31 +0000 (UTC) Received: from TX2EHSMHS041.bigfish.com (unknown [10.9.14.251]) by mail59-tx2.bigfish.com (Postfix) with ESMTP id D7CA51A004B; Fri, 2 Aug 2013 08:34:31 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS041.bigfish.com (10.9.99.141) with Microsoft SMTP Server (TLS) id 14.16.227.3; Fri, 2 Aug 2013 08:34:31 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-004.039d.mgd.msft.net (10.84.1.14) with Microsoft SMTP Server (TLS) id 14.3.136.1; Fri, 2 Aug 2013 08:34:31 +0000 Received: from localhost.localdomain (nchen-desktop.ap.freescale.net [10.192.242.40]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id r728Y6hb007485; Fri, 2 Aug 2013 01:34:27 -0700 From: Peter Chen To: , Subject: [PATCH v14 04/12] usb: chipidea: otg: Add otg file used to access otgsc Date: Fri, 2 Aug 2013 16:33:57 +0800 Message-ID: <1375432445-31918-5-git-send-email-peter.chen@freescale.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1375432445-31918-1-git-send-email-peter.chen@freescale.com> References: <1375432445-31918-1-git-send-email-peter.chen@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130802_043502_576248_2DCBE98A X-CRM114-Status: GOOD ( 17.70 ) X-Spam-Score: -4.2 (----) Cc: marex@denx.de, m.grzeschik@pengutronix.de, frank.li@freescale.com, linux-usb@vger.kernel.org, mkl@pengutronix.de, peter.chen@freescale.com, kernel@pengutronix.de, maxime.ripard@free-electrons.com, shawn.guo@linaro.org, festevam@gmail.com, linux-arm-kernel@lists.infradead.org, LW@KARO-electronics.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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=-5.6 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, 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 This file is mainly used to access otgsc currently, it may add otg related things in the future. Tested-by: Marek Vasut Signed-off-by: Peter Chen --- drivers/usb/chipidea/Makefile | 2 +- drivers/usb/chipidea/bits.h | 10 ++++++++ drivers/usb/chipidea/core.c | 3 +- drivers/usb/chipidea/otg.c | 50 +++++++++++++++++++++++++++++++++++++++++ drivers/usb/chipidea/otg.h | 19 +++++++++++++++ 5 files changed, 82 insertions(+), 2 deletions(-) diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile index 6cf5f68..a99d980 100644 --- a/drivers/usb/chipidea/Makefile +++ b/drivers/usb/chipidea/Makefile @@ -2,7 +2,7 @@ ccflags-$(CONFIG_USB_CHIPIDEA_DEBUG) := -DDEBUG obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc.o -ci_hdrc-y := core.o +ci_hdrc-y := core.o otg.o ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST) += host.o ci_hdrc-$(CONFIG_USB_CHIPIDEA_DEBUG) += debug.o diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h index aefa026..dd0cf9e 100644 --- a/drivers/usb/chipidea/bits.h +++ b/drivers/usb/chipidea/bits.h @@ -79,11 +79,21 @@ #define OTGSC_ASVIS BIT(18) #define OTGSC_BSVIS BIT(19) #define OTGSC_BSEIS BIT(20) +#define OTGSC_1MSIS BIT(21) +#define OTGSC_DPIS BIT(22) #define OTGSC_IDIE BIT(24) #define OTGSC_AVVIE BIT(25) #define OTGSC_ASVIE BIT(26) #define OTGSC_BSVIE BIT(27) #define OTGSC_BSEIE BIT(28) +#define OTGSC_1MSIE BIT(29) +#define OTGSC_DPIE BIT(30) +#define OTGSC_INT_EN_BITS (OTGSC_IDIE | OTGSC_AVVIE | OTGSC_ASVIE \ + | OTGSC_BSVIE | OTGSC_BSEIE | OTGSC_1MSIE \ + | OTGSC_DPIE) +#define OTGSC_INT_STATUS_BITS (OTGSC_IDIS | OTGSC_AVVIS | OTGSC_ASVIS \ + | OTGSC_BSVIS | OTGSC_BSEIS | OTGSC_1MSIS \ + | OTGSC_DPIS) /* USBMODE */ #define USBMODE_CM (0x03UL << 0) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 26f6599..a4be8a5 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -72,6 +72,7 @@ #include "bits.h" #include "host.h" #include "debug.h" +#include "otg.h" /* Controller register map */ static uintptr_t ci_regs_nolpm[] = { @@ -530,7 +531,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) goto stop; if (ci->is_otg) - hw_write(ci, OP_OTGSC, OTGSC_IDIE, OTGSC_IDIE); + ci_hdrc_otg_init(ci); ret = dbg_create_files(ci); if (!ret) diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c new file mode 100644 index 0000000..abefb4d --- /dev/null +++ b/drivers/usb/chipidea/otg.c @@ -0,0 +1,50 @@ +/* + * otg.c - ChipIdea USB IP core OTG driver + * + * Copyright (C) 2013 Freescale Semiconductor, Inc. + * + * Author: Peter Chen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +/* + * This file mainly handles otgsc register, it may include OTG operation + * in the future. + */ + +#include +#include +#include + +#include "ci.h" +#include "bits.h" + +void ci_clear_otg_interrupt(struct ci_hdrc *ci, u32 bits) +{ + /* Only clear request bits */ + hw_write(ci, OP_OTGSC, OTGSC_INT_STATUS_BITS, bits); +} + +void ci_enable_otg_interrupt(struct ci_hdrc *ci, u32 bits) +{ + hw_write(ci, OP_OTGSC, bits, bits); +} + +void ci_disable_otg_interrupt(struct ci_hdrc *ci, u32 bits) +{ + hw_write(ci, OP_OTGSC, bits, 0); +} + +/** + * ci_hdrc_otg_init - initialize otgsc bits + * ci: the controller + */ +int ci_hdrc_otg_init(struct ci_hdrc *ci) +{ + ci_enable_otg_interrupt(ci, OTGSC_IDIE); + + return 0; +} diff --git a/drivers/usb/chipidea/otg.h b/drivers/usb/chipidea/otg.h new file mode 100644 index 0000000..f24ec37 --- /dev/null +++ b/drivers/usb/chipidea/otg.h @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2013 Freescale Semiconductor, Inc. + * + * Author: Peter Chen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __DRIVERS_USB_CHIPIDEA_OTG_H +#define __DRIVERS_USB_CHIPIDEA_OTG_H + +int ci_hdrc_otg_init(struct ci_hdrc *ci); +void ci_clear_otg_interrupt(struct ci_hdrc *ci, u32 bits); +void ci_enable_otg_interrupt(struct ci_hdrc *ci, u32 bits); +void ci_disable_otg_interrupt(struct ci_hdrc *ci, u32 bits); + +#endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */