diff options
-rw-r--r-- | u-boot/board/goldelico/gta04/backlight.c | 8 | ||||
-rw-r--r-- | u-boot/board/goldelico/gta04/commands.c | 2 | ||||
-rw-r--r-- | u-boot/board/goldelico/gta04/gps.c | 26 | ||||
-rw-r--r-- | u-boot/board/goldelico/gta04/status.c | 88 | ||||
-rw-r--r-- | u-boot/board/goldelico/gta04/systest.c | 1 |
5 files changed, 92 insertions, 33 deletions
diff --git a/u-boot/board/goldelico/gta04/backlight.c b/u-boot/board/goldelico/gta04/backlight.c index 271a254..f5ec6e9 100644 --- a/u-boot/board/goldelico/gta04/backlight.c +++ b/u-boot/board/goldelico/gta04/backlight.c @@ -65,13 +65,13 @@ #elif defined(CONFIG_GOLDELICO_EXPANDER_B2) -#define GPIO_BACKLIGHT 146 /* = GPT11_PWM (instead of UART2-TX) */ -#define GPT_BACKLIGHT OMAP34XX_GPT11 +#define GPIO_BACKLIGHT 145 /* = GPT11_PWM (instead of UART2-TX) */ +#define GPT_BACKLIGHT OMAP34XX_GPT10 #elif defined(CONFIG_GOLDELICO_EXPANDER_B4) -#define GPIO_BACKLIGHT 146 /* = GPT11_PWM (instead of UART2-TX) */ -#define GPT_BACKLIGHT OMAP34XX_GPT11 +#define GPIO_BACKLIGHT 145 /* = GPT10_PWM (instead of UART2-RTS) */ +#define GPT_BACKLIGHT OMAP34XX_GPT10 #endif diff --git a/u-boot/board/goldelico/gta04/commands.c b/u-boot/board/goldelico/gta04/commands.c index 107cb17..45520d2 100644 --- a/u-boot/board/goldelico/gta04/commands.c +++ b/u-boot/board/goldelico/gta04/commands.c @@ -333,7 +333,7 @@ static int do_status_init(int argc, char *const argv[]) static void print_buttons(int status) { - printf("AUX: %s Power: %s Antenna: %s Pen: %s", (status&0x01)?"on":"off", (status&0x08)?"on":"off", (status&0x02)?"EXT":"INT", (status&0x10)?"1":"0"); + printf("AUX: %s Power: %s Antenna: %s Pen: %s Key: %s", (status&0x01)?"on":"off", (status&0x08)?"on":"off", (status&0x02)?"EXT":"INT", (status&0x10)?"1":"0", (status&0x20)?"1":"0"); } static int do_status_check(int argc, char *const argv[]) diff --git a/u-boot/board/goldelico/gta04/gps.c b/u-boot/board/goldelico/gta04/gps.c index 7f74dc8..9383a88 100644 --- a/u-boot/board/goldelico/gta04/gps.c +++ b/u-boot/board/goldelico/gta04/gps.c @@ -36,11 +36,13 @@ #define GPIO_GPSEXT 144 // external GPS antenna plugged in #define GPIO_GPS_ON 145 // reset for GPS module +#define GPIO_GPS_PPS 114 // Pulse per Second interrupt #else /* Beagle Hybrid */ -#define GPIO_GPSEXT 138 // external GPS antenna plugged in +#define GPIO_GPSEXT 144 // external GPS antenna plugged in #define GPIO_GPS_ON 156 +#define GPIO_GPS_PPS 138 // Pulse per Second interrupt #endif @@ -69,6 +71,8 @@ int gps_init(void) omap_set_gpio_direction(GPIO_GPS_ON, 0); // output omap_request_gpio(GPIO_GPSEXT); omap_set_gpio_direction(GPIO_GPSEXT, 1); // input + omap_request_gpio(GPIO_GPS_PPS); + omap_set_gpio_direction(GPIO_GPS_PPS, 1); // input return 0; } @@ -87,6 +91,7 @@ void gps_off(void) } static int lastant=-1; +static int lastpps=-1; static long timer; #define TIMEOUT 2 // in seconds @@ -100,13 +105,20 @@ void gps_echo(void) while (1) { // echo in both directions int ant=omap_get_gpio_datain(GPIO_GPSEXT); + int pps=omap_get_gpio_datain(GPIO_GPS_PPS); if(ant != lastant) { // changed - if(ant) - printf("external antenna\n"); - else - printf("internal antenna\n"); - lastant=ant; + if(ant) + printf("external antenna\n"); + else + printf("internal antenna\n"); + lastant=ant; + } + if(pps != lastpps) + { // comes only with >= 5 satellites + if(lastpps >= 0) + printf("PPS\n"); + lastpps=pps; } if(NS16550_tstc((NS16550_t)CONFIG_SYS_NS16550_COM2)) { @@ -126,7 +138,7 @@ void gps_echo(void) printf("no data: on-off impulse\n"); omap_set_gpio_dataout(GPIO_GPS_ON, 1); udelay(5000); - omap_set_gpio_dataout(GPIO_GPS_ON, 1); + omap_set_gpio_dataout(GPIO_GPS_ON, 0); timer=0; } udelay(100); // 10 kHz @ 9 kbit/s diff --git a/u-boot/board/goldelico/gta04/status.c b/u-boot/board/goldelico/gta04/status.c index f91abb3..3c55df5 100644 --- a/u-boot/board/goldelico/gta04/status.c +++ b/u-boot/board/goldelico/gta04/status.c @@ -38,9 +38,11 @@ #define hasTCA6507 (1==1) #define GPIO_AUX 7 // AUX/User button +#define GPIO_AUX_ACTIVE 1 #define GPIO_POWER -1 // N/A on GTA04 (access through TPS65950) #define GPIO_GPSEXT 144 // external GPS antenna is plugged in #define GPIO_PENIRQ 160 // TSC must be set up to provide PENIRQ +#define GPIO_KEYIRQ 176 // FIXME: was 63, 10 on GTA04A2 and A3 // FIXME: other expander variants? @@ -48,26 +50,33 @@ static int hasTCA6507=0; +#define GPIO_AUX_ACTIVE 1 +#define GPIO_KEYIRQ -1 + #if defined(CONFIG_GOLDELICO_EXPANDER_B1) -#define GPIO_AUX 136 // AUX/User button +#define GPIO_AUX 136 // AUX/User button on expansion board #define GPIO_POWER 137 // POWER button -#define GPIO_GPSEXT 138 // external GPS antenna is plugged in +#define GPIO_GPSEXT 144 // external GPS antenna is plugged in #define GPIO_PENIRQ 157 // TSC must be set up to provide PENIRQ #elif defined(CONFIG_GOLDELICO_EXPANDER_B2) -#define GPIO_AUX 136 // AUX/User button +#define GPIO_AUX 136 // AUX/User button on expansion board #define GPIO_POWER 137 // POWER button -#define GPIO_GPSEXT 138 // external GPS antenna is plugged in +#define GPIO_GPSEXT 144 // external GPS antenna is plugged in #define GPIO_PENIRQ 157 // TSC must be set up to provide PENIRQ +#undef GPIO_KEYIRQ +#define GPIO_KEYIRQ 138 // TRF79x0 #elif defined(CONFIG_GOLDELICO_EXPANDER_B4) -#define GPIO_AUX 136 // AUX/User button -#define GPIO_POWER 137 // POWER button -#define GPIO_GPSEXT 138 // external GPS antenna is plugged in +#define GPIO_AUX 7 // AUX/User button sits on main board +#define GPIO_POWER -1 // POWER button +#define GPIO_GPSEXT 144 // external GPS antenna is plugged in #define GPIO_PENIRQ 157 // TSC must be set up to provide PENIRQ +#undef GPIO_KEYIRQ +#define GPIO_KEYIRQ 138 // PPS interrupt #endif @@ -102,6 +111,9 @@ extern int get_board_revision(void); static int isXM = 0; +// FIXME some BB Expanders have neither TCA6507 nor LEDs +// we could use the GPIO 149 and 150 LEDs + #define GPIO_LED_AUX_RED (isXM?88:70) // AUX #define GPIO_LED_AUX_GREEN (isXM?89:71) // AUX #define GPIO_LED_POWER_RED 78 // Power @@ -134,7 +146,28 @@ void status_set_status(int value) } int status_get_buttons(void) -{ // convert button state into led state +{ // convert button state into led state (for mirror) + int status=0; + if(GPIO_AUX >= 0) + status |= ((omap_get_gpio_datain(GPIO_AUX) == GPIO_AUX_ACTIVE) << 0); + if(GPIO_GPSEXT >= 0) + status |= ((omap_get_gpio_datain(GPIO_GPSEXT)) << 1); + if(GPIO_POWER >= 0) + status |= ((!omap_get_gpio_datain(GPIO_POWER)) << 3); + else + { + u8 val; + i2c_set_bus_num(TWL4030_I2C_BUS); // read I2C1 + twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER, &val, TWL4030_PM_MASTER_STS_HW_CONDITIONS); // read state of power button (bit 0) from TPS65950 + status |= (val&0x01) != 0; + } + if(GPIO_PENIRQ >= 0) + status |= ((!omap_get_gpio_datain(GPIO_PENIRQ)) << 4); + if(GPIO_KEYIRQ >= 0) + status |= ((omap_get_gpio_datain(GPIO_KEYIRQ)) << 5); + return status; + +#if OLD #if defined(CONFIG_OMAP3_GTA04) u8 val; i2c_set_bus_num(TWL4030_I2C_BUS); // read I2C1 @@ -147,21 +180,22 @@ int status_get_buttons(void) return ((omap_get_gpio_datain(GPIO_AUX)) << 0) | ((0) << 1) | - ((!omap_get_gpio_datain(GPIO_POWER)) << 3) | + ((GPIO_POWER>=0?(!omap_get_gpio_datain(GPIO_POWER)):0) << 3) | ((omap_get_gpio_datain(GPIO_PENIRQ)) << 4); #else return ((!omap_get_gpio_datain(GPIO_AUX)) << 0) | ((omap_get_gpio_datain(GPIO_GPSEXT)) << 1) | - ((!omap_get_gpio_datain(GPIO_POWER)) << 3) | + ((GPIO_POWER>=0?(!omap_get_gpio_datain(GPIO_POWER)):0) << 3) | ((omap_get_gpio_datain(GPIO_PENIRQ)) << 4); #endif +#endif } int status_init(void) { isXM = (get_board_revision() == REVISION_XM); -#if !defined(CONFIG_OMAP3_GTA04) +#if !defined(CONFIG_OMAP3_GTA04) // we assume that a GTA04 always has a TCA6507 if(i2c_set_bus_num(TCA6507_BUS)) { printf ("could not select I2C2\n"); @@ -194,15 +228,23 @@ int status_init(void) omap_request_gpio(GPIO_LED_POWER_RED); omap_request_gpio(GPIO_LED_VIBRA); omap_request_gpio(GPIO_LED_UNUSED); - omap_request_gpio(GPIO_POWER); + if(GPIO_POWER >= 0) + omap_request_gpio(GPIO_POWER); } else { // initialize I2C controller } - omap_request_gpio(GPIO_AUX); - omap_request_gpio(GPIO_GPSEXT); - omap_request_gpio(GPIO_PENIRQ); + if(GPIO_AUX >= 0) + omap_request_gpio(GPIO_AUX); + if(GPIO_POWER >= 0) + omap_request_gpio(GPIO_POWER); + if(GPIO_GPSEXT >= 0) + omap_request_gpio(GPIO_GPSEXT); + if(GPIO_PENIRQ >= 0) + omap_request_gpio(GPIO_PENIRQ); + if(GPIO_KEYIRQ >= 0) + omap_request_gpio(GPIO_KEYIRQ); if(!hasTCA6507) { omap_set_gpio_direction(GPIO_LED_AUX_GREEN, 0); // output @@ -211,14 +253,18 @@ int status_init(void) omap_set_gpio_direction(GPIO_LED_POWER_RED, 0); // output omap_set_gpio_direction(GPIO_LED_VIBRA, 0); // output omap_set_gpio_direction(GPIO_LED_UNUSED, 0); // output - omap_set_gpio_direction(GPIO_POWER, 1); // input } - omap_set_gpio_direction(GPIO_AUX, 1); // input -#ifndef CONFIG_OMAP3_GTA04 - omap_set_gpio_direction(GPIO_POWER, 1); // input -#endif - omap_set_gpio_direction(GPIO_GPSEXT, 1); // input + if(GPIO_AUX >= 0) + omap_set_gpio_direction(GPIO_AUX, 1); // input + if(GPIO_POWER >= 0) + omap_set_gpio_direction(GPIO_POWER, 1); // input + if(GPIO_GPSEXT >= 0) + omap_set_gpio_direction(GPIO_GPSEXT, 1); // input + if(GPIO_PENIRQ >= 0) + omap_set_gpio_direction(GPIO_PENIRQ, 1); // input + if(GPIO_KEYIRQ >= 0) + omap_set_gpio_direction(GPIO_KEYIRQ, 1); // input // when sould we do omap_free_gpio(GPIO_LED_AUX_GREEN); ? printf("did init LED driver for %s\n", hasTCA6507?"TCA6507":"GPIOs"); diff --git a/u-boot/board/goldelico/gta04/systest.c b/u-boot/board/goldelico/gta04/systest.c index dbd913d..f96b79e 100644 --- a/u-boot/board/goldelico/gta04/systest.c +++ b/u-boot/board/goldelico/gta04/systest.c @@ -66,6 +66,7 @@ int bt_hci(int msg) MUX_VAL(CP(UART1_CTS), (IEN | PTU | EN | M4)) /*UART1_CTS -> Bluetooth HCI */ \ MUX_VAL(CP(UART1_RX), (IEN | PTU | EN | M4)) /*UART1_RX -> Bluetooth HCI */ + // FIXME: this is not 100% correct for BeagleBoard MUX_VAL(CP(UART2_CTS), (IEN | PTU | DIS | M4)) /*GPIO_144 - ext Ant */\ MUX_VAL(CP(UART2_RTS), (IEN | PTD | DIS | M4)) /*GPIO_145 - GPS ON(0)/OFF(1)*/\ MUX_VAL(CP(UART2_TX), (IEN | PTU | DIS | M4)) /*GPIO_146 - GPS_TX */\ |