2015-05-15 04:23:18 +02:00
|
|
|
/*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CADENCE_UART_H
|
2019-06-04 20:16:15 +02:00
|
|
|
#define CADENCE_UART_H
|
2015-05-15 04:23:18 +02:00
|
|
|
|
2019-08-12 07:23:51 +02:00
|
|
|
#include "hw/qdev-properties.h"
|
2015-05-15 04:23:18 +02:00
|
|
|
#include "hw/sysbus.h"
|
2017-01-26 15:26:44 +01:00
|
|
|
#include "chardev/char-fe.h"
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 07:31:58 +02:00
|
|
|
#include "qapi/error.h"
|
2015-05-15 04:23:18 +02:00
|
|
|
#include "qemu/timer.h"
|
2020-09-03 22:43:22 +02:00
|
|
|
#include "qom/object.h"
|
2015-05-15 04:23:18 +02:00
|
|
|
|
|
|
|
#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"
|
2020-09-16 20:25:19 +02:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(CadenceUARTState, CADENCE_UART)
|
2015-05-15 04:23:18 +02:00
|
|
|
|
2020-09-03 22:43:22 +02:00
|
|
|
struct CadenceUARTState {
|
2015-05-15 04:23:18 +02:00
|
|
|
/*< 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;
|
2016-10-22 11:52:51 +02:00
|
|
|
CharBackend chr;
|
2015-05-15 04:23:18 +02:00
|
|
|
qemu_irq irq;
|
|
|
|
QEMUTimer *fifo_trigger_handle;
|
2020-04-06 15:52:49 +02:00
|
|
|
Clock *refclk;
|
2020-09-03 22:43:22 +02:00
|
|
|
};
|
2015-05-15 04:23:18 +02:00
|
|
|
|
|
|
|
#endif
|