Commit 1a57aefd authored by ROOL's avatar ROOL :robot:
Browse files

Add support for HAL_USBPortPower to EHCI host controller

Detail:
  When signalled as a feature of the HAL device, call HAL_USBPortPower to turn on the port.
Admin:
  Submission from Willi Theiss.

Version 1.05. Tagged as 'NetBSD-1_05'
parent 2f96fb78
/* (1.04)
/* (1.05)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.04
#define Module_MajorVersion_CMHG 1.05
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 28 Sep 2015
#define Module_Date_CMHG 04 Nov 2015
#define Module_MajorVersion "1.04"
#define Module_Version 104
#define Module_MajorVersion "1.05"
#define Module_Version 105
#define Module_MinorVersion ""
#define Module_Date "28 Sep 2015"
#define Module_Date "04 Nov 2015"
#define Module_ApplicationDate "28-Sep-15"
#define Module_ApplicationDate "04-Nov-15"
#define Module_ComponentName "NetBSD"
#define Module_ComponentPath "mixed/RiscOS/Sources/HWSupport/USB/NetBSD"
#define Module_FullVersion "1.04"
#define Module_HelpVersion "1.04 (28 Sep 2015)"
#define Module_LibraryVersionInfo "1:4"
#define Module_FullVersion "1.05"
#define Module_HelpVersion "1.05 (04 Nov 2015)"
#define Module_LibraryVersionInfo "1:5"
......@@ -5,8 +5,8 @@
#define OHCIDriverModule_Module_Date_CMHG 22 Aug 2015
#define OHCIDriverModule_MajorVersion_CMHG 0.43
#define EHCIDriverModule_Module_Date_CMHG 22 Aug 2015
#define EHCIDriverModule_MajorVersion_CMHG 0.28
#define EHCIDriverModule_Module_Date_CMHG 04 Nov 2015
#define EHCIDriverModule_MajorVersion_CMHG 0.29
#define USBDriverModule_Module_Date_CMHG 28 Sep 2015
#define USBDriverModule_MajorVersion_CMHG 0.78
......@@ -52,6 +52,7 @@ extern size_t HAL_USBControllerInfo(int idx,usbinfo *info,size_t size);
extern int HAL_IRQEnable(int device);
extern int HAL_IRQDisable(int device);
extern void HAL_IRQClear(int device);
extern int HAL_USBPortPower(int idx,int port,int state);
extern device_ptr_t register_bus(device_ptr_t bus);
static void init_device(usbinfo *info,int idx)
......@@ -71,6 +72,14 @@ static void init_device(usbinfo *info,int idx)
HAL_IRQEnable(ehci->sc_irqdevno);
/* Register with USBDriver */
register_bus((device_ptr_t) ehci);
/* Switch on the ports (if under HAL control) */
if(info->flags & HALUSBControllerFlag_HAL_Port_Power)
{
for (int i = 0; i < ehci->sc_noport; i++)
{
HAL_USBPortPower(idx, i, 1);
}
}
}
void USBHAL_EHCIDriver_Init(void)
......
......@@ -138,6 +138,7 @@ int device_number;
int unhandled_irqs;
int registers_32bit=0;
static bool registering=false; /* True/false for whether we're in the middle of registering. Avoids nested registration attempt during ROM init. */
static bool hal_portpower = false; /* Whether to use HAL_PortPower to control the port */
_kernel_oserror* register_bus(void *in,struct device **out)
{
......@@ -176,6 +177,14 @@ _kernel_oserror* new_instance (_kernel_swi_regs* r, void* pw, void* h)
}
else
{
if (hal_portpower)
{
for (int i = 0; i < ehci_soft.sc_noport; i++)
{
_swix(OS_Hardware, _INR(0,2) | _INR(8,9),
hal_device, i, 1, OSHW_CallHAL, EntryNo_HAL_USBPortPower);
}
}
dprintf (("", "Registering with USB driver-done\n"));
}
......@@ -304,7 +313,7 @@ _kernel_oserror *module_init(const char *cmd_tail, int podule_base, void *pw) {
e = _swix(OS_Hardware, _INR(0,2)|_INR(8,9)|_OUT(0),
hal_device, &usbinfo, sizeof usbinfo,
0, EntryNo_HAL_USBControllerInfo,
OSHW_CallHAL, EntryNo_HAL_USBControllerInfo,
&usbinfolen);
if (!e && (usbinfolen == sizeof(usbinfo)) && (usbinfo.type == HALUSBControllerType_EHCI))
{
......@@ -315,6 +324,8 @@ _kernel_oserror *module_init(const char *cmd_tail, int podule_base, void *pw) {
registers_32bit = 1;
if(usbinfo.flags & HALUSBControllerFlag_EHCI_ETTF)
ettf = true;
if(usbinfo.flags & HALUSBControllerFlag_HAL_Port_Power)
hal_portpower = true;
break;
}
else if(e || !usbinfolen)
......@@ -339,7 +350,7 @@ _kernel_oserror *module_init(const char *cmd_tail, int podule_base, void *pw) {
_swix (OS_ClaimDeviceVector, _INR(0,4),
device_number| (1u<<31), usb_irq_entry, pw, 0, 0);
_swix (OS_Hardware, _IN(0) | _INR(8,9),
device_number, 0, EntryNo_HAL_IRQEnable);
device_number, OSHW_CallHAL, EntryNo_HAL_IRQEnable);
if ((magic = init_veneer ()) == NULL)
{
......@@ -395,7 +406,7 @@ _kernel_oserror *module_final(int fatal, int podule, void *pw)
/* don't disable the interrupt since it is shared, the OS will disable it
when noone is left responding */
// _swix (OS_Hardware, _IN(0) | _INR(8,9),
// device_number, 0, EntryNo_HAL_IRQDisable);
// device_number, OSHW_CallHAL, EntryNo_HAL_IRQDisable);
callx_remove_all_callbacks ();
callx_remove_all_callafters ();
callx_remove_all_calleverys ();
......@@ -576,7 +587,7 @@ int usb_irq_handler(_kernel_swi_regs *r, void *pw)
#ifdef EHCI_DEBUG
int u2s, u2s1;
_swix (OS_Hardware, _INR(8,9)|_OUT(0),
0, EntryNo_HAL_CounterRead, &u2s);
OSHW_CallHAL, EntryNo_HAL_CounterRead, &u2s);
// irqs++;
// ehci_softc_t* sc = &ehci_soft;
// if (ehcidebug > 1) dprintf (("", "Frame index: %x\n",
......@@ -593,7 +604,7 @@ int usb_irq_handler(_kernel_swi_regs *r, void *pw)
else
{
_swix (OS_Hardware, _INR(8,9)|_OUT(0),
0, EntryNo_HAL_CounterRead, &u2s1);
OSHW_CallHAL, EntryNo_HAL_CounterRead, &u2s1);
int t = (u2s - u2s1) * 5;
if (t < 0) t += 10000000; /* it wrapped */
if (ehcidebug > 1) dprintf(("", "irq for: %d nsecs\n", t));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment