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: 13777 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 3258C23EDD for ; Thu, 3 Jan 2013 15:06:32 +0000 (UTC) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by fiordland.canonical.com (Postfix) with ESMTP id B6D13A19545 for ; Thu, 3 Jan 2013 15:06:31 +0000 (UTC) Received: by mail-vc0-f175.google.com with SMTP id fy7so15515890vcb.34 for ; Thu, 03 Jan 2013 07:06:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-auditid:from:to:cc:subject:date:message-id:x-mailer :dlp-filter:x-mtr:x-brightmail-tracker:x-brightmail-tracker :x-cfilter-loop:x-gm-message-state; bh=oy/6u1PfLDbmzEQNsKHHhU8+5auNVV/HHfDSObeAid4=; b=n5BH64jLzwr5LQ35dLeEGh8vXMj+xWfv5c7j0I8QIL0CmOWHcmzO7wJkcSvudIVEow SbuVavFxMuHqHRxcLBMjMqNPLWerqux9c5lwWUTIx3j3lsZ2ZdlYyBazJ3l0PJkpZYiv MT50jNt2F4huZPd9cxTPBGhuHDQ+/dz6t2Jb8nkXCE+61tU4LkkPTvNoUsCYG+6Zeeeo B2WByYC/RwmR48IgR9JATx5AZwl58P1NJA4qa/I5yvqFEDum8N+jgD05Xw0xSUGAtAC9 P4vtsy+TemlunrcT//MGLInvOKGR7efOPDG0vpv6va5t4g9ouq/gfbajW6OeTMlEP0GN VNLw== X-Received: by 10.52.70.205 with SMTP id o13mr64438105vdu.75.1357225591152; Thu, 03 Jan 2013 07:06:31 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp95524veb; Thu, 3 Jan 2013 07:06:30 -0800 (PST) X-Received: by 10.68.232.200 with SMTP id tq8mr153822654pbc.52.1357225588505; Thu, 03 Jan 2013 07:06:28 -0800 (PST) Received: from mailout2.samsung.com (mailout2.samsung.com. [203.254.224.25]) by mx.google.com with ESMTP id f9si48149069paw.82.2013.01.03.07.06.27; Thu, 03 Jan 2013 07:06:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of gautam.vivek@samsung.com designates 203.254.224.25 as permitted sender) client-ip=203.254.224.25; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of gautam.vivek@samsung.com designates 203.254.224.25 as permitted sender) smtp.mail=gautam.vivek@samsung.com Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MG200HZG1YQP720@mailout2.samsung.com> for patches@linaro.org; Fri, 04 Jan 2013 00:06:26 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.125]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 6C.D9.01231.27E95E05; Fri, 04 Jan 2013 00:06:26 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-f3-50e59e72efb3 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id BB.D9.01231.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 patches@linaro.org; Fri, 04 Jan 2013 00:06:26 +0900 (KST) From: Vivek Gautam To: u-boot@lists.denx.de Cc: marex@denx.de, patches@linaro.org, sjg@chromium.org, Rajeshwari Shinde Subject: [PATCH v3 1/3] EHCI: Exynos: Add fdt support 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+NgFjrILMWRmVeSWpSXmKPExsWyRsSkVrdo3tMAg9lbNCymHP7C4sDocefa HrYAxigum5TUnMyy1CJ9uwSujPtfV7AWtChV7Dh2g7mBcYd0FyMnh4SAicS/pccYIWwxiQv3 1rOB2EICSxkltqwxh6l50N3N0sXIBRSfzijR82k6I4Sziknixr1v7CBVbAK6Ek1vd4FNEhGQ kPjVfxXMZhZIlzgx/xZrFyMHh7CAqcTe53wgJouAqsTzg4ogJq+Ah8S5H1oQqxQk3tx+xgxi swgISHybfIgFpERCQFZi0wFmkKUSAjvYJI4//sYMUS8pcXDFDZYJjIILGBlWMYqmFiQXFCel 5xrqFSfmFpfmpesl5+duYgSG0+l/z6R2MK5ssDjEKMDBqMTDy1j/JECINbGsuDL3EKMEB7OS CO/s/KcBQrwpiZVVqUX58UWlOanFhxh9gC6ZyCwlmpwPDPW8knhDYxNzU2NTSyMjM1NTHMJK 4ryMp4DGC6QnlqRmp6YWpBbBjGPi4JRqYIx49OL66lONN5dVnbHxv5XH86r5Nf8TsbpSyYhJ Xz2uZKyVfvhS6cR+t7SZXIvjrEUfRT2N1eEuZknv+2R4fMme/NlPF0yaPP98OKv1sjePFqq9 d1376Pa18lKnIMFZ/taul/a+zGd8Kpk82degRttJquC2yn5xtz83jbarnH3F8jfA6FLZa10l luKMREMt5qLiRAByK7KZVAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrILMWRmVeSWpSXmKPExsVy+t9jQd2ieU8DDK6dkLSYcvgLiwOjx51r e9gCGKMaGG0yUhNTUosUUvOS81My89JtlbyD453jTc0MDHUNLS3MlRTyEnNTbZVcfAJ03TJz gMYqKZQl5pQChQISi4uV9O0wTQgNcdO1gGmM0PUNCYLrMTJAAwlrGDPuf13BWtCiVLHj2A3m BsYd0l2MnBwSAiYSD7q7WSBsMYkL99azdTFycQgJTGeU6Pk0nRHCWcUkcePeN3aQKjYBXYmm t7sYQWwRAQmJX/1XwWxmgXSJE/NvsXYxcnAIC5hK7H3OB2KyCKhKPD+oCGLyCnhInPuhBbFK QeLN7WfMExi5FzAyrGIUTS1ILihOSs811CtOzC0uzUvXS87P3cQIDtdnUjsYVzZYHGIU4GBU 4uFlrH8SIMSaWFZcmXuIUYKDWUmEd3b+0wAh3pTEyqrUovz4otKc1OJDjD5AuycyS4km5wNj Ka8k3tDYxNzU2NTSxMLEzBKHsJI4L+MpoPEC6YklqdmpqQWpRTDjmDg4pRoYD/BO2j35+h3v Zu55KxesCNbsdDM9XHPXP2fJhq9F3N69yTPWnMxOe76V//wxs7exdhXfa+cbTYyLiitn3tJb qV4X+33BC+a4NBUpk6rN8e25D/bevWqTtfNtYEEC413fmUbuJv3xwddjVXqf8emaSKx9dsTv hvCx52pzeSIV/kVE7SjRtLujxFKckWioxVxUnAgA963cWIQCAAA= X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQl1Mex3+vKbHTO7el1x16IJTfOVJGMqpeiv+isFsy9GVlpuuoh7Vy888D5tJtlTcWowbrB3 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; }