Пример #1
0
static void mxs_pwm_led_brightness_set(struct led_classdev *pled,
					    enum led_brightness value)
{
	struct mxs_pwm_led *pwm_led;
	extern int wireless_detect;
	pwm_led = container_of(pled, struct mxs_pwm_led, dev);
	/*Foxconn, KingsChen, MKD, 20131018 {*/
	//For wireless charging does not trun on
	if (wireless_detect)
		value=0;
	/*Foxconn, KingsChen, MKD, 20131018 }*/
	if (pwm_led->pwm < CONFIG_MXS_PWM_CHANNELS) {
		__raw_writel(BF_PWM_CTRL_PWM_ENABLE(pwm_led->pwm),
			     leds.base + HW_PWM_CTRL_CLR);
      /*Foxconn, KingsChen, MKD, 20130924 {*/
		__raw_writel(BF_PWM_ACTIVEn_INACTIVE(MAX_LEVEL) |
				BF_PWM_ACTIVEn_ACTIVE(MAX_LEVEL - value),
			     leds.base + HW_PWM_ACTIVEn(pwm_led->pwm));
		#if 0
		__raw_writel(BF_PWM_ACTIVEn_INACTIVE(LED_FULL) |
				BF_PWM_ACTIVEn_ACTIVE(value),
			     leds.base + HW_PWM_ACTIVEn(pwm_led->pwm));
		#endif
		/*Foxconn, KingsChen, MKD, 20130924 }*/
		__raw_writel(BF_PWM_PERIODn_SETTINGS,
			     leds.base + HW_PWM_PERIODn(pwm_led->pwm));
		__raw_writel(BF_PWM_CTRL_PWM_ENABLE(pwm_led->pwm),
			     leds.base + HW_PWM_CTRL_SET);
	}
}
Пример #2
0
static int set_bl_intensity(struct mxs_platform_bl_data *data,
			    struct backlight_device *bd, int suspended)
{
	int intensity = bd->props.brightness;
	int scaled_int;

	if (bd->props.power != FB_BLANK_UNBLANK)
		intensity = 0;
	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
		intensity = 0;
	if (suspended)
		intensity = 0;

	scaled_int = ((intensity*2)+170);
	if(!intensity) scaled_int = 0;
	__raw_writel(BF_PWM_ACTIVEn_INACTIVE(scaled_int) |
		     BF_PWM_ACTIVEn_ACTIVE(0),
		     REGS_PWM_BASE + HW_PWM_ACTIVEn(4));
	__raw_writel(BF_PWM_PERIODn_CDIV(6) |	/* divide by 64 */
		     BF_PWM_PERIODn_INACTIVE_STATE(2) |	/* low */
		     BF_PWM_PERIODn_ACTIVE_STATE(3) |	/* high */
		     BF_PWM_PERIODn_PERIOD(399),
		     REGS_PWM_BASE + HW_PWM_PERIODn(4));
	return 0;
}
static int init_bl(struct stmp3xxx_platform_bl_data *data)
{
	int ret = 0;

	pwm_clk = clk_get(NULL, "pwm");
	if (IS_ERR(pwm_clk)) {
		ret = PTR_ERR(pwm_clk);
		goto out;
	}
	clk_enable(pwm_clk);
	stmp3xxx_reset_block(REGS_PWM_BASE, 1);

	ret = stmp3xxx_request_pin(PINID_PWM2, PIN_FUN1, "lcd_lms430");
	if (ret)
		goto out_mux;

	stmp3xxx_pin_voltage(PINID_PWM2, PIN_8MA, "lcd_lms430");
	stmp3xxx_pin_strength(PINID_PWM2, PIN_3_3V, "lcd_lms430");

	HW_PWM_ACTIVEn_WR(2, BF_PWM_ACTIVEn_INACTIVE(0) |
				BF_PWM_ACTIVEn_ACTIVE(0));
	HW_PWM_PERIODn_WR(2,
			BF_PWM_PERIODn_CDIV(6) | /* divide by 64 */
			BF_PWM_PERIODn_INACTIVE_STATE(2) | /* low */
			BF_PWM_PERIODn_ACTIVE_STATE(3) | /* high */
			BF_PWM_PERIODn_PERIOD(599));
	HW_PWM_CTRL_SET(BM_PWM_CTRL_PWM2_ENABLE);

	return 0;

out_mux:
	clk_put(pwm_clk);
out:
	return ret;
}
Пример #4
0
static void free_bl(struct mxs_platform_bl_data *data)
{
	__raw_writel(BF_PWM_ACTIVEn_INACTIVE(0) |
		     BF_PWM_ACTIVEn_ACTIVE(0),
		     REGS_PWM_BASE + HW_PWM_ACTIVEn(2));
	__raw_writel(BF_PWM_PERIODn_CDIV(6) |	/* divide by 64 */
		     BF_PWM_PERIODn_INACTIVE_STATE(2) |	/* low */
		     BF_PWM_PERIODn_ACTIVE_STATE(3) |	/* high */
		     BF_PWM_PERIODn_PERIOD(599),
		     REGS_PWM_BASE + HW_PWM_PERIODn(2));
	__raw_writel(BM_PWM_CTRL_PWM2_ENABLE, REGS_PWM_BASE + HW_PWM_CTRL_CLR);

	clk_disable(pwm_clk);
	clk_put(pwm_clk);
}
static void free_bl(struct stmp3xxx_platform_bl_data *data)
{
	HW_PWM_ACTIVEn_WR(2, BF_PWM_ACTIVEn_INACTIVE(0) |
				BF_PWM_ACTIVEn_ACTIVE(0));
	HW_PWM_PERIODn_WR(2,
		BF_PWM_PERIODn_CDIV(6) | /* divide by 64 */
		BF_PWM_PERIODn_INACTIVE_STATE(2) | /* low */
		BF_PWM_PERIODn_ACTIVE_STATE(3) | /* high */
		BF_PWM_PERIODn_PERIOD(599));
	HW_PWM_CTRL_CLR(BM_PWM_CTRL_PWM2_ENABLE);
	stmp3xxx_pin_voltage(PINID_PWM2, PIN_4MA, "lcd_lms430");
	stmp3xxx_pin_strength(PINID_PWM2, PIN_1_8V, "lcd_lms430");

	stmp3xxx_release_pin(PINID_PWM2, "lcd_lms430");
	clk_disable(pwm_clk);
	clk_put(pwm_clk);
}
Пример #6
0
static int __devexit mxs_pwm_led_remove(struct platform_device *pdev)
{
	int i;
	unsigned int pwm;
	for (i = 0; i < leds.led_num; i++) {
		pwm = leds.leds[i].pwm;
		__raw_writel(BF_PWM_CTRL_PWM_ENABLE(pwm),
			     leds.base + HW_PWM_CTRL_CLR);
		__raw_writel(BF_PWM_ACTIVEn_INACTIVE(0) |
				BF_PWM_ACTIVEn_ACTIVE(0),
			     leds.base + HW_PWM_ACTIVEn(pwm));
		__raw_writel(BF_PWM_PERIODn_SETTINGS,
			     leds.base + HW_PWM_PERIODn(pwm));
		led_classdev_unregister(&leds.leds[i].dev);
	}

	clk_disable(leds.pwm_clk);
	clk_put(leds.pwm_clk);

	return 0;
}
Пример #7
0
static int init_bl(struct mxs_platform_bl_data *data)
{
	int ret = 0;
	pwm_clk = clk_get(NULL, "pwm");
	if (IS_ERR(pwm_clk)) {
		ret = PTR_ERR(pwm_clk);
		return ret;
	}
	clk_enable(pwm_clk);
	mxs_reset_block(REGS_PWM_BASE, 1);

	__raw_writel(BF_PWM_ACTIVEn_INACTIVE(400) |
		     BF_PWM_ACTIVEn_ACTIVE(0),
		     REGS_PWM_BASE + HW_PWM_ACTIVEn(4));
	__raw_writel(BF_PWM_PERIODn_CDIV(6) |	/* divide by 64 */
		     BF_PWM_PERIODn_INACTIVE_STATE(2) |	/* low */
		     BF_PWM_PERIODn_ACTIVE_STATE(3) |	/* high */
		     BF_PWM_PERIODn_PERIOD(599),
		     REGS_PWM_BASE + HW_PWM_PERIODn(4));
	__raw_writel(BM_PWM_CTRL_PWM4_ENABLE, REGS_PWM_BASE + HW_PWM_CTRL_SET);
	__raw_writel(BF_PINCTRL_DOUT3_DOUT(1 << 30), REGS_PINCTRL_BASE + HW_PINCTRL_DOUT3_SET);
	return 0;
}
Пример #8
0
static int set_bl_intensity(struct mxs_platform_bl_data *data,
			    struct backlight_device *bd, int suspended)
{
	int intensity = bd->props.brightness;
	int scaled_int;

	if (bd->props.power != FB_BLANK_UNBLANK)
		intensity = 0;
	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
		intensity = 0;
	if (suspended)
		intensity = 0;

	/*
	 * This is not too cool but what can we do?
	 * Luminance changes non-linearly...
	 */
	if (regulator_set_current_limit
	    (data->regulator, bl_to_power(intensity), bl_to_power(intensity)))
		return -EBUSY;

	scaled_int = values[intensity / 10];
	if (scaled_int < 100) {
		int rem = intensity - 10 * (intensity / 10);	/* r = i % 10; */
		scaled_int += rem * (values[intensity / 10 + 1] -
				     values[intensity / 10]) / 10;
	}
	__raw_writel(BF_PWM_ACTIVEn_INACTIVE(scaled_int) |
		     BF_PWM_ACTIVEn_ACTIVE(0),
		     REGS_PWM_BASE + HW_PWM_ACTIVEn(2));
	__raw_writel(BF_PWM_PERIODn_CDIV(6) |	/* divide by 64 */
		     BF_PWM_PERIODn_INACTIVE_STATE(2) |	/* low */
		     BF_PWM_PERIODn_ACTIVE_STATE(3) |	/* high */
		     BF_PWM_PERIODn_PERIOD(399),
		     REGS_PWM_BASE + HW_PWM_PERIODn(2));
	return 0;
}