void _backlight_on(void) { ascodec_write(0x25, ascodec_read(0x25) | 2); /* lcd power */ ascodec_write(0x1c, 8|1); ascodec_write(0x1b, 0x90); lcd_enable(true); }
void powermgmt_init_target(void) { /* Everything CHARGER, OFF! */ ascodec_write(AS3514_IRQ_ENRD0, 0); ascodec_write(AS3514_CHARGER, TMPSUP_OFF | CHG_I_50MA | CHG_V_3_90V | CHG_OFF); }
/* Disable charger and minimize all settings. Reset timers, etc. */ static void disable_charger(void) { ascodec_write(AS3514_IRQ_ENRD0, 0); ascodec_write(AS3514_CHARGER, TMPSUP_OFF | CHG_I_50MA | CHG_V_3_90V | CHG_OFF); if (charge_state > DISCHARGING) charge_state = DISCHARGING; /* Not an error state already */ charger_total_timer = 0; battery_voltage_sync(); }
/* Enable charger with specified settings. Start timers, etc. */ static void enable_charger(void) { ascodec_write(AS3514_CHARGER, BATT_CHG_I | BATT_CHG_V); /* Watch for end of charge. Temperature supervision is handled in * hardware. Charger status can be read and has no interrupt enable. */ ascodec_write(AS3514_IRQ_ENRD0, CHG_ENDOFCH); sleep(HZ/10); /* Allow charger turn-on time (it could be gradual). */ ascodec_read(AS3514_IRQ_ENRD0); /* Clear out interrupts (important!) */ charge_state = CHARGING; charger_total_timer = CHARGER_TOTAL_TIMER; battery_voltage_sync(); }
/* * little helper method to set register values. * With the help of as3514_regs, we minimize i2c * traffic. */ static void as3514_write(unsigned int reg, unsigned int value) { ascodec_write(reg, value); if (reg < AS3514_NUM_AUDIO_REGS) as3514_regs[reg] = value; }
/* Read 10-bit channel data */ unsigned short adc_read(int channel) { if ((unsigned)channel >= NUM_ADC_CHANNELS) return 0; /* Select channel */ ascodec_write(AS3514_ADC_0, (channel << 4)); unsigned char buf[2]; /* Read data */ if (ascodec_readbytes(AS3514_ADC_0, 2, buf) < 0) return 0; /* decode to 10-bit and return */ return (((buf[0] & 0x3) << 8) | buf[1]); }
void usb_drv_exit(void) { tick_remove_task(usb_tick); USB_DEV_CTRL |= (1<<10); /* soft disconnect */ usb_phy_suspend(); /* * mask all interrupts _before_ writing to VIC_INT_EN_CLEAR, * or else the core might latch the interrupt while * the write ot VIC_INT_EN_CLEAR is in the pipeline and * so cause a fake spurious interrupt. */ USB_DEV_EP_INTR_MASK = 0xffffffff; USB_DEV_INTR_MASK = 0xffffffff; VIC_INT_EN_CLEAR = INTERRUPT_USB; CGU_USB &= ~(1<<5); bitclr32(&CGU_PERI, CGU_USB_CLOCK_ENABLE); /* Disable UVDD generating LDO */ ascodec_write(AS3515_USB_UTIL, ascodec_read(AS3515_USB_UTIL) & ~(1<<4)); usb_disable_pll(); cpu_boost(0); initialized = false; logf("usb_drv_exit() !!!!\n"); }
/* Read 10-bit channel data */ unsigned short adc_read(int channel) { unsigned short data = 0; if ((unsigned)channel >= NUM_ADC_CHANNELS) return 0; ascodec_lock(); /* Select channel */ if (ascodec_write(AS3514_ADC_0, (channel << 4)) >= 0) { unsigned char buf[2]; /* * The AS3514 ADC will trigger an interrupt when the conversion * is finished, if the corresponding enable bit in IRQ_ENRD2 * is set. * Previously the code did not wait and this apparently did * not pose any problems, but this should be more correct. * Without the wait the data read back may be completely or * partially (first one of the two bytes) stale. */ ascodec_wait_adc_finished(); /* Read data */ if (ascodec_readbytes(AS3514_ADC_0, 2, buf) >= 0) { data = (((buf[0] & 0x3) << 8) | buf[1]); } } ascodec_unlock(); return data; }
static void usb_phy_on(void) { /* PHY clock */ CGU_USB = 1<<5 /* enable */ | (CLK_DIV(AS3525_PLLB_FREQ, 48000000) / 2) << 2 | 2; /* source = PLLB */ /* UVDD on */ ascodec_write(AS3515_USB_UTIL, ascodec_read(AS3515_USB_UTIL) | (1<<4)); mdelay(100); /* reset */ CCU_SRC = CCU_SRC_USB_AHB_EN|CCU_SRC_USB_PHY_EN; CCU_SRL = CCU_SRL_MAGIC_NUMBER; mdelay(1); CCU_SRC = CCU_SRC_USB_AHB_EN; mdelay(1); CCU_SRC = CCU_SRL = 0; USB_GPIO_CSR = USB_GPIO_TX_ENABLE_N | USB_GPIO_TX_BIT_STUFF_EN | USB_GPIO_XO_ON | USB_GPIO_CLK_SEL10; /* 0x06180000; */ }
void _backlight_off(void) { lcd_enable(false); ascodec_write(0x25, ascodec_read(0x25) & ~2); /* lcd power */ ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x0); }
void _backlight_on(void) { ascodec_write(0x25, ascodec_read(0x25) | 2); /* lcd power */ ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x90); lcd_enable(true); }
void usb_drv_init(void) { logf("usb_drv_init() !!!!\n"); if (!initialized) { int i; for (i = 0; i < USB_NUM_EPS; i++) { semaphore_init(&endpoints[i][0].complete, 1, 0); semaphore_init(&endpoints[i][1].complete, 1, 0); } initialized = true; } usb_enable_pll(); /* we have external power, so boost cpu */ cpu_boost(1); /* length regulator: normal operation */ ascodec_write(AS3514_CVDD_DCDC3, ascodec_read(AS3514_CVDD_DCDC3) | 1<<2); /* AHB part */ bitset32(&CGU_PERI, CGU_USB_CLOCK_ENABLE); /* reset AHB */ CCU_SRC = CCU_SRC_USB_AHB_EN; CCU_SRL = CCU_SRL_MAGIC_NUMBER; mdelay(1); CCU_SRC = CCU_SRL = 0; USB_GPIO_CSR = USB_GPIO_TX_ENABLE_N | USB_GPIO_TX_BIT_STUFF_EN | USB_GPIO_XO_ON | USB_GPIO_CLK_SEL10; /* 0x06180000; */ /* bug workaround according to linux patch */ USB_DEV_CFG = (USB_DEV_CFG & ~3) | 1; /* full speed */ /* enable soft disconnect */ USB_DEV_CTRL |= USB_DEV_CTRL_SOFT_DISCONN; usb_phy_on(); usb_phy_suspend(); USB_DEV_CTRL |= USB_DEV_CTRL_SOFT_DISCONN; /* We don't care about SVC or SOF events */ /* Right now we don't handle suspend, so mask those too */ USB_DEV_INTR_MASK = USB_DEV_INTR_SVC | USB_DEV_INTR_SOF | USB_DEV_INTR_USB_SUSPEND | USB_DEV_INTR_EARLY_SUSPEND; USB_DEV_CFG = USB_DEV_CFG_STAT_ACK | USB_DEV_CFG_UNI_DIR | USB_DEV_CFG_PI_16BIT | USB_DEV_CFG_HS | USB_DEV_CFG_SELF_POWERED | USB_DEV_CFG_CSR_PRG | USB_DEV_CFG_PHY_ERR_DETECT; USB_DEV_CTRL = USB_DEV_CTRL_DESC_UPDATE | USB_DEV_CTRL_THRES_ENABLE | USB_DEV_CTRL_BURST_ENABLE | USB_DEV_CTRL_BLEN_8DWORDS | USB_DEV_CTRL_TLEN_8THMAXSIZE; USB_DEV_EP_INTR_MASK &= ~((1<<0) | (1<<16)); /* ep 0 */ reset_endpoints(1); /* clear pending interrupts */ USB_DEV_EP_INTR = 0xffffffff; USB_DEV_INTR = 0xffffffff; VIC_INT_ENABLE = INTERRUPT_USB; usb_phy_resume(); USB_DEV_CTRL &= ~USB_DEV_CTRL_SOFT_DISCONN; USB_GPIO_CSR = USB_GPIO_TX_ENABLE_N | USB_GPIO_TX_BIT_STUFF_EN | USB_GPIO_XO_ON | USB_GPIO_HS_INTR | USB_GPIO_CLK_SEL10; /* 0x06180000; */ tick_add_task(usb_tick); usb_enum_timeout = HZ; /* one second timeout for enumeration */ }
void backlight_hw_brightness(int brightness) { ascodec_write(AS3514_DCDC15, brightness); }
void _backlight_off(void) { ascodec_write(0x25, ascodec_read(0x25) & ~2); /* lcd power */ lcd_enable(false); }