static int adp8870_i2c_resume(struct i2c_client *client) { adp8870_set_bits(client, ADP8870_MDCR, NSTBY); adp8870_set_bits(client, ADP8870_MDCR, BLEN); /* BL_EN is set to 0 in standby */ return 0; }
static int adp8870_bl_set(struct backlight_device *bl, int brightness) { struct adp8870_bl *data = bl_get_data(bl); struct i2c_client *client = data->client; int ret = 0; if (data->pdata->en_ambl_sens) { if ((brightness > 0) && (brightness < ADP8870_MAX_BRIGHTNESS)) { /* Disable Ambient Light auto adjust */ ret = adp8870_clr_bits(client, ADP8870_MDCR, CMP_AUTOEN); if (ret) return ret; ret = adp8870_write(client, ADP8870_BLMX1, brightness); if (ret) return ret; } else { /* * MAX_BRIGHTNESS -> Enable Ambient Light auto adjust * restore daylight l1 sysfs brightness */ ret = adp8870_write(client, ADP8870_BLMX1, data->cached_daylight_max); if (ret) return ret; ret = adp8870_set_bits(client, ADP8870_MDCR, CMP_AUTOEN); if (ret) return ret; } } else { ret = adp8870_write(client, ADP8870_BLMX1, brightness); if (ret) return ret; } if (data->current_brightness && brightness == 0) ret = adp8870_set_bits(client, ADP8870_MDCR, DIM_EN); else if (data->current_brightness == 0 && brightness) ret = adp8870_clr_bits(client, ADP8870_MDCR, DIM_EN); if (!ret) data->current_brightness = brightness; return ret; }
static ssize_t adp8870_bl_ambient_light_zone_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct adp8870_bl *data = dev_get_drvdata(dev); unsigned long val; uint8_t reg_val; int ret; ret = kstrtoul(buf, 10, &val); if (ret) return ret; if (val == 0) { /* Enable automatic ambient light sensing */ adp8870_set_bits(data->client, ADP8870_MDCR, CMP_AUTOEN); } else if ((val > 0) && (val < 6)) { /* Disable automatic ambient light sensing */ adp8870_clr_bits(data->client, ADP8870_MDCR, CMP_AUTOEN); /* Set user supplied ambient light zone */ mutex_lock(&data->lock); adp8870_read(data->client, ADP8870_CFGR, ®_val); reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT); reg_val |= (val - 1) << CFGR_BLV_SHIFT; adp8870_write(data->client, ADP8870_CFGR, reg_val); mutex_unlock(&data->lock); } return count; }
static int adp8870_i2c_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); adp8870_set_bits(client, ADP8870_MDCR, NSTBY | BLEN); return 0; }
static int adp8870_led_setup(struct adp8870_led *led) { struct i2c_client *client = led->client; int ret = 0; ret = adp8870_write(client, ADP8870_ISC1 + led->id - 1, 0); ret |= adp8870_set_bits(client, ADP8870_ISCC, 1 << (led->id - 1)); if (led->id > 4) ret |= adp8870_set_bits(client, ADP8870_ISCT1, (led->flags & 0x3) << ((led->id - 5) * 2)); else ret |= adp8870_set_bits(client, ADP8870_ISCT2, (led->flags & 0x3) << ((led->id - 1) * 2)); return ret; }
static int adp8870_i2c_resume(struct i2c_client *client) { adp8870_set_bits(client, ADP8870_MDCR, NSTBY | BLEN); return 0; }
static int adp8870_bl_setup(struct backlight_device *bl) { struct adp8870_bl *data = bl_get_data(bl); struct i2c_client *client = data->client; struct adp8870_backlight_platform_data *pdata = data->pdata; int ret = 0; ret = adp8870_write(client, ADP8870_BLSEL, ~pdata->bl_led_assign); if (ret) return ret; ret = adp8870_write(client, ADP8870_PWMLED, pdata->pwm_assign); if (ret) return ret; ret = adp8870_write(client, ADP8870_BLMX1, pdata->l1_daylight_max); if (ret) return ret; ret = adp8870_write(client, ADP8870_BLDM1, pdata->l1_daylight_dim); if (ret) return ret; if (pdata->en_ambl_sens) { data->cached_daylight_max = pdata->l1_daylight_max; ret = adp8870_write(client, ADP8870_BLMX2, pdata->l2_bright_max); if (ret) return ret; ret = adp8870_write(client, ADP8870_BLDM2, pdata->l2_bright_dim); if (ret) return ret; ret = adp8870_write(client, ADP8870_BLMX3, pdata->l3_office_max); if (ret) return ret; ret = adp8870_write(client, ADP8870_BLDM3, pdata->l3_office_dim); if (ret) return ret; ret = adp8870_write(client, ADP8870_BLMX4, pdata->l4_indoor_max); if (ret) return ret; ret = adp8870_write(client, ADP8870_BLDM4, pdata->l4_indor_dim); if (ret) return ret; ret = adp8870_write(client, ADP8870_BLMX5, pdata->l5_dark_max); if (ret) return ret; ret = adp8870_write(client, ADP8870_BLDM5, pdata->l5_dark_dim); if (ret) return ret; ret = adp8870_write(client, ADP8870_L2TRP, pdata->l2_trip); if (ret) return ret; ret = adp8870_write(client, ADP8870_L2HYS, pdata->l2_hyst); if (ret) return ret; ret = adp8870_write(client, ADP8870_L3TRP, pdata->l3_trip); if (ret) return ret; ret = adp8870_write(client, ADP8870_L3HYS, pdata->l3_hyst); if (ret) return ret; ret = adp8870_write(client, ADP8870_L4TRP, pdata->l4_trip); if (ret) return ret; ret = adp8870_write(client, ADP8870_L4HYS, pdata->l4_hyst); if (ret) return ret; ret = adp8870_write(client, ADP8870_L5TRP, pdata->l5_trip); if (ret) return ret; ret = adp8870_write(client, ADP8870_L5HYS, pdata->l5_hyst); if (ret) return ret; ret = adp8870_write(client, ADP8870_ALS1_EN, L5_EN | L4_EN | L3_EN | L2_EN); if (ret) return ret; ret = adp8870_write(client, ADP8870_CMP_CTL, ALS_CMPR_CFG_VAL(pdata->abml_filt)); if (ret) return ret; } ret = adp8870_write(client, ADP8870_CFGR, BL_CFGR_VAL(pdata->bl_fade_law, 0)); if (ret) return ret; ret = adp8870_write(client, ADP8870_BLFR, FADE_VAL(pdata->bl_fade_in, pdata->bl_fade_out)); if (ret) return ret; /* * ADP8870 Rev0 requires GDWN_DIS bit set */ ret = adp8870_set_bits(client, ADP8870_MDCR, BLEN | DIM_EN | NSTBY | (data->revid == 0 ? GDWN_DIS : 0)); return ret; }