static int max8998_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) { struct max8998_rtc_info *info = dev_get_drvdata(dev); u8 data[8]; u8 val; int ret; ret = max8998_bulk_read(info->rtc, MAX8998_ALARM0_SEC, 8, data); if (ret < 0) return ret; max8998_data_to_tm(data, &alrm->time); ret = max8998_read_reg(info->rtc, MAX8998_ALARM0_CONF, &val); if (ret < 0) return ret; alrm->enabled = !!val; ret = max8998_read_reg(info->rtc, MAX8998_RTC_STATUS, &val); if (ret < 0) return ret; if (val & ALARM0_STATUS) alrm->pending = 1; else alrm->pending = 0; return 0; }
static int max8998_rtc_read_time(struct device *dev, struct rtc_time *tm) { struct max8998_rtc_info *info = dev_get_drvdata(dev); u8 data[8]; int ret; ret = max8998_bulk_read(info->rtc, MAX8998_RTC_SEC, 8, data); if (ret < 0) return ret; max8998_data_to_tm(data, tm); return rtc_valid_tm(tm); }
static irqreturn_t max8998_int_work_func(int irq, void *max8998_chg) { int ret; u8 data[MAX8998_NUM_IRQ_REGS]; struct chg_data *chg = max8998_chg; struct i2c_client *i2c = chg->iodev->i2c; ret = max8998_bulk_read(i2c, MAX8998_REG_IRQ1, MAX8998_NUM_IRQ_REGS, data); if (ret < 0) goto err; wake_lock(&chg->work_wake_lock); #ifndef TOPOFF_CURRENT_CHECK if (data[MAX8998_REG_IRQ3] & MAX8998_IRQ_TOPOFFR_MASK) { bat_info("%s : topoff intr(%d)\n", __func__, chg->set_batt_full); if (chg->set_batt_full) chg->bat_info.batt_is_full = true; else { chg->set_batt_full = true; if (chg->cable_status == CABLE_TYPE_AC) max8998_write_reg(i2c, MAX8998_REG_CHGR1, (MAX8998_TOPOFF_10 << MAX8998_SHIFT_TOPOFF) | (MAX8998_RSTR_DISABLE << MAX8998_SHIFT_RSTR) | (MAX8998_ICHG_600 << MAX8998_SHIFT_ICHG)); else if (chg->cable_status == CABLE_TYPE_USB) max8998_write_reg(i2c, MAX8998_REG_CHGR1, (MAX8998_TOPOFF_10 << MAX8998_SHIFT_TOPOFF) | (MAX8998_RSTR_DISABLE << MAX8998_SHIFT_RSTR) | (MAX8998_ICHG_475 << MAX8998_SHIFT_ICHG)); } } #endif if (data[MAX8998_REG_IRQ4] & MAX8998_IRQ_LOBAT1_MASK) max8998_lowbat_warning(chg); if (data[MAX8998_REG_IRQ4] & MAX8998_IRQ_LOBAT2_MASK) max8998_lowbat_critical(chg); queue_work(chg->monitor_wqueue, &chg->bat_work); return IRQ_HANDLED; err: pr_err("%s : pmic read error\n", __func__); return IRQ_HANDLED; }
static irqreturn_t max8998_int_work_func(int irq, void *max8998_chg) { int ret; u8 data[MAX8998_NUM_IRQ_REGS]; struct chg_data *chg = max8998_chg; struct i2c_client *i2c = chg->iodev->i2c; ret = max8998_bulk_read(i2c, MAX8998_REG_IRQ1, MAX8998_NUM_IRQ_REGS, data); if (ret < 0) goto err; wake_lock(&chg->work_wake_lock); if (data[MAX8998_REG_IRQ3] & MAX8998_IRQ_TOPOFFR_MASK) { bat_info("%s : topoff intr(%d)\n", __func__, chg->set_batt_full); if (chg->set_batt_full) chg->bat_info.batt_is_full = true; else { chg->set_batt_full = true; if (chg->cable_status == CABLE_TYPE_AC) #if defined(CONFIG_ARIES_NTT) max8998_write_reg(i2c, MAX8998_REG_CHGR1, (MAX8998_TOPOFF_10 << MAX8998_SHIFT_TOPOFF) | (MAX8998_RSTR_DISABLE << MAX8998_SHIFT_RSTR) | (MAX8998_ICHG_700 << MAX8998_SHIFT_ICHG)); #else max8998_write_reg(i2c, MAX8998_REG_CHGR1, (MAX8998_TOPOFF_10 << MAX8998_SHIFT_TOPOFF) | (MAX8998_RSTR_DISABLE << MAX8998_SHIFT_RSTR) | (MAX8998_ICHG_600 << MAX8998_SHIFT_ICHG)); #endif else if (chg->cable_status == CABLE_TYPE_USB) max8998_write_reg(i2c, MAX8998_REG_CHGR1, (MAX8998_TOPOFF_25 << MAX8998_SHIFT_TOPOFF) | (MAX8998_RSTR_DISABLE << MAX8998_SHIFT_RSTR) | (MAX8998_ICHG_475 << MAX8998_SHIFT_ICHG)); }