From patchwork Wed Oct 7 17:53:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Subbrathnam, Swaminathan" X-Patchwork-Id: 52306 Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n97HNgQI009861 for ; Wed, 7 Oct 2009 17:23:42 GMT Received: from dlep34.itg.ti.com ([157.170.170.115]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id n97HLYNO028870 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 7 Oct 2009 12:21:34 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep34.itg.ti.com (8.13.7/8.13.7) with ESMTP id n97HLVTj029878; Wed, 7 Oct 2009 12:21:32 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id A834C80635; Wed, 7 Oct 2009 12:21:07 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dbdp31.itg.ti.com (dbdp31.itg.ti.com [172.24.170.98]) by linux.omap.com (Postfix) with ESMTP id 84A6B80628 for ; Wed, 7 Oct 2009 12:20:39 -0500 (CDT) Received: from localhost.localdomain (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id n97HKatn009706; Wed, 7 Oct 2009 22:50:38 +0530 (IST) From: Swaminathan S To: davinci-linux-open-source@linux.davincidsp.com Date: Wed, 7 Oct 2009 23:23:07 +0530 Message-Id: <1254937992-2291-3-git-send-email-swami.iyer@ti.com> X-Mailer: git-send-email 1.6.0.rc1.64.g61192 In-Reply-To: <1254937992-2291-1-git-send-email-swami.iyer@ti.com> References: <1254937992-2291-1-git-send-email-swami.iyer@ti.com> Cc: linux-usb@vger.kernel.org Subject: [PATCH 2/7] Subscribes for USB resources for TI DM644x EVM platform. X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.4 Precedence: list List-Id: davinci-linux-open-source.linux.davincidsp.com List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c index 1213a00..bafae44 100644 --- a/arch/arm/mach-davinci/board-dm644x-evm.c +++ b/arch/arm/mach-davinci/board-dm644x-evm.c @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -63,6 +64,8 @@ #define LXT971_PHY_ID (0x001378e2) #define LXT971_PHY_MASK (0xfffffff0) +static int dm644x_evm_set_vbus(struct device *dev, int is_on); + static struct mtd_partition davinci_evm_norflash_partitions[] = { /* bootloader (UBL, U-Boot, etc) in first 5 sectors */ { @@ -477,7 +480,6 @@ evm_u35_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c) /* irlml6401 switches over 1A, in under 8 msec; * now it can be managed by nDRV_VBUS ... */ - setup_usb(500, 8); return 0; } @@ -699,6 +701,21 @@ static int davinci_phy_fixup(struct phy_device *phydev) #define HAS_NAND 0 #endif +static struct musb_hdrc_platform_data usb_evm_data[] = { + { +#if defined(CONFIG_USB_MUSB_OTG) + .mode = MUSB_OTG, +#elif defined(CONFIG_USB_MUSB_PERIPHERAL) + .mode = MUSB_PERIPHERAL, +#elif defined(CONFIG_USB_MUSB_HOST) + .mode = MUSB_HOST, +#endif + .power = 255, + .potpgt = 8, + .set_vbus = dm644x_evm_set_vbus, + } +}; + static __init void davinci_evm_init(void) { struct clk *aemif_clk; @@ -747,6 +764,7 @@ static __init void davinci_evm_init(void) phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK, davinci_phy_fixup); + dm644x_usb_configure(usb_evm_data, ARRAY_SIZE(usb_evm_data)); } static __init void davinci_evm_irq_init(void) @@ -754,6 +772,32 @@ static __init void davinci_evm_irq_init(void) davinci_irq_init(); } +#define GPIO_nVBUS_DRV (DAVINCI_N_GPIO + 16) /* USB VBUS line */ +static int vbus_state = -1; +static void evm_deferred_drvvbus(struct work_struct *ignored) +{ + gpio_set_value_cansleep(GPIO_nVBUS_DRV, vbus_state); + vbus_state = !vbus_state; +} + +/* + * DM644x EVM USB VBUS handler. On TI DM644x EVM USB VBUS is controller + * through I2C expander (0x3A) lines. Tthis function schedules a + * work thread to handle the actual VBUS on/off operations. + */ +static int dm644x_evm_set_vbus(struct device *dev, int is_on) +{ + static DECLARE_WORK(evm_vbus_work, evm_deferred_drvvbus); + + is_on = is_on ? 1 : 0; + if (vbus_state == is_on) + return 0; + + vbus_state = !is_on; + schedule_work(&evm_vbus_work); + return 0; +} + MACHINE_START(DAVINCI_EVM, "DaVinci DM644x EVM") /* Maintainer: MontaVista Software */ .phys_io = IO_PHYS, diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c index d6e0fa5..8e1559b 100644 --- a/arch/arm/mach-davinci/dm644x.c +++ b/arch/arm/mach-davinci/dm644x.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include "clock.h" #include "mux.h" @@ -761,6 +763,74 @@ void __init dm644x_init(void) davinci_common_init(&davinci_soc_info_dm644x); } +/* + * Configure the USB PHY for DM644x platforms. + */ +static int dm644x_usb_phy_config(struct device *dev, u8 mode, int is_on) +{ + u32 phy_ctrl = __raw_readl(USB_PHY_CTRL); + + if (is_on) { + /* power everything up; start the on-chip PHY and its PLL */ + phy_ctrl &= ~(USBPHY_OSCPDWN | USBPHY_OTGPDWN | USBPHY_PHYPDWN); + phy_ctrl |= USBPHY_SESNDEN | USBPHY_VBDTCTEN | USBPHY_PHYPLLON; + } else { + /* powerdown the on-chip PHY, its PLL, and the OTG block */ + phy_ctrl &= ~(USBPHY_SESNDEN | USBPHY_VBDTCTEN | + USBPHY_PHYPLLON); + phy_ctrl |= USBPHY_OSCPDWN | USBPHY_OTGPDWN | USBPHY_PHYPDWN; + } + + __raw_writel(phy_ctrl, USB_PHY_CTRL); + + if (is_on) { + /* wait for PLL to lock before proceeding */ + while ((__raw_readl(USB_PHY_CTRL) & USBPHY_PHYCLKGD) == 0) + cpu_relax(); + } + + return 0; +} + +static struct resource usb_resources[] = { + { + .start = DAVINCI_USB_OTG_BASE, + .end = DAVINCI_USB_OTG_BASE + 0x5ff, + .flags = IORESOURCE_MEM, + }, + { + .start = IRQ_USBINT, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct plat_res_data dm644x_usb_res; +static struct usb_plat_data dm644x_usb_plat_data; + +/* + * Initialize DM644x related USB information such as Memory maps, IRQ etc. + * Since DM644x supprot a single MUSB controller initialize the instance + * value to 1. + */ +void dm644x_usb_configure(struct musb_hdrc_platform_data *pdata, u8 num_inst) +{ + pdata->phy_config = dm644x_usb_phy_config; + + dm644x_usb_res.plat_data = pdata; + dm644x_usb_res.res_data = usb_resources; + dm644x_usb_res.num_res = ARRAY_SIZE(usb_resources); + + dm644x_usb_plat_data.prdata = &dm644x_usb_res; + dm644x_usb_plat_data.num_inst = num_inst; + + /* Call the generic platform register function. The USB + * configuration w.r.t no. of ep's, capabalities etc. are common + * across DaVinci platforms and hence allow the generic handler + * to populate the information. + */ + setup_usb(&dm644x_usb_plat_data); +} + static int __init dm644x_init_devices(void) { if (!cpu_is_davinci_dm644x()) diff --git a/arch/arm/mach-davinci/include/mach/dm644x.h b/arch/arm/mach-davinci/include/mach/dm644x.h index 0efb738..1f6f3fa 100644 --- a/arch/arm/mach-davinci/include/mach/dm644x.h +++ b/arch/arm/mach-davinci/include/mach/dm644x.h @@ -27,6 +27,7 @@ #include #include #include +#include #define DM644X_EMAC_BASE (0x01C80000) #define DM644X_EMAC_CNTRL_OFFSET (0x0000) @@ -38,5 +39,7 @@ void __init dm644x_init(void); void __init dm644x_init_asp(struct snd_platform_data *pdata); void dm644x_set_vpfe_config(struct vpfe_config *cfg); +extern void dm644x_usb_configure(struct musb_hdrc_platform_data *pdata, + u8 num_inst); #endif /* __ASM_ARCH_DM644X_H */ diff --git a/arch/arm/mach-davinci/include/mach/usb_davinci.h b/arch/arm/mach-davinci/include/mach/usb_davinci.h new file mode 100644 index 0000000..02f8af7 --- /dev/null +++ b/arch/arm/mach-davinci/include/mach/usb_davinci.h @@ -0,0 +1,41 @@ +/* + * This file contains the processor specific USB definitions + * of the TI DaVinci platforms. + * + * Copyright (C) 2009 Texas Instruments. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#ifndef USB_DAVINCI_H_ +#define USB_DAVINCI_H_ +#include +#include + +/* Integrated highspeed/otg PHY */ +#define USBPHY_CTL_PADDR (DAVINCI_SYSTEM_MODULE_BASE + 0x34) +#define USB_PHY_CTRL IO_ADDRESS(USBPHY_CTL_PADDR) + +#define USBPHY_PHYCLKGD BIT(8) +#define USBPHY_SESNDEN BIT(7) /* v(sess_end) comparator */ +#define USBPHY_VBDTCTEN BIT(6) /* v(bus) comparator */ +#define USBPHY_VBUSSENS BIT(5) /* (dm355,ro) is vbus > 0.5V */ +#define USBPHY_PHYPLLON BIT(4) /* override pll suspend */ +#define USBPHY_CLKO1SEL BIT(3) +#define USBPHY_OSCPDWN BIT(2) +#define USBPHY_OTGPDWN BIT(1) +#define USBPHY_PHYPDWN BIT(0) + +#endif