From: Stefan E. <se...@us...> - 2001-10-15 15:04:28
|
Update of /cvsroot/blob/blob/src/diag In directory usw-pr-cvs1:/tmp/cvs-serv12899 Modified Files: system3.c Log Message: - init sa1111 for pwm module (brightness & contrast) - lcd_power_up() bugfixes Index: system3.c =================================================================== RCS file: /cvsroot/blob/blob/src/diag/system3.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- system3.c 2001/10/09 17:54:08 1.2 +++ system3.c 2001/10/15 15:04:25 1.3 @@ -35,7 +35,9 @@ #include <blob/errno.h> #include <blob/util.h> #include <blob/command.h> +#include <blob/init.h> #include <blob/serial.h> +#include <blob/time.h> #include <blob/sa1100.h> #include <blob/sa1111.h> @@ -48,6 +50,14 @@ #define SET(reg,bit) ((reg) |= (1<<(bit))) #define CLR(reg,bit) ((reg) &= ~(1<<(bit))) +#define mem_b(adr) ( ((volatile unsigned char*)0)[adr] ) +#define mem_w(adr) ( ((volatile unsigned short int*)0)[(adr)/2] ) +#define mem_dw(adr) ( ((volatile unsigned long*)(0)) [(adr)/4] ) + +/* Optimization barrier */ +/* The "volatile" is due to gcc bugs */ +#define barrier() __asm__ __volatile__("": : :"memory") + #define CPLD_BASE (0x10000000) #define CPLD_ID (CPLD_BASE + 0x00) #define CPLD_IRQ (CPLD_BASE + 0x24) @@ -66,58 +76,100 @@ /********************************************************************** * prototypes */ +void sa1111_init(); /*********************************************************************/ /*********************************************************************/ /*********************************************************************/ #if defined(CONFIG_LCD_SUPPORT) + +__initlist(sa1111_init, INIT_LEVEL_INITIAL_HARDWARE); + +void sa1111_init() +{ + /* switch on clock for sa1111 */ + GAFR |= GPIO_32_768kHz; + GPDR |= GPIO_32_768kHz; + TUCR = TUCR_3_6864MHz; + + /* Now, set up the PLL and RCLK in the SA-1111: */ + SKCR = SKCR_PLL_BYPASS | SKCR_RDYEN | SKCR_OE_EN; + msleep(100); + SKCR = SKCR_PLL_BYPASS | SKCR_RCLKEN | SKCR_RDYEN | SKCR_OE_EN; + + SerialOutputString( "SA1111 ID: " ); + SerialOutputHex( SKID ); + SerialOutputString( "\n" ); + + /* + * SA-1111 Register Access Bus should now be available. Clocks for + * any other SA-1111 functional blocks must be enabled separately + * using the SKPCR. + */ + SKPCR |= SKPCR_DCLKEN | SKPCR_PWMCLKEN; + + /* + * If the system is going to use the SA-1111 DMA engines, set up + * the memory bus request/grant pins. Also configure the shared + * memory controller on the SA-1111 (SA-1111 Developer's Manual, + * section 3.2.3) and power up the DMA bus clock: + */ + GAFR |= (GPIO_MBGNT | GPIO_MBREQ); + GPDR |= GPIO_MBGNT; + GPDR &= ~GPIO_MBREQ; + TUCR |= TUCR_MR; + + SMCR = (SMCR_DTIM | SMCR_MBGE | + FInsrt(FExtr(MDCNFG, MDCNFG_SA1110_DRAC0), SMCR_DRAC) | + ((FExtr(MDCNFG, MDCNFG_SA1110_TDL0)==3) ? SMCR_CLAT : 0)); +} + /********************************************************************** * Overwrite LCD functions special for this platform */ int lcd_power_up( void ) { - SerialOutputString("_system3_" ); SET( MEM( CPLD_0 ), 7 ); + PB_DDR = 0xFFFFFFFF; SKPEN0 = 1; - SKPWM0 = 95; // und halbe Kraft SKPEN1 = 1; - SKPWM1 = 240; // und auf null + + lcd_contrast( 0x95 ); + lcd_brightness( 240 ); + lcd_backlight_on(); return 0; } int lcd_power_down( void ) { - SerialOutputString("_system3_" ); + SKPEN0 = 0; + SKPEN0 = 0; CLR( MEM( CPLD_0 ), 7 ); return 0; } int lcd_backlight_on( void ) { - SerialOutputString("_system3_" ); SET( MEM( CPLD_0 ), 2 ); return 0; } int lcd_backlight_off( void ) { - SerialOutputString("_system3_" ); CLR( MEM( CPLD_0 ), 2 ); return 0; } int lcd_contrast( int value ) { - SerialOutputString("_system3_" ); SKPWM0 = value; return 0; } int lcd_brightness( int value ) { - SerialOutputString("_system3_" ); SKPWM1 = value; return 0; } @@ -128,3 +180,19 @@ /********************************************************************** * static functions */ + +static int cpldtest( int argc, char *argv[] ) +{ + + int i = 100000; + unsigned char x = 0; + +label: + x = (*((unsigned char *)0x10000090)); + barrier(); + (*((unsigned char *)0x10000090)) = x; + barrier(); + goto label; +} +static char cpldhelp[] = "does not return!\n"; +__commandlist(cpldtest, "cpldtest", cpldhelp); |