PERFORCE change 167221 for review
Sylvestre Gallon
syl at FreeBSD.org
Tue Aug 11 19:08:29 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=167221
Change 167221 by syl at syl_atuin on 2009/08/11 19:08:11
Add support for clock pull{up|down}...
Implement generic_set_port_feature.
Implement generic_get_port_status.
The old roothub_exec code is commented in at91dci.c until I have finish
the new implmentation.
Affected files ...
.. //depot/projects/soc2009/syl_usb/src/sys/dev/usb/controller/at91dci.c#11 edit
.. //depot/projects/soc2009/syl_usb/src/sys/dev/usb/usb_controller.h#9 edit
.. //depot/projects/soc2009/syl_usb/src/sys/dev/usb/usb_roothub_exec.c#6 edit
Differences ...
==== //depot/projects/soc2009/syl_usb/src/sys/dev/usb/controller/at91dci.c#11 (text+ko) ====
@@ -1673,15 +1673,18 @@
struct usb_device_request *req, const void **pptr, uint16_t *plength)
{
struct at91dci_softc *sc = AT9100_DCI_BUS2SC(udev->bus);
- const void *ptr;
- uint16_t len;
- uint16_t value;
- uint16_t index;
- usb_error_t err;
+ struct usb_roothub_fops fops;
- USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
+ bzero(&fops, sizeof(struct usb_roothub_fops));
+ fops.handle_clocks_on = (usb_clocks_fops_t)&at91dci_clocks_on;
+ fops.handle_clocks_off = (usb_clocks_fops_t)&at91dci_clocks_off;
+ fops.handle_pull_up = (usb_clocks_fops_t)&at91dci_pull_up;
+ fops.handle_pull_down = (usb_clocks_fops_t)&at91dci_pull_down;
+ fops.handle_wakeup_peer = (usb_clocks_fops_t)&at91dci_wakeup_peer;
+ return generic_roothub_exec((struct usb_generic_softc *)sc, &fops, req,
+ pptr, plength);
+/* USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
- /* buffer reset */
ptr = (const void *)&sc->sc_hub_temp;
len = 0;
err = 0;
@@ -1689,7 +1692,6 @@
value = UGETW(req->wValue);
index = UGETW(req->wIndex);
- /* demultiplex the control request */
switch (req->bmRequestType) {
case UT_READ_DEVICE:
@@ -1712,9 +1714,9 @@
case UR_SET_CONFIG:
goto tr_handle_set_config;
case UR_CLEAR_FEATURE:
- goto tr_valid; /* nop */
+ goto tr_valid;
case UR_SET_DESCRIPTOR:
- goto tr_valid; /* nop */
+ goto tr_valid;
case UR_SET_FEATURE:
default:
goto tr_stalled;
@@ -1744,7 +1746,7 @@
}
break;
case UR_SYNCH_FRAME:
- goto tr_valid; /* nop */
+ goto tr_valid;
default:
goto tr_stalled;
}
@@ -1764,7 +1766,7 @@
case UR_SET_INTERFACE:
goto tr_handle_set_interface;
case UR_CLEAR_FEATURE:
- goto tr_valid; /* nop */
+ goto tr_valid;
case UR_SET_FEATURE:
default:
goto tr_stalled;
@@ -1784,12 +1786,10 @@
case UT_WRITE_CLASS_INTERFACE:
case UT_WRITE_VENDOR_INTERFACE:
- /* XXX forward */
break;
case UT_READ_CLASS_INTERFACE:
case UT_READ_VENDOR_INTERFACE:
- /* XXX forward */
break;
case UT_WRITE_CLASS_DEVICE:
@@ -1865,17 +1865,17 @@
goto tr_valid;
case UDESC_STRING:
switch (value & 0xff) {
- case 0: /* Language table */
+ case 0:
len = sizeof(at91dci_langtab);
ptr = (const void *)&at91dci_langtab;
goto tr_valid;
- case 1: /* Vendor */
+ case 1:
len = sizeof(at91dci_vendor);
ptr = (const void *)&at91dci_vendor;
goto tr_valid;
- case 2: /* Product */
+ case 2:
len = sizeof(at91dci_product);
ptr = (const void *)&at91dci_product;
goto tr_valid;
@@ -1952,7 +1952,6 @@
case UHF_C_PORT_ENABLE:
case UHF_C_PORT_OVER_CURRENT:
case UHF_C_PORT_RESET:
- /* nops */
break;
case UHF_PORT_POWER:
sc->sc_flags.port_powered = 0;
@@ -1985,7 +1984,6 @@
case UHF_PORT_RESET:
case UHF_PORT_TEST:
case UHF_PORT_INDICATOR:
- /* nops */
break;
case UHF_PORT_POWER:
sc->sc_flags.port_powered = 1;
@@ -2011,8 +2009,6 @@
at91dci_clocks_off(sc);
}
- /* Select FULL-speed and Device Side Mode */
-
value = UPS_PORT_MODE_DEVICE;
if (sc->sc_flags.port_powered) {
@@ -2037,7 +2033,6 @@
if (sc->sc_flags.status_vbus &&
sc->sc_flags.status_bus_reset) {
- /* reset endpoint flags */
bzero(sc->sc_ep_flags, sizeof(sc->sc_ep_flags));
}
}
@@ -2062,7 +2057,7 @@
done:
*plength = len;
*pptr = ptr;
- return (err);
+ return (err);*/
}
static void
==== //depot/projects/soc2009/syl_usb/src/sys/dev/usb/usb_controller.h#9 (text+ko) ====
@@ -38,6 +38,7 @@
struct usb_endpoint;
struct usb_page_cache;
struct usb_setup_params;
+struct usb_roothub_fops;
struct usb_hw_ep_profile;
struct usb_generic_softc;
struct usb_fs_isoc_schedule;
@@ -208,7 +209,8 @@
struct usb_port_status ps;
};
-typedef usb_error_t (*usb_roothub_fops_t)(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index);
+typedef usb_error_t (*usb_roothub_fops_t)(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index);
+typedef usb_error_t (*usb_clocks_fops_t)(struct usb_generic_softc *sc);
struct usb_roothub_fops {
usb_roothub_fops_t handle_get_descriptor;
@@ -230,6 +232,11 @@
usb_roothub_fops_t handle_get_port_status;
usb_roothub_fops_t handle_get_class_descriptor;
usb_roothub_fops_t handle_get_class_status;
+ usb_clocks_fops_t handle_clocks_on;
+ usb_clocks_fops_t handle_clocks_off;
+ usb_clocks_fops_t handle_pull_up;
+ usb_clocks_fops_t handle_pull_down;
+ usb_clocks_fops_t handle_wakeup_peer;
};
/* prototypes */
==== //depot/projects/soc2009/syl_usb/src/sys/dev/usb/usb_roothub_exec.c#6 (text+ko) ====
@@ -70,10 +70,16 @@
struct usb_generic_flags sc_flags;
};
+#define SAFE_OPS(fops, field, err) \
+ if (fops->field == NULL) \
+ err = generic_roothub_fops.field(sc, fops, &len, &value, &index); \
+ else \
+ err = fops->field(sc, fops, &len, &value, &index)
+
static struct usb_roothub_fops generic_roothub_fops;
static usb_error_t
-generic_get_descriptor(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_get_descriptor(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
switch ((*value) >> 8) {
case UDESC_DEVICE:
@@ -109,7 +115,7 @@
}
static usb_error_t
-generic_get_config(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_get_config(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
*len = 1;
sc->sc_hub_temp.wValue[0] = sc->sc_conf;
@@ -117,7 +123,7 @@
}
static usb_error_t
-generic_get_status(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_get_status(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
*len = 2;
USETW(sc->sc_hub_temp.wValue, UDS_SELF_POWERED);
@@ -125,7 +131,7 @@
}
static usb_error_t
-generic_set_address(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_set_address(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
if ((*value) & 0xff00) {
return (USB_ERR_STALLED);
@@ -135,7 +141,7 @@
}
static usb_error_t
-generic_set_config(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_set_config(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
if ((*value) >= 2) {
return (USB_ERR_STALLED);
@@ -145,31 +151,31 @@
}
static usb_error_t
-generic_clear_halt(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_clear_halt(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
return (0);
}
static usb_error_t
-generic_clear_wakeup(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_clear_wakeup(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
return (0);
}
static usb_error_t
-generic_set_halt(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_set_halt(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
return (0);
}
static usb_error_t
-generic_set_wakeup(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_set_wakeup(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
return (0);
}
static usb_error_t
-generic_get_ep_status(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_get_ep_status(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
*len = 2;
USETW(sc->sc_hub_temp.wValue, 0);
@@ -177,13 +183,13 @@
}
static usb_error_t
-generic_set_interface(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_set_interface(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
return (0);
}
static usb_error_t
-generic_get_interface(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_get_interface(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
*len = 1;
sc->sc_hub_temp.wValue[0] = 0;
@@ -191,7 +197,7 @@
}
static usb_error_t
-generic_get_iface_status(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_get_iface_status(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
*len = 2;
USETW(sc->sc_hub_temp.wValue, 0);
@@ -199,7 +205,7 @@
}
static usb_error_t
-generic_clear_port_feature(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_clear_port_feature(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
if ((*index) != 1) {
return (USB_ERR_STALLED);
@@ -208,7 +214,8 @@
switch (*value) {
case UHF_PORT_SUSPEND:
- /* XXX xxxdci_wakeup_peer */
+ if (fops->handle_wakeup_peer)
+ fops->handle_wakeup_peer(sc);
break;
case UHF_PORT_ENABLE:
@@ -223,7 +230,10 @@
break;
case UHF_PORT_POWER:
sc->sc_flags.port_powered = 0;
- /* XXX Pull down clock off */
+ if (fops->handle_pull_down)
+ fops->handle_pull_down(sc);
+ if (fops->handle_clocks_off)
+ fops->handle_clocks_off(sc);
break;
case UHF_C_PORT_CONNECTION:
sc->sc_flags.change_connect = 0;
@@ -238,27 +248,95 @@
}
static usb_error_t
-generic_set_port_feature(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_set_port_feature(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
+ if ((*index) != 1) {
+ return (USB_ERR_IOERROR);
+ }
+ DPRINTFN(9, "UR_SET_PORT_FEATURE");
+
+ switch (*value) {
+ case UHF_PORT_ENABLE:
+ sc->sc_flags.port_enabled = 1;
+ break;
+ case UHF_PORT_SUSPEND:
+ case UHF_PORT_RESET:
+ case UHF_PORT_TEST:
+ case UHF_PORT_INDICATOR:
+ break;
+ case UHF_PORT_POWER:
+ sc->sc_flags.port_powered = 1;
+ break;
+ default:
+ return (USB_ERR_IOERROR);
+ }
return (0);
}
static usb_error_t
-generic_get_tt_state(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_get_tt_state(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
*len = 2;
USETW(sc->sc_hub_temp.wValue, 0);
return (0);
}
+/* XXX at91 Need another func*/
static usb_error_t
-generic_get_port_status(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_get_port_status(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
+ DPRINTFN(9, "UR_GET_PORT_STATUS");
+
+ if (*index != 1) {
+ return (USB_ERR_STALLED);
+ }
+ if (sc->sc_flags.status_vbus) {
+ if (fops->handle_clocks_on)
+ fops->handle_clocks_on(sc);
+ if (fops->handle_pull_up)
+ fops->handle_pull_up(sc);
+ } else {
+ if (fops->handle_clocks_off)
+ fops->handle_clocks_off(sc);
+ if (fops->handle_pull_down)
+ fops->handle_pull_down(sc);
+ }
+
+ /* Select Full-Speend and Device Side Mode */
+
+ *value = UPS_PORT_MODE_DEVICE;
+
+ if (sc->sc_flags.port_powered) {
+ *value |= UPS_PORT_POWER;
+ }
+ if (sc->sc_flags.port_enabled) {
+ *value |= UPS_PORT_ENABLED;
+ }
+ if (sc->sc_flags.status_vbus &&
+ sc->sc_flags.status_bus_reset) {
+ *value |= UPS_CURRENT_CONNECT_STATUS;
+ }
+ if (sc->sc_flags.status_suspend) {
+ *value |= UPS_SUSPEND;
+ }
+ USETW(sc->sc_hub_temp.ps.wPortStatus, *value);
+
+ *value = 0;
+
+ if (sc->sc_flags.change_connect) {
+ *value |= UPS_C_CONNECT_STATUS;
+ }
+ if (sc->sc_flags.change_suspend) {
+ *value |= UPS_C_SUSPEND;
+ }
+ USETW(sc->sc_hub_temp.ps.wPortChange, *value);
+ *len = sizeof(sc->sc_hub_temp.ps);
+
return (0);
}
static usb_error_t
-generic_get_class_descriptor(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_get_class_descriptor(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
if ((*value) & 0xff) {
return (USB_ERR_STALLED);
@@ -268,19 +346,13 @@
}
static usb_error_t
-generic_get_class_status(struct usb_generic_softc *sc, uint16_t *len, uint16_t *value, uint16_t *index)
+generic_get_class_status(struct usb_generic_softc *sc, struct usb_roothub_fops *fops, uint16_t *len, uint16_t *value, uint16_t *index)
{
*len = 2;
USETW(sc->sc_hub_temp.wValue, 0);
return (0);
}
-#define SAFE_OPS(fops, field, err) \
- if (fops->field == NULL) \
- err = generic_roothub_fops.field(sc, &len, &value, &index); \
- else \
- err = fops->field(sc, &len, &value, &index)
-
usb_error_t
generic_roothub_exec(struct usb_generic_softc *sc, struct usb_roothub_fops *fops,
struct usb_device_request *req, const void **pptr, uint16_t *plength)
@@ -514,5 +586,10 @@
&generic_get_port_status,
&generic_get_class_descriptor,
&generic_get_class_status,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
};
More information about the p4-projects
mailing list