From patchwork Mon Feb 4 13:44:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 14537 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 AC47A23FEE for ; Mon, 4 Feb 2013 13:44:52 +0000 (UTC) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by fiordland.canonical.com (Postfix) with ESMTP id 69CF7A18276 for ; Mon, 4 Feb 2013 13:44:52 +0000 (UTC) Received: by mail-ve0-f171.google.com with SMTP id b10so4765347vea.30 for ; Mon, 04 Feb 2013 05:44:52 -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=4blPDwX89lgLRSJ51TeNHzR857d6OsaWjhJwDRMu//o=; b=OBSB4fcaTB+gsmY63RB59XxFFTpldYiEaCQ4ik8ASTB8Z94utWqQ8qTIUvbmlSTt3d xjbc2+VR3hUPRNCIZ8zzx06/SDzUPqvQlSJqQlpgCMjC4eF0KavfHrgRkmDkhMrIOrEC KFUz4HRnhVH8bZ1U+JkizmcFP0nbuyJ6kgitU1Uk1Wm4XbS5aHsTkTxpOq8/WSVh/SwP uabJfXQpuX1tGlBetyee8LAXbEjN+3zhkzoqKwjwD81kRCTSXJEAlcoiCe3dJvOG8XC3 kSyDL50A3LgMeXiyjo3rK7Av0K++7fcyMR98CXg0hmZqzxlot9Hh571VSA2lnetc79wc A3Nw== X-Received: by 10.59.7.65 with SMTP id da1mr18137457ved.4.1359985491920; Mon, 04 Feb 2013 05:44:51 -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.252.8 with SMTP id zo8csp87661vec; Mon, 4 Feb 2013 05:44:51 -0800 (PST) X-Received: by 10.194.178.33 with SMTP id cv1mr35222877wjc.46.1359985489156; Mon, 04 Feb 2013 05:44:49 -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 v1si5837876wjv.81.2013.02.04.05.44.48 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 04 Feb 2013 05:44:49 -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 1U2MLd-0007eX-Dh; Mon, 04 Feb 2013 13:44:37 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Anthony Liguori Subject: [PATCH 07/10] hw/arm_sysctl: Implement SYS_CFG_VOLT Date: Mon, 4 Feb 2013 13:44:33 +0000 Message-Id: <1359985476-29380-8-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1359985476-29380-1-git-send-email-peter.maydell@linaro.org> References: <1359985476-29380-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQmqsg5A8W906PwpKELmJEccjeqhZLgDeSSnQVFaUNEqXNcFtFKouqcyXm2A79E0WtR1Qpo4 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 ecee6fe..961bb57 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; } @@ -536,9 +551,19 @@ static void arm_sysctl_init(Object *obj) qdev_init_gpio_out(&s->busdev.qdev, &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(), }; @@ -556,6 +581,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, };