diff options
-rw-r--r-- | bootloader/meizu_m6sl.c | 34 | ||||
-rw-r--r-- | firmware/target/arm/s5l8700/meizu-m6sl/lcd-m6sl.c | 104 |
2 files changed, 134 insertions, 4 deletions
diff --git a/bootloader/meizu_m6sl.c b/bootloader/meizu_m6sl.c index 442a0f9e18..86c4c5731e 100644 --- a/bootloader/meizu_m6sl.c +++ b/bootloader/meizu_m6sl.c | |||
@@ -77,9 +77,10 @@ void bl_debug(bool bit) | |||
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | void bl_debug_int(unsigned int input) | 80 | void bl_debug_count(unsigned int input) |
81 | { | 81 | { |
82 | unsigned int i; | 82 | unsigned int i; |
83 | delay(SHORT_DELAY*3); | ||
83 | for (i = 0; i < input; i++) | 84 | for (i = 0; i < input; i++) |
84 | { | 85 | { |
85 | PDAT0 ^= (1 << 2); //Toggle backlight | 86 | PDAT0 ^= (1 << 2); //Toggle backlight |
@@ -87,12 +88,26 @@ void bl_debug_int(unsigned int input) | |||
87 | PDAT0 ^= (1 << 2); //Toggle backlight | 88 | PDAT0 ^= (1 << 2); //Toggle backlight |
88 | delay(2*SHORT_DELAY); | 89 | delay(2*SHORT_DELAY); |
89 | } | 90 | } |
91 | } | ||
92 | void bl_debug_int(unsigned int input,unsigned int count) | ||
93 | { | ||
94 | unsigned int i; | ||
95 | for (i = 0; i < count; i++) | ||
96 | { | ||
97 | bl_debug(input>>i & 1); | ||
98 | } | ||
90 | delay(SHORT_DELAY*6); | 99 | delay(SHORT_DELAY*6); |
91 | } | 100 | } |
92 | 101 | ||
102 | /* These functions are supposed to be static in lcd-m6sl.c, but | ||
103 | we use them here for testing */ | ||
104 | void init_lcd_spi(void); | ||
105 | unsigned int lcd_read_id(void); | ||
106 | |||
93 | void main(void) | 107 | void main(void) |
94 | { | 108 | { |
95 | //Set backlight pin to output and enable | 109 | //Set backlight pin to output and enable |
110 | unsigned int model; | ||
96 | int oldval = PCON0; | 111 | int oldval = PCON0; |
97 | PCON0 = ((oldval & ~(3 << 4)) | (1 << 4)); | 112 | PCON0 = ((oldval & ~(3 << 4)) | (1 << 4)); |
98 | PDAT0 |= (1 << 2); | 113 | PDAT0 |= (1 << 2); |
@@ -108,9 +123,18 @@ void main(void) | |||
108 | // Wait for play to be released | 123 | // Wait for play to be released |
109 | while((PDAT1 & (1 << 4))); | 124 | while((PDAT1 & (1 << 4))); |
110 | PDAT0 ^= (1 << 2); //Toggle backlight | 125 | PDAT0 ^= (1 << 2); //Toggle backlight |
126 | delay(LONG_DELAY); | ||
127 | |||
128 | init_lcd_spi(); | ||
129 | model=lcd_read_id(); | ||
130 | bl_debug_count((model&0xf000)>>12); | ||
131 | bl_debug_count((model&0xf00)>>8); | ||
132 | bl_debug_count((model&0xf0)>>4); | ||
133 | bl_debug_count(model&0xf); | ||
111 | 134 | ||
112 | /* Calibrate the lot */ | 135 | /* Calibrate the lot */ |
113 | qt1106_io(QT1106_MODE_FREE | QT1106_MOD_INF | QT1106_DI | QT1106_SLD_SLIDER | QT1106_CAL_WHEEL | QT1106_CAL_KEYS | QT1106_RES_4); | 136 | qt1106_io(QT1106_MODE_FREE | QT1106_MOD_INF | QT1106_DI \ |
137 | | QT1106_SLD_SLIDER | QT1106_CAL_WHEEL | QT1106_CAL_KEYS | QT1106_RES_4); | ||
114 | 138 | ||
115 | /* Set to maximum sensitivity */ | 139 | /* Set to maximum sensitivity */ |
116 | qt1106_io(QT1106_CT | (0x00 << 8) ); | 140 | qt1106_io(QT1106_CT | (0x00 << 8) ); |
@@ -119,8 +143,10 @@ void main(void) | |||
119 | { | 143 | { |
120 | qt1106_wait(); | 144 | qt1106_wait(); |
121 | 145 | ||
122 | int slider = qt1106_io(QT1106_MODE_FREE | QT1106_MOD_INF | QT1106_DI | QT1106_SLD_SLIDER | QT1106_RES_4); | 146 | int slider = qt1106_io(QT1106_MODE_FREE | QT1106_MOD_INF \ |
123 | bl_debug_int(((slider&0xff)) + 1); | 147 | | QT1106_DI | QT1106_SLD_SLIDER | QT1106_RES_4); |
148 | if(slider & 0x008000) | ||
149 | bl_debug_count(((slider&0xff)) + 1); | ||
124 | } | 150 | } |
125 | 151 | ||
126 | //power off | 152 | //power off |
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 | |||
45 | void 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 | |||
69 | static inline void delay(int duration) | ||
70 | { | ||
71 | volatile int i; | ||
72 | for(i=0;i<duration;i++); | ||
73 | } | ||
74 | |||
75 | unsigned 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 | |||
121 | void 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 | |||
127 | unsigned 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 | ||
34 | static int xoffset; /* needed for flip */ | 138 | static int xoffset; /* needed for flip */ |