static int tps65217_config_charger(struct tps65217_charger *charger) { int ret; dev_dbg(charger->dev, "%s\n", __func__); /* * tps65217 rev. G, p. 31 (see p. 32 for NTC schematic) * * The device can be configured to support a 100k NTC (B = 3960) by * setting the the NTC_TYPE bit in register CHGCONFIG1 to 1. However it * is not recommended to do so. In sleep mode, the charger continues * charging the battery, but all register values are reset to default * values. Therefore, the charger would get the wrong temperature * information. If 100k NTC setting is required, please contact the * factory. * * ATTENTION, conflicting information, from p. 46 * * NTC TYPE (for battery temperature measurement) * 0 – 100k (curve 1, B = 3960) * 1 – 10k (curve 2, B = 3480) (default on reset) * */ ret = tps65217_clear_bits(charger->tps, TPS65217_REG_CHGCONFIG1, TPS65217_CHGCONFIG1_NTC_TYPE, TPS65217_PROTECT_NONE); if (ret) { dev_err(charger->dev, "failed to set 100k NTC setting: %d\n", ret); return ret; } return 0; }
static int tps65217_pmic_disable(struct regulator_dev *dev) { struct tps65217 *tps = rdev_get_drvdata(dev); int rid = rdev_get_id(dev); if (rid < TPS65217_DCDC_1 || rid > TPS65217_LDO_4) return -EINVAL; /* Disable the regulator and password protection is level 1 */ return tps65217_clear_bits(tps, TPS65217_REG_ENABLE, dev->desc->enable_mask, TPS65217_PROTECT_L1); }
static int tps65217_pmic_disable(struct regulator_dev *dev) { struct tps65217 *tps = rdev_get_drvdata(dev); unsigned int rid = rdev_get_id(dev); if (rid < TPS65217_DCDC_1 || rid > TPS65217_LDO_4) return -EINVAL; return tps65217_clear_bits(tps, TPS65217_REG_ENABLE, tps->info[rid]->enable_mask, TPS65217_PROTECT_L1); }
static int tps65217_pmic_ldo_disable(struct regulator_dev *dev) { struct tps65217 *tps = rdev_get_drvdata(dev); unsigned int ldo = rdev_get_id(dev); if (ldo < TPS65217_LDO_1 || ldo > TPS65217_LDO_4) return -EINVAL; /* Disable the regulator and password protection is level 1 */ return tps65217_clear_bits(tps, TPS65217_REG_ENABLE, tps->info[ldo]->enable_mask, TPS65217_PROTECT_L1); }
static int tps65217_pmic_dcdc_disable(struct regulator_dev *dev) { struct tps65217 *tps = rdev_get_drvdata(dev); unsigned int dcdc = rdev_get_id(dev); if (dcdc < TPS65217_DCDC_1 || dcdc > TPS65217_DCDC_3) return -EINVAL; /* Disable the regulator and password protection is level 1 */ return tps65217_clear_bits(tps, TPS65217_REG_ENABLE, tps->info[dcdc]->enable_mask, TPS65217_PROTECT_L1); }
static int tps65217_bl_disable(struct tps65217_bl *tps65217_bl) { int rc; rc = tps65217_clear_bits(tps65217_bl->tps, TPS65217_REG_WLEDCTRL1, TPS65217_WLEDCTRL1_ISINK_ENABLE, TPS65217_PROTECT_NONE); if (rc) { dev_err(tps65217_bl->dev, "failed to disable backlight: %d\n", rc); return rc; } tps65217_bl->on = 0; dev_dbg(tps65217_bl->dev, "backlight disabled\n"); return 0; }
static int tps65217_bl_hw_init(struct tps65217_bl *tps65217_bl, struct tps65217_bl_pdata *pdata) { int rc; rc = tps65217_bl_disable(tps65217_bl); if (rc) return rc; switch (pdata->isel) { case TPS65217_BL_ISET1: /* select ISET_1 current level */ rc = tps65217_clear_bits(tps65217_bl->tps, TPS65217_REG_WLEDCTRL1, TPS65217_WLEDCTRL1_ISEL, TPS65217_PROTECT_NONE); if (rc) { dev_err(tps65217_bl->dev, "failed to select ISET1 current level: %d)\n", rc); return rc; } dev_dbg(tps65217_bl->dev, "selected ISET1 current level\n"); break; case TPS65217_BL_ISET2: /* select ISET2 current level */ rc = tps65217_set_bits(tps65217_bl->tps, TPS65217_REG_WLEDCTRL1, TPS65217_WLEDCTRL1_ISEL, TPS65217_WLEDCTRL1_ISEL, TPS65217_PROTECT_NONE); if (rc) { dev_err(tps65217_bl->dev, "failed to select ISET2 current level: %d\n", rc); return rc; } dev_dbg(tps65217_bl->dev, "selected ISET2 current level\n"); break; default: dev_err(tps65217_bl->dev, "invalid value for current level: %d\n", pdata->isel); return -EINVAL; } /* set PWM frequency */ rc = tps65217_set_bits(tps65217_bl->tps, TPS65217_REG_WLEDCTRL1, TPS65217_WLEDCTRL1_FDIM_MASK, pdata->fdim, TPS65217_PROTECT_NONE); if (rc) { dev_err(tps65217_bl->dev, "failed to select PWM dimming frequency: %d\n", rc); return rc; } return 0; }