From patchwork Fri Oct 16 11:05:27 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chaithrika@ti.com X-Patchwork-Id: 54234 Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9GBCCn2027543 for ; Fri, 16 Oct 2009 11:12:13 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id n9GBAKis031898 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 16 Oct 2009 06:10:20 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id n9GBAIEh005119; Fri, 16 Oct 2009 06:10:19 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 4C09980627; Fri, 16 Oct 2009 06:10:18 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id EB62E80626 for ; Fri, 16 Oct 2009 06:10:16 -0500 (CDT) Received: from tidmzi-ftp.india.ext.ti.com (localhost [127.0.0.1]) by dflp53.itg.ti.com (8.13.8/8.13.8) with SMTP id n9GBAEMc000088; Fri, 16 Oct 2009 06:10:15 -0500 (CDT) Received: from symphonyindia.ti.com (symphony-ftp [192.168.247.11]) by tidmzi-ftp.india.ext.ti.com (Postfix) with SMTP id 4DF633886B; Fri, 16 Oct 2009 16:37:09 +0530 (IST) Received: from localhost.localdomain ([192.168.247.76]) by symphonyindia.ti.com (8.13.1/8.12.10) with ESMTP id n9GB3nMJ029732; Fri, 16 Oct 2009 16:33:49 +0530 From: Chaithrika U S To: davinci-linux-open-source@linux.davincidsp.com Date: Fri, 16 Oct 2009 16:35:27 +0530 Message-Id: <1255691127-31438-1-git-send-email-chaithrika@ti.com> X-Mailer: git-send-email 1.5.6 Cc: akpm@linux-foundation.org, krzysztof.h1@poczta.fm Subject: [PATCH] davinci: fb: Calculate the clock divider from pixel clock info X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.4 Precedence: list List-Id: davinci-linux-open-source.linux.davincidsp.com List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c index d065894..d9ab839 100644 --- a/drivers/video/da8xx-fb.c +++ b/drivers/video/da8xx-fb.c @@ -113,6 +113,7 @@ struct da8xx_fb_par { unsigned short pseudo_palette[16]; unsigned int databuf_sz; unsigned int palette_sz; + unsigned int pxl_clk; }; /* Variable Screen Information */ @@ -155,7 +156,7 @@ struct da8xx_panel { int vfp; /* Vertical front porch */ int vbp; /* Vertical back porch */ int vsw; /* Vertical Sync Pulse Width */ - int pxl_clk; /* Pixel clock */ + unsigned int pxl_clk; /* Pixel clock */ unsigned char invert_pxl_clk; /* Invert Pixel clock */ }; @@ -171,7 +172,7 @@ static struct da8xx_panel known_lcd_panels[] = { .vfp = 2, .vbp = 2, .vsw = 0, - .pxl_clk = 0x10, + .pxl_clk = 4608000, .invert_pxl_clk = 1, }, /* Sharp LK043T1DG01 */ @@ -185,7 +186,7 @@ static struct da8xx_panel known_lcd_panels[] = { .vfp = 2, .vbp = 2, .vsw = 10, - .pxl_clk = 0x12, + .pxl_clk = 7833600, .invert_pxl_clk = 0, }, }; @@ -451,6 +452,18 @@ static void lcd_reset(struct da8xx_fb_par *par) lcdc_write(0, LCD_RASTER_CTRL_REG); } +static void lcd_calc_clk_divider(struct da8xx_fb_par *par) +{ + unsigned int lcd_clk, div; + + lcd_clk = clk_get_rate(par->lcdc_clk); + div = lcd_clk / par->pxl_clk; + + /* Configure the LCD clock divisor. */ + lcdc_write(LCD_CLK_DIVISOR(div) | + (LCD_RASTER_MODE & 0x1), LCD_CTRL_REG); +} + static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg, struct da8xx_panel *panel) { @@ -459,9 +472,8 @@ static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg, lcd_reset(par); - /* Configure the LCD clock divisor. */ - lcdc_write(LCD_CLK_DIVISOR(panel->pxl_clk) | - (LCD_RASTER_MODE & 0x1), LCD_CTRL_REG); + /* Calculate the divider */ + lcd_calc_clk_divider(par); if (panel->invert_pxl_clk) lcdc_write((lcdc_read(LCD_RASTER_TIMING_2_REG) | @@ -721,6 +733,8 @@ static int __init fb_probe(struct platform_device *device) } par = da8xx_fb_info->par; + par->lcdc_clk = fb_clk; + par->pxl_clk = lcdc_info->pxl_clk; if (lcd_init(par, lcd_cfg, lcdc_info) < 0) { dev_err(&device->dev, "lcd_init failed\n"); @@ -753,8 +767,6 @@ static int __init fb_probe(struct platform_device *device) da8xx_fb_fix.smem_len = par->databuf_sz - par->palette_sz; da8xx_fb_fix.line_length = (lcdc_info->width * lcd_cfg->bpp) / 8; - par->lcdc_clk = fb_clk; - par->irq = platform_get_irq(device, 0); if (par->irq < 0) { ret = -ENOENT;