Exemple #1
0
int max8907c_pwr_en_config(void)
{
	int ret;
	u8 data;

	if (!max8907c_client)
		return -EINVAL;

	/*
	 * Enable/disable PWREN h/w control mechanism (PWREN signal must be
	 * inactive = high at this time)
	 */
	ret = max8907c_set_bits(max8907c_client, MAX8907C_REG_RESET_CNFG,
					MAX8907C_MASK_PWR_EN, MAX8907C_PWR_EN);
	if (ret != 0)
		return ret;

	/*
	 * When enabled, connect PWREN to SEQ2 by clearing SEQ2 configuration
	 * settings for silicon revision that requires s/w WAR. On other
	 * MAX8907B revisions PWREN is always connected to SEQ2.
	 */
	data = max8907c_reg_read(max8907c_client, MAX8907C_REG_II2RR);

	if (data == MAX8907B_II2RR_PWREN_WAR) {
		data = 0x00;
		ret = max8907c_reg_write(max8907c_client, MAX8907C_REG_SEQ2CNFG, data);
	}
	return ret;
}
static void max8907c_power_off(void)
{
	if (!max8907c_client)
		return;

	max8907c_set_bits(max8907c_client, MAX8907C_REG_RESET_CNFG,
						MAX8907C_MASK_POWER_OFF, 0x40);
}
Exemple #3
0
int max8907c_power_off(void)
{
	if (!max8907c_client)
		return -EINVAL;

    //                                                       
#if defined (CONFIG_MACH_STAR) || defined (CONFIG_MACH_BSSQ)

        // Disable WLED (Qwerty LED or touch LED)
        max8907c_reg_write(max8907c_client, MAX8907C_REG_ILED_CNTL, 0x00);
    
        // Disable all regulators i2c controlled, set value as i2c_enabled, discharge res connected, output disabled
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL3, 0x1e);
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL4, 0x1e);
//        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL5, 0x1e);
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL6, 0x1e);
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL7, 0x1e);
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL8, 0x1e);
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL9, 0x1e);
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL10, 0x1e);
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL11, 0x1e);
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL12, 0x1e);
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL13, 0x1e);
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL14, 0x1e);
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL15, 0x1e);
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL16, 0x1e);
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL17, 0x1e);
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL18, 0x1e);
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL19, 0x1e);
        max8907c_reg_write(max8907c_client, MAX8907C_REG_LDOCTL20, 0x1e);
    
        // Disable PWREN, SW Power off SEQ1, SFT reset
        return max8907c_set_bits(max8907c_client, MAX8907C_REG_RESET_CNFG,
                            0xe0, 0x60);
#else
        return max8907c_set_bits(max8907c_client, MAX8907C_REG_RESET_CNFG,
                            MAX8907C_MASK_POWER_OFF, 0x40);
#endif
    //                                                       
}
Exemple #4
0
static void max8907c_set_charger(struct max8907c_charger *charger)
{
	struct max8907c_charger_pdata *pdata = charger->pdata;
	int ret;
	if (charger->online) {
		ret = max8907c_reg_write(charger->i2c, MAX8907C_REG_CHG_CNTL1,
					 (pdata->topoff_threshold << 5) |
					 (pdata->restart_hysteresis << 3) |
					 (pdata->fast_charging_current));
		if (unlikely(ret != 0))
			pr_err("Failed to set CHG_CNTL1: %d\n", ret);

		ret = max8907c_set_bits(charger->i2c, MAX8907C_REG_CHG_CNTL2,
					0x30, pdata->fast_charger_time << 4);
		if (unlikely(ret != 0))
			pr_err("Failed to set CHG_CNTL2: %d\n", ret);
	} else {
		ret = max8907c_set_bits(charger->i2c, MAX8907C_REG_CHG_CNTL1, 0x80, 0x1);
		if (unlikely(ret != 0))
			pr_err("Failed to set CHG_CNTL1: %d\n", ret);
	}
}
Exemple #5
0
int max8907c_pwr_en_attach(void)
{
	int ret;

	if (!max8907c_client)
		return -EINVAL;

	/* No sequencer delay for CPU rail when it is attached */
	ret = max8907c_reg_write(max8907c_client, MAX8907C_REG_SDSEQCNT1,
							MAX8907C_DELAY_CNT0);
	if (ret != 0)
		return ret;

	return max8907c_set_bits(max8907c_client, MAX8907C_REG_SDCTL1,
					MAX8907C_MASK_CTL_SEQ, MAX8907C_CTL_SEQ);
}
Exemple #6
0
static int max8907c_i2c_probe(struct i2c_client *i2c,
			      const struct i2c_device_id *id)
{
	printk(KERN_WARNING "[MAX8907C] probe called.");

	struct max8907c *max8907c;
	struct max8907c_platform_data *pdata = i2c->dev.platform_data;
	int ret;
	int i;

	max8907c = kzalloc(sizeof(struct max8907c), GFP_KERNEL);
	if (max8907c == NULL)
		return -ENOMEM;

	max8907c->dev = &i2c->dev;
	dev_set_drvdata(max8907c->dev, max8907c);

	max8907c->i2c_power = i2c;
	i2c_set_clientdata(i2c, max8907c);

	max8907c->i2c_rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR);
	i2c_set_clientdata(max8907c->i2c_rtc, max8907c);

      //                                                     
      max8907c->i2c_adc = i2c_new_dummy(i2c->adapter, ADC_I2C_ADDR);
      i2c_set_clientdata(max8907c->i2c_adc, max8907c);
      //                                                     

	mutex_init(&max8907c->io_lock);

	for (i = 0; i < ARRAY_SIZE(cells); i++)
		cells[i].mfd_data = max8907c;
	ret = mfd_add_devices(max8907c->dev, -1, cells, ARRAY_SIZE(cells),
			      NULL, 0);
	if (ret != 0) {
	  	i2c_unregister_device(max8907c->i2c_rtc);
		kfree(max8907c);
		pr_debug("max8907c: failed to add MFD devices   %X\n", ret);
		return ret;
	}

	max8907c_client = i2c;

	max8907c_irq_init(max8907c, i2c->irq, pdata->irq_base);

	ret = max8097c_add_subdevs(max8907c, pdata);

	if (pdata->max8907c_setup)
		return pdata->max8907c_setup();
    //                                                                        
        else{
            int ret;
            ret = max8907c_set_bits(max8907c_client, MAX8907C_REG_RESET_CNFG,
                        MAX8907C_MASK_PWR_EN, MAX8907C_PWR_EN);
            if (ret != 0)
                return ret;
        }
    //                                                                            

	return ret;
}