FreeCalypso > hg > freecalypso-sw
changeset 76:07b686248ab7
pirexplore: finally got the backlight to turn on
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Thu, 01 Aug 2013 00:26:29 +0000 |
parents | c9768f5fb329 |
children | fcbe1332b197 |
files | target-utils/libcommon/Makefile target-utils/libcommon/osmodelay.S target-utils/pirexplore/cmdtab.c target-utils/pirexplore/lcd.c target-utils/pirexplore/main.c |
diffstat | 5 files changed, 72 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/target-utils/libcommon/Makefile Sun Jul 28 01:30:22 2013 +0000 +++ b/target-utils/libcommon/Makefile Thu Aug 01 00:26:29 2013 +0000 @@ -6,7 +6,7 @@ OBJS= cmdentry.o dispatch.o hexarg.o parseargs.o serio.o serflush.o uartsel.o\ cmd_baud_switch.o cmd_dieid.o cmd_jump.o cmd_r8.o cmd_r16.o cmd_r32.o \ - cmd_w8.o cmd_w16.o cmd_w32.o + cmd_w8.o cmd_w16.o cmd_w32.o osmodelay.o all: libcommon.a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/target-utils/libcommon/osmodelay.S Thu Aug 01 00:26:29 2013 +0000 @@ -0,0 +1,30 @@ +/* + * This assembly module provides a replica of OsmocomBB's bogo-millisecond + * delay_ms() function. It is literally a copy of what OsmocomBB's delay_ms() + * compiles to with their gcc version and their optimization settings, as seen + * by doing arm-elf-objdump on their lib/delay.o. + * + * This hack is intended for those cases where we have to copy OsmocomBB's + * black magic voodoo operations with no ability to understand what is actually + * needed, such as SPCA552E initialization on the Pirelli DP-L10. + */ + + .text + .code 32 + .globl osmo_delay_ms +osmo_delay_ms: + mov r3, #0 + sub sp, sp, #4 + str r3, [sp] + ldr r3, =1300 + mul r3, r0, r3 + b 2f +1: ldr r2, [sp] + ldr r2, [sp] + add r2, r2, #1 + str r2, [sp] +2: ldr r2, [sp] + cmp r2, r3 + bcc 1b + add sp, sp, #4 + bx lr
--- a/target-utils/pirexplore/cmdtab.c Sun Jul 28 01:30:22 2013 +0000 +++ b/target-utils/pirexplore/cmdtab.c Thu Aug 01 00:26:29 2013 +0000 @@ -9,6 +9,7 @@ extern void cmd_rtc(); extern void cmd_rtccomp(); extern void cmd_spca(); +extern void cmd_spcainit(); extern void cmd_w8(); extern void cmd_w16(); extern void cmd_w32(); @@ -23,6 +24,7 @@ {"rtc", cmd_rtc}, {"rtccomp", cmd_rtccomp}, {"spca", cmd_spca}, + {"spcainit", cmd_spcainit}, {"w8", cmd_w8}, {"w16", cmd_w16}, {"w32", cmd_w32},
--- a/target-utils/pirexplore/lcd.c Sun Jul 28 01:30:22 2013 +0000 +++ b/target-utils/pirexplore/lcd.c Thu Aug 01 00:26:29 2013 +0000 @@ -1,6 +1,17 @@ #include <sys/types.h> #include "types.h" +#define GPIO_OUT_REG (*(volatile u16 *)0xFFFE4802) +#define nCS4_ADDR0 (*(volatile u16 *)0x02800000) +#define nCS4_ADDR2 (*(volatile u16 *)0x02800002) + +fb_spca_write(addr, data) +{ + GPIO_OUT_REG &= 0xFF7F; + nCS4_ADDR0 = addr; + nCS4_ADDR2 = data; +} + void cmd_spca(argbulk) char *argbulk; @@ -18,6 +29,31 @@ printf("ERROR: arg2 must be a valid 16-bit hex value\n"); return; } - *(volatile u16 *)0x02800000 = addr; - *(volatile u16 *)0x02800002 = data; + fb_spca_write(addr, data); } + +void +cmd_spcainit() +{ + /* + * Apparently we have to give it a reset pulse, then immediately + * do the black magic register write sequence. + */ + GPIO_OUT_REG = 0x0000; + GPIO_OUT_REG = 0x0012; + /* non-understandable voodoo copied from OsmocomBB */ + fb_spca_write(0x7e, 0x00); /* internal register access */ + osmo_delay_ms(10); + fb_spca_write(0x7a, 0x00); /* keep CPU in reset state */ + osmo_delay_ms(10); + fb_spca_write(0x7f, 0x00); /* select main page */ + osmo_delay_ms(5); + fb_spca_write(0x72, 0x07); /* don't reshape timing, 16 bit mode */ + fb_spca_write(0x14, 0x03); + fb_spca_write(0x7f, 0x00); /* select main page */ + osmo_delay_ms(5); + fb_spca_write(0x06, 0xff); + fb_spca_write(0x7f, 0x09); + fb_spca_write(0x19, 0x08); /* backlight: 0x08 is on, 0x0c is off */ + fb_spca_write(0x23, 0x18); +}
--- a/target-utils/pirexplore/main.c Sun Jul 28 01:30:22 2013 +0000 +++ b/target-utils/pirexplore/main.c Thu Aug 01 00:26:29 2013 +0000 @@ -25,11 +25,10 @@ * Other register settings replicating what OsmocomBB does * in board/pirelli_dpl10/init.c */ - *(volatile u16 *)0xfffef008 = 0x7090; + *(volatile u16 *)0xfffef008 = 0x7080; *(volatile u16 *)0xfffef00a = 0x021F; *(volatile u16 *)0xfffe4804 = 0xFF6D; *(volatile u16 *)0xfffe4802 = 0x0000; - *(volatile u16 *)0xfffe4802 = 0x0012; /* nCS4 setup for SPCA552E */ *(volatile u16 *)0xfffffb0a = 0x00A7; for (;;) {