Index: apps/debug_menu.c =================================================================== --- apps/debug_menu.c (revision 16245) +++ apps/debug_menu.c (working copy) @@ -990,6 +990,8 @@ #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \ (CONFIG_KEYPAD == SANSA_C200_PAD) # define DEBUG_CANCEL BUTTON_LEFT +#elif CONFIG_KEYPAD == GIGABEAT_S_PAD +# define DEBUG_CANCEL BUTTON_BACK #endif /* key definitions */ /* Test code!!! */ @@ -1262,6 +1264,57 @@ if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) return false; } +#elif CONFIG_CPU == IMX31L + char buf[50]; + int line; + unsigned long spibuf; + + lcd_setmargins(0, 0); + lcd_clear_display(); + lcd_setfont(FONT_SYSFIXED); + + line = 0; + snprintf(buf, sizeof(buf), "[Ports and Registers]"); lcd_puts(0, line++, buf); + while(1) + { + line = 1; + + snprintf(buf, sizeof(buf), "GPIO1_DR: %08x GPIO1_GDIR: %08x", GPIO1_DR, GPIO1_GDIR); lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), "GPIO2_DR: %08x GPIO2_GDIR: %08x", GPIO2_DR, GPIO2_GDIR); lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), "GPIO3_DR: %08x GPIO3_GDIR: %08x", GPIO3_DR, GPIO3_GDIR); lcd_puts(0, line++, buf); + line++; + snprintf(buf, sizeof(buf), "CLKCTL_CGR0: %08x", CLKCTL_CGR0); lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), "CLKCTL_CGR1: %08x", CLKCTL_CGR1); lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), "CLKCTL_CGR2: %08x", CLKCTL_CGR2); lcd_puts(0, line++, buf); + line++; + lcd_puts(0,line++,"PMU Registers"); + line++; + spi_read(0, &spibuf); + snprintf(buf, sizeof(buf), "Int. Status0: %08x", spibuf); lcd_puts(0,line++,buf); + spi_read(2, &spibuf); + snprintf(buf, sizeof(buf), "Int. Sense0: %08x", spibuf); lcd_puts(0,line++,buf); + spi_read(3, &spibuf); + snprintf(buf, sizeof(buf), "Int. Status1: %08x", spibuf); lcd_puts(0,line++,buf); + spi_read(5, &spibuf); + snprintf(buf, sizeof(buf), "Int. Sense1: %08x", spibuf); lcd_puts(0,line++,buf); + spi_read(20, &spibuf); + snprintf(buf, sizeof(buf), "RTC Time: %08x", spibuf); lcd_puts(0,line++,buf); + spi_read(43, &spibuf); + snprintf(buf, sizeof(buf), "ADC0: %08x", spibuf); lcd_puts(0,line++,buf); + spi_read(44, &spibuf); + snprintf(buf, sizeof(buf), "ADC1: %08x", spibuf); lcd_puts(0,line++,buf); + spi_read(45, &spibuf); + snprintf(buf, sizeof(buf), "ADC2: %08x", spibuf); lcd_puts(0,line++,buf); + spi_read(46, &spibuf); + snprintf(buf, sizeof(buf), "ADC3: %08x", spibuf); lcd_puts(0,line++,buf); + spi_read(47, &spibuf); + snprintf(buf, sizeof(buf), "ADC4: %08x", spibuf); lcd_puts(0,line++,buf); + line++; + + lcd_update(); + if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) + return false; + } #else return __dbg_ports(); #endif /* CPU */ @@ -2266,7 +2319,8 @@ (defined(CPU_PP) && !(defined(SANSA_E200) || defined(SANSA_C200))) { "Dump ROM contents", dbg_save_roms }, #endif -#if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) || CONFIG_CPU == S3C2440 +#if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) || \ + CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L { "View I/O ports", dbg_ports }, #endif #if defined(HAVE_TSC2100) && !defined(SIMULATOR) Index: firmware/export/config-gigabeat-s.h =================================================================== --- firmware/export/config-gigabeat-s.h (revision 16245) +++ firmware/export/config-gigabeat-s.h (working copy) @@ -123,6 +123,8 @@ #define HAVE_SERIAL +#define HAVE_HEADPHONE_DETECTION + /*Remove Comments from UART_INT to enable the UART interrupts,*/ /*otherwise iterrupts will be disabled. For now we will test */ /*UART state by polling the registers, and if necessary update this */ Index: firmware/target/arm/imx31/gigabeat-s/button-imx31.c =================================================================== --- firmware/target/arm/imx31/gigabeat-s/button-imx31.c (revision 16249) +++ firmware/target/arm/imx31/gigabeat-s/button-imx31.c (working copy) @@ -25,6 +25,7 @@ #include "system.h" #include "backlight-target.h" #include "avic-imx31.h" +#include "spi-imx31.h" /* Most code in here is taken from the Linux BSP provided by Freescale * Copyright 2004-2006 Freescale Semiconductor, Inc. All Rights Reserved. */ @@ -161,3 +162,10 @@ /* If hold, ignore any pressed button */ return hold_button ? BUTTON_NONE : int_btn; } + +bool headphones_inserted(void) +{ + unsigned long temp; + spi_read(5, &temp); + return (temp & (1<<4)); +} Index: firmware/target/arm/imx31/gigabeat-s/spi-imx31.c =================================================================== --- firmware/target/arm/imx31/gigabeat-s/spi-imx31.c (revision 16249) +++ firmware/target/arm/imx31/gigabeat-s/spi-imx31.c (working copy) @@ -26,16 +26,17 @@ * CSPI3 cs1, but we have no idea how to communicate to it */ void spi_init(void) { - CSPI_CONREG2 |= (2 << 20); // Burst will be triggered at SPI_RDY low - CSPI_CONREG2 |= (2 << 16); // Clock = IPG_CLK/16 - we want about 20mhz - CSPI_CONREG2 |= (31 << 8); // All 32 bits are to be transferred - CSPI_CONREG2 |= (1 << 3); // Start burst on TXFIFO write. - CSPI_CONREG2 |= (1 << 1); // Master mode. - CSPI_CONREG2 |= 1; // Enable CSPI2; + int reg = 0; + reg |= (2 << 20); // Burst will be triggered at SPI_RDY low + reg |= (3 << 16); // Clock = IPG_CLK/16 - we want about 20mhz + reg |= (31 << 8); // All 32 bits are to be transferred + //reg |= (1 << 3); // Start burst on TXFIFO write. + CSPI_CONREG2 = (reg | (1 << 1)); // Master mode. + CSPI_CONREG2 |= 1; // Enable CSPI2; } static int spi_transfer(int address, long data, long* buffer, bool read) { - return -1; /* Disable for now - hangs - and we'll use interrupts */ + //return -1; /* Disable for now - hangs - and we'll use interrupts */ unsigned long packet = 0; if(!read) { @@ -54,6 +55,7 @@ /* Send the packet */ CSPI_TXDATA2 = packet; + CSPI_CONREG2 |= (1 << 2); /* Poll the XCH bit to wait for the end of the transfer, with * a one second timeout */ Index: firmware/target/arm/imx31/gigabeat-s/power-imx31.c =================================================================== --- firmware/target/arm/imx31/gigabeat-s/power-imx31.c (revision 16245) +++ firmware/target/arm/imx31/gigabeat-s/power-imx31.c (working copy) @@ -54,6 +75,7 @@ void power_off(void) { + spi_send(13, (1<<3)); } #else /* SIMULATOR */