Ejemplo n.º 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);
	}
}
Ejemplo n.º 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;
}
Ejemplo n.º 3
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_hx8238a");
	if (ret)
		goto out_mux;
	stmp3xxx_pin_voltage(PINID_PWM2, PIN_12MA, "lcd_hx8238a");
	stmp3xxx_pin_strength(PINID_PWM2, PIN_3_3V, "lcd_hx8238a");

	stmp3xxx_clearl(BM_PWM_CTRL_PWM2_ENABLE, REGS_PWM_BASE + HW_PWM_CTRL);
	stmp3xxx_setl(BM_PWM_CTRL_PWM2_ANA_CTRL_ENABLE, REGS_PWM_BASE + HW_PWM_CTRL);
	__raw_writel(BF(10, PWM_ACTIVEn_INACTIVE) |
				BF(5, PWM_ACTIVEn_ACTIVE),
				REGS_PWM_BASE + HW_PWM_ACTIVEn(2));
	__raw_writel(BF(1, PWM_PERIODn_CDIV) | /* divide by 2 */
			BF(2, PWM_PERIODn_INACTIVE_STATE) | /* low */
			BF(3, PWM_PERIODn_ACTIVE_STATE) | /* high */
			BF(14, PWM_PERIODn_PERIOD),
			REGS_PWM_BASE + HW_PWM_PERIODn(2));
	return 0;

out_mux:
	clk_put(pwm_clk);
out:
	return ret;
}
Ejemplo n.º 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);
}
Ejemplo n.º 5
0
void imx233_pwm_setup(int channel, int period, int cdiv, int active,
    int active_state, int inactive, int inactive_state)
{
    /* stop */
    bool enable = imx233_pwm_is_enabled(channel);
    if(enable)
        imx233_pwm_enable(channel, false);
    /* setup pin */
    imx233_pinctrl_setup_vpin(VPIN_PWM(channel), "pwm", PINCTRL_DRIVE_4mA, false);
    /* watch the order ! active THEN period
     * NOTE: the register value is period-1 */
    HW_PWM_ACTIVEn(channel) = BF_OR2(PWM_ACTIVEn, ACTIVE(active), INACTIVE(inactive));
    HW_PWM_PERIODn(channel) = BF_OR4(PWM_PERIODn, PERIOD(period - 1),
        ACTIVE_STATE(active_state), INACTIVE_STATE(inactive_state), CDIV(cdiv));
    /* restore */
    imx233_pwm_enable(channel, enable);
}
Ejemplo n.º 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;
}
Ejemplo n.º 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;
}
Ejemplo n.º 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;
}