From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGYBH-00081r-FN for qemu-devel@nongnu.org; Fri, 15 Mar 2013 13:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UGYBA-0000RU-Jw for qemu-devel@nongnu.org; Fri, 15 Mar 2013 13:12:35 -0400 Received: from 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]:32917 helo=mnementh.archaic.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGYBA-0000Q8-Cz for qemu-devel@nongnu.org; Fri, 15 Mar 2013 13:12:28 -0400 From: Peter Maydell Date: Fri, 15 Mar 2013 16:56:29 +0000 Message-Id: <1363366599-24238-8-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1363366599-24238-1-git-send-email-peter.maydell@linaro.org> References: <1363366599-24238-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH 07/17] hw/arm_sysctl: Implement SYS_CFG_VOLT List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori , Blue Swirl Cc: qemu-devel@nongnu.org, Paul Brook 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 7c94b78..e2f00d3 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, }; -- 1.7.9.5