Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*--------------------------------------------------------------------------*/
- /* {{{ initialization of the HC and the root hub: */
- /*{{{*/
- static void
- dwc3884_power_on (void)
- {
- #ifdef CONFIG_PORTA_DANUBE
- // set gpio's for controlling usb power and clock gating
- #if 0 // JR: Keep this active for real project ??? NO -> This is done by scm_app
- // #if 0 // JR: initial init is done by u-boot in demo project ...
- // JR: usb power is on gpio 29
- clear_bit (13, DANUBE_GPIO_P1_ALTSEL0);
- clear_bit (13, DANUBE_GPIO_P1_ALTSEL1);
- set_bit (13, DANUBE_GPIO_P1_OD);
- set_bit (13, DANUBE_GPIO_P1_DIR);
- clear_bit (13, DANUBE_GPIO_P1_PUDSEL);
- clear_bit (13, DANUBE_GPIO_P1_PUDEN);
- set_bit (13, DANUBE_GPIO_P1_OUT);
- #endif
- #else // CONFIG_PORTA_DANUBE
- // set gpio's for controlling usb power and clock gating
- #if 0
- clear_bit (8, DANUBE_GPIO_P0_ALTSEL0);
- clear_bit (8, DANUBE_GPIO_P0_ALTSEL1);
- set_bit (8, DANUBE_GPIO_P0_OD);
- set_bit (8, DANUBE_GPIO_P0_DIR);
- clear_bit (8, DANUBE_GPIO_P0_PUDSEL);
- clear_bit (8, DANUBE_GPIO_P0_PUDEN);
- set_bit (8, DANUBE_GPIO_P0_OUT);
- #endif
- #endif // CONFIG_PORTA_DANUBE
- // set clock gating
- // JR: This means:: USB clock source is special internal clock generated from 36 MHz source
- set_bit (4, DANUBE_CGU_IFCCR);
- set_bit (5, DANUBE_CGU_IFCCR);
- // set power
- clear_bit (0, DANUBE_PMU_PWDCR);
- clear_bit (6, DANUBE_PMU_PWDCR);
- clear_bit (15, DANUBE_PMU_PWDCR);
- }
- /*}}}*/
- static int
- dwc3884_reset (struct dwc3884_hcd *hcd)
- {
- u32 tmp;
- // make the hardware be a host controller (default)
- clear_bit (DANUBE_USBCFG_HDSEL_BIT, DANUBE_RCU_UBSCFG);
- // set the HC's byte-order to big-endian
- // TODO: this should probably be set to the CPUs byte-order?!?
- set_bit (DANUBE_USBCFG_HOST_END_BIT, DANUBE_RCU_UBSCFG);
- set_bit (1, &hcd->global->rstctl); // gl reset
- mdelay (10);
- set_bit (0, &hcd->global->rstctl); // core reset
- mdelay (100);
- tmp = readl (&hcd->global->rstctl);
- if (tmp & 0x3)
- return -ETIMEDOUT;
- return 0;
- }
- static void complete_urbs (unsigned long param);
- /**
- * usb overcurrent irq
- */
- static irqreturn_t
- dwc3884_overcurrent_irq (int _irq, void *__hcd, struct pt_regs *_r)
- {
- int32_t retval = 0;
- #ifdef CONFIG_PORTA_DANUBE
- // JR: FIXME: Do we have to do any actions...
- // Kuepers: Yes, we have to do...fixed
- struct dwc3884_hcd *dwc3884 = __hcd;
- // really for us ?
- // ADSL "Get modem ready message" causes this IRQ, too
- if (((*DANUBE_ICU_IM4_ISR) &
- DANUBE_ICU_IM4_ISR_IR (DANUBE_USB_OC_INT - 128)) == 0) {
- warn ("interrupt sharing: not for us");
- dbg (" intsts=%08x, intena=%08x", *DANUBE_ICU_IM4_ISR,
- *DANUBE_ICU_IM4_IER);
- return IRQ_RETVAL (retval);
- }
- // disable interrupt
- // only call once:
- disable_irq_nosync (DANUBE_USB_OC_INT);
- if (dwc3884->port_oc == 0) {
- err ("USB over current");
- // The USB power is controlled by the application
- // if we switch off the power now, we can't shutdown USB devices safetly
- // so, we only disables the IRQs otherwise the system crashes
- // the IRQ is enabled again when dwc3884->port_oc is set to 0
- // GPIO29 output enables USB_PWR_EN-> switch off USB power
- // Abschalten der 5V-USB-Spg.: Problem muss abhängig von der Konfig. 100|500mA gemacht werden
- #if 0
- *DANUBE_GPIO_P1_DIR |= (1<<13);
- *DANUBE_GPIO_P1_ALTSEL0 &= ~(1<<13);
- *DANUBE_GPIO_P1_ALTSEL1 &= ~(1<<13);
- *DANUBE_GPIO_P1_OD |= (1<<13);
- if(dwc3884->power_supply == USB_POWER_SUPPLY_100mA)
- {
- *DANUBE_GPIO_P1_OUT |= (1<<13);
- }
- else
- {
- *DANUBE_GPIO_P1_OUT &= ~(1<<13);
- }
- #endif
- }
- else {
- // boeeh... gickguck
- }
- dwc3884->port_oc = 1;
- #else // CONFIG_PORTA_DANUBE
- #include <asm/danube/danube_led.h>
- struct led_config_param param = { 0 };
- struct dwc3884_hcd *dwc3884 = __hcd;
- dwc3884->port_oc = 1;
- param.operation_mask = CONFIG_OPERATION_DATA;
- param.data_mask = 1 << 5;
- //param.data = 1 << 5; // high
- param.data = 0; // low
- danube_led_config (¶m);
- #endif // CONFIG_PORTA_DANUBE
- //printk("usb over current\n");
- return IRQ_RETVAL (retval);
- }
- /**
- * start - called by the HCD-FW to initialize the
- * driver/hardware at the start (after the call to the hcd_alloc())
- */
- static int
- start (struct usb_hcd *hcd)
- {
- struct dwc3884_hcd *dwc3884 =
- list_entry (hcd, struct dwc3884_hcd, hcd);
- struct usb_device *udev;
- struct usb_bus *bus;
- u32 tmp;
- int status, i;
- dwc3884_power_on ();
- spin_lock_init (&dwc_hcd->lock);
- tasklet_init (&dwc3884->done_tasklet, complete_urbs,
- (unsigned long) dwc3884);
- INIT_LIST_HEAD (&dwc3884->done_urbs);
- dwc3884->prev_framenr = -1;
- dwc3884->frame_counter = 0;
- dwc3884->port_oc = 0;
- #ifdef CONFIG_PORTA_DANUBE
- // USB power supply 0:100mA:1:500mA
- // USBPowerSupply is a config value from nvram settings
- dwc3884->power_supply = USBPowerSupply;
- #endif // CONFIG_PORTA_DANUBE
Advertisement
Add Comment
Please, Sign In to add comment