static int uhci_pci_resume(struct usb_hcd *hcd, bool hibernated) { struct uhci_hcd *uhci = hcd_to_uhci(hcd); u16 pmc_enable = 0; /*CharlesTu,2009.08.30,patch uhci device disconnet irq nobody care issue * Before clear D3 mode ,disable UHCI resume interrupt * The right sequence: disconnect->wakeup->D0 mode->clear resume. */ if (enable_ehci_wake){ REG8_VAL(USB20_HOST_DEVICE_CFG_BASE_ADDR+0x0304) &= ~0x02; REG8_VAL(USB20_HOST_DEVICE_CFG_BASE_ADDR+0x1504) &= ~0x02; pci_read_config_word(to_pci_dev(uhci_dev(uhci)), 0x84, &pmc_enable); pmc_enable &= ~0x03; pci_write_config_word(to_pci_dev(uhci_dev(uhci)), 0x84, pmc_enable); } dev_dbg(uhci_dev(uhci), "%s\n", __func__); /* Since we aren't in D3 any more, it's safe to set this flag * even if the controller was dead. */ set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); spin_lock_irq(&uhci->lock); /* Make sure resume from hibernation re-enumerates everything */ if (hibernated) { uhci->reset_hc(uhci); finish_reset(uhci); } /* The firmware may have changed the controller settings during * a system wakeup. Check it and reconfigure to avoid problems. */ else { check_and_reset_hc(uhci); } configure_hc(uhci); /* Tell the core if the controller had to be reset */ if (uhci->rh_state == UHCI_RH_RESET) usb_root_hub_lost_power(hcd->self.root_hub); spin_unlock_irq(&uhci->lock); /* If interrupts don't work and remote wakeup is enabled then * the suspended root hub needs to be polled. */ if (!uhci->RD_enable && hcd->self.root_hub->do_remote_wakeup) set_bit(HCD_FLAG_POLL_RH, &hcd->flags); /* Does the root hub have a port wakeup pending? */ usb_hcd_poll_rh_status(hcd); return 0; }
static int g2214_reg_init(void) { unsigned int tmp_data = 2 ; /* Set safety time = 8hours */ tmp_data = g2214_read(REG_A6); tmp_data = tmp_data & (~(BIT4|BIT5|BIT6|BIT7)); tmp_data = tmp_data | (gmt->safety_time<<4); g2214_write(REG_A6,tmp_data); if(gmt->no_batt == 0){ /* Enable USB hardware mode */ REG8_VAL(USB_BASE_ADD+0x400+0x3F) = REG8_VAL(USB_BASE_ADD+0x400+0x3F) | BIT5; udelay(100000); /* Set battery charge voltage level */ g2214_write(REG_A8,(gmt->vseta << 6)); /* default value = 0x80 */ /* Set ISET_DCIN & ISET_VBUS & ISETA current level */ if(!gmt->otg_check ){ /* Check OTG */ gmt->usb_otg_enabled = 1; gmt->current_state = USB_OTG; g2214_write(REG_A8,((gmt->vseta << 6) | BIT3)); printf("USB OTG Mode. \n"); }else if(g2214_read(REG_A10) & BIT2){ /* DCIN */ gmt->current_state = DCIN; tmp_data = ((gmt->iset_dcin<<6) | (gmt->iset_vbus<<4) | gmt->resum_set.dcin); g2214_write(REG_A5,tmp_data); printf("DC Mode. \n"); }else if(gmt->usb_connected){ gmt->usb_otg_enabled = 0; if(REG8_VAL(USB_BASE_ADD+0x400+0x22) & BIT6){ /* Check adapter mode or pc mode */ gmt->current_state = USB_ADP; tmp_data = ((gmt->iset_dcin<<6) | (ADP_MODE<<4) | gmt->resum_set.otgadp); g2214_write(REG_A5,tmp_data); g2214_write(REG_A8,((gmt->vseta << 6) & ( ~(BIT3)))); printf("USB Adapter Mode. \n"); }else{ gmt->current_state = USB_PC; tmp_data = ((gmt->iset_dcin<<6) | (PC_MODE<<4) | gmt->resum_set.otgpc); g2214_write(REG_A5,tmp_data); g2214_write(REG_A8,((gmt->vseta << 6) & ( ~(BIT3)))); printf("USB PC Mode. \n"); } }else{ /* N/A IN */ gmt->current_state = USB_PC; tmp_data = ((gmt->iset_dcin<<6) | (PC_MODE<<4) | gmt->resum_set.otgpc); g2214_write(REG_A5,tmp_data); printf("N/A power source. \n"); } /* Disable USB hardware mode */ REG8_VAL(USB_BASE_ADD+0x400+0x3F) = REG8_VAL(USB_BASE_ADD+0x400+0x3F) & (~( BIT5)); } return 0; }
/* Disable PWM0 frequency output to avoid I20 hang situation */ void PWM0_GPIO_Output_Without_Frequecny_Control(int enable) { printk("Disable PWM0 frequency function, use GPIO31 to %s PWM output\n",(enable==1)?"enable":"disable"); REG8_VAL(PWM0_BASE_ADDR)=0x0; REG8_VAL(GPIO_OC_GP31_BYTE_ADDR) |= 0x08; REG8_VAL(GPIO_CTRL_GP31_BYTE_ADDR) |= 0x08; if ( enable ) REG8_VAL(GPIO_OD_GP31_BYTE_ADDR) |= 0x08; else REG8_VAL(GPIO_OD_GP31_BYTE_ADDR) &= ~0x08; printk("OK\n"); }
static void wm8650_wakeup_exit(u8 wk_src) { bat_dbg("Enter\n"); bat_dbg("vt1603 battery alarm use wakeup src:0x%08x\n", wk_src); /* disable WAKE_UP */ REG8_VAL(GPIO_CTRL_GP2_WAKEUP_SUS_BYTE_ADDR) &= ~wk_src; bat_dbg("Exit\n"); return ; }
static void wm8650_wakeup_init(int wk_src) { bat_dbg("Enter\n"); bat_dbg("vt1603 battery alarm use wakeup src:0x%08x\n", wk_src); /* disable WAKE_UP first */ REG8_VAL(GPIO_CTRL_GP2_WAKEUP_SUS_BYTE_ADDR) &= ~wk_src; /* disable WAKE_UP output */ REG8_VAL(GPIO_OC_GP2_WAKEUP_SUS_BYTE_ADDR) &= ~wk_src; /* enable pull high/low */ REG8_VAL(GPIO_PULL_EN_GP2_WAKEUP_SUS_BYTE_ADDR) |= wk_src; /* set pull high WAKE_UP */ REG8_VAL(GPIO_PULL_CTRL_GP2_WAKEUP_SUS_BYTE_ADDR) |= wk_src; /* enable WAKE_UP last */ REG8_VAL(GPIO_CTRL_GP2_WAKEUP_SUS_BYTE_ADDR) |= wk_src; bat_dbg("Exit\n"); return ; }
//largeElec = 1: large electricity charge, largeElec = 0: small electricity charge void pull_charge_elec_pin(int largeElec) { unsigned int val; if ((s_charge_elec_pin.ctl == 0) || (s_charge_elec_pin.oc == 0) || (s_charge_elec_pin.od == 0)) return; val = 1 << s_charge_elec_pin.bitmap; if (s_charge_elec_pin.act == 0) largeElec = ~largeElec; if (largeElec) { REG8_VAL(s_charge_elec_pin.od) |= val; } else { REG8_VAL(s_charge_elec_pin.od) &= ~val; } REG8_VAL(s_charge_elec_pin.oc) |= val; REG8_VAL(s_charge_elec_pin.ctl) |= val; }
void pwm_set_gpio(int no,int enable) { unsigned int pwm_pin; pwm_pin = (no==0)? 0x08:0x04; if( enable ) { REG8_VAL(GPIO_OD_GP31_PWM_BYTE_ADDR) &= ~pwm_pin; REG8_VAL(GPIO_CTRL_GP31_PWM_BYTE_ADDR) &= ~pwm_pin; } else { REG8_VAL(GPIO_OD_GP31_PWM_BYTE_ADDR) &= ~pwm_pin; REG8_VAL(GPIO_OC_GP31_PWM_BYTE_ADDR) |= pwm_pin; REG8_VAL(GPIO_CTRL_GP31_PWM_BYTE_ADDR) |= pwm_pin; } /* set to PWM mode */ if( no == 1 ) REG32_VAL(GPIO_PIN_SHARING_SEL_4BYTE_ADDR) |= 0x10; pwm_pin = REG32_VAL(PWM_CTRL_REG_ADDR + (0x10 * no)); if (((pwm_pin&PWM_ENABLE) != 0)&&(enable == 1)) set_lcd_power(1); if (((pwm_pin&PWM_ENABLE) == 0)&&(enable == 0)) set_lcd_power(0); }