Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport USB EHCI/OHCI code from BSP 3.0 #56

Open
wants to merge 1 commit into
base: pine64-hacks-1.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion drivers/power/axp_power/axp-chg.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ s32 axp_usb_det(void)
}
EXPORT_SYMBOL_GPL(axp_usb_det);

s32 axp_usb_vbus_output(int high)
{
return 0;
}
EXPORT_SYMBOL_GPL(axp_usb_vbus_output);

static void axp_usb_ac_check_status(struct axp_charger *charger)
{
if (!axp_config->pmu_init_bc_en) {
Expand Down Expand Up @@ -278,4 +284,3 @@ void axp_chg_exit(struct axp_charger *charger)
}
return;
}

1 change: 1 addition & 0 deletions drivers/power/axp_power/axp-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
s32 axp_usbcur(aw_charge_type type){ return 0; };
s32 axp_usbvol(aw_charge_type type){ return 0; };
s32 axp_usb_det(void){ return 0; };
s32 axp_usb_vbus_output(int high){ return 0; };
s32 axp_powerkey_get(void){ return 0; };
void axp_powerkey_set(int value){};
u64 axp_read_power_sply(void){ return 0; };
Expand Down
40 changes: 30 additions & 10 deletions drivers/usb/host/ehci_sunxi.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,30 @@ static struct scene_lock ehci_standby_lock[4];
#define SUNXI_EHCI_NAME "sunxi-ehci"
static const char ehci_name[] = SUNXI_EHCI_NAME;

#ifdef CONFIG_USB_SUNXI_EHCI0
#ifdef CONFIG_USB_SUNXI_EHCI0
#define SUNXI_EHCI0_OF_MATCH "allwinner,sunxi-ehci0"
#else
#define SUNXI_EHCI0_OF_MATCH "null"
#endif

#ifdef CONFIG_USB_SUNXI_EHCI1
#ifdef CONFIG_USB_SUNXI_EHCI1
#define SUNXI_EHCI1_OF_MATCH "allwinner,sunxi-ehci1"
#else
#define SUNXI_EHCI1_OF_MATCH "null"
#endif

#ifdef CONFIG_USB_SUNXI_EHCI2
#define SUNXI_EHCI2_OF_MATCH "allwinner,sunxi-ehci2"
#else
#define SUNXI_EHCI2_OF_MATCH "null"
#endif

#ifdef CONFIG_USB_SUNXI_EHCI3
#define SUNXI_EHCI3_OF_MATCH "allwinner,sunxi-ehci3"
#else
#define SUNXI_EHCI3_OF_MATCH "null"
#endif

static struct sunxi_hci_hcd *g_sunxi_ehci[4];
static u32 ehci_first_probe[4] = {1, 1, 1, 1};
static u32 ehci_enable[4] = {1, 1, 1, 1};
Expand Down Expand Up @@ -641,7 +653,7 @@ static int sunxi_ehci_hcd_probe(struct platform_device *pdev)
ret = init_sunxi_hci(pdev, SUNXI_USB_EHCI);
if(ret != 0){
dev_err(&pdev->dev, "init_sunxi_hci is fail\n");
return 0;
return -1;
}

sunxi_insmod_ehci(pdev);
Expand Down Expand Up @@ -699,21 +711,26 @@ static void sunxi_ehci_hcd_shutdown(struct platform_device* pdev)
}

if(sunxi_ehci->probe == 0){
DMSG_PANIC("ERR: %s, %s is disable, need not shutdown\n", __func__, sunxi_ehci->hci_name);
DMSG_INFO("%s, %s is disable, need not shutdown\n", __func__, sunxi_ehci->hci_name);
return;
}

DMSG_INFO("[%s]: ehci shutdown start\n", sunxi_ehci->hci_name);
pr_debug("[%s]: ehci shutdown start\n", sunxi_ehci->hci_name);
#ifdef CONFIG_PM
if(sunxi_ehci->wakeup_suspend){
scene_lock_destroy(&ehci_standby_lock[sunxi_ehci->usbc_no]);
}
#endif
usb_hcd_platform_shutdown(pdev);

sunxi_stop_ehci(sunxi_ehci);
/* disable usb otg INTUSBE, To solve usb0 device mode catch audio udev on reboot system is fail*/
if (sunxi_ehci->usbc_no == 0)
if (sunxi_ehci->otg_vbase) {
writel(0, (sunxi_ehci->otg_vbase
+ SUNXI_USBC_REG_INTUSBE));
}

DMSG_INFO("[%s]: ehci shutdown end\n", sunxi_ehci->hci_name);
pr_debug("[%s]: ehci shutdown end\n", sunxi_ehci->hci_name);

return ;
}
Expand Down Expand Up @@ -745,7 +762,8 @@ static int sunxi_ehci_hcd_suspend(struct device *dev)
}

if(sunxi_ehci->probe == 0){
DMSG_PANIC("[%s]: is disable, can not suspend\n", sunxi_ehci->hci_name);
DMSG_INFO("[%s]: is disable, can not suspend\n",
sunxi_ehci->hci_name);
return 0;
}

Expand Down Expand Up @@ -796,7 +814,8 @@ static int sunxi_ehci_hcd_resume(struct device *dev)
}

if(sunxi_ehci->probe == 0){
DMSG_PANIC("[%s]: is disable, can not resume\n", sunxi_ehci->hci_name);
DMSG_INFO("[%s]: is disable, can not resume\n",
sunxi_ehci->hci_name);
return 0;
}

Expand Down Expand Up @@ -840,6 +859,8 @@ static const struct dev_pm_ops aw_ehci_pmops = {
static const struct of_device_id sunxi_ehci_match[] = {
{.compatible = SUNXI_EHCI0_OF_MATCH, },
{.compatible = SUNXI_EHCI1_OF_MATCH, },
{.compatible = SUNXI_EHCI2_OF_MATCH, },
{.compatible = SUNXI_EHCI3_OF_MATCH, },
{},
};
MODULE_DEVICE_TABLE(of, sunxi_ehci_match);
Expand Down Expand Up @@ -905,4 +926,3 @@ int sunxi_usb_enable_ehci(__u32 usbc_no)
return 0;
}
EXPORT_SYMBOL(sunxi_usb_enable_ehci);

50 changes: 39 additions & 11 deletions drivers/usb/host/ohci_sunxi.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,24 @@ static const char ohci_name[] = SUNXI_OHCI_NAME;
#define SUNXI_OHCI0_OF_MATCH "null"
#endif


#if defined CONFIG_USB_SUNXI_OHCI1 && !defined SUNXI_USB_FPGA
#define SUNXI_OHCI1_OF_MATCH "allwinner,sunxi-ohci1"
#else
#define SUNXI_OHCI1_OF_MATCH "null"
#endif

#if defined CONFIG_USB_SUNXI_OHCI2 && !defined SUNXI_USB_FPGA
#define SUNXI_OHCI2_OF_MATCH "allwinner,sunxi-ohci2"
#else
#define SUNXI_OHCI2_OF_MATCH "null"
#endif

#if defined CONFIG_USB_SUNXI_OHCI3 && !defined SUNXI_USB_FPGA
#define SUNXI_OHCI3_OF_MATCH "allwinner,sunxi-ohci3"
#else
#define SUNXI_OHCI3_OF_MATCH "null"
#endif

static struct sunxi_hci_hcd *g_sunxi_ohci[4];
static u32 ohci_first_probe[4] = {1, 1, 1, 1};
static u32 ohci_enable[4] = {1, 1, 1, 1};
Expand Down Expand Up @@ -359,12 +370,11 @@ static int sunxi_ohci_hcd_probe(struct platform_device *pdev)
ret = init_sunxi_hci(pdev, SUNXI_USB_OHCI);
if(ret != 0){
dev_err(&pdev->dev, "init_sunxi_hci is fail\n");
return 0;
return -1;
}

sunxi_insmod_ohci(pdev);


sunxi_ohci = pdev->dev.platform_data;
if(sunxi_ohci == NULL){
DMSG_PANIC("ERR: %s, sunxi_ohci is null\n", __func__);
Expand Down Expand Up @@ -406,26 +416,32 @@ static void sunxi_ohci_hcd_shutdown(struct platform_device* pdev)

sunxi_ohci = pdev->dev.platform_data;
if(sunxi_ohci == NULL){
DMSG_PANIC("ERR: sunxi_ohci is null\n");
DMSG_PANIC("ERR: %s sunxi_ohci is null\n", __func__);
return ;
}

if(sunxi_ohci->probe == 0){
DMSG_PANIC("ERR: %s, %s is disable, need not shutdown\n", __func__, sunxi_ohci->hci_name);
DMSG_INFO("%s, %s is disable, need not shutdown\n", __func__, sunxi_ohci->hci_name);
return ;
}

DMSG_INFO("[%s]: ohci shutdown start\n", sunxi_ohci->hci_name);
pr_debug("[%s]: ohci shutdown start\n", sunxi_ohci->hci_name);

#ifdef CONFIG_PM
if(sunxi_ohci->wakeup_suspend){
scene_lock_destroy(&ohci_standby_lock[sunxi_ohci->usbc_no]);
}
#endif
usb_hcd_platform_shutdown(pdev);
sunxi_stop_ohci(sunxi_ohci);

DMSG_INFO("[%s]: ohci shutdown end\n", sunxi_ohci->hci_name);
/* disable usb otg INTUSBE, To solve usb0 device mode catch audio udev on reboot system is fail*/
if (sunxi_ohci->usbc_no == 0)
if (sunxi_ohci->otg_vbase) {
writel(0, (sunxi_ohci->otg_vbase
+ SUNXI_USBC_REG_INTUSBE));
}

pr_debug("[%s]: ohci shutdown end\n", sunxi_ohci->hci_name);

return;
}
Expand Down Expand Up @@ -457,7 +473,8 @@ static int sunxi_ohci_hcd_suspend(struct device *dev)
}

if(sunxi_ohci->probe == 0){
DMSG_PANIC("[%s]: is disable, can not suspend\n", sunxi_ohci->hci_name);
DMSG_INFO("[%s]: is disable, can not suspend\n",
sunxi_ohci->hci_name);
return 0;
}

Expand All @@ -480,6 +497,11 @@ static int sunxi_ohci_hcd_suspend(struct device *dev)
val |= OHCI_INTR_RD;
val |= OHCI_INTR_MIE;
ohci_writel(ohci, val, &ohci->regs->intrenable);

if(sunxi_ohci->clk_usbohci12m && sunxi_ohci->clk_losc){
clk_set_parent(sunxi_ohci->clk_usbohci12m, sunxi_ohci->clk_losc);
}

}else{
DMSG_INFO("[%s]: sunxi_ohci_hcd_suspend\n", sunxi_ohci->hci_name);

Expand Down Expand Up @@ -522,13 +544,18 @@ static int sunxi_ohci_hcd_resume(struct device *dev)
}

if(sunxi_ohci->probe == 0){
DMSG_PANIC("[%s]: is disable, can not resume\n", sunxi_ohci->hci_name);
DMSG_INFO("[%s]: is disable, can not resume\n",
sunxi_ohci->hci_name);
return 0;
}

if(sunxi_ohci->wakeup_suspend){
DMSG_INFO("[%s]: controller not suspend, need not resume\n", sunxi_ohci->hci_name);

if(sunxi_ohci->clk_usbohci12m && sunxi_ohci->clk_hoscx2){
clk_set_parent(sunxi_ohci->clk_usbohci12m, sunxi_ohci->clk_hoscx2);
}

scene_unlock(&ohci_standby_lock[sunxi_ohci->usbc_no]);
disable_wakeup_src(CPUS_USBMOUSE_SRC, 0);

Expand Down Expand Up @@ -563,6 +590,8 @@ static const struct dev_pm_ops sunxi_ohci_pmops = {
static const struct of_device_id sunxi_ohci_match[] = {
{.compatible = SUNXI_OHCI0_OF_MATCH, },
{.compatible = SUNXI_OHCI1_OF_MATCH, },
{.compatible = SUNXI_OHCI2_OF_MATCH, },
{.compatible = SUNXI_OHCI3_OF_MATCH, },
{},
};
MODULE_DEVICE_TABLE(of, sunxi_ohci_match);
Expand Down Expand Up @@ -629,4 +658,3 @@ int sunxi_usb_enable_ohci(__u32 usbc_no)
return 0;
}
EXPORT_SYMBOL(sunxi_usb_enable_ohci);

Loading