All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Hao Wu <wuhaotsh@google.com>
Cc: Patrick Venture <venture@google.com>,
	Havard Skinnemoen <hskinnemoen@google.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	CS20 KFTing <kfting@nuvoton.com>, qemu-arm <qemu-arm@nongnu.org>,
	IS20 Avi Fishman <Avi.Fishman@nuvoton.com>,
	Doug Evans <dje@google.com>
Subject: Re: [PATCH 3/4] hw/arm: Connect PWM fans in NPCM7XX boards
Date: Thu, 11 Mar 2021 12:08:43 +0000	[thread overview]
Message-ID: <CAFEAcA-NqB8ngBVqSeF_pNH_-J6rn5nGaQw9zazFn2rTBtnJGQ@mail.gmail.com> (raw)
In-Reply-To: <20210305183857.3120188-4-wuhaotsh@google.com>

On Fri, 5 Mar 2021 at 18:40, Hao Wu <wuhaotsh@google.com> wrote:
>
> This patch adds fan_splitters (split IRQs) in NPCM7XX boards. Each fan
> splitter corresponds to 1 PWM output and can connect to multiple fan
> inputs (MFT devices).
> In NPCM7XX boards(NPCM750 EVB and Quanta GSJ boards), we initializes
> these splitters and connect them to their corresponding modules
> according their specific device trees.
>
> Reviewed-by: Doug Evans <dje@google.com>
> Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
> Signed-off-by: Hao Wu <wuhaotsh@google.com>
> ---
>  hw/arm/npcm7xx_boards.c  | 99 ++++++++++++++++++++++++++++++++++++++++
>  include/hw/arm/npcm7xx.h | 11 ++++-
>  2 files changed, 109 insertions(+), 1 deletion(-)
>
> diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
> index fbf6ce8e02..e22fe4bf8f 100644
> --- a/hw/arm/npcm7xx_boards.c
> +++ b/hw/arm/npcm7xx_boards.c
> @@ -21,6 +21,7 @@
>  #include "hw/core/cpu.h"
>  #include "hw/i2c/smbus_eeprom.h"
>  #include "hw/loader.h"
> +#include "hw/qdev-core.h"
>  #include "hw/qdev-properties.h"
>  #include "qapi/error.h"
>  #include "qemu-common.h"
> @@ -116,6 +117,64 @@ static void at24c_eeprom_init(NPCM7xxState *soc, int bus, uint8_t addr,
>      i2c_slave_realize_and_unref(i2c_dev, i2c_bus, &error_abort);
>  }
>
> +static void npcm7xx_init_pwm_splitter(NPCM7xxMachine *machine,
> +                                      NPCM7xxState *soc, const int *fan_counts)
> +{
> +    SplitIRQ *splitters = machine->fan_splitter;
> +
> +    /*
> +     * PWM 0~3 belong to module 0 output 0~3.
> +     * PWM 4~7 belong to module 1 output 0~3.
> +     */
> +    for (int i = 0; i < NPCM7XX_NR_PWM_MODULES; ++i) {
> +        for (int j = 0; j < NPCM7XX_PWM_PER_MODULE; ++j) {
> +            int splitter_no = i * NPCM7XX_PWM_PER_MODULE + j;
> +            DeviceState *splitter;
> +
> +            if (fan_counts[splitter_no] < 1) {
> +                continue;
> +            }
> +            object_initialize_child(OBJECT(machine), "fan-splitter[*]",
> +                                    &splitters[splitter_no], TYPE_SPLIT_IRQ);
> +            splitter = DEVICE(&splitters[splitter_no]);
> +            qdev_prop_set_uint16(splitter, "num-lines",
> +                                 fan_counts[splitter_no]);
> +            qdev_realize(splitter, NULL, &error_abort);
> +            qdev_connect_gpio_out_named(DEVICE(&soc->pwm[i]), "duty-gpio-out",
> +                                        j, qdev_get_gpio_in(splitter, 0));

This will rather pointlessly create a splitter with a single input
if fan_counts[n] is 1, but conveniently you never actually do
that, so it's not a big deal.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM


  reply	other threads:[~2021-03-11 12:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05 18:38 [PATCH 0/4] hw/misc: Add NPCM7XX Tachometer Device Hao Wu via
2021-03-05 18:38 ` [PATCH 1/4] hw/misc: Add GPIOs for duty in NPCM7xx PWM Hao Wu via
2021-03-11 12:05   ` Peter Maydell
2021-03-05 18:38 ` [PATCH 2/4] hw/misc: Add NPCM7XX MFT Module Hao Wu via
2021-03-11 12:07   ` Peter Maydell
2021-03-05 18:38 ` [PATCH 3/4] hw/arm: Connect PWM fans in NPCM7XX boards Hao Wu via
2021-03-11 12:08   ` Peter Maydell [this message]
2021-03-05 18:38 ` [PATCH 4/4] tests/qtest: Test PWM fan RPM using MFT in PWM test Hao Wu via
2021-03-11 12:09   ` Peter Maydell
2021-03-05 19:00 ` [PATCH 0/4] hw/misc: Add NPCM7XX Tachometer Device no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFEAcA-NqB8ngBVqSeF_pNH_-J6rn5nGaQw9zazFn2rTBtnJGQ@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=Avi.Fishman@nuvoton.com \
    --cc=dje@google.com \
    --cc=hskinnemoen@google.com \
    --cc=kfting@nuvoton.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=venture@google.com \
    --cc=wuhaotsh@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.