void usb_disconnect() { struct usb_event evt; evt.event = USB_EVENT_DISCONNECT; if (static_data->usb_event_cb) { static_data->usb_event_cb(&evt); } if (dwc_otg_device->core_if->pcd_cb) { DWC_FREE(dwc_otg_device->core_if->pcd_cb); dwc_otg_device->core_if->pcd_cb = NULL; } if (dwc_otg_device->pcd) { dwc_otg_pcd_remove(dwc_otg_device->pcd); dwc_otg_device->pcd = NULL; } if (dwc_otg_device->core_if) { dwc_otg_cil_remove(dwc_otg_device->core_if); dwc_otg_device->core_if = NULL; } /* Disable clock */ MMIO_REG_VAL(AHB_CTRL_REG) &= ~CCU_USB_CLK_EN; /* Stopping USB PLL */ MMIO_REG_VAL(USB_PLL_CFG0) &= ~USB_PLL_PDLD; /* Disable regulator */ gpio_write(SOC_GPIO_32, VENABLE_USB_REGULATOR, 0); }
/* Computes the modular exponentiation (num^exp % mod). num, exp, and mod are * big endian numbers of size len, in bytes. Each len value must be a multiple * of 4. */ int dwc_dh_modpow(void *num, uint32_t num_len, void *exp, uint32_t exp_len, void *mod, uint32_t mod_len, void *out) { /* modpow() takes little endian numbers. AM uses big-endian. This * function swaps bytes of numbers before passing onto modpow. */ int retval = 0; uint32_t *result; uint32_t *bignum_num = DWC_ALLOC(num_len + 4); uint32_t *bignum_exp = DWC_ALLOC(exp_len + 4); uint32_t *bignum_mod = DWC_ALLOC(mod_len + 4); dh_swap_bytes(num, &bignum_num[1], num_len); bignum_num[0] = num_len / 4; dh_swap_bytes(exp, &bignum_exp[1], exp_len); bignum_exp[0] = exp_len / 4; dh_swap_bytes(mod, &bignum_mod[1], mod_len); bignum_mod[0] = mod_len / 4; result = dwc_modpow(bignum_num, bignum_exp, bignum_mod); if (!result) { retval = -1; goto dh_modpow_nomem; } dh_swap_bytes(&result[1], out, result[0] * 4); DWC_FREE(result); dh_modpow_nomem: DWC_FREE(bignum_num); DWC_FREE(bignum_exp); DWC_FREE(bignum_mod); return retval; }
dwc_timer_t *DWC_TIMER_ALLOC(char *name, dwc_timer_callback_t cb, void *data) { dwc_timer_t *t = DWC_ALLOC(sizeof(*t)); /*OS_ERR_TYPE err;*/ if (t == NULL) { DWC_ERROR("Cannot allocate memory for timer"); return NULL; } t->lock = DWC_SPINLOCK_ALLOC(); if (!t->lock) { DWC_ERROR("Cannot allocate memory for lock"); goto no_lock; } t->scheduled = 0; t->cb = cb; t->data = data; /*t->t = timer_create(timer_callback, (void *)t, 0, 0, 0, &err); if (err == E_OS_ERR) { DWC_ERROR("Cannot allocate memory for timer->t"); goto no_timer; }*/ return t; /* no_timer: */ DWC_SPINLOCK_FREE(t->lock); no_lock: DWC_FREE(t); return NULL; }
void DWC_TASK_FREE(dwc_tasklet_t * task) { DWC_FREE(task); }
void DWC_TIMER_FREE(dwc_timer_t * timer) { DWC_SPINLOCK_FREE(timer->lock); /* timer_delete(timer->t, NULL); */ DWC_FREE(timer); }
void __DWC_DMA_FREE(void *dma_ctx, uint32_t size, void *virt_addr, dwc_dma_t dma_addr) { DWC_FREE(virt_addr); }