Skip to content

Commit

Permalink
update(port/ohci): update ohci common code
Browse files Browse the repository at this point in the history
  • Loading branch information
sakumisu committed Dec 8, 2024
1 parent bfc1139 commit 963447c
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 71 deletions.
17 changes: 6 additions & 11 deletions port/ehci/usb_glue_aic.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@
#include <hal_syscfg.h>
#include "usbh_core.h"
#include "usb_hc_ehci.h"
#include "usb_hc_ohci.h"

#if !defined(CONFIG_USB_EHCI_CONFIGFLAG)
#error "aic ehci must define CONFIG_USB_EHCI_CONFIGFLAG"
#endif

#if !defined(CONFIG_USB_EHCI_WITH_OHCI)
#error "aic must define CONFIG_USB_EHCI_WITH_OHCI for ls/fs device"
#endif

#if CONFIG_USB_OHCI_HCOR_OFFSET != 0x400
#error "aic CONFIG_USB_OHCI_HCOR_OFFSET must be 0x400"
#endif
Expand Down Expand Up @@ -130,17 +135,7 @@ void usb_hc_low_level_init(struct usbh_bus *bus)

uint8_t usbh_get_port_speed(struct usbh_bus *bus, const uint8_t port)
{
/* Defined by individual manufacturers */
uint32_t regval;

regval = EHCI_HCOR->portsc[port-1];
if ((regval & EHCI_PORTSC_LSTATUS_MASK) == EHCI_PORTSC_LSTATUS_KSTATE)
return USB_SPEED_LOW;

if (regval & EHCI_PORTSC_PE)
return USB_SPEED_HIGH;
else
return USB_SPEED_FULL;
return USB_SPEED_HIGH;
}

void usb_ehci_dcache_clean(uintptr_t addr, uint32_t len)
Expand Down
1 change: 0 additions & 1 deletion port/ehci/usb_hc_ehci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,6 @@ int usbh_roothub_control(struct usbh_bus *bus, struct usb_setup_packet *setup, u

while (!(EHCI_HCOR->portsc[port - 1] & EHCI_PORTSC_OWNER)) {
}
return ohci_roothub_control(bus, setup, buf);
}
#endif
break;
Expand Down
13 changes: 9 additions & 4 deletions port/ohci/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
# Note

This OHCI is a companion controller of EHCI.
This OHCI is a companion controller of EHCI. But you can use OHCI only without CONFIG_USB_EHCI_WITH_OHCI definition.

**And you need to pay for using OHCI driver**.

## Support Chip List

### AllwinnerTech

- F133
- F133(EHCI + OHCI)

### Nuvoton

- Nuvoton all series
- Nuvoton all series(EHCI + OHCI, OHCI only)

### Artinchip

- d13x, d21x
- d13x, d21x(EHCI + OHCI)

### NXP

- LPC4X/LPC5X(OHCI only)
40 changes: 40 additions & 0 deletions port/ohci/usb_glue_lpc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "fsl_device_registers.h"
#include "fsl_power.h"
#include "usbh_core.h"

#if defined(CONFIG_USB_EHCI_WITH_OHCI)
#error "lpc does not have ehci"
#endif

void usb_hc_low_level_init(struct usbh_bus *bus)
{
#if ((defined FSL_FEATURE_SOC_SYSMPU_COUNT) && (FSL_FEATURE_SOC_SYSMPU_COUNT))
SYSMPU_Enable(SYSMPU, 0);
#endif /* FSL_FEATURE_SOC_SYSMPU_COUNT */

NVIC_ClearPendingIRQ(USB0_IRQn);
NVIC_ClearPendingIRQ(USB0_NEEDCLK_IRQn);

POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*< Turn on USB0 Phy */

RESET_PeripheralReset(kUSB0D_RST_SHIFT_RSTn);
RESET_PeripheralReset(kUSB0HSL_RST_SHIFT_RSTn);
RESET_PeripheralReset(kUSB0HMR_RST_SHIFT_RSTn);

CLOCK_EnableUsbfs0HostClock(kCLOCK_UsbfsSrcPll1, 48000000U);

NVIC_SetPriority(USB0_IRQn, 3);
EnableIRQ(USB0_IRQn);
}


void usb_hc_low_level_deinit(struct usbh_bus *bus)
{
DisableIRQ(USB0_IRQn);
}

void USB0_IRQHandler(void)
{
extern void USBH_IRQHandler(uint8_t busid);
USBH_IRQHandler(0);
}
Loading

0 comments on commit 963447c

Please sign in to comment.