From patchwork Thu Oct 15 15:46:15 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Subbrathnam, Swaminathan" X-Patchwork-Id: 54047 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 n9FFFBZE007142 for ; Thu, 15 Oct 2009 15:15:11 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id n9FFBvPq003938 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 15 Oct 2009 10:11:57 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id n9FFBuYE008446; Thu, 15 Oct 2009 10:11:56 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 3AF2380630; Thu, 15 Oct 2009 10:11:55 -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 84F9A80628 for ; Thu, 15 Oct 2009 10:11:49 -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 n9FFBkwG012115; Thu, 15 Oct 2009 20:41:48 +0530 (IST) From: Swaminathan S To: davinci-linux-open-source@linux.davincidsp.com Date: Thu, 15 Oct 2009 21:16:15 +0530 Message-Id: <1255621580-24379-3-git-send-email-swami.iyer@ti.com> X-Mailer: git-send-email 1.6.0.rc1.64.g61192 In-Reply-To: <1255621580-24379-1-git-send-email-swami.iyer@ti.com> References: <1255621580-24379-1-git-send-email-swami.iyer@ti.com> Cc: linux-usb@vger.kernel.org Subject: [PATCH Ver 1.0 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..08feb99 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.h b/arch/arm/mach-davinci/include/mach/usb.h index 435f228..96a60b1 100644 --- a/arch/arm/mach-davinci/include/mach/usb.h +++ b/arch/arm/mach-davinci/include/mach/usb.h @@ -10,6 +10,8 @@ #ifndef __ASM_ARCH_USB_H #define __ASM_ARCH_USB_H +#include +#include /* DA8xx CFGCHIP2 (USB 2.0 PHY Control) register bits */ #define CFGCHIP2_PHYCLKGD (1 << 17) @@ -34,6 +36,20 @@ #define CFGCHIP2_REFFREQ_24MHZ (2 << 0) #define CFGCHIP2_REFFREQ_48MHZ (3 << 0) +/* DMxxxx USB PHY definitions */ +#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) + struct da8xx_ohci_root_hub; typedef void (*da8xx_ocic_handler_t)(struct da8xx_ohci_root_hub *hub,