Commit 24cbac6b authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Update to use rationalised power and overcurrent API

OHCIDriver (only) had sketchy support for a HAL based scheme for controlling the port power and monitor overcurrent. However the implementation was limited to supporting the single port required for an embedded product (aka Rhenium in the CVS history). The change makes it follow a model much more akin to the HAL_TimerDevice/HAL_TimerIRQStatus/HAL_TimerIRQClear set of functions.
Version:
  Bumped OHCIDriver and USBDriver version numbers.
ohcimodule.c:
  Use some defines from OsBytes.h.
  Group the debug variables within the OHCI_DEBUG define so they go away in the release case.
  Allow for up to 15 ports to be controlled via the revised HAL API, and pass something other than a hardwired controller of 0 when controlling/monitoring power.
  Enumerate the device numbers for overcurrent monitoring on startup.
  Deal with the possibility of one (or more) of the device numbers being shared interrupts.
  Squash a few trivial compiler warnings.
ohcimodhead.cmhg:
  rename the handler/entry to reflect their use for overcurrent
ohci.c:
  Allow for up to 15 ports to be controlled by passing in the port index where needed.
usb_subr.c/usbdivar.h:
  Remove a RISC OS-ism in datatoggle, to converge with NetBSD a bit.
ehcivar.h/usb_port.h:
  Relocate the overrides for mutex_ functions here since this is the only controller using them. Previously when in "usb_port.h" they would indirectly get dragged in ia the nested include in "usb.h". The could in fact now be implemented using SyncLib, an exercise left to the reader.
usb.h
  Merge some of the device classes and other allocations from NetBSD.

While it's not been possible to test the revised API, due to not having sight of the original platform on which it was implemented, none of the actively maintained HALs currently use the HAL based power and overcurrent scheme anyway, so the new code never gets called. In that respect, it's no more broken then the previous single port-single controller version.

Version 0.89. Tagged as 'NetBSD-0_89'
parent 122cdff0
/* (0.88)
/* (0.89)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.88
#define Module_MajorVersion_CMHG 0.89
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 29 Aug 2014
#define Module_Date_CMHG 25 Oct 2014
#define Module_MajorVersion "0.88"
#define Module_Version 88
#define Module_MajorVersion "0.89"
#define Module_Version 89
#define Module_MinorVersion ""
#define Module_Date "29 Aug 2014"
#define Module_Date "25 Oct 2014"
#define Module_ApplicationDate "29-Aug-14"
#define Module_ApplicationDate "25-Oct-14"
#define Module_ComponentName "NetBSD"
#define Module_ComponentPath "mixed/RiscOS/Sources/HWSupport/USB/NetBSD"
#define Module_FullVersion "0.88"
#define Module_HelpVersion "0.88 (29 Aug 2014)"
#define Module_LibraryVersionInfo "0:88"
#define Module_FullVersion "0.89"
#define Module_HelpVersion "0.89 (25 Oct 2014)"
#define Module_LibraryVersionInfo "0:89"
File moved
......@@ -2,11 +2,11 @@
VersionNum file really,as a work around define them here so the CMHG
file remains unaltered */
#define OHCIDriverModule_Module_Date_CMHG 30 Mar 2013
#define OHCIDriverModule_MajorVersion_CMHG 0.40
#define OHCIDriverModule_Module_Date_CMHG 25 Oct 2014
#define OHCIDriverModule_MajorVersion_CMHG 0.41
#define EHCIDriverModule_Module_Date_CMHG 29 Aug 2014
#define EHCIDriverModule_MajorVersion_CMHG 0.25
#define USBDriverModule_Module_Date_CMHG 12 Aug 2014
#define USBDriverModule_MajorVersion_CMHG 0.70
#define USBDriverModule_Module_Date_CMHG 25 Oct 2014
#define USBDriverModule_MajorVersion_CMHG 0.71
This diff is collapsed.
......@@ -68,6 +68,6 @@ event-handler: vsync_entry/vsync Event_VSync
#endif
vector-handlers: usb_irq_entry/usb_irq_handler,
usb_irq_port_error_entry/usb_irq_port_error_handler,
usb_overcurrent_entry/usb_overcurrent_handler,
softintr_entry/softintr
generic-veneers: callout_entry/callout_handler
......@@ -948,7 +948,8 @@ ohci_init(ohci_softc_t *sc)
OWRITE4(sc, OHCI_RH_DESCRIPTOR_A, desca | OHCI_NOCP);
OWRITE4(sc, OHCI_RH_STATUS, OHCI_LPSC); /* Enable port power */
#ifdef __riscos
(*ohci_ppower)(1, 1); // port power on
for (i = 1; i <= OHCI_GET_NDP(desca); i++)
(*ohci_ppower)(i, 1); /* Port power on */
#endif /*__riscos*/
usb_delay_ms(&sc->sc_bus, OHCI_ENABLE_POWER_DELAY);
OWRITE4(sc, OHCI_RH_DESCRIPTOR_A, desca);
......@@ -2876,7 +2877,7 @@ ohci_root_ctrl_start(usbd_xfer_handle xfer)
/* Yes, writing to the LOW_SPEED bit clears power. */
OWRITE4(sc, port, UPS_LOW_SPEED);
#ifdef __riscos
(*ohci_ppower)(1, 0); // port power off
(*ohci_ppower)(index, 0); /* Port power off */
#endif /*__riscos*/
break;
case UHF_C_PORT_CONNECTION:
......@@ -3003,7 +3004,7 @@ ohci_root_ctrl_start(usbd_xfer_handle xfer)
DPRINTFN(2,("ohci_root_ctrl_transfer: set port power "
"%d\n", index));
#ifdef __riscos
(*ohci_ppower)(1, 1); // port power on
(*ohci_ppower)(index, 1); /* Port power on */
#endif /*__riscos*/
OWRITE4(sc, port, UPS_PORT_POWER);
break;
......
......@@ -1177,10 +1177,8 @@ usbd_new_device(device_ptr_t parent, usbd_bus_handle bus, int depth,
dev->def_ep_desc.bInterval = 0;
#ifndef __riscos /* No datatoggle member (and we memset dev to zero anyway!) */
/* doesn't matter, just don't let it uninitialized */
dev->def_ep.datatoggle = 0;
#endif
dev->quirks = &usbd_no_quirk;
dev->address = USB_START_ADDR;
......
......@@ -42,6 +42,14 @@
#else
#define EHCI_SMALL_PAGE_SIZE EHCI_PAGE_SIZE
#endif
#ifdef __riscos
/* EHCI could use SyncLib for mutex, but for now, just wing it */
#define mutex_init(a,b,c)
#define mutex_destroy(a)
#define mutex_enter(a)
#define mutex_exit(a)
typedef struct { int a; } kmutex_t;
#endif
typedef struct ehci_soft_qtd {
ehci_qtd_t qtd;
......
......@@ -121,11 +121,16 @@ typedef struct {
uWord wLength;
} UPACKED usb_device_request_t;
#define UT_GET_DIR(a) ((a) & 0x80)
#define UT_WRITE 0x00
#define UT_READ 0x80
#define UT_GET_TYPE(a) ((a) & 0x60)
#define UT_STANDARD 0x00
#define UT_CLASS 0x20
#define UT_VENDOR 0x40
#define UT_GET_RECIPIENT(a) ((a) & 0x1f)
#define UT_DEVICE 0x00
#define UT_INTERFACE 0x01
#define UT_ENDPOINT 0x02
......@@ -154,7 +159,7 @@ typedef struct {
#define UT_WRITE_VENDOR_OTHER (UT_WRITE | UT_VENDOR | UT_OTHER)
#define UT_WRITE_VENDOR_ENDPOINT (UT_WRITE | UT_VENDOR | UT_ENDPOINT)
/* Requests */
/* Standard Requests Codes from the USB 2.0 spec, table 9-4 */
#define UR_GET_STATUS 0x00
#define UR_CLEAR_FEATURE 0x01
#define UR_SET_FEATURE 0x03
......@@ -169,12 +174,15 @@ typedef struct {
#define UDESC_OTHER_SPEED_CONFIGURATION 0x07
#define UDESC_INTERFACE_POWER 0x08
#define UDESC_OTG 0x09
#define UDESC_DEBUG 0x0a
#define UDESC_INTERFACE_ASSOC 0x0b
#define UDESC_CS_DEVICE 0x21 /* class specific */
#define UDESC_CS_CONFIG 0x22
#define UDESC_CS_STRING 0x23
#define UDESC_CS_INTERFACE 0x24
#define UDESC_CS_ENDPOINT 0x25
#define UDESC_HUB 0x29
#define UDESC_SSHUB 0x2a
#define UR_SET_DESCRIPTOR 0x07
#define UR_GET_CONFIG 0x08
#define UR_SET_CONFIG 0x09
......@@ -182,16 +190,24 @@ typedef struct {
#define UR_SET_INTERFACE 0x0b
#define UR_SYNCH_FRAME 0x0c
/* Feature numbers */
/*
* Feature selectors. USB 2.0 spec, table 9-6 and OTG and EH suppliment,
* table 6-2
*/
#define UF_ENDPOINT_HALT 0
#define UF_DEVICE_REMOTE_WAKEUP 1
#define UF_TEST_MODE 2
#define UF_DEVICE_B_HNP_ENABLE 3
#define UF_DEVICE_A_HNP_SUPPORT 4
#define UF_DEVICE_A_ALT_HNP_SUPPORT 5
#define USB_MAX_IPACKET 8 /* maximum size of the initial packet */
#define USB_2_MAX_CTRL_PACKET 64
#define USB_2_MAX_BULK_PACKET 512
#define USB_3_MAX_CTRL_PACKET 512
typedef struct {
uByte bLength;
uByte bDescriptorType;
......@@ -295,7 +311,10 @@ typedef struct {
#define UR_GET_TT_STATE 0x0a
#define UR_STOP_TT 0x0b
/* Hub features */
/*
* Hub features from USB 2.0 spec, table 11-17 and updated by the
* LPM ECN table 4-7.
*/
#define UHF_C_HUB_LOCAL_POWER 0
#define UHF_C_HUB_OVER_CURRENT 1
#define UHF_PORT_CONNECTION 0
......@@ -305,6 +324,7 @@ typedef struct {
#define UHF_PORT_RESET 4
#define UHF_PORT_POWER 8
#define UHF_PORT_LOW_SPEED 9
#define UHF_PORT_L1 10
#define UHF_C_PORT_CONNECTION 16
#define UHF_C_PORT_ENABLE 17
#define UHF_C_PORT_SUSPEND 18
......@@ -312,6 +332,7 @@ typedef struct {
#define UHF_C_PORT_RESET 20
#define UHF_PORT_TEST 21
#define UHF_PORT_INDICATOR 22
#define UHF_C_PORT_L1 23
typedef struct {
uByte bDescLength;
......@@ -397,9 +418,12 @@ typedef struct {
#define UPS_SUSPEND 0x0004
#define UPS_OVERCURRENT_INDICATOR 0x0008
#define UPS_RESET 0x0010
#define UPS_PORT_L1 0x0020
#define UPS_PORT_POWER 0x0100
#define UPS_FULL_SPEED 0x0000 /* for completeness */
#define UPS_LOW_SPEED 0x0200
#define UPS_HIGH_SPEED 0x0400
#define UPS_SUPER_SPEED 0x0600
#define UPS_PORT_TEST 0x0800
#define UPS_PORT_INDICATOR 0x1000
uWord wPortChange;
......@@ -408,6 +432,7 @@ typedef struct {
#define UPS_C_SUSPEND 0x0004
#define UPS_C_OVERCURRENT_INDICATOR 0x0008
#define UPS_C_PORT_RESET 0x0010
#define UPS_C_PORT_L1 0x0020
} UPACKED usb_port_status_t;
/* Device class codes */
......@@ -418,6 +443,7 @@ typedef struct {
#define UDPROTO_FSHUB 0x00
#define UDPROTO_HSHUBSTT 0x01
#define UDPROTO_HSHUBMTT 0x02
#define UDPROTO_SSHUB 0x03
#define UDCLASS_DIAGNOSTIC 0xdc
#define UDCLASS_WIRELESS 0xe0
#define UDSUBCLASS_RF 0x01
......@@ -432,6 +458,11 @@ typedef struct {
#define UISUBCLASS_AUDIOSTREAM 2
#define UISUBCLASS_MIDISTREAM 3
#define UICLASS_VIDEO 0x0E
#define UISUBCLASS_VIDEOCONTROL 1
#define UISUBCLASS_VIDEOSTREAMING 2
#define UISUBCLASS_VIDEOCOLLECTION 3
#define UICLASS_CDC 0x02 /* communication */
#define UISUBCLASS_DIRECT_LINE_CONTROL_MODEL 1
#define UISUBCLASS_ABSTRACT_CONTROL_MODEL 2
......@@ -440,11 +471,14 @@ typedef struct {
#define UISUBCLASS_CAPI_CONTROLMODEL 5
#define UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL 6
#define UISUBCLASS_ATM_NETWORKING_CONTROL_MODEL 7
#define UIPROTO_CDC_NOCLASS 0 /* no class specific
protocol required */
#define UIPROTO_CDC_AT 1
#define UICLASS_HID 0x03
#define UISUBCLASS_BOOT 1
#define UIPROTO_BOOT_KEYBOARD 1
#define UIPROTO_MOUSE 2
#define UICLASS_PHYSICAL 0x05
......@@ -501,6 +535,7 @@ typedef struct {
#define UICLASS_WIRELESS 0xe0
#define UISUBCLASS_RF 0x01
#define UIPROTO_BLUETOOTH 0x01
#define UIPROTO_RNDIS 0x03
#define UICLASS_APPL_SPEC 0xfe
#define UISUBCLASS_FIRMWARE_DOWNLOAD 1
......@@ -522,7 +557,7 @@ typedef struct {
#if 0
/* These are the values from the spec. */
#define USB_PORT_RESET_DELAY 10 /* ms */
#define USB_PORT_ROOT_RESET_DELAY 50 /* ms */
#define USB_PORT_ROOT_RESET_DELAY 50 /* ms */
#define USB_PORT_RESET_RECOVERY 10 /* ms */
#define USB_PORT_POWERUP_DELAY 100 /* ms */
#define USB_SET_ADDRESS_SETTLE 2 /* ms */
......@@ -639,6 +674,7 @@ struct usb_device_info {
#define USB_SPEED_LOW 1
#define USB_SPEED_FULL 2
#define USB_SPEED_HIGH 3
#define USB_SPEED_SUPER 4
int udi_power; /* power consumption in mA, 0 if selfpowered */
int udi_nports;
char udi_devnames[USB_MAX_DEVNAMES][USB_MAX_DEVNAMELEN];
......
......@@ -60,12 +60,6 @@
#define lockinit(a,b,c,d,e)
#define lockmgr(a,b,c)
struct lock { int a; };
/* XXX now we have to worry about our lack of support for mutexes too */
#define mutex_init(a,b,c)
#define mutex_destroy(a)
#define mutex_enter(a)
#define mutex_exit(a)
typedef struct { int a; } kmutex_t;
#define device_has_power(a) (true)
......
......@@ -73,6 +73,7 @@ struct usbd_pipe;
struct usbd_endpoint {
usb_endpoint_descriptor_t *edesc;
int refcnt;
int datatoggle;
};
struct usbd_bus_methods {
......
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