Add i.MX6 (Single/Dual/Quad) support
v6 cover Add i.MX6 (Single/Dual/Quad) support
This patch series adds support for the Freescale i.MX6 processor.
For now we only support the following devices:
* up to 4 Cortex A9 cores
* A9 MPCORE (SCU, GIC, TWD)
* 5 i.MX UARTs
* 2 EPIT timers
* 1 GPT timer
* 7 GPIO controllers
* 6 SDHC controllers
* 5 SPI controllers
* 1 CCM device
* 1 SRC device
* 3 I2C devices
* various ROM/RAM areas.
This also adds the sabrelite board as a an actual platform for i.MX6.
This series was tested by booting a 4.4 linux kernel (using the imx_v6_v7_defconfig file as kernel configuration).
Note1: as sabrelite uses uart2 as console, you have to redirect the second QEMU serial port to stdout.
qemu-system-arm -M sabrelite -display none ... -serial null -serial stdio
Note2: You need to disable the GPIO section related to physical push buttons in the Linux DTS tree in order to avoid excecive interrupt triggering on GPIO devices for non existant buttons.
Jean-Christophe Dubois (6):
ARM: Factor out ARM on/off PSCI control functions i.MX: Add i.MX6 System Reset Controller device.
FIFO: Add a FIFO32 implementation
i.MX: Add the Freescale SPI Controller i.MX: Add i.MX6 SOC implementation.
i.MX: Add sabrelite i.MX6 emulation.
default-configs/arm-softmmu.mak | 1 + hw/arm/Makefile.objs | 1 + hw/arm/fsl-imx6.c | 449 +++++++++++++++++++++++++++++++++++++++ hw/arm/sabrelite.c | 122 +++++++++++ hw/misc/Makefile.objs | 1 + hw/misc/imx6_src.c | 264 +++++++++++++++++++++++ hw/ssi/Makefile.objs | 1 + hw/ssi/imx_spi.c | 454 ++++++++++++++++++++++++++++++++++++++++ include/hw/arm/fsl-imx6.h | 450 +++++++++++++++++++++++++++++++++++++++ include/hw/misc/imx6_src.h | 73 +++++++ include/hw/ssi/imx_spi.h | 103 +++++++++ include/qemu/fifo32.h | 191 +++++++++++++++++ target-arm/Makefile.objs | 1 + target-arm/arm-powerctl.c | 224 ++++++++++++++++++++ target-arm/arm-powerctl.h | 75 +++++++ target-arm/psci.c | 70 +------ 16 files changed, 2417 insertions(+), 63 deletions(-) create mode 100644 hw/arm/fsl-imx6.c create mode 100644 hw/arm/sabrelite.c create mode 100644 hw/misc/imx6_src.c create mode 100644 hw/ssi/imx_spi.c create mode 100644 include/hw/arm/fsl-imx6.h create mode 100644 include/hw/misc/imx6_src.h create mode 100644 include/hw/ssi/imx_spi.h create mode 100644 include/qemu/fifo32.h create mode 100644 target-arm/arm-powerctl.c create mode 100644 target-arm/arm-powerctl.h
Signature · 1 line
2.5.0
PATCH v6 1/6 ARM: Factor out ARM on/off PSCI control functions
Split ARM on/off function from PSCI support code.
This will allow to reuse these functions in other code.
---
Changes since V1:
* Not present on V1
Changes since V2:
* Not present on V2
Changes since V3:
* Move to a more generic/usefull API
* Manage CPU level/mode change at startup
* Allow PSCI to cope with EL2/HYP level.
* Keep distinct errors for different causes.
Changes since V4:
* Rework documentation in header file.
* Rework exception level handling.
* Added a TODO for mode handling.
Changes since V5:
* Code reworked based on feedback
* Don't try to support AArch64 CPU booting to AArch32 for now.
target-arm/Makefile.objs | 1 + target-arm/arm-powerctl.c | 224 ++++++++++++++++++++++++++++++++++++++++++++++ target-arm/arm-powerctl.h | 75 ++++++++++++++++ target-arm/psci.c | 70 ++------------- 4 files changed, 307 insertions(+), 63 deletions(-) create mode 100644 target-arm/arm-powerctl.c create mode 100644 target-arm/arm-powerctl.h
target-arm/Makefile.objs +1 -0
@@ -9,3 +9,4 @@ obj-y += neon_helper.o iwmmxt_helper.o obj-y += gdbstub.o obj-$(TARGET_AARCH64) += cpu64.o translate-a64.o helper-a64.o gdbstub64.o obj-y += crypto_helper.o +obj-y += arm-powerctl.o
target-arm/arm-powerctl.c new file +224 -0
224 lines not on this page · raw message
target-arm/arm-powerctl.h new file +75 -0
75 lines not on this page · raw message
target-arm/psci.c +7 -63
116 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v6 2/6 i.MX: Add i.MX6 System Reset Controller device.
In reply to Jean-Christophe DuboisThis controller is also present in i.MX5X devices but they are not yet emulated by QEMU.
---
Changes since V1:
* Change "reset" sematic to mean full power cyvle.
Changes since V2:
* use arm-powerctl API
* Added #include "qemu/osdep.h"
Changes since V3:
* Minor fixes.
Changes since V4:
* None
Changes since V5:
* None
hw/misc/Makefile.objs | 1 + hw/misc/imx6_src.c | 264 +++++++++++++++++++++++++++++++++++++++++++++ include/hw/misc/imx6_src.h | 73 +++++++++++++ 3 files changed, 338 insertions(+) create mode 100644 hw/misc/imx6_src.c create mode 100644 include/hw/misc/imx6_src.h
hw/misc/Makefile.objs +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_IMX) += imx_ccm.o obj-$(CONFIG_IMX) += imx31_ccm.o obj-$(CONFIG_IMX) += imx25_ccm.o obj-$(CONFIG_IMX) += imx6_ccm.o +obj-$(CONFIG_IMX) += imx6_src.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.o
hw/misc/imx6_src.c new file +264 -0
264 lines not on this page · raw message
include/hw/misc/imx6_src.h new file +73 -0
73 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v6 3/6 FIFO: Add a FIFO32 implementation
In reply to Jean-Christophe DuboisThis one is build on top of the existing FIFO8
---
Changes since V1:
* None
Changes since V2:
* Added copyright
* define Fifo32 as a struct containing Fifo8
* remove fifo32_pop_buf()
Changes since V3:
* Added comment on unsupported fifo32_pop_buf()
Changes since V4:
* None
Changes since V5:
* None
include/qemu/fifo32.h | 191 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 include/qemu/fifo32.h
include/qemu/fifo32.h new file +191 -0
@@ -0,0 +1,191 @@ +/* +* Generic FIFO32 component, based on FIFO8. +* +* Copyright (c) 2016 Jean-Christophe Dubois +* +* 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 FIFO32_H +#define FIFO32_H + +#include "qemu/osdep.h" +#include "qemu/fifo8.h" + +typedef struct { +Fifo8 fifo; +}Fifo32 ; + +/** +* fifo32_create: +* @fifo: struct Fifo32 to initialise with new FIFO +* @capacity: capacity of the newly created FIFO expressed in 32 bit words +* +* Create a FIFO of the specified size. Clients should call fifo32_destroy() +* when finished using the fifo. The FIFO is initially empty. +*/ + +static inline void fifo32_create (Fifo32 *fifo,uint32_t capacity) +{ +fifo8_create (&fifo->fifo, capacity *sizeof (uint32_t )); +} + +/** +* fifo32_destroy: +* @fifo: FIFO to cleanup +* +* Cleanup a FIFO created with fifo32_create(). Frees memory created for FIFO +* storage. The FIFO is no longer usable after this has been called. +*/ + +static inline void fifo32_destroy (Fifo32 *fifo) +{ +fifo8_destroy (&fifo->fifo); +} + +/** +* fifo32_num_free: +* @fifo: FIFO to check +* +* Return the number of free uint32_t slots in the FIFO. +* +* Returns: Number of free 32 bit words. +*/ + +static inline uint32_t fifo32_num_free (Fifo32 *fifo) +{ +return DIV_ROUND_UP (fifo8_num_free (&fifo->fifo),sizeof (uint32_t )); +} + +/** +* fifo32_num_used: +* @fifo: FIFO to check +* +* Return the number of used uint32_t slots in the FIFO. +* +* Returns: Number of used 32 bit words. +*/ + +static inline uint32_t fifo32_num_used (Fifo32 *fifo) +{ +return DIV_ROUND_UP (fifo8_num_used (&fifo->fifo),sizeof (uint32_t )); +} + +/** +* fifo32_push: +* @fifo: FIFO to push to +* @data: 32 bits data word to push +* +* Push a 32 bits data word to the FIFO. Behaviour is undefined if the FIFO +* is full. Clients are responsible for checking for fullness using +* fifo32_is_full(). +*/ + +static inline void fifo32_push (Fifo32 *fifo,uint32_t data) +{ +int i; + +for (i =0 ; i <sizeof (data); i++) { +fifo8_push (&fifo->fifo, data &0xff ); + data >>=8 ; + } +} + +/** +* fifo32_push_all: +* @fifo: FIFO to push to +* @data: data to push +* @size: number of 32 bit words to push +* +* Push a 32 bit word array to the FIFO. Behaviour is undefined if the FIFO +* is full. Clients are responsible for checking the space left in the FIFO +* using fifo32_num_free(). +*/ + +static inline void fifo32_push_all (Fifo32 *fifo,const uint32_t *data, +uint32_t num) +{ +int i; + +for (i =0 ; i < num; i++) { +fifo32_push (fifo, data[i]); + } +} + +/** +* fifo32_pop: +* @fifo: fifo to pop from +* +* Pop a 32 bits data word from the FIFO. Behaviour is undefined if the FIFO +* is empty. Clients are responsible for checking for emptiness using +* fifo32_is_empty(). +* +* Returns: The popped 32 bits data word. +*/ + +static inline uint32_t fifo32_pop (Fifo32 *fifo) +{ +uint32_t ret =0 ; +int i; + +for (i =0 ; i <sizeof (uint32_t ); i++) { + ret |= (fifo8_pop (&fifo->fifo) << (i *8 )); + } + +return ret; +} + +/** +* There is no fifo32_pop_buf() because the data is not stored in the buffer +* as a set of native-order words. +*/ + +/** +* fifo32_reset: +* @fifo: FIFO to reset +* +* Reset a FIFO. All data is discarded and the FIFO is emptied. +*/ + +static inline void fifo32_reset (Fifo32 *fifo) +{ +fifo8_reset (&fifo->fifo); +} + +/** +* fifo32_is_empty: +* @fifo: FIFO to check +* +* Check if a FIFO is empty. +* +* Returns: True if the fifo is empty, false otherwise. +*/ + +static inline bool fifo32_is_empty (Fifo32 *fifo) +{ +return fifo8_is_empty (&fifo->fifo); +} + +/** +* fifo32_is_full: +* @fifo: FIFO to check +* +* Check if a FIFO is full. +* +* Returns: True if the fifo is full, false otherwise. +*/ + +static inline bool fifo32_is_full (Fifo32 *fifo) +{ +return fifo8_num_free (&fifo->fifo) <sizeof (uint32_t ); +} + +#define VMSTATE_FIFO32 (_field, _state) VMSTATE_FIFO8(_field.fifo, _state) + +#endif /* FIFO32_H */
Signature · 1 line
2.5.0
PATCH v6 4/6 i.MX: Add the Freescale SPI Controller
In reply to Jean-Christophe Dubois---
Changes since V1:
* Access SPI slave only at a byte level.
* rework the CS activation to avoid to reset access to SPI slaves.
Changes since V2:
* Added #include "qemu/osdep.h"
* remove previous_level from state struct
* save burst_length in VMSTATE
Changes since V3:
* Don't call qemu_set_irq() in reset function
Changes since V4:
* None
Changes since V5:
* None
hw/ssi/Makefile.objs | 1 + hw/ssi/imx_spi.c | 454 +++++++++++++++++++++++++++++++++++++++++++++++ include/hw/ssi/imx_spi.h | 103 +++++++++++ 3 files changed, 558 insertions(+) create mode 100644 hw/ssi/imx_spi.c create mode 100644 include/hw/ssi/imx_spi.h
hw/ssi/Makefile.objs +1 -0
@@ -4,3 +4,4 @@ common-obj-$(CONFIG_XILINX_SPI) += xilinx_spi.o common-obj-$(CONFIG_XILINX_SPIPS) += xilinx_spips.o obj-$(CONFIG_OMAP) += omap_spi.o +obj-$(CONFIG_IMX) += imx_spi.o
hw/ssi/imx_spi.c new file +454 -0
454 lines not on this page · raw message
include/hw/ssi/imx_spi.h new file +103 -0
103 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v6 5/6 i.MX: Add i.MX6 SOC implementation.
In reply to Jean-Christophe DuboisFor now we only support the following devices:
* up to 4 Cortex A9 cores
* A9 MPCORE (SCU, GIC, TWD)
* 5 i.MX UARTs
* 2 EPIT timers
* 1 GPT timer
* 3 I2C controllers
* 7 GPIO controllers
* 6 SDHC controllers
* 5 SPI controllers
* 1 CCM device
* 1 SRC device
* various ROM/RAM areas.
---
Changes since V1:
* use g_strdup_printf/g_free instead of local char array.
* output a message on exit for unsupported number of cores.
Changes since V2:
* Added Include "osdep/qemu.h"
* Added support for EL3
* Added SPI controllers
* Added a property for each controller.
Changes since V3:
* None.
Changes since V4:
* None.
Changes since V5:
* None.
default-configs/arm-softmmu.mak | 1 + hw/arm/Makefile.objs | 1 + hw/arm/fsl-imx6.c | 449 +++++++++++++++++++++++++++++++++++++++ include/hw/arm/fsl-imx6.h | 450 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 901 insertions(+) create mode 100644 hw/arm/fsl-imx6.c create mode 100644 include/hw/arm/fsl-imx6.h
default-configs/arm-softmmu.mak +1 -0
@@ -100,6 +100,7 @@ CONFIG_ALLWINNER_A10_PIT=y CONFIG_ALLWINNER_A10_PIC=y CONFIG_ALLWINNER_A10=y +CONFIG_FSL_IMX6=y CONFIG_FSL_IMX31=y CONFIG_FSL_IMX25=y
hw/arm/Makefile.objs +1 -0
@@ -16,4 +16,5 @@ obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp.o xlnx-ep108.o obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o +obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o obj-$(CONFIG_ASPEED_SOC) += ast2400.o palmetto-bmc.o
hw/arm/fsl-imx6.c new file +449 -0
449 lines not on this page · raw message
include/hw/arm/fsl-imx6.h new file +450 -0
450 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v6 6/6 i.MX: Add sabrelite i.MX6 emulation.
In reply to Jean-Christophe DuboisThe sabrelite supports one SPI FLASH memory on SPI1
---
Changes since V1:
* Output a message and exit if RAM size is unsupported.
Changes since V2:
* Added include "qemu/osdep.h"
* Added access to controllers through properties.
Changes since V3:
* None
Changes since V4:
* Added a TODO.
Changes since V5:
* None
hw/arm/Makefile.objs | 2 +- hw/arm/sabrelite.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 hw/arm/sabrelite.c
hw/arm/Makefile.objs +1 -1
@@ -16,5 +16,5 @@ obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp.o xlnx-ep108.o obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o -obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o +obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o obj-$(CONFIG_ASPEED_SOC) += ast2400.o palmetto-bmc.o
hw/arm/sabrelite.c new file +122 -0
122 lines not on this page · raw message
Signature · 1 line
2.5.0
This will not compile on "target-arm.next" as I need to rework a bit the header file included.
I am fixing it and will send a v7.
Sorry for the noise.
JC
Quoted 65 lines · Jean-Christophe Dubois
This patch series adds support for the Freescale i.MX6 processor.
For now we only support the following devices:
* up to 4 Cortex A9 cores
* A9 MPCORE (SCU, GIC, TWD)
* 5 i.MX UARTs
* 2 EPIT timers
* 1 GPT timer
* 7 GPIO controllers
* 6 SDHC controllers
* 5 SPI controllers
* 1 CCM device
* 1 SRC device
* 3 I2C devices
* various ROM/RAM areas.This also adds the sabrelite board as a an actual platform for i.MX6.
This series was tested by booting a 4.4 linux kernel (using the
imx_v6_v7_defconfigfile as kernel configuration).Note1: as sabrelite uses uart2 as console, you have to redirect the second QEMU serial port to stdout.
qemu-system-arm -M sabrelite -display none ... -serial null -serial stdioNote2: You need to disable the GPIO section related to physical push buttons in the Linux DTS tree in order to avoid excecive interrupt triggering on GPIO devices for non existant buttons.
Jean-Christophe Dubois (6):
ARM: Factor out ARM on/off PSCI control functions i.MX: Add i.MX6 System Reset Controller device.
FIFO: Add a FIFO32 implementation
i.MX: Add the Freescale SPI Controller i.MX: Add i.MX6 SOC implementation.
i.MX: Add sabrelite i.MX6 emulation.default-configs/arm-softmmu.mak | 1 + hw/arm/Makefile.objs | 1 + hw/arm/fsl-imx6.c | 449 +++++++++++++++++++++++++++++++++++++++ hw/arm/sabrelite.c | 122 +++++++++++ hw/misc/Makefile.objs | 1 + hw/misc/imx6_src.c | 264 +++++++++++++++++++++++ hw/ssi/Makefile.objs | 1 + hw/ssi/imx_spi.c | 454 ++++++++++++++++++++++++++++++++++++++++ include/hw/arm/fsl-imx6.h | 450 +++++++++++++++++++++++++++++++++++++++ include/hw/misc/imx6_src.h | 73 +++++++ include/hw/ssi/imx_spi.h | 103 +++++++++ include/qemu/fifo32.h | 191 +++++++++++++++++ target-arm/Makefile.objs | 1 + target-arm/arm-powerctl.c | 224 ++++++++++++++++++++ target-arm/arm-powerctl.h | 75 +++++++ target-arm/psci.c | 70 +------ 16 files changed, 2417 insertions(+), 63 deletions(-)create mode 100644
hw/arm/fsl-imx6.c
create mode 100644hw/arm/sabrelite.c
create mode 100644hw/misc/imx6_src.c
create mode 100644hw/ssi/imx_spi.c
create mode 100644include/hw/arm/fsl-imx6.h
create mode 100644include/hw/misc/imx6_src.h
create mode 100644include/hw/ssi/imx_spi.h
create mode 100644include/qemu/fifo32.h
create mode 100644target-arm/arm-powerctl.c
create mode 100644target-arm/arm-powerctl.h