Skip to content

Commit 9dc782a

Browse files
committed
Backport USB EHCI/OHCI code from BSP 3.0
Backport from A64-BSP-3.0.tgz as found in the Pine64 wiki.
1 parent a08f521 commit 9dc782a

File tree

6 files changed

+305
-114
lines changed

6 files changed

+305
-114
lines changed

drivers/power/axp_power/axp-chg.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ s32 axp_usb_det(void)
5252
}
5353
EXPORT_SYMBOL_GPL(axp_usb_det);
5454

55+
s32 axp_usb_vbus_output(int high)
56+
{
57+
return 0;
58+
}
59+
EXPORT_SYMBOL_GPL(axp_usb_vbus_output);
60+
5561
static void axp_usb_ac_check_status(struct axp_charger *charger)
5662
{
5763
if (!axp_config->pmu_init_bc_en) {
@@ -278,4 +284,3 @@ void axp_chg_exit(struct axp_charger *charger)
278284
}
279285
return;
280286
}
281-

drivers/power/axp_power/axp-interface.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
s32 axp_usbcur(aw_charge_type type){ return 0; };
99
s32 axp_usbvol(aw_charge_type type){ return 0; };
1010
s32 axp_usb_det(void){ return 0; };
11+
s32 axp_usb_vbus_output(int high){ return 0; };
1112
s32 axp_powerkey_get(void){ return 0; };
1213
void axp_powerkey_set(int value){};
1314
u64 axp_read_power_sply(void){ return 0; };

drivers/usb/host/ehci_sunxi.c

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,30 @@ static struct scene_lock ehci_standby_lock[4];
3333
#define SUNXI_EHCI_NAME "sunxi-ehci"
3434
static const char ehci_name[] = SUNXI_EHCI_NAME;
3535

36-
#ifdef CONFIG_USB_SUNXI_EHCI0
36+
#ifdef CONFIG_USB_SUNXI_EHCI0
3737
#define SUNXI_EHCI0_OF_MATCH "allwinner,sunxi-ehci0"
3838
#else
3939
#define SUNXI_EHCI0_OF_MATCH "null"
4040
#endif
4141

42-
#ifdef CONFIG_USB_SUNXI_EHCI1
42+
#ifdef CONFIG_USB_SUNXI_EHCI1
4343
#define SUNXI_EHCI1_OF_MATCH "allwinner,sunxi-ehci1"
4444
#else
4545
#define SUNXI_EHCI1_OF_MATCH "null"
4646
#endif
4747

48+
#ifdef CONFIG_USB_SUNXI_EHCI2
49+
#define SUNXI_EHCI2_OF_MATCH "allwinner,sunxi-ehci2"
50+
#else
51+
#define SUNXI_EHCI2_OF_MATCH "null"
52+
#endif
53+
54+
#ifdef CONFIG_USB_SUNXI_EHCI3
55+
#define SUNXI_EHCI3_OF_MATCH "allwinner,sunxi-ehci3"
56+
#else
57+
#define SUNXI_EHCI3_OF_MATCH "null"
58+
#endif
59+
4860
static struct sunxi_hci_hcd *g_sunxi_ehci[4];
4961
static u32 ehci_first_probe[4] = {1, 1, 1, 1};
5062
static u32 ehci_enable[4] = {1, 1, 1, 1};
@@ -641,7 +653,7 @@ static int sunxi_ehci_hcd_probe(struct platform_device *pdev)
641653
ret = init_sunxi_hci(pdev, SUNXI_USB_EHCI);
642654
if(ret != 0){
643655
dev_err(&pdev->dev, "init_sunxi_hci is fail\n");
644-
return 0;
656+
return -1;
645657
}
646658

647659
sunxi_insmod_ehci(pdev);
@@ -699,21 +711,26 @@ static void sunxi_ehci_hcd_shutdown(struct platform_device* pdev)
699711
}
700712

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

706-
DMSG_INFO("[%s]: ehci shutdown start\n", sunxi_ehci->hci_name);
718+
pr_debug("[%s]: ehci shutdown start\n", sunxi_ehci->hci_name);
707719
#ifdef CONFIG_PM
708720
if(sunxi_ehci->wakeup_suspend){
709721
scene_lock_destroy(&ehci_standby_lock[sunxi_ehci->usbc_no]);
710722
}
711723
#endif
712724
usb_hcd_platform_shutdown(pdev);
713725

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

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

718735
return ;
719736
}
@@ -745,7 +762,8 @@ static int sunxi_ehci_hcd_suspend(struct device *dev)
745762
}
746763

747764
if(sunxi_ehci->probe == 0){
748-
DMSG_PANIC("[%s]: is disable, can not suspend\n", sunxi_ehci->hci_name);
765+
DMSG_INFO("[%s]: is disable, can not suspend\n",
766+
sunxi_ehci->hci_name);
749767
return 0;
750768
}
751769

@@ -796,7 +814,8 @@ static int sunxi_ehci_hcd_resume(struct device *dev)
796814
}
797815

798816
if(sunxi_ehci->probe == 0){
799-
DMSG_PANIC("[%s]: is disable, can not resume\n", sunxi_ehci->hci_name);
817+
DMSG_INFO("[%s]: is disable, can not resume\n",
818+
sunxi_ehci->hci_name);
800819
return 0;
801820
}
802821

@@ -840,6 +859,8 @@ static const struct dev_pm_ops aw_ehci_pmops = {
840859
static const struct of_device_id sunxi_ehci_match[] = {
841860
{.compatible = SUNXI_EHCI0_OF_MATCH, },
842861
{.compatible = SUNXI_EHCI1_OF_MATCH, },
862+
{.compatible = SUNXI_EHCI2_OF_MATCH, },
863+
{.compatible = SUNXI_EHCI3_OF_MATCH, },
843864
{},
844865
};
845866
MODULE_DEVICE_TABLE(of, sunxi_ehci_match);
@@ -905,4 +926,3 @@ int sunxi_usb_enable_ehci(__u32 usbc_no)
905926
return 0;
906927
}
907928
EXPORT_SYMBOL(sunxi_usb_enable_ehci);
908-

drivers/usb/host/ohci_sunxi.c

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,24 @@ static const char ohci_name[] = SUNXI_OHCI_NAME;
4040
#define SUNXI_OHCI0_OF_MATCH "null"
4141
#endif
4242

43-
4443
#if defined CONFIG_USB_SUNXI_OHCI1 && !defined SUNXI_USB_FPGA
4544
#define SUNXI_OHCI1_OF_MATCH "allwinner,sunxi-ohci1"
4645
#else
4746
#define SUNXI_OHCI1_OF_MATCH "null"
4847
#endif
4948

49+
#if defined CONFIG_USB_SUNXI_OHCI2 && !defined SUNXI_USB_FPGA
50+
#define SUNXI_OHCI2_OF_MATCH "allwinner,sunxi-ohci2"
51+
#else
52+
#define SUNXI_OHCI2_OF_MATCH "null"
53+
#endif
54+
55+
#if defined CONFIG_USB_SUNXI_OHCI3 && !defined SUNXI_USB_FPGA
56+
#define SUNXI_OHCI3_OF_MATCH "allwinner,sunxi-ohci3"
57+
#else
58+
#define SUNXI_OHCI3_OF_MATCH "null"
59+
#endif
60+
5061
static struct sunxi_hci_hcd *g_sunxi_ohci[4];
5162
static u32 ohci_first_probe[4] = {1, 1, 1, 1};
5263
static u32 ohci_enable[4] = {1, 1, 1, 1};
@@ -359,12 +370,11 @@ static int sunxi_ohci_hcd_probe(struct platform_device *pdev)
359370
ret = init_sunxi_hci(pdev, SUNXI_USB_OHCI);
360371
if(ret != 0){
361372
dev_err(&pdev->dev, "init_sunxi_hci is fail\n");
362-
return 0;
373+
return -1;
363374
}
364375

365376
sunxi_insmod_ohci(pdev);
366377

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

407417
sunxi_ohci = pdev->dev.platform_data;
408418
if(sunxi_ohci == NULL){
409-
DMSG_PANIC("ERR: sunxi_ohci is null\n");
419+
DMSG_PANIC("ERR: %s sunxi_ohci is null\n", __func__);
410420
return ;
411421
}
412422

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

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

420430
#ifdef CONFIG_PM
421431
if(sunxi_ohci->wakeup_suspend){
422432
scene_lock_destroy(&ohci_standby_lock[sunxi_ohci->usbc_no]);
423433
}
424434
#endif
425435
usb_hcd_platform_shutdown(pdev);
426-
sunxi_stop_ohci(sunxi_ohci);
427436

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

430446
return;
431447
}
@@ -457,7 +473,8 @@ static int sunxi_ohci_hcd_suspend(struct device *dev)
457473
}
458474

459475
if(sunxi_ohci->probe == 0){
460-
DMSG_PANIC("[%s]: is disable, can not suspend\n", sunxi_ohci->hci_name);
476+
DMSG_INFO("[%s]: is disable, can not suspend\n",
477+
sunxi_ohci->hci_name);
461478
return 0;
462479
}
463480

@@ -480,6 +497,11 @@ static int sunxi_ohci_hcd_suspend(struct device *dev)
480497
val |= OHCI_INTR_RD;
481498
val |= OHCI_INTR_MIE;
482499
ohci_writel(ohci, val, &ohci->regs->intrenable);
500+
501+
if(sunxi_ohci->clk_usbohci12m && sunxi_ohci->clk_losc){
502+
clk_set_parent(sunxi_ohci->clk_usbohci12m, sunxi_ohci->clk_losc);
503+
}
504+
483505
}else{
484506
DMSG_INFO("[%s]: sunxi_ohci_hcd_suspend\n", sunxi_ohci->hci_name);
485507

@@ -522,13 +544,18 @@ static int sunxi_ohci_hcd_resume(struct device *dev)
522544
}
523545

524546
if(sunxi_ohci->probe == 0){
525-
DMSG_PANIC("[%s]: is disable, can not resume\n", sunxi_ohci->hci_name);
547+
DMSG_INFO("[%s]: is disable, can not resume\n",
548+
sunxi_ohci->hci_name);
526549
return 0;
527550
}
528551

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

555+
if(sunxi_ohci->clk_usbohci12m && sunxi_ohci->clk_hoscx2){
556+
clk_set_parent(sunxi_ohci->clk_usbohci12m, sunxi_ohci->clk_hoscx2);
557+
}
558+
532559
scene_unlock(&ohci_standby_lock[sunxi_ohci->usbc_no]);
533560
disable_wakeup_src(CPUS_USBMOUSE_SRC, 0);
534561

@@ -563,6 +590,8 @@ static const struct dev_pm_ops sunxi_ohci_pmops = {
563590
static const struct of_device_id sunxi_ohci_match[] = {
564591
{.compatible = SUNXI_OHCI0_OF_MATCH, },
565592
{.compatible = SUNXI_OHCI1_OF_MATCH, },
593+
{.compatible = SUNXI_OHCI2_OF_MATCH, },
594+
{.compatible = SUNXI_OHCI3_OF_MATCH, },
566595
{},
567596
};
568597
MODULE_DEVICE_TABLE(of, sunxi_ohci_match);
@@ -629,4 +658,3 @@ int sunxi_usb_enable_ohci(__u32 usbc_no)
629658
return 0;
630659
}
631660
EXPORT_SYMBOL(sunxi_usb_enable_ohci);
632-

0 commit comments

Comments
 (0)