Skip to content

Commit 7cfbde5

Browse files
committed
hw/arm/aspeed: Add the 3 front LEDs drived by the PCA9552 #1
The Witherspoon has 3 LEDs connected to a PCA9552. Add them. The names and reset values are taken from: https://github.com/open-power/witherspoon-xml/blob/master/witherspoon.xml Example booting obmc-phosphor-image: $ qemu-system-arm -M witherspoon-bmc -trace led_change_intensity 1592693373.997015:led_change_intensity LED desc:'front-fault-4' color:green intensity 0% -> 100% 1592693373.997632:led_change_intensity LED desc:'front-power-3' color:green intensity 0% -> 100% 1592693373.998239:led_change_intensity LED desc:'front-id-5' color:green intensity 0% -> 100% 1592693500.291805:led_change_intensity LED desc:'front-power-3' color:green intensity 100% -> 0% 1592693500.312041:led_change_intensity LED desc:'front-power-3' color:green intensity 0% -> 100% 1592693500.821254:led_change_intensity LED desc:'front-power-3' color:green intensity 100% -> 0% 1592693501.331517:led_change_intensity LED desc:'front-power-3' color:green intensity 0% -> 100% 1592693501.841367:led_change_intensity LED desc:'front-power-3' color:green intensity 100% -> 0% 1592693502.350839:led_change_intensity LED desc:'front-power-3' color:green intensity 0% -> 100% 1592693502.861134:led_change_intensity LED desc:'front-power-3' color:green intensity 100% -> 0% 1592693503.371090:led_change_intensity LED desc:'front-power-3' color:green intensity 0% -> 100% We notice the front-power LED starts to blink at a ~2Hz rate. Reviewed-by: Richard Henderson <[email protected]> Reviewed-by: Luc Michel <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Cédric Le Goater <[email protected]> Message-Id: <[email protected]>
1 parent 4aef439 commit 7cfbde5

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

hw/arm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ config ASPEED_SOC
404404
select TMP105
405405
select TMP421
406406
select UNIMP
407+
select LED
407408

408409
config MPS2
409410
bool

hw/arm/aspeed.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "hw/i2c/smbus_eeprom.h"
2121
#include "hw/misc/pca9552.h"
2222
#include "hw/misc/tmp105.h"
23+
#include "hw/misc/led.h"
2324
#include "hw/qdev-properties.h"
2425
#include "qemu/log.h"
2526
#include "sysemu/block-backend.h"
@@ -525,9 +526,20 @@ static void sonorapass_bmc_i2c_init(AspeedMachineState *bmc)
525526

526527
static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc)
527528
{
529+
static const struct {
530+
unsigned gpio_id;
531+
LEDColor color;
532+
const char *description;
533+
bool gpio_polarity;
534+
} pca1_leds[] = {
535+
{13, LED_COLOR_GREEN, "front-fault-4", GPIO_POLARITY_ACTIVE_LOW},
536+
{14, LED_COLOR_GREEN, "front-power-3", GPIO_POLARITY_ACTIVE_LOW},
537+
{15, LED_COLOR_GREEN, "front-id-5", GPIO_POLARITY_ACTIVE_LOW},
538+
};
528539
AspeedSoCState *soc = &bmc->soc;
529540
uint8_t *eeprom_buf = g_malloc0(8 * 1024);
530541
DeviceState *dev;
542+
LEDState *led;
531543

532544
/* Bus 3: TODO bmp280@77 */
533545
/* Bus 3: TODO max31785@52 */
@@ -538,6 +550,14 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc)
538550
aspeed_i2c_get_bus(&soc->i2c, 3),
539551
&error_fatal);
540552

553+
for (size_t i = 0; i < ARRAY_SIZE(pca1_leds); i++) {
554+
led = led_create_simple(OBJECT(bmc),
555+
pca1_leds[i].gpio_polarity,
556+
pca1_leds[i].color,
557+
pca1_leds[i].description);
558+
qdev_connect_gpio_out(dev, pca1_leds[i].gpio_id,
559+
qdev_get_gpio_in(DEVICE(led), 0));
560+
}
541561
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), "tmp423", 0x4c);
542562
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), "tmp423", 0x4c);
543563

0 commit comments

Comments
 (0)