From patchwork Thu May 12 22:46:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 621767 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3r5Swf0QBBz9sdn for ; Fri, 13 May 2016 08:54:26 +1000 (AEST) Received: from localhost ([::1]:60127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0zUu-0006Mh-6k for incoming@patchwork.ozlabs.org; Thu, 12 May 2016 18:54:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0zQS-0006rA-UY for qemu-devel@nongnu.org; Thu, 12 May 2016 18:49:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0zQO-0002Ko-2y for qemu-devel@nongnu.org; Thu, 12 May 2016 18:49:48 -0400 Received: from mail-cys01nam02on0051.outbound.protection.outlook.com ([104.47.37.51]:6467 helo=NAM02-CY1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0zQN-0002Kd-NS for qemu-devel@nongnu.org; Thu, 12 May 2016 18:49:44 -0400 Received: from BL2NAM02FT036.eop-nam02.prod.protection.outlook.com (10.152.76.54) by BL2NAM02HT028.eop-nam02.prod.protection.outlook.com (10.152.77.103) with Microsoft SMTP Server (TLS) id 15.1.492.8; Thu, 12 May 2016 22:49:41 +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 BL2NAM02FT036.mail.protection.outlook.com (10.152.77.154) with Microsoft SMTP Server (TLS) id 15.1.492.8 via Frontend Transport; Thu, 12 May 2016 22:49:40 +0000 Received: from 172-16-1-203.xilinx.com ([172.16.1.203]:57385 helo=xsj-tvapsmtp02.xilinx.com) by xsj-tvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1b0zQK-0007gp-Bo; Thu, 12 May 2016 15:49:40 -0700 Received: from [127.0.0.1] (port=37992 helo=tsj-smtp-dlp1.xlnx.xilinx.com) by xsj-tvapsmtp02.xilinx.com with esmtp (Exim 4.63) (envelope-from ) id 1b0zQK-0005fu-8H; Thu, 12 May 2016 15:49:40 -0700 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 u4CMhOjS016027; Thu, 12 May 2016 15:43:24 -0700 Received: from [172.19.74.182] (port=36126 helo=xsjalistai50.xlnx.xilinx.com) by xsj-tvapsmtp02 with esmtp (Exim 4.63) (envelope-from ) id 1b0zQJ-0005fr-8R; Thu, 12 May 2016 15:49:39 -0700 From: Alistair Francis To: , Date: Thu, 12 May 2016 15:46:13 -0700 Message-ID: X-Mailer: git-send-email 2.7.4 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-22316.005 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/LMxULx0EYgBwQNP2crynOVn6nU8YCZ9 6WSCrIKSZCGrA0JSN27ge8TL/D9b7wPsRxCtpf+MLT/qPT6QgAS7+RMq/2CK6rA4c7UV2fQpvi2 PQO/FFQiz2ujrPVx9yEIU1NtMkm0Q== X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.96; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(9170700003)(118296001)(5003600100002)(8936002)(4326007)(71366001)(47776003)(11100500001)(50986999)(586003)(50466002)(33646002)(76176999)(50226002)(81166006)(6806005)(2950100001)(19580395003)(19580405001)(9786002)(5003940100001)(64026002)(85426001)(5008740100001)(1220700001)(106466001)(229853001)(87936001)(5001770100001)(77096005)(36756003)(92566002)(86362001)(2906002)(48376002)(105606002)(189998001)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2NAM02HT028; H:xsj-tvapsmtpgw01; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: cb6173ec-36ac-419b-6b20-08d37ab7b443 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2NAM02HT028; X-Microsoft-Antispam-PRVS: <23357294cec74cba9937eb653476c7bf@BL2NAM02HT028.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)(13024025)(5005006)(8121501046)(13018025)(13017025)(13023025)(13015025)(3002001)(10201501046)(6055026); SRVR:BL2NAM02HT028; BCL:0; PCL:0; RULEID:; SRVR:BL2NAM02HT028; X-Forefront-PRVS: 0940A19703 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2016 22:49:40.9417 (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: BL2NAM02HT028 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.37.51 Subject: [Qemu-devel] [PATCH v6 09/13] qdev: Define qdev_get_gpio_out 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: , 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 Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 db41aa1..e3015d2 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 1ce02b2..0e216af 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -285,6 +285,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,