qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] hw/misc/pca9552: Trace LED On/Off events


From: Cédric Le Goater
Subject: Re: [PATCH v2] hw/misc/pca9552: Trace LED On/Off events
Date: Wed, 17 Jun 2020 09:39:51 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0

On 6/17/20 8:47 AM, Philippe Mathieu-Daudé wrote:
> Example booting obmc-phosphor-image:
> 
>   $ qemu-system-arm -M witherspoon-bmc -trace pca\*
>   26033@1592376001.873828:pca9552_led_state 0x5594a9f57560 LEDs [........ 
> ........]
>   26033@1592376001.874169:pca9552_led_state 0x5594a9f57560 LEDs [........ 
> ........]
>   26033@1592376001.874348:pca9552_led_state 0x5594a9f57560 LEDs [........ 
> ........]
>   26033@1592376001.874514:pca9552_led_state 0x5594a9f57560 LEDs [........ 
> ........]
>   26033@1592376001.879601:pca9552_led_state 0x5594a9f57560 LEDs [........ 
> .......*]
>   26033@1592376001.880507:pca9552_led_state 0x5594a9f57560 LEDs [........ 
> ......**]
>   26033@1592376001.880885:pca9552_led_state 0x5594a9f57560 LEDs [........ 
> .....***]
>   26033@1592376001.881228:pca9552_led_state 0x5594a9f57560 LEDs [........ 
> ....****]
>   26033@1592376001.881601:pca9552_led_state 0x5594a9f57560 LEDs [..*..... 
> ....****]
>   26033@1592376001.881952:pca9552_led_state 0x5594a9f57560 LEDs [.**..... 
> ....****]
>   26033@1592376001.882299:pca9552_led_state 0x5594a9f57560 LEDs [***..... 
> ....****]
>   26033@1592376065.090910:pca9552_led_state 0x5594a9f57560 LEDs [*.*..... 
> ....****]
>   26033@1592376065.600649:pca9552_led_state 0x5594a9f57560 LEDs [***..... 
> ....****]
>   26033@1592376066.110565:pca9552_led_state 0x5594a9f57560 LEDs [*.*..... 
> ....****]
>   26033@1592376066.620390:pca9552_led_state 0x5594a9f57560 LEDs [***..... 
> ....****]

It looks better but the ordering is wrong.

> Suggested-by: Cédric Le Goater <clg@kaod.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/misc/pca9552.c    | 18 ++++++++++++++++++
>  hw/misc/trace-events |  3 +++
>  2 files changed, 21 insertions(+)
> 
> diff --git a/hw/misc/pca9552.c b/hw/misc/pca9552.c
> index cac729e35a..693f6c3b24 100644
> --- a/hw/misc/pca9552.c
> +++ b/hw/misc/pca9552.c
> @@ -17,6 +17,7 @@
>  #include "migration/vmstate.h"
>  #include "qapi/error.h"
>  #include "qapi/visitor.h"
> +#include "trace.h"
>  
>  #define PCA9552_LED_ON   0x0
>  #define PCA9552_LED_OFF  0x1
> @@ -95,6 +96,23 @@ static void pca9552_write(PCA9552State *s, uint8_t reg, 
> uint8_t data)
>      case PCA9552_LS3:
>          s->regs[reg] = data;
>          pca9552_update_pin_input(s);
> +        if (trace_event_get_state_backends(TRACE_PCA9552_LED_STATE)) {
> +            char buf[2][9];
> +
> +            for (int i = 0; i < 2; i++) {
> +                uint8_t val = s->regs[PCA9552_INPUT0 + i];
> +                sprintf(buf[i], "%c%c%c%c%c%c%c%c",
> +                        val & 0x80 ? '*' : '.',
> +                        val & 0x40 ? '*' : '.',
> +                        val & 0x20 ? '*' : '.',
> +                        val & 0x10 ? '*' : '.',
> +                        val & 0x08 ? '*' : '.',
> +                        val & 0x04 ? '*' : '.',
> +                        val & 0x02 ? '*' : '.',
> +                        val & 0x01 ? '*' : '.');
> +            }
> +            trace_pca9552_led_state(s, buf[1], buf[0]);
> +        }
>          break;

or something like this : 

 static void pca9552_update_pin_input(PCA9552State *s)
 {
     int i;
+    char state[s->nr_leds + 1];
 
     for (i = 0; i < s->nr_leds; i++) {
         uint8_t input_reg = PCA9552_INPUT0 + (i / 8);
@@ -45,9 +47,11 @@ static void pca9552_update_pin_input(PCA
         switch (config) {
         case PCA9552_LED_ON:
             s->regs[input_reg] |= 1 << input_shift;
+            state[i] = '*';
             break;
         case PCA9552_LED_OFF:
             s->regs[input_reg] &= ~(1 << input_shift);
+            state[i] = '.';
             break;
         case PCA9552_LED_PWM0:
         case PCA9552_LED_PWM1:
@@ -56,6 +60,9 @@ static void pca9552_update_pin_input(PCA
             break;
         }
     }
+    state[i] = 0;
+
+    trace_pca9552_led_state(s, state);
 }



The pin usage is described in the witherspoon DTS : 

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts?id=b1f9be9392f0#n78

The front-power led is blinking. I suppose it means the BMC is on but not the 
host.


Cheers,

C. 

>  
>      case PCA9552_INPUT0:
> diff --git a/hw/misc/trace-events b/hw/misc/trace-events
> index 5561746866..21e52f192d 100644
> --- a/hw/misc/trace-events
> +++ b/hw/misc/trace-events
> @@ -206,3 +206,6 @@ via1_rtc_cmd_pram_sect_write(int sector, int offset, int 
> addr, int value) "secto
>  # grlib_ahb_apb_pnp.c
>  grlib_ahb_pnp_read(uint64_t addr, uint32_t value) "AHB PnP read 
> addr:0x%03"PRIx64" data:0x%08x"
>  grlib_apb_pnp_read(uint64_t addr, uint32_t value) "APB PnP read 
> addr:0x%03"PRIx64" data:0x%08x"
> +
> +# pca9552.c
> +pca9552_led_state(void *object, const char *bufhi, const char *buflo) "%p 
> LEDs [%s %s]"
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]