From patchwork Thu Feb 21 18:57:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158931 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp835272jaa; Thu, 21 Feb 2019 11:01:30 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia0dm3RVKDgPc9OJThP9EEmVKFMTFN32w0fhjnnl3ff1gYr1TEIcG42yfIJyJyHHrSgyArN X-Received: by 2002:a25:3004:: with SMTP id w4mr33825810ybw.461.1550775690786; Thu, 21 Feb 2019 11:01:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550775690; cv=none; d=google.com; s=arc-20160816; b=SMk8MJXznudSkViQU/kPAjSjUcoC0m3mQymXiowkN6mIUAmETzc95Duk61fJ4FN60U M7xgASl+neNCsVHzTOkT4/zd8DArKKYe1CCfLkdH1fDym5XOGmKRHkxLyu9XgGz6amC3 TkUuqyXFrIDo6wFjRSCqRA80oJHsdZZjEnYj9agUNBNMy2QW1UvEJCvVyWgHOCKY2a/M 5a3JqUD9CfJkqiEBlPz+lmVa9oVOLvejBDXxJQnTDShUn62NbJ1r+hqwIWdYjxdlFFjT +qA2bHuO/Mghz0ordazey2e0LhnCH2vkE5ddrWVswbXVZ96MoNrNHAZI4YQ7itXjwEtF FwNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=1xlhf1mp9qqB33j+hK+JXtYtQaD6M2dVqgVLioh3iiM=; b=kST0neVP8VOdbSag8aHMmGf8CezujGK/P+iBtPjTun27HzOTCc0LTFcGR4roQWGM5f Fu2sPMl6zeHRTcy29hcL1ZBmOSMtE7T0NU1GT6mP+HSQAouxE5+jmR0UGlhnFJoXM4QS gu2n3b4tdqBXbGb/FcZfVADJ8eqJKigdLZ470dVLJgvYYSHDdQUZBFFjnE+7zUTqnVef uqgXnivz1RcxmM77ATC85UjJscVmZtAl6VTB8TabnjuJWTUWnA0JKso9/8KHk/sU23U5 X0MaFtS1Dcsbg5Xqks6vSRCF6+i5YM0udGY95Y5ZZnDeOORT/vL1xm3hZwOArQtPkI9J qdbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=yoJcXXXJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s204si14336187ywb.44.2019.02.21.11.01.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:01:30 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=yoJcXXXJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:36931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtb8-0003ai-8G for patch@linaro.org; Thu, 21 Feb 2019 14:01:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXn-0008QH-0x for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXl-0007PP-50 for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:02 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:41810) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXj-0007M7-9p for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:01 -0500 Received: by mail-wr1-x442.google.com with SMTP id n2so19643956wrw.8 for ; Thu, 21 Feb 2019 10:57:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1xlhf1mp9qqB33j+hK+JXtYtQaD6M2dVqgVLioh3iiM=; b=yoJcXXXJQHsR/94lZMFJE7NI2htQBItIjkspmC9MSTXVCRuTyr5EjhKvXbFu4+C/Zz JTlmYsrgQIc8X+XaPAnWo23qlPQx5jC5J1ZiTXDVyGBQ9YiWXPpVyWoe78VNe72VrHXY HKh1mj8xysBSwW3sqypWuQdx/n4BlARI4DatNJYWkqa8QkFCJXYEyfQg9BjG4IrL5Xv5 PDDFjWBUvwavq2hFKAQc2vEcwx91hOFxoF9nGAFmrHdiQgyPe+74HJ3/z/2NnouPC5Nf PbLacxTHxz4HzH0HTk7Vh1dtXpyJm/El4hECm5UfXZfqMQNJH3vT1XeqMGT5rgbIb/TM WNvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1xlhf1mp9qqB33j+hK+JXtYtQaD6M2dVqgVLioh3iiM=; b=UR0w4uuUeCey9WsRF/XAvAvmUgRKlez107zwZzwzmhRkzANS78UApmbL5Gi51UxiKI 4WkluJEaP3kbaUsVLVv5ePACRgdcbhcBlJKWm7ZXZ7oG8ULaC2b9oq2CK/ZZJrGWv2bF UiZrGySkv426kPv+PFimLybEVik8txen+GM5J1LXFh0Rc5r97kbHiBPv1FhsjJ8XnRMO zVf/yh0HXyYX4b/Um7xZwiPHLNha+EoeETyqQCkY+uci6QKfPg0xMKXmZdMfZ1wukPxI Hs1hMV/c21T/yDXA80cSqtH5fTGGaBEzFQShptY5rZIY70wcz0F/hFd84iKL2r3ZqknV NgFA== X-Gm-Message-State: AHQUAuaGB3eqMJJQzYYZ/fUiDFE7zC6yTl/fSQjDFyxYxfN/vwalP4ha jz6WskQ7qWgWuoTu76+Ewn9tJyjADks= X-Received: by 2002:adf:f391:: with SMTP id m17mr11380348wro.137.1550775474437; Thu, 21 Feb 2019 10:57:54 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c18sm29065085wre.32.2019.02.21.10.57.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:53 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:27 +0000 Message-Id: <20190221185739.25362-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190221185739.25362-1-peter.maydell@linaro.org> References: <20190221185739.25362-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PULL 09/21] hw/timer/pl031: Allow use as an embedded-struct device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create a new include file for the pl031's device struct, type macros, etc, so that it can be instantiated using the "embedded struct" coding style. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/hw/timer/pl031.h | 44 ++++++++++++++++++++++++++++++++++++++++ hw/timer/pl031.c | 25 +---------------------- MAINTAINERS | 1 + 3 files changed, 46 insertions(+), 24 deletions(-) create mode 100644 include/hw/timer/pl031.h -- 2.20.1 diff --git a/include/hw/timer/pl031.h b/include/hw/timer/pl031.h new file mode 100644 index 00000000000..99416d8ba52 --- /dev/null +++ b/include/hw/timer/pl031.h @@ -0,0 +1,44 @@ +/* + * ARM AMBA PrimeCell PL031 RTC + * + * Copyright (c) 2007 CodeSourcery + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. + */ + +#ifndef HW_TIMER_PL031 +#define HW_TIMER_PL031 + +#include "hw/sysbus.h" + +#define TYPE_PL031 "pl031" +#define PL031(obj) OBJECT_CHECK(PL031State, (obj), TYPE_PL031) + +typedef struct PL031State { + SysBusDevice parent_obj; + + MemoryRegion iomem; + QEMUTimer *timer; + qemu_irq irq; + + /* + * Needed to preserve the tick_count across migration, even if the + * absolute value of the rtc_clock is different on the source and + * destination. + */ + uint32_t tick_offset_vmstate; + uint32_t tick_offset; + + uint32_t mr; + uint32_t lr; + uint32_t cr; + uint32_t im; + uint32_t is; +} PL031State; + +#endif diff --git a/hw/timer/pl031.c b/hw/timer/pl031.c index d3aacce80da..f774dcd5223 100644 --- a/hw/timer/pl031.c +++ b/hw/timer/pl031.c @@ -12,6 +12,7 @@ */ #include "qemu/osdep.h" +#include "hw/timer/pl031.h" #include "hw/sysbus.h" #include "qemu/timer.h" #include "sysemu/sysemu.h" @@ -36,30 +37,6 @@ do { printf("pl031: " fmt , ## __VA_ARGS__); } while (0) #define RTC_MIS 0x18 /* Masked interrupt status register */ #define RTC_ICR 0x1c /* Interrupt clear register */ -#define TYPE_PL031 "pl031" -#define PL031(obj) OBJECT_CHECK(PL031State, (obj), TYPE_PL031) - -typedef struct PL031State { - SysBusDevice parent_obj; - - MemoryRegion iomem; - QEMUTimer *timer; - qemu_irq irq; - - /* Needed to preserve the tick_count across migration, even if the - * absolute value of the rtc_clock is different on the source and - * destination. - */ - uint32_t tick_offset_vmstate; - uint32_t tick_offset; - - uint32_t mr; - uint32_t lr; - uint32_t cr; - uint32_t im; - uint32_t is; -} PL031State; - static const unsigned char pl031_id[] = { 0x31, 0x10, 0x14, 0x00, /* Device ID */ 0x0d, 0xf0, 0x05, 0xb1 /* Cell ID */ diff --git a/MAINTAINERS b/MAINTAINERS index b1d786cfd87..db31bc4486c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -491,6 +491,7 @@ F: hw/sd/pl181.c F: hw/ssi/pl022.c F: include/hw/ssi/pl022.h F: hw/timer/pl031.c +F: include/hw/timer/pl031.h F: include/hw/arm/primecell.h F: hw/timer/cmsdk-apb-timer.c F: include/hw/timer/cmsdk-apb-timer.h