Index: sys/usb/src.km/ucd/ethernat/isp116x-hcd.c =================================================================== RCS file: /mint/freemint/sys/usb/src.km/ucd/ethernat/isp116x-hcd.c,v retrieving revision 1.4 diff -u -8 -p -r1.4 isp116x-hcd.c --- sys/usb/src.km/ucd/ethernat/isp116x-hcd.c 6 Mar 2013 21:03:59 -0000 1.4 +++ sys/usb/src.km/ucd/ethernat/isp116x-hcd.c 11 Mar 2013 16:57:21 -0000 @@ -145,27 +145,27 @@ struct isp116x_platform_data isp116x_boa static long got_rhsc; /* root hub status change */ struct usb_device *devgone; /* device which was disconnected */ static long rh_devnum; /* address of Root Hub endpoint */ static int found = 0; /* * interrupt handling - bottom half */ -void _cdecl ethernat_int (void); +void _cdecl ethernat_int (void); /* * interrupt handling - top half */ static void int_handle_tophalf (PROC *p, long arg); /* *Function prototypes */ long isp116x_check_id (struct isp116x *); -static long isp116x_reset (struct isp116x *); +static long isp116x_reset (struct isp116x *); long submit_bulk_msg (struct usb_device *, unsigned long , void *, long); long submit_control_msg (struct usb_device *, unsigned long, void *, long, struct devrequest *); long submit_int_msg (struct usb_device *, unsigned long, void *, long, long); long _cdecl init (struct kentry *, struct ucdinfo *, char **); /* @@ -536,17 +536,17 @@ write_ptddata_to_fifo(struct isp116x *is unsigned short *dp2 = (unsigned short *) buf; unsigned short w; long quot = len % 4; /* For EtherNat, take the raw_write out in write functions, here we don't * like that EtherNat swap the bytes for us, so we swap them before we send * them, then the bytes will arrive to the USB device with the correct positions */ - if ((unsigned long)dp2 & 1) + if ((unsigned long)dp2 & 1) { /* not aligned */ for (; len > 1; len -= 2) { w = *dp++; w |= *dp++ << 8; isp116x_write_data16(isp116x, w); } @@ -575,17 +575,16 @@ read_ptddata_from_fifo(struct isp116x *i unsigned char *dp = (unsigned char *) buf; unsigned short *dp2 = (unsigned short *) buf; unsigned short w; long quot = len % 4; /* For EtherNAT, take the raw_read out from read functions, we want to swap the bytes to * read correct values because EtherNat swapped the bytes by hardware before we read them */ - if ((unsigned long)dp2 & 1) { /* not aligned */ for (; len > 1; len -= 2) { w = isp116x_read_data16(isp116x); *dp++ = w & 0xff; *dp++ = (w >> 8) & 0xff; @@ -623,17 +622,17 @@ pack_fifo(struct isp116x *isp116x, struc isp116x_write_reg16(isp116x, HCXFERCTR, buflen); isp116x_write_addr(isp116x, HCATLPORT | ISP116x_WRITE_OFFSET); done = 0; for (i = 0; i < n; i++) { DEBUG(("i=%ld - done=%ld - len=%d", i, done, PTD_GET_LEN(&ptd[i]))); -/* For EtherNAT, use raw_write to don't swap bytes */ + /* For EtherNAT, use raw_write to don't swap bytes */ dump_ptd(&ptd[i]); isp116x_raw_write_data16(isp116x, ptd[i].count); isp116x_raw_write_data16(isp116x, ptd[i].mps); isp116x_raw_write_data16(isp116x, ptd[i].len); isp116x_raw_write_data16(isp116x, ptd[i].faddr); dump_ptd_data(&ptd[i], (unsigned char *) data + done, 0); @@ -662,21 +661,16 @@ unpack_fifo(struct isp116x *isp116x, str isp116x_write_reg16(isp116x, HCuPINT, HCuPINT_AIIEOT); isp116x_write_reg16(isp116x, HCXFERCTR, buflen); isp116x_write_addr(isp116x, HCATLPORT); ret = TD_CC_NOERROR; done = 0; for (i = 0; i < n; i++) { - /* Galvez: DEBUG */ -// DEBUG(("i=%d - done=%d - len=%d", i, done, PTD_GET_LEN(&ptd[i]))); - DEBUG(("i=%ld n=%ld - done=%ld - len= %ld ptd_len=%d", i, n, done, len, PTD_GET_LEN(&ptd[i]))); - /*****************/ - /* For EtherNAT, use raw_read to don't swap bytes */ ptd[i].count = isp116x_raw_read_data16(isp116x); ptd[i].mps = isp116x_raw_read_data16(isp116x); ptd[i].len = isp116x_raw_read_data16(isp116x); ptd[i].faddr = isp116x_raw_read_data16(isp116x); dump_ptd(&ptd[i]); /* when cc is 15 the data has not being touch by the HC @@ -784,18 +778,16 @@ max_transfer_len(struct usb_device *dev, { unsigned mpck = (*uinf->usb_maxpacket)(dev, pipe); /* One PTD can transfer 1023 bytes but try to always * transfer multiples of endpoint buffer size */ return 1023 / mpck * mpck; } -//#include /* Tgettimeofday */ -//#include /* Do an USB transfer */ static long isp116x_submit_job(struct usb_device *dev, unsigned long pipe, long dir, void *buffer, long len) { struct isp116x *isp116x = &isp116x_dev; @@ -862,23 +854,22 @@ retry: isp116x_write_reg32(isp116x, HCINTSTAT, 0xff); /* Prepare the PTD data */ ptd->count = PTD_CC_MSK | PTD_ACTIVE_MSK | PTD_TOGGLE(usb_gettoggle(dev, epnum, dir_out)); ptd->mps = PTD_MPS(max) | PTD_SPD(speed_low) | PTD_EP(epnum) | PTD_LAST_MSK; ptd->len = PTD_LEN(len) | PTD_DIR(dir); ptd->faddr = PTD_FA(usb_pipedevice(pipe)); - retry_same: /* FIFO not empty? */ if (isp116x_read_reg16(isp116x, HCBUFSTAT) & HCBUFSTAT_ATL_FULL) { - DEBUG(("****** FIFO not empty! ******")); + DEBUG(("****** FIFO not empty! (2) ******")); dev->status = USB_ST_BUF_ERR; return -1; } /* Pack data into FIFO ram */ pack_fifo(isp116x, dev, pipe, ptd, 1, buffer, len); # ifdef EXTRA_DELAY @@ -935,41 +926,40 @@ retry_same: * FIXME! NOTE! AAAARGH! * This is potentially dangerous because it assumes * that only one device is ever plugged in! */ devgone = dev; } } - /* Ok, now we can read transfer status */ /* FIFO not ready? */ if (!(isp116x_read_reg16(isp116x, HCBUFSTAT) & HCBUFSTAT_ATL_DONE)) { DEBUG(("****** FIFO not ready! ******")); dev->status = USB_ST_BUF_ERR; return -1; } + /* Unpack data from FIFO ram */ cc = unpack_fifo(isp116x, dev, pipe, ptd, 1, buffer, len); i = PTD_GET_COUNT(ptd); done += i; buffer = (char *)buffer + i; len -= i; - /* There was some kind of real problem; Prepare the PTD again * and retry from the failed transaction on */ if (cc && cc != TD_NOTACCESSED && cc != TD_DATAUNDERRUN) { - DEBUG(("PROBLEM cc: %d", cc)); + DEBUG(("PROBLEM cc: %ld", cc)); if (retries >= 100) { retries -= 100; /* The chip will have toggled the toggle bit for the failed * transaction too. We have to toggle it back. */ usb_settoggle(dev, epnum, dir_out, !PTD_GET_TOGGLE(ptd)); goto retry; @@ -991,20 +981,19 @@ retry_same: set_extra_delay = 1; goto retry_same; } usb_settoggle(dev, epnum, dir_out, PTD_GET_TOGGLE(ptd)); goto retry; } } - if (cc != TD_CC_NOERROR && cc != TD_DATAUNDERRUN) { - DEBUG(("****** completition code error %x ******", cc)); + DEBUG(("****** completion code error %lx ******", cc)); switch (cc) { case TD_CC_BITSTUFFING: dev->status = USB_ST_BIT_ERR; break; case TD_CC_STALL: dev->status = USB_ST_STALLED; break; @@ -1137,41 +1126,41 @@ isp116x_submit_rh_msg(struct usb_device case RH_CLEAR_FEATURE | RH_OTHER | RH_CLASS: DEBUG(("RH_CLEAR_FEATURE | RH_OTHER | RH_CLASS")); switch (wValue) { case RH_PORT_ENABLE: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, - RH_PS_CCS); + RH_PS_CCS); len = 0; break; case RH_PORT_SUSPEND: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, - RH_PS_POCI); + RH_PS_POCI); len = 0; break; case RH_PORT_POWER: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, - RH_PS_LSDA); + RH_PS_LSDA); len = 0; break; case RH_C_PORT_CONNECTION: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, RH_PS_CSC); len = 0; break; case RH_C_PORT_ENABLE: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, - RH_PS_PESC); + RH_PS_PESC); len = 0; break; case RH_C_PORT_SUSPEND: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, RH_PS_PSSC); len = 0; break; @@ -1198,45 +1187,45 @@ isp116x_submit_rh_msg(struct usb_device case RH_SET_FEATURE | RH_OTHER | RH_CLASS: DEBUG(("RH_SET_FEATURE | RH_OTHER | RH_CLASS")); switch (wValue) { case RH_PORT_SUSPEND: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, - RH_PS_PSS); + RH_PS_PSS); len = 0; break; case RH_PORT_RESET: /* Spin until any current reset finishes */ while (1) { tmp = isp116x_read_reg32(isp116x, HCRHPORT1 + wIndex - 1); if (!(tmp & RH_PS_PRS)) break; mdelay(1); } isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, - RH_PS_PRS); + RH_PS_PRS); mdelay(10); len = 0; break; case RH_PORT_POWER: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, RH_PS_PPS); len = 0; break; case RH_PORT_ENABLE: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, - RH_PS_PES); + RH_PS_PES); len = 0; break; default: ALERT(("invalid wValue")); stat = USB_ST_STALLED; } isp116x_show_regs(isp116x); @@ -1251,41 +1240,41 @@ isp116x_submit_rh_msg(struct usb_device case RH_GET_DESCRIPTOR: DEBUG(("RH_GET_DESCRIPTOR: %x, %d", wValue, wLength)); switch (wValue) { case (USB_DT_DEVICE << 8): /* device descriptor */ len = min1_t(unsigned long, - leni, min2_t(unsigned long, + leni, min2_t(unsigned long, sizeof(root_hub_dev_des), wLength)); data_buf = root_hub_dev_des; break; case (USB_DT_CONFIG << 8): /* configuration descriptor */ len = min1_t(unsigned long, - leni, min2_t(unsigned long, + leni, min2_t(unsigned long, sizeof(root_hub_config_des), wLength)); data_buf = root_hub_config_des; break; case ((USB_DT_STRING << 8) | 0x00): /* string 0 descriptors */ len = min1_t(unsigned long, - leni, min2_t(unsigned long, + leni, min2_t(unsigned long, sizeof(root_hub_str_index0), wLength)); data_buf = root_hub_str_index0; break; case ((USB_DT_STRING << 8) | 0x01): /* string 1 descriptors */ len = min1_t(unsigned long, - leni, min2_t(unsigned long, + leni, min2_t(unsigned long, sizeof(root_hub_str_index1), wLength)); data_buf = root_hub_str_index1; break; default: ALERT(("invalid wValue")); stat = USB_ST_STALLED; @@ -1320,17 +1309,17 @@ isp116x_submit_rh_msg(struct usb_device else { data_buf[0] += 2; data_buf[8] = (tmp & RH_B_DR) >> 8; data_buf[10] = data_buf[9] = 0xff; } len = min1_t(unsigned long, leni, - min2_t(unsigned long, data_buf[0], wLength)); + min2_t(unsigned long, data_buf[0], wLength)); break; case RH_GET_CONFIGURATION: DEBUG(("RH_GET_CONFIGURATION")); *(unsigned char *) data_buf = 0x01; len = 1; break; @@ -1359,27 +1348,27 @@ isp116x_submit_rh_msg(struct usb_device return stat; } /* --- Transfer functions -------------------------------------------------- */ long submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, - long len, long interval) + long len, long interval) { DEBUG(("dev=0x%lx pipe=%lx buf=0x%lx size=%d int=%d", - dev, pipe, buffer, len, interval)); + dev, pipe, buffer, len, interval)); return -1; } long submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, - long len, struct devrequest *setup) + long len, struct devrequest *setup) { long devnum = usb_pipedevice(pipe); long epnum = usb_pipeendpoint(pipe); long max = max_transfer_len(dev, pipe); long dir_in = usb_pipein(pipe); long done, ret; @@ -1439,25 +1428,25 @@ submit_control_msg(struct usb_device *de dump_msg(dev, pipe, buffer, len, "DEV(ret)"); return done; } long submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, - long len) + long len) { long dir_out = usb_pipeout(pipe); long max = max_transfer_len(dev, pipe); long done, ret; DEBUG(("--- BULK ---------------------------------------")); DEBUG(("dev=%ld pipe=%ld buf=0x%lx size=%d dir_out=%d", - usb_pipedevice(pipe), usb_pipeendpoint(pipe), buffer, len, dir_out)); + usb_pipedevice(pipe), usb_pipeendpoint(pipe), buffer, len, dir_out)); done = 0; while (done < len) { ret = isp116x_submit_job(dev, pipe, !dir_out ? PTD_DIR_IN : PTD_DIR_OUT, (unsigned char *) buffer + done, max > len - done ? len - done : max); @@ -1559,20 +1548,20 @@ isp116x_reset(struct isp116x *isp116x) { clkrdy = isp116x_read_reg16(isp116x, HCuPINT) & HCuPINT_CLKRDY; if (clkrdy) break; mdelay(1); } if (!clkrdy) { - ALERT(("clock not ready after %dms", timeout)); + ALERT(("clock not ready after %ldms", timeout)); /* After sw_reset the clock won't report to be ready, if H_WAKEUP pin is high. */ - ALERT(("please make sure that the H_WAKEUP pin is pulled low!")); + DEBUG(("please make sure that the H_WAKEUP pin is pulled low!")); ret = -1; } return ret; } static void isp116x_stop(struct isp116x *isp116x) { @@ -1590,17 +1579,17 @@ isp116x_stop(struct isp116x *isp116x) val &= ~(RH_A_NPS | RH_A_PSM); isp116x_write_reg32(isp116x, HCRHDESCA, val); isp116x_write_reg32(isp116x, HCRHSTATUS, RH_HS_LPS); isp116x_sw_reset(isp116x); } static void -int_handle_tophalf (PROC *process, long arg) +int_handle_tophalf(PROC *process, long arg) { struct isp116x *isp116x = &isp116x_dev; if (isp116x->rhport[0] & RH_PS_CSC) { (*uinf->usb_rh_wakeup)(); } @@ -1626,25 +1615,25 @@ ethernat_int(void) set_old_int_lvl(); if (irqstat & HCuPINT_OPR) { intstat = isp116x_read_reg32(isp116x, HCINTSTAT); isp116x_write_reg32(isp116x, HCINTSTAT, intstat); - if (intstat & HCINT_RHSC) + if (intstat & HCINT_RHSC) { isp116x->rhstatus = isp116x_read_reg32(isp116x, HCRHSTATUS); isp116x->rhport[0] = isp116x_read_reg32(isp116x, HCRHPORT1); isp116x->rhport[1] = isp116x_read_reg32(isp116x, HCRHPORT2); addroottimeout (0L, int_handle_tophalf, 0x1); } - } + } isp116x_write_reg16(isp116x, HCuPINTENB, HCuPINT_OPR); set_int_lvl6(); /* Enable CPLD USB interrupt again */ *ETHERNAT_CPLD_CR = (*ETHERNAT_CPLD_CR) | 0x04; } @@ -1733,29 +1722,29 @@ isp116x_start(struct isp116x *isp116x) isp116x->disabled = 0; return 0; } /* --- Inteface functions -------------------------------------------------- */ static long _cdecl -ethernat_open (struct ucdif *u) +ethernat_open(struct ucdif *u) { return E_OK; } static long _cdecl -ethernat_close (struct ucdif *u) +ethernat_close(struct ucdif *u) { return E_OK; } static long _cdecl -ethernat_ioctl (struct ucdif *u, short cmd, long arg) +ethernat_ioctl(struct ucdif *u, short cmd, long arg) { long ret = E_OK; switch (cmd) { case FS_INFO: { *(long *)arg = (((long)VER_MAJOR << 16) | VER_MINOR); @@ -1771,35 +1760,36 @@ ethernat_ioctl (struct ucdif *u, short c ret = usb_lowlevel_stop (); break; } case SUBMIT_CONTROL_MSG : { struct control_msg *ctrl_msg = (struct control_msg *)arg; ret = submit_control_msg (ctrl_msg->dev, ctrl_msg->pipe, - ctrl_msg->data, ctrl_msg->size, ctrl_msg->setup); + ctrl_msg->data, ctrl_msg->size, + ctrl_msg->setup); break; } case SUBMIT_BULK_MSG : { struct bulk_msg *bulk_msg = (struct bulk_msg *)arg; ret = submit_bulk_msg (bulk_msg->dev, bulk_msg->pipe, - bulk_msg->data, bulk_msg->len); + bulk_msg->data, bulk_msg->len); break; } case SUBMIT_INT_MSG : { struct int_msg *int_msg = (struct int_msg *)arg; ret = submit_int_msg(int_msg->dev, int_msg->pipe, - int_msg->buffer, int_msg->transfer_len, - int_msg->interval); + int_msg->buffer, int_msg->transfer_len, + int_msg->interval); break; } default: { return ENOSYS; } } @@ -1822,17 +1812,16 @@ isp116x_check_id(struct isp116x *isp116x { ALERT(("invalid chip ID %04x", val)); return -1; } return 0; } - long usb_lowlevel_init(long dummy1, const struct pci_device_id *dummy2) { // unsigned short val; struct isp116x *isp116x = &isp116x_dev; got_rhsc = rh_devnum = 0; @@ -1889,26 +1878,26 @@ usb_lowlevel_stop(void) if (!isp116x->disabled) isp116x_stop(isp116x); return 0; } void -ethernat_probe_c (void) +ethernat_probe_c(void) { if (!((*ETHERNAT_CPLD_CR) == (*ETHERNAT_CPLD_CR))) return; found = 1; } long _cdecl -init (struct kentry *k, struct ucdinfo *uinfo, char **reason) +init(struct kentry *k, struct ucdinfo *uinfo, char **reason) { long ret; short sr; kentry = k; uinf = uinfo; if (check_kentry_version()) Index: sys/usb/src.km/ucd/ethernat/isp116x.h =================================================================== RCS file: /mint/freemint/sys/usb/src.km/ucd/ethernat/isp116x.h,v retrieving revision 1.3 diff -u -8 -p -r1.3 isp116x.h --- sys/usb/src.km/ucd/ethernat/isp116x.h 6 Mar 2013 21:03:59 -0000 1.3 +++ sys/usb/src.km/ucd/ethernat/isp116x.h 11 Mar 2013 16:57:26 -0000 @@ -450,17 +450,17 @@ static inline void isp116x_write_data32( { writew(val & 0xffff, isp116x->data_reg); isp116x_delay(isp116x, UDELAY); writew(val >> 16, isp116x->data_reg); isp116x_delay(isp116x, UDELAY); } /* - * Added for EtherNat, to write HC registers without swaping them + * Added for EtherNat, to write HC registers without swapping them * EtherNat already swap them by hardware (i suppose.....) */ static inline void isp116x_raw_write_data32(struct isp116x *isp116x, unsigned long val) { __raw_writew(val & 0xffff, isp116x->data_reg); isp116x_delay(isp116x, UDELAY); __raw_writew(val >> 16, isp116x->data_reg); isp116x_delay(isp116x, UDELAY); @@ -475,17 +475,17 @@ static inline unsigned long isp116x_read isp116x_delay(isp116x, UDELAY); val |= ((unsigned long) readw(isp116x->data_reg)) << 16; isp116x_delay(isp116x, UDELAY); return val; } /* - * Added for EtherNat, to read HC registers without swaping them + * Added for EtherNat, to read HC registers without swapping them * EtherNat already swap them by hardware (i suppose.....) */ static inline unsigned long isp116x_raw_read_data32(struct isp116x *isp116x) { unsigned long val; val = (unsigned long) __raw_readw(isp116x->data_reg); isp116x_delay(isp116x, UDELAY); @@ -495,17 +495,17 @@ static inline unsigned long isp116x_raw_ return val; } /*******************************************************************/ /* Let's keep register access functions out of line. Hint: we wait at least 150 ns at every access. */ -/* with EtherNat use raw_read to avoid swaping bytes*/ +/* with EtherNat use raw_read to avoid swapping bytes*/ static unsigned short isp116x_read_reg16(struct isp116x *isp116x, unsigned reg) { isp116x_write_addr(isp116x, reg); return isp116x_raw_read_data16(isp116x); } static unsigned long isp116x_read_reg32(struct isp116x *isp116x, unsigned long reg) @@ -516,17 +516,17 @@ static unsigned long isp116x_read_reg32( static void isp116x_write_reg16(struct isp116x *isp116x, unsigned reg, unsigned val) { isp116x_write_addr(isp116x, reg | ISP116x_WRITE_OFFSET); isp116x_raw_write_data16(isp116x, (unsigned short) (val & 0xffff)); } -/* with Etehrnat used raw_write to avoid swaping bytes by software */ +/* with Etehrnat used raw_write to avoid swapping bytes by software */ static void isp116x_write_reg32(struct isp116x *isp116x, unsigned long reg, unsigned long val) { isp116x_write_addr(isp116x, reg | ISP116x_WRITE_OFFSET); isp116x_raw_write_data32(isp116x, (unsigned long) val); } /* --- USB HUB constants (not OHCI-specific; see hub.h) -------------------- */ Index: sys/usb/src.km/ucd/netusbee/isp116x-hcd.c =================================================================== RCS file: /mint/freemint/sys/usb/src.km/ucd/netusbee/isp116x-hcd.c,v retrieving revision 1.3 diff -u -8 -p -r1.3 isp116x-hcd.c --- sys/usb/src.km/ucd/netusbee/isp116x-hcd.c 6 Mar 2013 21:04:01 -0000 1.3 +++ sys/usb/src.km/ucd/netusbee/isp116x-hcd.c 11 Mar 2013 16:57:29 -0000 @@ -67,19 +67,19 @@ #include "../../config.h" #include "../../endian/io.h" #include "../../usb.h" #include "../ucd_defs.h" #include "netusbee_int.h" #define VER_MAJOR 0 #define VER_MINOR 1 -#define VER_STATUS +#define VER_STATUS -#define MSG_VERSION str (VER_MAJOR) "." str (VER_MINOR) str (VER_STATUS) +#define MSG_VERSION str (VER_MAJOR) "." str (VER_MINOR) str (VER_STATUS) #define MSG_BUILDDATE __DATE__ #define MSG_BOOT \ "\033p NetUSBee USB controller driver " MSG_VERSION " \033q\r\n" #define MSG_GREET \ "Ported, mixed and shaken by David Galvez.\r\n" \ "Compiled " MSG_BUILDDATE ".\r\n\r\n" @@ -95,28 +95,28 @@ */ #if 0 # define DEV_DEBUG 1 #endif #ifdef DEV_DEBUG -# define FORCE(x) +# define FORCE(x) # define ALERT(x) KERNEL_ALERT x # define DEBUG(x) KERNEL_DEBUG x # define TRACE(x) KERNEL_TRACE x # define ASSERT(x) assert x #else -# define FORCE(x) +# define FORCE(x) # define ALERT(x) KERNEL_ALERT x -# define DEBUG(x) -# define TRACE(x) +# define DEBUG(x) +# define TRACE(x) # define ASSERT(x) assert x #endif /* * Enable the following defines if you wish enable extra debugging messages. */ #ifdef DEV_DEBUG @@ -143,27 +143,27 @@ struct isp116x isp116x_dev; struct isp116x_platform_data isp116x_board; static long got_rhsc; /* root hub status change */ struct usb_device *devgone; /* device which was disconnected */ static long rh_devnum; /* address of Root Hub endpoint */ /* * interrupt handling - bottom half */ -void _cdecl netusbee_int (void); +void _cdecl netusbee_int (void); /* * interrupt handling - top half */ static void int_handle_tophalf (PROC *p, long arg); -/* +/* *Function prototypes */ long isp116x_check_id (struct isp116x *); -static long isp116x_reset (struct isp116x *); +static long isp116x_reset (struct isp116x *); long submit_bulk_msg (struct usb_device *, unsigned long , void *, long); long submit_control_msg (struct usb_device *, unsigned long, void *, long, struct devrequest *); long submit_int_msg (struct usb_device *, unsigned long, void *, long, long); long _cdecl init (struct kentry *, struct ucdinfo *, char **); /* @@ -171,17 +171,17 @@ long _cdecl init (struct kentry *, str */ static long _cdecl netusbee_open (struct ucdif *); static long _cdecl netusbee_close (struct ucdif *); static long _cdecl netusbee_ioctl (struct ucdif *, short, long); static char lname[] = "NetUSBee USB controller driver for FreeMiNT\0"; -static struct ucdif netusbee_uif = +static struct ucdif netusbee_uif = { 0, /* *next */ USB_CONTRLL, /* class */ lname, /* lname */ "netusbee", /* name */ 0, /* unit */ 0, /* flags */ netusbee_open, /* open */ @@ -249,37 +249,36 @@ static struct ucdif netusbee_uif = isp116x_show_reg(d, HCATLBUFLEN); \ isp116x_show_reg(d, HCBUFSTAT); \ isp116x_show_reg(d, HCRDITL0LEN); \ isp116x_show_reg(d, HCRDITL1LEN); \ } #if defined(TRACE_EXTRA) -#if 0 + static long isp116x_get_current_frame_number(struct usb_device *usb_dev) { struct isp116x *isp116x = &isp116x_dev; return isp116x_read_reg32(isp116x, HCFMNUM); } -#endif static void dump_msg(struct usb_device *dev, unsigned long pipe, void *buffer, long len, char *str) { #if defined(VERBOSE) long i; char build_str[64]; char buf[(len * 4) + 24 + 6]; #endif DEBUG(("%s URB:[%4lx] dev:%2ld,ep:%2ld-%c,type:%s,len:%ld stat:0x%lx", - str, isp116x_get_current_frame_number(dev), + str, isp116x_get_current_frame_number(dev), usb_pipedevice(pipe), usb_pipeendpoint(pipe), usb_pipeout(pipe) ? 'O' : 'I', usb_pipetype(pipe) < 2 ? (usb_pipeint(pipe) ? "INTR" : "ISOC") : (usb_pipecontrol(pipe) ? "CTRL" : "BULK"), len, dev->status)); #if defined(VERBOSE) @@ -287,17 +286,17 @@ dump_msg(struct usb_device *dev, unsigne if (len > 0 && buffer) { sprintf(build_str, sizeof(build_str), __FILE__ ": data(%ld):", len); strcat(buf, build_str); for (i = 0; i < 16 && i < len; i++) { sprintf(build_str, sizeof(build_str), " %02x", ((unsigned char *) buffer)[i]); strcat(buf, build_str); - } + } sprintf(build_str, sizeof(build_str), "%s\r\n", i < len ? "..." : ""); strcat(buf, build_str); DEBUG((buf)); } #endif } # define PTD_DIR_STR(ptd) ({char __c; \ @@ -341,17 +340,17 @@ dump_ptd(struct ptd *ptd) static inline void dump_ptd_data(struct ptd *ptd, unsigned char * buffer, long type) { #if defined(VERBOSE) long k; char build_str[64]; char buf[64 + 4 * PTD_GET_LEN(ptd)]; - + sprintf(buf, sizeof(buf),"\0"); if (type == 0 /* 0ut data */ ) { sprintf(build_str, sizeof(build_str), "isp116x: %s: out data: ", __FUNCTION__); strcat(buf, build_str); for (k = 0; k < PTD_GET_LEN(ptd); ++k) { sprintf(build_str, sizeof(build_str), "%02x ", ((unsigned char *) buffer)[k]); @@ -365,18 +364,18 @@ dump_ptd_data(struct ptd *ptd, unsigned strcat(buf, build_str); for (k = 0; k < PTD_GET_COUNT(ptd); ++k) { sprintf(build_str, sizeof(build_str), "%02x ", ((unsigned char *) buffer)[k]); strcat(buf, build_str); } DEBUG((buf)); } - - + + if (PTD_GET_LAST(ptd)) { DEBUG(("--- last PTD ---")); } #endif } #else @@ -530,22 +529,22 @@ rh_check_port_status(struct isp116x *isp */ static void write_ptddata_to_fifo(struct isp116x *isp116x, void *buf, long len) { unsigned char *dp = (unsigned char *) buf; unsigned short *dp2 = (unsigned short *) buf; unsigned short w; long quot = len % 4; - + /* For NetUSBee, take the raw_write out in write functions, here we don't * like that NetUSBee swap the bytes for us, so we swap them before we send * them, then the bytes will arrive to the USB device with the correct positions */ - if ((unsigned long)dp2 & 1) + if ((unsigned long)dp2 & 1) { /* not aligned */ for (; len > 1; len -= 2) { w = *dp++; w |= *dp++ << 8; isp116x_write_data16(isp116x, w); } @@ -593,17 +592,16 @@ read_ptddata_from_fifo(struct isp116x *i } else { /* aligned */ for (; len > 1; len -= 2) *dp2++ = isp116x_read_data16(isp116x); if (len) *(unsigned char *) dp2 = 0xff & isp116x_raw_read_data16(isp116x); - } if (quot == 1 || quot == 2) isp116x_read_data16(isp116x); } /* Write PTD's and data for scheduled transfers into the fifo ram. * Fifo must be empty and ready */ @@ -611,36 +609,36 @@ static void pack_fifo(struct isp116x *isp116x, struct usb_device *dev, unsigned long pipe, struct ptd *ptd, long n, void *data, long len) { long buflen = n * sizeof(struct ptd) + len; long i, done; DEBUG(("--- pack buffer 0x%08lx - %ld bytes (fifo %ld) ---", data, len, buflen)); - + isp116x_write_reg16(isp116x, HCuPINT, HCuPINT_AIIEOT); - + isp116x_write_reg16(isp116x, HCXFERCTR, buflen); set_int_lvl7(); isp116x_write_addr(isp116x, HCATLPORT | ISP116x_WRITE_OFFSET); done = 0; for (i = 0; i < n; i++) { - //DEBUG(("i=%ld - done=%ld - len=%d", i, done, PTD_GET_LEN(&ptd[i]))); + DEBUG(("i=%ld - done=%ld - len=%d", i, done, PTD_GET_LEN(&ptd[i]))); /* For NetUSBee, use raw_write to don't swap bytes */ -// dump_ptd(&ptd[i]); + dump_ptd(&ptd[i]); isp116x_raw_write_data16(isp116x, ptd[i].count); isp116x_raw_write_data16(isp116x, ptd[i].mps); isp116x_raw_write_data16(isp116x, ptd[i].len); isp116x_raw_write_data16(isp116x, ptd[i].faddr); -// dump_ptd_data(&ptd[i], (unsigned char *) data + done, 0); + dump_ptd_data(&ptd[i], (unsigned char *) data + done, 0); /* This part is critical, disamble interrupts */ // set_int_lvl7(); write_ptddata_to_fifo(isp116x, (unsigned char *) data + done, PTD_GET_LEN(&ptd[i])); // set_old_int_lvl(); @@ -663,24 +661,24 @@ unpack_fifo(struct isp116x *isp116x, str isp116x_write_reg16(isp116x, HCuPINT, HCuPINT_AIIEOT); isp116x_write_reg16(isp116x, HCXFERCTR, buflen); set_int_lvl7(); isp116x_write_addr(isp116x, HCATLPORT); ret = TD_CC_NOERROR; done = 0; for (i = 0; i < n; i++) - { + { /* For NetUSBee, use raw_read to don't swap bytes */ ptd[i].count = isp116x_raw_read_data16(isp116x); ptd[i].mps = isp116x_raw_read_data16(isp116x); ptd[i].len = isp116x_raw_read_data16(isp116x); ptd[i].faddr = isp116x_raw_read_data16(isp116x); -// dump_ptd(&ptd[i]); - + dump_ptd(&ptd[i]); + /* when cc is 15 the data has not being touch by the HC * so we have to read all to empty completly the buffer */ if (PTD_GET_COUNT(ptd) != 0 || PTD_GET_CC(ptd) == 15 || PTD_GET_CC(ptd) == 5 || PTD_GET_CC(ptd) == 6) { /* This part is critical, disamble interrupts */ // set_int_lvl7(); @@ -688,17 +686,17 @@ unpack_fifo(struct isp116x *isp116x, str (unsigned char *) data + done, PTD_GET_LEN(&ptd[i])); // set_old_int_lvl(); } dump_ptd_data(&ptd[i], (unsigned char *) data + done, 1); done += PTD_GET_LEN(&ptd[i]); - + cc = PTD_GET_CC(&ptd[i]); /* Data underrun means basically that we had more buffer space than * the function had data. It is perfectly normal but upper levels have * to know how much we actually transferred. */ if (cc == TD_NOTACCESSED || (cc != TD_CC_NOERROR && (ret == TD_CC_NOERROR || ret == TD_DATAUNDERRUN))) @@ -719,17 +717,17 @@ isp116x_interrupt(struct isp116x *isp116 unsigned short irqstat; unsigned long intstat; long ret = 0; isp116x_write_reg16(isp116x, HCuPINTENB, 0); irqstat = isp116x_read_reg16(isp116x, HCuPINT); isp116x_write_reg16(isp116x, HCuPINT, irqstat); DEBUG((">>>>>> irqstat %x <<<<<<", irqstat)); - + if (irqstat & HCuPINT_ATL) { DEBUG((">>>>>> HCuPINT_ATL <<<<<<")); udelay(500); ret = 1; } if (irqstat & HCuPINT_OPR) @@ -779,24 +777,23 @@ isp116x_interrupt(struct isp116x *isp116 * HC does the splitting into endpoint digestible transactions */ struct ptd ptd[1]; static inline long max_transfer_len(struct usb_device *dev, unsigned long pipe) { unsigned mpck = (*uinf->usb_maxpacket)(dev, pipe); - + /* One PTD can transfer 1023 bytes but try to always * transfer multiples of endpoint buffer size */ return 1023 / mpck * mpck; } - /* Do an USB transfer */ static long isp116x_submit_job(struct usb_device *dev, unsigned long pipe, long dir, void *buffer, long len) { struct isp116x *isp116x = &isp116x_dev; long type = usb_pipetype(pipe); @@ -808,17 +805,17 @@ isp116x_submit_job(struct usb_device *de /* 500 frames or 0.5s timeout when function is busy and NAKs transactions for a while */ long retries = 500; short set_extra_delay = 0; DEBUG(("------------------------------------------------")); dump_msg(dev, pipe, buffer, len, "SUBMIT"); DEBUG(("------------------------------------------------")); - + if (len >= 1024) { ALERT(("Too big job")); dev->status = USB_ST_CRC_ERR; return -1; } if (isp116x->disabled) @@ -844,17 +841,17 @@ isp116x_submit_job(struct usb_device *de } if (type == PIPE_ISOCHRONOUS) { ALERT(("isochronous transfers not supported")); dev->status = USB_ST_CRC_ERR; return -1; } - + /* FIFO not empty? */ if (isp116x_read_reg16(isp116x, HCBUFSTAT) & HCBUFSTAT_ATL_FULL) { DEBUG(("****** FIFO not empty! ******")); dev->status = USB_ST_BUF_ERR; return -1; } @@ -862,23 +859,22 @@ retry: isp116x_write_reg32(isp116x, HCINTSTAT, 0xff); /* Prepare the PTD data */ ptd->count = PTD_CC_MSK | PTD_ACTIVE_MSK | PTD_TOGGLE(usb_gettoggle(dev, epnum, dir_out)); ptd->mps = PTD_MPS(max) | PTD_SPD(speed_low) | PTD_EP(epnum) | PTD_LAST_MSK; ptd->len = PTD_LEN(len) | PTD_DIR(dir); ptd->faddr = PTD_FA(usb_pipedevice(pipe)); - retry_same: /* FIFO not empty? */ if (isp116x_read_reg16(isp116x, HCBUFSTAT) & HCBUFSTAT_ATL_FULL) { - DEBUG(("****** FIFO not empty! 2 ******")); + DEBUG(("****** FIFO not empty! (2) ******")); dev->status = USB_ST_BUF_ERR; return -1; } /* Pack data into FIFO ram */ pack_fifo(isp116x, dev, pipe, ptd, 1, buffer, len); # ifdef EXTRA_DELAY @@ -937,17 +933,16 @@ retry_same: * FIXME! NOTE! AAAARGH! * This is potentially dangerous because it assumes * that only one device is ever plugged in! */ devgone = dev; } } - /* Ok, now we can read transfer status */ /* FIFO not ready? */ if (!(isp116x_read_reg16(isp116x, HCBUFSTAT) & HCBUFSTAT_ATL_DONE)) { DEBUG(("****** FIFO not ready! ******")); dev->status = USB_ST_BUF_ERR; return -1; @@ -955,18 +950,17 @@ retry_same: /* Unpack data from FIFO ram */ cc = unpack_fifo(isp116x, dev, pipe, ptd, 1, buffer, len); i = PTD_GET_COUNT(ptd); done += i; buffer = (char *)buffer + i; len -= i; - - + /* There was some kind of real problem; Prepare the PTD again * and retry from the failed transaction on */ if (cc && cc != TD_NOTACCESSED && cc != TD_DATAUNDERRUN) { DEBUG(("PROBLEM cc: %ld", cc)); if (retries >= 100) { @@ -989,17 +983,16 @@ retry_same: if (retries) { --retries; if (cc == TD_NOTACCESSED && PTD_GET_ACTIVE(ptd) && !PTD_GET_COUNT(ptd)) { set_extra_delay = 1; goto retry_same; } - DEBUG(("cc == TD_NOTACCESSED || PTD_GET_ACTIVE(ptd) retry")); usb_settoggle(dev, epnum, dir_out, PTD_GET_TOGGLE(ptd)); goto retry; } } if (cc != TD_CC_NOERROR && cc != TD_DATAUNDERRUN) { DEBUG(("****** completion code error %lx ******", cc)); @@ -1021,17 +1014,16 @@ retry_same: return -cc; } else usb_settoggle(dev, epnum, dir_out, PTD_GET_TOGGLE(ptd)); dump_msg(dev, pipe, buffer, len, "SUBMIT(ret)"); dev->status = 0; - return done; } /* Adapted from au1x00_usb_ohci.c */ static long isp116x_submit_rh_msg(struct usb_device *dev, unsigned long pipe, void *buffer, long transfer_len, @@ -1140,41 +1132,41 @@ isp116x_submit_rh_msg(struct usb_device case RH_CLEAR_FEATURE | RH_OTHER | RH_CLASS: DEBUG(("RH_CLEAR_FEATURE | RH_OTHER | RH_CLASS")); switch (wValue) { case RH_PORT_ENABLE: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, - RH_PS_CCS); + RH_PS_CCS); len = 0; break; case RH_PORT_SUSPEND: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, - RH_PS_POCI); + RH_PS_POCI); len = 0; break; case RH_PORT_POWER: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, - RH_PS_LSDA); + RH_PS_LSDA); len = 0; break; case RH_C_PORT_CONNECTION: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, RH_PS_CSC); len = 0; break; case RH_C_PORT_ENABLE: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, - RH_PS_PESC); + RH_PS_PESC); len = 0; break; case RH_C_PORT_SUSPEND: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, RH_PS_PSSC); len = 0; break; @@ -1201,45 +1193,45 @@ isp116x_submit_rh_msg(struct usb_device case RH_SET_FEATURE | RH_OTHER | RH_CLASS: DEBUG(("RH_SET_FEATURE | RH_OTHER | RH_CLASS")); switch (wValue) { case RH_PORT_SUSPEND: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, - RH_PS_PSS); + RH_PS_PSS); len = 0; break; case RH_PORT_RESET: /* Spin until any current reset finishes */ while (1) { tmp = isp116x_read_reg32(isp116x, HCRHPORT1 + wIndex - 1); if (!(tmp & RH_PS_PRS)) break; mdelay(1); } isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, - RH_PS_PRS); + RH_PS_PRS); mdelay(10); len = 0; break; case RH_PORT_POWER: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, RH_PS_PPS); len = 0; break; case RH_PORT_ENABLE: isp116x_write_reg32(isp116x, HCRHPORT1 + wIndex - 1, - RH_PS_PES); + RH_PS_PES); len = 0; break; default: ALERT(("invalid wValue")); stat = USB_ST_STALLED; } isp116x_show_regs(isp116x); @@ -1254,41 +1246,41 @@ isp116x_submit_rh_msg(struct usb_device case RH_GET_DESCRIPTOR: DEBUG(("RH_GET_DESCRIPTOR: %x, %d", wValue, wLength)); switch (wValue) { case (USB_DT_DEVICE << 8): /* device descriptor */ len = min1_t(unsigned long, - leni, min2_t(unsigned long, + leni, min2_t(unsigned long, sizeof(root_hub_dev_des), wLength)); data_buf = root_hub_dev_des; break; case (USB_DT_CONFIG << 8): /* configuration descriptor */ len = min1_t(unsigned long, - leni, min2_t(unsigned long, + leni, min2_t(unsigned long, sizeof(root_hub_config_des), wLength)); data_buf = root_hub_config_des; break; case ((USB_DT_STRING << 8) | 0x00): /* string 0 descriptors */ len = min1_t(unsigned long, - leni, min2_t(unsigned long, + leni, min2_t(unsigned long, sizeof(root_hub_str_index0), wLength)); data_buf = root_hub_str_index0; break; case ((USB_DT_STRING << 8) | 0x01): /* string 1 descriptors */ len = min1_t(unsigned long, - leni, min2_t(unsigned long, + leni, min2_t(unsigned long, sizeof(root_hub_str_index1), wLength)); data_buf = root_hub_str_index1; break; default: ALERT(("invalid wValue")); stat = USB_ST_STALLED; @@ -1323,17 +1315,17 @@ isp116x_submit_rh_msg(struct usb_device else { data_buf[0] += 2; data_buf[8] = (tmp & RH_B_DR) >> 8; data_buf[10] = data_buf[9] = 0xff; } len = min1_t(unsigned long, leni, - min2_t(unsigned long, data_buf[0], wLength)); + min2_t(unsigned long, data_buf[0], wLength)); break; case RH_GET_CONFIGURATION: DEBUG(("RH_GET_CONFIGURATION")); *(unsigned char *) data_buf = 0x01; len = 1; break; @@ -1362,46 +1354,46 @@ isp116x_submit_rh_msg(struct usb_device return stat; } /* --- Transfer functions -------------------------------------------------- */ long submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, - long len, long interval) + long len, long interval) { DEBUG(("dev=0x%lx pipe=%lx buf=0x%lx size=%d int=%d", dev, pipe, buffer, len, interval)); return -1; } long submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, - long len, struct devrequest *setup) + long len, struct devrequest *setup) { long devnum = usb_pipedevice(pipe); long epnum = usb_pipeendpoint(pipe); long max = max_transfer_len(dev, pipe); long dir_in = usb_pipein(pipe); long done, ret; - - + + /* Control message is for the HUB? */ if (devnum == rh_devnum) return isp116x_submit_rh_msg(dev, pipe, buffer, len, setup); /* Ok, no HUB message so send the message to the device */ /* Setup phase */ DEBUG(("--- SETUP PHASE --------------------------------")); usb_settoggle(dev, epnum, 1, 0); - - + + ret = isp116x_submit_job(dev, pipe, PTD_DIR_SETUP, setup, sizeof(struct devrequest)); if (ret < 0) { DEBUG(("control setup phase error (ret = %d", ret)); return -1; } @@ -1444,25 +1436,25 @@ submit_control_msg(struct usb_device *de return done; } short flagy = 0; long submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, - long len) + long len) { long dir_out = usb_pipeout(pipe); long max = max_transfer_len(dev, pipe); long done, ret; - + DEBUG(("--- BULK ---------------------------------------")); DEBUG(("dev=%ld pipe=%ld buf=0x%lx size=%d dir_out=%d", - usb_pipedevice(pipe), usb_pipeendpoint(pipe), buffer, len, dir_out)); + usb_pipedevice(pipe), usb_pipeendpoint(pipe), buffer, len, dir_out)); done = 0; while (done < len) { ret = isp116x_submit_job(dev, pipe, !dir_out ? PTD_DIR_IN : PTD_DIR_OUT, (unsigned char *) buffer + done, max > len - done ? len - done : max); @@ -1509,37 +1501,37 @@ isp116x_sw_reset(struct isp116x *isp116x { long retries = 15; long ret = 0; isp116x->disabled = 1; isp116x_write_reg16(isp116x, HCSWRES, HCSWRES_MAGIC); isp116x_write_reg32(isp116x, HCCMDSTAT, HCCMDSTAT_HCR); - + while (--retries) { /* It usually resets within 1 ms */ /* GALVEZ: not enough for TOS, try 7 ms */ mdelay(7); if (!(isp116x_read_reg32(isp116x, HCCMDSTAT) & HCCMDSTAT_HCR)) break; } - + if (!retries) { DEBUG(("software reset timeout")); ret = -1; } # if 0 /* GALVEZ: DEBUG SOFTWARE RESET */ - + retries = 5000; - + while (--retries){ if ((isp116x_read_reg32(isp116x, HCCMDSTAT) & HCCMDSTAT_HCR)) { INFO ("HCR: 1 retries: %d\n\r",retries); } } # endif /* END DEBUG */ return ret; @@ -1548,55 +1540,55 @@ isp116x_sw_reset(struct isp116x *isp116x static long isp116x_reset(struct isp116x *isp116x) { unsigned long t; unsigned short clkrdy = 0; long ret, timeout = 1000;/* ms * Galvez: 15 ms sometimes isn't enough, * for NetUSBee under TOS ??????? increased to 150 ms - */ + */ ret = isp116x_sw_reset(isp116x); if (ret) return ret; for (t = 0; t < timeout; t++) { clkrdy = isp116x_read_reg16(isp116x, HCuPINT) & HCuPINT_CLKRDY; if (clkrdy) break; mdelay(4); /* Default 1 ms */ } if (!clkrdy) { - DEBUG(("clock not ready after %ldms", timeout)); + ALERT(("clock not ready after %ldms", timeout)); /* After sw_reset the clock won't report to be ready, if H_WAKEUP pin is high. */ DEBUG(("please make sure that the H_WAKEUP pin is pulled low!")); ret = -1; } return ret; } -static void +static void isp116x_stop(struct isp116x *isp116x) { unsigned long val; isp116x_write_reg16(isp116x, HCuPINTENB, 0); /* Switch off ports' power, some devices don't come up after next 'start' without this */ val = isp116x_read_reg32(isp116x, HCRHDESCA); val &= ~(RH_A_NPS | RH_A_PSM); isp116x_write_reg32(isp116x, HCRHDESCA, val); isp116x_write_reg32(isp116x, HCRHSTATUS, RH_HS_LPS); - + isp116x_sw_reset(isp116x); } static void int_handle_tophalf(PROC *process, long arg) { struct isp116x *isp116x = &isp116x_dev; @@ -1620,35 +1612,35 @@ netusbee_hub_events(void) { struct isp116x *isp116x = &isp116x_dev; unsigned short irqstat; unsigned long intstat; /* Shut out all further interrupts */ isp116x_write_reg16(isp116x, HCuPINTENB, 0); irqstat = isp116x_read_reg16(isp116x, HCuPINT); - + // set_old_int_lvl(); - + if (irqstat & HCuPINT_OPR) { intstat = isp116x_read_reg32(isp116x, HCINTSTAT); isp116x_write_reg32(isp116x, HCINTSTAT, intstat); - if (intstat & HCINT_RHSC) + if (intstat & HCINT_RHSC) { isp116x->rhstatus = isp116x_read_reg32(isp116x, HCRHSTATUS); isp116x->rhport[0] = isp116x_read_reg32(isp116x, HCRHPORT1); isp116x->rhport[1] = isp116x_read_reg32(isp116x, HCRHPORT2); - + addroottimeout (0L, int_handle_tophalf, 0x1); } isp116x_write_reg16(isp116x, HCuPINT, HCuPINT_OPR); - } - + } + isp116x_write_reg16(isp116x, HCuPINTENB, isp116x->irqenb); // set_int_lvl7(); } void netusbee_hub_poll_thread(void *); void netusbee_hub_poll(PROC *proc, long dummy); void @@ -1674,17 +1666,17 @@ netusbee_hub_poll_thread(void *dummy) kthread_exit(0); } /* * Configure the chip. The chip must be successfully reset by now. */ -static long +static long isp116x_start(struct isp116x *isp116x) { struct isp116x_platform_data *board = isp116x->board; unsigned long val; /* Clear interrupt status and disable all interrupt sources */ isp116x_write_reg16(isp116x, HCuPINT, 0xff); isp116x_write_reg16(isp116x, HCuPINTENB, 0); @@ -1715,17 +1707,17 @@ isp116x_start(struct isp116x *isp116x) power switching. */ /* For NetUSBee ports are always powered */ val |= RH_A_NPS; // val |= RH_A_PSM; /* Report overcurrent per port */ // val |= RH_A_OCPM; /* Overcurrent protection disable */ val |= RH_A_NOCP; - + isp116x_write_reg32(isp116x, HCRHDESCA, val); isp116x->rhdesca = isp116x_read_reg32(isp116x, HCRHDESCA); val = RH_B_PPCM; isp116x_write_reg32(isp116x, HCRHDESCB, val); isp116x->rhdescb = isp116x_read_reg32(isp116x, HCRHDESCB); val = 0; @@ -1740,28 +1732,28 @@ isp116x_start(struct isp116x *isp116x) val = HCCONTROL_USB_OPER; if (board->remote_wakeup_enable) val |= HCCONTROL_RWE; isp116x_write_reg32(isp116x, HCCONTROL, val); /* Disable ports to avoid race in device enumeration */ isp116x_write_reg32(isp116x, HCRHPORT1, RH_PS_CCS); isp116x_write_reg32(isp116x, HCRHPORT2, RH_PS_CCS); - + isp116x->intenb = HCINT_MIE | HCINT_RHSC; /* HCINT_UE */ isp116x_write_reg32(isp116x, HCINTENB, isp116x->intenb); // isp116x->irqenb = HCuPINT_OPR; /* | HCuPINT_ATL; | HCuPINT_SUSP */ // isp116x_write_reg16(isp116x, HCuPINTENB, isp116x->irqenb); // val = isp116x_read_reg16(isp116x, HCHWCFG); // val |= HCHWCFG_INT_ENABLE; // isp116x_write_reg16(isp116x, HCHWCFG, val); long r; r = kthread_create(NULL, netusbee_hub_poll_thread, NULL, NULL, "hubpoll"); - + if (r) { /* XXX todo -> exit gracefully */ //DEBUG((/*0000000a*/"can't create NetUSBee kernel thread")); } isp116x_show_regs(isp116x); @@ -1804,45 +1796,46 @@ netusbee_ioctl(struct ucdif *u, short cm case LOWLEVEL_STOP : { ret = usb_lowlevel_stop (); break; } case SUBMIT_CONTROL_MSG : { struct control_msg *ctrl_msg = (struct control_msg *)arg; - + ret = submit_control_msg (ctrl_msg->dev, ctrl_msg->pipe, - ctrl_msg->data, ctrl_msg->size, ctrl_msg->setup); + ctrl_msg->data, ctrl_msg->size, + ctrl_msg->setup); break; } case SUBMIT_BULK_MSG : { struct bulk_msg *bulk_msg = (struct bulk_msg *)arg; ret = submit_bulk_msg (bulk_msg->dev, bulk_msg->pipe, - bulk_msg->data, bulk_msg->len); + bulk_msg->data, bulk_msg->len); break; } case SUBMIT_INT_MSG : { struct int_msg *int_msg = (struct int_msg *)arg; ret = submit_int_msg(int_msg->dev, int_msg->pipe, - int_msg->buffer, int_msg->transfer_len, - int_msg->interval); + int_msg->buffer, int_msg->transfer_len, + int_msg->interval); break; } default: { return ENOSYS; } - } + } return ret; } /* --- Init functions ------------------------------------------------------ */ long @@ -1857,18 +1850,17 @@ isp116x_check_id(struct isp116x *isp116x { ALERT(("invalid chip ID %04x", val)); return -1; } return 0; } - -long +long usb_lowlevel_init(long dummy1, const struct pci_device_id *dummy2) { // unsigned short val; struct isp116x *isp116x = &isp116x_dev; got_rhsc = rh_devnum = 0; @@ -1892,27 +1884,27 @@ usb_lowlevel_init(long dummy1, const str #ifdef ISP116X_HCD_REMOTE_WAKEUP_ENABLE isp116x_board.remote_wakeup_enable = 1; #endif isp116x->board = &isp116x_board; /* Try to get ISP116x silicon chip ID */ if (isp116x_check_id(isp116x) < 0) return (-1); - + isp116x->disabled = 1; isp116x->sleeping = 0; isp116x_reset(isp116x); isp116x_start(isp116x); return 0; } -long +long usb_lowlevel_stop(void) { struct isp116x *isp116x = &isp116x_dev; if (!isp116x->disabled) isp116x_stop(isp116x); return 0; Index: sys/usb/src.km/ucd/netusbee/isp116x.h =================================================================== RCS file: /mint/freemint/sys/usb/src.km/ucd/netusbee/isp116x.h,v retrieving revision 1.4 diff -u -8 -p -r1.4 isp116x.h --- sys/usb/src.km/ucd/netusbee/isp116x.h 6 Mar 2013 21:04:01 -0000 1.4 +++ sys/usb/src.km/ucd/netusbee/isp116x.h 11 Mar 2013 16:57:30 -0000 @@ -403,45 +403,45 @@ struct isp116x unsigned long p; static inline void isp116x_write_addr(struct isp116x *isp116x, unsigned reg) { u16 dumm; - isp116x->data_reg = (u16*)(ISP116X_HCD_DATA + ((reg & 0x00ff)<<1)); + isp116x->data_reg = (u16*)(ISP116X_HCD_DATA + ((reg & 0x00ff)<<1)); dumm = __raw_readw(isp116x->data_reg); isp116x->addr_reg = (u16*)ISP116X_HCD_ADDR; dumm = __raw_readw(isp116x->addr_reg); isp116x_delay(isp116x, UDELAY); UNUSED (dumm); } static inline void isp116x_write_data16(struct isp116x *isp116x, unsigned short val) { u16 dumm; - isp116x->data_reg = (u16*)(ISP116X_HCD_DATA + ((val & 0xff00)>>7)); + isp116x->data_reg = (u16*)(ISP116X_HCD_DATA + ((val & 0xff00)>>7)); dumm = __raw_readw(isp116x->data_reg); isp116x->addr_reg = (u16*)((ISP116X_HCD_ADDR - 0x4000) + ((val & 0x00ff)<<1)); dumm = __raw_readw(isp116x->addr_reg); isp116x_delay(isp116x, UDELAY); UNUSED (dumm); } static inline void isp116x_raw_write_data16(struct isp116x *isp116x, unsigned short val) { u16 dumm; isp116x->data_reg = (u16*)(ISP116X_HCD_DATA + ((val & 0x00ff)<<1)); dumm = __raw_readw(isp116x->data_reg); - isp116x->addr_reg = (u16*)((ISP116X_HCD_ADDR - 0x4000) + ((val & 0xff00)>>7)); + isp116x->addr_reg = (u16*)((ISP116X_HCD_ADDR - 0x4000) + ((val & 0xff00)>>7)); dumm = __raw_readw(isp116x->addr_reg); isp116x_delay(isp116x, UDELAY); UNUSED (dumm); } static inline unsigned short isp116x_read_data16(struct isp116x *isp116x) { @@ -477,19 +477,19 @@ static inline void isp116x_write_data32( /* * Added for NetUSBee, to write HC registers without swapping them * NetUSBee already swap them by hardware (i suppose.....) */ static inline void isp116x_raw_write_data32(struct isp116x *isp116x, unsigned long val) { u16 dumm; - isp116x->data_reg = (u16*)(ISP116X_HCD_DATA + ((val & 0x000000ff)<<1)); + isp116x->data_reg = (u16*)(ISP116X_HCD_DATA + ((val & 0x000000ff)<<1)); dumm = __raw_readw(isp116x->data_reg); - isp116x->addr_reg = (u16*)((ISP116X_HCD_ADDR - 0x4000) + ((val & 0x0000ff00)>>7)); + isp116x->addr_reg = (u16*)((ISP116X_HCD_ADDR - 0x4000) + ((val & 0x0000ff00)>>7)); dumm = __raw_readw(isp116x->addr_reg); isp116x_delay(isp116x, UDELAY); isp116x->data_reg = (u16*)(ISP116X_HCD_DATA + ((val & 0x00ff0000)>>15)); dumm = __raw_readw(isp116x->data_reg); isp116x->addr_reg = (u16*)((ISP116X_HCD_ADDR - 0x4000) + ((val & 0xff000000)>>23) ); dumm = __raw_readw(isp116x->addr_reg); isp116x_delay(isp116x, UDELAY);