From patchwork Mon Aug 18 14:28:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 35524 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7489720676 for ; Mon, 18 Aug 2014 15:12:23 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id fp1sf41342551pdb.5 for ; Mon, 18 Aug 2014 08:12:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=CaqWbedNYNiB2/a0DHze2DUo4WZXKqtrXBpJBcZ6BP4=; b=U2fLaP9jEOylzBHRFJkLT8f4lBXPC5KGgZX6ao5i1eq09AEdSOPnz88g7sLYEsahJI NCh9MaiEN3j1BCGmCB6mmFMd6oVbUA/xS9X7j6vsSGcR7nKuthS1iSkFxIiWM1VA1ieP 8olfgOsfBEup7rgJyHZfJA3GDh8h1IpDBDw+AHgAjIe6HLi3LBT7u9czlp2NL7UMMmqY gcl+3v9RpAIzi3VV7u7cumXTWGbqVoC8bY2270ItVEZV9zQivnQqExO+e6Fhxxj2SP1o tlv+AyHNAAJ+iOB2D2FeV2tjJE3JYPpVM6Ohs24kjGqOhAa5bLhqmhEq5UJMU5QTnU7r wJ4A== X-Gm-Message-State: ALoCoQkChQNK+n4AZ3EssMgKPRgqe46yq80ihZbo/Bx3471K07jqpgnVMLIQwVO19VszT0DzvmQ+ X-Received: by 10.68.222.194 with SMTP id qo2mr18589100pbc.6.1408374736902; Mon, 18 Aug 2014 08:12:16 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.107.70 with SMTP id g64ls2630919qgf.85.gmail; Mon, 18 Aug 2014 08:12:16 -0700 (PDT) X-Received: by 10.220.110.77 with SMTP id m13mr1994051vcp.35.1408374736761; Mon, 18 Aug 2014 08:12:16 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id t1si7221111vcx.69.2014.08.18.08.12.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Aug 2014 08:12:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id hq11so5938600vcb.30 for ; Mon, 18 Aug 2014 08:12:16 -0700 (PDT) X-Received: by 10.52.119.229 with SMTP id kx5mr5127626vdb.40.1408374736669; Mon, 18 Aug 2014 08:12:16 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp160491vcb; Mon, 18 Aug 2014 08:12:15 -0700 (PDT) X-Received: by 10.180.108.1 with SMTP id hg1mr73082742wib.25.1408374735544; Mon, 18 Aug 2014 08:12:15 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id lj12si7143806wic.10.2014.08.18.08.12.15 for ; Mon, 18 Aug 2014 08:12:15 -0700 (PDT) Received-SPF: none (google.com: u-boot-bounces@lists.denx.de does not designate permitted sender hosts) client-ip=85.214.87.163; Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C296E4B5D0; Mon, 18 Aug 2014 17:10: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 s+zQFrfSkaxf; Mon, 18 Aug 2014 17:10:13 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 682504B64D; Mon, 18 Aug 2014 17:08:02 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0945E4A044 for ; Mon, 18 Aug 2014 16:29:48 +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 6qriWlQPwVQi for ; Mon, 18 Aug 2014 16:29:42 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by theia.denx.de (Postfix) with ESMTPS id D4BF14A03B for ; Mon, 18 Aug 2014 16:29:08 +0200 (CEST) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s7IET6Bt006717 for ; Mon, 18 Aug 2014 09:29:06 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s7IET6d6006609 for ; Mon, 18 Aug 2014 09:29:06 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Mon, 18 Aug 2014 09:29:06 -0500 Received: from a0393678lt.apr.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s7IESbMB003614; Mon, 18 Aug 2014 09:29:03 -0500 From: Kishon Vijay Abraham I To: , , , , , , Date: Mon, 18 Aug 2014 19:58:32 +0530 Message-ID: <1408372115-4570-11-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1408372115-4570-1-git-send-email-kishon@ti.com> References: <1408372115-4570-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 18 Aug 2014 17:07:53 +0200 Subject: [U-Boot] [UBOOT RFC PATCH 10/13] board: ti: DRA7: added USB initializtion code X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: kishon@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Implemented board_usb_init(), board_usb_cleanup() and board_usb_gadget_handle_interrupts() in dra7xx board file that can be invoked by various gadget drivers. Signed-off-by: Kishon Vijay Abraham I --- arch/arm/include/asm/arch-omap5/omap.h | 12 ++++ board/ti/dra7xx/evm.c | 106 +++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) diff --git a/arch/arm/include/asm/arch-omap5/omap.h b/arch/arm/include/asm/arch-omap5/omap.h index b9600cf..a2348a2 100644 --- a/arch/arm/include/asm/arch-omap5/omap.h +++ b/arch/arm/include/asm/arch-omap5/omap.h @@ -33,6 +33,18 @@ #define CONTROL_ID_CODE CONTROL_CORE_ID_CODE #endif +#ifdef CONFIG_DRA7XX +#define DRA7_USB_OTG_SS1_BASE 0x48890000 +#define DRA7_USB_OTG_SS1_GLUE_BASE 0x48880000 +#define DRA7_USB3_PHY1_PLL_CTRL 0x4A084C00 +#define DRA7_USB3_PHY1_POWER 0x4A002370 +#define DRA7_USB2_PHY1_POWER 0x4A002300 + +#define DRA7_USB_OTG_SS2_BASE 0x488D0000 +#define DRA7_USB_OTG_SS2_GLUE_BASE 0x488C0000 +#define DRA7_USB2_PHY2_POWER 0x4A002E74 +#endif + /* To be verified */ #define OMAP5430_CONTROL_ID_CODE_ES1_0 0x0B94202F #define OMAP5430_CONTROL_ID_CODE_ES2_0 0x1B94202F diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c index 073d151..0d1b93f 100644 --- a/board/ti/dra7xx/evm.c +++ b/board/ti/dra7xx/evm.c @@ -13,10 +13,14 @@ #include #include #include +#include #include #include #include #include +#include +#include +#include #include "mux_data.h" @@ -125,6 +129,108 @@ int board_mmc_init(bd_t *bis) } #endif +static struct dwc3_device usb_otg_ss1 = { + .maximum_speed = USB_SPEED_SUPER, + .base = DRA7_USB_OTG_SS1_BASE, + .needs_fifo_resize = true, +}; + +static struct dwc3_omap_device usb_otg_ss1_glue = { + .base = (void *)DRA7_USB_OTG_SS1_GLUE_BASE, + .utmi_mode = DWC3_OMAP_UTMI_MODE_SW, + .vbus_id_status = OMAP_DWC3_VBUS_VALID, +}; + +static struct ti_usb_phy_device usb_phy1_device = { + .pll_ctrl_base = (void *)DRA7_USB3_PHY1_PLL_CTRL, + .usb2_phy_power = (void *)DRA7_USB2_PHY1_POWER, + .usb3_phy_power = (void *)DRA7_USB3_PHY1_POWER, +}; + +static struct dwc3_device usb_otg_ss2 = { + .maximum_speed = USB_SPEED_SUPER, + .base = DRA7_USB_OTG_SS2_BASE, + .needs_fifo_resize = true, +}; + +static struct dwc3_omap_device usb_otg_ss2_glue = { + .base = (void *) DRA7_USB_OTG_SS2_GLUE_BASE, + .utmi_mode = DWC3_OMAP_UTMI_MODE_SW, + .vbus_id_status = OMAP_DWC3_VBUS_VALID, +}; + +static struct ti_usb_phy_device usb_phy2_device = { + .usb2_phy_power = (void *) DRA7_USB2_PHY2_POWER, +}; + +int board_usb_init(int index, enum usb_init_type init) +{ + switch (index) { + case 0: + if (init == USB_INIT_DEVICE) { + usb_otg_ss1.dr_mode = USB_DR_MODE_PERIPHERAL; + usb_otg_ss1_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID; + } else { + usb_otg_ss1.dr_mode = USB_DR_MODE_HOST; + usb_otg_ss1_glue.vbus_id_status = OMAP_DWC3_ID_GROUND; + } + + ti_usb_phy_uboot_init(&usb_phy1_device); + dwc3_omap_uboot_init(&usb_otg_ss1_glue); + dwc3_uboot_init(&usb_otg_ss1); + break; + case 1: + if (init == USB_INIT_DEVICE) { + usb_otg_ss2.dr_mode = USB_DR_MODE_PERIPHERAL; + usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID; + } else { + usb_otg_ss2.dr_mode = USB_DR_MODE_HOST; + usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_ID_GROUND; + } + + ti_usb_phy_uboot_init(&usb_phy2_device); + dwc3_omap_uboot_init(&usb_otg_ss2_glue); + dwc3_uboot_init(&usb_otg_ss2); + break; + default: + printf("Invalid Controller Index\n"); + } + + return 0; +} + +int board_usb_cleanup(int index, enum usb_init_type init) +{ + switch (index) { + case 0: + case 1: + ti_usb_phy_uboot_exit(index); + dwc3_uboot_exit(index); + dwc3_omap_uboot_exit(index); + break; + default: + printf("Invalid Controller Index\n"); + } + return 0; +} + +int board_usb_gadget_handle_interrupts(int index) +{ + u32 status; + switch (index) { + case 0: + case 1: + status = dwc3_omap_uboot_interrupt_status(index); + if (status) + dwc3_uboot_handle_interrupt(index); + break; + default: + printf("Invalid Controller Index\n"); + } + + return 0; +} + #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT) int spl_start_uboot(void) {