Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 16649596 authored by Olof Johansson's avatar Olof Johansson
Browse files

Merge tag 'renesas-backlight-for-v3.12' of...

Merge tag 'renesas-backlight-for-v3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas into next/boards

From Simon Horman:
Renesas ARM and SH based SoC backlight drivers for v3.12

Backlight drivers used by SH and ARM SH-Mobile boards.

* tag 'renesas-backlight-for-v3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas

:
  ARM: mach-shmobile: ag5evm: Use bd6107 backlight driver
  sh: kfr2r09: Use lv5207lp backlight
  sh: ecovec24: Use gpio-backlight
  ARM: mach-shmobile: mackerel: Use gpio-backlight
  backlight: Add ROHM BD6107 backlight driver
  backlight: Add Sanyo LV5207LP backlight driver
  backlight: Add GPIO-based backlight driver

Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
parents ad81f054 0fb19cda
Loading
Loading
Loading
Loading
+16 −49
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
#include <linux/mmc/sh_mmcif.h>
#include <linux/mmc/sh_mobile_sdhi.h>
#include <linux/mfd/tmio.h>
#include <linux/platform_data/bd6107.h>
#include <linux/sh_clk.h>
#include <linux/irqchip/arm-gic.h>
#include <video/sh_mobile_lcdc.h>
@@ -291,47 +292,7 @@ static struct platform_device mipidsi0_device = {
	},
};

static unsigned char lcd_backlight_seq[3][2] = {
	{ 0x04, 0x07 },
	{ 0x23, 0x80 },
	{ 0x03, 0x01 },
};

static int lcd_backlight_set_brightness(int brightness)
{
	struct i2c_adapter *adap;
	struct i2c_msg msg;
	unsigned int i;
	int ret;

	if (brightness == 0) {
		/* Reset the chip */
		gpio_set_value(235, 0);
		mdelay(24);
		gpio_set_value(235, 1);
		return 0;
	}

	adap = i2c_get_adapter(1);
	if (adap == NULL)
		return -ENODEV;

	for (i = 0; i < ARRAY_SIZE(lcd_backlight_seq); i++) {
		msg.addr = 0x6d;
		msg.buf = &lcd_backlight_seq[i][0];
		msg.len = 2;
		msg.flags = 0;

		ret = i2c_transfer(adap, &msg, 1);
		if (ret < 0)
			break;
	}

	i2c_put_adapter(adap);
	return ret < 0 ? ret : 0;
}

/* LCDC0 */
/* LCDC0 and backlight */
static const struct fb_videomode lcdc0_modes[] = {
	{
		.name		= "R63302(QHD)",
@@ -361,11 +322,6 @@ static struct sh_mobile_lcdc_info lcdc0_info = {
			.width = 44,
			.height = 79,
		},
		.bl_info = {
			.name = "sh_mobile_lcdc_bl",
			.max_brightness = 1,
			.set_brightness = lcd_backlight_set_brightness,
		},
		.tx_dev = &mipidsi0_device,
	}
};
@@ -394,6 +350,17 @@ static struct platform_device lcdc0_device = {
	},
};

static struct bd6107_platform_data backlight_data = {
	.fbdev = &lcdc0_device.dev,
	.reset = 235,
	.def_value = 0,
};

static struct i2c_board_info backlight_board_info = {
	I2C_BOARD_INFO("bd6107", 0x6d),
	.platform_data = &backlight_data,
};

/* Fixed 2.8V regulators to be used by SDHI0 */
static struct regulator_consumer_supply fixed2v8_power_consumers[] =
{
@@ -648,15 +615,15 @@ static void __init ag5evm_init(void)
	gpio_set_value(217, 1);
	mdelay(100);

	/* LCD backlight controller */
	gpio_request_one(235, GPIOF_OUT_INIT_LOW, NULL); /* RESET */
	lcd_backlight_set_brightness(0);

#ifdef CONFIG_CACHE_L2X0
	/* Shared attribute override enable, 64K*8way */
	l2x0_init(IOMEM(0xf0100000), 0x00460000, 0xc2000fff);
#endif
	sh73a0_add_standard_devices();

	i2c_register_board_info(1, &backlight_board_info, 1);

	platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
}

+17 −17
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
#include <linux/mtd/physmap.h>
#include <linux/mtd/sh_flctl.h>
#include <linux/pinctrl/machine.h>
#include <linux/platform_data/gpio_backlight.h>
#include <linux/pm_clock.h>
#include <linux/regulator/fixed.h>
#include <linux/regulator/machine.h>
@@ -49,7 +50,6 @@
#include <linux/tca6416_keypad.h>
#include <linux/usb/renesas_usbhs.h>
#include <linux/dma-mapping.h>

#include <video/sh_mobile_hdmi.h>
#include <video/sh_mobile_lcdc.h>
#include <media/sh_mobile_ceu.h>
@@ -346,7 +346,7 @@ static struct platform_device meram_device = {
	},
};

/* LCDC */
/* LCDC and backlight */
static struct fb_videomode mackerel_lcdc_modes[] = {
	{
		.name		= "WVGA Panel",
@@ -362,13 +362,6 @@ static struct fb_videomode mackerel_lcdc_modes[] = {
	},
};

static int mackerel_set_brightness(int brightness)
{
	gpio_set_value(31, brightness);

	return 0;
}

static const struct sh_mobile_meram_cfg lcd_meram_cfg = {
	.icb[0] = {
		.meram_size     = 0x40,
@@ -393,11 +386,6 @@ static struct sh_mobile_lcdc_info lcdc_info = {
			.width		= 152,
			.height		= 91,
		},
		.bl_info = {
			.name = "sh_mobile_lcdc_bl",
			.max_brightness = 1,
			.set_brightness = mackerel_set_brightness,
		},
		.meram_cfg = &lcd_meram_cfg,
	}
};
@@ -425,6 +413,20 @@ static struct platform_device lcdc_device = {
	},
};

static struct gpio_backlight_platform_data gpio_backlight_data = {
	.fbdev = &lcdc_device.dev,
	.gpio = 31,
	.def_value = 1,
	.name = "backlight",
};

static struct platform_device gpio_backlight_device = {
	.name = "gpio-backlight",
	.dev = {
		.platform_data = &gpio_backlight_data,
	},
};

/* HDMI */
static struct sh_mobile_hdmi_info hdmi_info = {
	.flags		= HDMI_SND_SRC_SPDIF,
@@ -1231,6 +1233,7 @@ static struct platform_device *mackerel_devices[] __initdata = {
	&nor_flash_device,
	&smc911x_device,
	&lcdc_device,
	&gpio_backlight_device,
	&usbhs0_device,
	&usbhs1_device,
	&leds_device,
@@ -1441,9 +1444,6 @@ static void __init mackerel_init(void)
				  ARRAY_SIZE(mackerel_pinctrl_map));
	sh7372_pinmux_init();

	/* backlight, off by default */
	gpio_request_one(31, GPIOF_OUT_INIT_LOW, NULL);

	gpio_request_one(151, GPIOF_OUT_INIT_HIGH, NULL); /* LCDDON */

	/* USBHS0 */
+20 −17
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#include <linux/spi/mmc_spi.h>
#include <linux/input.h>
#include <linux/input/sh_keysc.h>
#include <linux/platform_data/gpio_backlight.h>
#include <linux/sh_eth.h>
#include <linux/sh_intc.h>
#include <linux/videodev2.h>
@@ -303,7 +304,7 @@ static struct platform_device usbhs_device = {
	.resource	= usbhs_resources,
};

/* LCDC */
/* LCDC and backlight */
static const struct fb_videomode ecovec_lcd_modes[] = {
	{
		.name		= "Panel",
@@ -334,13 +335,6 @@ static const struct fb_videomode ecovec_dvi_modes[] = {
	},
};

static int ecovec24_set_brightness(int brightness)
{
	gpio_set_value(GPIO_PTR1, brightness);

	return 0;
}

static struct sh_mobile_lcdc_info lcdc_info = {
	.ch[0] = {
		.interface_type = RGB18,
@@ -350,11 +344,6 @@ static struct sh_mobile_lcdc_info lcdc_info = {
			.width = 152,
			.height = 91,
		},
		.bl_info = {
			.name = "sh_mobile_lcdc_bl",
			.max_brightness = 1,
			.set_brightness = ecovec24_set_brightness,
		},
	}
};

@@ -380,6 +369,20 @@ static struct platform_device lcdc_device = {
	},
};

static struct gpio_backlight_platform_data gpio_backlight_data = {
	.fbdev = &lcdc_device.dev,
	.gpio = GPIO_PTR1,
	.def_value = 1,
	.name = "backlight",
};

static struct platform_device gpio_backlight_device = {
	.name = "gpio-backlight",
	.dev = {
		.platform_data = &gpio_backlight_data,
	},
};

/* CEU0 */
static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
	.flags = SH_CEU_FLAG_USE_8BIT_BUS,
@@ -1049,6 +1052,7 @@ static struct platform_device *ecovec_devices[] __initdata = {
	&usb1_common_device,
	&usbhs_device,
	&lcdc_device,
	&gpio_backlight_device,
	&ceu0_device,
	&ceu1_device,
	&keysc_device,
@@ -1239,11 +1243,9 @@ static int __init arch_setup(void)

	gpio_request(GPIO_PTE6, NULL);
	gpio_request(GPIO_PTU1, NULL);
	gpio_request(GPIO_PTR1, NULL);
	gpio_request(GPIO_PTA2, NULL);
	gpio_direction_input(GPIO_PTE6);
	gpio_direction_output(GPIO_PTU1, 0);
	gpio_direction_output(GPIO_PTR1, 0);
	gpio_direction_output(GPIO_PTA2, 0);

	/* I/O buffer drive ability is high */
@@ -1256,6 +1258,9 @@ static int __init arch_setup(void)
		lcdc_info.ch[0].lcd_modes		= ecovec_dvi_modes;
		lcdc_info.ch[0].num_modes		= ARRAY_SIZE(ecovec_dvi_modes);

		/* No backlight */
		gpio_backlight_data.fbdev = NULL;

		gpio_set_value(GPIO_PTA2, 1);
		gpio_set_value(GPIO_PTU1, 1);
	} else {
@@ -1265,8 +1270,6 @@ static int __init arch_setup(void)
		lcdc_info.ch[0].lcd_modes		= ecovec_lcd_modes;
		lcdc_info.ch[0].num_modes		= ARRAY_SIZE(ecovec_lcd_modes);

		gpio_set_value(GPIO_PTR1, 1);

		/* FIXME
		 *
		 * LCDDON control is needed for Panel,
+0 −48
Original line number Diff line number Diff line
@@ -276,51 +276,3 @@ void kfr2r09_lcd_start(void *sohandle, struct sh_mobile_lcdc_sys_bus_ops *so)
{
	write_memory_start(sohandle, so);
}

#define CTRL_CKSW       0x10
#define CTRL_C10        0x20
#define CTRL_CPSW       0x80
#define MAIN_MLED4      0x40
#define MAIN_MSW        0x80

int kfr2r09_lcd_set_brightness(int brightness)
{
	struct i2c_adapter *a;
	struct i2c_msg msg;
	unsigned char buf[2];
	int ret;

	a = i2c_get_adapter(0);
	if (!a)
		return -ENODEV;

	buf[0] = 0x00;
	if (brightness)
		buf[1] = CTRL_CPSW | CTRL_C10 | CTRL_CKSW;
	else
		buf[1] = 0;

	msg.addr = 0x75;
	msg.buf = buf;
	msg.len = 2;
	msg.flags = 0;
	ret = i2c_transfer(a, &msg, 1);
	if (ret != 1)
		return -ENODEV;

	buf[0] = 0x01;
	if (brightness)
		buf[1] = MAIN_MSW | MAIN_MLED4 | 0x0c;
	else
		buf[1] = 0;

	msg.addr = 0x75;
	msg.buf = buf;
	msg.len = 2;
	msg.flags = 0;
	ret = i2c_transfer(a, &msg, 1);
	if (ret != 1)
		return -ENODEV;

	return 0;
}
+14 −5
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <linux/input.h>
#include <linux/input/sh_keysc.h>
#include <linux/i2c.h>
#include <linux/platform_data/lv5207lp.h>
#include <linux/regulator/fixed.h>
#include <linux/regulator/machine.h>
#include <linux/usb/r8a66597.h>
@@ -159,11 +160,6 @@ static struct sh_mobile_lcdc_info kfr2r09_sh_lcdc_info = {
			.setup_sys = kfr2r09_lcd_setup,
			.start_transfer = kfr2r09_lcd_start,
		},
		.bl_info = {
			.name = "sh_mobile_lcdc_bl",
			.max_brightness = 1,
			.set_brightness = kfr2r09_lcd_set_brightness,
		},
		.sys_bus_cfg = {
			.ldmt2r = 0x07010904,
			.ldmt3r = 0x14012914,
@@ -195,6 +191,17 @@ static struct platform_device kfr2r09_sh_lcdc_device = {
	},
};

static struct lv5207lp_platform_data kfr2r09_backlight_data = {
	.fbdev = &kfr2r09_sh_lcdc_device.dev,
	.def_value = 13,
	.max_value = 13,
};

static struct i2c_board_info kfr2r09_backlight_board_info = {
	I2C_BOARD_INFO("lv5207lp", 0x75),
	.platform_data = &kfr2r09_backlight_data,
};

static struct r8a66597_platdata kfr2r09_usb0_gadget_data = {
	.on_chip = 1,
};
@@ -627,6 +634,8 @@ static int __init kfr2r09_devices_setup(void)
	gpio_request(GPIO_FN_SDHI0CMD, NULL);
	gpio_request(GPIO_FN_SDHI0CLK, NULL);

	i2c_register_board_info(0, &kfr2r09_backlight_board_info, 1);

	return platform_add_devices(kfr2r09_devices,
				    ARRAY_SIZE(kfr2r09_devices));
}
Loading