From patchwork Tue Jan 8 09:35:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 210317 X-Patchwork-Delegate: promsoft@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 78D4A2C008F for ; Tue, 8 Jan 2013 20:28:37 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 262F04A0F7; Tue, 8 Jan 2013 10:28:35 +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 PMq-th7nOFHk; Tue, 8 Jan 2013 10:28:34 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E5B054A0EF; Tue, 8 Jan 2013 10:28:33 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5603C4A0EF for ; Tue, 8 Jan 2013 10:28:32 +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 Ed35oAVD2GCo for ; Tue, 8 Jan 2013 10:28:30 +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 mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by theia.denx.de (Postfix) with ESMTP id 8B21B4A0EB for ; Tue, 8 Jan 2013 10:28:28 +0100 (CET) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MGA00KTTVMFWHM0@mailout2.samsung.com> for u-boot@lists.denx.de; Tue, 08 Jan 2013 18:28:25 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.124]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 86.B1.12699.9B6EBE05; Tue, 08 Jan 2013 18:28:25 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-01-50ebe6b90ff8 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id D5.B1.12699.9B6EBE05; Tue, 08 Jan 2013 18:28:25 +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 <0MGA007GGVMY1E30@mmp2.samsung.com> for u-boot@lists.denx.de; Tue, 08 Jan 2013 18:28:25 +0900 (KST) From: Vivek Gautam To: u-boot@lists.denx.de Date: Tue, 08 Jan 2013 15:05:03 +0530 Message-id: <1357637705-10446-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+NgFjrILMWRmVeSWpSXmKPExsWyRsSkRnfns9cBBqvnqVq83dvJ7sDocfbO DsYAxigum5TUnMyy1CJ9uwSujAVL/zAVHFaq2DNlPUsD40vpLkZODgkBE4kL9xexQdhiEhfu rQeyuTiEBJYySnx9+4gRpmjd6T3MEInpjBL7um5DOWuYJK7+mccEUsUmoCvR9HYXWIeIgITE r/6rQDYHB7NAjcTehfEgprCAqUTPryKQChYBVYlrr5+wdzGyc/AKeEj8MYTYpCDx5vYzZogK AYlvkw+xgDRKCMhKbDoAtlNCYAebxPuTP6Auk5Q4uOIGywRGwQWMDKsYRVMLkguKk9JzjfS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bC6xWXOWyzVAxyvM11Trn/w4cCRf33pytXXbdwWeXpe nmTTEiOY/1Z5b+aMWbw34pZEK7EUZyQaajEXFScCAO+ZADODAgAA X-CFilter-Loop: Reflected Cc: marex@denx.de, kmpark@infradead.org, patches@linaro.org, joshi@samsung.com, rajeshwari.s@samsung.com Subject: [U-Boot] [PATCH v4 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 v4: - Rebased on top of u-boot-samsung/master. 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. Changes 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; }