From patchwork Wed Feb 28 22:32:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 879471 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="hoVQ+sKd"; dkim-atps=neutral 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 3zs9WX1tnrz9s1q for ; Thu, 1 Mar 2018 09:40:40 +1100 (AEDT) Received: from localhost ([::1]:47439 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erAOs-0003QA-Br for incoming@patchwork.ozlabs.org; Wed, 28 Feb 2018 17:40:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erALL-0000rg-QA for qemu-devel@nongnu.org; Wed, 28 Feb 2018 17:37:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1erALH-0008Oq-FF for qemu-devel@nongnu.org; Wed, 28 Feb 2018 17:36:59 -0500 Received: from mail-by2nam01on0058.outbound.protection.outlook.com ([104.47.34.58]:22885 helo=NAM01-BY2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1erALG-0008Mi-Qs for qemu-devel@nongnu.org; Wed, 28 Feb 2018 17:36:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=rmZpJDpBHxAdCjA0gHxpY30m6t6pviEkzTQWDLtFmG0=; b=hoVQ+sKdvccT2jgZH+CYb2GSH7Ho7pGqSL/EkjOTyEWePUqQL0HLh4JoAYWKTVDQwPjhzpu7sQqo3O85c70kzQkHxzEwz25twpj4EjemsxnDnwQH5xwTMo67cv9sg5sbFoK3U/OSmWYmifmondkGgbpf+TBgzS3906ukbJGfugQ= Received: from SN4PR0201CA0058.namprd02.prod.outlook.com (2603:10b6:803:20::20) by SN1PR02MB1312.namprd02.prod.outlook.com (2a01:111:e400:583e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.527.15; Wed, 28 Feb 2018 22:36:50 +0000 Received: from BL2NAM02FT019.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::208) by SN4PR0201CA0058.outlook.office365.com (2603:10b6:803:20::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.548.13 via Frontend Transport; Wed, 28 Feb 2018 22:36:50 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.100 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.100; helo=xsj-pvapsmtpgw02; Received: from xsj-pvapsmtpgw02 (149.199.60.100) by BL2NAM02FT019.mail.protection.outlook.com (10.152.77.166) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.527.18 via Frontend Transport; Wed, 28 Feb 2018 22:36:49 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:56043 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1erALB-0003OK-Km; Wed, 28 Feb 2018 14:36:49 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1erALB-0005pS-IZ; Wed, 28 Feb 2018 14:36:49 -0800 Received: from xsj-pvapsmtp01 (smtp2.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id w1SMagSG003537; Wed, 28 Feb 2018 14:36:42 -0800 Received: from [172.19.2.220] (helo=xsjalistai50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1erAL4-0005oJ-4E; Wed, 28 Feb 2018 14:36:42 -0800 From: Alistair Francis To: , , Date: Wed, 28 Feb 2018 14:32:03 -0800 Message-ID: X-Mailer: git-send-email 2.14.1 In-Reply-To: References: X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.100; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39860400002)(346002)(39380400002)(396003)(376002)(2980300002)(438002)(199004)(189003)(8676002)(50466002)(118296001)(47776003)(26005)(77096007)(186003)(336011)(63266004)(575784001)(2201001)(7696005)(51416003)(36386004)(76176011)(59450400001)(5660300001)(356003)(305945005)(2906002)(106466001)(4326008)(39060400002)(6666003)(54906003)(81156014)(2950100002)(316002)(36756003)(8936002)(9786002)(48376002)(16586007)(478600001)(110136005)(81166006)(50226002)(106002)(107986001)(5001870100001)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR02MB1312; H:xsj-pvapsmtpgw02; FPR:; SPF:Pass; PTR:xapps1.xilinx.com,unknown-60-100.xilinx.com; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2NAM02FT019; 1:yfs+CPZn+dBbyoUYQ+1RXsyb8Nr8d6sQy0eCU9BpYvm/siLb/xrAlKJ4qeuhf5nSQ0Serydi9YX4IT7zYP5KP16Ik+nbS2yWmD+qwpeMNHKmu2GPdQQOL9INFYjFpz2b MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 681a5864-cc01-4267-4bc2-08d57efbc228 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(4608076)(2017052603307)(7153060); SRVR:SN1PR02MB1312; X-Microsoft-Exchange-Diagnostics: 1; SN1PR02MB1312; 3:rQXRih9LrGmHByYg7Z4ZIs35N62RS7BsnTqV6BhgaAExwtFx4gcTkj6vA+eghe2EyAbX4RSNE3/YI1EnStSObCfYjPMUR18rWlbrFHTso7g3ZzA0h7CKxyRzqIzRSKSx8Q9ZLYnaw2tVdmnc8rprxuqTcR68awHn/cPm1QX3JNjWdaEw/0tJY7YDAuNzuz/CX+NUauM27FNGdoZ3I4j1DcuP596Jr+0IjjkfeQOf8/ilNfuhWeX08QGBbVWRS1Drp/Ow9RzRwo1Xp6eqMTPeeMuiijoU2jYq0q1Pw2605U7MnNwm4gSwguQktpRSWTNUVVhgg9u44BTRc/IGcgq++K5HKdRD0dJK7XrRFy58btc=; 25:rC22P5N/J+IQoZmXJ3CIwUJaDlk5kckLvxHMgwGMHS93/aOi7F2l0qdtmocDH4Dcru+sK+8qnZdQ7iRSMcP3osllHCYAXAqkOhA8KByBv0IL7go08wh+s/rZDgoFgZp6LctnL6t1bAeqSBP+YRAAg3Q84On+zOmNRkYI8JaSiqgRDyMxC3Kfv1OrlTYDq84q5AmloBFn/mdituXuGwAGg9uqZ722ySZUWZPAPovjf7czvrp2zHbE6pi91tuEvnmqzC5FGSMsNyyUCi8kLW6L5YcROOaC16QnUGd3YH52wxXTrjf0W7RhnddI1zbpUe7pUIwOjDHSrQrLPNd3yj07BHxeuvrvo02hV1kus7Rtjps= X-MS-TrafficTypeDiagnostic: SN1PR02MB1312: X-Microsoft-Exchange-Diagnostics: 1; SN1PR02MB1312; 31:s7NlNXjBKZ4/f/fS2Sr0H/PFWJFI0zgmVduJMWBYwhf/4xJvd/vIjucR/wBbRWLIKqpWrfHAj0sVTgdqVUFQe23ten1AKS6ZcyPUD5Qc+bZVnATNEiXC+iM/J6cejH3x2LQfHtDuIUNs4u5u6QaDs64eoY623DvGS5w/J445n9r6i4w8vElTkizENDS1mKjW5YQQPQ4L4FWPa4fz9HQj4L6OiVGfUnjlnZKgJ9nSkLs=; 20:CC/J3Rqx8BYw+te0BRF1ybJrMMhnVKADzH27druI+Bkg1bFPVgAVSgiGjmMQL0lVvraLoOIBBV1zPswMJVQ/L5MWmOD49Y5+cs+791IFMQcZ8WyCN5YMovbTdQmLTNtZ+M9f2Ro+6AcFjoizFl0f/RqglbL1RaeWPxRVJvthcS+E/wIZFBxY8NnDSeglKW+kYmn7IaGt5mjDTrGHdH206DRFMnISGK7X6zvmFxyDh/AJvMasm38EHKU1WZ+M85iXUvyqLdkN1dzfgkNdZ93I5Z0t1xaNpDZddOaW2xiyQPw1yw0k4EwottMX2iLI+Kr7txCj9vqPRE9PqaeELUdv/bJxqtBwh9Lt648JFxWaGi4cva1ud0H8s1UWZWAmgpb7LfBoBEzk5muZkz/+Mg80ao75C3S+V+kQzja2mhSTtomCB5nDTyrexz/048jtyhfanV18j7j1ZKkZHuMj/I1SP53EpYtUrfNEv9C0d+PbKJ514cKHn+ZY7/bB1rOI89f4 X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040501)(2401047)(8121501046)(5005006)(3002001)(3231220)(944501220)(52105095)(93006095)(93004095)(10201501046)(6055026)(6041288)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:SN1PR02MB1312; BCL:0; PCL:0; RULEID:; SRVR:SN1PR02MB1312; X-Microsoft-Exchange-Diagnostics: 1; SN1PR02MB1312; 4:yH2CXQ8bDvJZ705GDSy03OZJ2luklzsEX9UDzXGQOxOfy1FL0ecPiOf1PoeJ4VRxarErmbDmqN+qfEjb7yYg9w7Y33Dr8rDZz8zBB+g8WPRQlk1usCokO72FWaeIq48vGtTJ+SK4o5rceH82iNRUlO36Xr9lh136AVl67o7GhphPHJkzAbefYSB7/RL0nCFgt4Qc+exxxLNkNjkIJ905kyZ4irYue+o39b+Jm9jjWEGvNtkOtgGwFmB8tv78lWccK3rZBH+Hlmm7rAdP6GCTWItBjW7SvAbVZIg1BaqbOT/17UtHGuKwAUcIGhQ/A9Yu X-Forefront-PRVS: 0597911EE1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR02MB1312; 23:7icqPD2jqPsQGkY2qMig+h0v3qMdGkTKcSwNr/66e?= UDLoJ5xo0We3zxwu6zEkaPfasw7N6EXwfIYr44FqRmVTgXHfXA0pzWFY5wndKBEKFrKZKMsMVNyD9BaO+XN4IYHLtx1VPPzBkL8ls8GHcMEn2jdRDvFkyjSD/KAGo7Uf8yxQM+n2jC8H/ge968tKgwF8d23e6yth7/wq6z5NEnbpdATtH0dPLuf/T9APx+PfFHXnF6mHj8bkSujgwuAru8v+uyHRLTxDQ8fgd4sNFYItk1fQ1jKQVme003ypZRZml0H99WaUd1V8sKNu1MYU9zPaRu6tq0pm29NIl5VDhUra3tPvYie0LgLwPquM9OAeR9ROX0Km9eLZe7iQk2yekca8dgN2cn1MhD60MM7v42VxjhWRzLsHrmzoVjefBvbmPBPlqgQhFWtEHXOrdpSfVQ7Bx40D5OyhevF/zwN0RnHgsfyi652q+jXEkc6jKOLahzUHwL+/sNboXsOZj4CQjCNwiErnkHJS7XXXFIMiEEdsMdQvxf6feRzpiCgNLNtdT0E+ZQ1MDCAtBFtD+Evn0KHmRF4IhK4UR/Zefmdxh5/o0FNpcWStWj8mlhPLvUsLrsrSi/D9XoTwB4ZbTOinnIPZx+stWFOnq/faj4NvlLykewGAFSPPq724EVQ+6w56zngqm+pzuba2gQjX4PvqA82ASCWZedCPecMx8HL0sLyyx64tsIW6Wj7+0NlspjcMX9qr7NagtL+HADN8mSrdLE99CjKEy+atn6v6i9voGzPYVDruTu1Lq/qu++lgd72gN12tIlD0ZvnHQQfw9JY9SAgZ+tJlnU8ZBpATB/If68fx6XgjH2dElSrEEE5rh17iuKiCCYqqppaNXWcgEmq1Xyo83pL+UO8/X6VohTByiwnAh8fnF4vVnkqMJIPYKT10D+Rytm0P0lOYeDaUNAlw2GKPDPOXrJqPGW2T9xUVMS7qOFfWJnJspZ5CD9hXZF7QZJ0FX5uw5CA9cSOUQ/8A6Uiz0XKvRybo0x8P41QNLl+RMvrtTqlh79aTkyfxz+YAT0+6wKlg6J1mjHeyFWeFwx8YUVcbL19EU4tO7dnoUKvqPrRyrk6eXf1MxPPXSjwM9i9j68nhlTP1EhsUoNV9cVeGPHNwbUvt8rk7q/QPDtJKA== X-Microsoft-Exchange-Diagnostics: 1; SN1PR02MB1312; 6:KgN2UgGY5JcTZkQY9ueaDIECDSM37srUh6p6qKIT7OKN/3eaBB1Ya+ASrTe1ukpgPDWTE1+/99SQbO76onu7hmqkpZGq4PDEesyjg69rM6pb9x1KCvgD8GGiA8OkFcIfZFRIy9hdKzpGz27MqyI4WUiIiyQK3Ex+wiw0mK7NxUiLYLqjuxz7XY+rjLBpY1fwHOonKCLJFNr2sG/5Zw/0WtWr+oHNHhvcDRi0ViF8veiHRaow9IqNwuNTCMv5quSKNWhu41a58OYtWdD5JheoUOsTwkjXdbYYvWoG9Gij20ghn00M6BehV0DnUiduVzmFkYe82337F9mTRTcnCRUTDTGjTquKeNKQkK//KnbyUlA=; 5:R1y8SCStcoXPjCYd1/a8aLMV0MGQaKwqlEvp4HI5vQJHkgVw8f4iFmee2t5gimzxWzerd5rVVSh6g4JcNIpextAT1i1DIiwZbyk8L1D27+pw0NRykaSODEi/hzHLLzYB5MRu03sqmzl8Pf4DoqkThTDuHtpK9rf1mqqqF4TMZ/4=; 24:6YPlQsJjpOK3OgHvEfUEDBQUFz1VFuxi5Pjqun64Nd1prI1t8PTeQa0llwJ+s4Waj4vpcbjMSjnJnYMYPZV+/eYVqzI/tdQuXVBFumern6I=; 7:exYDYVhAgFaTDAYprc/L/+BdZj6rEdbeJLO/9jVxSGWB8QK9Bv2NvSdqMtlQL4Nsn5YIjV+h4gq9fjEJgeA7/9mkraPVdwyJFgOeeDrLAjN/TNAYEr/PPGpdAk9u3lnptKOduZSDMhQw5ra9Uk3q8KoiREPcPCrTmgyX/x+BbYg9lkb+1plJfYSP8RaGCI4fI/626Jq6UftqzYK8VEDln8iVYoxf//45KnylFpN5CtMAUKsJSAYQRPWCH+aFaT05 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2018 22:36:49.9136 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 681a5864-cc01-4267-4bc2-08d57efbc228 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.100]; Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR02MB1312 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.34.58 Subject: [Qemu-devel] [PATCH v2 3/5] hw/gpio: Add the xlnx-pmu-iomod-gpo 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: , Cc: alistair23@gmail.com, alistair.francis@xilinx.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé --- include/hw/gpio/xlnx-pmu-iomod-gp.h | 52 +++++++++++++ hw/gpio/xlnx-pmu-iomod-gp.c | 150 ++++++++++++++++++++++++++++++++++++ hw/gpio/Makefile.objs | 2 + 3 files changed, 204 insertions(+) create mode 100644 include/hw/gpio/xlnx-pmu-iomod-gp.h create mode 100644 hw/gpio/xlnx-pmu-iomod-gp.c diff --git a/include/hw/gpio/xlnx-pmu-iomod-gp.h b/include/hw/gpio/xlnx-pmu-iomod-gp.h new file mode 100644 index 0000000000..0ee162829b --- /dev/null +++ b/include/hw/gpio/xlnx-pmu-iomod-gp.h @@ -0,0 +1,52 @@ +/* + * QEMU model of Xilinx I/O Module GPO + * + * Copyright (c) 2013 Xilinx Inc + * Written by Edgar E. Iglesias + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef HW_XLNX_ZYNQMP_IOMOD_GPIO_H +#define HW_XLNX_ZYNQMP_IOMOD_GPIO_H + +#include "qemu/osdep.h" + +#define TYPE_XLNX_ZYNQMP_IOMOD_GPIO "xlnx.pmu_iomodule_gpio" + +#define XLNX_ZYNQMP_IOMOD_GPIO(obj) \ + OBJECT_CHECK(XlnxPMUIOGPIO, (obj), TYPE_XLNX_ZYNQMP_IOMOD_GPIO) + +#define XLNX_ZYNQMP_IOMOD_GPIO_R_MAX (0x00 + 1) + +typedef struct XlnxPMUIOGPIO { + SysBusDevice parent_obj; + MemoryRegion iomem; + + uint32_t size; + + /* GPO */ + uint32_t init; + qemu_irq outputs[32]; + + uint32_t regs[XLNX_ZYNQMP_IOMOD_GPIO_R_MAX]; + RegisterInfo regs_info[XLNX_ZYNQMP_IOMOD_GPIO_R_MAX]; +} XlnxPMUIOGPIO; + +#endif /* HW_XLNX_ZYNQMP_IOMOD_GPIO_H */ diff --git a/hw/gpio/xlnx-pmu-iomod-gp.c b/hw/gpio/xlnx-pmu-iomod-gp.c new file mode 100644 index 0000000000..0e45a89b44 --- /dev/null +++ b/hw/gpio/xlnx-pmu-iomod-gp.c @@ -0,0 +1,150 @@ +/* + * QEMU model of Xilinx I/O Module GPO + * + * Copyright (c) 2013 Xilinx Inc + * Written by Edgar E. Iglesias + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "hw/sysbus.h" +#include "hw/register.h" +#include "qemu/log.h" +#include "hw/gpio/xlnx-pmu-iomod-gp.h" + +#ifndef XLNX_ZYNQMP_IOMOD_GPIO_DEBUG +#define XLNX_ZYNQMP_IOMOD_GPIO_DEBUG 0 +#endif + +REG32(GPO0, 0x00) + +static void xlnx_iomod_gpio_gpo0_prew(RegisterInfo *reg, uint64_t value) +{ + XlnxPMUIOGPIO *s = XLNX_ZYNQMP_IOMOD_GPIO(reg->opaque); + unsigned int i; + + for (i = 0; i < s->size; i++) { + bool flag = !!(value & (1 << i)); + qemu_set_irq(s->outputs[i], flag); + } +} + +static uint64_t xlnx_iomod_gpio_gpo0_postr(RegisterInfo *reg, uint64_t value) +{ + return 0; +} + +static const RegisterAccessInfo xlnx_iomod_gpio_regs_info[] = { + { .name = "GPO0", .addr = A_GPO0, + .post_write = xlnx_iomod_gpio_gpo0_prew, + .post_read = xlnx_iomod_gpio_gpo0_postr, + } +}; + +static void xlnx_iomod_gpio_reset(DeviceState *dev) +{ + XlnxPMUIOGPIO *s = XLNX_ZYNQMP_IOMOD_GPIO(dev); + int i; + + for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { + register_reset(&s->regs_info[i]); + } + + xlnx_iomod_gpio_gpo0_prew(&s->regs_info[R_GPO0], s->init); +} + +static const MemoryRegionOps xlnx_iomod_gpio_ops = { + .read = register_read_memory, + .write = register_write_memory, + .endianness = DEVICE_LITTLE_ENDIAN, + .valid = { + .min_access_size = 4, + .max_access_size = 4, + }, +}; + +static void xlnx_iomod_gpio_realize(DeviceState *dev, Error **errp) +{ + XlnxPMUIOGPIO *s = XLNX_ZYNQMP_IOMOD_GPIO(dev); + + assert(s->size <= 32); + qdev_init_gpio_out(dev, s->outputs, s->size); +} + +static void xlnx_iomod_gpio_init(Object *obj) +{ + XlnxPMUIOGPIO *s = XLNX_ZYNQMP_IOMOD_GPIO(obj); + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); + RegisterInfoArray *reg_array; + + memory_region_init(&s->iomem, obj, TYPE_XLNX_ZYNQMP_IOMOD_GPIO, + XLNX_ZYNQMP_IOMOD_GPIO_R_MAX * 4); + reg_array = + register_init_block32(DEVICE(obj), xlnx_iomod_gpio_regs_info, + ARRAY_SIZE(xlnx_iomod_gpio_regs_info), + s->regs_info, s->regs, + &xlnx_iomod_gpio_ops, + XLNX_ZYNQMP_IOMOD_GPIO_DEBUG, + XLNX_ZYNQMP_IOMOD_GPIO_R_MAX * 4); + memory_region_add_subregion(&s->iomem, + 0x0, + ®_array->mem); + sysbus_init_mmio(sbd, &s->iomem); +} + +static const VMStateDescription vmstate_xlnx_iomod_gpio = { + .name = TYPE_XLNX_ZYNQMP_IOMOD_GPIO, + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_END_OF_LIST(), + } +}; + +static Property xlnx_iomod_gpio_properties[] = { + DEFINE_PROP_UINT32("size", XlnxPMUIOGPIO, size, 0), + DEFINE_PROP_UINT32("gpo-init", XlnxPMUIOGPIO, init, 0), + DEFINE_PROP_END_OF_LIST(), +}; + +static void xlnx_iomod_gpio_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->reset = xlnx_iomod_gpio_reset; + dc->realize = xlnx_iomod_gpio_realize; + dc->props = xlnx_iomod_gpio_properties; + dc->vmsd = &vmstate_xlnx_iomod_gpio; +} + +static const TypeInfo xlnx_iomod_gpio_info = { + .name = TYPE_XLNX_ZYNQMP_IOMOD_GPIO, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(XlnxPMUIOGPIO), + .class_init = xlnx_iomod_gpio_class_init, + .instance_init = xlnx_iomod_gpio_init, +}; + +static void xlnx_iomod_gpio_register_types(void) +{ + type_register_static(&xlnx_iomod_gpio_info); +} + +type_init(xlnx_iomod_gpio_register_types) diff --git a/hw/gpio/Makefile.objs b/hw/gpio/Makefile.objs index fa0a72e6d0..4cefadee85 100644 --- a/hw/gpio/Makefile.objs +++ b/hw/gpio/Makefile.objs @@ -8,3 +8,5 @@ common-obj-$(CONFIG_GPIO_KEY) += gpio_key.o obj-$(CONFIG_OMAP) += omap_gpio.o obj-$(CONFIG_IMX) += imx_gpio.o obj-$(CONFIG_RASPI) += bcm2835_gpio.o + +obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-pmu-iomod-gp.o