mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
hw/arm/fsl-imx8mp: Implement general purpose timers
Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Bernhard Beschow <shentey@gmail.com> Message-id: 20250223114708.1780-14-shentey@gmail.com [PMM: drop static const from gpt_attrs for GCC 7.5] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
1ac21eb8fb
commit
f8b2612176
6 changed files with 92 additions and 0 deletions
|
@ -18,6 +18,7 @@ The ``imx8mp-evk`` machine implements the following devices:
|
||||||
* 6 I2C Controllers
|
* 6 I2C Controllers
|
||||||
* 3 SPI Controllers
|
* 3 SPI Controllers
|
||||||
* 3 Watchdogs
|
* 3 Watchdogs
|
||||||
|
* 6 General Purpose Timers
|
||||||
* Secure Non-Volatile Storage (SNVS) including an RTC
|
* Secure Non-Volatile Storage (SNVS) including an RTC
|
||||||
* Clock Tree
|
* Clock Tree
|
||||||
|
|
||||||
|
|
|
@ -602,6 +602,7 @@ config FSL_IMX8MP
|
||||||
select FSL_IMX8MP_CCM
|
select FSL_IMX8MP_CCM
|
||||||
select IMX
|
select IMX
|
||||||
select IMX_I2C
|
select IMX_I2C
|
||||||
|
select OR_IRQ
|
||||||
select PCI_EXPRESS_DESIGNWARE
|
select PCI_EXPRESS_DESIGNWARE
|
||||||
select PCI_EXPRESS_FSL_IMX8M_PHY
|
select PCI_EXPRESS_FSL_IMX8M_PHY
|
||||||
select SDHCI
|
select SDHCI
|
||||||
|
|
|
@ -208,6 +208,13 @@ static void fsl_imx8mp_init(Object *obj)
|
||||||
object_initialize_child(obj, name, &s->uart[i], TYPE_IMX_SERIAL);
|
object_initialize_child(obj, name, &s->uart[i], TYPE_IMX_SERIAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < FSL_IMX8MP_NUM_GPTS; i++) {
|
||||||
|
g_autofree char *name = g_strdup_printf("gpt%d", i + 1);
|
||||||
|
object_initialize_child(obj, name, &s->gpt[i], TYPE_IMX8MP_GPT);
|
||||||
|
}
|
||||||
|
object_initialize_child(obj, "gpt5-gpt6-irq", &s->gpt5_gpt6_irq,
|
||||||
|
TYPE_OR_IRQ);
|
||||||
|
|
||||||
for (i = 0; i < FSL_IMX8MP_NUM_I2CS; i++) {
|
for (i = 0; i < FSL_IMX8MP_NUM_I2CS; i++) {
|
||||||
g_autofree char *name = g_strdup_printf("i2c%d", i + 1);
|
g_autofree char *name = g_strdup_printf("i2c%d", i + 1);
|
||||||
object_initialize_child(obj, name, &s->i2c[i], TYPE_IMX_I2C);
|
object_initialize_child(obj, name, &s->i2c[i], TYPE_IMX_I2C);
|
||||||
|
@ -375,6 +382,52 @@ static void fsl_imx8mp_realize(DeviceState *dev, Error **errp)
|
||||||
qdev_get_gpio_in(gicdev, serial_table[i].irq));
|
qdev_get_gpio_in(gicdev, serial_table[i].irq));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* GPTs */
|
||||||
|
object_property_set_int(OBJECT(&s->gpt5_gpt6_irq), "num-lines", 2,
|
||||||
|
&error_abort);
|
||||||
|
if (!qdev_realize(DEVICE(&s->gpt5_gpt6_irq), NULL, errp)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qdev_connect_gpio_out(DEVICE(&s->gpt5_gpt6_irq), 0,
|
||||||
|
qdev_get_gpio_in(gicdev, FSL_IMX8MP_GPT5_GPT6_IRQ));
|
||||||
|
|
||||||
|
for (i = 0; i < FSL_IMX8MP_NUM_GPTS; i++) {
|
||||||
|
hwaddr gpt_addrs[FSL_IMX8MP_NUM_GPTS] = {
|
||||||
|
fsl_imx8mp_memmap[FSL_IMX8MP_GPT1].addr,
|
||||||
|
fsl_imx8mp_memmap[FSL_IMX8MP_GPT2].addr,
|
||||||
|
fsl_imx8mp_memmap[FSL_IMX8MP_GPT3].addr,
|
||||||
|
fsl_imx8mp_memmap[FSL_IMX8MP_GPT4].addr,
|
||||||
|
fsl_imx8mp_memmap[FSL_IMX8MP_GPT5].addr,
|
||||||
|
fsl_imx8mp_memmap[FSL_IMX8MP_GPT6].addr,
|
||||||
|
};
|
||||||
|
|
||||||
|
s->gpt[i].ccm = IMX_CCM(&s->ccm);
|
||||||
|
|
||||||
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpt[i]), errp)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt[i]), 0, gpt_addrs[i]);
|
||||||
|
|
||||||
|
if (i < FSL_IMX8MP_NUM_GPTS - 2) {
|
||||||
|
static const unsigned int gpt_irqs[FSL_IMX8MP_NUM_GPTS - 2] = {
|
||||||
|
FSL_IMX8MP_GPT1_IRQ,
|
||||||
|
FSL_IMX8MP_GPT2_IRQ,
|
||||||
|
FSL_IMX8MP_GPT3_IRQ,
|
||||||
|
FSL_IMX8MP_GPT4_IRQ,
|
||||||
|
};
|
||||||
|
|
||||||
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt[i]), 0,
|
||||||
|
qdev_get_gpio_in(gicdev, gpt_irqs[i]));
|
||||||
|
} else {
|
||||||
|
int irq = i - FSL_IMX8MP_NUM_GPTS + 2;
|
||||||
|
|
||||||
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt[i]), 0,
|
||||||
|
qdev_get_gpio_in(DEVICE(&s->gpt5_gpt6_irq), irq));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* I2Cs */
|
/* I2Cs */
|
||||||
for (i = 0; i < FSL_IMX8MP_NUM_I2CS; i++) {
|
for (i = 0; i < FSL_IMX8MP_NUM_I2CS; i++) {
|
||||||
struct {
|
struct {
|
||||||
|
|
|
@ -126,6 +126,17 @@ static const IMXClk imx7_gpt_clocks[] = {
|
||||||
CLK_NONE, /* 111 not defined */
|
CLK_NONE, /* 111 not defined */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const IMXClk imx8mp_gpt_clocks[] = {
|
||||||
|
CLK_NONE, /* 000 No clock source */
|
||||||
|
CLK_IPG, /* 001 ipg_clk, 532MHz */
|
||||||
|
CLK_IPG_HIGH, /* 010 ipg_clk_highfreq */
|
||||||
|
CLK_EXT, /* 011 External clock */
|
||||||
|
CLK_32k, /* 100 ipg_clk_32k */
|
||||||
|
CLK_HIGH, /* 101 ipg_clk_16M */
|
||||||
|
CLK_NONE, /* 110 not defined */
|
||||||
|
CLK_NONE, /* 111 not defined */
|
||||||
|
};
|
||||||
|
|
||||||
/* Must be called from within ptimer_transaction_begin/commit block */
|
/* Must be called from within ptimer_transaction_begin/commit block */
|
||||||
static void imx_gpt_set_freq(IMXGPTState *s)
|
static void imx_gpt_set_freq(IMXGPTState *s)
|
||||||
{
|
{
|
||||||
|
@ -552,6 +563,13 @@ static void imx7_gpt_init(Object *obj)
|
||||||
s->clocks = imx7_gpt_clocks;
|
s->clocks = imx7_gpt_clocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void imx8mp_gpt_init(Object *obj)
|
||||||
|
{
|
||||||
|
IMXGPTState *s = IMX_GPT(obj);
|
||||||
|
|
||||||
|
s->clocks = imx8mp_gpt_clocks;
|
||||||
|
}
|
||||||
|
|
||||||
static const TypeInfo imx25_gpt_info = {
|
static const TypeInfo imx25_gpt_info = {
|
||||||
.name = TYPE_IMX25_GPT,
|
.name = TYPE_IMX25_GPT,
|
||||||
.parent = TYPE_SYS_BUS_DEVICE,
|
.parent = TYPE_SYS_BUS_DEVICE,
|
||||||
|
@ -584,6 +602,12 @@ static const TypeInfo imx7_gpt_info = {
|
||||||
.instance_init = imx7_gpt_init,
|
.instance_init = imx7_gpt_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const TypeInfo imx8mp_gpt_info = {
|
||||||
|
.name = TYPE_IMX8MP_GPT,
|
||||||
|
.parent = TYPE_IMX25_GPT,
|
||||||
|
.instance_init = imx8mp_gpt_init,
|
||||||
|
};
|
||||||
|
|
||||||
static void imx_gpt_register_types(void)
|
static void imx_gpt_register_types(void)
|
||||||
{
|
{
|
||||||
type_register_static(&imx25_gpt_info);
|
type_register_static(&imx25_gpt_info);
|
||||||
|
@ -591,6 +615,7 @@ static void imx_gpt_register_types(void)
|
||||||
type_register_static(&imx6_gpt_info);
|
type_register_static(&imx6_gpt_info);
|
||||||
type_register_static(&imx6ul_gpt_info);
|
type_register_static(&imx6ul_gpt_info);
|
||||||
type_register_static(&imx7_gpt_info);
|
type_register_static(&imx7_gpt_info);
|
||||||
|
type_register_static(&imx8mp_gpt_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
type_init(imx_gpt_register_types)
|
type_init(imx_gpt_register_types)
|
||||||
|
|
|
@ -17,10 +17,12 @@
|
||||||
#include "hw/misc/imx7_snvs.h"
|
#include "hw/misc/imx7_snvs.h"
|
||||||
#include "hw/misc/imx8mp_analog.h"
|
#include "hw/misc/imx8mp_analog.h"
|
||||||
#include "hw/misc/imx8mp_ccm.h"
|
#include "hw/misc/imx8mp_ccm.h"
|
||||||
|
#include "hw/or-irq.h"
|
||||||
#include "hw/pci-host/designware.h"
|
#include "hw/pci-host/designware.h"
|
||||||
#include "hw/pci-host/fsl_imx8m_phy.h"
|
#include "hw/pci-host/fsl_imx8m_phy.h"
|
||||||
#include "hw/sd/sdhci.h"
|
#include "hw/sd/sdhci.h"
|
||||||
#include "hw/ssi/imx_spi.h"
|
#include "hw/ssi/imx_spi.h"
|
||||||
|
#include "hw/timer/imx_gpt.h"
|
||||||
#include "hw/watchdog/wdt_imx2.h"
|
#include "hw/watchdog/wdt_imx2.h"
|
||||||
#include "qom/object.h"
|
#include "qom/object.h"
|
||||||
#include "qemu/units.h"
|
#include "qemu/units.h"
|
||||||
|
@ -35,6 +37,7 @@ enum FslImx8mpConfiguration {
|
||||||
FSL_IMX8MP_NUM_CPUS = 4,
|
FSL_IMX8MP_NUM_CPUS = 4,
|
||||||
FSL_IMX8MP_NUM_ECSPIS = 3,
|
FSL_IMX8MP_NUM_ECSPIS = 3,
|
||||||
FSL_IMX8MP_NUM_GPIOS = 5,
|
FSL_IMX8MP_NUM_GPIOS = 5,
|
||||||
|
FSL_IMX8MP_NUM_GPTS = 6,
|
||||||
FSL_IMX8MP_NUM_I2CS = 6,
|
FSL_IMX8MP_NUM_I2CS = 6,
|
||||||
FSL_IMX8MP_NUM_IRQS = 160,
|
FSL_IMX8MP_NUM_IRQS = 160,
|
||||||
FSL_IMX8MP_NUM_UARTS = 4,
|
FSL_IMX8MP_NUM_UARTS = 4,
|
||||||
|
@ -47,6 +50,7 @@ struct FslImx8mpState {
|
||||||
|
|
||||||
ARMCPU cpu[FSL_IMX8MP_NUM_CPUS];
|
ARMCPU cpu[FSL_IMX8MP_NUM_CPUS];
|
||||||
GICv3State gic;
|
GICv3State gic;
|
||||||
|
IMXGPTState gpt[FSL_IMX8MP_NUM_GPTS];
|
||||||
IMXGPIOState gpio[FSL_IMX8MP_NUM_GPIOS];
|
IMXGPIOState gpio[FSL_IMX8MP_NUM_GPIOS];
|
||||||
IMX8MPCCMState ccm;
|
IMX8MPCCMState ccm;
|
||||||
IMX8MPAnalogState analog;
|
IMX8MPAnalogState analog;
|
||||||
|
@ -58,6 +62,7 @@ struct FslImx8mpState {
|
||||||
IMX2WdtState wdt[FSL_IMX8MP_NUM_WDTS];
|
IMX2WdtState wdt[FSL_IMX8MP_NUM_WDTS];
|
||||||
DesignwarePCIEHost pcie;
|
DesignwarePCIEHost pcie;
|
||||||
FslImx8mPciePhyState pcie_phy;
|
FslImx8mPciePhyState pcie_phy;
|
||||||
|
OrIRQState gpt5_gpt6_irq;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FslImx8mpMemoryRegions {
|
enum FslImx8mpMemoryRegions {
|
||||||
|
@ -224,6 +229,12 @@ enum FslImx8mpIrqs {
|
||||||
FSL_IMX8MP_I2C3_IRQ = 37,
|
FSL_IMX8MP_I2C3_IRQ = 37,
|
||||||
FSL_IMX8MP_I2C4_IRQ = 38,
|
FSL_IMX8MP_I2C4_IRQ = 38,
|
||||||
|
|
||||||
|
FSL_IMX8MP_GPT1_IRQ = 55,
|
||||||
|
FSL_IMX8MP_GPT2_IRQ = 54,
|
||||||
|
FSL_IMX8MP_GPT3_IRQ = 53,
|
||||||
|
FSL_IMX8MP_GPT4_IRQ = 52,
|
||||||
|
FSL_IMX8MP_GPT5_GPT6_IRQ = 51,
|
||||||
|
|
||||||
FSL_IMX8MP_GPIO1_LOW_IRQ = 64,
|
FSL_IMX8MP_GPIO1_LOW_IRQ = 64,
|
||||||
FSL_IMX8MP_GPIO1_HIGH_IRQ = 65,
|
FSL_IMX8MP_GPIO1_HIGH_IRQ = 65,
|
||||||
FSL_IMX8MP_GPIO2_LOW_IRQ = 66,
|
FSL_IMX8MP_GPIO2_LOW_IRQ = 66,
|
||||||
|
|
|
@ -80,6 +80,7 @@
|
||||||
#define TYPE_IMX6_GPT "imx6.gpt"
|
#define TYPE_IMX6_GPT "imx6.gpt"
|
||||||
#define TYPE_IMX6UL_GPT "imx6ul.gpt"
|
#define TYPE_IMX6UL_GPT "imx6ul.gpt"
|
||||||
#define TYPE_IMX7_GPT "imx7.gpt"
|
#define TYPE_IMX7_GPT "imx7.gpt"
|
||||||
|
#define TYPE_IMX8MP_GPT "imx8mp.gpt"
|
||||||
|
|
||||||
#define TYPE_IMX_GPT TYPE_IMX25_GPT
|
#define TYPE_IMX_GPT TYPE_IMX25_GPT
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue