From patchwork Tue Aug 2 08:39:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lin X-Patchwork-Id: 107856 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 79FDDB71C6 for ; Tue, 2 Aug 2011 18:33:57 +1000 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QoAPv-0002l6-TI; Tue, 02 Aug 2011 08:33:37 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QoAPu-00081o-E3; Tue, 02 Aug 2011 08:33:34 +0000 Received: from db3ehsobe003.messaging.microsoft.com ([213.199.154.141] helo=DB3EHSOBE003.bigfish.com) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QoAPA-0007pY-5Q for linux-arm-kernel@lists.infradead.org; Tue, 02 Aug 2011 08:32:50 +0000 Received: from mail89-db3-R.bigfish.com (10.3.81.254) by DB3EHSOBE003.bigfish.com (10.3.84.23) with Microsoft SMTP Server id 14.1.225.22; Tue, 2 Aug 2011 08:32:46 +0000 Received: from mail89-db3 (localhost.localdomain [127.0.0.1]) by mail89-db3-R.bigfish.com (Postfix) with ESMTP id B049A3E02B3; Tue, 2 Aug 2011 08:32:46 +0000 (UTC) X-SpamScore: 3 X-BigFish: VS3(zzc8kzz1202hzz8275bhz2dh2a8h668h839h) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPVD:NLI; H:mail.freescale.net; RD:none; EFVD:NLI Received: from mail89-db3 (localhost.localdomain [127.0.0.1]) by mail89-db3 (MessageSwitch) id 1312273966336726_29576; Tue, 2 Aug 2011 08:32:46 +0000 (UTC) Received: from DB3EHSMHS001.bigfish.com (unknown [10.3.81.249]) by mail89-db3.bigfish.com (Postfix) with ESMTP id 45364B9804F; Tue, 2 Aug 2011 08:32:46 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by DB3EHSMHS001.bigfish.com (10.3.87.101) with Microsoft SMTP Server (TLS) id 14.1.225.22; Tue, 2 Aug 2011 08:32:45 +0000 Received: from az33smr02.freescale.net (10.64.34.200) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server id 14.1.289.8; Tue, 2 Aug 2011 03:32:44 -0500 Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by az33smr02.freescale.net (8.13.1/8.13.0) with ESMTP id p728WUAX002387; Tue, 2 Aug 2011 03:32:42 -0500 (CDT) From: Tony Lin To: Subject: [PATCH v4 6/7] ARM: mxs: add usb platform operations Date: Tue, 2 Aug 2011 16:39:45 +0800 Message-ID: <1312274386-6833-7-git-send-email-tony.lin@freescale.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1312274386-6833-1-git-send-email-tony.lin@freescale.com> References: <1312274386-6833-1-git-send-email-tony.lin@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110802_043248_563908_38D33029 X-CRM114-Status: GOOD ( 24.50 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [213.199.154.141 listed in list.dnswl.org] Cc: s.hauer@pengutronix.de, stern@rowland.harvard.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 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 add usb phy register definitions and functions usb host driver will use these callback functions to initialize usb phy and change working mode Signed-off-by: Tony Lin --- arch/arm/mach-mxs/Kconfig | 1 + arch/arm/mach-mxs/devices-mx28.h | 4 + arch/arm/mach-mxs/devices/Kconfig | 3 + arch/arm/mach-mxs/devices/Makefile | 1 + arch/arm/mach-mxs/devices/platform-usb.c | 96 +++++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/hardware.h | 2 + arch/arm/mach-mxs/include/mach/mx23.h | 8 +- arch/arm/mach-mxs/include/mach/mxs.h | 12 +++- arch/arm/mach-mxs/mach-mx28evk.c | 11 +++ 9 files changed, 133 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig index 4cd0231..1b11e79 100644 --- a/arch/arm/mach-mxs/Kconfig +++ b/arch/arm/mach-mxs/Kconfig @@ -48,6 +48,7 @@ config MACH_MX28EVK select MXS_HAVE_PLATFORM_FLEXCAN select MXS_HAVE_PLATFORM_MXS_MMC select MXS_HAVE_PLATFORM_MXSFB + select MXS_HAVE_PLATFORM_USB select MXS_OCOTP help Include support for MX28EVK platform. This includes specific diff --git a/arch/arm/mach-mxs/devices-mx28.h b/arch/arm/mach-mxs/devices-mx28.h index 79b9452..b4dc758 100644 --- a/arch/arm/mach-mxs/devices-mx28.h +++ b/arch/arm/mach-mxs/devices-mx28.h @@ -43,5 +43,9 @@ extern const struct mxs_mxs_mmc_data mx28_mxs_mmc_data[] __initconst; #define mx28_add_mxs_pwm(id) mxs_add_mxs_pwm(MX28_PWM_BASE_ADDR, id) +extern const struct mxs_usbh_data mx28_mxs_usbh_data[] __initconst; +#define mx28_add_mxs_usbh(id, pdata) \ + mxs_add_mxs_usbh(&mx28_mxs_usbh_data[id], pdata) + struct platform_device *__init mx28_add_mxsfb( const struct mxsfb_platform_data *pdata); diff --git a/arch/arm/mach-mxs/devices/Kconfig b/arch/arm/mach-mxs/devices/Kconfig index acf9eea..8c0f6fa 100644 --- a/arch/arm/mach-mxs/devices/Kconfig +++ b/arch/arm/mach-mxs/devices/Kconfig @@ -23,3 +23,6 @@ config MXS_HAVE_PLATFORM_MXS_PWM config MXS_HAVE_PLATFORM_MXSFB bool + +config MXS_HAVE_PLATFORM_USB + bool diff --git a/arch/arm/mach-mxs/devices/Makefile b/arch/arm/mach-mxs/devices/Makefile index 351915c..a964bc9 100644 --- a/arch/arm/mach-mxs/devices/Makefile +++ b/arch/arm/mach-mxs/devices/Makefile @@ -8,3 +8,4 @@ obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_MMC) += platform-mxs-mmc.o obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_PWM) += platform-mxs-pwm.o obj-y += platform-gpio-mxs.o obj-$(CONFIG_MXS_HAVE_PLATFORM_MXSFB) += platform-mxsfb.o +obj-$(CONFIG_MXS_HAVE_PLATFORM_USB) += platform-usb.o diff --git a/arch/arm/mach-mxs/devices/platform-usb.c b/arch/arm/mach-mxs/devices/platform-usb.c new file mode 100644 index 0000000..b9119ff --- /dev/null +++ b/arch/arm/mach-mxs/devices/platform-usb.c @@ -0,0 +1,96 @@ +/* + * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License version 2 as published by the + * Free Software Foundation. + */ + +#include +#include +#include +#include + +#include +#include +#include + +#define mxs_usbh_data_entry_single(soc, _id, hwid) \ + { \ + .id = _id, \ + .iobase = soc ## _USBCTRL ## hwid ## _BASE_ADDR, \ + .phy_iobase = soc ## _USBPHY ## hwid ## _BASE_ADDR, \ + .irq = soc ## _INT_USB ## hwid, \ + } + +#define mxs_usbh_data_entry(soc, _id, hwid) \ + [_id] = mxs_usbh_data_entry_single(soc, _id, hwid) + +#ifdef CONFIG_SOC_IMX23 +const struct mxs_usbh_data mx23_mxs_usbh_data[] __initconst = { + mxs_usbh_data_entry(MX23, 0, 0), +}; +#endif + +#ifdef CONFIG_SOC_IMX28 +const struct mxs_usbh_data mx28_mxs_usbh_data[] __initconst = { + mxs_usbh_data_entry(MX28, 0, 0), + mxs_usbh_data_entry(MX28, 1, 1), +}; +#endif + +struct platform_device *__init mxs_add_mxs_usbh( + const struct mxs_usbh_data *data, + struct mxc_usbh_platform_data *pdata) +{ + struct mxs_usb_private_date *usbh_private; + struct platform_device *pdev; + struct resource res[] = { + { + .start = data->iobase, + .end = data->iobase + SZ_64K - 1, + .flags = IORESOURCE_MEM, + }, { + .start = data->irq, + .end = data->irq, + .flags = IORESOURCE_IRQ, + }, + }; + + usbh_private = kmalloc(sizeof(*usbh_private), GFP_KERNEL); + if (!usbh_private) + return NULL; + + usbh_private->phy_regs = ioremap(data->phy_iobase, SZ_8K); + usbh_private->ctrl_regs = ioremap(data->iobase, SZ_64K); + if (!usbh_private->phy_regs || !usbh_private->ctrl_regs) + goto out; + + if (data->id == 0) + usbh_private->usb_phy_clk = clk_get(NULL, "usb0_phy"); + else if (data->id == 1) + usbh_private->usb_phy_clk = clk_get(NULL, "usb1_phy"); + else + BUG(); + if (IS_ERR(usbh_private->usb_phy_clk)) + goto out; + + pdata->priv = usbh_private; + + pdev = mxs_add_platform_device_dmamask("mxc-ehci", data->id, + res, ARRAY_SIZE(res), pdata, + sizeof(*pdata), DMA_BIT_MASK(32)); + if (pdev) + return pdev; + +out: + if (usbh_private->usb_phy_clk) + clk_put(usbh_private->usb_phy_clk); + if (usbh_private->phy_regs) + iounmap(usbh_private->phy_regs); + if (usbh_private->ctrl_regs) + iounmap(usbh_private->ctrl_regs); + kfree(usbh_private); + + return NULL; +} diff --git a/arch/arm/mach-mxs/include/mach/hardware.h b/arch/arm/mach-mxs/include/mach/hardware.h index 53e89a0..affa72b 100644 --- a/arch/arm/mach-mxs/include/mach/hardware.h +++ b/arch/arm/mach-mxs/include/mach/hardware.h @@ -26,4 +26,6 @@ #define IOMEM(addr) ((void __force __iomem *)(addr)) #endif +#include "mxs.h" + #endif /* __MACH_MXS_HARDWARE_H__ */ diff --git a/arch/arm/mach-mxs/include/mach/mx23.h b/arch/arm/mach-mxs/include/mach/mx23.h index 599094b..7955b75 100644 --- a/arch/arm/mach-mxs/include/mach/mx23.h +++ b/arch/arm/mach-mxs/include/mach/mx23.h @@ -64,8 +64,8 @@ #define MX23_AUART1_BASE_ADDR (MX23_IO_BASE_ADDR + 0x06c000) #define MX23_AUART2_BASE_ADDR (MX23_IO_BASE_ADDR + 0x06e000) #define MX23_DUART_BASE_ADDR (MX23_IO_BASE_ADDR + 0x070000) -#define MX23_USBPHY_BASE_ADDR (MX23_IO_BASE_ADDR + 0x07c000) -#define MX23_USBCTRL_BASE_ADDR (MX23_IO_BASE_ADDR + 0x080000) +#define MX23_USBPHY0_BASE_ADDR (MX23_IO_BASE_ADDR + 0x07c000) +#define MX23_USBCTRL0_BASE_ADDR (MX23_IO_BASE_ADDR + 0x080000) #define MX23_DRAM_BASE_ADDR (MX23_IO_BASE_ADDR + 0x0e0000) #define MX23_IO_P2V(x) MXS_IO_P2V(x) @@ -89,8 +89,8 @@ #define MX23_INT_SPDIF_ERROR 10 #define MX23_INT_SAIF1_IRQ 10 #define MX23_INT_SAIF2_IRQ 10 -#define MX23_INT_USB_CTRL 11 -#define MX23_INT_USB_WAKEUP 12 +#define MX23_INT_USB0 11 +#define MX23_INT_USB0_WAKEUP 12 #define MX23_INT_GPMI_DMA 13 #define MX23_INT_SSP1_DMA 14 #define MX23_INT_SSP1_ERROR 15 diff --git a/arch/arm/mach-mxs/include/mach/mxs.h b/arch/arm/mach-mxs/include/mach/mxs.h index 35a89dd..0661e90 100644 --- a/arch/arm/mach-mxs/include/mach/mxs.h +++ b/arch/arm/mach-mxs/include/mach/mxs.h @@ -35,7 +35,17 @@ machine_is_mx28evk() || \ machine_is_tx28() || \ 0) - +#define cpu_is_mx1() 0 +#define cpu_is_mx21() 0 +#define cpu_is_mx25() 0 +#define cpu_is_mx27() 0 +#define cpu_is_mx31() 0 +#define cpu_is_mx35() 0 +#define cpu_is_mx50() 0 +#define cpu_is_mx51() 0 +#define cpu_is_mx53() 0 +#define cpu_is_mx3() (cpu_is_mx31() || cpu_is_mx35()) +#define cpu_is_mx2() (cpu_is_mx21() || cpu_is_mx27()) /* * IO addresses common to MXS-based */ diff --git a/arch/arm/mach-mxs/mach-mx28evk.c b/arch/arm/mach-mxs/mach-mx28evk.c index 680d6e4..29c2f29 100644 --- a/arch/arm/mach-mxs/mach-mx28evk.c +++ b/arch/arm/mach-mxs/mach-mx28evk.c @@ -27,6 +27,7 @@ #include #include "devices-mx28.h" +#include "usbh.h" #define MX28EVK_FLEXCAN_SWITCH MXS_GPIO_NR(2, 13) #define MX28EVK_FEC_PHY_POWER MXS_GPIO_NR(2, 15) @@ -355,6 +356,14 @@ static struct mxs_mmc_platform_data mx28evk_mmc_pdata[] __initdata = { }, }; +static struct mxc_usbh_platform_data usbh_pdata __initdata = { + .init = fsl_usb_host_init, + .exit = fsl_usb_host_uninit, + .portsc = MXC_EHCI_MODE_ULPI, + .otg = NULL, + .plt_irq_handler = fsl_plt_usbh_irq_handler, +}; + static void __init mx28evk_init(void) { int ret; @@ -412,6 +421,8 @@ static void __init mx28evk_init(void) "usb1-power-en"); if (ret) pr_warn("failed to request gpio usb1-power-en %d\n", ret); + mx28_add_mxs_usbh(1, &usbh_pdata); + gpio_led_register_device(0, &mx28evk_led_data); }