From patchwork Tue Jul 16 20:47:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 259514 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id A16BB2C016E for ; Wed, 17 Jul 2013 06:56:18 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 12BB24A03A; Tue, 16 Jul 2013 22:56:13 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VHRDrDvAgSz9; Tue, 16 Jul 2013 22:56:12 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 82BEA4A051; Tue, 16 Jul 2013 22:56:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E24854A01F for ; Tue, 16 Jul 2013 22:55:49 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ayxArrfooNUo for ; Tue, 16 Jul 2013 22:55:32 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 BL_NJABL=SKIP(-1.5) (only DNSBL check requested) Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by theia.denx.de (Postfix) with ESMTPS id 1F7A44A02F for ; Tue, 16 Jul 2013 22:55:26 +0200 (CEST) Received: by mail-pa0-f49.google.com with SMTP id ld11so1175060pab.36 for ; Tue, 16 Jul 2013 13:55:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=x0DaRFq214B8leTNZcl2fFvOsI7766DjVqe/c3Y3Ag0=; b=KuMcvvvdU7pw9m05rjyanBCBn8autO/5ezyB4zBBc+SWV/e8LSTeZg8UuMThZbvdFM UpP6uh3H9oCCfDETz9SK0tPq9h45bwQWiveYsQdKEIA0mJohzcrRwAbn2dl/cMtUBSqd fRhHefCtkJ1VrOf+hLQ3C8QKasZxHjRcIKjcdr35RjOcBctrORBlNqoO11uY/l1UizRV ggSmCXIaRajqL66hMB/bHl7EByUv+TD6tGeOxvyPACm+ywAVXFlp52/ItWqA+n3ltqCB OBHjqZJopxmjNWyEJWqLBAspo2pQR/V0953t5j8IZmbkww9R6qTk0wOyMhC9Sy57kKLy v+Fg== X-Received: by 10.66.235.106 with SMTP id ul10mr4262875pac.174.1374007673845; Tue, 16 Jul 2013 13:47:53 -0700 (PDT) Received: from officeserver-2 ([70.96.116.236]) by mx.google.com with ESMTPSA id pq1sm3647069pbb.26.2013.07.16.13.47.51 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 16 Jul 2013 13:47:52 -0700 (PDT) Received: from tkisky by officeserver-2 with local (Exim 4.80) (envelope-from ) id 1UzCA2-0000jG-33; Tue, 16 Jul 2013 13:47:50 -0700 From: Troy Kisky To: marek.vasut@gmail.com Date: Tue, 16 Jul 2013 13:47:29 -0700 Message-Id: <1374007666-2749-2-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1374007666-2749-1-git-send-email-troy.kisky@boundarydevices.com> References: <1374007666-2749-1-git-send-email-troy.kisky@boundarydevices.com> X-Gm-Message-State: ALoCoQnpKxTTcUg/wd5L79a4YUIc5DEWf9kc1vbORQQGktjRTzjUqF3rpw1nftFOOO67r/nMhyns Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH RFC V1 01/18] Add functions for use with i.mx6 otg udc X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Add functions for use with mx6 soc void otg_enable(void); void reset_usb_phy1(void); Signed-off-by: Troy Kisky --- arch/arm/cpu/armv7/mx6/soc.c | 70 +++++++++++++++++++++++++++++++ arch/arm/include/asm/arch-mx6/sys_proto.h | 4 ++ 2 files changed, 74 insertions(+) diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c index fc436fb..e5a5734 100644 --- a/arch/arm/cpu/armv7/mx6/soc.c +++ b/arch/arm/cpu/armv7/mx6/soc.c @@ -28,11 +28,81 @@ #include #include #include +#include #include #include #include #include +#ifdef CONFIG_MV_UDC + +struct set_clr_tog { + u32 val; + u32 set; + u32 clr; + u32 tog; +}; + +struct usbphy { + struct set_clr_tog pwd; + struct set_clr_tog tx; + struct set_clr_tog rx; + struct set_clr_tog ctrl; +}; + +#define BM_USBPHY_CTRL_CLKGATE 0x40000000 + +static void enable_usb_phy1_clk(unsigned char enable) +{ + struct usbphy *phy = (struct usbphy *)USB_PHY0_BASE_ADDR; + + writel(BM_USBPHY_CTRL_CLKGATE, + enable ? &phy->ctrl.clr : &phy->ctrl.set); +} + +#define BM_USBPHY_CTRL_SFTRST 0x80000000 + +void reset_usb_phy1(void) +{ + struct usbphy *phy = (struct usbphy *)USB_PHY0_BASE_ADDR; + + /* Reset USBPHY module */ + writel(BM_USBPHY_CTRL_SFTRST, &phy->ctrl.set); + udelay(10); + + /* Remove CLKGATE and SFTRST */ + writel(BM_USBPHY_CTRL_CLKGATE | BM_USBPHY_CTRL_SFTRST, &phy->ctrl.clr); + udelay(10); + + /* Power up the PHY */ + writel(0, &phy->pwd.val); +} + + +#define BM_ANADIG_USB1_CHRG_DETECT_CHK_CHRG_B 0x00080000 +#define BM_ANADIG_USB1_CHRG_DETECT_EN_B 0x00100000 + +static void set_usb_phy1_clk(void) +{ + struct anatop_regs *anatop = (struct anatop_regs *)ANATOP_BASE_ADDR; + + writel(BM_ANADIG_USB1_CHRG_DETECT_EN_B + | BM_ANADIG_USB1_CHRG_DETECT_CHK_CHRG_B, + &anatop->usb1_chrg_detect_set); + + /* make sure pll is enable here */ + writel(BM_ANADIG_USB1_PLL_480_CTRL_EN_USB_CLKS, + &anatop->usb1_pll_480_ctrl_set); +} + +void otg_enable(void) +{ + set_usb_phy1_clk(); + enable_usboh3_clk(1); + enable_usb_phy1_clk(1); +} +#endif + struct scu_regs { u32 ctrl; u32 config; diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h b/arch/arm/include/asm/arch-mx6/sys_proto.h index 38e4e51..8ac57df 100644 --- a/arch/arm/include/asm/arch-mx6/sys_proto.h +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h @@ -56,4 +56,8 @@ int mxs_wait_mask_set(struct mxs_register_32 *reg, int mxs_wait_mask_clr(struct mxs_register_32 *reg, uint32_t mask, unsigned int timeout); + +void otg_enable(void); +void reset_usb_phy1(void); + #endif