netfilter: Fix wrong backporting
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / drivers / autotst / lcdc.c
1 /*
2  * Copyright (C) 2012 Spreadtrum Communications Inc.
3  *
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.
7  *
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.
12  */
13
14 #include <linux/fb.h>
15 #include <linux/clk.h>
16 #include <linux/delay.h>
17
18 #include "lcdc_reg.h"
19
20
21 //#define  LCDC_DEBUG
22 #ifdef LCDC_DEBUG
23 #define LCDC_PRINT printk
24 #else
25 #define LCDC_PRINT(...)
26 #endif
27
28
29 int32_t lcm_send_cmd (uint32_t cmd)
30 {
31         /* wait for that the ahb enter idle state */
32         while(lcdc_read(LCM_CTRL) & BIT(20));
33
34         lcdc_write(cmd, LCM_CMD);
35         return 0;
36 }
37
38 int32_t lcm_send_cmd_data (uint32_t cmd, uint32_t data)
39 {
40         /* wait for that the ahb enter idle state */
41         while(lcdc_read(LCM_CTRL) & BIT(20));
42
43         lcdc_write(cmd, LCM_CMD);
44
45         /* wait for that the ahb enter idle state */
46         while(lcdc_read(LCM_CTRL) & BIT(20));
47
48         lcdc_write(data, LCM_DATA);
49         return 0;
50 }
51
52 int32_t lcm_send_data (uint32_t data)
53 {
54         /* wait for that the ahb enter idle state */
55          while(lcdc_read(LCM_CTRL) & BIT(20));
56
57         lcdc_write(data, LCM_DATA);
58         return 0;
59 }
60
61 uint32_t lcm_read_data (void)
62 {
63         /* wait for that the ahb enter idle state */
64         while(lcdc_read(LCM_CTRL) & BIT(20));
65         lcdc_write(1 << 24, LCM_DATA);
66         udelay(50);
67         return lcdc_read(LCM_RDDATA);
68 }
69
70 static struct clk * s_lcdcclk = NULL;
71
72 int lcm_init(void)
73 {
74         //int i;
75         unsigned int ctrl;
76
77     if( NULL == s_lcdcclk ) {
78         s_lcdcclk = clk_get(NULL, "clk_lcdc");
79     }
80         if( s_lcdcclk == NULL ) {
81                 printk(KERN_ERR "can not get clk_lcdc!!!!!\n");
82                 return -EFAULT;
83         }
84
85         clk_enable(s_lcdcclk);
86
87     ctrl = lcdc_read(LCM_CTRL);
88         printk("reg[LCM_CTRL] = %x\n", ctrl);
89
90         ctrl &= 0x10000;
91         ctrl |= 0x02828; // bus&pixel are 24bits
92
93     lcdc_write(ctrl, LCM_CTRL);
94
95     //lcdc_write((1 << 8) | (5 << 4) | 5, LCM_TIMING0);
96     //lcdc_write((1 << 8) | (5 << 4) | 5, LCM_TIMING1);
97
98     //for( i = LCM_CTRL; i <= LCM_RSTN;  i += 4 ) {
99     //    printk("reg[%x] = %x\n", i, lcdc_read(i));
100     //}
101
102         return 0;
103 }
104
105 int lcm_close(void)
106 {
107         if( NULL != s_lcdcclk ) {
108                 clk_disable(s_lcdcclk);
109         }
110         printk("lcm_close \n");
111         return 0;
112 }
113
114