Add the TTC to the xlnx-zynqmp board
cover Add the TTC to the xlnx-zynqmp board
Hi,
This serie adds the TTC timers to the xlnx-zynqmp board required to boot some os. It seems that the waveform feature is not implemented but since that's not directly software visible it is not an issue. An other limitation is that the frequency is fixed and should be configurable through the zynqmp clock controllers.
Thanks,
Fred
KONRAD Frederic (2):
cadence_ttc: extract CadenceTTCState to a new header file
xlnx-zynqmp: add the timers
hw/arm/xlnx-zynqmp.c | 25 +++++++++++++++++ hw/timer/cadence_ttc.c | 35 +----------------------- include/hw/arm/xlnx-zynqmp.h | 3 +++ include/hw/timer/cadence_ttc.h | 61 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 34 deletions(-) create mode 100644 include/hw/timer/cadence_ttc.h
Signature · 1 line
1.8.3.1
PATCH 1/2 cadence_ttc: extract CadenceTTCState to a new header file
We want to add this model to the xlnx-zynqmp board so let's make CadenceTTCState available in an header file.
--- hw/timer/cadence_ttc.c | 35 +----------------------- include/hw/timer/cadence_ttc.h | 61 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 34 deletions(-) create mode 100644 include/hw/timer/cadence_ttc.h
hw/timer/cadence_ttc.c +1 -34
@@ -16,9 +16,7 @@* with this program; if not, see <http://www.gnu.org/licenses/>. */ -#include "qemu/osdep.h" -#include "hw/sysbus.h" -#include "qemu/timer.h" +#include "hw/timer/cadence_ttc.h" #ifdef CADENCE_TTC_ERR_DEBUG #define DB_PRINT (...) do { \
@@ -45,37 +43,6 @@#define CLOCK_CTRL_PS_EN 0x00000001#define CLOCK_CTRL_PS_V 0x0000001e -typedef struct { -QEMUTimer *timer; -int freq; - -uint32_t reg_clock; -uint32_t reg_count; -uint32_t reg_value; -uint16_t reg_interval; -uint16_t reg_match[3 ]; -uint32_t reg_intr; -uint32_t reg_intr_en; -uint32_t reg_event_ctrl; -uint32_t reg_event; - -uint64_t cpu_time; -unsigned int cpu_time_valid; - -qemu_irq irq; -}CadenceTimerState ; - -#define TYPE_CADENCE_TTC "cadence_ttc" -#define CADENCE_TTC (obj) \ - OBJECT_CHECK(CadenceTTCState, (obj), TYPE_CADENCE_TTC) - -typedef struct CadenceTTCState { -SysBusDevice parent_obj; - -MemoryRegion iomem; -CadenceTimerState timer[3 ]; -}CadenceTTCState ; -static void cadence_timer_update (CadenceTimerState *s) {qemu_set_irq (s->irq, !!(s->reg_intr & s->reg_intr_en));
include/hw/timer/cadence_ttc.h new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH for-2.12 1/2] cadence_ttc: extract CadenceTTCState to a new header file
Quoted 15 lines · KONRAD Frederic
We want to add this model to the xlnx-zynqmp board so let's make CadenceTTCState available in an header file.
Signed-off-by KONRAD Frederic <[email protected]>--- hw/timer/cadence_ttc.c | 35 +----------------------- include/hw/timer/cadence_ttc.h | 61 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 34 deletions(-) create mode 100644 include/hw/timer/cadence_ttc.hhw/timer/cadence_ttc.c +0
-0
hw/timer/cadence_ttc.c line 19
Quoted 7 lines
hw/timer/cadence_ttc.c +1
-3@@ -16,9 +16,7 @@* with this program; if not, see <http://www.gnu.org/licenses/>. */ -#include "qemu/osdep.h" -#include "hw/sysbus.h" -#include "qemu/timer.h" +#include "hw/timer/cadence_ttc.h"
Something's gone wrong here. osdep.h should always be the first header in any .c file, and it should never be included by any other .h file.
thanks
-- PMM
Re: [Qemu-devel] [PATCH for-2.12 1/2] cadence_ttc: extract CadenceTTCState to a new header file
Quoted 29 lines · Peter Maydell
Quoted 15 lines · KONRAD Frederic
We want to add this model to the xlnx-zynqmp board so let's make CadenceTTCState available in an header file.
Signed-off-by KONRAD Frederic <[email protected]>--- hw/timer/cadence_ttc.c | 35 +----------------------- include/hw/timer/cadence_ttc.h | 61 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 34 deletions(-)create mode 100644
include/hw/timer/cadence_ttc.hhw/timer/cadence_ttc.c +0
-0hw/timer/cadence_ttc.c line 19
Quoted 7 lines
hw/timer/cadence_ttc.c +1
-3@@ -16,9 +16,7 @@* with this program; if not, see <http://www.gnu.org/licenses/>. */ -#include "qemu/osdep.h" -#include "hw/sysbus.h" -#include "qemu/timer.h" +#include "hw/timer/cadence_ttc.h" Something's gone wrong here.
osdep.hshould always be the first header in any .c file, and it should never be included by any other .h file.
Quoted 3 lines
thanks
-- PMM
Hi Peter,
Thanks for your input. I'll fix that.
Fred
PATCH 2/2 xlnx-zynqmp: add the timers
In reply to KONRAD FredericThis adds the TTC to the xlnx-zynqmp board according to the ultrascale TRM.
--- hw/arm/xlnx-zynqmp.c | 25 +++++++++++++++++++++++++ include/hw/arm/xlnx-zynqmp.h | 3 +++ 2 files changed, 28 insertions(+)
hw/arm/xlnx-zynqmp.c +25 -0
@@ -78,6 +78,14 @@ static const int spi_intr[XLNX_ZYNQMP_NUM_SPIS] = { 19, 20, }; +static const uint64_t ttc_addr[XLNX_ZYNQMP_NUM_TTC ] = { +0xFF110000 ,0xFF120000 ,0xFF130000 ,0xFF140000 , +}; + +static const uint64_t ttc_intr[XLNX_ZYNQMP_NUM_TTC ] = { +36 ,39 ,42 ,45 , +}; + typedef struct XlnxZynqMPGICRegion { int region_index; uint32_t address;
@@ -174,6 +182,11 @@ static void xlnx_zynqmp_init(Object *obj)object_initialize (&s->dpdma,sizeof (s->dpdma),TYPE_XLNX_DPDMA );qdev_set_parent_bus (DEVICE (&s->dpdma),sysbus_get_default ()); + +for (i =0 ; i <XLNX_ZYNQMP_NUM_TTC ; i++) { +object_initialize (&s->ttc[i],sizeof (s->ttc[i]),TYPE_CADENCE_TTC ); +qdev_set_parent_bus (DEVICE (&s->ttc[i]),sysbus_get_default ()); + } }static void xlnx_zynqmp_realize (DeviceState *dev,Error **errp)
@@ -422,6 +435,18 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) &error_abort);sysbus_mmio_map (SYS_BUS_DEVICE (&s->dpdma),0 ,DPDMA_ADDR );sysbus_connect_irq (SYS_BUS_DEVICE (&s->dpdma),0 , gic_spi[DPDMA_IRQ ]); + +for (i =0 ; i <XLNX_ZYNQMP_NUM_TTC ; i++) { +object_property_set_bool (OBJECT (&s->ttc[i]), true,"realized" , &err); + +if (err) { +error_propagate (errp, err); +return ; + } +sysbus_mmio_map (SYS_BUS_DEVICE (&s->ttc[i]),0 , ttc_addr[i]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->ttc[i]),0 , + gic_spi[ttc_intr[i]]); + } }static Property xlnx_zynqmp_props[] = {
include/hw/arm/xlnx-zynqmp.h +3 -0
@@ -28,6 +28,7 @@#include "hw/ssi/xilinx_spips.h" #include "hw/dma/xlnx_dpdma.h" #include "hw/display/xlnx_dp.h" +#include "hw/timer/cadence_ttc.h" #define TYPE_XLNX_ZYNQMP "xlnx,zynqmp"#define XLNX_ZYNQMP (obj) OBJECT_CHECK(XlnxZynqMPState, (obj), \
@@ -39,6 +40,7 @@#define XLNX_ZYNQMP_NUM_UARTS 2#define XLNX_ZYNQMP_NUM_SDHCI 2#define XLNX_ZYNQMP_NUM_SPIS 2 +#define XLNX_ZYNQMP_NUM_TTC 4#define XLNX_ZYNQMP_NUM_OCM_BANKS 4#define XLNX_ZYNQMP_OCM_RAM_0_ADDRESS 0xFFFC0000
@@ -85,6 +87,7 @@ typedef struct XlnxZynqMPState {XilinxSPIPS spi[XLNX_ZYNQMP_NUM_SPIS ];XlnxDPState dp;XlnxDPDMAState dpdma; +CadenceTTCState ttc[XLNX_ZYNQMP_NUM_TTC ];char *boot_cpu;ARMCPU *boot_cpu_ptr;
Signature · 1 line
1.8.3.1
A message that is not in the archive (sent off-list or not yet received): CAKmqyKOQDEbiiv825hPvb2AytSOpY_35Aw46WcT0fRU8SZbJFw@mail.gmail.com
Re: [Qemu-devel] [PATCH for-2.12 2/2] xlnx-zynqmp: add the timers
Quoted 52 lines · Alistair Francis
Quoted 40 lines · KONRAD Frederic
This adds the TTC to the xlnx-zynqmp board according to the ultrascale TRM.
Signed-off-by KONRAD Frederic <[email protected]>--- hw/arm/xlnx-zynqmp.c | 25 +++++++++++++++++++++++++ include/hw/arm/xlnx-zynqmp.h | 3 +++ 2 files changed, 28 insertions(+)hw/arm/xlnx-zynqmp.c +13
-0@@ -78,6 +78,14 @@ static const int spi_intr[XLNX_ZYNQMP_NUM_SPIS] = { 19, 20, }; +static const uint64_t ttc_addr[XLNX_ZYNQMP_NUM_TTC ] = { +0xFF110000 ,0xFF120000 ,0xFF130000 ,0xFF140000 , +}; + +static const uint64_t ttc_intr[XLNX_ZYNQMP_NUM_TTC ] = { +36 ,39 ,42 ,45 , +}; + typedef struct XlnxZynqMPGICRegion { int region_index; uint32_t address;@@ -174,6 +182,11 @@ static void xlnx_zynqmp_init(Object *obj)object_initialize (&s->dpdma,sizeof (s->dpdma),TYPE_XLNX_DPDMA );qdev_set_parent_bus (DEVICE (&s->dpdma),sysbus_get_default ()); + +for (i =0 ; i <XLNX_ZYNQMP_NUM_TTC ; i++) { +object_initialize (&s->ttc[i],sizeof (s->ttc[i]),TYPE_CADENCE_TTC ); +qdev_set_parent_bus (DEVICE (&s->ttc[i]),sysbus_get_default ()); + } }static void xlnx_zynqmp_realize (DeviceState *dev,Error **errp)hw/arm/xlnx-zynqmp.c static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) · line 441
Quoted 7 lines
hw/arm/xlnx-zynqmp.c +4
-0@@ -422,6 +435,18 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) &error_abort);sysbus_mmio_map (SYS_BUS_DEVICE (&s->dpdma),0 ,DPDMA_ADDR );sysbus_connect_irq (SYS_BUS_DEVICE (&s->dpdma),0 , gic_spi[DPDMA_IRQ ]); + +for (i =0 ; i <XLNX_ZYNQMP_NUM_TTC ; i++) { +object_property_set_bool (OBJECT (&s->ttc[i]), true,"realized" , &err); +No new line here.
Quoted 5 lines
Otherwise:
Reviewed-by Alistair Francis <[email protected]>Alistair
Thanks,
I'll fix that and resend.
Fred
Quoted 44 lines
Quoted 44 lines
hw/arm/xlnx-zynqmp.c +8
-0+if (err) { +error_propagate (errp, err); +return ; + } +sysbus_mmio_map (SYS_BUS_DEVICE (&s->ttc[i]),0 , ttc_addr[i]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->ttc[i]),0 , + gic_spi[ttc_intr[i]]); + } }static Property xlnx_zynqmp_props[] = {include/hw/arm/xlnx-zynqmp.h +3
-1@@ -28,6 +28,7 @@#include "hw/ssi/xilinx_spips.h" #include "hw/dma/xlnx_dpdma.h" #include "hw/display/xlnx_dp.h" +#include "hw/timer/cadence_ttc.h" #define TYPE_XLNX_ZYNQMP "xlnx,zynqmp"#define XLNX_ZYNQMP (obj) OBJECT_CHECK(XlnxZynqMPState, (obj), \@@ -39,6 +40,7 @@#define XLNX_ZYNQMP_NUM_UARTS 2#define XLNX_ZYNQMP_NUM_SDHCI 2#define XLNX_ZYNQMP_NUM_SPIS 2 +#define XLNX_ZYNQMP_NUM_TTC 4#define XLNX_ZYNQMP_NUM_OCM_BANKS 4#define XLNX_ZYNQMP_OCM_RAM_0_ADDRESS 0xFFFC0000@@ -85,6 +87,7 @@ typedef struct XlnxZynqMPState {XilinxSPIPS spi[XLNX_ZYNQMP_NUM_SPIS ];XlnxDPState dp;XlnxDPDMAState dpdma; +CadenceTTCState ttc[XLNX_ZYNQMP_NUM_TTC ];char *boot_cpu;ARMCPU *boot_cpu_ptr; --1.8.3.1