From patchwork Tue Jan 19 22:35:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 8065581 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 21BF6BEEE5 for ; Tue, 19 Jan 2016 22:43:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 829432052A for ; Tue, 19 Jan 2016 22:43:15 +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 B6A6F2045E for ; Tue, 19 Jan 2016 22:43:14 +0000 (UTC) Received: from localhost ([::1]:39518 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLeza-00026W-7F for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Jan 2016 17:43:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLeuQ-0000lO-Km for qemu-devel@nongnu.org; Tue, 19 Jan 2016 17:37:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLeuN-0003sm-9H for qemu-devel@nongnu.org; Tue, 19 Jan 2016 17:37:54 -0500 Received: from mail-bl2nam02on0066.outbound.protection.outlook.com ([104.47.38.66]:24520 helo=NAM02-BL2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLeuN-0003sf-40 for qemu-devel@nongnu.org; Tue, 19 Jan 2016 17:37:51 -0500 Received: from SN1NAM02FT013.eop-nam02.prod.protection.outlook.com (10.152.72.52) by SN1NAM02HT099.eop-nam02.prod.protection.outlook.com (10.152.73.99) with Microsoft SMTP Server (TLS) id 15.1.355.15; Tue, 19 Jan 2016 22:37:49 +0000 Authentication-Results: spf=fail (sender IP is 149.199.60.96) smtp.mailfrom=xilinx.com; suse.de; dkim=none (message not signed) header.d=none; suse.de; 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 SN1NAM02FT013.mail.protection.outlook.com (10.152.72.98) with Microsoft SMTP Server (TLS) id 15.1.355.15 via Frontend Transport; Tue, 19 Jan 2016 22:37:48 +0000 Received: from 172-16-1-203.xilinx.com ([172.16.1.203]:34462 helo=xsj-tvapsmtp02.xilinx.com) by xsj-tvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1aLeuK-0008R3-4z; Tue, 19 Jan 2016 14:37:48 -0800 Received: from [127.0.0.1] (port=41681 helo=tsj-smtp-dlp1.xlnx.xilinx.com) by xsj-tvapsmtp02.xilinx.com with esmtp (Exim 4.63) (envelope-from ) id 1aLeuJ-0007h8-Vn; Tue, 19 Jan 2016 14:37:48 -0800 Received: from xsj-tvapsmtp02 (smtptest.xilinx.com [172.16.1.203]) by tsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u0JMWEk6015279; Tue, 19 Jan 2016 14:32:14 -0800 Received: from [172.19.74.182] (port=39726 helo=xsjalistai50.xlnx.xilinx.com) by xsj-tvapsmtp02 with esmtp (Exim 4.63) (envelope-from ) id 1aLeuJ-0007h5-7l; Tue, 19 Jan 2016 14:37:47 -0800 From: Alistair Francis To: Date: Tue, 19 Jan 2016 14:35:20 -0800 Message-ID: <081cdaf70459a467622cdebd83e30c72ae16f251.1453237258.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-22054.006 X-TM-AS-Result: No--1.785-7.0-31-10 X-imss-scan-details: No--1.785-7.0-31-10 X-TMASE-MatchedRID: I4WY2Dgn0Ph37FC663+5pxAN/SFMteFxmoKXVHfiMM/JYIv7y0tu9uO/ ytE9sHcwTu39anhUL2LqPiG7FulJ0xLmJd2F/yFuyeVujmXuYYVoo6Z+9srk3psoi2XrUn/J8m+ hzBStant2CRFHw6Iz/ydET58jp62S8AwdjRZ9G8SnwI/LMxULx0EYgBwQNP2crynOVn6nU8ZQWv jl9vhjyOkQBBWzgvcJqWhiu5TfMGx9ZoGhXFhnnD4jcv9O/Cg4S7+RMq/2CK6rA4c7UV2fQpvi2 PQO/FFQiz2ujrPVx9yEIU1NtMkm0Q== 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)(189002)(199003)(105606002)(33646002)(106466001)(19580405001)(2950100001)(6806005)(77096005)(1096002)(5008740100001)(87936001)(19580395003)(50226001)(48376002)(2906002)(11100500001)(86362001)(50466002)(2351001)(47776003)(50986999)(5003940100001)(5001960100002)(85426001)(586003)(36756003)(110136002)(64026002)(92566002)(118296001)(81156007)(189998001)(71366001)(5003600100002)(229853001)(76176999)(4326007)(1220700001)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1NAM02HT099; H:xsj-tvapsmtpgw01; FPR:; SPF:Fail; PTR:unknown-60-96.xilinx.com; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: c36b151d-43c7-4306-2959-08d3212128c6 X-Exchange-Antispam-Report-Test: UriScan:; BCL:0; PCL:0; RULEID:; SRVR:SN1NAM02HT099; UriScan:(192813158149592); X-Microsoft-Antispam-PRVS: <81e1d5e680a44dc5afeba358b77cc452@SN1NAM02HT099.eop-nam02.prod.protection.outlook.com> X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13018025)(8121501046)(13017025)(13015025)(5005006)(520078)(13023025)(13024025)(10201501046)(3002001); SRVR:SN1NAM02HT099; BCL:0; PCL:0; RULEID:; SRVR:SN1NAM02HT099; X-Forefront-PRVS: 0826B2F01B X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2016 22:37:48.8584 (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: SN1NAM02HT099 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.38.66 Cc: edgar.iglesias@xilinx.com, peter.maydell@linaro.org, alistair.francis@xilinx.com, crosthwaitepeter@gmail.com, edgar.iglesias@gmail.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v2 11/16] qdev: Define qdev_get_gpio_out 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 An API similar to the existing qdev_get_gpio_in() except gets outputs. Useful for: 1: Implementing lightweight devices that don't want to keep pointers to their own GPIOs. They can get their GPIO pointers at runtime from QOM using this API. 2: testing or debugging code which may wish to override the hardware generated value of of a GPIO with a user specified value (E.G. interrupt injection). Signed-off-by: Peter Crosthwaite Signed-off-by: Alistair Francis --- hw/core/qdev.c | 12 ++++++++++++ include/hw/qdev-core.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 2c7101d..308e4a1 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -489,6 +489,18 @@ qemu_irq qdev_get_gpio_in(DeviceState *dev, int n) return qdev_get_gpio_in_named(dev, NULL, n); } +qemu_irq qdev_get_gpio_out_named(DeviceState *dev, const char *name, int n) +{ + char *propname = g_strdup_printf("%s[%d]", + name ? name : "unnamed-gpio-out", n); + return (qemu_irq)object_property_get_link(OBJECT(dev), propname, NULL); +} + +qemu_irq qdev_get_gpio_out(DeviceState *dev, int n) +{ + return qdev_get_gpio_out_named(dev, NULL, n); +} + void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n, qemu_irq pin) { diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index abcdee8..0a09b8a 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -287,6 +287,8 @@ bool qdev_machine_modified(void); qemu_irq qdev_get_gpio_in(DeviceState *dev, int n); qemu_irq qdev_get_gpio_in_named(DeviceState *dev, const char *name, int n); +qemu_irq qdev_get_gpio_out(DeviceState *dev, int n); +qemu_irq qdev_get_gpio_out_named(DeviceState *dev, const char *name, int n); void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin); void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n,