From patchwork Thu Jan 3 15:12:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 209301 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 5B0292C007E for ; Fri, 4 Jan 2013 07:12:28 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4FA744A0EF; Thu, 3 Jan 2013 21:12:25 +0100 (CET) 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 yaNkcbWXk+gN; Thu, 3 Jan 2013 21:12:25 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BF9FA4A02E; Thu, 3 Jan 2013 21:12:17 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 73D9C4A0F1 for ; Thu, 3 Jan 2013 16:06:33 +0100 (CET) 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 tw-SFYj5ojYU for ; Thu, 3 Jan 2013 16:06:31 +0100 (CET) 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 mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by theia.denx.de (Postfix) with ESMTP id 4A6E04A0EE for ; Thu, 3 Jan 2013 16:06:29 +0100 (CET) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MG2004KI1YQTPA0@mailout3.samsung.com> for u-boot@lists.denx.de; Fri, 04 Jan 2013 00:06:26 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.123]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 70.AD.12699.27E95E05; Fri, 04 Jan 2013 00:06:26 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-b3-50e59e72a169 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 4F.9D.12699.27E95E05; Fri, 04 Jan 2013 00:06:26 +0900 (KST) Received: from vivekkumarg-linuxpc.sisodomain.com ([107.108.73.134]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MG2002M51Y8UP00@mmp2.samsung.com> for u-boot@lists.denx.de; Fri, 04 Jan 2013 00:06:26 +0900 (KST) From: Vivek Gautam To: u-boot@lists.denx.de Date: Thu, 03 Jan 2013 20:42:55 +0530 Message-id: <1357225977-13346-1-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.6.5 DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrELMWRmVeSWpSXmKPExsWyRsSkWrdo3tMAg689+hZv93ayOzB6nL2z gzGAMYrLJiU1J7MstUjfLoEr4/7XFawFLUoVO47dYG5g3CHdxcjJISFgIrH40nFmCFtM4sK9 9WxdjFwcQgJLGSWWLzjJBFO048laVojEdEaJ5yc3s0A4a5gkLny9AlbFJqAr0fR2FyOILSIg IfGr/yqYzSyQLnFi/i2gbg4OYQFTib3P+UBMFgFViecHFUFMXgEPiXM/tCBWKUi8uf0M7B4W AQGJb5MPsYCUSAjISmw6wAyyVEJgB5vEt0MzWCDqJSUOrrjBMoFRcAEjwypG0dSC5ILipP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/bNLcM7hT88fV2tapV9dy6v42flv96a9c9W8FU5eE/hW w59mt1jog+vS1g2X8x04pdWUWIozEg21mIuKEwH8upJ/hAIAAA== X-CFilter-Loop: Reflected X-Mailman-Approved-At: Thu, 03 Jan 2013 21:12:16 +0100 Cc: marex@denx.de, Rajeshwari Shinde , patches@linaro.org Subject: [U-Boot] [PATCH v3 1/3] EHCI: Exynos: Add fdt support 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 From: Rajeshwari Shinde Adding fdt support to ehci-exynos in order to parse register base addresses from the device node. Signed-off-by: Vivek Gautam Signed-off-by: Rajeshwari Shinde --- Changes in v3: - Using macros for error no. - Using a common function exynos_usb_parse_dt() to parse all DT related data. - Using a global structure "exynos_ehci" to store register base addresses and thereby using it. Chnages in v2: - Removed checkpatch errors. drivers/usb/host/ehci-exynos.c | 92 +++++++++++++++++++++++++++++++++++++--- 1 files changed, 85 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index 9f0ed06..3ca4c5c 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -21,13 +21,71 @@ */ #include +#include +#include +#include #include #include #include #include #include +#include +#include #include "ehci.h" +/* Declare global data pointer */ +DECLARE_GLOBAL_DATA_PTR; + +/** + * Contains pointers to register base addresses + * for the usb controller. + */ +struct exynos_ehci { + struct exynos_usb_phy *usb; + unsigned int *hcd; +}; + +static int exynos_usb_parse_dt(const void *blob, struct exynos_ehci *exynos) +{ + unsigned int node; + int depth; + + node = fdtdec_next_compatible(blob, 0, COMPAT_SAMSUNG_EXYNOS_EHCI); + if (node <= 0) { + debug("EHCI: Can't get device node for ehci\n"); + return -ENODEV; + } + + /* + * Get the base address for EHCI controller from the device node + */ + exynos->hcd = (unsigned int *)fdtdec_get_addr(blob, node, "reg"); + if (exynos->hcd == NULL) { + debug("Can't get the EHCI register address\n"); + return -ENXIO; + } + + depth = 0; + node = fdtdec_next_compatible_subnode(blob, node, + COMPAT_SAMSUNG_EXYNOS_USB_PHY, &depth); + if (node <= 0) { + debug("EHCI: Can't get device node for usb-phy controller\n"); + return -ENODEV; + } + + /* + * Get the base address for usbphy from the device node + */ + exynos->usb = (struct exynos_usb_phy *)fdtdec_get_addr(blob, node, + "reg"); + if (exynos->usb == NULL) { + debug("Can't get the usbphy register address\n"); + return -ENXIO; + } + + return 0; +} + /* Setup the EHCI host controller. */ static void setup_usb_phy(struct exynos_usb_phy *usb) { @@ -86,12 +144,20 @@ static void reset_usb_phy(struct exynos_usb_phy *usb) */ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { - struct exynos_usb_phy *usb; + struct exynos_ehci *exynos = NULL; + + exynos = (struct exynos_ehci *) + kzalloc(sizeof(struct exynos_ehci), GFP_KERNEL); + if (!exynos) { + debug("failed to allocate exynos ehci context\n"); + return -ENOMEM; + } - usb = (struct exynos_usb_phy *)samsung_get_base_usb_phy(); - setup_usb_phy(usb); + exynos_usb_parse_dt(gd->fdt_blob, exynos); - *hccr = (struct ehci_hccr *)samsung_get_base_usb_ehci(); + setup_usb_phy(exynos->usb); + + *hccr = (struct ehci_hccr *)(exynos->hcd); *hcor = (struct ehci_hcor *)((uint32_t) *hccr + HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); @@ -99,6 +165,8 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) (uint32_t)*hccr, (uint32_t)*hcor, (uint32_t)HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); + kfree(exynos); + return 0; } @@ -108,10 +176,20 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) */ int ehci_hcd_stop(int index) { - struct exynos_usb_phy *usb; + struct exynos_ehci *exynos = NULL; + + exynos = (struct exynos_ehci *) + kzalloc(sizeof(struct exynos_ehci), GFP_KERNEL); + if (!exynos) { + debug("failed to allocate exynos ehci context\n"); + return -ENOMEM; + } + + exynos_usb_parse_dt(gd->fdt_blob, exynos); + + reset_usb_phy(exynos->usb); - usb = (struct exynos_usb_phy *)samsung_get_base_usb_phy(); - reset_usb_phy(usb); + kfree(exynos); return 0; }