diff options
author | Seshendra Gadagottu <sgadagottu@nvidia.com> | 2011-07-13 09:29:58 +0530 |
---|---|---|
committer | Varun Colbert <vcolbert@nvidia.com> | 2011-07-25 18:44:17 -0700 |
commit | 6572dacaabbb78dd3356ccd595990595aa9a3ca2 (patch) | |
tree | 2dc1c8e9bb2eedb6772e8101c26be145e007256c | |
parent | d580981423e8c40218badcc1ba9a11c32ad96dec (diff) |
arm: tegra: usb_phy: Separating ulpi and uhsic phy configuration
Avoided mixing of ulpi and uhsic configuration in usb_phy code.
Added postsuspend function for uhsic.
BUG 793840
Change-Id: If24fe1d9f13db53bfe51a7f9a2728bd042ea1912
Reviewed-on: http://git-master/r/40771
Tested-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: Scott Williams <scwilliams@nvidia.com>
-rw-r--r-- | arch/arm/mach-tegra/include/mach/usb_phy.h | 5 | ||||
-rw-r--r-- | arch/arm/mach-tegra/usb_phy.c | 73 |
2 files changed, 48 insertions, 30 deletions
diff --git a/arch/arm/mach-tegra/include/mach/usb_phy.h b/arch/arm/mach-tegra/include/mach/usb_phy.h index 0672b049dbfa..30160d63cc41 100644 --- a/arch/arm/mach-tegra/include/mach/usb_phy.h +++ b/arch/arm/mach-tegra/include/mach/usb_phy.h @@ -50,11 +50,14 @@ struct tegra_ulpi_config { }; struct tegra_uhsic_config { + int enable_gpio; + int reset_gpio; u8 sync_start_delay; u8 idle_wait_delay; u8 term_range_adj; u8 elastic_underrun_limit; u8 elastic_overrun_limit; + int (*postsuspend)(void); }; enum tegra_usb_phy_port_speed { @@ -109,6 +112,8 @@ void tegra_usb_phy_clk_enable(struct tegra_usb_phy *phy); void tegra_usb_phy_power_off(struct tegra_usb_phy *phy, bool is_dpd); +void tegra_usb_phy_postsuspend(struct tegra_usb_phy *phy, bool is_dpd); + void tegra_usb_phy_preresume(struct tegra_usb_phy *phy, bool is_dpd); void tegra_usb_phy_postresume(struct tegra_usb_phy *phy, bool is_dpd); diff --git a/arch/arm/mach-tegra/usb_phy.c b/arch/arm/mach-tegra/usb_phy.c index 8c9f9fafeeb3..8ba86e6154f4 100644 --- a/arch/arm/mach-tegra/usb_phy.c +++ b/arch/arm/mach-tegra/usb_phy.c @@ -510,14 +510,6 @@ static struct tegra_utmip_config utmip_default[] = { }, }; -static struct tegra_uhsic_config uhsic_default = { - .sync_start_delay = 9, - .idle_wait_delay = 17, - .term_range_adj = 0, - .elastic_underrun_limit = 16, - .elastic_overrun_limit = 16, -}; - struct usb_phy_plat_data usb_phy_data[] = { { 0, 0, -1, NULL}, { 0, 0, -1, NULL}, @@ -977,6 +969,16 @@ static int utmi_phy_postresume(struct tegra_usb_phy *phy, bool is_dpd) return 0; } +static int uhsic_phy_postsuspend(struct tegra_usb_phy *phy, bool is_dpd) +{ + struct tegra_uhsic_config *uhsic_config = phy->config; + + if (uhsic_config->postsuspend) + uhsic_config->postsuspend(); + + return 0; +} + static int uhsic_phy_postresume(struct tegra_usb_phy *phy, bool is_dpd) { #ifdef CONFIG_ARCH_TEGRA_2x_SOC @@ -1412,11 +1414,7 @@ static int uhsic_phy_power_on(struct tegra_usb_phy *phy, bool is_dpd) { unsigned long val; void __iomem *base = phy->regs; - struct tegra_uhsic_config *config = &uhsic_default; - struct tegra_ulpi_config *ulpi_config = phy->config; - - if (ulpi_config->preinit) - ulpi_config->preinit(); + struct tegra_uhsic_config *uhsic_config = phy->config; val = readl(base + UHSIC_PADS_CFG1); val &= ~(UHSIC_PD_BG | UHSIC_PD_TX | UHSIC_PD_TRK | UHSIC_PD_RX | @@ -1435,13 +1433,13 @@ static int uhsic_phy_power_on(struct tegra_usb_phy *phy, bool is_dpd) writel(val, base + USB_SUSP_CTRL); val = readl(base + UHSIC_HSRX_CFG0); - val |= UHSIC_IDLE_WAIT(config->idle_wait_delay); - val |= UHSIC_ELASTIC_UNDERRUN_LIMIT(config->elastic_underrun_limit); - val |= UHSIC_ELASTIC_OVERRUN_LIMIT(config->elastic_overrun_limit); + val |= UHSIC_IDLE_WAIT(uhsic_config->idle_wait_delay); + val |= UHSIC_ELASTIC_UNDERRUN_LIMIT(uhsic_config->elastic_underrun_limit); + val |= UHSIC_ELASTIC_OVERRUN_LIMIT(uhsic_config->elastic_overrun_limit); writel(val, base + UHSIC_HSRX_CFG0); val = readl(base + UHSIC_HSRX_CFG1); - val |= UHSIC_HS_SYNC_START_DLY(config->sync_start_delay); + val |= UHSIC_HS_SYNC_START_DLY(uhsic_config->sync_start_delay); writel(val, base + UHSIC_HSRX_CFG1); val = readl(base + UHSIC_MISC_CFG0); @@ -1546,6 +1544,7 @@ struct tegra_usb_phy *tegra_usb_phy_open(int instance, void __iomem *regs, { struct tegra_usb_phy *phy; struct tegra_ulpi_config *ulpi_config; + struct tegra_ulpi_config *uhsic_config; unsigned long parent_rate; int i; int err; @@ -1629,29 +1628,29 @@ struct tegra_usb_phy *tegra_usb_phy_open(int instance, void __iomem *regs, } #ifndef CONFIG_ARCH_TEGRA_2x_SOC else if (phy->usb_phy_type == TEGRA_USB_PHY_TYPE_HSIC) { - ulpi_config = config; - gpio_request(ulpi_config->enable_gpio, + uhsic_config = config; + gpio_request(uhsic_config->enable_gpio, "uhsic_enable"); - if (ulpi_config->reset_gpio != -1) - gpio_request(ulpi_config->reset_gpio, + if (uhsic_config->reset_gpio != -1) + gpio_request(uhsic_config->reset_gpio, "uhsic_reset"); /* hsic enable signal deasserted, hsic reset asserted */ - gpio_direction_output(ulpi_config->enable_gpio, + gpio_direction_output(uhsic_config->enable_gpio, 0 /* deasserted */); - if (ulpi_config->reset_gpio != -1) - gpio_direction_output(ulpi_config->reset_gpio, + if (uhsic_config->reset_gpio != -1) + gpio_direction_output(uhsic_config->reset_gpio, 0 /* asserted */); - tegra_gpio_enable(ulpi_config->enable_gpio); - if (ulpi_config->reset_gpio != -1) - tegra_gpio_enable(ulpi_config->reset_gpio); + tegra_gpio_enable(uhsic_config->enable_gpio); + if (uhsic_config->reset_gpio != -1) + tegra_gpio_enable(uhsic_config->reset_gpio); /* keep hsic reset asserted for 1 ms */ udelay(1000); /* enable (power on) hsic */ - gpio_set_value_cansleep(ulpi_config->enable_gpio, 1); + gpio_set_value_cansleep(uhsic_config->enable_gpio, 1); udelay(1000); /* deassert reset */ - if (ulpi_config->reset_gpio != -1) - gpio_set_value_cansleep(ulpi_config->reset_gpio, 1); + if (uhsic_config->reset_gpio != -1) + gpio_set_value_cansleep(uhsic_config->reset_gpio, 1); } #endif @@ -1765,6 +1764,20 @@ void tegra_usb_phy_preresume(struct tegra_usb_phy *phy, bool is_dpd) preresume[phy->usb_phy_type](phy, is_dpd); } +void tegra_usb_phy_postsuspend(struct tegra_usb_phy *phy, bool is_dpd) + +{ + const tegra_phy_fp postsuspend[] = { + NULL, + NULL, + NULL, + uhsic_phy_postsuspend, + }; + + if (postsuspend[phy->usb_phy_type]) + postsuspend[phy->usb_phy_type](phy, is_dpd); +} + void tegra_usb_phy_postresume(struct tegra_usb_phy *phy, bool is_dpd) { const tegra_phy_fp postresume[] = { |