/*! * mouse_cf_modinit() - module init * * This is called by the Linux kernel; either when the module is loaded * if compiled as a module, or during the system intialization if the * driver is linked into the kernel. * * This function will parse module parameters if required and then register * the mouse driver with the USB Device software. * */ static int mouse_cf_modinit (void) { int i; printk (KERN_INFO "%s: vendor_id: %04x product_id: %04x\n", __FUNCTION__, vendor_id, product_id); #if !defined(OTG_C99) mouse_cf_global_init(); mouse_cf_ops_init(); #endif /* defined(OTG_C99) */ MOUSE = otg_trace_obtain_tag(); TRACE_MSG2(MOUSE, "vendor_id: %04x product_id: %04x",vendor_id, product_id); //if (vendor_id) // mouse_composite_driver.idVendor = cpu_to_le16(vendor_id); //if (product_id) // mouse_composite_driver.idProduct = cpu_to_le16(product_id); // register as usb function driver TRACE_MSG0(MOUSE, "REGISTER COMPOSITE"); THROW_IF (usbd_register_composite_function (&mouse_composite_driver, "mouse-random-cf", NULL, mouse_arg_list, NULL), error); TRACE_MSG0(MOUSE, "REGISTER FINISHED"); CATCH(error) { otg_trace_invalidate_tag(MOUSE); return -EINVAL; } return 0; }
/*! * zasevb_isp1301_bh()- call isp1301 bottom half handler * @param arg * This is a wrapper to the isp1301 bottom half handler, it * re-enables the gpio interrupt after processing complete. */ void zasevb_isp1301_bh(void *arg) { TRACE_MSG0(TCD, "ZASEVB GPIO INTERRUPT: ISP1301_BH"); isp1301_bh(arg); TRACE_MSG0(TCD, "ZASEVB GPIO INTERRUPT: REENABLE"); gpio_config_int_en(ZGPIO_PORT, ZGPIO_PIN, TRUE); }
/*! pmic_otg_wakeup - called to wake up pmic_otg_task */ void pmic_otg_wakeup(void) { TRACE_MSG0(REMOVE_TCD, "start"); //SCHEDULE_WORK(pmic_otg_wq); otg_up_work(pmic_otg_task); TRACE_MSG0(REMOVE_TCD, "finsih"); }
/*! * mxc_gptcr_timer_int_hndlr() - timer interrupt * @param irq * @param dev_id * @param regs */ irqreturn_t mxc_gptcr_timer_int_hndlr (int irq, void *dev_id, struct pt_regs *regs) { u32 gptsr = *_reg_GPT_GPTSR; *_reg_GPT_GPTIR &= ~(0x04); if (gptsr & (0x01 << 2)){ TRACE_MSG7(OCD, "cnt: %08x match: %08x gptsr: %08x GPTCNT: %08x GPTCR: %08x GPTSR: %08x GPTOCR3: %08x\n", mxc_gptcr_ticks_set, mxc_gptcr_match_set, gptsr, *_reg_GPT_GPTCNT, *_reg_GPT_GPTCR, *_reg_GPT_GPTSR, *_reg_GPT_GPTOCR3); *_reg_GPT_GPTCR &= ~(0x7 << 26); *_reg_GPT_GPTOCR3 = 0; TRACE_MSG0(OCD, "OCM3"); TRACE_MSG1(OCD, "active: %x", mxc_gptcr_active); if (mxc_gptcr_active) { TRACE_MSG0(OCD, "calling otg_event"); mxc_gptcr_active = 0; otg_event(ocd_instance->otg, TMOUT, OCD, "TMOUT"); } else { TRACE_MSG0(OCD, "skipping otg_event"); } *_reg_GPT_GPTSR |= 0x4; return IRQ_HANDLED; } if (!mxc_shared_int) *_reg_GPT_GPTIR |= 0x4; return IRQ_NONE; }
/*! * generic_cl_modinit() - module init * * This is called by the Linux kernel; either when the module is loaded * if compiled as a module, or during the system intialization if the * driver is linked into the kernel. * * This function will parse module parameters if required and then register * the generic driver with the USB Device software. * */ static int generic_cl_modinit (void) { #if !defined(OTG_C99) /*! function_ops - operations table for the USB Device Core */ ZERO(generic_function_ops); generic_function_ops.device_request=generic_cl_device_request; /*! called for each received device request */ /*! class_driver - USB Device Core function driver definition */ ZERO(generic_class_driver); generic_class_driver.driver.name = "generic-class"; /*! driver name */ generic_class_driver.driver.fops = &generic_function_ops; /*! operations table */ #endif /* defined(OTG_C99) */ GCLASS = otg_trace_obtain_tag(NULL, "generic-cf"); // register as usb function driver TRACE_MSG0(GCLASS, "REGISTER CLASS"); THROW_IF (usbd_register_class_function (&generic_class_driver, "generic-class", NULL), error); TRACE_MSG0(GCLASS, "REGISTER FINISHED"); CATCH(error) { generic_cl_modexit(); return -EINVAL; } return 0; }
/*! mxc_pmic_dm_pulldown_func - used to enable or disable peripheral connecting to bus * * @param otg - otg instance * @param flag - enable/disable flag */ void mxc_pmic_dm_pulldown_func(struct otg_instance *otg, u8 flag) { struct tcd_instance *tcd = (struct tcd_instance *)otg->tcd; //TRACE_MSG0(tcd->TAG, "--"); switch (flag) { case SET: TRACE_MSG0(tcd->TAG, "MC13783_LOC_CONN SET - Set DM PULLDOWN"); // global_flag |= UDM_FLAG_SET; global_flag_array[end_flag] = UDM_FLAG_SET; pmic_bh_wakeup(); // mc13783_convity_set_pull_down_switch(PD_UDM_15, TRUE); break; case RESET: TRACE_MSG0(tcd->TAG, "MC13783_LOC_CONN RESET - Clr DM PULLDOWN"); // global_flag |= UDM_FLAG_RESET; global_flag_array[end_flag] = UDM_FLAG_RESET; pmic_bh_wakeup(); // mc13783_convity_set_pull_down_switch(PD_UDM_15, TRUE); break; } if (end_flag++ > 15) end_flag = 0; }
/*! * otg_pci_isr() - interrupt service handler */ irqreturn_t otg_pci_isr(int irq, void *data, struct pt_regs *r) { struct pci_dev *pci_dev = data; struct otg_dev *otg_dev = pci_get_drvdata(pci_dev); int i; /* XXX spinlock */ RETURN_IRQ_HANDLED_UNLESS(otg_dev); TRACE_MSG0(otg_dev->PCI, "---------------------------------------- Start"); for (i = OTG_DRIVER_TCD; i < OTG_DRIVER_TYPES; i++) { struct otg_driver *otg_driver; otg_driver = otg_dev->otg_pci_driver->drivers[i]; CONTINUE_UNLESS(otg_driver); TRACE_MSG2(otg_dev->PCI, "try %s %d", otg_driver->name, i); CONTINUE_UNLESS(otg_driver->isr); RETURN_IRQ_HANDLED_IF_IRQ_HANDLED (otg_driver->isr(otg_dev, data)); TRACE_MSG2(otg_dev->PCI, "not handled by %s %d", otg_driver->name, i); } TRACE_MSG2(otg_dev->PCI, "try %s %d", otg_dev->otg_pci_driver->name, i); if (otg_dev->otg_pci_driver->isr) RETURN_IRQ_HANDLED_IF_IRQ_HANDLED (otg_dev->otg_pci_driver->isr(otg_dev, data)); /* XXX spinlock */ TRACE_MSG0(otg_dev->PCI, "---------------------------------------- IRQ_NONE ----"); return IRQ_NONE; }
/*! net_fd_recv_urb2 - callback to process a received URB * * @param urb - pointer to copy of received urb, * @param rc - receiving urb result code * * @return non-zero for failure. */ int net_fd_recv_urb2(struct usbd_urb *urb, int rc) { struct usbd_function_instance *function_instance = urb->function_instance; struct usb_network_private *npd = function_instance->privdata; int hs = usbd_high_speed(function_instance); int endpoint_index = urb->endpoint_index; #ifndef CONFIG_OTG_NETWORK_DOUBLE_OUT int recv_index = 0; #else /* CONFIG_OTG_NETWORK_DOUBLE_OUT */ int recv_index = (endpoint_index == BULK_OUT_A) ? 0 : 1; #endif /* CONFIG_OTG_NETWORK_DOUBLE_OUT */ int alloc_length = usbd_endpoint_transferSize(function_instance, endpoint_index, hs); int status = urb->status; void *os_data; u8 *os_buffer; if (TRACE_VERY_VERBOSE) { TRACE_MSG4(NTT, "status: %d actual_length: %d bus status: %d device_state: %d", urb->status, urb->actual_length, usbd_get_device_status(function_instance), usbd_get_device_state(function_instance) ); TRACE_NRECV(NTT, 32, urb->buffer); TRACE_MSG0(NTT, "--"); TRACE_RECV(NTT, urb->actual_length, urb->buffer); } otg_atomic_dec(&npd->recv_urbs_started[recv_index]); /* process the data */ if (urb->status == USBD_URB_OK) npd->net_recv_urb(urb, rc); if (urb->status == USBD_URB_CANCELLED) net_os_dealloc_buffer(function_instance, urb->function_privdata, urb->buffer); /* disconnect os_data buffer from urb */ urb->function_privdata = NULL; urb->buffer = NULL; urb->function_instance = NULL; urb->status = USBD_URB_OK; usbd_free_urb(urb); if ((USBD_OK == usbd_get_device_status(function_instance)) && (STATE_CONFIGURED == usbd_get_device_state(function_instance))) { blan_start_recv(function_instance); } else { TRACE_MSG0(NTT, "NOT RESTARTING"); } return 0; }
/*! * zasevb_modexit() - This is used as module exit, and as cleanup if modinit fails. */ static void zasevb_modexit (void) { struct otg_instance *otg = ocd_instance->otg; //struct pcd_instance *pcd = (struct pcd_instance *)otg->pcd; //struct usbd_bus_instance *bus= pcd->bus; TRACE_MSG0(ZAS, "Modules exit!"); if (otg) otg_exit(otg); mxc_procfs_exit(); /* Disable GPT */ #if defined(CONFIG_OTG_GPTR) mxc_gptcr_mod_exit(); #endif /* defined(CONFIG_OTG_GPTR) */ #if defined(CONFIG_OTG_HRT) mxc_hrt_mod_exit(); #endif /* defined(CONFIG_OTG_GPTR) */ #ifdef OTG_USE_I2C TRACE_MSG0(ZAS, "0. I2C"); i2c_mod_exit(otg); #endif #if !defined(CONFIG_USB_HOST) if (pcd_ops.mod_exit) pcd_ops.mod_exit(otg); REMOVE_pcd_instance = otg_set_pcd_ops(otg, NULL); #else /* !defined(CONFIG_USB_HOST) */ printk(KERN_INFO"%s: PCD DRIVER N/A\n", __FUNCTION__); #endif /* !defined(CONFIG_USB_HOST) */ #if defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE) if (hcd_ops.mod_exit) hcd_ops.mod_exit(otg); hcd_instance = otg_set_hcd_ops(otg, NULL); //HCD = otg_trace_invalidate_tag(HCD); #else /* defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE) */ printk(KERN_INFO"%s: HCD DRIVER N/A\n", __FUNCTION__); #endif /* defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE) */ if (tcd_ops.mod_exit) tcd_ops.mod_exit(otg); printk(KERN_INFO"%s: set_tcd_ops\n", __FUNCTION__); REMOVE_tcd_instance = otg_set_tcd_ops(otg, NULL); //REMOVE_TCD = otg_trace_invalidate_tag(REMOVE_TCD); if (ocd_ops.mod_exit) ocd_ops.mod_exit(otg); ocd_instance = otg_set_ocd_ops(otg, NULL); ZAS = otg_trace_invalidate_tag(ZAS); otg_destroy(otg); }
/*! * zasevb_isp1301_bh()- call isp1301 bottom half handler * @param arg * This is a wrapper to the isp1301 bottom half handler, it * re-enables the gpio interrupt after processing complete. */ void *zasevb_isp1301_bh(void *arg) { TRACE_MSG0(REMOVE_TCD, "ZASEVB GPIO INTERRUPT: ISP1301_BH"); isp1301_bh(arg); TRACE_MSG0(REMOVE_TCD, "ZASEVB GPIO INTERRUPT: REENABLE"); if (zasevb_int_disabled) { zasevb_int_disabled = FALSE; enable_irq(IOMUX_TO_IRQ(PIN_GPIO2)); } return 0; }
/*! mxc_mc13783_mx21_vbus_drain - used to enable Vbus discharge */ void mxc_mc13783_mx21_vbus_drain_func(struct otg_instance *otg, u8 flag) { struct tcd_instance *tcd = otg->tcd; //TRACE_MSG0(TCD, "--"); switch (flag) { case SET: TRACE_MSG0(TCD, "OUTPUT: TCD_DISCHRG_VBUS_SET"); break; case RESET: TRACE_MSG0(TCD, "OUTPUT: TCD_DISCHRG_VBUS_RESET"); break; } }
/*! mxc_mc13783_tcd_en() - used to enable * */ void mxc_mc13783_tcd_en(struct otg_instance *otg, u8 flag) { switch (flag) { case SET: case PULSE: TRACE_MSG0(TCD, "SET/PULSE"); mc13783_otg_wakeup (); break; case RESET: TRACE_MSG0(TCD, "RESET"); break; } }
/*! mxc_pmic_dp_det_func - used to enable or disable D+ detect * * @param otg - otg instance * @param flag - enable/disable flag */ void mxc_pmic_dp_det_func(struct otg_instance *otg, u8 flag) { struct tcd_instance *tcd = (struct tcd_instance *)otg->tcd; //TRACE_MSG0(tcd->TAG, "--"); switch (flag) { case SET: TRACE_MSG0(tcd->TAG, "setting DP_HI detect"); break; case RESET: TRACE_MSG0(tcd->TAG, "reseting DP_HI detect"); break; } }
/*! mxc_mc13783_audio_func - used to enable or disable Carkit Interrupt * */ void mxc_mc13783_audio_func(struct otg_instance *otg, u8 flag) { struct tcd_instance *tcd = (struct tcd_instance *)otg->tcd; //TRACE_MSG0(TCD, "--"); switch (flag) { case SET: TRACE_MSG0(TCD, "SET AUDIO_EN"); break; case RESET: TRACE_MSG0(TCD, "RESET AUDIO_EN"); break; } }
/*! mxc_mc13783_bdis_acon_func - used to enable or disable auto a-connect * */ void mxc_mc13783_bdis_acon_func(struct otg_instance *otg, u8 flag) { struct tcd_instance *tcd = (struct tcd_instance *)otg->tcd; //TRACE_MSG0(TCD, "--"); switch (flag) { case SET: TRACE_MSG0(TCD, "setting BDIS ACON"); break; case RESET: TRACE_MSG0(TCD, "reseting BDIS ACON"); break; } }
/*! mxc_mc13783_id_pulldown_func - used to enable or disable ID pulldown * */ void mxc_mc13783_id_pulldown_func(struct otg_instance *otg, u8 flag) { struct tcd_instance *tcd = (struct tcd_instance *)otg->tcd; //TRACE_MSG0(TCD, "--"); switch (flag) { case SET: TRACE_MSG0(TCD, "setting ID PULLDOWN"); break; case RESET: TRACE_MSG0(TCD, "reseting ID PULLDOWN"); break; } }
/*! mxc_mc13783_peripheral_host_func - used to enable or disable peripheral connecting to bus * * A-Device D+ pulldown D- pulldown * idle set set * host set set * peripheral reset set * * B-Device * idle set set * host set set * peripheral reset set */ void mxc_mc13783_peripheral_host_func(struct otg_instance *otg, u8 flag) { struct tcd_instance *tcd = (struct tcd_instance *)otg->tcd; //TRACE_MSG0(TCD, "--"); switch (flag) { case SET: // peripheral TRACE_MSG0(TCD, "SET - CLR DP PULLDOWN"); break; case RESET: // host TRACE_MSG0(TCD, "RESET - SET DM PULLDOWN"); break; } }
/*! mxc_mc13783_cr_det_func - used to enable or disable D+ detect * */ void mxc_mc13783_cr_det_func(struct otg_instance *otg, u8 flag) { struct tcd_instance *tcd = (struct tcd_instance *)otg->tcd; //TRACE_MSG0(TCD, "--"); switch (flag) { case SET: TRACE_MSG0(TCD, "setting CR_INT detect"); break; case RESET: TRACE_MSG0(TCD, "reseting CR_INT detect"); break; } }
/*========================================================================== FUNCTION: fx2lp_read_setup_pkt_irq DESCRIPTION: Gets and handles a setup packet from FX2LP ARGUMENTS PASSED: pfx2lp RETURN VALUE: None PRE-CONDITIONS: Interrupt context POST-CONDITIONS: None. IMPORTANT NOTES: This still has the kludge to set bus speed the first time we see a setup packet. ==========================================================================*/ void fx2lp_read_setup_pkt_irq( PFX2LP_PCD pfx2lp) { struct pcd_instance *pcd = pfx2lp->pcd; struct usbd_device_request request; volatile u16 *pfifo_addr; u16 temp; pfifo_addr = pfx2lp->pcmd_out_addr; temp = FX2LP_WORD_SWAP(*pfifo_addr); /* check if this is really what we're looking for */ if ((temp & FX2LP_PLUS_SETUP_PKT_CMD) == 0) { return; } /* hardly worth setting up a loop */ ((u16 *)&request)[0] = FX2LP_WORD_SWAP(*pfifo_addr); ((u16 *)&request)[1] = FX2LP_WORD_SWAP(*pfifo_addr); ((u16 *)&request)[2] = FX2LP_WORD_SWAP(*pfifo_addr); ((u16 *)&request)[3] = FX2LP_WORD_SWAP(*pfifo_addr); #if (FX2LP_DETAIL_KPF & (FX2LP_DETAIL_DATAFLOW|FX2LP_DETAI_INIT)) printk ("\n Setup: RT %02x, R %02x, V %04x, I %04X, L %04X", request.bmRequestType, request.bRequest, request.wValue, request.wIndex, request.wLength); #endif if (pcd_recv_setup_irq(pcd, &request)) { //printk("\n^^^^^^^^^^^^^^%s:%d\n",__FUNCTION__,__LINE__); TRACE_MSG0(PCD, "pcd_ep0: STALLING"); fx2lp_stall_ep0(pfx2lp); } else if ((request.wLength == 0) && (request.bmRequestType & USB_REQ_DIRECTION_MASK) == USB_REQ_HOST2DEVICE) { /* we need to ACK the setup packet */ TRACE_MSG0(PCD,"Scheduling setup complete"); pfx2lp->pep_status[FX2LP_EP0].send_zlp = TRUE; fx2lp_schedule_ready_event (pfx2lp, FX2LP_RDY_EV_N_WRITE_EP0); fx2lp_schedule_ready_event (pfx2lp, FX2LP_RDY_EV_N_SETUP_CPLT); } }
/*! mxc_pmic_tcd_init() - used to enable mc13783 * @param otg - otg instance pointer * @param flag - * */ void mxc_pmic_tcd_init(struct otg_instance *otg, u8 flag) { struct tcd_instance *tcd = otg->tcd; switch (flag) { case SET: case PULSE: TRACE_MSG0(tcd->TAG, "SET/PULSE"); break; case RESET: TRACE_MSG0(tcd->TAG, "RESET"); break; } pmic_otg_wakeup(); otg_event (otg, OCD_OK, otg->tcd->TAG, "MC13783 OK"); }
/*! mxc_pmic_tcd_en() - used to enable/ disable mc13783 * * @param otg - otg instance * @param flag - enable/ disable flag */ void mxc_pmic_tcd_en(struct otg_instance *otg, u8 flag) { struct tcd_instance *tcd = otg->tcd; switch (flag) { case SET: case PULSE: TRACE_MSG0(tcd->TAG, "SET/PULSE"); pmic_otg_wakeup(); // otg_event_set_irq(tcd_instance->otg, 1, mxc_mc13783_vbus(tcd_instance->otg), B_SESS_VLD, TCD, "B_SESS_VLD"); break; case RESET: TRACE_MSG0(tcd->TAG, "RESET"); break; } }
/*! * mxc_ocd_init() - used to initialize/enable or disable the tcd driver * @param otg * @param flag */ void mxc_ocd_init(struct otg_instance *otg, u8 flag) { TRACE_MSG0(otg->ocd->TAG, "--"); switch (flag) { case SET: TRACE_MSG0(otg->ocd->TAG, "FS_otg->ocd->TAG_EN SET"); mxc_init(otg); break; case RESET: mxc_exit(otg); TRACE_MSG0(otg->ocd->TAG, "FS_otg->ocd->TAG_EN RESET"); break; } otg_event(otg, OCD_OK, otg->ocd->TAG, "MX21 OK"); }
/*! * mxc_mc13783_usbi_handler() - event handler * * Called when mc13783 generates a USBI interrupt event, this is from Vbus on USB cable attach * */ void mc13783_usbi_handler (void) { TRACE_MSG0(TCD, "mc13783 generates a USBI interrupt event"); mc13783_otg_wakeup (); }
/*! mxc_mc13783_mono_func - used to enable or disable mono audio connection * */ void mxc_mc13783_mono_func(struct otg_instance *otg, u8 flag) { struct tcd_instance *tcd = (struct tcd_instance *)otg->tcd; //TRACE_MSG0(TCD, "--"); switch (flag) { case SET: TRACE_MSG0(TCD, "setting MONO"); /* XXX enable mono output */ break; case RESET: TRACE_MSG0(TCD, "reseting MONO"); /* XXX disable mono output */ break; } }
/*! mxc_mc13783_uart_func - used to enable or disable transparent uart mode * */ void mxc_mc13783_uart_func(struct otg_instance *otg, u8 flag) { struct tcd_instance *tcd = (struct tcd_instance *)otg->tcd; //TRACE_MSG0(TCD, "--"); switch (flag) { case SET: TRACE_MSG0(TCD, "setting UART_EN"); /* XXX enable uart */ break; case RESET: TRACE_MSG0(TCD, "reseting UART_EN"); /* XXX disable uart */ break; } }
void pmic_se1i_handler(void) { TRACE_MSG0(REMOVE_TCD, "--"); pmic_otg_wakeup(); #if 0 #if 1 t_sensor_bits sense_bits; if (pmic_get_sensors(&sense_bits)) { printk(KERN_INFO "%s: pmic_get_sensors() failed\n", __FUNCTION__); return; } TRACE_MSG1(REMOVE_TCD, "MC13783 EVENT: se1: %d", sense_bits.sense_se1s); otg_event(tcd_instance->otg, (sense_bits.sense_se1s ? SE1_DET : SE1_DET_), REMOVE_TCD, "MC13783 SE1"); #else otg_event(tcd_instance->otg, (pmic_check_sense(sense_se1s) ? SE1_DET : SE1_DET_), REMOVE_TCD, "MC13783 SE1"); #endif #endif }
/*! blan_start_recv - start recv urb(s) * *@param function_instance - pointer to this function instance *@return none */ int blan_start_recv(struct usbd_function_instance *function_instance) { struct usb_network_private *npd = function_instance->privdata; TRACE_MSG0(NTT, "SCHEDULE"); otg_up_work(npd->blan_recv_task); return 0; }
void mc13783_se1i_handler (void) { TRACE_MSG0(TCD, "--"); mc13783_otg_wakeup (); }
void mxc_mc13783_mod_init(void) { bool transceiver; TRACE_MSG0(TCD, "Setup the work item"); PREPARE_WORK_ITEM(mc13783_work_bh, &mc13783_bh, NULL); PREPARE_WORK_ITEM(mc13783_otg_wq, &mc13783_otg_event_bh, NULL); /* if (power_ic_get_reg_value(POWER_IC_REG_ATLAS_USB_0, BIT_USBXCVREN, &value, 1) < 0) { printk("%s: power_ic_get_reg_value failed\n", __FUNCTION__); } if (mc13783_convity_get_usb_transceiver(&transceiver)) printk(KERN_INFO"%s: mc13783_convity_get_usb_transciver failed\n", __FUNCTION__); printk(KERN_INFO"%s: tw: %02x\n", __FUNCTION__, transceiver); mc13783_convity_event_sub(IT_CONVITY_USBI, mc13783_usbi_handler); mc13783_convity_event_sub(IT_CONVITY_IDI, mc13783_idi_handler); mc13783_convity_event_sub(IT_CONVITY_SE1I, mc13783_se1i_handler); // XXX it may be more appropriate to do this in the enable function // and reset to something when disaabled mc13783_convity_set_interface_mode(IM_USB); mc13783_convity_set_var_disconnect(TRUE); mc13783_convity_set_udp_pull (TRUE); */ start_flag = end_flag = 0; }
int blan_start_recv_endpoint(struct usbd_function_instance *function_instance, int endpoint_index, otg_atomic_t *recv_urbs_started, char *msg) { struct usb_network_private *npd = function_instance->privdata; int i; int hs = usbd_high_speed(function_instance); int alloc_length = usbd_endpoint_transferSize(function_instance, endpoint_index, hs); if (TRACE_VERBOSE) TRACE_MSG4(NTT, "endpoint_index: %d recv_urbs_started: %d alloc_length: %d %s", endpoint_index, otg_atomic_read(recv_urbs_started), alloc_length, msg); while (otg_atomic_read(recv_urbs_started) < npd->max_recv_urbs ) { u8 *os_buffer = NULL; void *os_data = NULL; struct usbd_urb *urb; #ifdef DEBUG_CRC_SEEN if (npd->seen_crc_error) { TRACE_MSG0(NTT, "CRC ERROR NOT RESTARTING"); break; } #endif /* DEBUG_CRC_SEEN */ /* get os buffer - os_buffer is data, os_data is the os data structure */ os_data = net_os_alloc_buffer(function_instance, &os_buffer, alloc_length); /* allocate urb with no buffer */ /*allocate urb without buffer */ urb = usbd_alloc_urb(function_instance, endpoint_index, 0, net_fd_recv_urb2); /* start urb with buffer pointing at the os_buffer in os_data structure */ if (os_buffer && urb) { urb->function_privdata = os_data; urb->buffer = os_buffer; urb->flags |= npd->recv_urb_flags; urb->alloc_length = urb->buffer_length = alloc_length; if (usbd_start_out_urb(urb)) { net_os_dealloc_buffer(function_instance, os_data, os_buffer); urb->function_privdata = NULL; urb->buffer = NULL; usbd_free_urb(urb); } otg_atomic_inc(recv_urbs_started); continue; } TRACE_MSG1(NTT, "recv_urbs_started: %d FAILED EARLY", otg_atomic_read(recv_urbs_started)); if (os_buffer || os_data) net_os_dealloc_buffer(function_instance, os_data, os_buffer); if (urb) urb->buffer = NULL; usbd_free_urb(urb); break; } if (TRACE_VERBOSE) TRACE_MSG1(NTT, "recv_urbs_started: %d", otg_atomic_read(recv_urbs_started)); return 0; }