rendered paste bodyIndex: bootloader/meizu_m6sl.c
===================================================================
--- bootloader/meizu_m6sl.c (revision 18520)
+++ bootloader/meizu_m6sl.c (working copy)
@@ -77,22 +77,36 @@
}
}
-void bl_debug_int(unsigned int input)
+void bl_debug_count(unsigned int input)
{
unsigned int i;
- for (i = 0; i < input; i++)
+ delay(SHORT_DELAY*6);
+ for (i = 0; i <= input; i++)
{
PDAT0 ^= (1 << 2); //Toggle backlight
delay(SHORT_DELAY);
PDAT0 ^= (1 << 2); //Toggle backlight
- delay(2*SHORT_DELAY);
+ delay(4*SHORT_DELAY);
}
delay(SHORT_DELAY*6);
}
+void bl_debug_int(unsigned int input,unsigned int count)
+{
+ unsigned int i;
+ for (i = 0; i < count; i++)
+ {
+ bl_debug(input>>i & 1);
+ }
+ delay(SHORT_DELAY*6);
+}
+void init_lcd_spi(void);
+unsigned int lcd_read_id(void);
+
void main(void)
{
//Set backlight pin to output and enable
+ unsigned int model;
int oldval = PCON0;
PCON0 = ((oldval & ~(3 << 4)) | (1 << 4));
PDAT0 |= (1 << 2);
@@ -108,20 +122,34 @@
// Wait for play to be released
while((PDAT1 & (1 << 4)));
PDAT0 ^= (1 << 2); //Toggle backlight
+ delay(LONG_DELAY);
+ init_lcd_spi();
+ model=lcd_read_id();
+ bl_debug_count(model&0xf);
+ bl_debug_count((model&0xf0)>>4);
+ bl_debug_count((model&0xf00)>>8);
+ bl_debug_count((model&0xf000)>>12);
+ bl_debug_count((model&0xf0000)>>16);
+ bl_debug_count((model&0xf00000)>>20);
+ bl_debug_count((model&0xf000000)>>24);
+ bl_debug_count((model&0xf0000000)>>28);
+
/* Calibrate the lot */
qt1106_io(QT1106_MODE_FREE | QT1106_MOD_INF | QT1106_DI | QT1106_SLD_SLIDER | QT1106_CAL_WHEEL | QT1106_CAL_KEYS | QT1106_RES_4);
/* Set to maximum sensitivity */
qt1106_io(QT1106_CT | (0x00 << 8) );
+ /*
while(true)
{
qt1106_wait();
int slider = qt1106_io(QT1106_MODE_FREE | QT1106_MOD_INF | QT1106_DI | QT1106_SLD_SLIDER | QT1106_RES_4);
- bl_debug_int(((slider&0xff)) + 1);
+ bl_debug_count(((slider&0xff)) + 1);
}
+ */
//power off
PDAT1&=~(1<<3);
Index: firmware/target/arm/s5l8700/meizu-m6sl/lcd-m6sl.c
===================================================================
--- firmware/target/arm/s5l8700/meizu-m6sl/lcd-m6sl.c (revision 18520)
+++ firmware/target/arm/s5l8700/meizu-m6sl/lcd-m6sl.c (working copy)
@@ -29,6 +29,109 @@
/*** definitions ***/
+#define SPIDELAY(_x) void(_x);
+
+#define SETMOSI() (PDAT4 |= (1 << 3))
+#define CLRMOSI() (PDAT4 &= ~(1 << 3))
+
+#define MISO ((PDAT1 >> 1) & 1)
+
+#define SETCLK() (PDAT4 |= (1 << 2))
+#define CLRCLK() (PDAT4 &= ~(1 << 2))
+
+#define SETSS() (PDAT7 |= (1 << 1))
+#define CLRSS() (PDAT7 &= ~(1 << 1))
+
+void init_lcd_spi(void)
+{
+ int oldval;
+
+ oldval = PCON1;
+ //Set P1.1 to input
+ PCON1 = ((oldval & ~(0xf << 4)));
+
+ oldval = PCON4;
+ //Set P4.2 and 4.3 to output
+ PCON4 = ((oldval & ~(0xf << 8 | 0xf << 12)) | (1 << 8 | 1 << 12));
+
+ oldval = PCON4;
+ //Set P4.2 and 4.3 to output
+ PCON4 = ((oldval & ~(0xf << 8 | 0xf << 12)) | (1 << 8 | 1 << 12));
+
+ oldval = PCON7;
+ //Set P7.0 and 7.1 to output
+ PCON7 = ((oldval & ~(0xf << 0 | 0xf << 4)) | (1 << 0 | 1 << 4));
+
+ SETSS();
+ SETCLK();
+}
+
+static inline void delay(int duration)
+{
+ volatile int i;
+ for(i=0;i<duration;i++);
+}
+
+unsigned int lcd_spi_io(unsigned int output,unsigned int bits,unsigned int inskip)
+{
+ unsigned int input = 0;
+ int i;
+
+ //delay(10); // < 470 us
+
+ CLRSS();
+ //delay(13); // > 22 us
+
+ for (i = 0; i < bits+inskip; i++) {
+
+ CLRCLK();
+
+ if(i<bits)
+ {
+ if (output & (1 << (bits-1)))
+ SETMOSI();
+ else
+ CLRMOSI();
+ output <<= 1;
+ }
+ else
+ {
+ CLRMOSI();
+ }
+
+ //delay(20); // >> 6.7 us
+
+ SETCLK();
+
+ if(i>=inskip)
+ {
+ input |= MISO;
+ input <<= 1;
+ }
+
+ //delay(20); // >> 6.7 us
+ }
+
+ SETSS();
+
+ return (input);
+}
+
+
+unsigned int lcd_read_id(void)
+{
+ /*
+ one way to read it is that you send a start byte with RS and RW both 0, followed by a 16 bit register address (0
+ in out case). After that a new start byte, with RS and RW both one, and the following two bytes IN contain the data we
+ want
+ */
+ unsigned int device_code;
+ lcd_spi_io(0x700022,24,0); // possibly 0x74
+
+ device_code=lcd_spi_io(0x7300,16,32); // possibly 0x77
+ return device_code;
+}
+
/** globals **/
static int xoffset; /* needed for flip */