Exemple #1
0
static int adp5520_bl_setup(struct backlight_device *bl)
{
	struct adp5520_bl *data = bl_get_data(bl);
	struct device *master = data->master;
	struct adp5520_backlight_platfrom_data *pdata = data->pdata;
	int ret = 0;

	ret |= adp5520_write(master, DAYLIGHT_MAX, pdata->l1_daylight_max);
	ret |= adp5520_write(master, DAYLIGHT_DIM, pdata->l1_daylight_dim);

	if (pdata->en_ambl_sens) {
		data->cached_daylight_max = pdata->l1_daylight_max;
		ret |= adp5520_write(master, OFFICE_MAX, pdata->l2_office_max);
		ret |= adp5520_write(master, OFFICE_DIM, pdata->l2_office_dim);
		ret |= adp5520_write(master, DARK_MAX, pdata->l3_dark_max);
		ret |= adp5520_write(master, DARK_DIM, pdata->l3_dark_dim);
		ret |= adp5520_write(master, L2_TRIP, pdata->l2_trip);
		ret |= adp5520_write(master, L2_HYS, pdata->l2_hyst);
		ret |= adp5520_write(master, L3_TRIP, pdata->l3_trip);
		ret |= adp5520_write(master, L3_HYS, pdata->l3_hyst);
		ret |= adp5520_write(master, ALS_CMPR_CFG,
			ALS_CMPR_CFG_VAL(pdata->abml_filt, L3_EN));
	}

	ret |= adp5520_write(master, BL_CONTROL,
			BL_CTRL_VAL(pdata->fade_led_law, pdata->en_ambl_sens);

	ret |= adp5520_write(master, BL_FADE, FADE_VAL(pdata->fade_in,
			pdata->fade_out));

	ret |= adp5520_set_bits(master, MODE_STATUS, BL_EN | DIM_EN);

	return ret;
}
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;
}