From patchwork Tue May 15 13:58:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhao X-Patchwork-Id: 8653 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 9352723E13 for ; Tue, 15 May 2012 13:59:14 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 4C688A182AC for ; Tue, 15 May 2012 13:59:14 +0000 (UTC) Received: by yenq6 with SMTP id q6so6748877yen.11 for ; Tue, 15 May 2012 06:59:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :x-spamscore:x-bigfish:x-forefront-antispam-report:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:x-originatororg:x-gm-message-state; bh=dUT5ZOhcfD2fmDZFYGKCURetLbIGJVxxdHGxat8mEhg=; b=GqeAIU+ZkJTyfEuFALDBUUg+dROFJTW0XCIRUd2HOPO/h3MZ66AXa7sW4CXQeKHE59 yzqj7/JaKDrwQF5rgjl7gFV88GVLt6fGh7zLHaQX5gGmPsrZA1b8b8DS/DkbIEO9y5iM 3i1oCKIHzg+WGK7L2GQLlgVLgWOd43ZU6m/JVwb1kUq56WTjau1d2KFtIMR0jVy2mp3V hTaXW46aQofYK1AF2FcKtwsm9eXmG2SS26iVN0kb5zlkfMHUHeshpCdXAZtsG/hRVKME 7jWKBV9QFyguw+qbQ+wQiMLhY3ALMsOwjFnh7EGHywvykCHFz55NGkLj+p/SmhnK30o1 gmOg== Received: by 10.50.87.227 with SMTP id bb3mr2313013igb.57.1337090353601; Tue, 15 May 2012 06:59:13 -0700 (PDT) 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.231.35.72 with SMTP id o8csp422506ibd; Tue, 15 May 2012 06:59:12 -0700 (PDT) Received: by 10.180.93.38 with SMTP id cr6mr30402366wib.16.1337090352274; Tue, 15 May 2012 06:59:12 -0700 (PDT) Received: from tx2outboundpool.messaging.microsoft.com (tx2ehsobe001.messaging.microsoft.com. [65.55.88.11]) by mx.google.com with ESMTPS id c45si17200685wec.72.2012.05.15.06.59.11 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 15 May 2012 06:59:12 -0700 (PDT) Received-SPF: neutral (google.com: 65.55.88.11 is neither permitted nor denied by best guess record for domain of B20223@freescale.com) client-ip=65.55.88.11; Authentication-Results: mx.google.com; spf=neutral (google.com: 65.55.88.11 is neither permitted nor denied by best guess record for domain of B20223@freescale.com) smtp.mail=B20223@freescale.com Received: from mail99-tx2-R.bigfish.com (10.9.14.242) by TX2EHSOBE002.bigfish.com (10.9.40.22) with Microsoft SMTP Server id 14.1.225.23; Tue, 15 May 2012 13:59:04 +0000 Received: from mail99-tx2 (localhost [127.0.0.1]) by mail99-tx2-R.bigfish.com (Postfix) with ESMTP id D698A405F4; Tue, 15 May 2012 13:59:04 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bh8275dhz2dh2a8h668h839hd24he5bh) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI Received: from mail99-tx2 (localhost.localdomain [127.0.0.1]) by mail99-tx2 (MessageSwitch) id 1337090341905792_15062; Tue, 15 May 2012 13:59:01 +0000 (UTC) Received: from TX2EHSMHS014.bigfish.com (unknown [10.9.14.242]) by mail99-tx2.bigfish.com (Postfix) with ESMTP id D64F9200104; Tue, 15 May 2012 13:59:01 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS014.bigfish.com (10.9.99.114) with Microsoft SMTP Server (TLS) id 14.1.225.23; Tue, 15 May 2012 13:59:00 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server id 14.2.298.5; Tue, 15 May 2012 08:59:05 -0500 Received: from b20223-02.ap.freescale.net (b20223-02.ap.freescale.net [10.192.242.124]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id q4FDwjZN003112; Tue, 15 May 2012 08:59:01 -0500 (CDT) From: Richard Zhao To: , CC: , , , , , , , , , Richard Zhao Subject: [PATCH v1 4/7] usb: chipidea: add imx driver binding Date: Tue, 15 May 2012 21:58:20 +0800 Message-ID: <1337090303-16046-5-git-send-email-richard.zhao@freescale.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1337090303-16046-1-git-send-email-richard.zhao@freescale.com> References: <1337090303-16046-1-git-send-email-richard.zhao@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-Gm-Message-State: ALoCoQkemi0J0XStToshOrfXaoRZSxgnUrJSUgNijbXhR/xpYyn7ym04K6hynBT2PYW0d8lCbrvv Signed-off-by: Richard Zhao --- drivers/usb/chipidea/Makefile | 2 +- drivers/usb/chipidea/ci13xxx_imx.c | 177 ++++++++++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+), 1 deletions(-) create mode 100644 drivers/usb/chipidea/ci13xxx_imx.c diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile index 0f34c0c..6821385 100644 --- a/drivers/usb/chipidea/Makefile +++ b/drivers/usb/chipidea/Makefile @@ -14,5 +14,5 @@ ifneq ($(CONFIG_ARCH_MSM),) endif ifneq ($(CONFIG_ARCH_MXC),) - obj-$(CONFIG_USB_CHIPIDEA) += phy-imx-utmi.o + obj-$(CONFIG_USB_CHIPIDEA) += phy-imx-utmi.o ci13xxx_imx.o endif diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c new file mode 100644 index 0000000..5f36f07 --- /dev/null +++ b/drivers/usb/chipidea/ci13xxx_imx.c @@ -0,0 +1,177 @@ +/* + * Copyright 2012 Freescale Semiconductor, Inc. + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ci.h" + +#define pdev_to_phy(pdev) \ + ((struct usb_phy *)platform_get_drvdata(pdev)) + +static void ci13xxx_imx_notify_event(struct ci13xxx *udc, unsigned event) +{ +#if 0 + struct device *dev = udc->gadget.dev.parent; + int val; + + switch (event) { + case CI13XXX_CONTROLLER_RESET_EVENT: + dev_dbg(dev, "CI13XXX_CONTROLLER_RESET_EVENT received\n"); + writel(0, USB_AHBBURST); + writel(0, USB_AHBMODE); + break; + case CI13XXX_CONTROLLER_STOPPED_EVENT: + dev_dbg(dev, "CI13XXX_CONTROLLER_STOPPED_EVENT received\n"); + /* + * Put the transceiver in non-driving mode. Otherwise host + * may not detect soft-disconnection. + */ + val = usb_phy_io_read(udc->transceiver, ULPI_FUNC_CTRL); + val &= ~ULPI_FUNC_CTRL_OPMODE_MASK; + val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; + usb_phy_io_write(udc->transceiver, val, ULPI_FUNC_CTRL); + break; + default: + dev_dbg(dev, "unknown ci13xxx_udc event\n"); + break; + } +#endif +} + +static struct ci13xxx_udc_driver ci13xxx_imx_udc_driver = { + .name = "ci13xxx_imx", + .flags = CI13XXX_REGS_SHARED | + CI13XXX_PULLUP_ON_VBUS | + CI13XXX_DISABLE_STREAMING, + .capoffset = 0x100, + + .notify_event = ci13xxx_imx_notify_event, +}; + +static int ci13xxx_imx_probe(struct platform_device *pdev) +{ + struct platform_device *plat_ci, *phy_pdev; + struct device_node *phy_np; + struct resource *res; + int hub_reset, vbus_pwr; + int ret; + + dev_dbg(&pdev->dev, "ci13xxx_imx_probe\n"); + + phy_np = of_parse_phandle(pdev->dev.of_node, "fsl,usbphy", 0); + if (phy_np) { + phy_pdev = of_find_device_by_node(phy_np); + if (phy_pdev) { + struct usb_phy *phy; + phy = pdev_to_phy(phy_pdev); + if (phy) + usb_phy_init(phy); + } + of_node_put(phy_np); + } + + hub_reset = of_get_named_gpio(pdev->dev.of_node, "fsl,hub-reset", 0); + if (hub_reset > 0 && + devm_gpio_request(&pdev->dev, hub_reset, "hub-reset")) { + gpio_direction_output(hub_reset, 0); + udelay(10); + gpio_direction_output(hub_reset, 1); + } + + /* we only support host now, so enable vbus here */ + vbus_pwr = of_get_named_gpio(pdev->dev.of_node, "fsl,vbus-power", 0); + if (vbus_pwr > 0 && + devm_gpio_request(&pdev->dev, vbus_pwr, "vbus-pwr")) { + gpio_direction_output(vbus_pwr, 1); + } + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, "can't get device resources\n"); + return -ENOENT; + } + + plat_ci = platform_device_alloc("ci_hdrc", (int)res->start); + if (!plat_ci) { + dev_err(&pdev->dev, "can't allocate ci_hdrc platform device\n"); + return -ENOMEM; + } + + ret = platform_device_add_resources(plat_ci, pdev->resource, + pdev->num_resources); + if (ret) { + dev_err(&pdev->dev, "can't add resources to platform device\n"); + goto put_platform; + } + + ret = platform_device_add_data(plat_ci, &ci13xxx_imx_udc_driver, + sizeof(ci13xxx_imx_udc_driver)); + if (ret) + goto put_platform; + + plat_ci->dev.dma_mask = + kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL); + if (!plat_ci->dev.dma_mask) { + ret = -ENOMEM; + goto put_platform; + } + *plat_ci->dev.dma_mask = DMA_BIT_MASK(32); + plat_ci->dev.coherent_dma_mask = DMA_BIT_MASK(32); + + ret = platform_device_add(plat_ci); + if (ret) + goto free_dma_mask; + + pm_runtime_no_callbacks(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + return 0; + +free_dma_mask: + kfree(plat_ci->dev.dma_mask); + plat_ci->dev.dma_mask = NULL; +put_platform: + platform_device_put(plat_ci); + + return ret; +} + +static const struct of_device_id ci13xxx_imx_dt_ids[] = { + { .compatible = "fsl,imx6q-usboh3", }, + { /* sentinel */ } +}; + +static struct platform_driver ci13xxx_imx_driver = { + .probe = ci13xxx_imx_probe, + .driver = { + .name = "imx_usboh3", + .of_match_table = ci13xxx_imx_dt_ids, + }, +}; + +MODULE_ALIAS("platform:imx_usboh3"); + +static int __init ci13xxx_imx_init(void) +{ + return platform_driver_register(&ci13xxx_imx_driver); +} +module_init(ci13xxx_imx_init); + +MODULE_LICENSE("GPL v2");