2 * Copyright (C) 2012 Spreadtrum Communications Inc.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
15 #include <linux/clk.h>
16 #include <linux/delay.h>
23 #define LCDC_PRINT printk
25 #define LCDC_PRINT(...)
29 int32_t lcm_send_cmd (uint32_t cmd)
31 /* wait for that the ahb enter idle state */
32 while(lcdc_read(LCM_CTRL) & BIT(20));
34 lcdc_write(cmd, LCM_CMD);
38 int32_t lcm_send_cmd_data (uint32_t cmd, uint32_t data)
40 /* wait for that the ahb enter idle state */
41 while(lcdc_read(LCM_CTRL) & BIT(20));
43 lcdc_write(cmd, LCM_CMD);
45 /* wait for that the ahb enter idle state */
46 while(lcdc_read(LCM_CTRL) & BIT(20));
48 lcdc_write(data, LCM_DATA);
52 int32_t lcm_send_data (uint32_t data)
54 /* wait for that the ahb enter idle state */
55 while(lcdc_read(LCM_CTRL) & BIT(20));
57 lcdc_write(data, LCM_DATA);
61 uint32_t lcm_read_data (void)
63 /* wait for that the ahb enter idle state */
64 while(lcdc_read(LCM_CTRL) & BIT(20));
65 lcdc_write(1 << 24, LCM_DATA);
67 return lcdc_read(LCM_RDDATA);
70 static struct clk * s_lcdcclk = NULL;
77 if( NULL == s_lcdcclk ) {
78 s_lcdcclk = clk_get(NULL, "clk_lcdc");
80 if( s_lcdcclk == NULL ) {
81 printk(KERN_ERR "can not get clk_lcdc!!!!!\n");
85 clk_enable(s_lcdcclk);
87 ctrl = lcdc_read(LCM_CTRL);
88 printk("reg[LCM_CTRL] = %x\n", ctrl);
91 ctrl |= 0x02828; // bus&pixel are 24bits
93 lcdc_write(ctrl, LCM_CTRL);
95 //lcdc_write((1 << 8) | (5 << 4) | 5, LCM_TIMING0);
96 //lcdc_write((1 << 8) | (5 << 4) | 5, LCM_TIMING1);
98 //for( i = LCM_CTRL; i <= LCM_RSTN; i += 4 ) {
99 // printk("reg[%x] = %x\n", i, lcdc_read(i));
107 if( NULL != s_lcdcclk ) {
108 clk_disable(s_lcdcclk);
110 printk("lcm_close \n");