From patchwork Tue May 15 08:23:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 159254 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B6A96B6FA3 for ; Tue, 15 May 2012 18:27:43 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SUD4Q-0006Lm-Hf; Tue, 15 May 2012 08:25:26 +0000 Received: from mail-out.m-online.net ([2001:a60:0:32:0:1:25:1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SUD37-0005rt-0P for linux-arm-kernel@lists.infradead.org; Tue, 15 May 2012 08:24:09 +0000 Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3VsBdF6VDfz3hhgC; Tue, 15 May 2012 10:24:01 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.8.164]) by mail.m-online.net (Postfix) with ESMTP id 3VsBdF5XWlz4KK5P; Tue, 15 May 2012 10:24:01 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from smtp-auth.mnet-online.de ([192.168.8.180]) by localhost (dynscan1.mail.m-online.net [192.168.8.164]) (amavisd-new, port 10024) with ESMTP id J+6zkkyGidVU; Tue, 15 May 2012 10:24:00 +0200 (CEST) Received: from mashiro.lan (host-82-135-33-74.customer.m-online.net [82.135.33.74]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA; Tue, 15 May 2012 10:23:59 +0200 (CEST) From: Marek Vasut To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 6/8] CI13xxx: Add i.MX233/i.MX28 binding code Date: Tue, 15 May 2012 10:23:37 +0200 Message-Id: <1337070219-3630-7-git-send-email-marex@denx.de> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1337070219-3630-1-git-send-email-marex@denx.de> References: <1337070219-3630-1-git-send-email-marex@denx.de> MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Marek Vasut , Fabio Estevam , Wolfgang Denk , Detlev Zundel , Greg Kroah-Hartman , Sascha Hauer , Wolfram Sang , Felipe Balbi , Alan Stern , linux-i2c@vger.kernel.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Shawn Guo , Dong Aisheng , Stefano Babic X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org This codes connects the CI13xxx driver with the core found inside of the Freescale i.MX244/i.MX28 CPU. Signed-off-by: Marek Vasut Cc: Alan Stern Cc: Detlev Zundel CC: Dong Aisheng CC: Fabio Estevam Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: Linux ARM kernel Cc: linux-i2c@vger.kernel.org CC: Sascha Hauer CC: Shawn Guo Cc: Stefano Babic CC: Uwe Kleine-König Cc: Wolfgang Denk Cc: Wolfram Sang --- drivers/usb/chipidea/Makefile | 4 + drivers/usb/chipidea/ci13xxx_mxs.c | 201 ++++++++++++++++++++++++++++++++++++ 2 files changed, 205 insertions(+) create mode 100644 drivers/usb/chipidea/ci13xxx_mxs.c diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile index cc34937..266d57d 100644 --- a/drivers/usb/chipidea/Makefile +++ b/drivers/usb/chipidea/Makefile @@ -12,3 +12,7 @@ endif ifneq ($(CONFIG_ARCH_MSM),) obj-$(CONFIG_USB_CHIPIDEA) += ci13xxx_msm.o endif + +ifneq ($(CONFIG_ARCH_MXS),) + obj-$(CONFIG_USB_CHIPIDEA) += ci13xxx_mxs.o +endif diff --git a/drivers/usb/chipidea/ci13xxx_mxs.c b/drivers/usb/chipidea/ci13xxx_mxs.c new file mode 100644 index 0000000..fcca90b --- /dev/null +++ b/drivers/usb/chipidea/ci13xxx_mxs.c @@ -0,0 +1,201 @@ +/* + * drivers/usb/chipidea/ci13xxx_mxs.c + * + * Freescale i.MX233/i.MX28 USB glue driver to CI13xxx core. + * + * Copyright (C) 2012 Marek Vasut + * on behalf of DENX Software Engineering GmbH + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "ci.h" + +static void ci13xxx_mxs_notify(struct ci13xxx *ci, unsigned event) +{ + uint32_t status; + struct usb_phy *phy; + struct mxs_ci13xxx_phy_notify notify; + + phy = usb_get_transceiver(); + if (!phy) + return; + + if (event != CI13XXX_CONTROLLER_HOST_IRQ_EVENT) + return; + + status = hw_read(ci, OP_USBSTS, ~0); + + notify.discon = status & STS_PCD; + + usb_phy_notify(phy, ¬ify); +} + +static struct ci13xxx_udc_driver ci13xxx_mxs_udc_driver = { + .name = "ci13xxx_mxs", + .flags = /*CI13XXX_REGS_SHARED |*/ + CI13XXX_REQUIRE_TRANSCEIVER | + CI13XXX_PULLUP_ON_VBUS | + CI13XXX_DISABLE_STREAMING, + .capoffset = 0x100, + .notify_event = ci13xxx_mxs_notify, +}; + +struct ci13xxx_mxs_data { + struct clk *clk; + struct platform_device *pdev; +}; + +static int __devinit ci13xxx_mxs_probe(struct platform_device *pdev) +{ + struct ci13xxx_mxs_data *data; + int ret; + struct usb_phy *phy; + + phy = usb_get_transceiver(); + if (!phy) + return -EPROBE_DEFER; + + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + if (!data) { + dev_err(&pdev->dev, "Failed to allocate CI13xxx-MXS data!\n"); + return -ENOMEM; + } + + ret = usb_phy_init(phy); + if (ret) { + dev_err(&pdev->dev, "Failed to initialize PHY!\n"); + return -EINVAL; + } + + data->pdev = platform_device_alloc("ci_hdrc", -1); + if (!data->pdev) { + dev_err(&pdev->dev, + "Failed to allocate ci_hdrc platform device!\n"); + ret = -ENOMEM; + goto put_phy; + } + + /* Add DMA mask */ + data->pdev->dev.dma_mask = devm_kzalloc(&pdev->dev, + sizeof(*data->pdev->dev.dma_mask), + GFP_KERNEL); + if (!data->pdev->dev.dma_mask) { + ret = -ENOMEM; + goto put_platform; + } + + *data->pdev->dev.dma_mask = DMA_BIT_MASK(32); + data->pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); + + ret = platform_device_add_resources(data->pdev, pdev->resource, + pdev->num_resources); + if (ret) { + dev_err(&pdev->dev, + "Failed to add resources to platform device!\n"); + goto put_platform; + } + + ret = platform_device_add_data(data->pdev, &ci13xxx_mxs_udc_driver, + sizeof(ci13xxx_mxs_udc_driver)); + if (ret) { + dev_err(&pdev->dev, + "Failed to add platform data to platform device!\n"); + goto put_platform; + } + + /* Claim the Host clock. */ + data->clk = clk_get(&pdev->dev, "usb"); + if (IS_ERR(data->clk)) { + dev_err(&pdev->dev, "Failed to claim clock for USB Host\n"); + ret = PTR_ERR(data->clk); + goto put_platform; + } + + /* Prepare Host clock. */ + ret = clk_prepare_enable(data->clk); + if (ret) { + dev_err(&pdev->dev, "Failed to enable clock for USB Host.\n"); + goto put_clk; + } + + ret = platform_device_add(data->pdev); + if (ret) + goto put_clk; + + dev_set_drvdata(&pdev->dev, data); + + pm_runtime_no_callbacks(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + return 0; + +put_clk: + clk_put(data->clk); +put_platform: + platform_device_put(data->pdev); +put_phy: + usb_phy_shutdown(phy); + return ret; +} + +static int __devexit ci13xxx_mxs_remove(struct platform_device *pdev) +{ + struct ci13xxx_mxs_data *data = dev_get_drvdata(&pdev->dev); + struct usb_phy *phy = usb_get_transceiver(); + + clk_disable_unprepare(data->clk); + clk_put(data->clk); + + if (phy) + usb_phy_shutdown(phy); + + platform_device_del(data->pdev); + platform_device_put(data->pdev); + + return 0; +} + +static struct platform_driver ci13xxx_mxs_driver = { + .probe = ci13xxx_mxs_probe, + .remove = __devexit_p(ci13xxx_mxs_remove), + .driver = { + .name = "mxs-usb", + .owner = THIS_MODULE, + }, +}; + +module_platform_driver(ci13xxx_mxs_driver); + +MODULE_ALIAS("platform:mxs-usb"); +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("CI13xxx MXS USB binding"); +MODULE_AUTHOR("Marek Vasut ");