mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 16:53:55 -06:00
hw/misc: Add GPIOs for duty in NPCM7xx PWM
This patch adds GPIOs in NPCM7xx PWM module for its duty values. The purpose of this is to connect it to the MFT module to provide an input for measuring a PWM fan's RPM. Each PWM module has NPCM7XX_PWM_PER_MODULE of GPIOs, each one corresponds to one PWM instance and can connect to multiple fan instances in MFT. Reviewed-by: Doug Evans <dje@google.com> Reviewed-by: Tyrone Ting <kfting@nuvoton.com> Signed-off-by: Hao Wu <wuhaotsh@google.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 20210311180855.149764-2-wuhaotsh@google.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
bcb902a1ed
commit
71b50b9d1c
2 changed files with 7 additions and 1 deletions
|
@ -139,6 +139,7 @@ static void npcm7xx_pwm_update_duty(NPCM7xxPWM *p)
|
|||
trace_npcm7xx_pwm_update_duty(DEVICE(p->module)->canonical_path,
|
||||
p->index, p->duty, duty);
|
||||
p->duty = duty;
|
||||
qemu_set_irq(p->module->duty_gpio_out[p->index], p->duty);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -483,6 +484,7 @@ static void npcm7xx_pwm_init(Object *obj)
|
|||
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
||||
int i;
|
||||
|
||||
QEMU_BUILD_BUG_ON(ARRAY_SIZE(s->pwm) != NPCM7XX_PWM_PER_MODULE);
|
||||
for (i = 0; i < NPCM7XX_PWM_PER_MODULE; i++) {
|
||||
NPCM7xxPWM *p = &s->pwm[i];
|
||||
p->module = s;
|
||||
|
@ -501,6 +503,8 @@ static void npcm7xx_pwm_init(Object *obj)
|
|||
object_property_add_uint32_ptr(obj, "duty[*]",
|
||||
&s->pwm[i].duty, OBJ_PROP_FLAG_READ);
|
||||
}
|
||||
qdev_init_gpio_out_named(DEVICE(s), s->duty_gpio_out,
|
||||
"duty-gpio-out", NPCM7XX_PWM_PER_MODULE);
|
||||
}
|
||||
|
||||
static const VMStateDescription vmstate_npcm7xx_pwm = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue