summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootloader/meizu_m6sl.c34
-rw-r--r--firmware/target/arm/s5l8700/meizu-m6sl/lcd-m6sl.c104
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)
}
}
-void bl_debug_int(unsigned int input)
+void bl_debug_count(unsigned int input)
{
unsigned int i;
+ delay(SHORT_DELAY*3);
for (i = 0; i < input; i++)
{
PDAT0 ^= (1 << 2); //Toggle backlight
@@ -87,12 +88,26 @@ void bl_debug_int(unsigned int input)
PDAT0 ^= (1 << 2); //Toggle backlight
delay(2*SHORT_DELAY);
}
+}
+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);
}
+/* These functions are supposed to be static in lcd-m6sl.c, but
+ we use them here for testing */
+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,9 +123,18 @@ void main(void)
// 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&0xf000)>>12);
+ bl_debug_count((model&0xf00)>>8);
+ bl_debug_count((model&0xf0)>>4);
+ bl_debug_count(model&0xf);
/* 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);
+ 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) );
@@ -119,8 +143,10 @@ void main(void)
{
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);
+ int slider = qt1106_io(QT1106_MODE_FREE | QT1106_MOD_INF \
+ | QT1106_DI | QT1106_SLD_SLIDER | QT1106_RES_4);
+ if(slider & 0x008000)
+ bl_debug_count(((slider&0xff)) + 1);
}
//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 @@
/*** 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;
+ unsigned 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 <<= 1;
+ input |= MISO;
+ }
+
+ //delay(20); // >> 6.7 us
+ }
+
+ SETSS();
+
+ return (input);
+}
+
+
+void spi_set_reg(unsigned char reg,unsigned short value)
+{
+ lcd_spi_io(0x700000|reg,24,0); // possibly 0x74
+ lcd_spi_io(0x720000|value,24,0); // possibly 0x77
+}
+
+unsigned int lcd_read_id(void)
+{
+ unsigned int device_code;
+ lcd_spi_io(0x700000,24,0); // possibly 0x74
+
+ device_code=lcd_spi_io(0x7300,16,24); // possibly 0x77
+ return device_code;
+}
+
/** globals **/
static int xoffset; /* needed for flip */