From patchwork Thu May 12 14:36:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MAYURESH JANORKAR X-Patchwork-Id: 780352 X-Patchwork-Delegate: tomi.valkeinen@nokia.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4CEbA1L002370 for ; Thu, 12 May 2011 14:37:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757819Ab1ELOhI (ORCPT ); Thu, 12 May 2011 10:37:08 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:43732 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757805Ab1ELOhH (ORCPT ); Thu, 12 May 2011 10:37:07 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id p4CEaphU019633 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 12 May 2011 09:36:57 -0500 Received: from dbde71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id p4CEah52005630; Thu, 12 May 2011 20:06:44 +0530 (IST) Received: from dbde02.ent.ti.com ([172.24.170.145]) by dbde71.ent.ti.com ([172.24.170.149]) with mapi; Thu, 12 May 2011 20:06:43 +0530 From: "Janorkar, Mayuresh" To: "Valkeinen, Tomi" , Igor Grinberg CC: "tony@atomide.com" , "linux-omap@vger.kernel.org" , Stanley Miao Date: Thu, 12 May 2011 20:06:42 +0530 Subject: RE: [PATCH 4/6] OMAP: LDP: Port the display driver to new DSS2 Thread-Topic: [PATCH 4/6] OMAP: LDP: Port the display driver to new DSS2 Thread-Index: AcwQmmgSenTyuYQ7SAiu+Yd/hpjrowAF0zmg Message-ID: References: <1304926567-26814-1-git-send-email-tomi.valkeinen@ti.com> <1304926567-26814-5-git-send-email-tomi.valkeinen@ti.com> <1305095563.2097.11.camel@deskari> <4DCB80DD.5090408@compulab.co.il> <4DCB8937.2060101@compulab.co.il> <4DCB9C71.2020503@compulab.co.il> <4DCBC273.9030807@compulab.co.il> <1305200857.2062.24.camel@deskari> In-Reply-To: <1305200857.2062.24.camel@deskari> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 12 May 2011 14:37:11 +0000 (UTC) > -----Original Message----- > From: Valkeinen, Tomi > Sent: Thursday, May 12, 2011 5:18 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 14:20 +0300, Igor Grinberg wrote: > > > Right. Do both fixes make it work? > > > > If it is, then Tomi, > > will you add both fixes to the patch set with our SOBs? > > or do you want this to be sent properly as a follow up? > > Yes, I can add these all to the same patch and handle it through DSS > tree. Although due to the reluctance to make changes to arch/arm/*omap*, > I guess we'll pass these patches in this merge window. > > Mayuresh, if you're able to test this and it works, can you send me the > full diff so that I don't make any mistakes combining the code? > > Tomi > Please find the patch below. I have also attached the same. There are formatting problems with this patch. But this can be used as a reference. I have verified bootup with Penguins on LDP board. From 1f3470d3d792721bf5aa4d060c1cf79f5a587497 Mon Sep 17 00:00:00 2001 From: Mayuresh Janorkar Date: Thu, 12 May 2011 18:53:46 +0530 Subject: [PATCH] LDP Tomi patch --- arch/arm/mach-omap2/board-ldp.c | 87 ++++++++++-- drivers/video/omap2/displays/Kconfig | 5 + drivers/video/omap2/displays/Makefile | 1 + drivers/video/omap2/displays/panel-ldp.c | 223 ++++++++++++++++++++++++++++++ 4 files changed, 305 insertions(+), 11 deletions(-) mode change 100644 => 100755 arch/arm/mach-omap2/board-ldp.c create mode 100755 drivers/video/omap2/displays/panel-ldp.c diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c old mode 100644 new mode 100755 index e2ba779..fa6327a --- a/arch/arm/mach-omap2/board-ldp.c +++ b/arch/arm/mach-omap2/board-ldp.c @@ -43,6 +43,7 @@ #include #include +#include #include "board-flash.h" #include "mux.h" @@ -53,6 +54,11 @@ #define LDP_SMSC911X_GPIO 152 #define DEBUG_BASE 0x08000000 #define LDP_ETHR_START DEBUG_BASE +#define LCD_PANEL_BACKLIGHT_GPIO (15 + OMAP_MAX_GPIO_LINES) +#define LCD_PANEL_ENABLE_GPIO (7 + OMAP_MAX_GPIO_LINES) + +#define LCD_PANEL_RESET_GPIO 55 +#define LCD_PANEL_QVGA_GPIO 56 static struct resource ldp_smsc911x_resources[] = { [0] = { @@ -275,19 +281,78 @@ 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, +#define SDP3430_LCD_PANEL_BACKLIGHT_GPIO 8 +#define SDP3430_LCD_PANEL_ENABLE_GPIO 5 + +static unsigned backlight_gpio; +static unsigned enable_gpio; +static int lcd_enabled; + +static void __init sdp3430_display_init(void) +{ + printk(KERN_INFO "\n LDP:: sdp3430_display_init "); + return; +} + +static int sdp3430_panel_enable_lcd(struct omap_dss_device *dssdev) +{ + int status; + return 0; +} + +static void sdp3430_panel_disable_lcd(struct omap_dss_device *dssdev) +{ + lcd_enabled = 0; + + gpio_direction_output(enable_gpio, 0); + gpio_direction_output(backlight_gpio, 0); + + gpio_direction_output(LCD_PANEL_ENABLE_GPIO, 0); + gpio_direction_output(LCD_PANEL_BACKLIGHT_GPIO, 0); + +} + +static struct omap_dss_device sdp3430_lcd_device = { + .name = "lcd", + .driver_name = "ldp_panel", + .type = OMAP_DISPLAY_TYPE_DPI, + .phy.dpi.data_lines = 16, + .platform_enable = sdp3430_panel_enable_lcd, + .platform_disable = sdp3430_panel_disable_lcd, }; -static struct omap_lcd_config ldp_lcd_config __initdata = { - .ctrl_name = "internal", +static struct omap_dss_device *sdp3430_dss_devices[] = { + &sdp3430_lcd_device, }; -static struct omap_board_config_kernel ldp_config[] __initdata = { - { OMAP_TAG_LCD, &ldp_lcd_config }, +static struct omap_dss_board_info sdp3430_dss_data = { + .num_devices = ARRAY_SIZE(sdp3430_dss_devices), + .devices = sdp3430_dss_devices, + .default_device = &sdp3430_lcd_device, }; +/* VPLL2 for digital video outputs */ +static struct regulator_consumer_supply sdp3430_vpll2_supplies[] = { + REGULATOR_SUPPLY("vdds_dsi", "omapdss"), + REGULATOR_SUPPLY("vdds_dsi", "omap_dsi1"), +}; + +static struct regulator_init_data sdp3430_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(sdp3430_vpll2_supplies), + .consumer_supplies = sdp3430_vpll2_supplies, +}; + + static void __init omap_ldp_init_early(void) { omap2_init_common_infrastructure(); @@ -358,6 +423,7 @@ static struct twl4030_platform_data ldp_twldata = { .vaux1 = &ldp_vaux1, .gpio = &ldp_gpio_data, .keypad = &ldp_kp_twl4030_data, + .vpll2 = &sdp3430_vpll2, }; static struct i2c_board_info __initdata ldp_i2c_boardinfo[] = { @@ -390,7 +456,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,10 +506,8 @@ 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(); +// sdp3430_display_init(); platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices)); ts_gpio = 54; ldp_spi_board_info[0].irq = gpio_to_irq(ts_gpio); @@ -459,6 +522,8 @@ static void __init omap_ldp_init(void) omap2_hsmmc_init(mmc); /* link regulators to MMC adapters */ ldp_vmmc1_supply.dev = mmc[0].dev; + sdp3430_display_init(); + omap_display_init(&sdp3430_dss_data); } MACHINE_START(OMAP_LDP, "OMAP LDP board") diff --git a/drivers/video/omap2/displays/Kconfig b/drivers/video/omap2/displays/Kconfig index 0b05593..3f4488b 100644 --- a/drivers/video/omap2/displays/Kconfig +++ b/drivers/video/omap2/displays/Kconfig @@ -55,4 +55,9 @@ config PANEL_ACX565AKM select BACKLIGHT_CLASS_DEVICE help This is the LCD panel used on Nokia N900 +config PANEL_LDP + tristate "LDP PANEL" + help + This is the LCD panel used on LDP + endmenu diff --git a/drivers/video/omap2/displays/Makefile b/drivers/video/omap2/displays/Makefile index d90f73c..9d7235c 100644 --- a/drivers/video/omap2/displays/Makefile +++ b/drivers/video/omap2/displays/Makefile @@ -7,3 +7,4 @@ obj-$(CONFIG_PANEL_TAAL) += panel-taal.o obj-$(CONFIG_PANEL_PICODLP) += panel-picodlp.o obj-$(CONFIG_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o obj-$(CONFIG_PANEL_ACX565AKM) += panel-acx565akm.o +obj-$(CONFIG_PANEL_LDP) += panel-ldp.o diff --git a/drivers/video/omap2/displays/panel-ldp.c b/drivers/video/omap2/displays/panel-ldp.c new file mode 100755 index 0000000..3f9bfd1 --- /dev/null +++ b/drivers/video/omap2/displays/panel-ldp.c @@ -0,0 +1,223 @@ +/* + * Generic DPI Panels support + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#define LCD_PANEL_BACKLIGHT_GPIO (15 + OMAP_MAX_GPIO_LINES) +#define LCD_PANEL_ENABLE_GPIO (7 + OMAP_MAX_GPIO_LINES) + +#define LCD_PANEL_RESET_GPIO 55 +#define LCD_PANEL_QVGA_GPIO 56 + +#ifdef CONFIG_FB_OMAP_LCD_VGA +#define LCD_XRES 480 +#define LCD_YRES 640 +#define LCD_PIXCLOCK_MAX 41700 +#else +#define LCD_XRES 240 +#define LCD_YRES 320 +#define LCD_PIXCLOCK_MAX 185186 +#endif + +#define PM_RECEIVER TWL4030_MODULE_PM_RECEIVER +#define ENABLE_VAUX2_DEDICATED 0x09 +#define ENABLE_VAUX2_DEV_GRP 0x20 +#define ENABLE_VAUX3_DEDICATED 0x03 +#define ENABLE_VAUX3_DEV_GRP 0x20 + +#define ENABLE_VPLL2_DEDICATED 0x05 +#define ENABLE_VPLL2_DEV_GRP 0xE0 +#define TWL4030_VPLL2_DEV_GRP 0x33 +#define TWL4030_VPLL2_DEDICATED 0x36 + +#define t2_out(c, r, v) twl_i2c_write_u8(c, r, v) + +static struct omap_video_timings ldp_timings = { + .x_res = 480, + .y_res = 640, + + .hsw = 3, + .hfp = 3, + .hbp = 39, + + .vsw = 1, + .vfp = 2, + .vbp = 7, + .pixel_clock = 41700, +}; + +static void ldp_panel_cleanup(void) +{ + gpio_free(LCD_PANEL_BACKLIGHT_GPIO); + gpio_free(LCD_PANEL_ENABLE_GPIO); + gpio_free(LCD_PANEL_QVGA_GPIO); + gpio_free(LCD_PANEL_RESET_GPIO); +} + +static int panel_ldp_probe(struct omap_dss_device *dssdev) +{ + dssdev->panel.timings = ldp_timings; + dssdev->panel.config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS | + OMAP_DSS_LCD_IHS; + dssdev->panel.acb = 0x28; + + return 0; +} + +static void panel_ldp_remove(struct omap_dss_device *dssdev) +{ + return; +} + +static int panel_ldp_power_on(struct omap_dss_device *dssdev) +{ + int r = 0; + + if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) + return 0; + r = omapdss_dpi_display_enable(dssdev); + if (r) + goto err0; + + /* wait couple of vsyncs until enabling the LCD */ + msleep(50); + if (dssdev->platform_enable) { + r = dssdev->platform_enable(dssdev); + if (r) + goto err1; + } + return 0; +err1: + omapdss_dpi_display_disable(dssdev); +err0: + return r; +} + +static void panel_ldp_power_off(struct omap_dss_device *dssdev) +{ + if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) + return; + + if (dssdev->platform_disable) + dssdev->platform_disable(dssdev); + + /* wait at least 5 vsyncs after disabling the LCD */ + + msleep(100); + + omapdss_dpi_display_disable(dssdev); +} +static int panel_ldp_enable(struct omap_dss_device *dssdev) +{ + gpio_request(LCD_PANEL_RESET_GPIO, "lcd reset"); + gpio_request(LCD_PANEL_QVGA_GPIO, "lcd qvga"); + gpio_request(LCD_PANEL_ENABLE_GPIO, "lcd panel"); + gpio_request(LCD_PANEL_BACKLIGHT_GPIO, "lcd backlight"); + + gpio_direction_output(LCD_PANEL_QVGA_GPIO, 0); + gpio_direction_output(LCD_PANEL_RESET_GPIO, 0); + gpio_direction_output(LCD_PANEL_ENABLE_GPIO, 0); + gpio_direction_output(LCD_PANEL_BACKLIGHT_GPIO, 0); + +#ifdef CONFIG_FB_OMAP_LCD_VGA + gpio_set_value(LCD_PANEL_QVGA_GPIO, 0); +#else + gpio_set_value(LCD_PANEL_QVGA_GPIO, 1); +#endif + gpio_set_value(LCD_PANEL_RESET_GPIO, 1); + + if (0 != t2_out(PM_RECEIVER, ENABLE_VPLL2_DEDICATED, + TWL4030_VPLL2_DEDICATED)) + return -EIO; + + if (0 != t2_out(PM_RECEIVER, ENABLE_VPLL2_DEV_GRP, + TWL4030_VPLL2_DEV_GRP)) + return -EIO; + + gpio_direction_output(LCD_PANEL_ENABLE_GPIO, 1); + gpio_direction_output(LCD_PANEL_BACKLIGHT_GPIO, 1); + + int r = panel_ldp_power_on(dssdev); + + dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; + if (0 != t2_out(PM_RECEIVER, ENABLE_VAUX3_DEDICATED, + TWL4030_VAUX3_DEDICATED)) + return -EIO; + + if (0 != t2_out(PM_RECEIVER, ENABLE_VAUX3_DEV_GRP, + TWL4030_VAUX3_DEV_GRP)) + return -EIO; + + return r; +} + +static void panel_ldp_disable(struct omap_dss_device *dssdev) +{ + gpio_direction_output(LCD_PANEL_ENABLE_GPIO, 0); + gpio_direction_output(LCD_PANEL_BACKLIGHT_GPIO, 0); + + t2_out(PM_RECEIVER, 0x0, TWL4030_VPLL2_DEDICATED); + t2_out(PM_RECEIVER, 0x0, TWL4030_VPLL2_DEV_GRP); + msleep(4); + panel_ldp_power_off(dssdev); + dssdev->state = OMAP_DSS_DISPLAY_DISABLED; +} + +static void panel_ldp_get_resolution(struct omap_dss_device *dssdev, int *w, int *h) +{ + *w = ldp_timings.x_res; + *h = ldp_timings.y_res; + if (*w == 0) + *w = 320; +} + +static struct omap_dss_driver ldp_panel = { + .probe = panel_ldp_probe, + .remove = panel_ldp_remove, + + .enable = panel_ldp_enable, + .disable = panel_ldp_disable, + + .get_resolution = panel_ldp_get_resolution, + + .driver = { + .name = "ldp_panel", + .owner = THIS_MODULE, + }, +}; + +static int __init panel_ldp_drv_init(void) +{ + return omap_dss_register_driver(&ldp_panel); +} + +static void __exit panel_ldp_drv_exit(void) +{ + omap_dss_unregister_driver(&ldp_panel); +} + +module_init(panel_ldp_drv_init); +module_exit(panel_ldp_drv_exit); +MODULE_LICENSE("GPL");