/** * mxs_power_configure_power_source() - Configure power block source * * This function is the core of the power configuration logic. The function * selects the power block input source and configures the whole power block * accordingly. After the configuration is complete and the system is stable * again, the function switches the CPU clock source back to PLL. Finally, * the function switches the voltage rails to DC-DC converter. */ static void mxs_power_configure_power_source(void) { int batt_ready, batt_good; struct mxs_power_regs *power_regs = (struct mxs_power_regs *)MXS_POWER_BASE; struct mxs_lradc_regs *lradc_regs = (struct mxs_lradc_regs *)MXS_LRADC_BASE; debug("SPL: Configuring power source\n"); mxs_power_setup_dcdc_clocksource(); mxs_src_power_init(); if (readl(&power_regs->hw_power_sts) & POWER_STS_VDD5V_GT_VDDIO) { batt_ready = mxs_is_batt_ready(); if (batt_ready) { /* 5V source detected, good battery detected. */ mxs_batt_boot(); } else { batt_good = mxs_is_batt_good(); if (!batt_good) { /* 5V source detected, bad battery detected. */ writel(LRADC_CONVERSION_AUTOMATIC, &lradc_regs->hw_lradc_conversion_clr); clrbits_le32(&power_regs->hw_power_battmonitor, POWER_BATTMONITOR_BATT_VAL_MASK); } mxs_5v_boot(); } } else { /* 5V not detected, booting from battery. */ mxs_batt_boot(); } /* * TODO: Do not switch CPU clock to PLL if we are VDD5V is sourced * from USB VBUS */ mxs_power_clock2pll(); mxs_init_batt_bo(); mxs_switch_vddd_to_dcdc_source(); #ifdef CONFIG_MX23 /* Fire up the VDDMEM LinReg now that we're all set. */ debug("SPL: Enabling mx23 VDDMEM linear regulator\n"); writel(POWER_VDDMEMCTRL_ENABLE_LINREG | POWER_VDDMEMCTRL_ENABLE_ILIMIT, &power_regs->hw_power_vddmemctrl); #endif }
static void mxs_power_configure_power_source(void) { int batt_ready, batt_good; struct mxs_power_regs *power_regs = (struct mxs_power_regs *)MXS_POWER_BASE; struct mxs_lradc_regs *lradc_regs = (struct mxs_lradc_regs *)MXS_LRADC_BASE; mxs_src_power_init(); if (readl(&power_regs->hw_power_sts) & POWER_STS_VDD5V_GT_VDDIO) { batt_ready = mxs_is_batt_ready(); if (batt_ready) { /* 5V source detected, good battery detected. */ mxs_batt_boot(); } else { batt_good = mxs_is_batt_good(); if (!batt_good) { /* 5V source detected, bad battery detected. */ writel(LRADC_CONVERSION_AUTOMATIC, &lradc_regs->hw_lradc_conversion_clr); clrbits_le32(&power_regs->hw_power_battmonitor, POWER_BATTMONITOR_BATT_VAL_MASK); } mxs_5v_boot(); } } else { /* 5V not detected, booting from battery. */ mxs_batt_boot(); } mxs_power_clock2pll(); mxs_init_batt_bo(); mxs_switch_vddd_to_dcdc_source(); }