bool _backlight_init(void)
{
    pmu_write(0x2a, 6);
    pmu_write(0x28, 0x2e);
    pmu_write(0x2b, 20);

    _backlight_on();

    return true;
}
void pmu_ldo_on_in_standby(unsigned int ldo, int onoff)
{
    if (ldo < 4)
    {
        unsigned char newval = pmu_read(0x3B) & ~(1 << (2 * ldo));
        if (onoff) newval |= 1 << (2 * ldo);
        pmu_write(0x3B, newval);
    }
    else if (ldo < 8)
    {
        unsigned char newval = pmu_read(0x3C) & ~(1 << (2 * (ldo - 4)));
        if (onoff) newval |= 1 << (2 * (ldo - 4));
        pmu_write(0x3C, newval);
    }
}
Example #3
0
/*
 * Do I2C/PMU writes to bring up SD card bus power
 *
 */
void board_sdmmc_voltage_init(void)
{
	/* Enable LDO5 with 3.3v for SDMMC3 */
	pmu_write(PMU_REG_LDO5, PMU_LDO5(HIGH_POWER, 3300));

	/* Switch the power on */
	gpio_request(TEGRA_GPIO(J, 2), "EN_3V3_EMMC");
	gpio_direction_output(TEGRA_GPIO(J, 2), 1);
}
Example #4
0
bool_t pmu_init(void)
{
	u8_t val;

	iic_init();

	if(pmu_read(0x31, &val))
		pmu_write(0x31, val & 0xf8);

	return TRUE;
}
int pmu_read_adc(unsigned int adc)
{
    int data = 0;
    mutex_lock(&pmu_adc_mutex);
    pmu_write(0x54, 5 | (adc << 4));
    while ((data & 0x80) == 0)
    {
        yield();
        data = pmu_read(0x57);
    }
    int value = (pmu_read(0x55) << 2) | (data & 3);
    mutex_unlock(&pmu_adc_mutex);
    return value;
}
/* main init */
void pmu_init(void)
{
    mutex_init(&pmu_adc_mutex);
    queue_init(&pmu_queue, false);

    create_thread(pmu_thread,
            pmu_thread_stack, sizeof(pmu_thread_stack), 0,
            "PMU" IF_PRIO(, PRIORITY_SYSTEM) IF_COP(, CPU));

    /* configure PMU interrutps */
    for (int i = 0; i < 6; i++)
        ints_msk[i] = 0xff;

#if CONFIG_CHARGING
    ints_msk[0] &= ~PCF5063X_INT1_ADPINS &    /* FireWire */
                   ~PCF5063X_INT1_ADPREM;
#endif
    ints_msk[1] &= ~PCF5063X_INT2_EXTON2R &   /* USB */
                   ~PCF5063X_INT2_EXTON2F;
#ifdef IPOD_ACCESSORY_PROTOCOL
    ints_msk[1] &= ~PCF5063X_INT2_EXTON3R &   /* Accessory */
                   ~PCF5063X_INT2_EXTON3F;
#endif
    ints_msk[5] &= ~PCF50635_INT6_GPIO2;      /* Holdswitch */

    pmu_write_multiple(PCF5063X_REG_INT1M, 5, ints_msk);
    pmu_write(PCF50635_REG_INT6M, ints_msk[5]);

    /* clear all */
    unsigned char ints[5];
    pmu_read_multiple(PCF5063X_REG_INT1, 5, ints);
    pmu_read(PCF50635_REG_INT6);

    /* get initial values */
#if CONFIG_CHARGING
    pmu_read_inputs_mbcs();
#endif
    pmu_read_inputs_ooc();
    pmu_read_inputs_gpio();

    eint_register(&pmu_eint);
}
Example #7
0
static inline void software_reset(void)
{
	uint16_t pmucnt2;

	switch (current_cpu_type()) {
	case CPU_VR4122:
	case CPU_VR4131:
	case CPU_VR4133:
		pmucnt2 = pmu_read(PMUCNT2REG);
		pmucnt2 |= SOFTRST;
		pmu_write(PMUCNT2REG, pmucnt2);
		break;
	default:
		set_c0_status(ST0_BEV | ST0_ERL);
		change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED);
		__flush_cache_all();
		write_c0_wired(0);
		__asm__("jr	%0"::"r"(0xbfc00000));
		break;
	}
}
/* returns raw value, 8 or 10-bit resolution */
unsigned short pmu_read_adc(const struct pmu_adc_channel *ch)
{
    mutex_lock(&pmu_adc_mutex);

    pmu_write(PCF5063X_REG_ADCC3, ch->adcc3);
    if (ch->bias_dly)
        sleep(ch->bias_dly);
    uint8_t buf[2] = { ch->adcc2, ch->adcc1 | PCF5063X_ADCC1_ADCSTART };
    pmu_write_multiple(PCF5063X_REG_ADCC2, 2, buf);

    int adcs3 = 0;
    while (!(adcs3 & PCF5063X_ADCS3_ADCRDY))
    {
        yield();
        adcs3 = pmu_read(PCF5063X_REG_ADCS3);
    }

    int raw = pmu_read(PCF5063X_REG_ADCS1);
    if ((ch->adcc1 & PCF5063X_ADCC1_RES_MASK) == PCF5063X_ADCC1_RES_10BIT)
        raw = (raw << 2) | (adcs3 & PCF5063X_ADCS3_ADCDAT1L_MASK);

    mutex_unlock(&pmu_adc_mutex);
    return raw;
}
void pmu_enter_standby(void)
{
    pmu_write(0xc, 1);
}
void pmu_set_wake_condition(unsigned char condition)
{
    pmu_write(0xd, condition);
}
void pmu_ldo_power_off(unsigned int ldo)
{
    if (ldo > 6) return;
    pmu_write(0x2e + (ldo << 1), 0);
}
void pmu_hdd_power(bool on)
{
    pmu_write(0x1b, on ? 1 : 0);
}
void pmu_ldo_set_voltage(unsigned int ldo, unsigned char voltage)
{
    if (ldo > 6) return;
    pmu_write(0x2d + (ldo << 1), voltage);
}
void _backlight_off(void)
{
    pmu_write(0x29, 0);
}
void _backlight_on(void)
{
    pmu_write(0x29, 1);
}
void _backlight_set_brightness(int brightness)
{
    pmu_write(0x28, brightness);
}