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: 13910 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 97FC823E21 for ; Tue, 8 Jan 2013 09:28:29 +0000 (UTC) Received: from mail-vb0-f44.google.com (mail-vb0-f44.google.com [209.85.212.44]) by fiordland.canonical.com (Postfix) with ESMTP id 3B6D2A18259 for ; Tue, 8 Jan 2013 09:28:29 +0000 (UTC) Received: by mail-vb0-f44.google.com with SMTP id fc26so157871vbb.17 for ; Tue, 08 Jan 2013 01:28:28 -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=kFj4C2KY38LoxyQCDhBY31GnDez6+O60WtbRXNafRBY=; b=jKwTxN7ShEqPCvvgKUWd0ABJ22zUADhStsgKc4u+JQKgtSBvICTvPEOAklI2LY2wFE d+cRAz/jCBp7lQ5MJRPKrcaQs6X5nTHS6ObUJhyWAM7f/rRrHIe6jRGhuxf1KLAzcq3s OujWWenXGVMJEKPujX5zfBAl1klsYDdUIqCFjyekXpWp7knDRQxAsUAaLvOOaWCAAHrP Ft0j2nHOXyIH6hfmZsPzKLby6YO4LVbu3VMqLbfM8jMKLKNunMeklrZa2+xz+Adr2fsr zq5xFZllOruWYFkhK4YVUl4/hggx6fNZrEPVh8TGp5kx1pR+mcnLKuIhHgO6g365OuIQ afuw== X-Received: by 10.58.247.132 with SMTP id ye4mr88992430vec.9.1357637308708; Tue, 08 Jan 2013 01:28:28 -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 st5csp101013veb; Tue, 8 Jan 2013 01:28:27 -0800 (PST) X-Received: by 10.68.251.233 with SMTP id zn9mr20989264pbc.7.1357637307239; Tue, 08 Jan 2013 01:28:27 -0800 (PST) Received: from mailout3.samsung.com (mailout3.samsung.com. [203.254.224.33]) by mx.google.com with ESMTP id ru9si61980421pbc.10.2013.01.08.01.28.26; Tue, 08 Jan 2013 01:28:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of gautam.vivek@samsung.com designates 203.254.224.33 as permitted sender) client-ip=203.254.224.33; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of gautam.vivek@samsung.com designates 203.254.224.33 as permitted sender) smtp.mail=gautam.vivek@samsung.com Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MGA00DOMVMQ0EK0@mailout3.samsung.com> for patches@linaro.org; Tue, 08 Jan 2013 18:28:25 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.124]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id EB.58.01231.9B6EBE05; Tue, 08 Jan 2013 18:28:25 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-e3-50ebe6b999ce Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 2B.58.01231.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 patches@linaro.org; Tue, 08 Jan 2013 18:28:25 +0900 (KST) From: Vivek Gautam To: u-boot@lists.denx.de Cc: patches@linaro.org, marex@denx.de, sjg@chromium.org, kmpark@infradead.org, rajeshwari.s@samsung.com, joshi@samsung.com Subject: [PATCH v4 1/3] EHCI: Exynos: Add fdt support 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+NgFjrILMWRmVeSWpSXmKPExsWyRsSkRnfns9cBBo/bVC2mHP7C4sDocefa HrYAxigum5TUnMyy1CJ9uwSujAVL/zAVHFaq2DNlPUsD40vpLkZODgkBE4k3P6+zQNhiEhfu rWfrYuTiEBJYyijxuG0fM0xR97yzzBCJ6YwSMyatg3JWMUksPDaNFaSKTUBXountLkYQW0RA QuJX/1Ugm4ODWaBGYu/CeBBTWMBUoudXEUgFi4CqxLXXT9i7GNk5eAU8JP4YQmxSkHhz+xkz RIWAxLfJh1hAGiUEZCU2HQDbKSGwg03i6f2H7BD1khIHV9xgmcAouICRYRWjaGpBckFxUnqu oV5xYm5xaV66XnJ+7iZGYDid/vdMagfjygaLQ4wCHIxKPLyXYl4HCLEmlhVX5h5ilOBgVhLh td8HFOJNSaysSi3Kjy8qzUktPsToA3TJRGYp0eR8YKjnlcQbGpuYmxqbWhoZmZma4hBWEudl PPUkQEggPbEkNTs1tSC1CGYcEwenVAPjFr1uyeCKFLlPdRZT9jWFz/jX/l1SIGGbtXyn9cad rU+tPIqlZYzLliYpCm05tIT/zJo35zicfe7uzjF5+cl9R/im6I3Tb3ZrLJU6J2e2/1zz4xC2 nlArQ+U9pUab1d/6ZLDc+zN/xzoPjzDbOulwcU/BTa4nOoO9NVTaoiVXMWdffxxaclqJpTgj 0VCLuag4EQDOSpmnVAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrALMWRmVeSWpSXmKPExsVy+t9jQd2dz14HGKw/LWAx5fAXFgdGjzvX 9rAFMEY1MNpkpCampBYppOYl56dk5qXbKnkHxzvHm5oZGOoaWlqYKynkJeam2iq5+AToumXm AI1VUihLzCkFCgUkFhcr6dthmhAa4qZrAdMYoesbEgTXY2SABhLWMGYsWPqHqeCwUsWeKetZ GhhfSncxcnJICJhIdM87ywxhi0lcuLeerYuRi0NIYDqjxIxJ65ghnFVMEguPTWMFqWIT0JVo eruLEcQWEZCQ+NV/Fcjm4GAWqJHYuzAexBQWMJXo+VUEUsEioCpx7fUT9i5Gdg5eAQ+JP4YQ mxQk3tx+xjyBkXsBI8MqRtHUguSC4qT0XEO94sTc4tK8dL3k/NxNjOBgfSa1g3Flg8UhRgEO RiUe3ksxrwOEWBPLiitzDzFKcDArifDa7wMK8aYkVlalFuXHF5XmpBYfYvQB2j2RWUo0OR8Y SXkl8YbGJuamxqaWJhYmZpY4hJXEeRlPPQkQEkhPLEnNTk0tSC2CGcfEwSnVwCj/3qPnTckp 29jrWelX91bnMvPGenHuXro13rntL1+Gsc+VT5LRsRWsviWeCoufzNeWf3+2femkxH3zFkfq KVUu+BYsmGBcWcIts1hrccyx5HC19psqM17P9fCysyyMPHOpVmzOojKL/sOZ4tkHn519M3P1 HYWfUxUjHqSYRa5RCevfv0WwRImlOCPRUIu5qDgRAJGhyzSDAgAA X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQmxbYLmw7+8usKJ7aBGSdJKRqGu+WzQAFHwhkjfssOMFTNjh0n0QYhZbq2vaJhHauaYv+8s 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; }