diff options
author | Frank Gevaerts <frank@gevaerts.be> | 2008-09-16 16:51:25 +0000 |
---|---|---|
committer | Frank Gevaerts <frank@gevaerts.be> | 2008-09-16 16:51:25 +0000 |
commit | c0e898ae2983d36f6f58f26b25f543c69d281457 (patch) | |
tree | 50e13b240ed62d092e6a737e1accda045f7bfa5c /firmware/target/arm/s5l8700 | |
parent | 95bc9fd59682ea499adab4bf85cece255f3ba2db (diff) |
Now reads the LCD controller ID succesfully and flashes it using the backlight
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18531 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/s5l8700')
-rw-r--r-- | firmware/target/arm/s5l8700/meizu-m6sl/lcd-m6sl.c | 104 |
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 @@ /*** 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 */ |