From patchwork Fri Apr 24 19:31:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 464390 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 0BA1C140079 for ; Sat, 25 Apr 2015 05:36:52 +1000 (AEST) Received: from localhost ([::1]:46217 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YljP8-0002Uc-0I for incoming@patchwork.ozlabs.org; Fri, 24 Apr 2015 15:36:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YljK2-0002Gz-Lw for qemu-devel@nongnu.org; Fri, 24 Apr 2015 15:31:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YljJz-0007im-5a for qemu-devel@nongnu.org; Fri, 24 Apr 2015 15:31:34 -0400 Received: from mail-bn1on0085.outbound.protection.outlook.com ([157.56.110.85]:31648 helo=na01-bn1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YljJy-0007iX-Vs for qemu-devel@nongnu.org; Fri, 24 Apr 2015 15:31:31 -0400 Received: from BL2FFO11FD028.protection.gbl (10.173.160.30) by BL2FFO11HUB057.protection.gbl (10.173.161.157) with Microsoft SMTP Server (TLS) id 15.1.148.11; Fri, 24 Apr 2015 19:31:30 +0000 Authentication-Results: spf=fail (sender IP is 149.199.60.96) smtp.mailfrom=xilinx.com; gmail.com; dkim=none (message not signed) header.d=none; 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 BL2FFO11FD028.mail.protection.outlook.com (10.173.161.107) with Microsoft SMTP Server (TLS) id 15.1.154.14 via Frontend Transport; Fri, 24 Apr 2015 19:31:29 +0000 Received: from 172-16-1-203.xilinx.com ([172.16.1.203]:51879 helo=xsj-tvapsmtp02.xilinx.com) by xsj-tvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1YljFD-0001mr-Sa; Fri, 24 Apr 2015 12:26:35 -0700 Received: from [127.0.0.1] (port=33507 helo=tsj-smtp-dlp1.xlnx.xilinx.com) by xsj-tvapsmtp02.xilinx.com with esmtp (Exim 4.63) (envelope-from ) id 1YljJw-0001GS-QN; Fri, 24 Apr 2015 12:31:28 -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 t3OJRPJD005371; Fri, 24 Apr 2015 12:27:25 -0700 Received: from [172.19.74.49] (port=38253 helo=xsjsorenbubuntu.xilinx.com) by xsj-tvapsmtp02 with esmtp (Exim 4.63) (envelope-from ) id 1YljJv-0001GK-Td; Fri, 24 Apr 2015 12:31:27 -0700 From: Peter Crosthwaite To: Date: Fri, 24 Apr 2015 12:31:27 -0700 Message-ID: <74565bac3230ecf27f03353e299ce79d350e729d.1429903602.git.peter.crosthwaite@xilinx.com> X-Mailer: git-send-email 2.3.6.3.g2cc70ee In-Reply-To: References: X-RCIS-Action: ALLOW X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-7.5.0.1018-21500.005 X-TM-AS-Result: No--2.431-7.0-31-10 X-imss-scan-details: No--2.431-7.0-31-10 X-TMASE-MatchedRID: l/nE+SiO7Ibj3O4G38MrjY6MisxJraxHCt59Uh3p/NVWoRkbdZaAbrpp SwuYPeB7ZMmd/uF7O5uVbXLNvAI4thnsS71Oo/Hw4RtSDjG+z7BeCrB32KOS0DRCaZSKE/Os3WI ObrBKHkq2XO6LyR+n36AY5nebYtjnU6k75K+J6PBCvapcIkxJX+9KnaK64e2iaE68ZUyTrQWFKd 8XesWMYNA1IgPHTFOhnnHu/YLKO/NY2LnVaSgBRUhwlOfYeSqx3FYvKmZiVnMKogmGusPLbx4ua 24ul9od3HLPrw7aQmmvvCk/pUr59kb7j8pmihQlyhsNNXtKW8HWSrKtwxqWpdnu97SXKBPYo3+u 3ItaRPXi8zVgXoAltsIJ+4gwXrEtWBd6ltyXuvulgS5DY9u3YDIGygLS5BPsITQHstnkhb0rMr5 KnhW1xSs8Oqveu8o4A05Yff/hzgrNeHztnMyjLuM4045CjccyMcv5gKX0YENLv5Eyr/YIrqsDhz tRXZ9Cm+LY9A78UVCLPa6Os9XH3AncqsF+GX35ftwZ3X11IV0= X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.96; CTRY:US; IPV:NLI; EFV:NLI; BMV:1; SFV:NSPM; SFS:(10009020)(6009001)(339900001)(199003)(189002)(46102003)(15975445007)(105606002)(2351001)(62966003)(77096005)(77156002)(110136001)(92566002)(6806004)(19580405001)(19580395003)(87936001)(50226001)(2950100001)(50466002)(50986999)(64026002)(118296001)(33646002)(36756003)(71366001)(229853001)(106466001)(86362001)(48376002)(47776003)(85426001)(76176999)(107986001)(4001430100001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2FFO11HUB057; H:xsj-tvapsmtpgw01; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2FFO11HUB057; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5002010)(5005006)(3002001); SRVR:BL2FFO11HUB057; BCL:0; PCL:0; RULEID:; SRVR:BL2FFO11HUB057; X-Forefront-PRVS: 05568D1FF7 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2015 19:31:29.6997 (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: BL2FFO11HUB057 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 X-Received-From: 157.56.110.85 Cc: edgar.iglesias@xilinx.com, peter.maydell@linaro.org, zach.pfeffer@xilinx.com, jues@xilinx.com, ozaki.ryota@gmail.com, Alistair Francis , michals@xilinx.com Subject: [Qemu-devel] [PATCH target-arm v5 10/14] char: cadence_uart: Split state struct and type into header 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Create a new header for Cadence UART to allow using the device with modern SoC programming conventions. The state struct needs to be visible to embed the device in SoC containers. Reviewed-by: Alistair Francis Reviewed-by: Peter Maydell Tested-by: Alistair Francis Signed-off-by: Peter Crosthwaite --- changed since v4 (PMM review): remove include guard _ Add (c) info to header Make commit msg body standalone changed since v1: Fix /* Public */ comment spacing (Alistair review) hw/char/cadence_uart.c | 29 +---------------------- include/hw/char/cadence_uart.h | 53 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 28 deletions(-) create mode 100644 include/hw/char/cadence_uart.h diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index 4a4d3eb..9d379e5 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -16,9 +16,7 @@ * with this program; if not, see . */ -#include "hw/sysbus.h" -#include "sysemu/char.h" -#include "qemu/timer.h" +#include "hw/char/cadence_uart.h" #ifdef CADENCE_UART_ERR_DEBUG #define DB_PRINT(...) do { \ @@ -85,8 +83,6 @@ #define LOCAL_LOOPBACK (0x2 << UART_MR_CHMODE_SH) #define REMOTE_LOOPBACK (0x3 << UART_MR_CHMODE_SH) -#define CADENCE_UART_RX_FIFO_SIZE 16 -#define CADENCE_UART_TX_FIFO_SIZE 16 #define UART_INPUT_CLK 50000000 #define R_CR (0x00/4) @@ -108,29 +104,6 @@ #define R_PWID (0x40/4) #define R_TTRIG (0x44/4) -#define CADENCE_UART_R_MAX (0x48/4) - -#define TYPE_CADENCE_UART "cadence_uart" -#define CADENCE_UART(obj) OBJECT_CHECK(CadenceUARTState, (obj), \ - TYPE_CADENCE_UART) - -typedef struct { - /*< private >*/ - SysBusDevice parent_obj; - /*< public >*/ - - MemoryRegion iomem; - uint32_t r[CADENCE_UART_R_MAX]; - uint8_t rx_fifo[CADENCE_UART_RX_FIFO_SIZE]; - uint8_t tx_fifo[CADENCE_UART_TX_FIFO_SIZE]; - uint32_t rx_wpos; - uint32_t rx_count; - uint32_t tx_count; - uint64_t char_tx_time; - CharDriverState *chr; - qemu_irq irq; - QEMUTimer *fifo_trigger_handle; -} CadenceUARTState; static void uart_update_status(CadenceUARTState *s) { diff --git a/include/hw/char/cadence_uart.h b/include/hw/char/cadence_uart.h new file mode 100644 index 0000000..6310f52 --- /dev/null +++ b/include/hw/char/cadence_uart.h @@ -0,0 +1,53 @@ +/* + * Device model for Cadence UART + * + * Copyright (c) 2010 Xilinx Inc. + * Copyright (c) 2012 Peter A.G. Crosthwaite (peter.crosthwaite@petalogix.com) + * Copyright (c) 2012 PetaLogix Pty Ltd. + * Written by Haibing Ma + * M.Habib + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef CADENCE_UART_H + +#include "hw/sysbus.h" +#include "sysemu/char.h" +#include "qemu/timer.h" + +#define CADENCE_UART_RX_FIFO_SIZE 16 +#define CADENCE_UART_TX_FIFO_SIZE 16 + +#define CADENCE_UART_R_MAX (0x48/4) + +#define TYPE_CADENCE_UART "cadence_uart" +#define CADENCE_UART(obj) OBJECT_CHECK(CadenceUARTState, (obj), \ + TYPE_CADENCE_UART) + +typedef struct { + /*< private >*/ + SysBusDevice parent_obj; + + /*< public >*/ + MemoryRegion iomem; + uint32_t r[CADENCE_UART_R_MAX]; + uint8_t rx_fifo[CADENCE_UART_RX_FIFO_SIZE]; + uint8_t tx_fifo[CADENCE_UART_TX_FIFO_SIZE]; + uint32_t rx_wpos; + uint32_t rx_count; + uint32_t tx_count; + uint64_t char_tx_time; + CharDriverState *chr; + qemu_irq irq; + QEMUTimer *fifo_trigger_handle; +} CadenceUARTState; + +#define CADENCE_UART_H +#endif