From patchwork Tue Mar 8 21:06:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 8537821 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4D2DDC0553 for ; Tue, 8 Mar 2016 21:12:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7AB21201FA for ; Tue, 8 Mar 2016 21:12:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E460201C8 for ; Tue, 8 Mar 2016 21:12:22 +0000 (UTC) Received: from localhost ([::1]:37427 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adOvV-0000xL-U3 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 08 Mar 2016 16:12:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adOt8-0005jr-Jm for qemu-devel@nongnu.org; Tue, 08 Mar 2016 16:09:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adOt5-0002jt-7D for qemu-devel@nongnu.org; Tue, 08 Mar 2016 16:09:54 -0500 Received: from mail-bl2nam02on0055.outbound.protection.outlook.com ([104.47.38.55]:43168 helo=NAM02-BL2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adOt5-0002jb-2F for qemu-devel@nongnu.org; Tue, 08 Mar 2016 16:09:51 -0500 Received: from SN1NAM02FT005.eop-nam02.prod.protection.outlook.com (10.152.72.52) by SN1NAM02HT122.eop-nam02.prod.protection.outlook.com (10.152.73.248) with Microsoft SMTP Server (TLS) id 15.1.427.7; Tue, 8 Mar 2016 21:09:49 +0000 Authentication-Results: spf=fail (sender IP is 149.199.60.96) smtp.mailfrom=xilinx.com; linaro.org; dkim=none (message not signed) header.d=none; linaro.org; dmarc=none action=none header.from=xilinx.com; Received-SPF: Fail (protection.outlook.com: domain of xilinx.com does not designate 149.199.60.96 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.96; helo=xsj-tvapsmtpgw01; Received: from xsj-tvapsmtpgw01 (149.199.60.96) by SN1NAM02FT005.mail.protection.outlook.com (10.152.72.117) with Microsoft SMTP Server (TLS) id 15.1.427.7 via Frontend Transport; Tue, 8 Mar 2016 21:09:46 +0000 Received: from 172-16-1-203.xilinx.com ([172.16.1.203]:47535 helo=xsj-tvapsmtp02.xilinx.com) by xsj-tvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1adOsz-0006CX-FQ; Tue, 08 Mar 2016 13:09:45 -0800 Received: from [127.0.0.1] (port=48480 helo=tsj-smtp-dlp1.xlnx.xilinx.com) by xsj-tvapsmtp02.xilinx.com with esmtp (Exim 4.63) (envelope-from ) id 1adOsz-0000e7-AQ; Tue, 08 Mar 2016 13:09:45 -0800 Received: from xsj-tvapsmtp02 (xsj-tvapsmtp02.xilinx.com [172.16.1.203]) by tsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u28L3sGT021879; Tue, 8 Mar 2016 13:03:55 -0800 Received: from [172.19.74.182] (port=56658 helo=xsjalistai50.xlnx.xilinx.com) by xsj-tvapsmtp02 with esmtp (Exim 4.63) (envelope-from ) id 1adOsy-0000e4-HV; Tue, 08 Mar 2016 13:09:44 -0800 From: Alistair Francis To: , Date: Tue, 8 Mar 2016 13:06:44 -0800 Message-ID: <2294fcbd404f04c2d787a51a049a14885a9902a5.1457470980.git.alistair.francis@xilinx.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: X-RCIS-Action: ALLOW X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-8.0.0.1202-22178.005 X-TM-AS-Result: No--10.712-7.0-31-10 X-imss-scan-details: No--10.712-7.0-31-10 X-TMASE-MatchedRID: 5HHZS01SLJz/uyguzMmOKBWCVBr+Ay98tZN20SHV1TSneP2LcHykgd/9 N6lK9KH6rLrdQysupgx7XrDFT6+EKZnghuhFDtTnS3OTftLNfg2K6IJmwLQESBwKSCi0KXuE3oz JRX7b4NmOACjEIVDcsTEzpCEHqTDO7PE1ojYEvaH/hOhZ6EJFBQRryDXHx6oXv+26ZYWzwkKZCv kc8xHjBbMmq+VCeSCQiSBtKT/MiwYfE8yM4pjsDwtuKBGekqUpI/NGWt0UYPDRBhLbdDRXNqcoZ TDd67XIs50dZP+4sXHr7UK7iLPTOLi1i/8TVkhs X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.96; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(106466001)(2906002)(105606002)(2950100001)(36756003)(5003940100001)(4326007)(64026002)(77096005)(586003)(229853001)(71366001)(19580395003)(50226001)(19580405001)(1220700001)(118296001)(5003600100002)(48376002)(86362001)(575784001)(87936001)(5008740100001)(85426001)(6806005)(11100500001)(50986999)(33646002)(1096002)(5001770100001)(81166005)(92566002)(189998001)(76176999)(50466002)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1NAM02HT122; H:xsj-tvapsmtpgw01; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 98843aa8-e1df-41a1-1693-08d34795fbe2 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1NAM02HT122; X-Microsoft-Antispam-PRVS: <2bc4d21918364494b2d9e75e5b08812b@SN1NAM02HT122.eop-nam02.prod.protection.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13015025)(13024025)(13017025)(5005006)(8121501046)(13018025)(13023025)(10201501046)(3002001); SRVR:SN1NAM02HT122; BCL:0; PCL:0; RULEID:; SRVR:SN1NAM02HT122; X-Forefront-PRVS: 08756AC3C8 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2016 21:09:46.4562 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.96]; Helo=[xsj-tvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1NAM02HT122 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.38.55 Cc: edgar.iglesias@xilinx.com, alistair.francis@xilinx.com, crosthwaitepeter@gmail.com, edgar.iglesias@gmail.com, alex.bennee@linaro.org, afaerber@suse.de, fred.konrad@greensocs.com Subject: [Qemu-devel] [PATCH v5 06/15] register: QOMify X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Crosthwaite QOMify registers as a child of TYPE_DEVICE. This allows registers to define GPIOs. Define an init helper that will do QOM initialisation. Signed-off-by: Peter Crosthwaite Signed-off-by: Alistair Francis Reviewed-by: KONRAD Frederic --- V5: - Convert to using only one memory region hw/core/register.c | 23 +++++++++++++++++++++++ include/hw/register.h | 15 +++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/hw/core/register.c b/hw/core/register.c index e1cd0c4..28f3776 100644 --- a/hw/core/register.c +++ b/hw/core/register.c @@ -147,6 +147,17 @@ void register_reset(RegisterInfo *reg) register_write_val(reg, reg->access->reset); } +void register_init(RegisterInfo *reg) +{ + assert(reg); + + if (!reg->data || !reg->access) { + return; + } + + object_initialize((void *)reg, sizeof(*reg), TYPE_REGISTER); +} + static inline void register_write_memory(void *opaque, hwaddr addr, uint64_t value, unsigned size, bool be) { @@ -216,3 +227,15 @@ uint64_t register_read_memory_le(void *opaque, hwaddr addr, unsigned size) { return register_read_memory(opaque, addr, size, false); } + +static const TypeInfo register_info = { + .name = TYPE_REGISTER, + .parent = TYPE_DEVICE, +}; + +static void register_register_types(void) +{ + type_register_static(®ister_info); +} + +type_init(register_register_types) diff --git a/include/hw/register.h b/include/hw/register.h index b105d76..d732f55 100644 --- a/include/hw/register.h +++ b/include/hw/register.h @@ -11,6 +11,7 @@ #ifndef REGISTER_H #define REGISTER_H +#include "hw/qdev-core.h" #include "exec/memory.h" typedef struct RegisterInfo RegisterInfo; @@ -79,6 +80,9 @@ struct RegisterAccessInfo { */ struct RegisterInfo { + /* */ + DeviceState parent_obj; + /* */ void *data; int data_size; @@ -91,6 +95,9 @@ struct RegisterInfo { void *opaque; }; +#define TYPE_REGISTER "qemu,register" +#define REGISTER(obj) OBJECT_CHECK(RegisterInfo, (obj), TYPE_REGISTER) + /** * This structure is used to group all of the individual registers which are * modeled using the RegisterInfo strucutre. @@ -136,6 +143,14 @@ uint64_t register_read(RegisterInfo *reg); void register_reset(RegisterInfo *reg); /** + * Initialize a register. GPIO's are setup as IOs to the specified device. + * Fast paths for eligible registers are enabled. + * @reg: Register to initialize + */ + +void register_init(RegisterInfo *reg); + +/** * Memory API MMIO write handler that will write to a Register API register. * _be for big endian variant and _le for little endian. * @opaque: RegisterInfo to write to