summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/s5l8700/meizu-m6sl/lcd-m6sl.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/firmware/target/arm/s5l8700/meizu-m6sl/lcd-m6sl.c b/firmware/target/arm/s5l8700/meizu-m6sl/lcd-m6sl.c
index 1affab3b01..567023d35e 100644
--- a/firmware/target/arm/s5l8700/meizu-m6sl/lcd-m6sl.c
+++ b/firmware/target/arm/s5l8700/meizu-m6sl/lcd-m6sl.c
@@ -29,6 +29,110 @@
29/*** definitions ***/ 29/*** definitions ***/
30 30
31 31
32#define SPIDELAY(_x) void(_x);
33
34#define SETMOSI() (PDAT4 |= (1 << 3))
35#define CLRMOSI() (PDAT4 &= ~(1 << 3))
36
37#define MISO ((PDAT1 >> 1) & 1)
38
39#define SETCLK() (PDAT4 |= (1 << 2))
40#define CLRCLK() (PDAT4 &= ~(1 << 2))
41
42#define SETSS() (PDAT7 |= (1 << 1))
43#define CLRSS() (PDAT7 &= ~(1 << 1))
44
45void init_lcd_spi(void)
46{
47 int oldval;
48
49 oldval = PCON1;
50 //Set P1.1 to input
51 PCON1 = ((oldval & ~(0xf << 4)));
52
53 oldval = PCON4;
54 //Set P4.2 and 4.3 to output
55 PCON4 = ((oldval & ~(0xf << 8 | 0xf << 12)) | (1 << 8 | 1 << 12));
56
57 oldval = PCON4;
58 //Set P4.2 and 4.3 to output
59 PCON4 = ((oldval & ~(0xf << 8 | 0xf << 12)) | (1 << 8 | 1 << 12));
60
61 oldval = PCON7;
62 //Set P7.0 and 7.1 to output
63 PCON7 = ((oldval & ~(0xf << 0 | 0xf << 4)) | (1 << 0 | 1 << 4));
64
65 SETSS();
66 SETCLK();
67}
68
69static inline void delay(int duration)
70{
71 volatile int i;
72 for(i=0;i<duration;i++);
73}
74
75unsigned int lcd_spi_io(unsigned int output,unsigned int bits,unsigned int inskip)
76{
77 unsigned int input = 0;
78 unsigned int i;
79
80 //delay(10); // < 470 us
81
82 CLRSS();
83 //delay(13); // > 22 us
84
85 for (i = 0; i < bits+inskip; i++) {
86
87 CLRCLK();
88
89 if(i<bits)
90 {
91 if (output & (1 << (bits-1)))
92 SETMOSI();
93 else
94 CLRMOSI();
95 output <<= 1;
96 }
97 else
98 {
99 CLRMOSI();
100 }
101
102 //delay(20); // >> 6.7 us
103
104 SETCLK();
105
106 if(i>=inskip)
107 {
108 input <<= 1;
109 input |= MISO;
110 }
111
112 //delay(20); // >> 6.7 us
113 }
114
115 SETSS();
116
117 return (input);
118}
119
120
121void spi_set_reg(unsigned char reg,unsigned short value)
122{
123 lcd_spi_io(0x700000|reg,24,0); // possibly 0x74
124 lcd_spi_io(0x720000|value,24,0); // possibly 0x77
125}
126
127unsigned int lcd_read_id(void)
128{
129 unsigned int device_code;
130 lcd_spi_io(0x700000,24,0); // possibly 0x74
131
132 device_code=lcd_spi_io(0x7300,16,24); // possibly 0x77
133 return device_code;
134}
135
32/** globals **/ 136/** globals **/
33 137
34static int xoffset; /* needed for flip */ 138static int xoffset; /* needed for flip */