From patchwork Thu May 12 22:46:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 9086751 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 2333EBF29F for ; Thu, 12 May 2016 22:57:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 41D0C2021A for ; Thu, 12 May 2016 22:57:24 +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 17AF1201CE for ; Thu, 12 May 2016 22:57:23 +0000 (UTC) Received: from localhost ([::1]:60155 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0zXm-0003bm-CB for patchwork-qemu-devel@patchwork.kernel.org; Thu, 12 May 2016 18:57:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0zQY-00070c-JC for qemu-devel@nongnu.org; Thu, 12 May 2016 18:49:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0zQU-0002Lm-51 for qemu-devel@nongnu.org; Thu, 12 May 2016 18:49:53 -0400 Received: from mail-bl2nam02on0050.outbound.protection.outlook.com ([104.47.38.50]:32755 helo=NAM02-BL2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0zQU-0002Lg-03 for qemu-devel@nongnu.org; Thu, 12 May 2016 18:49:50 -0400 Received: from BL2NAM02FT026.eop-nam02.prod.protection.outlook.com (10.152.76.55) by BL2NAM02HT031.eop-nam02.prod.protection.outlook.com (10.152.76.73) with Microsoft SMTP Server (TLS) id 15.1.492.8; Thu, 12 May 2016 22:49:48 +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 BL2NAM02FT026.mail.protection.outlook.com (10.152.77.156) with Microsoft SMTP Server (TLS) id 15.1.492.8 via Frontend Transport; Thu, 12 May 2016 22:49:48 +0000 Received: from 172-16-1-203.xilinx.com ([172.16.1.203]:57406 helo=xsj-tvapsmtp02.xilinx.com) by xsj-tvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1b0zQR-0007gy-I3; Thu, 12 May 2016 15:49:47 -0700 Received: from [127.0.0.1] (port=38014 helo=tsj-smtp-dlp1.xlnx.xilinx.com) by xsj-tvapsmtp02.xilinx.com with esmtp (Exim 4.63) (envelope-from ) id 1b0zQR-0005gL-Fp; Thu, 12 May 2016 15:49:47 -0700 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 u4CMhV1M016039; Thu, 12 May 2016 15:43:32 -0700 Received: from [172.19.74.182] (port=36134 helo=xsjalistai50.xlnx.xilinx.com) by xsj-tvapsmtp02 with esmtp (Exim 4.63) (envelope-from ) id 1b0zQQ-0005gI-L0; Thu, 12 May 2016 15:49:46 -0700 From: Alistair Francis To: , Date: Thu, 12 May 2016 15:46:21 -0700 Message-ID: <1f1c046dab32038cae9cde7a3ed9b93863f3b3cb.1463093051.git.alistair.francis@xilinx.com> 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--14.069-7.0-31-10 X-imss-scan-details: No--14.069-7.0-31-10 X-TMASE-MatchedRID: 0GLaK6Fr/ewdLPf4wYvhgfnCl+sgkNd7/3SuiWnIBLsvM0Gdq0fzqSvR mSs3bLLrtlzui8kfp9+gGOZ3m2LY510BBmTIE0cJuIwLnB3Aqp2WHGENdT+VP/yP/Dwocml3LJb swLUY6eHpqfRwQ2lroFE2Nala7ShfBb95QfAlOsh0BEBFOTiHn0EKKv3+tzX75Aihb6iR3snHp/ 8+EGjK8GXqc2R50DiassrXC6I71T3m/rLlT+R1sZVRzPxemJL0IWrhso05H/UcXmBZ3mI5SXR+K 6XFupgQQZo9f5IxepDqeGKysj4p1jN6CsG02nkoHOx1Vder/0sjo8c0NkYYIrStxTlX+hJ7fgzZ AgJekeMXhp1hWpo6RWOy/BluF3tCxkSgnHUeW2XhG1IOMb7PsObVJDm0C8mjfmHrLgoJIlx0TsA FB/Ez16BW1QEmGLzrUBhe7+FKfBebGHSBj+j5WfGBihrnFyBP9uT35pz6g++afu7GwPW5Jo2n3C Vm0yC54vM1YF6AJbbCCfuIMF6xLSAHAopEd76vffYtwFE5vrc3/6tYuUpEEWN+cOCIrB0T2xePu fGynPOO4VGiSJFUDA== X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.96; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(9170700003)(47776003)(5001770100001)(2950100001)(229853001)(9786002)(50226002)(105606002)(106466001)(1220700001)(2906002)(4326007)(81166006)(92566002)(586003)(19580395003)(19580405001)(6806005)(5008740100001)(50986999)(71366001)(11100500001)(76176999)(189998001)(77096005)(33646002)(50466002)(8936002)(118296001)(36756003)(86362001)(87936001)(85426001)(64026002)(5003940100001)(48376002)(5003600100002)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2NAM02HT031; H:xsj-tvapsmtpgw01; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: bde0ee38-b889-439e-bbc9-08d37ab7b8ad X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2NAM02HT031; X-Microsoft-Antispam-PRVS: <0981ebdbc859480daea6afef4aa2c499@BL2NAM02HT031.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)(13017025)(13015025)(13018025)(13023025)(13024025)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:BL2NAM02HT031; BCL:0; PCL:0; RULEID:; SRVR:BL2NAM02HT031; X-Forefront-PRVS: 0940A19703 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2016 22:49:48.2400 (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: BL2NAM02HT031 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.38.50 Subject: [Qemu-devel] [PATCH v6 12/13] misc: Introduce ZynqMP IOU SLCR 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 IOU = I/O Unit SLCR = System Level Control Registers This IP is a misc collections of control registers that switch various properties of system IPs. Currently the only thing implemented is the SD_SLOTTYPE control (implemented as a GPIO output). Signed-off-by: Peter Crosthwaite Signed-off-by: Alistair Francis --- hw/misc/Makefile.objs | 1 + hw/misc/xlnx-zynqmp-iou-slcr.c | 115 +++++++++++++++++++++++++++++++++ include/hw/misc/xlnx-zynqmp-iou-slcr.h | 47 ++++++++++++++ 3 files changed, 163 insertions(+) create mode 100644 hw/misc/xlnx-zynqmp-iou-slcr.c create mode 100644 include/hw/misc/xlnx-zynqmp-iou-slcr.h diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs index 93f9528..d772c50 100644 --- a/hw/misc/Makefile.objs +++ b/hw/misc/Makefile.objs @@ -42,6 +42,7 @@ obj-$(CONFIG_RASPI) += bcm2835_property.o obj-$(CONFIG_SLAVIO) += slavio_misc.o obj-$(CONFIG_ZYNQ) += zynq_slcr.o obj-$(CONFIG_ZYNQ) += zynq-xadc.o +obj-$(CONFIG_ZYNQ) += xlnx-zynqmp-iou-slcr.o obj-$(CONFIG_STM32F2XX_SYSCFG) += stm32f2xx_syscfg.o obj-$(CONFIG_MIPS_CPS) += mips_cmgcr.o obj-$(CONFIG_MIPS_CPS) += mips_cpc.o diff --git a/hw/misc/xlnx-zynqmp-iou-slcr.c b/hw/misc/xlnx-zynqmp-iou-slcr.c new file mode 100644 index 0000000..00b617e --- /dev/null +++ b/hw/misc/xlnx-zynqmp-iou-slcr.c @@ -0,0 +1,115 @@ +/* + * Xilinx ZynqMP IOU System Level Control Registers (SLCR) + * + * Copyright (c) 2013 Xilinx Inc + * Copyright (c) 2013 Peter Crosthwaite + * + * 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/misc/xlnx-zynqmp-iou-slcr.h" + +#ifndef XLNX_ZYNQMP_IOU_SLCR_ERR_DEBUG +#define XLNX_ZYNQMP_IOU_SLCR_ERR_DEBUG 0 +#endif + +REG32(SD_SLOTTYPE, 0x310) + #define R_SD_SLOTTYPE_RSVD 0xffff7ffe + +static const RegisterAccessInfo xlnx_zynqmp_iou_slcr_regs_info[] = { + { .name = "SD Slot TYPE", .decode.addr = A_SD_SLOTTYPE, + .rsvd = R_SD_SLOTTYPE_RSVD, + .gpios = (RegisterGPIOMapping []) { + { .name = "SD0_SLOTTYPE", .bit_pos = 0 }, + { .name = "SD1_SLOTTYPE", .bit_pos = 15 }, + {}, + } + } + /* FIXME: Complete device model */ +}; + +static void xlnx_zynqmp_iou_slcr_reset(DeviceState *dev) +{ + XlnxZynqMPIOUSLCR *s = XLNX_ZYNQMP_IOU_SLCR(dev); + int i; + + for (i = 0; i < XLNX_ZYNQ_MP_IOU_SLCR_R_MAX; ++i) { + register_reset(&s->regs_info[i]); + } +} + +static const MemoryRegionOps xlnx_zynqmp_iou_slcr_ops = { + .read = register_read_memory_le, + .write = register_write_memory_le, + .endianness = DEVICE_LITTLE_ENDIAN, + .valid = { + .min_access_size = 4, + .max_access_size = 4, + } +}; + +static void xlnx_zynqmp_iou_slcr_init(Object *obj) +{ + XlnxZynqMPIOUSLCR *s = XLNX_ZYNQMP_IOU_SLCR(obj); + + memory_region_init(&s->iomem, obj, "MMIO", XLNX_ZYNQ_MP_IOU_SLCR_R_MAX * 4); + register_init_block32(DEVICE(obj), xlnx_zynqmp_iou_slcr_regs_info, + ARRAY_SIZE(xlnx_zynqmp_iou_slcr_regs_info), + s->regs_info, s->regs, &s->iomem, + &xlnx_zynqmp_iou_slcr_ops, + XLNX_ZYNQMP_IOU_SLCR_ERR_DEBUG, + XLNX_ZYNQ_MP_IOU_SLCR_R_MAX); + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem); +} + +static const VMStateDescription vmstate_xlnx_zynqmp_iou_slcr = { + .name = "xlnx_zynqmp_iou_slcr", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT32_ARRAY(regs, XlnxZynqMPIOUSLCR, + XLNX_ZYNQ_MP_IOU_SLCR_R_MAX), + VMSTATE_END_OF_LIST(), + } +}; + +static void xlnx_zynqmp_iou_slcr_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->reset = xlnx_zynqmp_iou_slcr_reset; + dc->vmsd = &vmstate_xlnx_zynqmp_iou_slcr; +} + +static const TypeInfo xlnx_zynqmp_iou_slcr_info = { + .name = TYPE_XLNX_ZYNQMP_IOU_SLCR, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(XlnxZynqMPIOUSLCR), + .class_init = xlnx_zynqmp_iou_slcr_class_init, + .instance_init = xlnx_zynqmp_iou_slcr_init, +}; + +static void xlnx_zynqmp_iou_slcr_register_types(void) +{ + type_register_static(&xlnx_zynqmp_iou_slcr_info); +} + +type_init(xlnx_zynqmp_iou_slcr_register_types) diff --git a/include/hw/misc/xlnx-zynqmp-iou-slcr.h b/include/hw/misc/xlnx-zynqmp-iou-slcr.h new file mode 100644 index 0000000..b3bcb19 --- /dev/null +++ b/include/hw/misc/xlnx-zynqmp-iou-slcr.h @@ -0,0 +1,47 @@ +/* + * Xilinx ZynqMP IOU system level control registers (SLCR) + * + * Copyright (c) 2013 Xilinx Inc + * Copyright (c) 2013 Peter Crosthwaite + * + * 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 "hw/sysbus.h" +#include "hw/register.h" + +#define TYPE_XLNX_ZYNQMP_IOU_SLCR "xlnx_zynqmp-iou-slcr" + +#define XLNX_ZYNQMP_IOU_SLCR(obj) \ + OBJECT_CHECK(XlnxZynqMPIOUSLCR, (obj), TYPE_XLNX_ZYNQMP_IOU_SLCR) + +#define XLNX_ZYNQ_MP_IOU_SLCR_R_MAX (0x314 / 4) + +typedef struct XlnxZynqMPIOUSLCR XlnxZynqMPIOUSLCR; + +struct XlnxZynqMPIOUSLCR { + /*< private >*/ + SysBusDevice busdev; + + /*< public >*/ + MemoryRegion iomem; + + uint32_t regs[XLNX_ZYNQ_MP_IOU_SLCR_R_MAX]; + RegisterInfo regs_info[XLNX_ZYNQ_MP_IOU_SLCR_R_MAX]; +};