Sudhakar Rajashekhara <[email protected]> writes:
> This patch adds platform support for the graphic display
> (Sharp LK043T1DG01) found on DA850/OMAP-L138 based EVM.
>
> Signed-off-by: Sudhakar Rajashekhara <[email protected]>
> ---
> Since the previous version, following are the modifications:
> 1. Defined the macros for the LCD back light and LCD power
> GPIO pins.
> 2. Made da850_lcd_hw_init() function static.
> 3. Added gpio_free() for 1st GPIO pin, if gpio_request for
> the 2nd GPIO pin fails.
> 4. Removed un-necessary mdelays from da850_lcd_hw_init()
> function.
> 5. Also removed LPSC disable/enable sequence from
> da850_lcd_hw_init() function.
> 6. Removed the comments for the members of lcd_ctrl_config
> structure.
>
> arch/arm/mach-davinci/board-da850-evm.c | 58 +++++++++++++++++++++++++++
> arch/arm/mach-davinci/da850.c | 42 ++++++++++++++++++++
> arch/arm/mach-davinci/devices-da8xx.c | 59
> ++++++++++++++++++++++++++++
> arch/arm/mach-davinci/include/mach/da8xx.h | 3 +
> arch/arm/mach-davinci/include/mach/mux.h | 26 ++++++++++++
> 5 files changed, 188 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-davinci/board-da850-evm.c
> b/arch/arm/mach-davinci/board-da850-evm.c
> index d989346..b05b7f5 100644
> --- a/arch/arm/mach-davinci/board-da850-evm.c
> +++ b/arch/arm/mach-davinci/board-da850-evm.c
> @@ -17,6 +17,8 @@
> #include <linux/console.h>
> #include <linux/i2c.h>
> #include <linux/i2c/at24.h>
> +#include <linux/gpio.h>
> +#include <linux/delay.h>
>
> #include <asm/mach-types.h>
> #include <asm/mach/arch.h>
> @@ -25,10 +27,16 @@
> #include <mach/irqs.h>
> #include <mach/cp_intc.h>
> #include <mach/da8xx.h>
> +#include <mach/psc.h>
>
> #define DA850_EVM_PHY_MASK 0x1
> #define DA850_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
>
> +/* GPIO 2[15] is used for LCD Back light - 16 * 2 + 15 = 47*/
> +#define DA850_LCD_BL_PIN 47
> +/* GPIO 8[10] is used for LCD Power - 16 * 8 + 10 = 138 */
> +#define DA850_LCD_PWR_PIN 138
> +
> static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
> .bus_freq = 100, /* kHz */
> .bus_delay = 0, /* usec */
> @@ -38,6 +46,41 @@ static struct davinci_uart_config da850_evm_uart_config
> __initdata = {
> .enabled_uarts = 0x7,
> };
>
> +static int da850_lcd_hw_init(void)
> +{
> + int status;
> +
> + status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
> + if (status < 0)
> + return status;
> +
> + status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
> + if (status < 0) {
> + gpio_free(DA850_LCD_BL_PIN);
> + return status;
> + }
> +
> + gpio_direction_output(DA850_LCD_BL_PIN, 0);
> + gpio_direction_output(DA850_LCD_PWR_PIN, 0);
> +
> + /* disable lcd backlight */
> + gpio_set_value(DA850_LCD_BL_PIN, 0);
> +
> + /* disable lcd power */
> + gpio_set_value(DA850_LCD_PWR_PIN, 0);
> +
> + /* enable lcd power */
> + gpio_set_value(DA850_LCD_PWR_PIN, 1);
> +
> + /* enable lcd backlight */
> + gpio_set_value(DA850_LCD_BL_PIN, 1);
> +
> + gpio_free(DA850_LCD_BL_PIN);
> + gpio_free(DA850_LCD_PWR_PIN);
Do you really want to free these and allow other potential users to
change the direction/value?
Since this board code, I suspect you want to request and hold the GPIO
lines. This also would allow the use of the GPIO sysfs interface
to toggle power and backlight for debug.
Kevin
> + return 0;
> +}
> +
> static __init void da850_evm_init(void)
> {
> struct davinci_soc_info *soc_info = &davinci_soc_info;
> @@ -86,6 +129,21 @@ static __init void da850_evm_init(void)
> */
> __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
> __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
> +
> + ret = da8xx_pinmux_setup(da850_lcdcntl_pins);
> + if (ret)
> + pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
> + ret);
> +
> + ret = da850_lcd_hw_init();
> + if (ret)
> + pr_warning("da850_evm_init: lcd initialization failed: %d\n",
> + ret);
> +
> + ret = da8xx_register_lcdc();
> + if (ret)
> + pr_warning("da850_evm_init: lcdc registration failed: %d\n",
> + ret);
> }
>
> #ifdef CONFIG_SERIAL_8250_CONSOLE
> diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
> index c5efc51..69acb6e 100644
> --- a/arch/arm/mach-davinci/da850.c
> +++ b/arch/arm/mach-davinci/da850.c
> @@ -290,6 +290,13 @@ static struct clk emac_clk = {
> .psc_ctlr = 1,
> };
>
> +static struct clk lcdc_clk = {
> + .name = "lcdc",
> + .parent = &pll0_sysclk2,
> + .lpsc = DA8XX_LPSC1_LCDC,
> + .psc_ctlr = 1,
> +};
> +
> static struct davinci_clk da850_clks[] = {
> CLK(NULL, "ref", &ref_clk),
> CLK(NULL, "pll0", &pll0_clk),
> @@ -327,6 +334,7 @@ static struct davinci_clk da850_clks[] = {
> CLK(NULL, "arm", &arm_clk),
> CLK(NULL, "rmii", &rmii_clk),
> CLK("davinci_emac.1", NULL, &emac_clk),
> + CLK("da8xx_lcdc.0", NULL, &lcdc_clk),
> CLK(NULL, NULL, NULL),
> };
>
> @@ -373,6 +381,30 @@ static const struct mux_config da850_pins[] = {
> MUX_CFG(DA850, MII_RXD_0, 3, 28, 15, 8, false)
> MUX_CFG(DA850, MDIO_CLK, 4, 0, 15, 8, false)
> MUX_CFG(DA850, MDIO_D, 4, 4, 15, 8, false)
> + /* LCD function */
> + MUX_CFG(DA850, LCD_D_7, 16, 8, 15, 2, false)
> + MUX_CFG(DA850, LCD_D_6, 16, 12, 15, 2, false)
> + MUX_CFG(DA850, LCD_D_5, 16, 16, 15, 2, false)
> + MUX_CFG(DA850, LCD_D_4, 16, 20, 15, 2, false)
> + MUX_CFG(DA850, LCD_D_3, 16, 24, 15, 2, false)
> + MUX_CFG(DA850, LCD_D_2, 16, 28, 15, 2, false)
> + MUX_CFG(DA850, LCD_D_1, 17, 0, 15, 2, false)
> + MUX_CFG(DA850, LCD_D_0, 17, 4, 15, 2, false)
> + MUX_CFG(DA850, LCD_D_15, 17, 8, 15, 2, false)
> + MUX_CFG(DA850, LCD_D_14, 17, 12, 15, 2, false)
> + MUX_CFG(DA850, LCD_D_13, 17, 16, 15, 2, false)
> + MUX_CFG(DA850, LCD_D_12, 17, 20, 15, 2, false)
> + MUX_CFG(DA850, LCD_D_11, 17, 24, 15, 2, false)
> + MUX_CFG(DA850, LCD_D_10, 17, 28, 15, 2, false)
> + MUX_CFG(DA850, LCD_D_9, 18, 0, 15, 2, false)
> + MUX_CFG(DA850, LCD_D_8, 18, 4, 15, 2, false)
> + MUX_CFG(DA850, LCD_PCLK, 18, 24, 15, 2, false)
> + MUX_CFG(DA850, LCD_HSYNC, 19, 0, 15, 2, false)
> + MUX_CFG(DA850, LCD_VSYNC, 19, 4, 15, 2, false)
> + MUX_CFG(DA850, NLCD_AC_ENB_CS, 19, 24, 15, 2, false)
> + /* GPIO function */
> + MUX_CFG(DA850, GPIO2_15, 5, 0, 15, 8, false)
> + MUX_CFG(DA850, GPIO8_10, 18, 28, 15, 8, false)
> #endif
> };
>
> @@ -410,6 +442,16 @@ const short da850_cpgmac_pins[] __initdata = {
> -1
> };
>
> +const short da850_lcdcntl_pins[] __initdata = {
> + DA850_LCD_D_1, DA850_LCD_D_2, DA850_LCD_D_3, DA850_LCD_D_4,
> + DA850_LCD_D_5, DA850_LCD_D_6, DA850_LCD_D_7, DA850_LCD_D_8,
> + DA850_LCD_D_9, DA850_LCD_D_10, DA850_LCD_D_11, DA850_LCD_D_12,
> + DA850_LCD_D_13, DA850_LCD_D_14, DA850_LCD_D_15, DA850_LCD_PCLK,
> + DA850_LCD_HSYNC, DA850_LCD_VSYNC, DA850_NLCD_AC_ENB_CS, DA850_GPIO2_15,
> + DA850_GPIO8_10,
> + -1
> +};
> +
> /* FIQ are pri 0-1; otherwise 2-7, with 7 lowest priority */
> static u8 da850_default_priorities[DA850_N_CP_INTC_IRQ] = {
> [IRQ_DA8XX_COMMTX] = 7,
> diff --git a/arch/arm/mach-davinci/devices-da8xx.c
> b/arch/arm/mach-davinci/devices-da8xx.c
> index 11c0971..57eb0b5 100644
> --- a/arch/arm/mach-davinci/devices-da8xx.c
> +++ b/arch/arm/mach-davinci/devices-da8xx.c
> @@ -21,6 +21,7 @@
> #include <mach/common.h>
> #include <mach/time.h>
> #include <mach/da8xx.h>
> +#include <video/da8xx-fb.h>
>
> #include "clock.h"
>
> @@ -285,3 +286,61 @@ int __init da8xx_register_emac(void)
> {
> return platform_device_register(&da8xx_emac_device);
> }
> +
> +static const struct display_panel disp_panel = {
> + QVGA,
> + 16,
> + 16,
> + COLOR_ACTIVE,
> +};
> +
> +static struct lcd_ctrl_config lcd_cfg = {
> + &disp_panel,
> + .ac_bias = 255,
> + .ac_bias_intrpt = 0,
> + .dma_burst_sz = 16,
> + .bpp = 16,
> + .fdd = 255,
> + .tft_alt_mode = 0,
> + .stn_565_mode = 0,
> + .mono_8bit_mode = 0,
> + .invert_line_clock = 1,
> + .invert_frm_clock = 1,
> + .sync_edge = 0,
> + .sync_ctrl = 1,
> + .raster_order = 0,
> +};
> +
> +static struct da8xx_lcdc_platform_data da850_evm_lcdc_pdata = {
> + .manu_name = "sharp",
> + .controller_data = &lcd_cfg,
> + .type = "Sharp_LK043T1DG01",
> +};
> +
> +static struct resource da8xx_lcdc_resources[] = {
> + [0] = { /* registers */
> + .start = DA8XX_LCD_CNTRL_BASE,
> + .end = DA8XX_LCD_CNTRL_BASE + SZ_4K - 1,
> + .flags = IORESOURCE_MEM,
> + },
> + [1] = { /* interrupt */
> + .start = IRQ_DA8XX_LCDINT,
> + .end = IRQ_DA8XX_LCDINT,
> + .flags = IORESOURCE_IRQ,
> + },
> +};
> +
> +static struct platform_device da850_lcdc_device = {
> + .name = "da8xx_lcdc",
> + .id = 0,
> + .num_resources = ARRAY_SIZE(da8xx_lcdc_resources),
> + .resource = da8xx_lcdc_resources,
> + .dev = {
> + .platform_data = &da850_evm_lcdc_pdata,
> + }
> +};
> +
> +int __init da8xx_register_lcdc(void)
> +{
> + return platform_device_register(&da850_lcdc_device);
> +}
> diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h
> b/arch/arm/mach-davinci/include/mach/da8xx.h
> index a8cb570..951e091 100644
> --- a/arch/arm/mach-davinci/include/mach/da8xx.h
> +++ b/arch/arm/mach-davinci/include/mach/da8xx.h
> @@ -36,6 +36,7 @@
> #define DA8XX_TIMER64P1_BASE 0x01c21000
> #define DA8XX_GPIO_BASE 0x01e26000
> #define DA8XX_PSC1_BASE 0x01e27000
> +#define DA8XX_LCD_CNTRL_BASE 0x01e13000
>
> #define PINMUX0 0x00
> #define PINMUX1 0x04
> @@ -65,6 +66,7 @@ int da8xx_register_edma(void);
> int da8xx_register_i2c(int instance, struct davinci_i2c_platform_data
> *pdata);
> int da8xx_register_watchdog(void);
> int da8xx_register_emac(void);
> +int da8xx_register_lcdc(void);
>
> extern struct platform_device da8xx_serial_device;
> extern struct emac_platform_data da8xx_emac_pdata;
> @@ -100,6 +102,7 @@ extern const short da850_uart2_pins[];
> extern const short da850_i2c0_pins[];
> extern const short da850_i2c1_pins[];
> extern const short da850_cpgmac_pins[];
> +extern const short da850_lcdcntl_pins[];
>
> int da8xx_pinmux_setup(const short pins[]);
>
> diff --git a/arch/arm/mach-davinci/include/mach/mux.h
> b/arch/arm/mach-davinci/include/mach/mux.h
> index 8676680..6aab1be 100644
> --- a/arch/arm/mach-davinci/include/mach/mux.h
> +++ b/arch/arm/mach-davinci/include/mach/mux.h
> @@ -750,6 +750,32 @@ enum davinci_da850_index {
> DA850_MII_RXD_0,
> DA850_MDIO_CLK,
> DA850_MDIO_D,
> +
> + /* LCD function */
> + DA850_LCD_D_7,
> + DA850_LCD_D_6,
> + DA850_LCD_D_5,
> + DA850_LCD_D_4,
> + DA850_LCD_D_3,
> + DA850_LCD_D_2,
> + DA850_LCD_D_1,
> + DA850_LCD_D_0,
> + DA850_LCD_D_15,
> + DA850_LCD_D_14,
> + DA850_LCD_D_13,
> + DA850_LCD_D_12,
> + DA850_LCD_D_11,
> + DA850_LCD_D_10,
> + DA850_LCD_D_9,
> + DA850_LCD_D_8,
> + DA850_LCD_PCLK,
> + DA850_LCD_HSYNC,
> + DA850_LCD_VSYNC,
> + DA850_NLCD_AC_ENB_CS,
> +
> + /* GPIO function */
> + DA850_GPIO2_15,
> + DA850_GPIO8_10,
> };
>
> #ifdef CONFIG_DAVINCI_MUX
> --
> 1.5.6
>
> _______________________________________________
> Davinci-linux-open-source mailing list
> [email protected]
> http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source