From: "Michael S. Tsirkin" <mst@redhat.com>
To: Paulo Alcantara <pcacjr@gmail.com>
Cc: pbonzini@redhat.com, seabios@seabios.org,
Paulo Alcantara <pcacjr@zytor.com>,
qemu-devel@nongnu.org, kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH v7 3/3] ich9: implement strap SPKR pin logic
Date: Sun, 28 Jun 2015 10:37:58 +0200 [thread overview]
Message-ID: <20150628101953-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <1435427793-27841-3-git-send-email-pcacjr@zytor.com>
On Sat, Jun 27, 2015 at 02:56:33PM -0300, Paulo Alcantara wrote:
> If the signal is sampled high, this indicates that the system is
> strapped to the "No Reboot" mode (ICH9 will disable the TCO Timer system
> reboot feature). The status of this strap is readable via the NO_REBOOT
> bit (CC: offset 0x3410:bit 5).
>
> The NO_REBOOT bit is set when SPKR pin on ICH9 is sampled high. This bit
> may be set or cleared by software if the strap is sampled low but may
> not override the strap when it indicates "No Reboot".
>
> This patch implements the logic where hardware has ability to set SPKR
> pin through a property named "pin-spkr"
I would call it "noreboot" and not pin-spkr
since that's what it does in the end.
> and it's sampled low by default.
I think sample high is a safer default.
>
> Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
> ---
> hw/acpi/tco.c | 3 ++-
> hw/isa/lpc_ich9.c | 38 ++++++++++++++++++++++++++++++++++++++
> include/hw/i386/ich9.h | 11 +++++++++++
> 3 files changed, 51 insertions(+), 1 deletion(-)
>
> diff --git a/hw/acpi/tco.c b/hw/acpi/tco.c
> index 1794a54..c1f5739 100644
> --- a/hw/acpi/tco.c
> +++ b/hw/acpi/tco.c
> @@ -64,7 +64,8 @@ static void tco_timer_expired(void *opaque)
> tr->tco.sts2 |= TCO_BOOT_STS;
> tr->timeouts_no = 0;
>
> - if (!(gcs & ICH9_CC_GCS_NO_REBOOT)) {
> + if ((lpc->pin_strap.spkr & ICH9_PS_SPKR_PIN_LOW) &&
> + !(gcs & ICH9_CC_GCS_NO_REBOOT)) {
> watchdog_perform_action();
> tco_timer_stop(tr);
> return;
> diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
> index b547002..49d1f30 100644
> --- a/hw/isa/lpc_ich9.c
> +++ b/hw/isa/lpc_ich9.c
> @@ -575,11 +575,49 @@ static void ich9_lpc_get_sci_int(Object *obj, Visitor *v,
> visit_type_uint32(v, &value, name, errp);
> }
>
> +static void ich9_lpc_get_spkr_pin(Object *obj, Visitor *v,
> + void *opaque, const char *name,
> + Error **errp)
> +{
> + ICH9LPCState *lpc = opaque;
> + uint8_t value = lpc->pin_strap.spkr;
> +
> + visit_type_uint8(v, &value, name, errp);
> +}
> +
> +static void ich9_lpc_set_spkr_pin(Object *obj, Visitor *v,
> + void *opaque, const char *name,
> + Error **errp)
> +{
> + ICH9LPCState *lpc = opaque;
> + Error *local_err = NULL;
> + uint8_t value;
> + uint32_t *gcs;
> +
> + visit_type_uint8(v, &value, name, &local_err);
> + if (local_err) {
> + goto out;
> + }
> + value &= ICH9_PS_SPKR_PIN_MASK;
> + if (value & ICH9_PS_SPKR_PIN_HIGH) {
> + gcs = (uint32_t *)&lpc->chip_config[ICH9_CC_GCS];
> + *gcs |= ICH9_CC_GCS_NO_REBOOT;
> + }
> + lpc->pin_strap.spkr = value;
> +out:
> + error_propagate(errp, local_err);
> +}
> +
> static void ich9_lpc_add_properties(ICH9LPCState *lpc)
> {
> static const uint8_t acpi_enable_cmd = ICH9_APM_ACPI_ENABLE;
> static const uint8_t acpi_disable_cmd = ICH9_APM_ACPI_DISABLE;
> + lpc->pin_strap.spkr = ICH9_PS_SPKR_PIN_DEFAULT;
>
> + object_property_add(OBJECT(lpc), "pin-spkr", "uint8",
> + ich9_lpc_get_spkr_pin,
> + ich9_lpc_set_spkr_pin,
> + NULL, lpc, NULL);
> object_property_add(OBJECT(lpc), ACPI_PM_PROP_SCI_INT, "uint32",
> ich9_lpc_get_sci_int,
> NULL, NULL, NULL, NULL);
BTW it's easier to add simple properties in dc->props
then you don't need all the error propagate code etc.
> diff --git a/include/hw/i386/ich9.h b/include/hw/i386/ich9.h
> index f5681a3..aafc43f 100644
> --- a/include/hw/i386/ich9.h
> +++ b/include/hw/i386/ich9.h
> @@ -46,6 +46,11 @@ typedef struct ICH9LPCState {
> ICH9LPCPMRegs pm;
> uint32_t sci_level; /* track sci level */
>
> + /* 2.24 Pin Straps */
> + struct {
> + uint8_t spkr;
> + } pin_strap;
> +
> /* 10.1 Chipset Configuration registers(Memory Space)
> which is pointed by RCBA */
> uint8_t chip_config[ICH9_CC_SIZE];
> @@ -72,6 +77,12 @@ Object *ich9_lpc_find(void);
> #define Q35_MASK(bit, ms_bit, ls_bit) \
> ((uint##bit##_t)(((1ULL << ((ms_bit) + 1)) - 1) & ~((1ULL << ls_bit) - 1)))
>
> +/* ICH9: Pin Straps */
> +#define ICH9_PS_SPKR_PIN_LOW 0x01
> +#define ICH9_PS_SPKR_PIN_HIGH 0x02
> +#define ICH9_PS_SPKR_PIN_MASK 0x03
> +#define ICH9_PS_SPKR_PIN_DEFAULT ICH9_PS_SPKR_PIN_LOW
> +
The interface seems a bit inconvenient to me.
Why not make it a simple boolean property?
> /* ICH9: Chipset Configuration Registers */
> #define ICH9_CC_ADDR_MASK (ICH9_CC_SIZE - 1)
>
> --
> 2.1.0
next prev parent reply other threads:[~2015-06-28 8:38 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-27 0:29 [Qemu-devel] [PATCH 1/3] ich9: add TCO interface emulation Paulo Alcantara
2015-05-27 0:29 ` [Qemu-devel] [PATCH 2/3] target-i386: reserve RCRB mmio space in ACPI DSDT table Paulo Alcantara
2015-05-27 12:03 ` Paolo Bonzini
2015-05-27 17:51 ` Paulo Alcantara
2015-05-28 7:13 ` [Qemu-devel] [SeaBIOS] " Gerd Hoffmann
2015-05-30 10:57 ` Paulo Alcantara
2015-06-01 7:16 ` Gerd Hoffmann
2015-06-01 11:59 ` Paulo Alcantara
2015-05-27 0:29 ` [Qemu-devel] [PATCH 3/3] tests: add testcase for TCO watchdog emulation Paulo Alcantara
2015-05-27 11:58 ` [Qemu-devel] [PATCH 1/3] ich9: add TCO interface emulation Paolo Bonzini
2015-05-27 18:23 ` Paulo Alcantara
2015-05-30 22:04 ` [Qemu-devel] [PATCH v2 " Paulo Alcantara
2015-05-30 22:04 ` [Qemu-devel] [PATCH v2 2/3] target-i386: reserve RCRB mmio space in ACPI DSDT table Paulo Alcantara
2015-05-30 22:04 ` [Qemu-devel] [PATCH v2 3/3] tests: add testcase for TCO watchdog emulation Paulo Alcantara
2015-06-01 9:07 ` Paolo Bonzini
2015-06-01 9:05 ` [Qemu-devel] [PATCH v2 1/3] ich9: add TCO interface emulation Paolo Bonzini
2015-06-01 13:38 ` Paulo Alcantara
2015-06-01 21:37 ` Paulo Alcantara
2015-06-01 23:48 ` [Qemu-devel] [PATCH v3 " Paulo Alcantara
2015-06-01 23:48 ` [Qemu-devel] [PATCH v3 2/3] target-i386: reserve RCRB mmio space in ACPI DSDT table Paulo Alcantara
2015-06-17 13:33 ` Michael S. Tsirkin
2015-06-18 2:14 ` Paulo Alcantara
2015-06-01 23:48 ` [Qemu-devel] [PATCH v3 3/3] tests: add testcase for TCO watchdog emulation Paulo Alcantara
2015-06-17 13:37 ` Michael S. Tsirkin
2015-06-18 2:23 ` Paulo Alcantara
2015-06-10 13:17 ` [Qemu-devel] [PATCH v3 1/3] ich9: add TCO interface emulation Paulo Alcantara
2015-06-17 13:27 ` Michael S. Tsirkin
2015-06-18 2:10 ` Paulo Alcantara
2015-06-22 0:37 ` [Qemu-devel] [PATCH v4 " Paulo Alcantara
2015-06-22 0:37 ` [Qemu-devel] [PATCH v4 2/3] target-i386: reserve RCRB mmio space in ACPI DSDT table Paulo Alcantara
2015-06-22 8:40 ` Michael S. Tsirkin
2015-06-22 12:53 ` Paulo Alcantara
2015-06-23 10:38 ` [Qemu-devel] [SeaBIOS] " Igor Mammedov
2015-06-23 10:58 ` Michael S. Tsirkin
2015-06-23 12:29 ` Igor Mammedov
2015-06-23 12:37 ` Michael S. Tsirkin
2015-06-23 11:15 ` Paolo Bonzini
2015-06-23 11:18 ` Paolo Bonzini
2015-06-23 12:22 ` Michael S. Tsirkin
2015-06-22 0:37 ` [Qemu-devel] [PATCH v4 3/3] tests: add testcase for TCO watchdog emulation Paulo Alcantara
2015-06-22 8:39 ` [Qemu-devel] [PATCH v4 1/3] ich9: add TCO interface emulation Michael S. Tsirkin
2015-06-22 12:30 ` Paulo Alcantara
2015-06-22 12:32 ` Paolo Bonzini
2015-06-22 12:47 ` Michael S. Tsirkin
2015-06-22 13:04 ` Paolo Bonzini
2015-06-22 13:07 ` Michael S. Tsirkin
2015-06-22 13:19 ` Paulo Alcantara
2015-06-22 13:10 ` Markus Armbruster
2015-06-22 8:43 ` Michael S. Tsirkin
2015-06-22 9:45 ` Paolo Bonzini
2015-06-22 12:11 ` Michael S. Tsirkin
2015-06-22 12:36 ` Paulo Alcantara
2015-06-22 12:44 ` Michael S. Tsirkin
2015-06-22 12:59 ` Paolo Bonzini
2015-06-22 18:29 ` Paulo Alcantara
2015-06-22 23:10 ` [Qemu-devel] [PATCH v5 " Paulo Alcantara
2015-06-22 23:10 ` [Qemu-devel] [PATCH v5 2/3] target-i386: reserve RCRB mmio space in ACPI DSDT table Paulo Alcantara
2015-06-23 14:29 ` [Qemu-devel] [SeaBIOS] " Igor Mammedov
2015-06-23 15:33 ` Michael S. Tsirkin
2015-06-23 14:39 ` Igor Mammedov
2015-06-23 15:06 ` Michael S. Tsirkin
2015-06-23 15:12 ` Igor Mammedov
2015-06-23 15:29 ` Michael S. Tsirkin
2015-06-24 15:11 ` [Qemu-devel] " Michael S. Tsirkin
2015-06-24 16:00 ` Paulo Alcantara
2015-06-24 16:04 ` Michael S. Tsirkin
2015-06-22 23:10 ` [Qemu-devel] [PATCH v5 3/3] tests: add testcase for TCO watchdog emulation Paulo Alcantara
2015-06-23 6:39 ` [Qemu-devel] [PATCH v5 1/3] ich9: add TCO interface emulation Michael S. Tsirkin
2015-06-24 18:03 ` [Qemu-devel] [PATCH v6 1/2] " Paulo Alcantara
2015-06-24 18:03 ` [Qemu-devel] [PATCH v6 2/2] tests: add testcase for TCO watchdog emulation Paulo Alcantara
2015-06-27 17:56 ` [Qemu-devel] [PATCH v7 1/3] ich9: add TCO interface emulation Paulo Alcantara
2015-06-27 17:56 ` [Qemu-devel] [PATCH v7 2/3] tests: add testcase for TCO watchdog emulation Paulo Alcantara
2015-06-27 17:56 ` [Qemu-devel] [PATCH v7 3/3] ich9: implement strap SPKR pin logic Paulo Alcantara
2015-06-28 8:37 ` Michael S. Tsirkin [this message]
2015-06-28 16:21 ` Paulo Alcantara
2015-06-28 17:58 ` [Qemu-devel] [PATCH v8 1/3] ich9: add TCO interface emulation Paulo Alcantara
2015-06-28 17:58 ` [Qemu-devel] [PATCH v8 2/3] tests: add testcase for TCO watchdog emulation Paulo Alcantara
2015-06-28 17:58 ` [Qemu-devel] [PATCH v8 3/3] ich9: implement strap SPKR pin logic Paulo Alcantara
2015-07-01 13:18 ` Paolo Bonzini
2015-07-01 13:31 ` Michael S. Tsirkin
2015-07-01 13:34 ` Paolo Bonzini
2015-07-02 1:30 ` Paulo Alcantara
2015-07-02 6:55 ` Paolo Bonzini
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=20150628101953-mutt-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=kraxel@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pcacjr@gmail.com \
--cc=pcacjr@zytor.com \
--cc=qemu-devel@nongnu.org \
--cc=seabios@seabios.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).