diff mbox

[4/6] OMAP: LDP: Port the display driver to new DSS2

Message ID 1305535980.2002.34.camel@deskari (mailing list archive)
State New, archived
Headers show

Commit Message

Tomi Valkeinen May 16, 2011, 8:53 a.m. UTC
On Thu, 2011-05-12 at 09:40 +0300, Igor Grinberg wrote:
> 
> On 05/11/11 09:32, Tomi Valkeinen wrote:
> 
> > On Wed, 2011-05-11 at 10:28 +0530, Janorkar, Mayuresh wrote:
> >
> >>> +static void __init ldp_display_init(void)
> >>> +{
> >>> +	int r;
> >>> +
> >>> +	struct gpio gpios[] = {
> >>> +		{LCD_PANEL_RESET_GPIO, GPIOF_OUT_INIT_HIGH, "LCD RESET"},
> >>> +		{LCD_PANEL_QVGA_GPIO, GPIOF_OUT_INIT_HIGH, "LCD QVGA"},
> >>> +		{LCD_PANEL_ENABLE_GPIO, GPIOF_OUT_INIT_LOW, "LCD ENABLE"},
> >>> +		{LCD_PANEL_BACKLIGHT_GPIO, GPIOF_OUT_INIT_LOW, "LCD
> >>> BACKLIGHT"},
> >>> +	};
> >>> +
> >>> +	r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
> >>> +	if (r) {
> >>> +		pr_err("Cannot request LCD GPIOs, error %d\n", r);
> >>> +		return;
> >>> +	}
> >> If I test with this patch, this request is returning error.
> > Hmm. Well, the GPIOs are the same as in the old driver. However, the old
> > driver doesn't even seem to check if it manages to request the GPIOs, so
> > it may well be that it was failing also.
> >
> > Can you check from /sys/class/gpio/ if some of the GPIOs are already
> > allocated: 207, 199, 55, 56?
> >
> > The definition of two of those GPIOs look kinda funny to me: (15 +
> > OMAP_MAX_GPIO_LINES). I don't know what OMAP_MAX_GPIO_LINES means, but
> > it sure doesn't sound ok to have a GPIO number that is 15 over the
> > maximum =).
> >
> 
> This means that some kind of gpio expander is used.
> I bet those are twl gpios (or may be some other discrete chip).
> If those are twl gpios then you need to provide the .setup callback
> in struct twl4030_gpio_platform_data which will request and setup those gpios.

Here's an updated patch with the twl gpio code.

All the old omapfb porting patches, including new drivers for DSS2, can
be found from 

git://gitorious.org/linux-omap-dss2/linux.git old-omapfb-port

 Tomi





--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Igor Grinberg May 16, 2011, 11:13 a.m. UTC | #1
On 05/16/11 11:53, Tomi Valkeinen wrote:

> Here's an updated patch with the twl gpio code.

Looks good, though one minor issue below

> All the old omapfb porting patches, including new drivers for DSS2, can
> be found from 
>
> git://gitorious.org/linux-omap-dss2/linux.git old-omapfb-port
>
>  Tomi
>
> diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
> index e2ba779..ed78b9a 100644
> --- a/arch/arm/mach-omap2/board-ldp.c
> +++ b/arch/arm/mach-omap2/board-ldp.c
> @@ -44,6 +44,9 @@
>  #include <asm/delay.h>
>  #include <plat/usb.h>
>  
> +#include <video/omapdss.h>
> +#include <video/omap-panel-generic-dpi.h>
> +
>  #include "board-flash.h"
>  #include "mux.h"
>  #include "hsmmc.h"
> @@ -275,19 +278,70 @@ static inline void __init ldp_init_smsc911x(void)
>  	gpio_direction_input(eth_gpio);
>  }
>  
> -static struct platform_device ldp_lcd_device = {
> -	.name		= "ldp_lcd",
> -	.id		= -1,
> +/* LCD */
> +
> +static int ldp_backlight_gpio;
> +static int ldp_lcd_enable_gpio;
> +
> +#define LCD_PANEL_RESET_GPIO		55
> +#define LCD_PANEL_QVGA_GPIO		56
> +
> +static int ldp_panel_enable_lcd(struct omap_dss_device *dssdev)
> +{
> +	gpio_direction_output(ldp_lcd_enable_gpio, 1);
> +	gpio_direction_output(ldp_backlight_gpio, 1);
> +
> +	return 0;
> +}
> +
> +static void ldp_panel_disable_lcd(struct omap_dss_device *dssdev)
> +{
> +	gpio_direction_output(ldp_lcd_enable_gpio, 0);
> +	gpio_direction_output(ldp_backlight_gpio, 0);
> +}
> +
> +static struct panel_generic_dpi_data ldp_panel_data = {
> +	.name			= "2430sdp",
> +	.platform_enable	= ldp_panel_enable_lcd,
> +	.platform_disable	= ldp_panel_disable_lcd,
> +};
> +
> +static struct omap_dss_device ldp_lcd_device = {
> +	.name			= "lcd",
> +	.driver_name		= "generic_dpi_panel",
> +	.type			= OMAP_DISPLAY_TYPE_DPI,
> +	.phy.dpi.data_lines	= 16,
> +	.data			= &ldp_panel_data,
>  };
>  
> -static struct omap_lcd_config ldp_lcd_config __initdata = {
> -	.ctrl_name	= "internal",
> +static struct omap_dss_device *ldp_dss_devices[] = {
> +	&ldp_lcd_device,
>  };
>  
> -static struct omap_board_config_kernel ldp_config[] __initdata = {
> -	{ OMAP_TAG_LCD,		&ldp_lcd_config },
> +static struct omap_dss_board_info ldp_dss_data = {
> +	.num_devices	= ARRAY_SIZE(ldp_dss_devices),
> +	.devices	= ldp_dss_devices,
> +	.default_device	= &ldp_lcd_device,
>  };
>  
> +static void __init ldp_display_init(void)
> +{
> +	int r;
> +
> +	static struct gpio gpios[] __initdata = {
> +		{LCD_PANEL_RESET_GPIO, GPIOF_OUT_INIT_HIGH, "LCD RESET"},
> +		{LCD_PANEL_QVGA_GPIO, GPIOF_OUT_INIT_HIGH, "LCD QVGA"},
> +	};
> +
> +	r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
> +	if (r) {
> +		pr_err("Cannot request LCD GPIOs, error %d\n", r);
> +		return;
> +	}
> +
> +	omap_display_init(&ldp_dss_data);
> +}
> +
>  static void __init omap_ldp_init_early(void)
>  {
>  	omap2_init_common_infrastructure();
> @@ -298,10 +352,30 @@ static struct twl4030_usb_data ldp_usb_data = {
>  	.usb_mode	= T2_USB_MODE_ULPI,
>  };
>  
> +static int ldp_twl_gpio_setup(struct device *dev, unsigned gpio, unsigned ngpio)
> +{
> +	int r;
> +
> +	struct gpio gpios[] = {
> +		{gpio + 7 , GPIOF_OUT_INIT_LOW, "LCD ENABLE"},
> +		{gpio + 15, GPIOF_OUT_INIT_LOW, "LCD BACKLIGHT"},
> +	};
> +
> +	r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
> +	if (r)
> +		pr_err("Cannot request LCD GPIOs, error %d\n", r);
> +
> +	ldp_backlight_gpio = gpio + 15;
> +	ldp_lcd_enable_gpio = gpio + 7;

If the gpio_request_array() fails (though it shouldn't),
won't it be right to set both variables to -EINVAL?

Other then that, you can have my
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>

Thanks for bringing this all together.
MAYURESH JANORKAR May 16, 2011, 11:26 a.m. UTC | #2
> -----Original Message-----
> From: Valkeinen, Tomi
> Sent: Monday, May 16, 2011 2:23 PM
> To: Igor Grinberg
> Cc: Janorkar, Mayuresh; tony@atomide.com; linux-omap@vger.kernel.org;
> Stanley Miao
> Subject: Re: [PATCH 4/6] OMAP: LDP: Port the display driver to new DSS2
> 
> On Thu, 2011-05-12 at 09:40 +0300, Igor Grinberg wrote:
> >
> > On 05/11/11 09:32, Tomi Valkeinen wrote:
> >
> > > On Wed, 2011-05-11 at 10:28 +0530, Janorkar, Mayuresh wrote:
> > >
> > >>> +static void __init ldp_display_init(void)
> > >>> +{
> > >>> +	int r;
> > >>> +
> > >>> +	struct gpio gpios[] = {
> > >>> +		{LCD_PANEL_RESET_GPIO, GPIOF_OUT_INIT_HIGH, "LCD
> RESET"},
> > >>> +		{LCD_PANEL_QVGA_GPIO, GPIOF_OUT_INIT_HIGH, "LCD QVGA"},
> > >>> +		{LCD_PANEL_ENABLE_GPIO, GPIOF_OUT_INIT_LOW, "LCD
> ENABLE"},
> > >>> +		{LCD_PANEL_BACKLIGHT_GPIO, GPIOF_OUT_INIT_LOW, "LCD
> > >>> BACKLIGHT"},
> > >>> +	};
> > >>> +
> > >>> +	r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
> > >>> +	if (r) {
> > >>> +		pr_err("Cannot request LCD GPIOs, error %d\n", r);
> > >>> +		return;
> > >>> +	}
> > >> If I test with this patch, this request is returning error.
> > > Hmm. Well, the GPIOs are the same as in the old driver. However, the
> old
> > > driver doesn't even seem to check if it manages to request the GPIOs,
> so
> > > it may well be that it was failing also.
> > >
> > > Can you check from /sys/class/gpio/ if some of the GPIOs are already
> > > allocated: 207, 199, 55, 56?
> > >
> > > The definition of two of those GPIOs look kinda funny to me: (15 +
> > > OMAP_MAX_GPIO_LINES). I don't know what OMAP_MAX_GPIO_LINES means, but
> > > it sure doesn't sound ok to have a GPIO number that is 15 over the
> > > maximum =).
> > >
> >
> > This means that some kind of gpio expander is used.
> > I bet those are twl gpios (or may be some other discrete chip).
> > If those are twl gpios then you need to provide the .setup callback
> > in struct twl4030_gpio_platform_data which will request and setup those
> gpios.
> 
> Here's an updated patch with the twl gpio code.
> 
> All the old omapfb porting patches, including new drivers for DSS2, can
> be found from
> 
> git://gitorious.org/linux-omap-dss2/linux.git old-omapfb-port
> 
>  Tomi
> 
> diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-
> ldp.c
> index e2ba779..ed78b9a 100644
> --- a/arch/arm/mach-omap2/board-ldp.c
> +++ b/arch/arm/mach-omap2/board-ldp.c
> @@ -44,6 +44,9 @@
>  #include <asm/delay.h>
>  #include <plat/usb.h>
> 
> +#include <video/omapdss.h>
> +#include <video/omap-panel-generic-dpi.h>
> +
>  #include "board-flash.h"
>  #include "mux.h"
>  #include "hsmmc.h"
> @@ -275,19 +278,70 @@ static inline void __init ldp_init_smsc911x(void)
>  	gpio_direction_input(eth_gpio);
>  }
> 
> -static struct platform_device ldp_lcd_device = {
> -	.name		= "ldp_lcd",
> -	.id		= -1,
> +/* LCD */
> +
> +static int ldp_backlight_gpio;
> +static int ldp_lcd_enable_gpio;
> +
> +#define LCD_PANEL_RESET_GPIO		55
> +#define LCD_PANEL_QVGA_GPIO		56
> +
> +static int ldp_panel_enable_lcd(struct omap_dss_device *dssdev)
> +{
> +	gpio_direction_output(ldp_lcd_enable_gpio, 1);
> +	gpio_direction_output(ldp_backlight_gpio, 1);
> +
> +	return 0;
> +}
> +
> +static void ldp_panel_disable_lcd(struct omap_dss_device *dssdev)
> +{
> +	gpio_direction_output(ldp_lcd_enable_gpio, 0);
> +	gpio_direction_output(ldp_backlight_gpio, 0);
> +}
> +
> +static struct panel_generic_dpi_data ldp_panel_data = {
> +	.name			= "2430sdp",
> +	.platform_enable	= ldp_panel_enable_lcd,
> +	.platform_disable	= ldp_panel_disable_lcd,
> +};
> +
> +static struct omap_dss_device ldp_lcd_device = {
> +	.name			= "lcd",
> +	.driver_name		= "generic_dpi_panel",
> +	.type			= OMAP_DISPLAY_TYPE_DPI,
> +	.phy.dpi.data_lines	= 16,

From a working DSS code at:
http://lxr.linux.no/#linux+v2.6.38/drivers/video/omap/lcd_ldp.c
.data_lines should be 18

> +	.data			= &ldp_panel_data,
>  };
> 
> -static struct omap_lcd_config ldp_lcd_config __initdata = {
> -	.ctrl_name	= "internal",
> +static struct omap_dss_device *ldp_dss_devices[] = {
> +	&ldp_lcd_device,
>  };
> 
> -static struct omap_board_config_kernel ldp_config[] __initdata = {
> -	{ OMAP_TAG_LCD,		&ldp_lcd_config },
> +static struct omap_dss_board_info ldp_dss_data = {
> +	.num_devices	= ARRAY_SIZE(ldp_dss_devices),
> +	.devices	= ldp_dss_devices,
> +	.default_device	= &ldp_lcd_device,
>  };
> 
> +static void __init ldp_display_init(void)
> +{
> +	int r;
> +
> +	static struct gpio gpios[] __initdata = {
> +		{LCD_PANEL_RESET_GPIO, GPIOF_OUT_INIT_HIGH, "LCD RESET"},
> +		{LCD_PANEL_QVGA_GPIO, GPIOF_OUT_INIT_HIGH, "LCD QVGA"},
> +	};
> +
> +	r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
> +	if (r) {
> +		pr_err("Cannot request LCD GPIOs, error %d\n", r);
> +		return;
> +	}
> +
> +	omap_display_init(&ldp_dss_data);
> +}
> +
>  static void __init omap_ldp_init_early(void)
>  {
>  	omap2_init_common_infrastructure();
> @@ -298,10 +352,30 @@ static struct twl4030_usb_data ldp_usb_data = {
>  	.usb_mode	= T2_USB_MODE_ULPI,
>  };
> 
> +static int ldp_twl_gpio_setup(struct device *dev, unsigned gpio, unsigned
> ngpio)
> +{
> +	int r;
> +
> +	struct gpio gpios[] = {
> +		{gpio + 7 , GPIOF_OUT_INIT_LOW, "LCD ENABLE"},
> +		{gpio + 15, GPIOF_OUT_INIT_LOW, "LCD BACKLIGHT"},
> +	};
> +
> +	r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
> +	if (r)
> +		pr_err("Cannot request LCD GPIOs, error %d\n", r);
> +
> +	ldp_backlight_gpio = gpio + 15;
> +	ldp_lcd_enable_gpio = gpio + 7;
> +
> +	return r;
> +}
> +
>  static struct twl4030_gpio_platform_data ldp_gpio_data = {
>  	.gpio_base	= OMAP_MAX_GPIO_LINES,
>  	.irq_base	= TWL4030_GPIO_IRQ_BASE,
>  	.irq_end	= TWL4030_GPIO_IRQ_END,
> +	.setup		= ldp_twl_gpio_setup,
>  };
> 
>  static struct twl4030_madc_platform_data ldp_madc_data = {
> @@ -347,6 +421,26 @@ static struct regulator_init_data ldp_vaux1 = {
>  	.consumer_supplies		= ldp_vaux1_supplies,
>  };
> 
> +static struct regulator_consumer_supply ldp_vpll2_supplies[] = {
> +	REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
> +	REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi1"),
> +};
> +
> +static struct regulator_init_data ldp_vpll2 = {
> +	.constraints = {
> +		.name			= "VDVI",
> +		.min_uV			= 1800000,
> +		.max_uV			= 1800000,
> +		.apply_uV		= true,
> +		.valid_modes_mask	= REGULATOR_MODE_NORMAL
> +					| REGULATOR_MODE_STANDBY,
> +		.valid_ops_mask		= REGULATOR_CHANGE_MODE
> +					| REGULATOR_CHANGE_STATUS,
> +	},
> +	.num_consumer_supplies	= ARRAY_SIZE(ldp_vpll2_supplies),
> +	.consumer_supplies	= ldp_vpll2_supplies,
> +};
> +
>  static struct twl4030_platform_data ldp_twldata = {
>  	.irq_base	= TWL4030_IRQ_BASE,
>  	.irq_end	= TWL4030_IRQ_END,
> @@ -356,6 +450,7 @@ static struct twl4030_platform_data ldp_twldata = {
>  	.usb		= &ldp_usb_data,
>  	.vmmc1		= &ldp_vmmc1,
>  	.vaux1		= &ldp_vaux1,
> +	.vpll2		= &ldp_vpll2,
>  	.gpio		= &ldp_gpio_data,
>  	.keypad		= &ldp_kp_twl4030_data,
>  };
> @@ -390,7 +485,6 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
> 
>  static struct platform_device *ldp_devices[] __initdata = {
>  	&ldp_smsc911x_device,
> -	&ldp_lcd_device,
>  	&ldp_gpio_keys_device,
>  };
> 
> @@ -441,8 +535,6 @@ static struct mtd_partition ldp_nand_partitions[] = {
>  static void __init omap_ldp_init(void)
>  {
>  	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
> -	omap_board_config = ldp_config;
> -	omap_board_config_size = ARRAY_SIZE(ldp_config);
>  	ldp_init_smsc911x();
>  	omap_i2c_init();
>  	platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
> @@ -459,6 +551,8 @@ static void __init omap_ldp_init(void)
>  	omap2_hsmmc_init(mmc);
>  	/* link regulators to MMC adapters */
>  	ldp_vmmc1_supply.dev = mmc[0].dev;
> +
> +	ldp_display_init();
>  }
> 
>  MACHINE_START(OMAP_LDP, "OMAP LDP board")
> 
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tomi Valkeinen May 17, 2011, 11:44 a.m. UTC | #3
On Mon, 2011-05-16 at 16:56 +0530, Janorkar, Mayuresh wrote:
> 
> > -----Original Message-----
> > From: Valkeinen, Tomi
> > Sent: Monday, May 16, 2011 2:23 PM
> > To: Igor Grinberg
> > Cc: Janorkar, Mayuresh; tony@atomide.com; linux-omap@vger.kernel.org;
> > Stanley Miao
> > Subject: Re: [PATCH 4/6] OMAP: LDP: Port the display driver to new DSS2

> > +static struct omap_dss_device ldp_lcd_device = {
> > +	.name			= "lcd",
> > +	.driver_name		= "generic_dpi_panel",
> > +	.type			= OMAP_DISPLAY_TYPE_DPI,
> > +	.phy.dpi.data_lines	= 16,
> 
> From a working DSS code at:
> http://lxr.linux.no/#linux+v2.6.38/drivers/video/omap/lcd_ldp.c
> .data_lines should be 18

Right, I missed that. Thanks.

 Tomi


--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tomi Valkeinen May 17, 2011, 11:49 a.m. UTC | #4
On Mon, 2011-05-16 at 14:13 +0300, Igor Grinberg wrote:
> On 05/16/11 11:53, Tomi Valkeinen wrote:
> 
> > Here's an updated patch with the twl gpio code.
> 
> Looks good, though one minor issue below
> 
> > All the old omapfb porting patches, including new drivers for DSS2, can
> > be found from 
> >
> > git://gitorious.org/linux-omap-dss2/linux.git old-omapfb-port
> >
> >  Tomi
> >
> > diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
> > index e2ba779..ed78b9a 100644
> > --- a/arch/arm/mach-omap2/board-ldp.c
> > +++ b/arch/arm/mach-omap2/board-ldp.c
> > @@ -44,6 +44,9 @@
> >  #include <asm/delay.h>
> >  #include <plat/usb.h>
> >  
> > +#include <video/omapdss.h>
> > +#include <video/omap-panel-generic-dpi.h>
> > +
> >  #include "board-flash.h"
> >  #include "mux.h"
> >  #include "hsmmc.h"
> > @@ -275,19 +278,70 @@ static inline void __init ldp_init_smsc911x(void)
> >  	gpio_direction_input(eth_gpio);
> >  }
> >  
> > -static struct platform_device ldp_lcd_device = {
> > -	.name		= "ldp_lcd",
> > -	.id		= -1,
> > +/* LCD */
> > +
> > +static int ldp_backlight_gpio;
> > +static int ldp_lcd_enable_gpio;
> > +
> > +#define LCD_PANEL_RESET_GPIO		55
> > +#define LCD_PANEL_QVGA_GPIO		56
> > +
> > +static int ldp_panel_enable_lcd(struct omap_dss_device *dssdev)
> > +{
> > +	gpio_direction_output(ldp_lcd_enable_gpio, 1);
> > +	gpio_direction_output(ldp_backlight_gpio, 1);
> > +
> > +	return 0;
> > +}
> > +
> > +static void ldp_panel_disable_lcd(struct omap_dss_device *dssdev)
> > +{
> > +	gpio_direction_output(ldp_lcd_enable_gpio, 0);
> > +	gpio_direction_output(ldp_backlight_gpio, 0);
> > +}
> > +
> > +static struct panel_generic_dpi_data ldp_panel_data = {
> > +	.name			= "2430sdp",
> > +	.platform_enable	= ldp_panel_enable_lcd,
> > +	.platform_disable	= ldp_panel_disable_lcd,
> > +};
> > +
> > +static struct omap_dss_device ldp_lcd_device = {
> > +	.name			= "lcd",
> > +	.driver_name		= "generic_dpi_panel",
> > +	.type			= OMAP_DISPLAY_TYPE_DPI,
> > +	.phy.dpi.data_lines	= 16,
> > +	.data			= &ldp_panel_data,
> >  };
> >  
> > -static struct omap_lcd_config ldp_lcd_config __initdata = {
> > -	.ctrl_name	= "internal",
> > +static struct omap_dss_device *ldp_dss_devices[] = {
> > +	&ldp_lcd_device,
> >  };
> >  
> > -static struct omap_board_config_kernel ldp_config[] __initdata = {
> > -	{ OMAP_TAG_LCD,		&ldp_lcd_config },
> > +static struct omap_dss_board_info ldp_dss_data = {
> > +	.num_devices	= ARRAY_SIZE(ldp_dss_devices),
> > +	.devices	= ldp_dss_devices,
> > +	.default_device	= &ldp_lcd_device,
> >  };
> >  
> > +static void __init ldp_display_init(void)
> > +{
> > +	int r;
> > +
> > +	static struct gpio gpios[] __initdata = {
> > +		{LCD_PANEL_RESET_GPIO, GPIOF_OUT_INIT_HIGH, "LCD RESET"},
> > +		{LCD_PANEL_QVGA_GPIO, GPIOF_OUT_INIT_HIGH, "LCD QVGA"},
> > +	};
> > +
> > +	r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
> > +	if (r) {
> > +		pr_err("Cannot request LCD GPIOs, error %d\n", r);
> > +		return;
> > +	}
> > +
> > +	omap_display_init(&ldp_dss_data);
> > +}
> > +
> >  static void __init omap_ldp_init_early(void)
> >  {
> >  	omap2_init_common_infrastructure();
> > @@ -298,10 +352,30 @@ static struct twl4030_usb_data ldp_usb_data = {
> >  	.usb_mode	= T2_USB_MODE_ULPI,
> >  };
> >  
> > +static int ldp_twl_gpio_setup(struct device *dev, unsigned gpio, unsigned ngpio)
> > +{
> > +	int r;
> > +
> > +	struct gpio gpios[] = {
> > +		{gpio + 7 , GPIOF_OUT_INIT_LOW, "LCD ENABLE"},
> > +		{gpio + 15, GPIOF_OUT_INIT_LOW, "LCD BACKLIGHT"},
> > +	};
> > +
> > +	r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
> > +	if (r)
> > +		pr_err("Cannot request LCD GPIOs, error %d\n", r);
> > +
> > +	ldp_backlight_gpio = gpio + 15;
> > +	ldp_lcd_enable_gpio = gpio + 7;
> 
> If the gpio_request_array() fails (though it shouldn't),
> won't it be right to set both variables to -EINVAL?

Ah, yes. I'll fix that.

Do you know what will happen if twl_gpio_setup fails? Just an error
print, or will TWL driver fail?

> Thanks for bringing this all together.

We still don't know if it works or not =).

 Tomi


--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tomi Valkeinen May 17, 2011, 11:56 a.m. UTC | #5
On Tue, 2011-05-17 at 14:49 +0300, Tomi Valkeinen wrote:
> On Mon, 2011-05-16 at 14:13 +0300, Igor Grinberg wrote:
> > On 05/16/11 11:53, Tomi Valkeinen wrote:

> > > +static int ldp_twl_gpio_setup(struct device *dev, unsigned gpio, unsigned ngpio)
> > > +{
> > > +	int r;
> > > +
> > > +	struct gpio gpios[] = {
> > > +		{gpio + 7 , GPIOF_OUT_INIT_LOW, "LCD ENABLE"},
> > > +		{gpio + 15, GPIOF_OUT_INIT_LOW, "LCD BACKLIGHT"},
> > > +	};
> > > +
> > > +	r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
> > > +	if (r)
> > > +		pr_err("Cannot request LCD GPIOs, error %d\n", r);
> > > +
> > > +	ldp_backlight_gpio = gpio + 15;
> > > +	ldp_lcd_enable_gpio = gpio + 7;
> > 
> > If the gpio_request_array() fails (though it shouldn't),
> > won't it be right to set both variables to -EINVAL?
> 
> Ah, yes. I'll fix that.
> 
> Do you know what will happen if twl_gpio_setup fails? Just an error
> print, or will TWL driver fail?

And I wonder if gpio_is_valid() works correctly for GPIOs from an gpio
expander? With a quick search, gpio_is_valid returns true if gpio is
between [0, 256[, and doesn't care if there are gpio expanders or not...

 Tomi


--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Igor Grinberg May 17, 2011, 12:28 p.m. UTC | #6
On 05/17/11 14:56, Tomi Valkeinen wrote:
> On Tue, 2011-05-17 at 14:49 +0300, Tomi Valkeinen wrote:
>> On Mon, 2011-05-16 at 14:13 +0300, Igor Grinberg wrote:
>>> On 05/16/11 11:53, Tomi Valkeinen wrote:
>>>> +static int ldp_twl_gpio_setup(struct device *dev, unsigned gpio, unsigned ngpio)
>>>> +{
>>>> +	int r;
>>>> +
>>>> +	struct gpio gpios[] = {
>>>> +		{gpio + 7 , GPIOF_OUT_INIT_LOW, "LCD ENABLE"},
>>>> +		{gpio + 15, GPIOF_OUT_INIT_LOW, "LCD BACKLIGHT"},
>>>> +	};
>>>> +
>>>> +	r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
>>>> +	if (r)
>>>> +		pr_err("Cannot request LCD GPIOs, error %d\n", r);
>>>> +
>>>> +	ldp_backlight_gpio = gpio + 15;
>>>> +	ldp_lcd_enable_gpio = gpio + 7;
>>> If the gpio_request_array() fails (though it shouldn't),
>>> won't it be right to set both variables to -EINVAL?
>> Ah, yes. I'll fix that.
>>
>> Do you know what will happen if twl_gpio_setup fails? Just an error
>> print, or will TWL driver fail?

I'm currently based on Tony's devel-cleanup branch (which is v2.6.39-rc4-...)
this is what twl4030-gpio.c does:

status = pdata->setup(&pdev->dev,
                pdata->gpio_base, TWL4030_GPIO_MAX);
if (status)
            dev_dbg(&pdev->dev, "setup --> %d\n", status);

so yes it is just an error print.

> And I wonder if gpio_is_valid() works correctly for GPIOs from an gpio
> expander? With a quick search, gpio_is_valid returns true if gpio is
> between [0, 256[, and doesn't care if there are gpio expanders or not...

Right, a sanity check only...
I guess each time 256 is not enough it just gets bumped up...
This can be a problem some day...
May be it should be a part of struct gpio_chip so the responsibility for
gpio validity will be on the driver in charge of that gpio?
But that is totally different discussion.

Regarding:

> We still don't know if it works or not =).

I thought Mayuresh checked this and confirmed, no?
Tomi Valkeinen May 17, 2011, 1:16 p.m. UTC | #7
On Tue, 2011-05-17 at 15:28 +0300, Igor Grinberg wrote:
> On 05/17/11 14:56, Tomi Valkeinen wrote:

> > We still don't know if it works or not =).
> 
> I thought Mayuresh checked this and confirmed, no?

No, as far as I understood he tried with the patch he attached, which
was something very different than this patch.

 Tomi


--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index e2ba779..ed78b9a 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -44,6 +44,9 @@ 
 #include <asm/delay.h>
 #include <plat/usb.h>
 
+#include <video/omapdss.h>
+#include <video/omap-panel-generic-dpi.h>
+
 #include "board-flash.h"
 #include "mux.h"
 #include "hsmmc.h"
@@ -275,19 +278,70 @@  static inline void __init ldp_init_smsc911x(void)
 	gpio_direction_input(eth_gpio);
 }
 
-static struct platform_device ldp_lcd_device = {
-	.name		= "ldp_lcd",
-	.id		= -1,
+/* LCD */
+
+static int ldp_backlight_gpio;
+static int ldp_lcd_enable_gpio;
+
+#define LCD_PANEL_RESET_GPIO		55
+#define LCD_PANEL_QVGA_GPIO		56
+
+static int ldp_panel_enable_lcd(struct omap_dss_device *dssdev)
+{
+	gpio_direction_output(ldp_lcd_enable_gpio, 1);
+	gpio_direction_output(ldp_backlight_gpio, 1);
+
+	return 0;
+}
+
+static void ldp_panel_disable_lcd(struct omap_dss_device *dssdev)
+{
+	gpio_direction_output(ldp_lcd_enable_gpio, 0);
+	gpio_direction_output(ldp_backlight_gpio, 0);
+}
+
+static struct panel_generic_dpi_data ldp_panel_data = {
+	.name			= "2430sdp",
+	.platform_enable	= ldp_panel_enable_lcd,
+	.platform_disable	= ldp_panel_disable_lcd,
+};
+
+static struct omap_dss_device ldp_lcd_device = {
+	.name			= "lcd",
+	.driver_name		= "generic_dpi_panel",
+	.type			= OMAP_DISPLAY_TYPE_DPI,
+	.phy.dpi.data_lines	= 16,
+	.data			= &ldp_panel_data,
 };
 
-static struct omap_lcd_config ldp_lcd_config __initdata = {
-	.ctrl_name	= "internal",
+static struct omap_dss_device *ldp_dss_devices[] = {
+	&ldp_lcd_device,
 };
 
-static struct omap_board_config_kernel ldp_config[] __initdata = {
-	{ OMAP_TAG_LCD,		&ldp_lcd_config },
+static struct omap_dss_board_info ldp_dss_data = {
+	.num_devices	= ARRAY_SIZE(ldp_dss_devices),
+	.devices	= ldp_dss_devices,
+	.default_device	= &ldp_lcd_device,
 };
 
+static void __init ldp_display_init(void)
+{
+	int r;
+
+	static struct gpio gpios[] __initdata = {
+		{LCD_PANEL_RESET_GPIO, GPIOF_OUT_INIT_HIGH, "LCD RESET"},
+		{LCD_PANEL_QVGA_GPIO, GPIOF_OUT_INIT_HIGH, "LCD QVGA"},
+	};
+
+	r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
+	if (r) {
+		pr_err("Cannot request LCD GPIOs, error %d\n", r);
+		return;
+	}
+
+	omap_display_init(&ldp_dss_data);
+}
+
 static void __init omap_ldp_init_early(void)
 {
 	omap2_init_common_infrastructure();
@@ -298,10 +352,30 @@  static struct twl4030_usb_data ldp_usb_data = {
 	.usb_mode	= T2_USB_MODE_ULPI,
 };
 
+static int ldp_twl_gpio_setup(struct device *dev, unsigned gpio, unsigned ngpio)
+{
+	int r;
+
+	struct gpio gpios[] = {
+		{gpio + 7 , GPIOF_OUT_INIT_LOW, "LCD ENABLE"},
+		{gpio + 15, GPIOF_OUT_INIT_LOW, "LCD BACKLIGHT"},
+	};
+
+	r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
+	if (r)
+		pr_err("Cannot request LCD GPIOs, error %d\n", r);
+
+	ldp_backlight_gpio = gpio + 15;
+	ldp_lcd_enable_gpio = gpio + 7;
+
+	return r;
+}
+
 static struct twl4030_gpio_platform_data ldp_gpio_data = {
 	.gpio_base	= OMAP_MAX_GPIO_LINES,
 	.irq_base	= TWL4030_GPIO_IRQ_BASE,
 	.irq_end	= TWL4030_GPIO_IRQ_END,
+	.setup		= ldp_twl_gpio_setup,
 };
 
 static struct twl4030_madc_platform_data ldp_madc_data = {
@@ -347,6 +421,26 @@  static struct regulator_init_data ldp_vaux1 = {
 	.consumer_supplies		= ldp_vaux1_supplies,
 };
 
+static struct regulator_consumer_supply ldp_vpll2_supplies[] = {
+	REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
+	REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi1"),
+};
+
+static struct regulator_init_data ldp_vpll2 = {
+	.constraints = {
+		.name			= "VDVI",
+		.min_uV			= 1800000,
+		.max_uV			= 1800000,
+		.apply_uV		= true,
+		.valid_modes_mask	= REGULATOR_MODE_NORMAL
+					| REGULATOR_MODE_STANDBY,
+		.valid_ops_mask		= REGULATOR_CHANGE_MODE
+					| REGULATOR_CHANGE_STATUS,
+	},
+	.num_consumer_supplies	= ARRAY_SIZE(ldp_vpll2_supplies),
+	.consumer_supplies	= ldp_vpll2_supplies,
+};
+
 static struct twl4030_platform_data ldp_twldata = {
 	.irq_base	= TWL4030_IRQ_BASE,
 	.irq_end	= TWL4030_IRQ_END,
@@ -356,6 +450,7 @@  static struct twl4030_platform_data ldp_twldata = {
 	.usb		= &ldp_usb_data,
 	.vmmc1		= &ldp_vmmc1,
 	.vaux1		= &ldp_vaux1,
+	.vpll2		= &ldp_vpll2,
 	.gpio		= &ldp_gpio_data,
 	.keypad		= &ldp_kp_twl4030_data,
 };
@@ -390,7 +485,6 @@  static struct omap2_hsmmc_info mmc[] __initdata = {
 
 static struct platform_device *ldp_devices[] __initdata = {
 	&ldp_smsc911x_device,
-	&ldp_lcd_device,
 	&ldp_gpio_keys_device,
 };
 
@@ -441,8 +535,6 @@  static struct mtd_partition ldp_nand_partitions[] = {
 static void __init omap_ldp_init(void)
 {
 	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
-	omap_board_config = ldp_config;
-	omap_board_config_size = ARRAY_SIZE(ldp_config);
 	ldp_init_smsc911x();
 	omap_i2c_init();
 	platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
@@ -459,6 +551,8 @@  static void __init omap_ldp_init(void)
 	omap2_hsmmc_init(mmc);
 	/* link regulators to MMC adapters */
 	ldp_vmmc1_supply.dev = mmc[0].dev;
+
+	ldp_display_init();
 }
 
 MACHINE_START(OMAP_LDP, "OMAP LDP board")