From patchwork Mon Feb 25 16:44:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 15072 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 81D3023E02 for ; Mon, 25 Feb 2013 16:44:46 +0000 (UTC) Received: from mail-vb0-f42.google.com (mail-vb0-f42.google.com [209.85.212.42]) by fiordland.canonical.com (Postfix) with ESMTP id 3BE28A180BD for ; Mon, 25 Feb 2013 16:44:46 +0000 (UTC) Received: by mail-vb0-f42.google.com with SMTP id ff1so1807939vbb.15 for ; Mon, 25 Feb 2013 08:44:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=/aXBuzt2GJHAPq8jWAIw6a4kS6OI2FeB1xJC0CBo+DU=; b=LNhWjsKMO/Utt4KV1pIpg4O73PiZdXhayVNH0K8NVOK8fWZWd0nWVeTKnnBEr+zQpR TVq59QvMrSxVXBbWGvPX4CFPCLoTSTqA6yekUley4LImmWEBjeJ5uVbam4kAT5E6HtMf gVoIzZsfPgW6POTSYfzyi5WrGIOcaW9AXlZy9lbNKo7JVypGLWbU9g93VLhFNv4daBY6 1Q4hugAmE/oBJxerln1huC+3fNiH17gQp1WIBr9qh4mxePU+7JBb9U5RnwgkzBekpGmJ W3Cgg/ZT+9Xb9WZZQbQxwZgfaaLafbfaLx2VF1KgBVWiZ817ymAttOrXAmoNOULboLi/ aFxg== X-Received: by 10.52.93.235 with SMTP id cx11mr8661333vdb.51.1361810685737; Mon, 25 Feb 2013 08:44:45 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp67556veb; Mon, 25 Feb 2013 08:44:44 -0800 (PST) X-Received: by 10.194.9.166 with SMTP id a6mr5284956wjb.2.1361810680394; Mon, 25 Feb 2013 08:44:40 -0800 (PST) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id i1si3694003wie.29.2013.02.25.08.44.39 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 25 Feb 2013 08:44:40 -0800 (PST) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Authentication-Results: mx.google.com; spf=neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1UA1AH-0006te-Ei; Mon, 25 Feb 2013 16:44:33 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= , Anthony Liguori Subject: [PATCH v2 07/10] hw/arm_sysctl: Implement SYS_CFG_VOLT Date: Mon, 25 Feb 2013 16:44:30 +0000 Message-Id: <1361810673-26473-8-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1361810673-26473-1-git-send-email-peter.maydell@linaro.org> References: <1361810673-26473-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQnvMJgXjNgomWmNd4oyWlDRs9SYyAx9CSrmZJAtmltX6fmMRwTG64PEj+4hH1XimjPEWJqJ Implement the SYS_CFG_VOLT registers which return the voltage of various supplies on motherboard and daughterboard. Since QEMU implements a perfectly stable power supply these registers always return a constant value. The number and value of the daughterboard voltages is dependent on the specific daughterboard, so we use a property array to allow the board to configure them appropriately. Signed-off-by: Peter Maydell --- hw/arm_sysctl.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/hw/arm_sysctl.c b/hw/arm_sysctl.c index 6d135ac..0d79310 100644 --- a/hw/arm_sysctl.c +++ b/hw/arm_sysctl.c @@ -35,6 +35,8 @@ typedef struct { uint32_t sys_cfgctrl; uint32_t sys_cfgstat; uint32_t sys_clcd; + uint32_t db_num_vsensors; + uint32_t *db_voltage; } arm_sysctl_state; static const VMStateDescription vmstate_arm_sysctl = { @@ -236,6 +238,19 @@ static bool vexpress_cfgctrl_read(arm_sysctl_state *s, unsigned int dcc, } switch (function) { + case SYS_CFG_VOLT: + if (site == SYS_CFG_SITE_DB1 && device < s->db_num_vsensors) { + *val = s->db_voltage[device]; + return true; + } + if (site == SYS_CFG_SITE_MB && device == 0) { + /* There is only one motherboard voltage sensor: + * VIO : 3.3V : bus voltage between mother and daughterboard + */ + *val = 3300000; + return true; + } + break; default: break; } @@ -537,9 +552,19 @@ static void arm_sysctl_init(Object *obj) qdev_init_gpio_out(dev, &s->pl110_mux_ctrl, 1); } +static void arm_sysctl_finalize(Object *obj) +{ + SysBusDevice *dev = SYS_BUS_DEVICE(obj); + arm_sysctl_state *s = FROM_SYSBUS(arm_sysctl_state, dev); + g_free(s->db_voltage); +} + static Property arm_sysctl_properties[] = { DEFINE_PROP_UINT32("sys_id", arm_sysctl_state, sys_id, 0), DEFINE_PROP_UINT32("proc_id", arm_sysctl_state, proc_id, 0), + /* Daughterboard power supply voltages (as reported via SYS_CFG) */ + DEFINE_PROP_ARRAY("db-voltage", arm_sysctl_state, db_num_vsensors, + db_voltage, qdev_prop_uint32, uint32_t), DEFINE_PROP_END_OF_LIST(), }; @@ -557,6 +582,7 @@ static const TypeInfo arm_sysctl_info = { .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(arm_sysctl_state), .instance_init = arm_sysctl_init, + .instance_finalize = arm_sysctl_finalize, .class_init = arm_sysctl_class_init, };