diff options
Diffstat (limited to 'drivers/usb/musb-new/sunxi.c')
-rw-r--r-- | drivers/usb/musb-new/sunxi.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c index c9a6a16..e8a3a23 100644 --- a/drivers/usb/musb-new/sunxi.c +++ b/drivers/usb/musb-new/sunxi.c @@ -22,8 +22,9 @@ */ #include <common.h> #include <asm/arch/cpu.h> +#include <asm/arch/clock.h> #include <asm/arch/gpio.h> -#include <asm/arch/usbc.h> +#include <asm/arch/usb_phy.h> #include <asm-generic/gpio.h> #include "linux-compat.h" #include "musb_core.h" @@ -213,43 +214,57 @@ static void sunxi_musb_enable(struct musb *musb) if (is_host_enabled(musb)) { /* port power on */ - sunxi_usbc_vbus_enable(0); + sunxi_usb_phy_power_on(0); } } static void sunxi_musb_disable(struct musb *musb) { + struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; + pr_debug("%s():\n", __func__); /* Put the controller back in a pristane state for "usb reset" */ if (musb->is_active) { - sunxi_usbc_disable(0); - sunxi_usbc_enable(0); + sunxi_usb_phy_exit(0); +#ifdef CONFIG_SUNXI_GEN_SUN6I + clrbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_GATE_OFFSET_USB0); +#endif + clrbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_USB0); + + mdelay(10); + + setbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_USB0); +#ifdef CONFIG_SUNXI_GEN_SUN6I + setbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_GATE_OFFSET_USB0); +#endif + sunxi_usb_phy_init(0); musb->is_active = 0; } } static int sunxi_musb_init(struct musb *musb) { + struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; int err; pr_debug("%s():\n", __func__); - err = sunxi_usbc_request_resources(0); - if (err) - return err; - if (is_host_enabled(musb)) { - err = sunxi_usbc_vbus_detect(0); + err = sunxi_usb_phy_vbus_detect(0); if (err) { eprintf("Error: A charger is plugged into the OTG\n"); - sunxi_usbc_free_resources(0); return -EIO; } } musb->isr = sunxi_musb_interrupt; - sunxi_usbc_enable(0); + + setbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_USB0); +#ifdef CONFIG_SUNXI_GEN_SUN6I + setbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_GATE_OFFSET_USB0); +#endif + sunxi_usb_phy_init(0); USBC_ConfigFIFO_Base(); USBC_EnableDpDmPullUp(musb->mregs); @@ -273,10 +288,10 @@ static int sunxi_musb_exit(struct musb *musb) USBC_DisableDpDmPullUp(musb->mregs); USBC_DisableIdPullUp(musb->mregs); - sunxi_usbc_vbus_disable(0); - sunxi_usbc_disable(0); + sunxi_usb_phy_power_off(0); + sunxi_usb_phy_exit(0); - return sunxi_usbc_free_resources(0); + return 0; } const struct musb_platform_ops sunxi_musb_ops = { |