NXP i.MX RT595
cover NXP i.MX RT595
This patch set adds support for NXP's RT500 MCU [1] and the RT595 EVK[2]. More RT500 device models will be submitted in future patch sets.
This is a minimal patch set that allows running the NXP MCU SDK hello world example[4].
The patch set introduces a (python) tool that generates C header files from ARM SVD files[3]. This significantly reduces the effort to write a new device model by automatically generating: register definitions and layout (including bit fields), register names for easier debugging and tracing, reset register values, register write masks, etc.
The generated files are commited and not generated at compile time. Build targets are created so that they can be easily regenerated if needed.
Changes since RFC v3:
* rewrite the flexcomm devices to take advantage of QEMU's object model / class inheritance and overlapped memory region and remove the adhoc flexcomm APIs
* remove code duplication by using common fifo functions for USART and SPI
* fix copyright in one of the headers
* remove hw/registerfields.h from generated headers as hw/register.h is already included
* fix signed off email address for the qtests API patches
* fix description (tests/unit -> tests/qtest) for RT500 clock controller tests
* convert devices to use the Resettable interfaces
* add support for migration
* rework the fifo32 tests on top of Mark's and Phillippe's work
Changes since RFC v2:
* convert tests from unit to qtest
* move i2c and spi testers from unit tests to hw/misc devices
* switch to using RegisterAccessInfo to generate register information like register names, reset values, or read-only mask
* use register_write instead of adding a new reg32_write API
* remove reg32_aligned_access completly and rely on memops access constraints and size of access for alignment checks
* add qtest APIs for checking memory access faulires
* add qtest APIs for accessing the device clock frequency
* fix bugs detected by address sanitizers
Changes since RFC v1:
* setup scripts/git.orderfile
* svd_gen_header: add support for multi line comments
* svd_gen_header: use qemu register fields instead of bitfields
* svd_gen_header: generate register write mask array
* add mcux-soc-svd as a subproject instead of commiting the rt595 SVD file directly
* svd generated headers: don't generate them at compile time, instead commit the generated headers and create compile targets so that it is easy to regenerate them
* remove pysvd dependency; developers who need to (re)generate svd headers need to have it installed on the host machine
* use DEFINE_TYPES where possible
* use g_strdup_printf where possible
* reduce iterator variables scopes
* hard code rt500 to use the cortex-m33
* use static for local arrays initializers
* remove rt500 properties as they are not yet used
* drop private/public comments
* remove unused headers
* free rt500 mem regions in rt500_unrealize() instead of rt500_finalize
* use memops access constraints where possible instead of reg32_aligned_access
* flexspi: use 64bit properties for mmap_size property
* rstctl: use a generic abstract type and remove the "num" property
* flexspi: don't call get_system_memory() directly and remove mmap_base property
[1] https://www.nxp.com/docs/en/data-sheet/IMXRT500EC.pdf
[2] https://www.nxp.com/webapp/Download?colCode=MIMXRT595EVKHUG
[3] https://arm-software.github.io/CMSIS_5/SVD/html/index.html
[4] Building and running the NXP MCU SDK hello world example
Clone the following git repos:
https://github.com/nxp-mcuxpresso/cmsis.git,
https://github.com/nxp-mcuxpresso/mcux-sdk.git
https://github.com/nxp-mcuxpresso/mcux-sdk-examples.git
in the following directories: CMSIS, core, examples.
cd examples/evkmimxrt595/demo_apps/hello_world/armgcc
ARMGCC_DIR=/usr CFLAGS=-I../../../../../CMSIS/CMSIS/Core/Include \
sh build_flash_debug.sh
qemu-system-arm --machine rt595-evk -kernel flash_debug/hello_world.elf \
-global armv7m.init-nsvtor=0x08001000 -global armv7m.init-svtor=0x08001000 \
-chardev stdio,id=flexcomm0Octavian Purdila (22):
fifo32: add peek function
tests/unit: add fifo32 tests
Add mcux-soc-svd subproject
hw/misc: add support for flexcomm hw/misc/flexcomm.c: add common fifo functionality hw/char: add support for flexcomm usart
hw/i2c: add support for flexcomm i2c
hw/misc: add support for RT500's clock controller hw/ssi: add support for flexspi
hw/misc: add support for RT500's reset controller hw/arm: add basic support for the RT500 SoC hw/arm: add RT595-EVK board
tests/qtest: add register access macros and functions system/qtest: add APIS to check for memory access failures tests/qtest: add flexcomm tests
tests/qtest: add flexcomm usart tests
hw/misc: add i2c-tester
tests/qtest: add tests for flexcomm i2c
hw/ssi: allow NULL realize callbacks for peripherals hw/misc: add spi-tester
systems/qtest: add device clock APIs tests/qtest: add tests for RT500's clock controller
Sebastian Ene (2):
hw/ssi: add support for flexcomm spi
tests/qtest: add tests for flexcomm spi
Stefan Stanacar (1):
scripts: add script to generate C header files from SVD XML files
meson.build | 4 + include/hw/arm/rt500.h | 44 + include/hw/arm/svd/flexcomm.h | 112 + include/hw/arm/svd/flexcomm_i2c.h | 1190 ++++++ include/hw/arm/svd/flexcomm_spi.h | 1036 +++++ include/hw/arm/svd/flexcomm_usart.h | 1021 +++++ include/hw/arm/svd/flexspi.h | 2656 +++++++++++++ include/hw/arm/svd/rt500.h | 63 + include/hw/arm/svd/rt500_clkctl0.h | 2483 ++++++++++++ include/hw/arm/svd/rt500_clkctl1.h | 3396 +++++++++++++++++ include/hw/arm/svd/rt500_rstctl0.h | 858 +++++ include/hw/arm/svd/rt500_rstctl1.h | 1371 +++++++ include/hw/char/flexcomm_usart.h | 33 + include/hw/i2c/flexcomm_i2c.h | 40 + include/hw/misc/flexcomm.h | 57 + include/hw/misc/flexcomm_function.h | 55 + include/hw/misc/i2c_tester.h | 30 + include/hw/misc/rt500_clk_freqs.h | 18 + include/hw/misc/rt500_clkctl0.h | 35 + include/hw/misc/rt500_clkctl1.h | 36 + include/hw/misc/rt500_rstctl.h | 32 + include/hw/misc/spi_tester.h | 32 + include/hw/qdev-clock.h | 10 + include/hw/ssi/flexcomm_spi.h | 36 + include/hw/ssi/flexspi.h | 31 + include/qemu/fifo32.h | 28 + tests/qtest/libqtest-single.h | 116 + tests/qtest/libqtest.h | 98 + tests/qtest/reg-utils.h | 70 + hw/arm/rt500.c | 329 ++ hw/arm/rt595-evk.c | 64 + hw/char/flexcomm_usart.c | 288 ++ hw/core/qdev-clock.c | 2 +- hw/i2c/flexcomm_i2c.c | 250 ++ hw/misc/flexcomm.c | 411 ++ hw/misc/i2c_tester.c | 109 + hw/misc/rt500_clkctl0.c | 253 ++ hw/misc/rt500_clkctl1.c | 238 ++ hw/misc/rt500_rstctl.c | 258 ++ hw/misc/spi_tester.c | 67 + hw/ssi/flexcomm_spi.c | 422 ++ hw/ssi/flexspi.c | 181 + hw/ssi/ssi.c | 4 +- system/qtest.c | 95 +- tests/qtest/flexcomm-i2c-test.c | 170 + tests/qtest/flexcomm-spi-test.c | 145 + tests/qtest/flexcomm-test.c | 82 + tests/qtest/flexcomm-usart-test.c | 316 ++ tests/qtest/libqtest.c | 102 +- tests/qtest/rt500-clkctl-test.c | 195 + tests/unit/test-fifo.c | 50 + hw/arm/Kconfig | 12 + hw/arm/meson.build | 4 + hw/arm/svd/meson.build | 35 + hw/char/meson.build | 1 + hw/char/trace-events | 8 + hw/i2c/meson.build | 1 + hw/i2c/trace-events | 10 + hw/misc/Kconfig | 21 + hw/misc/meson.build | 7 + hw/misc/trace-events | 18 + hw/ssi/Kconfig | 4 + hw/ssi/meson.build | 2 + hw/ssi/trace-events | 9 + meson_options.txt | 3 + scripts/meson-buildoptions.sh | 4 + scripts/svd-gen-header.py | 329 ++ subprojects/.gitignore | 1 + subprojects/mcux-soc-svd.wrap | 5 + .../packagefiles/mcux-soc-svd/meson.build | 5 + tests/qtest/meson.build | 3 + 71 files changed, 19482 insertions(+), 22 deletions(-) create mode 100644 include/hw/arm/rt500.h create mode 100644 include/hw/arm/svd/flexcomm.h create mode 100644 include/hw/arm/svd/flexcomm_i2c.h create mode 100644 include/hw/arm/svd/flexcomm_spi.h create mode 100644 include/hw/arm/svd/flexcomm_usart.h create mode 100644 include/hw/arm/svd/flexspi.h create mode 100644 include/hw/arm/svd/rt500.h create mode 100644 include/hw/arm/svd/rt500_clkctl0.h create mode 100644 include/hw/arm/svd/rt500_clkctl1.h create mode 100644 include/hw/arm/svd/rt500_rstctl0.h create mode 100644 include/hw/arm/svd/rt500_rstctl1.h create mode 100644 include/hw/char/flexcomm_usart.h create mode 100644 include/hw/i2c/flexcomm_i2c.h create mode 100644 include/hw/misc/flexcomm.h create mode 100644 include/hw/misc/flexcomm_function.h create mode 100644 include/hw/misc/i2c_tester.h create mode 100644 include/hw/misc/rt500_clk_freqs.h create mode 100644 include/hw/misc/rt500_clkctl0.h create mode 100644 include/hw/misc/rt500_clkctl1.h create mode 100644 include/hw/misc/rt500_rstctl.h create mode 100644 include/hw/misc/spi_tester.h create mode 100644 include/hw/ssi/flexcomm_spi.h create mode 100644 include/hw/ssi/flexspi.h create mode 100644 tests/qtest/reg-utils.h create mode 100644 hw/arm/rt500.c create mode 100644 hw/arm/rt595-evk.c create mode 100644 hw/char/flexcomm_usart.c create mode 100644 hw/i2c/flexcomm_i2c.c create mode 100644 hw/misc/flexcomm.c create mode 100644 hw/misc/i2c_tester.c create mode 100644 hw/misc/rt500_clkctl0.c create mode 100644 hw/misc/rt500_clkctl1.c create mode 100644 hw/misc/rt500_rstctl.c create mode 100644 hw/misc/spi_tester.c create mode 100644 hw/ssi/flexcomm_spi.c create mode 100644 hw/ssi/flexspi.c create mode 100644 tests/qtest/flexcomm-i2c-test.c create mode 100644 tests/qtest/flexcomm-spi-test.c create mode 100644 tests/qtest/flexcomm-test.c create mode 100644 tests/qtest/flexcomm-usart-test.c create mode 100644 tests/qtest/rt500-clkctl-test.c create mode 100644 hw/arm/svd/meson.build create mode 100755 scripts/svd-gen-header.py create mode 100644 subprojects/mcux-soc-svd.wrap create mode 100644 subprojects/packagefiles/mcux-soc-svd/meson.build
Signature · 1 line
2.46.0.662.g92d0881bb0-goog
PATCH 1/25 fifo32: add peek function
Add fifo32_peek() that returns the first element from the queue without popping it.
--- include/qemu/fifo32.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
include/qemu/fifo32.h +28 -0
@@ -140,6 +140,34 @@ static inline uint32_t fifo32_pop(Fifo32 *fifo)return ret; } +/** +* fifo32_peek: +* @fifo: fifo to peek at +* +* Returns the value from the FIFO's head without poping it. Behaviour +* is undefined if the FIFO is empty. Clients are responsible for +* checking for emptiness using fifo32_is_empty(). +* +* Returns: the value from the FIFO's head +*/ + +static inline uint32_t fifo32_peek (Fifo32 *fifo) +{ +uint32_t ret =0 , num; +const uint8_t *buf; + + buf =fifo8_peek_bufptr (&fifo->fifo,4 , &num); +if (num !=4 ) { +return ret; + } + +for (int i =0 ; i <sizeof (uint32_t ); i++) { + ret |= buf[i] << (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.
Signature · 1 line
2.46.0.662.g92d0881bb0-goog
PATCH 2/25 tests/unit: add fifo32 tests
In reply to Octavian PurdilaAdd push/pop and peek tests for fifo32.
--- tests/unit/test-fifo.c | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
tests/unit/test-fifo.c +50 -0
@@ -13,6 +13,7 @@#include "qemu/osdep.h" #include "migration/vmstate.h" #include "qemu/fifo8.h" +#include "qemu/fifo32.h" const VMStateInfo vmstate_info_uint32;const VMStateInfo vmstate_info_buffer;
@@ -432,6 +433,53 @@ static void test_fifo8_pushpop(void)fifo8_destroy (&fifo); } +static void test_fifo32_pushpop (void ) +{ +Fifo32 fifo; +uint32_t e; + +fifo32_create (&fifo,2 ); +fifo32_push (&fifo,0x11121314 ); +fifo32_push (&fifo,0x21222324 ); +g_assert (fifo32_num_used (&fifo) ==2 ); + + e =fifo32_pop (&fifo); +g_assert (e ==0x11121314 ); +g_assert (fifo32_num_used (&fifo) ==1 ); + + e =fifo32_peek (&fifo); +g_assert (e ==0x21222324 ); + +g_assert (fifo32_num_used (&fifo) ==1 ); +fifo32_destroy (&fifo); +} + +static void test_fifo32_peek (void ) +{ +Fifo32 fifo; +uint32_t e; + +fifo32_create (&fifo,2 ); +fifo32_push (&fifo,0x11121314 ); +fifo32_push (&fifo,0x21222324 ); +g_assert (fifo32_num_used (&fifo) ==2 ); + + e =fifo32_peek (&fifo); +g_assert (e ==0x11121314 ); +g_assert (fifo32_num_used (&fifo) ==2 ); + + e =fifo32_pop (&fifo); +g_assert (e ==0x11121314 ); +g_assert (fifo32_num_used (&fifo) ==1 ); + + e =fifo32_peek (&fifo); +g_assert (e ==0x21222324 ); +g_assert (fifo32_num_used (&fifo) ==1 ); + +fifo32_destroy (&fifo); +} + +int main (int argc,char *argv[]) {g_test_init (&argc, &argv,NULL );
@@ -445,5 +493,7 @@ int main(int argc, char *argv[])g_test_add_func ("/fifo8/peek_bufptr_wrap" , test_fifo8_peek_bufptr_wrap);g_test_add_func ("/fifo8/pop_bufptr" , test_fifo8_pop_bufptr);g_test_add_func ("/fifo8/pop_bufptr_wrap" , test_fifo8_pop_bufptr_wrap); +g_test_add_func ("/fifo32/pushpop" , test_fifo32_pushpop); +g_test_add_func ("/fifo32/peek" , test_fifo32_peek);return g_test_run (); }
Signature · 1 line
2.46.0.662.g92d0881bb0-goog
PATCH 3/25 scripts: add script to generate C header files from SVD XML files
In reply to Octavian PurdilaFrom: Stefan Stanacar <[email protected]>
The CMSIS System View Description format(CMSIS-SVD) is an XML based description of Arm Cortex-M microcontrollers provided and maintained by sillicon vendors. It includes details such as peripherals registers (down to bitfields), peripheral register block addresses, reset values, etc.
This script uses this information to create header files that makes it easier to emulate peripherals.
The script can be used to create either peripheral specific headers or board / system specific information.
Peripheral specific headers contains information such as register layout (using the qemu register fields infrastructure), register names, register write masks and register reset values, the latter using RegisterAccessInfo.
Here is an excerpt from a generated header:
#pragma once
#include "hw/registerfields.h" /* Flexcomm */ #define FLEXCOMM_REGS_NO (1024) /* Peripheral Select and Flexcomm module ID */ REG32(FLEXCOMM_PSELID, 4088); /* Peripheral Select */ FIELD(FLEXCOMM_PSELID, PERSEL, 0, 3); /* Lock the peripheral select */ FIELD(FLEXCOMM_PSELID, LOCK, 3, 1); /* USART present indicator */ FIELD(FLEXCOMM_PSELID, USARTPRESENT, 4, 1); ...
typedef enum { /* FLEXCOMM_PSELID_LOCK */
/* Peripheral select can be changed by software. */ FLEXCOMM_PSELID_LOCK_UNLOCKED = 0,
/* Peripheral select is locked and cannot be changed until this
* Flexcomm module or the entire device is reset. */
FLEXCOMM_PSELID_LOCK_LOCKED = 1,
} FLEXCOMM_PSELID_LOCK_Enum;
...
#define FLEXCOMM_REGISTER_ACCESS_INFO_ARRAY(_name) \
struct RegisterAccessInfo _name[FLEXCOMM_REGS_NO] = { \
[0 ... FLEXCOMM_REGS_NO -1] = { \
.name = "", \
.addr = -1, \
}, \
[R_FLEXCOMM_PSELID] = { \
.name = "PSELID", \
.addr = 0xFF8, \
.ro = 0xFFFFFFF0, \
.reset = 0x101000, \
}, \
[R_FLEXCOMM_PID] = { \
.name = "PID", \
.addr = 0xFFC, \
.ro = 0xFFFFFFFF, \
.reset = 0x0, \
}, \
}Board specific headers contains information about peripheral base register addresses.
[tavip: pylint fixes, generate layout with qemu register fields instead of bitfields, generate register names, romask and reset values]
--- meson.build | 4 + scripts/svd-gen-header.py | 329 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 333 insertions(+) create mode 100755 scripts/svd-gen-header.py
meson.build +4 -0
@@ -3338,6 +3338,10 @@ tracetool_depends = files( 'scripts/tracetool/__init__.py', ) +svd_gen_header = [ + python, files('scripts/svd-gen-header.py') +] + qemu_version_cmd = [find_program('scripts/qemu-version.sh'), meson.current_source_dir(), get_option('pkgversion'), meson.project_version()]
scripts/svd-gen-header.py new file +329 -0
329 lines not on this page · raw message
Signature · 1 line
2.46.0.662.g92d0881bb0-goog
PATCH 4/25 Add mcux-soc-svd subproject
In reply to Octavian PurdilaAdd mcux-soc-svd subproject that contains SVD files that are going to be used to generate C header with register layout definitions and other helpers to create device models.
Guard the subproject by a configuration option since it is rarely going to be used - whenever new headers will be generated. It is unlikely that already generated headers will be updated, with the exception of minor hardware revisions.
Also export the rt595 SVD file which is going to be used by subsequent patches.
TBD: switch to a qemu gitlab fork before merge
--- hw/arm/svd/meson.build | 4 ++++ meson_options.txt | 3 +++ scripts/meson-buildoptions.sh | 4 ++++ subprojects/.gitignore | 1 + subprojects/mcux-soc-svd.wrap | 5 +++++ subprojects/packagefiles/mcux-soc-svd/meson.build | 5 +++++ 6 files changed, 22 insertions(+) create mode 100644 hw/arm/svd/meson.build create mode 100644 subprojects/mcux-soc-svd.wrap create mode 100644 subprojects/packagefiles/mcux-soc-svd/meson.build
hw/arm/svd/meson.build new file +4 -0
@@ -0,0 +1,4 @@ +if get_option('mcux-soc-svd') + mcux_soc_svd = subproject('mcux-soc-svd') + rt595 = mcux_soc_svd.get_variable('rt595') +endif
meson_options.txt +3 -0
@@ -375,3 +375,6 @@ option('hexagon_idef_parser', type : 'boolean', value : true, option('x86_version', type : 'combo', choices : ['0', '1', '2', '3', '4'], value: '1', description: 'tweak required x86_64 architecture version beyond compiler default') + +option('mcux-soc-svd', type : 'boolean', value : false, + description: 'enable targets to generate C headers from mcux-soc-svd')
scripts/meson-buildoptions.sh +4 -0
@@ -41,6 +41,8 @@ meson_options_help() { printf "%s\n" ' --enable-lto Use link time optimization' printf "%s\n" ' --enable-malloc=CHOICE choose memory allocator to use [system] (choices:' printf "%s\n" ' jemalloc/system/tcmalloc)' + printf "%s\n" ' --enable-mcux-soc-svd enable targets to generate C headers from mcux-' + printf "%s\n" ' soc-svd' printf "%s\n" ' --enable-module-upgrades try to load modules from alternate paths for' printf "%s\n" ' upgrades' printf "%s\n" ' --enable-rng-none dummy RNG, avoid using /dev/(u)random and'
@@ -395,6 +397,8 @@ _meson_option_parse() { --enable-malloc-trim) printf "%s" -Dmalloc_trim=enabled ;; --disable-malloc-trim) printf "%s" -Dmalloc_trim=disabled ;; --mandir=*) quote_sh "-Dmandir=$2" ;; + --enable-mcux-soc-svd) printf "%s" -Dmcux-soc-svd=true ;; + --disable-mcux-soc-svd) printf "%s" -Dmcux-soc-svd=false ;; --enable-membarrier) printf "%s" -Dmembarrier=enabled ;; --disable-membarrier) printf "%s" -Dmembarrier=disabled ;; --enable-module-upgrades) printf "%s" -Dmodule_upgrades=true ;;
subprojects/.gitignore +1 -0
@@ -6,3 +6,4 @@ /keycodemapdb /libvfio-user /slirp +/mcux-soc-svd
subprojects/mcux-soc-svd.wrap new file +5 -0
@@ -0,0 +1,5 @@ +[wrap-git] +url = https://github.com/nxp-mcuxpresso/mcux-soc-svd/ +revision = 7f6f9ef7420144fe14cd9bc4d8e0e3523232da04 +patch_directory = mcux-soc-svd +depth = 1
subprojects/packagefiles/mcux-soc-svd/meson.build new file +5 -0
@@ -0,0 +1,5 @@ +project('mcux-soc-svd') + +fs = import('fs') + +rt595 = fs.copyfile('MIMXRT595S/MIMXRT595S_cm33.xml')
Signature · 1 line
2.46.0.662.g92d0881bb0-goog
PATCH 5/25 hw/misc: add support for flexcomm
In reply to Octavian PurdilaAdd support for NXP's FLEXCOMM device model.
FLEXCOMM is a generic serial communication module which support multiple functions: UART, SPI and I2C. These are configurable at runtime.
An abstract FlexcomFunction class is created that will be extended for specific functions. Each function has a dedicated overlapped MemoryRegion that it is going to be activated when that particular function is selected.
A generic MemoryRegion is used to map generic registers (PSELID, PID) that is always active but has a lower priority. The function memory region is trimed to not include the generic registers.
The FlexcommFunction object also gets access to the (non-concurrently) shared register backstore.
The patch includes an automatically generated header which contains the register layout and helpers.
The header can be regenerated with the svd-flexcomm target when the build is configured with --enable-mcux-soc-svd.
--- include/hw/arm/svd/flexcomm.h | 112 ++++++++++ include/hw/misc/flexcomm.h | 49 +++++ include/hw/misc/flexcomm_function.h | 47 ++++ hw/misc/flexcomm.c | 319 ++++++++++++++++++++++++++++ hw/arm/meson.build | 2 + hw/arm/svd/meson.build | 3 + hw/misc/Kconfig | 3 + hw/misc/meson.build | 2 + hw/misc/trace-events | 5 + 9 files changed, 542 insertions(+) create mode 100644 include/hw/arm/svd/flexcomm.h create mode 100644 include/hw/misc/flexcomm.h create mode 100644 include/hw/misc/flexcomm_function.h create mode 100644 hw/misc/flexcomm.c
include/hw/arm/svd/flexcomm.h new file +112 -0
@@ -0,0 +1,112 @@ +/* +* Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause +* +* Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml +*/ +#pragma once + +#include "hw/register.h" + +/* Flexcomm */ +#define FLEXCOMM_REGS_NO (1024) + +/* Peripheral Select and Flexcomm module ID */ +REG32 (FLEXCOMM_PSELID ,4088 ); +/* Peripheral Select */ +FIELD (FLEXCOMM_PSELID ,PERSEL ,0 ,3 ); +/* Lock the peripheral select */ +FIELD (FLEXCOMM_PSELID ,LOCK ,3 ,1 ); +/* USART present indicator */ +FIELD (FLEXCOMM_PSELID ,USARTPRESENT ,4 ,1 ); +/* SPI present indicator */ +FIELD (FLEXCOMM_PSELID ,SPIPRESENT ,5 ,1 ); +/* I2C present indicator */ +FIELD (FLEXCOMM_PSELID ,I2CPRESENT ,6 ,1 ); +/* I2S Present */ +FIELD (FLEXCOMM_PSELID ,I2SPRESENT ,7 ,1 ); +/* Flexcomm ID */ +FIELD (FLEXCOMM_PSELID ,ID ,12 ,20 ); + +/* Peripheral Identification */ +REG32 (FLEXCOMM_PID ,4092 ); +/* Minor revision of module implementation */ +FIELD (FLEXCOMM_PID , Minor_Rev,8 ,4 ); +/* Major revision of module implementation */ +FIELD (FLEXCOMM_PID , Major_Rev,12 ,4 ); +/* Module identifier for the selected function */ +FIELD (FLEXCOMM_PID ,ID ,16 ,16 ); + + +typedef enum { +/* No peripheral selected. */ +FLEXCOMM_PSELID_PERSEL_NO_PERIPH_SELECTED =0 , +/* USART function selected */ +FLEXCOMM_PSELID_PERSEL_USART =1 , +/* SPI function selected */ +FLEXCOMM_PSELID_PERSEL_SPI =2 , +/* I2C */ +FLEXCOMM_PSELID_PERSEL_I2C =3 , +/* I2S Transmit */ +FLEXCOMM_PSELID_PERSEL_I2S_TRANSMIT =4 , +/* I2S Receive */ +FLEXCOMM_PSELID_PERSEL_I2S_RECEIVE =5 , +}FLEXCOMM_PSELID_PERSEL_Enum ; + +typedef enum { +/* Peripheral select can be changed by software. */ +FLEXCOMM_PSELID_LOCK_UNLOCKED =0 , +/* +* Peripheral select is locked and cannot be changed until this Flexcomm +* module or the entire device is reset. +*/ +FLEXCOMM_PSELID_LOCK_LOCKED =1 , +}FLEXCOMM_PSELID_LOCK_Enum ; + +typedef enum { +/* This Flexcomm module does not include the USART function. */ +FLEXCOMM_PSELID_USARTPRESENT_NOT_PRESENT =0 , +/* This Flexcomm module includes the USART function. */ +FLEXCOMM_PSELID_USARTPRESENT_PRESENT =1 , +}FLEXCOMM_PSELID_USARTPRESENT_Enum ; + +typedef enum { +/* This Flexcomm module does not include the SPI function. */ +FLEXCOMM_PSELID_SPIPRESENT_NOT_PRESENT =0 , +/* This Flexcomm module includes the SPI function. */ +FLEXCOMM_PSELID_SPIPRESENT_PRESENT =1 , +}FLEXCOMM_PSELID_SPIPRESENT_Enum ; + +typedef enum { +/* I2C Not Present */ +FLEXCOMM_PSELID_I2CPRESENT_NOT_PRESENT =0 , +/* I2C Present */ +FLEXCOMM_PSELID_I2CPRESENT_PRESENT =1 , +}FLEXCOMM_PSELID_I2CPRESENT_Enum ; + +typedef enum { +/* I2S Not Present */ +FLEXCOMM_PSELID_I2SPRESENT_NOT_PRESENT =0 , +/* I2S Present */ +FLEXCOMM_PSELID_I2SPRESENT_PRESENT =1 , +}FLEXCOMM_PSELID_I2SPRESENT_Enum ; + + +#define FLEXCOMM_REGISTER_ACCESS_INFO_ARRAY (_name) \ + struct RegisterAccessInfo _name[FLEXCOMM_REGS_NO] = { \ + [0 ... FLEXCOMM_REGS_NO - 1] = { \ + .name = "", \ + .addr = -1, \ + }, \ + [R_FLEXCOMM_PSELID] = { \ + .name = "PSELID", \ + .addr = 0xFF8, \ + .ro = 0xFFFFFFF0, \ + .reset = 0x101000, \ + }, \ + [R_FLEXCOMM_PID] = { \ + .name = "PID", \ + .addr = 0xFFC, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + }
include/hw/misc/flexcomm.h new file +49 -0
49 lines not on this page · raw message
include/hw/misc/flexcomm_function.h new file +47 -0
47 lines not on this page · raw message
hw/misc/flexcomm.c new file +319 -0
319 lines not on this page · raw message
hw/arm/meson.build +2 -0
@@ -82,3 +82,5 @@ system_ss.add(when: 'CONFIG_VEXPRESS', if_true: files('vexpress.c')) system_ss.add(when: 'CONFIG_Z2', if_true: files('z2.c')) hw_arch += {'arm': arm_ss} + +subdir('svd')
hw/arm/svd/meson.build +3 -0
@@ -1,4 +1,7 @@ if get_option('mcux-soc-svd') mcux_soc_svd = subproject('mcux-soc-svd') rt595 = mcux_soc_svd.get_variable('rt595') + run_target('svd-flexcomm', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm.h', + '-p', 'FLEXCOMM0', '-t', 'FLEXCOMM']) endif
hw/misc/Kconfig +3 -0
@@ -213,4 +213,7 @@ config IOSB config XLNX_VERSAL_TRNG bool +config FLEXCOMM + bool + source macio/Kconfig
hw/misc/meson.build +2 -0
@@ -157,3 +157,5 @@ system_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa_ec.c')) # HPPA devices system_ss.add(when: 'CONFIG_LASI', if_true: files('lasi.c')) + +system_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm.c'))
hw/misc/trace-events +5 -0
@@ -362,3 +362,8 @@ aspeed_sli_read(uint64_t offset, unsigned int size, uint32_t data) "To 0x%" PRIx aspeed_sliio_write(uint64_t offset, unsigned int size, uint32_t data) "To 0x%" PRIx64 " of size %u: 0x%" PRIx32 aspeed_sliio_read(uint64_t offset, unsigned int size, uint32_t data) "To 0x%" PRIx64 " of size %u: 0x%" PRIx32 +# flexcomm +flexcomm_reset(void) "" +flexcomm_irq(const char *id, uint8_t irq) "%s %d" +flexcomm_reg_read(const char *devname, const char *regname, uint32_t addr, uint32_t val) "%s: %s[0x%04x] -> 0x%08x" +flexcomm_reg_write(const char *dename, const char *regname, uint32_t addr, uint32_t val) "%s: %s[0x%04x] <- 0x%08x"
Signature · 1 line
2.46.0.662.g92d0881bb0-goog
PATCH 6/25 hw/misc/flexcomm.c: add common fifo functionality
In reply to Octavian PurdilaFLEXCOMM SPI and USART share FIFO functionality. Add common helper functions to avoid code duplication.
--- include/hw/misc/flexcomm.h | 2 + include/hw/misc/flexcomm_function.h | 8 +++ hw/misc/flexcomm.c | 83 +++++++++++++++++++++++++++++ hw/misc/trace-events | 1 + 4 files changed, 94 insertions(+)
include/hw/misc/flexcomm.h +2 -0
@@ -44,6 +44,8 @@ struct FlexcommState {uint32_t functions;qemu_irq irq;bool irq_state; +Fifo32 rx_fifo; + Fifo32 tx_fifo; };#endif /* HW_FLEXCOMM_H */
include/hw/misc/flexcomm_function.h +8 -0
@@ -23,6 +23,8 @@ struct FlexcommFunction {MemoryRegion mmio;uint32_t *regs; +Fifo32 *tx_fifo; +Fifo32 *rx_fifo; };typedef void (*FlexcommFunctionSelect )(FlexcommFunction *f,bool selected);
@@ -32,6 +34,7 @@ struct FlexcommFunctionClass {const MemoryRegionOps *mmio_ops;const char *name; +bool has_fifos;FlexcommFunctionSelect select; };
@@ -43,5 +46,10 @@ static inline void flexcomm_select(FlexcommFunction *obj, bool selected) }void flexcomm_set_irq (FlexcommFunction *f,bool irq); +void flexcomm_update_fifostat (FlexcommFunction *f); +void flexcomm_clear_fifostat (FlexcommFunction *f,uint64_t value); +void flexcomm_init_fifos (FlexcommFunction *f,unsigned num); +void flexcomm_cleanup_fifos (FlexcommFunction *f); +void flexcomm_reset_fifos (FlexcommFunction *f);#endif /* HW_FLEXCOMM_FUNCTION_H */
hw/misc/flexcomm.c +83 -0
118 lines not on this page · raw message
hw/misc/trace-events +1 -0
@@ -367,3 +367,4 @@ flexcomm_reset(void) "" flexcomm_irq(const char *id, uint8_t irq) "%s %d" flexcomm_reg_read(const char *devname, const char *regname, uint32_t addr, uint32_t val) "%s: %s[0x%04x] -> 0x%08x" flexcomm_reg_write(const char *dename, const char *regname, uint32_t addr, uint32_t val) "%s: %s[0x%04x] <- 0x%08x" +flexcomm_fifostat(const char *id, uint32_t fifostat, uint32_t fifoinstat) "%s: %08x %08x"
Signature · 1 line
2.46.0.662.g92d0881bb0-goog
PATCH 7/25 hw/char: add support for flexcomm usart
In reply to Octavian PurdilaAdd support for NXP's flexcomm usart. It supports interupts and FIFO access but no DMA.
The patch includes an automatically generated header which contains the register layout and helpers.
The header can be regenerated with the svd-flexcomm-usart target when the build is configured with --enable-mcux-soc-svd.
--- include/hw/arm/svd/flexcomm_usart.h | 1021 +++++++++++++++++++++++++++ include/hw/char/flexcomm_usart.h | 33 + include/hw/misc/flexcomm.h | 2 + hw/char/flexcomm_usart.c | 288 ++++++++ hw/misc/flexcomm.c | 3 + hw/arm/svd/meson.build | 3 + hw/char/meson.build | 1 + hw/char/trace-events | 8 + 8 files changed, 1359 insertions(+) create mode 100644 include/hw/arm/svd/flexcomm_usart.h create mode 100644 include/hw/char/flexcomm_usart.h create mode 100644 hw/char/flexcomm_usart.c
include/hw/arm/svd/flexcomm_usart.h new file +1021 -0
@@ -0,0 +1,1021 @@ +/* +* Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause +* +* Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml +*/ +#pragma once + +#include "hw/register.h" + +/* Flexcomm USART */ +#define FLEXCOMM_USART_REGS_NO (1024) + +/* USART Configuration */ +REG32 (FLEXCOMM_USART_CFG ,0 ); +/* USART Enable */ +FIELD (FLEXCOMM_USART_CFG ,ENABLE ,0 ,1 ); +/* Data Length. Selects the data size for the USART. */ +FIELD (FLEXCOMM_USART_CFG ,DATALEN ,2 ,2 ); +/* Parity Select. Selects what type of parity is used by the USART. */ +FIELD (FLEXCOMM_USART_CFG ,PARITYSEL ,4 ,2 ); +/* Stop Length */ +FIELD (FLEXCOMM_USART_CFG ,STOPLEN ,6 ,1 ); +/* Mode 32 kHz */ +FIELD (FLEXCOMM_USART_CFG ,MODE32K ,7 ,1 ); +/* LIN Break Mode Enable */ +FIELD (FLEXCOMM_USART_CFG ,LINMODE ,8 ,1 ); +/* CTS Enable */ +FIELD (FLEXCOMM_USART_CFG ,CTSEN ,9 ,1 ); +/* Synchronous Enable. Selects synchronous or asynchronous operation. */ +FIELD (FLEXCOMM_USART_CFG ,SYNCEN ,11 ,1 ); +/* Clock Polarity */ +FIELD (FLEXCOMM_USART_CFG ,CLKPOL ,12 ,1 ); +/* Synchronous mode Master Select */ +FIELD (FLEXCOMM_USART_CFG ,SYNCMST ,14 ,1 ); +/* Loopback Mode */ +FIELD (FLEXCOMM_USART_CFG ,LOOP ,15 ,1 ); +/* Output Enable Turnaround Time Enable for RS-485 Operation. */ +FIELD (FLEXCOMM_USART_CFG ,OETA ,18 ,1 ); +/* Automatic Address Matching Enable */ +FIELD (FLEXCOMM_USART_CFG ,AUTOADDR ,19 ,1 ); +/* Output Enable Select */ +FIELD (FLEXCOMM_USART_CFG ,OESEL ,20 ,1 ); +/* Output Enable Polarity */ +FIELD (FLEXCOMM_USART_CFG ,OEPOL ,21 ,1 ); +/* Receive Data Polarity */ +FIELD (FLEXCOMM_USART_CFG ,RXPOL ,22 ,1 ); +/* Transmit data polarity */ +FIELD (FLEXCOMM_USART_CFG ,TXPOL ,23 ,1 ); + +/* USART Control */ +REG32 (FLEXCOMM_USART_CTL ,4 ); +/* Break Enable */ +FIELD (FLEXCOMM_USART_CTL ,TXBRKEN ,1 ,1 ); +/* Enable Address Detect Mode */ +FIELD (FLEXCOMM_USART_CTL ,ADDRDET ,2 ,1 ); +/* Transmit Disable */ +FIELD (FLEXCOMM_USART_CTL ,TXDIS ,6 ,1 ); +/* Continuous Clock Generation */ +FIELD (FLEXCOMM_USART_CTL ,CC ,8 ,1 ); +/* Clear Continuous Clock */ +FIELD (FLEXCOMM_USART_CTL ,CLRCCONRX ,9 ,1 ); +/* Autobaud Enable */ +FIELD (FLEXCOMM_USART_CTL ,AUTOBAUD ,16 ,1 ); + +/* USART Status */ +REG32 (FLEXCOMM_USART_STAT ,8 ); +/* Receiver Idle */ +FIELD (FLEXCOMM_USART_STAT ,RXIDLE ,1 ,1 ); +/* Transmitter Idle */ +FIELD (FLEXCOMM_USART_STAT ,TXIDLE ,3 ,1 ); +/* CTS value */ +FIELD (FLEXCOMM_USART_STAT ,CTS ,4 ,1 ); +/* Delta CTS */ +FIELD (FLEXCOMM_USART_STAT ,DELTACTS ,5 ,1 ); +/* Transmitter Disabled Status Flag */ +FIELD (FLEXCOMM_USART_STAT ,TXDISSTAT ,6 ,1 ); +/* Received Break */ +FIELD (FLEXCOMM_USART_STAT ,RXBRK ,10 ,1 ); +/* Delta Received Break */ +FIELD (FLEXCOMM_USART_STAT ,DELTARXBRK ,11 ,1 ); +/* Start */ +FIELD (FLEXCOMM_USART_STAT ,START ,12 ,1 ); +/* Framing Error Interrupt Flag */ +FIELD (FLEXCOMM_USART_STAT ,FRAMERRINT ,13 ,1 ); +/* Parity Error Interrupt Flag */ +FIELD (FLEXCOMM_USART_STAT ,PARITYERRINT ,14 ,1 ); +/* Received Noise Interrupt Flag */ +FIELD (FLEXCOMM_USART_STAT ,RXNOISEINT ,15 ,1 ); +/* Auto Baud Error */ +FIELD (FLEXCOMM_USART_STAT ,ABERR ,16 ,1 ); + +/* Interrupt Enable Read and Set for USART (not FIFO) Status */ +REG32 (FLEXCOMM_USART_INTENSET ,12 ); +/* Transmit Idle Flag */ +FIELD (FLEXCOMM_USART_INTENSET ,TXIDLEEN ,3 ,1 ); +/* Delta CTS Input Flag */ +FIELD (FLEXCOMM_USART_INTENSET ,DELTACTSEN ,5 ,1 ); +/* Transmit Disabled Flag */ +FIELD (FLEXCOMM_USART_INTENSET ,TXDISEN ,6 ,1 ); +/* Delta Receive Break Enable */ +FIELD (FLEXCOMM_USART_INTENSET ,DELTARXBRKEN ,11 ,1 ); +/* Start Enable */ +FIELD (FLEXCOMM_USART_INTENSET ,STARTEN ,12 ,1 ); +/* Frame Error Enable */ +FIELD (FLEXCOMM_USART_INTENSET ,FRAMERREN ,13 ,1 ); +/* Parity Error Enble */ +FIELD (FLEXCOMM_USART_INTENSET ,PARITYERREN ,14 ,1 ); +/* Receive Noise Enable */ +FIELD (FLEXCOMM_USART_INTENSET ,RXNOISEEN ,15 ,1 ); +/* Auto Baud Error Enable */ +FIELD (FLEXCOMM_USART_INTENSET ,ABERREN ,16 ,1 ); + +/* Interrupt Enable Clear */ +REG32 (FLEXCOMM_USART_INTENCLR ,16 ); +/* Transmit Idle Clear */ +FIELD (FLEXCOMM_USART_INTENCLR ,TXIDLECLR ,3 ,1 ); +/* Delta CTS Clear */ +FIELD (FLEXCOMM_USART_INTENCLR ,DELTACTSCLR ,5 ,1 ); +/* Transmit Disable Clear */ +FIELD (FLEXCOMM_USART_INTENCLR ,TXDISCLR ,6 ,1 ); +/* Delta Receive Break Clear */ +FIELD (FLEXCOMM_USART_INTENCLR ,DELTARXBRKCLR ,11 ,1 ); +/* Start Clear */ +FIELD (FLEXCOMM_USART_INTENCLR ,STARTCLR ,12 ,1 ); +/* Frame Error Clear */ +FIELD (FLEXCOMM_USART_INTENCLR ,FRAMERRCLR ,13 ,1 ); +/* Parity Error Clear */ +FIELD (FLEXCOMM_USART_INTENCLR ,PARITYERRCLR ,14 ,1 ); +/* Receive Noise Clear */ +FIELD (FLEXCOMM_USART_INTENCLR ,RXNOISECLR ,15 ,1 ); +/* Auto Baud Error Clear */ +FIELD (FLEXCOMM_USART_INTENCLR ,ABERRCLR ,16 ,1 ); + +/* Baud Rate Generator */ +REG32 (FLEXCOMM_USART_BRG ,32 ); +/* Baud Rate Generator Value */ +FIELD (FLEXCOMM_USART_BRG ,BRGVAL ,0 ,16 ); + +/* Interrupt Status */ +REG32 (FLEXCOMM_USART_INTSTAT ,36 ); +/* Transmitter Idle Flag */ +FIELD (FLEXCOMM_USART_INTSTAT ,TXIDLE ,3 ,1 ); +/* Delta CTS Change Flag */ +FIELD (FLEXCOMM_USART_INTSTAT ,DELTACTS ,5 ,1 ); +/* Transmitter Disabled Interrupt Flag */ +FIELD (FLEXCOMM_USART_INTSTAT ,TXDISINT ,6 ,1 ); +/* Delta Receiver Break Change Flag */ +FIELD (FLEXCOMM_USART_INTSTAT ,DELTARXBRK ,11 ,1 ); +/* Start Detected on Receiver Flag */ +FIELD (FLEXCOMM_USART_INTSTAT ,START ,12 ,1 ); +/* Framing Error Interrupt Flag */ +FIELD (FLEXCOMM_USART_INTSTAT ,FRAMERRINT ,13 ,1 ); +/* Parity Error Interrupt Flag */ +FIELD (FLEXCOMM_USART_INTSTAT ,PARITYERRINT ,14 ,1 ); +/* Received Noise Interrupt Flag */ +FIELD (FLEXCOMM_USART_INTSTAT ,RXNOISEINT ,15 ,1 ); +/* Auto Baud Error Interrupt Flag */ +FIELD (FLEXCOMM_USART_INTSTAT ,ABERRINT ,16 ,1 ); + +/* Oversample Selection Register for Asynchronous Communication */ +REG32 (FLEXCOMM_USART_OSR ,40 ); +/* Oversample Selection Value */ +FIELD (FLEXCOMM_USART_OSR ,OSRVAL ,0 ,4 ); + +/* Address Register for Automatic Address Matching */ +REG32 (FLEXCOMM_USART_ADDR ,44 ); +/* Address */ +FIELD (FLEXCOMM_USART_ADDR ,ADDRESS ,0 ,8 ); + +/* FIFO Configuration */ +REG32 (FLEXCOMM_USART_FIFOCFG ,3584 ); +/* Enable the Transmit FIFO. */ +FIELD (FLEXCOMM_USART_FIFOCFG ,ENABLETX ,0 ,1 ); +/* Enable the Receive FIFO */ +FIELD (FLEXCOMM_USART_FIFOCFG ,ENABLERX ,1 ,1 ); +/* FIFO Size Configuration */ +FIELD (FLEXCOMM_USART_FIFOCFG ,SIZE ,4 ,2 ); +/* DMA Configuration for Transmit */ +FIELD (FLEXCOMM_USART_FIFOCFG ,DMATX ,12 ,1 ); +/* DMA Configuration for Receive */ +FIELD (FLEXCOMM_USART_FIFOCFG ,DMARX ,13 ,1 ); +/* Wake-up for Transmit FIFO Level */ +FIELD (FLEXCOMM_USART_FIFOCFG ,WAKETX ,14 ,1 ); +/* Wake-up for Receive FIFO Level */ +FIELD (FLEXCOMM_USART_FIFOCFG ,WAKERX ,15 ,1 ); +/* Empty Command for the Transmit FIFO */ +FIELD (FLEXCOMM_USART_FIFOCFG ,EMPTYTX ,16 ,1 ); +/* Empty Command for the Receive FIFO */ +FIELD (FLEXCOMM_USART_FIFOCFG ,EMPTYRX ,17 ,1 ); +/* Pop FIFO for Debug Reads */ +FIELD (FLEXCOMM_USART_FIFOCFG ,POPDBG ,18 ,1 ); + +/* FIFO Status */ +REG32 (FLEXCOMM_USART_FIFOSTAT ,3588 ); +/* TX FIFO Error */ +FIELD (FLEXCOMM_USART_FIFOSTAT ,TXERR ,0 ,1 ); +/* RX FIFO Error */ +FIELD (FLEXCOMM_USART_FIFOSTAT ,RXERR ,1 ,1 ); +/* Peripheral Interrupt */ +FIELD (FLEXCOMM_USART_FIFOSTAT ,PERINT ,3 ,1 ); +/* Transmit FIFO Empty */ +FIELD (FLEXCOMM_USART_FIFOSTAT ,TXEMPTY ,4 ,1 ); +/* Transmit FIFO is Not Full */ +FIELD (FLEXCOMM_USART_FIFOSTAT ,TXNOTFULL ,5 ,1 ); +/* Receive FIFO is Not Empty */ +FIELD (FLEXCOMM_USART_FIFOSTAT ,RXNOTEMPTY ,6 ,1 ); +/* Receive FIFO is Full */ +FIELD (FLEXCOMM_USART_FIFOSTAT ,RXFULL ,7 ,1 ); +/* Transmit FIFO Current Level */ +FIELD (FLEXCOMM_USART_FIFOSTAT ,TXLVL ,8 ,5 ); +/* Receive FIFO Current Level */ +FIELD (FLEXCOMM_USART_FIFOSTAT ,RXLVL ,16 ,5 ); + +/* FIFO Trigger Settings for Interrupt and DMA Request */ +REG32 (FLEXCOMM_USART_FIFOTRIG ,3592 ); +/* Transmit FIFO Level Trigger Enable. */ +FIELD (FLEXCOMM_USART_FIFOTRIG ,TXLVLENA ,0 ,1 ); +/* Receive FIFO Level Trigger Enable */ +FIELD (FLEXCOMM_USART_FIFOTRIG ,RXLVLENA ,1 ,1 ); +/* Transmit FIFO Level Trigger Point */ +FIELD (FLEXCOMM_USART_FIFOTRIG ,TXLVL ,8 ,4 ); +/* Receive FIFO Level Trigger Point */ +FIELD (FLEXCOMM_USART_FIFOTRIG ,RXLVL ,16 ,4 ); + +/* FIFO Interrupt Enable */ +REG32 (FLEXCOMM_USART_FIFOINTENSET ,3600 ); +/* Transmit Error Interrupt Enable */ +FIELD (FLEXCOMM_USART_FIFOINTENSET ,TXERR ,0 ,1 ); +/* Receive Error Interrupt Enable */ +FIELD (FLEXCOMM_USART_FIFOINTENSET ,RXERR ,1 ,1 ); +/* Transmit FIFO Level Interrupt Enable */ +FIELD (FLEXCOMM_USART_FIFOINTENSET ,TXLVL ,2 ,1 ); +/* Receive FIFO Level Interrupt Enable */ +FIELD (FLEXCOMM_USART_FIFOINTENSET ,RXLVL ,3 ,1 ); + +/* FIFO Interrupt Enable Clear */ +REG32 (FLEXCOMM_USART_FIFOINTENCLR ,3604 ); +/* Transmit Error Interrupt Enable */ +FIELD (FLEXCOMM_USART_FIFOINTENCLR ,TXERR ,0 ,1 ); +/* Receive Error Interrupt Enable */ +FIELD (FLEXCOMM_USART_FIFOINTENCLR ,RXERR ,1 ,1 ); +/* Transmit FIFO Level Interrupt Enable */ +FIELD (FLEXCOMM_USART_FIFOINTENCLR ,TXLVL ,2 ,1 ); +/* Receive FIFO Level Interrupt Enable */ +FIELD (FLEXCOMM_USART_FIFOINTENCLR ,RXLVL ,3 ,1 ); + +/* FIFO Interrupt Status */ +REG32 (FLEXCOMM_USART_FIFOINTSTAT ,3608 ); +/* TX FIFO Error Interrupt Status */ +FIELD (FLEXCOMM_USART_FIFOINTSTAT ,TXERR ,0 ,1 ); +/* RX FIFO Error Interrupt Status */ +FIELD (FLEXCOMM_USART_FIFOINTSTAT ,RXERR ,1 ,1 ); +/* Transmit FIFO Level Interrupt Status */ +FIELD (FLEXCOMM_USART_FIFOINTSTAT ,TXLVL ,2 ,1 ); +/* Receive FIFO Level Interrupt Status */ +FIELD (FLEXCOMM_USART_FIFOINTSTAT ,RXLVL ,3 ,1 ); +/* Peripheral Interrupt Status */ +FIELD (FLEXCOMM_USART_FIFOINTSTAT ,PERINT ,4 ,1 ); + +/* FIFO Write Data */ +REG32 (FLEXCOMM_USART_FIFOWR ,3616 ); +/* Transmit data to the FIFO */ +FIELD (FLEXCOMM_USART_FIFOWR ,TXDATA ,0 ,9 ); + +/* FIFO Read Data */ +REG32 (FLEXCOMM_USART_FIFORD ,3632 ); +/* Received Data from the FIFO */ +FIELD (FLEXCOMM_USART_FIFORD ,RXDATA ,0 ,9 ); +/* Framing Error Status Flag */ +FIELD (FLEXCOMM_USART_FIFORD ,FRAMERR ,13 ,1 ); +/* Parity Error Status Flag */ +FIELD (FLEXCOMM_USART_FIFORD ,PARITYERR ,14 ,1 ); +/* Received Noise Flag */ +FIELD (FLEXCOMM_USART_FIFORD ,RXNOISE ,15 ,1 ); + +/* FIFO Data Read with No FIFO Pop */ +REG32 (FLEXCOMM_USART_FIFORDNOPOP ,3648 ); +/* Received Data from the FIFO */ +FIELD (FLEXCOMM_USART_FIFORDNOPOP ,RXDATA ,0 ,9 ); +/* Framing Error Status Flag */ +FIELD (FLEXCOMM_USART_FIFORDNOPOP ,FRAMERR ,13 ,1 ); +/* Parity Error Status Flag */ +FIELD (FLEXCOMM_USART_FIFORDNOPOP ,PARITYERR ,14 ,1 ); +/* Received Noise Flag */ +FIELD (FLEXCOMM_USART_FIFORDNOPOP ,RXNOISE ,15 ,1 ); + +/* FIFO Size */ +REG32 (FLEXCOMM_USART_FIFOSIZE ,3656 ); +/* FIFO Size */ +FIELD (FLEXCOMM_USART_FIFOSIZE ,FIFOSIZE ,0 ,5 ); + +/* Peripheral Identification */ +REG32 (FLEXCOMM_USART_ID ,4092 ); +/* Aperture */ +FIELD (FLEXCOMM_USART_ID ,APERTURE ,0 ,8 ); +/* Minor revision of module implementation */ +FIELD (FLEXCOMM_USART_ID ,MINOR_REV ,8 ,4 ); +/* Major revision of module implementation */ +FIELD (FLEXCOMM_USART_ID ,MAJOR_REV ,12 ,4 ); +/* Module identifier for the selected function */ +FIELD (FLEXCOMM_USART_ID ,ID ,16 ,16 ); + + +typedef enum { +/* Disabled */ +FLEXCOMM_USART_CFG_ENABLE_DISABLED =0 , +/* Enabled. The USART is enabled for operation. */ +FLEXCOMM_USART_CFG_ENABLE_ENABLED =1 , +}FLEXCOMM_USART_CFG_ENABLE_Enum ; + +typedef enum { +/* 7 bit data length */ +FLEXCOMM_USART_CFG_DATALEN_BIT_7 =0 , +/* 8 bit data length */ +FLEXCOMM_USART_CFG_DATALEN_BIT_8 =1 , +/* +* 9 bit data length. The 9th bit is commonly used for addressing in +* multidrop mode. See the ADDRDET[CTL]. +*/ +FLEXCOMM_USART_CFG_DATALEN_BIT_9 =2 , +}FLEXCOMM_USART_CFG_DATALEN_Enum ; + +typedef enum { +/* No parity */ +FLEXCOMM_USART_CFG_PARITYSEL_NO_PARITY =0 , +/* Even parity */ +FLEXCOMM_USART_CFG_PARITYSEL_EVEN_PARITY =2 , +/* Odd parity */ +FLEXCOMM_USART_CFG_PARITYSEL_ODD_PARITY =3 , +}FLEXCOMM_USART_CFG_PARITYSEL_Enum ; + +typedef enum { +/* 1 stop bit */ +FLEXCOMM_USART_CFG_STOPLEN_BIT_1 =0 , +/* +* 2 stop bits. This setting should be used only for asynchronous +* communication. +*/ +FLEXCOMM_USART_CFG_STOPLEN_BITS_2 =1 , +}FLEXCOMM_USART_CFG_STOPLEN_Enum ; + +typedef enum { +/* Disabled. USART uses standard clocking. */ +FLEXCOMM_USART_CFG_MODE32K_DISABLED =0 , +/* Enabled */ +FLEXCOMM_USART_CFG_MODE32K_ENABLED =1 , +}FLEXCOMM_USART_CFG_MODE32K_Enum ; + +typedef enum { +/* +* Disabled. Break detect and generate is configured for normal operation. +*/ +FLEXCOMM_USART_CFG_LINMODE_DISABLED =0 , +/* +* Enabled. Break detect and generate is configured for LIN bus operation. +*/ +FLEXCOMM_USART_CFG_LINMODE_ENABLED =1 , +}FLEXCOMM_USART_CFG_LINMODE_Enum ; + +typedef enum { +/* +* No flow control. The transmitter does not receive any automatic flow +* control signal. +*/ +FLEXCOMM_USART_CFG_CTSEN_DISABLED =0 , +/* +* Flow control enabled. The transmitter uses the CTS input (or RTS output +* in loopback mode) for flow control purposes. +*/ +FLEXCOMM_USART_CFG_CTSEN_ENABLED =1 , +}FLEXCOMM_USART_CFG_CTSEN_Enum ; + +typedef enum { +/* Asynchronous mode */ +FLEXCOMM_USART_CFG_SYNCEN_ASYNCHRONOUS_MODE =0 , +/* Synchronous mode */ +FLEXCOMM_USART_CFG_SYNCEN_SYNCHRONOUS_MODE =1 , +}FLEXCOMM_USART_CFG_SYNCEN_Enum ; + +typedef enum { +/* Falling edge. RXD is sampled on the falling edge of SCLK. */ +FLEXCOMM_USART_CFG_CLKPOL_FALLING_EDGE =0 , +/* Rising edge. RXD is sampled on the rising edge of SCLK. */ +FLEXCOMM_USART_CFG_CLKPOL_RISING_EDGE =1 , +}FLEXCOMM_USART_CFG_CLKPOL_Enum ; + +typedef enum { +/* Slave. When synchronous mode is enabled, the USART is a slave. */ +FLEXCOMM_USART_CFG_SYNCMST_SLAVE =0 , +/* Master. When synchronous mode is enabled, the USART is a master. */ +FLEXCOMM_USART_CFG_SYNCMST_MASTER =1 , +}FLEXCOMM_USART_CFG_SYNCMST_Enum ; + +typedef enum { +/* Normal operation */ +FLEXCOMM_USART_CFG_LOOP_NORMAL =0 , +/* Loopback mode */ +FLEXCOMM_USART_CFG_LOOP_LOOPBACK =1 , +}FLEXCOMM_USART_CFG_LOOP_Enum ; + +typedef enum { +/* Disabled */ +FLEXCOMM_USART_CFG_OETA_DISABLED =0 , +/* Enabled */ +FLEXCOMM_USART_CFG_OETA_ENABLED =1 , +}FLEXCOMM_USART_CFG_OETA_Enum ; + +typedef enum { +/* Disabled */ +FLEXCOMM_USART_CFG_AUTOADDR_DISABLED =0 , +/* Enabled */ +FLEXCOMM_USART_CFG_AUTOADDR_ENABLED =1 , +}FLEXCOMM_USART_CFG_AUTOADDR_Enum ; + +typedef enum { +/* +* Standard. The RTS signal is used as the standard flow control function. +*/ +FLEXCOMM_USART_CFG_OESEL_STANDARD =0 , +/* +* RS-485. The RTS signal is configured to provide an output enable signal +* to control an RS-485 transceiver. +*/ +FLEXCOMM_USART_CFG_OESEL_RS_485 =1 , +}FLEXCOMM_USART_CFG_OESEL_Enum ; + +typedef enum { +/* Low. If selected by OESEL, the output enable is active low. */ +FLEXCOMM_USART_CFG_OEPOL_LOW =0 , +/* High. If selected by OESEL, the output enable is active high. */ +FLEXCOMM_USART_CFG_OEPOL_HIGH =1 , +}FLEXCOMM_USART_CFG_OEPOL_Enum ; + +typedef enum { +/* Standard */ +FLEXCOMM_USART_CFG_RXPOL_STANDARD =0 , +/* Inverted */ +FLEXCOMM_USART_CFG_RXPOL_INVERTED =1 , +}FLEXCOMM_USART_CFG_RXPOL_Enum ; + +typedef enum { +/* Standard */ +FLEXCOMM_USART_CFG_TXPOL_STANDARD =0 , +/* Inverted */ +FLEXCOMM_USART_CFG_TXPOL_INVERTED =1 , +}FLEXCOMM_USART_CFG_TXPOL_Enum ; + +typedef enum { +/* Normal operation */ +FLEXCOMM_USART_CTL_TXBRKEN_NORMAL =0 , +/* Continuous break */ +FLEXCOMM_USART_CTL_TXBRKEN_CONTINUOUS =1 , +}FLEXCOMM_USART_CTL_TXBRKEN_Enum ; + +typedef enum { +/* Disabled. The USART presents all incoming data. */ +FLEXCOMM_USART_CTL_ADDRDET_DISABLED =0 , +/* Enabled */ +FLEXCOMM_USART_CTL_ADDRDET_ENABLED =1 , +}FLEXCOMM_USART_CTL_ADDRDET_Enum ; + +typedef enum { +/* Not disabled. USART transmitter is not disabled. */ +FLEXCOMM_USART_CTL_TXDIS_ENABLED =0 , +/* +* Disabled. USART transmitter is disabled after any character currently +* being transmitted is complete. This feature can be used to facilitate +* software flow control. +*/ +FLEXCOMM_USART_CTL_TXDIS_DISABLED =1 , +}FLEXCOMM_USART_CTL_TXDIS_Enum ; + +typedef enum { +/* Clock on character */ +FLEXCOMM_USART_CTL_CC_CLOCK_ON_CHARACTER =0 , +/* Continuous clock */ +FLEXCOMM_USART_CTL_CC_CONTINOUS_CLOCK =1 , +}FLEXCOMM_USART_CTL_CC_Enum ; + +typedef enum { +/* No effect. No effect on the CC bit. */ +FLEXCOMM_USART_CTL_CLRCCONRX_NO_EFFECT =0 , +/* Auto-clear */ +FLEXCOMM_USART_CTL_CLRCCONRX_AUTO_CLEAR =1 , +}FLEXCOMM_USART_CTL_CLRCCONRX_Enum ; + +typedef enum { +/* Disabled */ +FLEXCOMM_USART_CTL_AUTOBAUD_DISABLED =0 , +/* Enabled */ +FLEXCOMM_USART_CTL_AUTOBAUD_ENABLED =1 , +}FLEXCOMM_USART_CTL_AUTOBAUD_Enum ; + +typedef enum { +/* The receiver is currently receiving data. */ +FLEXCOMM_USART_STAT_RXIDLE_RX_ACTIVE =0 , +/* The receiver is not currently receiving data. */ +FLEXCOMM_USART_STAT_RXIDLE_RX_IDLE =1 , +}FLEXCOMM_USART_STAT_RXIDLE_Enum ; + +typedef enum { +/* The transmitter is currently sending data. */ +FLEXCOMM_USART_STAT_TXIDLE_TX_ACTIVE =0 , +/* The transmitter is not currently sending data. */ +FLEXCOMM_USART_STAT_TXIDLE_TX_IDLE =1 , +}FLEXCOMM_USART_STAT_TXIDLE_Enum ; + +typedef enum { +/* +* Not Idle. Indicates that the USART transmitter is NOT fully idle after +* being disabled. +*/ +FLEXCOMM_USART_STAT_TXDISSTAT_TX_NOT_IDLE =0 , +/* +* Idle. Indicates that the USART transmitter is fully idle after being +* disabled (CTL[TXDIS] = 1). +*/ +FLEXCOMM_USART_STAT_TXDISSTAT_TX_IDLE =1 , +}FLEXCOMM_USART_STAT_TXDISSTAT_Enum ; + +typedef enum { +/* +* Enables an interrupt when the transmitter becomes idle (STAT[TXIDLE] = +* 1). +*/ +FLEXCOMM_USART_INTENSET_TXIDLEEN_ENABLE =1 , +}FLEXCOMM_USART_INTENSET_TXIDLEEN_Enum ; + +typedef enum { +/* +* Enables an interrupt when there is a change in the state of the CTS +* input. +*/ +FLEXCOMM_USART_INTENSET_DELTACTSEN_ENABLE =1 , +}FLEXCOMM_USART_INTENSET_DELTACTSEN_Enum ; + +typedef enum { +/* +* Enables an interrupt when the transmitter is fully disabled as indicated +* by the STAT[TXDISINT] flag. See the description of the STAT[TXDISINT] +* flag. +*/ +FLEXCOMM_USART_INTENSET_TXDISEN_ENABLE =1 , +}FLEXCOMM_USART_INTENSET_TXDISEN_Enum ; + +typedef enum { +/* Enable */ +FLEXCOMM_USART_INTENSET_DELTARXBRKEN_ENABLE =1 , +}FLEXCOMM_USART_INTENSET_DELTARXBRKEN_Enum ; + +typedef enum { +/* Enables an interrupt when a received start bit has been detected. */ +FLEXCOMM_USART_INTENSET_STARTEN_ENABLE =1 , +}FLEXCOMM_USART_INTENSET_STARTEN_Enum ; + +typedef enum { +/* Enables an interrupt when a framing error has been detected. */ +FLEXCOMM_USART_INTENSET_FRAMERREN_ENABLE =1 , +}FLEXCOMM_USART_INTENSET_FRAMERREN_Enum ; + +typedef enum { +/* Enables an interrupt when a parity error has been detected. */ +FLEXCOMM_USART_INTENSET_PARITYERREN_ENABLE =1 , +}FLEXCOMM_USART_INTENSET_PARITYERREN_Enum ; + +typedef enum { +/* +* Enables an interrupt when noise is detected. See the description of the +* CTL[RXNOISEINT] bit. +*/ +FLEXCOMM_USART_INTENSET_RXNOISEEN_ENABLE =1 , +}FLEXCOMM_USART_INTENSET_RXNOISEEN_Enum ; + +typedef enum { +/* Enables an interrupt when an auto baud error occurs. */ +FLEXCOMM_USART_INTENSET_ABERREN_ENABLE =1 , +}FLEXCOMM_USART_INTENSET_ABERREN_Enum ; + +typedef enum { +/* FCLK is used directly by the USART function. */ + FLEXCOMM_USART_BRG_BRGVAL_Zero =0 , +/* FCLK is divided by 2 before use by the USART function. */ + FLEXCOMM_USART_BRG_BRGVAL_One =1 , +/* FCLK is divided by 3 before use by the USART function. */ + FLEXCOMM_USART_BRG_BRGVAL_Two =2 , +/* FCLK is divided by 65,536 before use by the USART function. */ +FLEXCOMM_USART_BRG_BRGVAL_FFFF =65535 , +}FLEXCOMM_USART_BRG_BRGVAL_Enum ; + +typedef enum { +/* Not supported */ + FLEXCOMM_USART_OSR_OSRVAL_zero =0 , +/* Not supported */ + FLEXCOMM_USART_OSR_OSRVAL_one =1 , +/* Not supported */ + FLEXCOMM_USART_OSR_OSRVAL_two =2 , +/* Not supported */ + FLEXCOMM_USART_OSR_OSRVAL_three =3 , +/* 5 function clocks are used to transmit and receive each data bit. */ + FLEXCOMM_USART_OSR_OSRVAL_four =4 , +/* 6 function clocks are used to transmit and receive each data bit. */ + FLEXCOMM_USART_OSR_OSRVAL_five =5 , +/* 16 function clocks are used to transmit and receive each data bit. */ + FLEXCOMM_USART_OSR_OSRVAL_sixteen =15 , +}FLEXCOMM_USART_OSR_OSRVAL_Enum ; + +typedef enum { +/* The transmit FIFO is not enabled. */ +FLEXCOMM_USART_FIFOCFG_ENABLETX_DISABLED =0 , +/* The transmit FIFO is enabled. */ +FLEXCOMM_USART_FIFOCFG_ENABLETX_ENABLED =1 , +}FLEXCOMM_USART_FIFOCFG_ENABLETX_Enum ; + +typedef enum { +/* The receive FIFO is not enabled. */ +FLEXCOMM_USART_FIFOCFG_ENABLERX_DISABLED =0 , +/* The receive FIFO is enabled. */ +FLEXCOMM_USART_FIFOCFG_ENABLERX_ENABLED =1 , +}FLEXCOMM_USART_FIFOCFG_ENABLERX_Enum ; + +typedef enum { +/* FIFO is configured as 16 entries of 8 bits. */ +FLEXCOMM_USART_FIFOCFG_SIZE_SIZE16 =0 , +/* Not used */ +FLEXCOMM_USART_FIFOCFG_SIZE_SIZEINVALID1 =1 , +/* Not used */ +FLEXCOMM_USART_FIFOCFG_SIZE_SIZEINVALID2 =2 , +/* Not used */ +FLEXCOMM_USART_FIFOCFG_SIZE_SIZEINVALID3 =3 , +}FLEXCOMM_USART_FIFOCFG_SIZE_Enum ; + +typedef enum { +/* DMA is not used for the transmit function. */ +FLEXCOMM_USART_FIFOCFG_DMATX_DISABLED =0 , +/* +* Triggers DMA for the transmit function if the FIFO is not full. +* Generally, data interrupts would be disabled if DMA is enabled. +*/ +FLEXCOMM_USART_FIFOCFG_DMATX_ENABLED =1 , +}FLEXCOMM_USART_FIFOCFG_DMATX_Enum ; + +typedef enum { +/* DMA is not used for the receive function. */ +FLEXCOMM_USART_FIFOCFG_DMARX_DISABLED =0 , +/* +* Triggers DMA for the receive function if the FIFO is not empty. +* Generally, data interrupts would be disabled if DMA is enabled. +*/ +FLEXCOMM_USART_FIFOCFG_DMARX_ENABLED =1 , +}FLEXCOMM_USART_FIFOCFG_DMARX_Enum ; + +typedef enum { +/* Only enabled interrupts will wake up the device from low power modes. */ +FLEXCOMM_USART_FIFOCFG_WAKETX_DISABLED =0 , +/* +* A device wake-up for DMA will occur if the transmit FIFO level reaches +* the value specified by FIFOTRIG[TXLVL], even when the TXLVL interrupt is +* not enabled. +*/ +FLEXCOMM_USART_FIFOCFG_WAKETX_ENABLED =1 , +}FLEXCOMM_USART_FIFOCFG_WAKETX_Enum ; + +typedef enum { +/* Only enabled interrupts will wake up the device from low power modes. */ +FLEXCOMM_USART_FIFOCFG_WAKERX_DISABLED =0 , +/* +* A device wake-up for DMA will occur if the receive FIFO level reaches +* the value specified by FIFOTRIG[RXLVL], even when the RXLVL interrupt is +* not enabled. +*/ +FLEXCOMM_USART_FIFOCFG_WAKERX_ENABLED =1 , +}FLEXCOMM_USART_FIFOCFG_WAKERX_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_USART_FIFOCFG_EMPTYTX_NO_EFFECT =0 , +/* The TX FIFO is emptied. */ +FLEXCOMM_USART_FIFOCFG_EMPTYTX_EMPTY_THE_TX_FIFO =1 , +}FLEXCOMM_USART_FIFOCFG_EMPTYTX_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_USART_FIFOCFG_EMPTYRX_NO_EFFECT =0 , +/* The RX FIFO is emptied. */ +FLEXCOMM_USART_FIFOCFG_EMPTYRX_EMPTY_THE_RX_FIFO =1 , +}FLEXCOMM_USART_FIFOCFG_EMPTYRX_Enum ; + +typedef enum { +/* Debug reads of the FIFO do not pop the FIFO. */ +FLEXCOMM_USART_FIFOCFG_POPDBG_DO_NOT_POP =0 , +/* A debug read will cause the FIFO to pop. */ +FLEXCOMM_USART_FIFOCFG_POPDBG_POP =1 , +}FLEXCOMM_USART_FIFOCFG_POPDBG_Enum ; + +typedef enum { +/* A transmit FIFO error has not occurred. */ +FLEXCOMM_USART_FIFOSTAT_TXERR_NO_TXERR =0 , +/* +* A transmit FIFO error has occurred. This error could be an overflow +* caused by pushing data into a full FIFO, or by an underflow if the FIFO +* is empty when data is needed. +*/ +FLEXCOMM_USART_FIFOSTAT_TXERR_TXERR =1 , +}FLEXCOMM_USART_FIFOSTAT_TXERR_Enum ; + +typedef enum { +/* A receive FIFO overflow has not occurred */ +FLEXCOMM_USART_FIFOSTAT_RXERR_NO_RXERR =0 , +/* +* A receive FIFO overflow has occurred, caused by software or DMA not +* emptying the FIFO fast enough +*/ +FLEXCOMM_USART_FIFOSTAT_RXERR_RXERR =1 , +}FLEXCOMM_USART_FIFOSTAT_RXERR_Enum ; + +typedef enum { +/* No Peripheral Interrupt */ +FLEXCOMM_USART_FIFOSTAT_PERINT_NO_PERINT =0 , +/* Peripheral Interrupt */ +FLEXCOMM_USART_FIFOSTAT_PERINT_PERINT =1 , +}FLEXCOMM_USART_FIFOSTAT_PERINT_Enum ; + +typedef enum { +/* The transmit FIFO is not empty. */ +FLEXCOMM_USART_FIFOSTAT_TXEMPTY_TXFIFO_ISNOTEMPTY =0 , +/* +* The transmit FIFO is empty, although the peripheral may still be +* processing the last piece of data. +*/ +FLEXCOMM_USART_FIFOSTAT_TXEMPTY_TXFIFO_ISEMPTY =1 , +}FLEXCOMM_USART_FIFOSTAT_TXEMPTY_Enum ; + +typedef enum { +/* +* The transmit FIFO is full and another write would cause it to overflow. +*/ +FLEXCOMM_USART_FIFOSTAT_TXNOTFULL_TXFIFO_ISFULL =0 , +/* The transmit FIFO is not full, so more data can be written. */ +FLEXCOMM_USART_FIFOSTAT_TXNOTFULL_TXFIFO_ISNOTFULL =1 , +}FLEXCOMM_USART_FIFOSTAT_TXNOTFULL_Enum ; + +typedef enum { +/* The receive FIFO is empty. */ +FLEXCOMM_USART_FIFOSTAT_RXNOTEMPTY_RXFIFO_ISEMPTY =0 , +/* The receive FIFO is not empty, so data can be read. */ +FLEXCOMM_USART_FIFOSTAT_RXNOTEMPTY_RXFIFO_ISNOTEMPTY =1 , +}FLEXCOMM_USART_FIFOSTAT_RXNOTEMPTY_Enum ; + +typedef enum { +/* The receive FIFO is not full. */ +FLEXCOMM_USART_FIFOSTAT_RXFULL_RXFIFO_ISNOTFULL =0 , +/* The receive FIFO is full. */ +FLEXCOMM_USART_FIFOSTAT_RXFULL_RXFIFO_ISFULL =1 , +}FLEXCOMM_USART_FIFOSTAT_RXFULL_Enum ; + +typedef enum { +/* Transmit FIFO level does not generate a FIFO level trigger. */ +FLEXCOMM_USART_FIFOTRIG_TXLVLENA_DISABLED =0 , +/* +* A trigger will be generated if the transmit FIFO level reaches the value +* specified by the TXLVL field. +*/ +FLEXCOMM_USART_FIFOTRIG_TXLVLENA_ENABLED =1 , +}FLEXCOMM_USART_FIFOTRIG_TXLVLENA_Enum ; + +typedef enum { +/* Receive FIFO level does not generate a FIFO level trigger. */ +FLEXCOMM_USART_FIFOTRIG_RXLVLENA_DISABLED =0 , +/* +* An trigger will be generated if the receive FIFO level reaches the value +* specified by the RXLVL field. +*/ +FLEXCOMM_USART_FIFOTRIG_RXLVLENA_ENABLED =1 , +}FLEXCOMM_USART_FIFOTRIG_RXLVLENA_Enum ; + +typedef enum { +/* Trigger when the TX FIFO becomes empty */ +FLEXCOMM_USART_FIFOTRIG_TXLVL_TXLVL0 =0 , +/* Trigger when the TX FIFO level decreases to 1 entry */ +FLEXCOMM_USART_FIFOTRIG_TXLVL_TXLVL1 =1 , +/* +* Trigger when the TX FIFO level decreases to 15 entries (is no longer +* full) +*/ +FLEXCOMM_USART_FIFOTRIG_TXLVL_TXLVL15 =15 , +}FLEXCOMM_USART_FIFOTRIG_TXLVL_Enum ; + +typedef enum { +/* Trigger when the RX FIFO has received 1 entry (is no longer empty) */ +FLEXCOMM_USART_FIFOTRIG_RXLVL_RXLVL1 =0 , +/* Trigger when the RX FIFO has received 2 entries */ +FLEXCOMM_USART_FIFOTRIG_RXLVL_RXLVL2 =1 , +/* Trigger when the RX FIFO has received 16 entries (has become full) */ +FLEXCOMM_USART_FIFOTRIG_RXLVL_RXLVL15 =15 , +}FLEXCOMM_USART_FIFOTRIG_RXLVL_Enum ; + +typedef enum { +/* No interrupt will be generated for a transmit error. */ +FLEXCOMM_USART_FIFOINTENSET_TXERR_DISABLED =0 , +/* An interrupt will be generated when a transmit error occurs. */ +FLEXCOMM_USART_FIFOINTENSET_TXERR_ENABLED =1 , +}FLEXCOMM_USART_FIFOINTENSET_TXERR_Enum ; + +typedef enum { +/* No interrupt will be generated for a receive error. */ +FLEXCOMM_USART_FIFOINTENSET_RXERR_DISABLED =0 , +/* An interrupt will be generated when a receive error occurs. */ +FLEXCOMM_USART_FIFOINTENSET_RXERR_ENABLED =1 , +}FLEXCOMM_USART_FIFOINTENSET_RXERR_Enum ; + +typedef enum { +/* No interrupt will be generated based on the TX FIFO level. */ +FLEXCOMM_USART_FIFOINTENSET_TXLVL_DISABLED =0 , +/* +* If FIFOTRIG[TXLVLENA] = 1, then an interrupt will be generated when the +* TX FIFO level decreases to the level specified by FIFOTRIG[TXLVL] +*/ +FLEXCOMM_USART_FIFOINTENSET_TXLVL_ENABLED =1 , +}FLEXCOMM_USART_FIFOINTENSET_TXLVL_Enum ; + +typedef enum { +/* No interrupt will be generated based on the RX FIFO level. */ +FLEXCOMM_USART_FIFOINTENSET_RXLVL_DISABLED =0 , +/* +* If FIFOTRIG[RXLVLENA] = 1, an interrupt will be generated when the when +* the RX FIFO level increases to the level specified by FIFOTRIG[RXLVL]. +*/ +FLEXCOMM_USART_FIFOINTENSET_RXLVL_ENABLED =1 , +}FLEXCOMM_USART_FIFOINTENSET_RXLVL_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_USART_FIFOINTENCLR_TXERR_NO_EFFECT =0 , +/* Clear the interrupt */ +FLEXCOMM_USART_FIFOINTENCLR_TXERR_CLEAR_THE_TXERR =1 , +}FLEXCOMM_USART_FIFOINTENCLR_TXERR_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_USART_FIFOINTENCLR_RXERR_NO_EFFECT =0 , +/* Clear the interrupt */ +FLEXCOMM_USART_FIFOINTENCLR_RXERR_CLEAR_THE_RXERR =1 , +}FLEXCOMM_USART_FIFOINTENCLR_RXERR_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_USART_FIFOINTENCLR_TXLVL_NO_EFFECT =0 , +/* Clear the interrupt */ +FLEXCOMM_USART_FIFOINTENCLR_TXLVL_CLEAR_THE_TXLVL =1 , +}FLEXCOMM_USART_FIFOINTENCLR_TXLVL_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_USART_FIFOINTENCLR_RXLVL_NO_EFFECT =0 , +/* Clear the interrupt */ +FLEXCOMM_USART_FIFOINTENCLR_RXLVL_CLEAR_THE_RXLVL =1 , +}FLEXCOMM_USART_FIFOINTENCLR_RXLVL_Enum ; + +typedef enum { +/* Not pending */ +FLEXCOMM_USART_FIFOINTSTAT_TXERR_TXERR_ISNOTPENDING =0 , +/* Pending */ +FLEXCOMM_USART_FIFOINTSTAT_TXERR_TXERR_ISPENDING =1 , +}FLEXCOMM_USART_FIFOINTSTAT_TXERR_Enum ; + +typedef enum { +/* Not pending */ +FLEXCOMM_USART_FIFOINTSTAT_RXERR_RXERR_ISNOTPENDING =0 , +/* Pending */ +FLEXCOMM_USART_FIFOINTSTAT_RXERR_RXERR_ISPENDING =1 , +}FLEXCOMM_USART_FIFOINTSTAT_RXERR_Enum ; + +typedef enum { +/* Not pending */ +FLEXCOMM_USART_FIFOINTSTAT_TXLVL_TXLVL_ISNOTPENDING =0 , +/* Pending */ +FLEXCOMM_USART_FIFOINTSTAT_TXLVL_TXLVL_ISPENDING =1 , +}FLEXCOMM_USART_FIFOINTSTAT_TXLVL_Enum ; + +typedef enum { +/* Not pending */ +FLEXCOMM_USART_FIFOINTSTAT_RXLVL_RXLVL_ISNOTPENDING =0 , +/* Pending */ +FLEXCOMM_USART_FIFOINTSTAT_RXLVL_RXLVL_ISPENDING =1 , +}FLEXCOMM_USART_FIFOINTSTAT_RXLVL_Enum ; + +typedef enum { +/* Not pending */ +FLEXCOMM_USART_FIFOINTSTAT_PERINT_PERINT_ISNOTPENDING =0 , +/* Pending */ +FLEXCOMM_USART_FIFOINTSTAT_PERINT_PERINT_ISPENDING =1 , +}FLEXCOMM_USART_FIFOINTSTAT_PERINT_Enum ; + + +#define FLEXCOMM_USART_REGISTER_ACCESS_INFO_ARRAY (_name) \ + struct RegisterAccessInfo _name[FLEXCOMM_USART_REGS_NO] = { \ + [0 ... FLEXCOMM_USART_REGS_NO - 1] = { \ + .name = "", \ + .addr = -1, \ + }, \ + [R_FLEXCOMM_USART_CFG] = { \ + .name = "CFG", \ + .addr = 0x0, \ + .ro = 0xFF032402, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_USART_CTL] = { \ + .name = "CTL", \ + .addr = 0x4, \ + .ro = 0xFFFEFCB9, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_USART_STAT] = { \ + .name = "STAT", \ + .addr = 0x8, \ + .ro = 0xFFFE07DF, \ + .reset = 0xA, \ + }, \ + [R_FLEXCOMM_USART_INTENSET] = { \ + .name = "INTENSET", \ + .addr = 0xC, \ + .ro = 0xFFFE0797, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_USART_INTENCLR] = { \ + .name = "INTENCLR", \ + .addr = 0x10, \ + .ro = 0xFFFE0797, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_USART_BRG] = { \ + .name = "BRG", \ + .addr = 0x20, \ + .ro = 0xFFFF0000, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_USART_INTSTAT] = { \ + .name = "INTSTAT", \ + .addr = 0x24, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_USART_OSR] = { \ + .name = "OSR", \ + .addr = 0x28, \ + .ro = 0xFFFFFFF0, \ + .reset = 0xF, \ + }, \ + [R_FLEXCOMM_USART_ADDR] = { \ + .name = "ADDR", \ + .addr = 0x2C, \ + .ro = 0xFFFFFF00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFOCFG] = { \ + .name = "FIFOCFG", \ + .addr = 0xE00, \ + .ro = 0xFFF80FFC, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFOSTAT] = { \ + .name = "FIFOSTAT", \ + .addr = 0xE04, \ + .ro = 0xFFFFFFFC, \ + .reset = 0x30, \ + }, \ + [R_FLEXCOMM_USART_FIFOTRIG] = { \ + .name = "FIFOTRIG", \ + .addr = 0xE08, \ + .ro = 0xFFF0F0FC, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFOINTENSET] = { \ + .name = "FIFOINTENSET", \ + .addr = 0xE10, \ + .ro = 0xFFFFFFF0, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFOINTENCLR] = { \ + .name = "FIFOINTENCLR", \ + .addr = 0xE14, \ + .ro = 0xFFFFFFF0, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFOINTSTAT] = { \ + .name = "FIFOINTSTAT", \ + .addr = 0xE18, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFOWR] = { \ + .name = "FIFOWR", \ + .addr = 0xE20, \ + .ro = 0xFFFFFE00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFORD] = { \ + .name = "FIFORD", \ + .addr = 0xE30, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFORDNOPOP] = { \ + .name = "FIFORDNOPOP", \ + .addr = 0xE40, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_USART_FIFOSIZE] = { \ + .name = "FIFOSIZE", \ + .addr = 0xE48, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x10, \ + }, \ + [R_FLEXCOMM_USART_ID] = { \ + .name = "ID", \ + .addr = 0xFFC, \ + .ro = 0xFFFFFFFF, \ + .reset = 0xE0102100, \ + }, \ + }
include/hw/char/flexcomm_usart.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* QEMU model for NXP's FLEXCOMM USART +* +* Copyright (c) 2024 Google LLC +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef HW_FLEXCOMM_USART_H +#define HW_FLEXCOMM_USART_H + +#include "hw/misc/flexcomm_function.h" +#include "chardev/char-fe.h" + +#define TYPE_FLEXCOMM_USART "flexcomm-usart" +OBJECT_DECLARE_TYPE (FlexcommUsartState, FlexcommUsartClass,FLEXCOMM_USART ); + +struct FlexcommUsartState { +FlexcommFunction parent_obj; + +CharBackend chr; +}; + +struct FlexcommUsartClass { +FlexcommFunctionClass parent_obj; + +FlexcommFunctionSelect select; +}; + +#endif /* HW_FLEXCOMM_USART_H */
include/hw/misc/flexcomm.h +2 -0
@@ -15,6 +15,7 @@#include "hw/sysbus.h" #include "hw/arm/svd/flexcomm.h" #include "qemu/fifo32.h" +#include "hw/char/flexcomm_usart.h" #define FLEXCOMM_FUNC_USART 0#define FLEXCOMM_FUNC_SPI 1
@@ -46,6 +47,7 @@ struct FlexcommState {bool irq_state;Fifo32 rx_fifo;Fifo32 tx_fifo; + FlexcommUsartState usart; };#endif /* HW_FLEXCOMM_H */
hw/char/flexcomm_usart.c new file +288 -0
288 lines not on this page · raw message
hw/misc/flexcomm.c +3 -0
@@ -23,6 +23,7 @@#include "migration/vmstate.h" #include "hw/misc/flexcomm.h" #include "hw/arm/svd/flexcomm_usart.h" +#include "hw/char/flexcomm_usart.h" #define REG (s, reg) (s->regs[R_FLEXCOMM_##reg])#define RF_WR (s, reg, field, val) \
@@ -218,6 +219,7 @@ static void flexcomm_init(Object *obj) TYPE_FLEXCOMM, sizeof(s->regs));sysbus_init_mmio (SYS_BUS_DEVICE (obj), &s->container);sysbus_init_irq (sbd, &s->irq); +object_initialize_child (obj,"usart" , &s->usart,TYPE_FLEXCOMM_USART ); }static void flexcomm_finalize (Object *obj)
@@ -247,6 +249,7 @@ static void flexcomm_realize(DeviceState *dev, Error **errp)FlexcommState *s =FLEXCOMM (dev);memory_region_add_subregion_overlap (&s->container,0 , &s->mmio,-1 ); +flexcomm_func_realize_and_unref (FLEXCOMM_FUNCTION (&s->usart), errp); }static const VMStateDescription vmstate_flexcomm = {
hw/arm/svd/meson.build +3 -0
@@ -4,4 +4,7 @@ if get_option('mcux-soc-svd') run_target('svd-flexcomm', command: svd_gen_header + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm.h', '-p', 'FLEXCOMM0', '-t', 'FLEXCOMM']) + run_target('svd-flexcomm-usart', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_usart.h', + '-p', 'USART0', '-t', 'FLEXCOMM_USART']) endif
hw/char/meson.build +1 -0
@@ -38,3 +38,4 @@ system_ss.add(when: 'CONFIG_GOLDFISH_TTY', if_true: files('goldfish_tty.c')) specific_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('terminal3270.c')) specific_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-serial-bus.c')) specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr_vty.c')) +system_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm_usart.c'))
hw/char/trace-events +8 -0
@@ -125,3 +125,11 @@ xen_console_unrealize(unsigned int idx) "idx %u" xen_console_realize(unsigned int idx, const char *chrdev) "idx %u chrdev %s" xen_console_device_create(unsigned int idx) "idx %u" xen_console_device_destroy(unsigned int idx) "idx %u" + +# flexcomm_usart.c +flexcomm_usart_reg_read(const char *id, const char *reg_name, uint32_t addr, uint32_t val) " %s: %s[0x%04x] -> 0x%08x" +flexcomm_usart_reg_write(const char *id, const char *reg_name, uint32_t addr, uint32_t val) "%s: %s[0x%04x] <- 0x%08x" +flexcomm_usart_rx_space(const char *id, uint32_t rx) "%s: %d" +flexcomm_usart_rx(const char *id) "%s" +flexcomm_usart_tx(const char *id) "%s" +flexcomm_usart_irq(const char *id, bool irq, bool fifoirqs, bool perirqs, bool enabled) "%s: %d %d %d %d"
Signature · 1 line
2.46.0.662.g92d0881bb0-goog
PATCH 8/25 hw/i2c: add support for flexcomm i2c
In reply to Octavian PurdilaAdd support for NXP's flexcomm i2c. It does not support slave mode or DMA.
The patch includes an automatically generated header which contains the register layout and helpers.
The header can be regenerated with the svd-flexcomm-i2c target when the build is configured with --enable-mcux-soc-svd.
--- include/hw/arm/svd/flexcomm_i2c.h | 1190 +++++++++++++++++++++++++++++ include/hw/i2c/flexcomm_i2c.h | 40 + include/hw/misc/flexcomm.h | 2 + hw/i2c/flexcomm_i2c.c | 250 ++++++ hw/misc/flexcomm.c | 3 + hw/arm/svd/meson.build | 3 + hw/i2c/meson.build | 1 + hw/i2c/trace-events | 10 + hw/misc/Kconfig | 1 + 9 files changed, 1500 insertions(+) create mode 100644 include/hw/arm/svd/flexcomm_i2c.h create mode 100644 include/hw/i2c/flexcomm_i2c.h create mode 100644 hw/i2c/flexcomm_i2c.c
include/hw/arm/svd/flexcomm_i2c.h new file +1190 -0
@@ -0,0 +1,1190 @@ +/* +* Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause +* +* Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml +*/ +#pragma once + +#include "hw/register.h" + +/* I2C Bus Interface */ +#define FLEXCOMM_I2C_REGS_NO (1024) + +/* Configuration Register */ +REG32 (FLEXCOMM_I2C_CFG ,2048 ); +/* Master Enable */ +FIELD (FLEXCOMM_I2C_CFG ,MSTEN ,0 ,1 ); +/* Slave Enable */ +FIELD (FLEXCOMM_I2C_CFG ,SLVEN ,1 ,1 ); +/* Monitor Enable */ +FIELD (FLEXCOMM_I2C_CFG ,MONEN ,2 ,1 ); +/* I2C bus Time-out Enable */ +FIELD (FLEXCOMM_I2C_CFG ,TIMEOUTEN ,3 ,1 ); +/* Monitor function Clock Stretching */ +FIELD (FLEXCOMM_I2C_CFG ,MONCLKSTR ,4 ,1 ); +/* High Speed mode Capable enable */ +FIELD (FLEXCOMM_I2C_CFG ,HSCAPABLE ,5 ,1 ); + +/* Status Register */ +REG32 (FLEXCOMM_I2C_STAT ,2052 ); +/* Master Pending */ +FIELD (FLEXCOMM_I2C_STAT ,MSTPENDING ,0 ,1 ); +/* Master State code */ +FIELD (FLEXCOMM_I2C_STAT ,MSTSTATE ,1 ,3 ); +/* Master Arbitration Loss flag */ +FIELD (FLEXCOMM_I2C_STAT ,MSTARBLOSS ,4 ,1 ); +/* Master Start/Stop Error flag */ +FIELD (FLEXCOMM_I2C_STAT ,MSTSTSTPERR ,6 ,1 ); +/* Slave Pending */ +FIELD (FLEXCOMM_I2C_STAT ,SLVPENDING ,8 ,1 ); +/* Slave State */ +FIELD (FLEXCOMM_I2C_STAT ,SLVSTATE ,9 ,2 ); +/* Slave Not Stretching */ +FIELD (FLEXCOMM_I2C_STAT ,SLVNOTSTR ,11 ,1 ); +/* Slave address match Index T */ +FIELD (FLEXCOMM_I2C_STAT ,SLVIDX ,12 ,2 ); +/* Slave selected flag */ +FIELD (FLEXCOMM_I2C_STAT ,SLVSEL ,14 ,1 ); +/* Slave Deselected flag */ +FIELD (FLEXCOMM_I2C_STAT ,SLVDESEL ,15 ,1 ); +/* Monitor Ready */ +FIELD (FLEXCOMM_I2C_STAT ,MONRDY ,16 ,1 ); +/* Monitor Overflow flag */ +FIELD (FLEXCOMM_I2C_STAT ,MONOV ,17 ,1 ); +/* Monitor Active flag */ +FIELD (FLEXCOMM_I2C_STAT ,MONACTIVE ,18 ,1 ); +/* Monitor Idle flag */ +FIELD (FLEXCOMM_I2C_STAT ,MONIDLE ,19 ,1 ); +/* Event Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_STAT ,EVENTTIMEOUT ,24 ,1 ); +/* SCL Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_STAT ,SCLTIMEOUT ,25 ,1 ); + +/* Interrupt Enable Set Register */ +REG32 (FLEXCOMM_I2C_INTENSET ,2056 ); +/* Master Pending interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MSTPENDINGEN ,0 ,1 ); +/* Master Arbitration Loss interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MSTARBLOSSEN ,4 ,1 ); +/* Master Start/Stop Error interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MSTSTSTPERREN ,6 ,1 ); +/* Slave Pending interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SLVPENDINGEN ,8 ,1 ); +/* Slave Not Stretching interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SLVNOTSTREN ,11 ,1 ); +/* Slave Deselect interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SLVDESELEN ,15 ,1 ); +/* Monitor data Ready interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MONRDYEN ,16 ,1 ); +/* Monitor Overrun interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MONOVEN ,17 ,1 ); +/* Monitor Idle interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MONIDLEEN ,19 ,1 ); +/* Event Time-out interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,EVENTTIMEOUTEN ,24 ,1 ); +/* SCL Time-out interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SCLTIMEOUTEN ,25 ,1 ); + +/* Interrupt Enable Clear Register */ +REG32 (FLEXCOMM_I2C_INTENCLR ,2060 ); +/* Master Pending interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MSTPENDINGCLR ,0 ,1 ); +/* Master Arbitration Loss interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MSTARBLOSSCLR ,4 ,1 ); +/* Master Start/Stop Error interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MSTSTSTPERRCLR ,6 ,1 ); +/* Slave Pending interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SLVPENDINGCLR ,8 ,1 ); +/* Slave Not Stretching interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SLVNOTSTRCLR ,11 ,1 ); +/* Slave Deselect interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SLVDESELCLR ,15 ,1 ); +/* Monitor data Ready interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MONRDYCLR ,16 ,1 ); +/* Monitor Overrun interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MONOVCLR ,17 ,1 ); +/* Monitor Idle interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MONIDLECLR ,19 ,1 ); +/* Event time-out interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,EVENTTIMEOUTCLR ,24 ,1 ); +/* SCL time-out interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SCLTIMEOUTCLR ,25 ,1 ); + +/* Time-out Register */ +REG32 (FLEXCOMM_I2C_TIMEOUT ,2064 ); +/* Time-out time value, the bottom 4 bits */ +FIELD (FLEXCOMM_I2C_TIMEOUT ,TOMIN ,0 ,4 ); +/* Time-out time value */ +FIELD (FLEXCOMM_I2C_TIMEOUT ,TO ,4 ,12 ); + +/* Clock Divider Register */ +REG32 (FLEXCOMM_I2C_CLKDIV ,2068 ); +/* Divider Value */ +FIELD (FLEXCOMM_I2C_CLKDIV ,DIVVAL ,0 ,16 ); + +/* Interrupt Status Register */ +REG32 (FLEXCOMM_I2C_INTSTAT ,2072 ); +/* Master Pending */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MSTPENDING ,0 ,1 ); +/* Master Arbitration Loss flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MSTARBLOSS ,4 ,1 ); +/* Master Start/Stop Error flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MSTSTSTPERR ,6 ,1 ); +/* Slave Pending */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SLVPENDING ,8 ,1 ); +/* Slave Not Stretching status */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SLVNOTSTR ,11 ,1 ); +/* Slave Deselected flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SLVDESEL ,15 ,1 ); +/* Monitor Ready */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MONRDY ,16 ,1 ); +/* Monitor Overflow flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MONOV ,17 ,1 ); +/* Monitor Idle flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MONIDLE ,19 ,1 ); +/* Event Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,EVENTTIMEOUT ,24 ,1 ); +/* SCL Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SCLTIMEOUT ,25 ,1 ); + +/* Master Control Register */ +REG32 (FLEXCOMM_I2C_MSTCTL ,2080 ); +/* Master Continue(write-only) */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTCONTINUE ,0 ,1 ); +/* Master Start control(write-only) */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTSTART ,1 ,1 ); +/* Master Stop control(write-only) */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTSTOP ,2 ,1 ); +/* Master DMA enable */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTDMA ,3 ,1 ); + +/* Master Timing Register */ +REG32 (FLEXCOMM_I2C_MSTTIME ,2084 ); +/* Master SCL Low time */ +FIELD (FLEXCOMM_I2C_MSTTIME ,MSTSCLLOW ,0 ,3 ); +/* Master SCL High time */ +FIELD (FLEXCOMM_I2C_MSTTIME ,MSTSCLHIGH ,4 ,3 ); + +/* Master Data Register */ +REG32 (FLEXCOMM_I2C_MSTDAT ,2088 ); +/* Master function data register */ +FIELD (FLEXCOMM_I2C_MSTDAT ,DATA ,0 ,8 ); + +/* Slave Control Register */ +REG32 (FLEXCOMM_I2C_SLVCTL ,2112 ); +/* Slave Continue */ +FIELD (FLEXCOMM_I2C_SLVCTL ,SLVCONTINUE ,0 ,1 ); +/* Slave NACK */ +FIELD (FLEXCOMM_I2C_SLVCTL ,SLVNACK ,1 ,1 ); +/* Slave DMA enable */ +FIELD (FLEXCOMM_I2C_SLVCTL ,SLVDMA ,3 ,1 ); +/* Automatic Acknowledge */ +FIELD (FLEXCOMM_I2C_SLVCTL ,AUTOACK ,8 ,1 ); +/* Automatic Match Read */ +FIELD (FLEXCOMM_I2C_SLVCTL ,AUTOMATCHREAD ,9 ,1 ); + +/* Slave Data Register */ +REG32 (FLEXCOMM_I2C_SLVDAT ,2116 ); +/* Slave function data register */ +FIELD (FLEXCOMM_I2C_SLVDAT ,DATA ,0 ,8 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR0 ,2120 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR0 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR0 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR0 ,AUTONACK ,15 ,1 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR1 ,2124 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR1 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR1 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR1 ,AUTONACK ,15 ,1 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR2 ,2128 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR2 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR2 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR2 ,AUTONACK ,15 ,1 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR3 ,2132 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR3 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR3 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR3 ,AUTONACK ,15 ,1 ); + +/* Slave Qualification for Address 0 Register */ +REG32 (FLEXCOMM_I2C_SLVQUAL0 ,2136 ); +/* Qualify mode for slave address 0 */ +FIELD (FLEXCOMM_I2C_SLVQUAL0 ,QUALMODE0 ,0 ,1 ); +/* Slave address Qualifier for address 0 */ +FIELD (FLEXCOMM_I2C_SLVQUAL0 ,SLVQUAL0 ,1 ,7 ); + +/* Monitor Receiver Data Register */ +REG32 (FLEXCOMM_I2C_MONRXDAT ,2176 ); +/* Monitor function Receiver Data */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONRXDAT ,0 ,8 ); +/* Monitor Received Start */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONSTART ,8 ,1 ); +/* Monitor Received Repeated Start */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONRESTART ,9 ,1 ); +/* Monitor Received NACK */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONNACK ,10 ,1 ); + +/* Peripheral Identification Register */ +REG32 (FLEXCOMM_I2C_ID ,4092 ); +/* Aperture */ +FIELD (FLEXCOMM_I2C_ID ,APERTURE ,0 ,8 ); +/* Minor revision of module implementation */ +FIELD (FLEXCOMM_I2C_ID ,MINOR_REV ,8 ,4 ); +/* Major revision of module implementation */ +FIELD (FLEXCOMM_I2C_ID ,MAJOR_REV ,12 ,4 ); +/* Module identifier for the selected function */ +FIELD (FLEXCOMM_I2C_ID ,ID ,16 ,16 ); + + +typedef enum { +/* +* Disabled. The I2C Master function is disabled. When disabled, the Master +* configuration settings are not changed, but the Master function is +* internally reset. +*/ +FLEXCOMM_I2C_CFG_MSTEN_DISABLED =0 , +/* Enabled. The I2C Master function is enabled. */ +FLEXCOMM_I2C_CFG_MSTEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_MSTEN_Enum ; + +typedef enum { +/* +* Disabled. The I2C slave function is disabled. When disabled, the Slave +* configuration settings are not changed, but the Slave function is +* internally reset. +*/ +FLEXCOMM_I2C_CFG_SLVEN_DISABLED =0 , +/* Enabled. The I2C slave function is enabled. */ +FLEXCOMM_I2C_CFG_SLVEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_SLVEN_Enum ; + +typedef enum { +/* +* Disabled. The I2C Monitor function is disabled. When disabled, the +* Monitor function configuration settings are not changed, but the Monitor +* function is internally reset. +*/ +FLEXCOMM_I2C_CFG_MONEN_DISABLED =0 , +/* Enabled. The I2C Monitor function is enabled. */ +FLEXCOMM_I2C_CFG_MONEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_MONEN_Enum ; + +typedef enum { +/* +* Disabled. The time-out function is disabled. When disabled, the time-out +* function is internally reset. +*/ +FLEXCOMM_I2C_CFG_TIMEOUTEN_DISABLED =0 , +/* +* Enabled. The time-out function is enabled. Both types of time-out flags +* will be generated and will cause interrupts if those flags are enabled. +* Typically, only one time-out flag will be used in a system. +*/ +FLEXCOMM_I2C_CFG_TIMEOUTEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_TIMEOUTEN_Enum ; + +typedef enum { +/* +* Disabled. The Monitor function will not perform clock stretching. +* Software or DMA may not always be able to read data provided by the +* Monitor function before it (the data) is overwritten. This mode can be +* used when non-invasive monitoring is critical. +*/ +FLEXCOMM_I2C_CFG_MONCLKSTR_DISABLED =0 , +/* +* Enabled. The Monitor function will perform clock stretching, to ensure +* that the software or DMA can read all incoming data supplied by the +* Monitor function. +*/ +FLEXCOMM_I2C_CFG_MONCLKSTR_ENABLED =1 , +}FLEXCOMM_I2C_CFG_MONCLKSTR_Enum ; + +typedef enum { +/* Fast mode Plus enable */ +FLEXCOMM_I2C_CFG_HSCAPABLE_FAST_MODE_PLUS =0 , +/* High Speed mode enable */ +FLEXCOMM_I2C_CFG_HSCAPABLE_HIGH_SPEED =1 , +}FLEXCOMM_I2C_CFG_HSCAPABLE_Enum ; + +typedef enum { +/* +* In progress. Communication is in progress and the Master function is +* busy and cannot currently accept a command. +*/ +FLEXCOMM_I2C_STAT_MSTPENDING_IN_PROGRESS =0 , +/* +* Pending. The Master function needs software service or is in the idle +* state. If the master is not in the idle state, then the master is +* waiting to receive or transmit data, or is waiting for the NACK bit. +*/ +FLEXCOMM_I2C_STAT_MSTPENDING_PENDING =1 , +}FLEXCOMM_I2C_STAT_MSTPENDING_Enum ; + +typedef enum { +/* +* Idle. The Master function is available to be used for a new transaction. +*/ +FLEXCOMM_I2C_STAT_MSTSTATE_IDLE =0 , +/* +* Receive ready. Received data is available (in Master Receiver mode). +* Address plus Read was previously sent and Acknowledged by a slave. +*/ +FLEXCOMM_I2C_STAT_MSTSTATE_RECEIVE_READY =1 , +/* +* Transmit ready. Data can be transmitted (in Master Transmitter mode). +* Address plus Write was previously sent and Acknowledged by a slave. +*/ +FLEXCOMM_I2C_STAT_MSTSTATE_TRANSMIT_READY =2 , +/* NACK Address. Slave NACKed address. */ +FLEXCOMM_I2C_STAT_MSTSTATE_NACK_ADDRESS =3 , +/* NACK Data. Slave NACKed transmitted data. */ +FLEXCOMM_I2C_STAT_MSTSTATE_NACK_DATA =4 , +}FLEXCOMM_I2C_STAT_MSTSTATE_Enum ; + +typedef enum { +/* No Arbitration Loss has occurred */ +FLEXCOMM_I2C_STAT_MSTARBLOSS_NO_LOSS =0 , +/* +* Arbitration loss. The Master function has experienced an Arbitration +* Loss. At this point, the Master function has already stopped driving the +* bus and has gone into an idle state. Software can respond by doing +* nothing, or by sending a Start (to attempt to gain control of the bus +* when the bus next becomes idle). +*/ +FLEXCOMM_I2C_STAT_MSTARBLOSS_ARBITRATION_LOSS =1 , +}FLEXCOMM_I2C_STAT_MSTARBLOSS_Enum ; + +typedef enum { +/* No Start/Stop Error has occurred. */ +FLEXCOMM_I2C_STAT_MSTSTSTPERR_NO_ERROR =0 , +/* +* The Master function has experienced a Start/Stop Error. A Start or Stop +* was detected at a time when Start or Stop is not allowed by the I2C +* specification. The Master interface has stopped driving the bus and gone +* into an idle state; no action is required. A request for a Start could +* be made, or software could attempt to make sure that the bus has not +* stalled. +*/ +FLEXCOMM_I2C_STAT_MSTSTSTPERR_ERROR =1 , +}FLEXCOMM_I2C_STAT_MSTSTSTPERR_Enum ; + +typedef enum { +/* +* In progress. The Slave function does not currently need software +* service. +*/ +FLEXCOMM_I2C_STAT_SLVPENDING_IN_PROGRESS =0 , +/* +* Pending. The Slave function needs software service. Information about +* what is needed is in the Slave state field (SLVSTATE). +*/ +FLEXCOMM_I2C_STAT_SLVPENDING_PENDING =1 , +}FLEXCOMM_I2C_STAT_SLVPENDING_Enum ; + +typedef enum { +/* +* Slave address. Address plus R/W received. At least one of the 4 slave +* addresses has been matched by hardware. +*/ +FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_ADDRESS =0 , +/* Slave receive. Received data is available (in Slave Receiver mode). */ +FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_RECEIVE =1 , +/* Slave transmit. Data can be transmitted (in Slave Transmitter mode). */ +FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_TRANSMIT =2 , +}FLEXCOMM_I2C_STAT_SLVSTATE_Enum ; + +typedef enum { +/* +* Stretching. The slave function is currently stretching the I2C bus +* clock. Deep-Sleepmode cannot be entered at this time. +*/ +FLEXCOMM_I2C_STAT_SLVNOTSTR_STRETCHING =0 , +/* +* Not stretching. The slave function is not currently stretching the I2C +* bus clock. Deep-sleep mode can be entered at this time. +*/ +FLEXCOMM_I2C_STAT_SLVNOTSTR_NOT_STRETCHING =1 , +}FLEXCOMM_I2C_STAT_SLVNOTSTR_Enum ; + +typedef enum { +/* Address 0. Slave address 0 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS0 =0 , +/* Address 1. Slave address 1 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS1 =1 , +/* Address 2. Slave address 2 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS2 =2 , +/* Address 3. Slave address 3 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS3 =3 , +}FLEXCOMM_I2C_STAT_SLVIDX_Enum ; + +typedef enum { +/* Not selected. The Slave function is not currently selected. */ +FLEXCOMM_I2C_STAT_SLVSEL_NOT_SELECTED =0 , +/* Selected. The Slave function is currently selected. */ +FLEXCOMM_I2C_STAT_SLVSEL_SELECTED =1 , +}FLEXCOMM_I2C_STAT_SLVSEL_Enum ; + +typedef enum { +/* +* Not deselected. The Slave function has not become deselected. This does +* not mean that the Slave is currently selected. That information is in +* the SLVSEL flag. +*/ +FLEXCOMM_I2C_STAT_SLVDESEL_NOT_DESELECTED =0 , +/* +* Deselected. The Slave function has become deselected. This is +* specifically caused by the SLVSEL flag changing from 1 to 0. See SLVSEL +* for details about when that event occurs. +*/ +FLEXCOMM_I2C_STAT_SLVDESEL_DESELECTED =1 , +}FLEXCOMM_I2C_STAT_SLVDESEL_Enum ; + +typedef enum { +/* No data. The Monitor function does not currently have data available. */ +FLEXCOMM_I2C_STAT_MONRDY_NO_DATA =0 , +/* Data waiting. The Monitor function has data waiting to be read. */ +FLEXCOMM_I2C_STAT_MONRDY_DATA_WAITING =1 , +}FLEXCOMM_I2C_STAT_MONRDY_Enum ; + +typedef enum { +/* No overrun. Monitor data has not overrun. */ +FLEXCOMM_I2C_STAT_MONOV_NO_OVERRUN =0 , +/* +* Overrun. A Monitor data overrun has occurred. An overrun can only happen +* when Monitor clock stretching not enabled via the CFG[MONCLKSTR] bit. +* Writing 1 to MONOV bit clears the MONOV flag. +*/ +FLEXCOMM_I2C_STAT_MONOV_OVERRUN =1 , +}FLEXCOMM_I2C_STAT_MONOV_Enum ; + +typedef enum { +/* Inactive. The Monitor function considers the I2C bus to be inactive. */ +FLEXCOMM_I2C_STAT_MONACTIVE_INACTIVE =0 , +/* Active. The Monitor function considers the I2C bus to be active. */ +FLEXCOMM_I2C_STAT_MONACTIVE_ACTIVE =1 , +}FLEXCOMM_I2C_STAT_MONACTIVE_Enum ; + +typedef enum { +/* +* Not idle. The I2C bus is not idle, or MONIDLE flag has been cleared by +* software. +*/ +FLEXCOMM_I2C_STAT_MONIDLE_NOT_IDLE =0 , +/* +* Idle. The I2C bus has gone idle at least once, since the last time +* MONIDLE flag was cleared by software. +*/ +FLEXCOMM_I2C_STAT_MONIDLE_IDLE =1 , +}FLEXCOMM_I2C_STAT_MONIDLE_Enum ; + +typedef enum { +/* No time-out. I2C bus events have not caused a time-out. */ +FLEXCOMM_I2C_STAT_EVENTTIMEOUT_NO_TIMEOUT =0 , +/* +* Event time-out. The time between I2C bus events has been longer than the +* time specified by the TIMEOUT register. +*/ +FLEXCOMM_I2C_STAT_EVENTTIMEOUT_EVEN_TIMEOUT =1 , +}FLEXCOMM_I2C_STAT_EVENTTIMEOUT_Enum ; + +typedef enum { +/* No time-out. SCL low time has not caused a time-out. */ +FLEXCOMM_I2C_STAT_SCLTIMEOUT_NO_TIMEOUT =0 , +/* Time-out. SCL low time has caused a time-out. */ +FLEXCOMM_I2C_STAT_SCLTIMEOUT_TIMEOUT =1 , +}FLEXCOMM_I2C_STAT_SCLTIMEOUT_Enum ; + +typedef enum { +/* Disabled. The MstPending interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_DISABLED =0 , +/* Enabled. The MstPending interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_Enum ; + +typedef enum { +/* Disabled. The MstArbLoss interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_DISABLED =0 , +/* Enabled. The MstArbLoss interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_Enum ; + +typedef enum { +/* Disabled. The MstStStpErr interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_DISABLED =0 , +/* Enabled. The MstStStpErr interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_Enum ; + +typedef enum { +/* Disabled. The SlvPending interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_DISABLED =0 , +/* Enabled. The SlvPending interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_Enum ; + +typedef enum { +/* Disabled. The SlvNotStr interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_DISABLED =0 , +/* Enabled. The SlvNotStr interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_Enum ; + +typedef enum { +/* Disabled. The SlvDeSel interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SLVDESELEN_DISABLED =0 , +/* Enabled. The SlvDeSel interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SLVDESELEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SLVDESELEN_Enum ; + +typedef enum { +/* Disabled. The MonRdy interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MONRDYEN_DISABLED =0 , +/* Enabled. The MonRdy interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MONRDYEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MONRDYEN_Enum ; + +typedef enum { +/* Disabled. The MonOv interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MONOVEN_DISABLED =0 , +/* Enabled. The MonOv interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MONOVEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MONOVEN_Enum ; + +typedef enum { +/* Disabled. The MonIdle interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MONIDLEEN_DISABLED =0 , +/* Enabled. The MonIdle interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MONIDLEEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MONIDLEEN_Enum ; + +typedef enum { +/* Disabled. The Event time-out interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_DISABLED =0 , +/* Enabled. The Event time-out interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_Enum ; + +typedef enum { +/* Disabled. The SCL time-out interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_DISABLED =0 , +/* Enabled. The SCL time-out interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_CLEAR_MSTPENDING =1 , +}FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_CLEAR_MSTARBLOSS =1 , +}FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_CLEAR_MSTSTSTPERR =1 , +}FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_CLEAR_SLVPENDING =1 , +}FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_CLEAR_SLVNOTSTR =1 , +}FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_CLEAR_SLVDESEL =1 , +}FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MONRDYCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MONRDYCLR_CLEAR_MONRDY =1 , +}FLEXCOMM_I2C_INTENCLR_MONRDYCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MONOVCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MONOVCLR_CLEAR_MONOV =1 , +}FLEXCOMM_I2C_INTENCLR_MONOVCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MONIDLECLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MONIDLECLR_CLEAR_MONIDLE =1 , +}FLEXCOMM_I2C_INTENCLR_MONIDLECLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_CLEAR_EVENTTIMEOUT =1 , +}FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_CLEAR_SCLTIMEOUT =1 , +}FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_Enum ; + +typedef enum { +/* A time-out will occur after 16 counts of the I2C function clock. */ +FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT16 =0 , +/* A time-out will occur after 32 counts of the I2C function clock. */ +FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT32 =1 , +/* A time-out will occur after 65,536 counts of the I2C function clock. */ +FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT65K =4095 , +}FLEXCOMM_I2C_TIMEOUT_TO_Enum ; + +typedef enum { +/* FCLK is used directly by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKUNDIVIDED =0 , +/* FCLK is divided by 2 before being used by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV2 =1 , +/* FCLK is divided by 3 before being used by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV3 =2 , +/* FCLK is divided by 65,536 before being used by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV65K =65535 , +}FLEXCOMM_I2C_CLKDIV_DIVVAL_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MSTPENDING_MSTPENDING_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MSTPENDING_MSTPENDING_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MSTPENDING_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_MSTARBLOSS_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_MSTARBLOSS_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_MSTSTSTPERR_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_MSTSTSTPERR_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SLVPENDING_SLVPENDING_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SLVPENDING_SLVPENDING_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SLVPENDING_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_SLVNOTSTR_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_SLVNOTSTR_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SLVDESEL_SLVDESEL_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SLVDESEL_SLVDESEL_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SLVDESEL_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MONRDY_MONRDY_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MONRDY_MONRDY_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MONRDY_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MONOV_MONOV_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MONOV_MONOV_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MONOV_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MONIDLE_MONIDLE_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MONIDLE_MONIDLE_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MONIDLE_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_EVENTTIMEOUT_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_EVENTTIMEOUT_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_SCLTIMEOUT_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_SCLTIMEOUT_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_NO_EFFECT =0 , +/* +* Continue. Informs the Master function to continue to the next operation. +* This action must done after writing transmit data, reading received +* data, or any other housekeeping related to the next bus operation. +*/ +FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_CONTINUE =1 , +}FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_MSTCTL_MSTSTART_NO_EFFECT =0 , +/* +* Start. A Start will be generated on the I2C bus at the next allowed +* time. +*/ +FLEXCOMM_I2C_MSTCTL_MSTSTART_START =1 , +}FLEXCOMM_I2C_MSTCTL_MSTSTART_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_MSTCTL_MSTSTOP_NO_EFFECT =0 , +/* +* Stop. A Stop will be generated on the I2C bus at the next allowed time, +* preceded by a NACK to the slave if the master is receiving data from the +* slave (in Master Receiver mode). +*/ +FLEXCOMM_I2C_MSTCTL_MSTSTOP_STOP =1 , +}FLEXCOMM_I2C_MSTCTL_MSTSTOP_Enum ; + +typedef enum { +/* Disable. No DMA requests are generated for master operation. */ +FLEXCOMM_I2C_MSTCTL_MSTDMA_DISABLED =0 , +/* +* Enable. A DMA request is generated for I2C master data operations. When +* this I2C master is generating Acknowledge bits in Master Receiver mode, +* the acknowledge is generated automatically. +*/ +FLEXCOMM_I2C_MSTCTL_MSTDMA_ENABLED =1 , +}FLEXCOMM_I2C_MSTCTL_MSTDMA_Enum ; + +typedef enum { +/* +* 2 clocks. Minimum SCL low time is 2 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_2CLOCKS =0 , +/* +* 3 clocks. Minimum SCL low time is 3 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_3CLOCKS =1 , +/* +* 4 clocks. Minimum SCL low time is 4 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_4CLOCKS =2 , +/* +* 5 clocks. Minimum SCL low time is 5 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_5CLOCKS =3 , +/* +* 6 clocks. Minimum SCL low time is 6 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_6CLOCKS =4 , +/* +* 7 clocks. Minimum SCL low time is 7 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_7CLOCKS =5 , +/* +* 8 clocks. Minimum SCL low time is 8 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_8CLOCKS =6 , +/* +* 9 clocks. Minimum SCL low time is 9 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_9CLOCKS =7 , +}FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_Enum ; + +typedef enum { +/* +* 2 clocks. Minimum SCL high time is 2 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_2CLOCKS =0 , +/* +* 3 clocks. Minimum SCL high time is 3 clocks of the I2C clock pre-divider +* . +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_3CLOCKS =1 , +/* +* 4 clocks. Minimum SCL high time is 4 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_4CLOCKS =2 , +/* +* 5 clocks. Minimum SCL high time is 5 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_5CLOCKS =3 , +/* +* 6 clocks. Minimum SCL high time is 6 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_6CLOCKS =4 , +/* +* 7 clocks. Minimum SCL high time is 7 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_7CLOCKS =5 , +/* +* 8 clocks. Minimum SCL high time is 8 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_8CLOCKS =6 , +/* +* 9 clocks. Minimum SCL high time is 9 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_9CLOCKS =7 , +}FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_NO_EFFECT =0 , +/* +* Continue. Informs the Slave function to continue to the next operation, +* by clearing the STAT[SLVPENDING] flag. This must be done after writing +* transmit data, reading received data, or any other housekeeping related +* to the next bus operation. Automatic Operation has different +* requirements. SLVCONTINUE should not be set unless SLVPENDING = 1. +*/ +FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_CONTINUE =1 , +}FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_SLVCTL_SLVNACK_NO_EFFECT =0 , +/* +* NACK. Causes the Slave function to NACK the master when the slave is +* receiving data from the master (in Slave Receiver mode). +*/ +FLEXCOMM_I2C_SLVCTL_SLVNACK_NACK =1 , +}FLEXCOMM_I2C_SLVCTL_SLVNACK_Enum ; + +typedef enum { +/* Disabled. No DMA requests are issued for Slave mode operation. */ +FLEXCOMM_I2C_SLVCTL_SLVDMA_DISABLED =0 , +/* +* Enabled. DMA requests are issued for I2C slave data transmission and +* reception. +*/ +FLEXCOMM_I2C_SLVCTL_SLVDMA_ENABLED =1 , +}FLEXCOMM_I2C_SLVCTL_SLVDMA_Enum ; + +typedef enum { +/* +* Normal, non-automatic operation. If AUTONACK = 0, then a SlvPending +* interrupt is generated when a matching address is received. If AUTONACK +* = 1, then received addresses are NACKed (ignored). +*/ +FLEXCOMM_I2C_SLVCTL_AUTOACK_NORMAL =0 , +/* +* A header with matching SLVADR0 and matching direction as set by +* AUTOMATCHREAD will be ACKed immediately, allowing the master to move on +* to the data bytes. If the address matches SLVADR0, but the direction +* does not match AUTOMATCHREAD, then the behavior will depend on the +* SLVADR0[AUTONACK] bit: if AUTONACK is set, then it will be Nacked; if +* AUTONACK is clear, then a SlvPending interrupt is generated. +*/ +FLEXCOMM_I2C_SLVCTL_AUTOACK_AUTOMATIC_ACK =1 , +}FLEXCOMM_I2C_SLVCTL_AUTOACK_Enum ; + +typedef enum { +/* In Automatic Mode, the expected next operation is an I2C write. */ +FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_I2C_WRITE =0 , +/* In Automatic Mode, the expected next operation is an I2C read. */ +FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_I2C_READ =1 , +}FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR0_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR0_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR0_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR0_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR0_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR0_AUTONACK_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR1_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR1_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR1_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR1_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR1_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR1_AUTONACK_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR2_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR2_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR2_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR2_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR2_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR2_AUTONACK_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR3_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR3_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR3_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR3_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR3_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR3_AUTONACK_Enum ; + +typedef enum { +/* +* Mask. The SLVQUAL0 field is used as a logical mask for matching address +* 0. +*/ +FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_MASK =0 , +/* +* Extend. The SLVQUAL0 field is used to extend address 0 matching in a +* range of addresses. +*/ +FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_EXTEND =1 , +}FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_Enum ; + +typedef enum { +/* +* No start detected. The Monitor function has not detected a Start event +* on the I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONSTART_NO_START_DETECTED =0 , +/* +* Start detected. The Monitor function has detected a Start event on the +* I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONSTART_START_DETECTED =1 , +}FLEXCOMM_I2C_MONRXDAT_MONSTART_Enum ; + +typedef enum { +/* +* No repeated start detected. The Monitor function has not detected a +* Repeated Start event on the I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONRESTART_NOT_DETECTED =0 , +/* +* Repeated start detected. The Monitor function has detected a Repeated +* Start event on the I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONRESTART_DETECTED =1 , +}FLEXCOMM_I2C_MONRXDAT_MONRESTART_Enum ; + +typedef enum { +/* +* Acknowledged. The data currently being provided by the Monitor function +* was acknowledged by at least one master or slave receiver. +*/ +FLEXCOMM_I2C_MONRXDAT_MONNACK_ACKNOWLEDGED =0 , +/* +* Not acknowledged. The data currently being provided by the Monitor +* function was not acknowledged by any receiver. +*/ +FLEXCOMM_I2C_MONRXDAT_MONNACK_NOT_ACKNOWLEDGED =1 , +}FLEXCOMM_I2C_MONRXDAT_MONNACK_Enum ; + + +#define FLEXCOMM_I2C_REGISTER_ACCESS_INFO_ARRAY (_name) \ + struct RegisterAccessInfo _name[FLEXCOMM_I2C_REGS_NO] = { \ + [0 ... FLEXCOMM_I2C_REGS_NO - 1] = { \ + .name = "", \ + .addr = -1, \ + }, \ + [R_FLEXCOMM_I2C_CFG] = { \ + .name = "CFG", \ + .addr = 0x800, \ + .ro = 0xFFFFFFC0, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_STAT] = { \ + .name = "STAT", \ + .addr = 0x804, \ + .ro = 0xFCF57FAF, \ + .reset = 0x801, \ + }, \ + [R_FLEXCOMM_I2C_INTENSET] = { \ + .name = "INTENSET", \ + .addr = 0x808, \ + .ro = 0xFCF476AE, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_INTENCLR] = { \ + .name = "INTENCLR", \ + .addr = 0x80C, \ + .ro = 0xFCF476AE, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_TIMEOUT] = { \ + .name = "TIMEOUT", \ + .addr = 0x810, \ + .ro = 0xFFFF0000, \ + .reset = 0xFFFF, \ + }, \ + [R_FLEXCOMM_I2C_CLKDIV] = { \ + .name = "CLKDIV", \ + .addr = 0x814, \ + .ro = 0xFFFF0000, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_INTSTAT] = { \ + .name = "INTSTAT", \ + .addr = 0x818, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x801, \ + }, \ + [R_FLEXCOMM_I2C_MSTCTL] = { \ + .name = "MSTCTL", \ + .addr = 0x820, \ + .ro = 0xFFFFFFF0, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_MSTTIME] = { \ + .name = "MSTTIME", \ + .addr = 0x824, \ + .ro = 0xFFFFFF88, \ + .reset = 0x77, \ + }, \ + [R_FLEXCOMM_I2C_MSTDAT] = { \ + .name = "MSTDAT", \ + .addr = 0x828, \ + .ro = 0xFFFFFF00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVCTL] = { \ + .name = "SLVCTL", \ + .addr = 0x840, \ + .ro = 0xFFFFFCF4, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVDAT] = { \ + .name = "SLVDAT", \ + .addr = 0x844, \ + .ro = 0xFFFFFF00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR0] = { \ + .name = "SLVADR0", \ + .addr = 0x848, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR1] = { \ + .name = "SLVADR1", \ + .addr = 0x84C, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR2] = { \ + .name = "SLVADR2", \ + .addr = 0x850, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR3] = { \ + .name = "SLVADR3", \ + .addr = 0x854, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVQUAL0] = { \ + .name = "SLVQUAL0", \ + .addr = 0x858, \ + .ro = 0xFFFFFF00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_MONRXDAT] = { \ + .name = "MONRXDAT", \ + .addr = 0x880, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_ID] = { \ + .name = "ID", \ + .addr = 0xFFC, \ + .ro = 0xFFFFFFFF, \ + .reset = 0xE0301300, \ + }, \ + }
include/hw/i2c/flexcomm_i2c.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* QEMU model for NXP's FLEXCOMM I2C +* +* Copyright (c) 2024 Google LLC +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef HW_FLEXCOMM_I2C_H +#define HW_FLEXCOMM_I2C_H + +#include "hw/i2c/i2c.h" +#include "hw/misc/flexcomm_function.h" + +#define TYPE_FLEXCOMM_I2C "flexcomm-i2c" +OBJECT_DECLARE_TYPE (FlexcommI2cState, FlexcommI2cClass,FLEXCOMM_I2C ); + +struct FlexcommI2cState { +FlexcommFunction parent_obj; + +I2CBus *bus; +}; + +struct FlexcommI2cClass { +FlexcommFunctionClass parent_obj; + +FlexcommFunctionSelect select; +}; + +#define MSTSTATE_IDLE 0 +#define MSTSTATE_RXRDY 1 +#define MSTSTATE_TXRDY 2 +#define MSTSTATE_NAKADR 3 +#define MSTSTATE_NAKDAT 4 + + +#endif /* HW_FLEXCOMM_I2C_H */
include/hw/misc/flexcomm.h +2 -0
@@ -16,6 +16,7 @@#include "hw/arm/svd/flexcomm.h" #include "qemu/fifo32.h" #include "hw/char/flexcomm_usart.h" +#include "hw/i2c/flexcomm_i2c.h" #define FLEXCOMM_FUNC_USART 0#define FLEXCOMM_FUNC_SPI 1
@@ -48,6 +49,7 @@ struct FlexcommState {Fifo32 rx_fifo;Fifo32 tx_fifo;FlexcommUsartState usart; + FlexcommI2cState i2c; };#endif /* HW_FLEXCOMM_H */
hw/i2c/flexcomm_i2c.c new file +250 -0
250 lines not on this page · raw message
hw/misc/flexcomm.c +3 -0
@@ -24,6 +24,7 @@#include "hw/misc/flexcomm.h" #include "hw/arm/svd/flexcomm_usart.h" #include "hw/char/flexcomm_usart.h" +#include "hw/i2c/flexcomm_i2c.h" #define REG (s, reg) (s->regs[R_FLEXCOMM_##reg])#define RF_WR (s, reg, field, val) \
@@ -220,6 +221,7 @@ static void flexcomm_init(Object *obj)sysbus_init_mmio (SYS_BUS_DEVICE (obj), &s->container);sysbus_init_irq (sbd, &s->irq);object_initialize_child (obj,"usart" , &s->usart,TYPE_FLEXCOMM_USART ); +object_initialize_child (obj,"i2c" , &s->i2c,TYPE_FLEXCOMM_I2C ); }static void flexcomm_finalize (Object *obj)
@@ -250,6 +252,7 @@ static void flexcomm_realize(DeviceState *dev, Error **errp)memory_region_add_subregion_overlap (&s->container,0 , &s->mmio,-1 );flexcomm_func_realize_and_unref (FLEXCOMM_FUNCTION (&s->usart), errp); +flexcomm_func_realize_and_unref (FLEXCOMM_FUNCTION (&s->i2c), errp); }static const VMStateDescription vmstate_flexcomm = {
hw/arm/svd/meson.build +3 -0
@@ -7,4 +7,7 @@ if get_option('mcux-soc-svd') run_target('svd-flexcomm-usart', command: svd_gen_header + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_usart.h', '-p', 'USART0', '-t', 'FLEXCOMM_USART']) + run_target('svd-flexcomm-i2c', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_i2c.h', + '-p', 'I2C0', '-t', 'FLEXCOMM_I2C']) endif
hw/i2c/meson.build +1 -0
@@ -18,4 +18,5 @@ i2c_ss.add(when: 'CONFIG_PPC4XX', if_true: files('ppc4xx_i2c.c')) i2c_ss.add(when: 'CONFIG_PCA954X', if_true: files('i2c_mux_pca954x.c')) i2c_ss.add(when: 'CONFIG_PMBUS', if_true: files('pmbus_device.c')) i2c_ss.add(when: 'CONFIG_BCM2835_I2C', if_true: files('bcm2835_i2c.c')) +i2c_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm_i2c.c')) system_ss.add_all(when: 'CONFIG_I2C', if_true: i2c_ss)
hw/i2c/trace-events +10 -0
@@ -51,3 +51,13 @@ npcm7xx_smbus_recv_fifo(const char *id, uint8_t received, uint8_t expected) "%s pca954x_write_bytes(uint8_t value) "PCA954X write data: 0x%02x" pca954x_read_data(uint8_t value) "PCA954X read data: 0x%02x" + +# flexcomm_i2c.c + +flexcomm_i2c_reg_read(const char *id, const char *reg_name, uint32_t addr, uint32_t val) " %s: %s[0x%04x] -> 0x%08x" +flexcomm_i2c_reg_write(const char *id, const char *reg_name, uint32_t addr, uint32_t val) "%s: %s[0x%04x] <- 0x%08x" +flexcomm_i2c_start(const char *id, uint8_t addr, uint8_t recv) "%s: 0x%02x %d" +flexcomm_i2c_rx(const char *id, uint8_t data) "%s: <- 0x%02x" +flexcomm_i2c_tx(const char *id, uint8_t data) "%s: -> 0x%02x" +flexcomm_i2c_nak(const char *id) "%s: <- nak" +flexcomm_i2c_irq(const char *id, bool irq, bool perirqs, bool enabled) "%s: %d %d %d"
hw/misc/Kconfig +1 -0
@@ -215,5 +215,6 @@ config XLNX_VERSAL_TRNG config FLEXCOMM bool + select I2C source macio/Kconfig
Signature · 1 line
2.46.0.662.g92d0881bb0-goog
Re: [PATCH 08/25] hw/i2c: add support for flexcomm i2c
Quoted 276 lines · Octavian Purdila
Add support for NXP's flexcomm i2c. It does not support slave mode or DMA.
The patch includes an automatically generated header which contains the register layout and helpers.
The header can be regenerated with the svd-flexcomm-i2c target when the build is configured with --enable-mcux-soc-svd.
Signed-off-by Octavian Purdila <[email protected]>--- include/hw/arm/svd/flexcomm_i2c.h | 1190 +++++++++++++++++++++++++++++ include/hw/i2c/flexcomm_i2c.h | 40 + include/hw/misc/flexcomm.h | 2 + hw/i2c/flexcomm_i2c.c | 250 ++++++ hw/misc/flexcomm.c | 3 + hw/arm/svd/meson.build | 3 + hw/i2c/meson.build | 1 + hw/i2c/trace-events | 10 + hw/misc/Kconfig | 1 + 9 files changed, 1500 insertions(+) create mode 100644 include/hw/arm/svd/flexcomm_i2c.h create mode 100644 include/hw/i2c/flexcomm_i2c.h create mode 100644 hw/i2c/flexcomm_i2c.cinclude/hw/arm/svd/flexcomm_i2c.h new file +245
-0@@ -0,0 +1,1190 @@ +/* +* Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause +* +* Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml +*/ +#pragma once + +#include "hw/register.h" + +/* I2C Bus Interface */ +#define FLEXCOMM_I2C_REGS_NO (1024) + +/* Configuration Register */ +REG32 (FLEXCOMM_I2C_CFG ,2048 ); +/* Master Enable */ +FIELD (FLEXCOMM_I2C_CFG ,MSTEN ,0 ,1 ); +/* Slave Enable */ +FIELD (FLEXCOMM_I2C_CFG ,SLVEN ,1 ,1 ); +/* Monitor Enable */ +FIELD (FLEXCOMM_I2C_CFG ,MONEN ,2 ,1 ); +/* I2C bus Time-out Enable */ +FIELD (FLEXCOMM_I2C_CFG ,TIMEOUTEN ,3 ,1 ); +/* Monitor function Clock Stretching */ +FIELD (FLEXCOMM_I2C_CFG ,MONCLKSTR ,4 ,1 ); +/* High Speed mode Capable enable */ +FIELD (FLEXCOMM_I2C_CFG ,HSCAPABLE ,5 ,1 ); + +/* Status Register */ +REG32 (FLEXCOMM_I2C_STAT ,2052 ); +/* Master Pending */ +FIELD (FLEXCOMM_I2C_STAT ,MSTPENDING ,0 ,1 ); +/* Master State code */ +FIELD (FLEXCOMM_I2C_STAT ,MSTSTATE ,1 ,3 ); +/* Master Arbitration Loss flag */ +FIELD (FLEXCOMM_I2C_STAT ,MSTARBLOSS ,4 ,1 ); +/* Master Start/Stop Error flag */ +FIELD (FLEXCOMM_I2C_STAT ,MSTSTSTPERR ,6 ,1 ); +/* Slave Pending */ +FIELD (FLEXCOMM_I2C_STAT ,SLVPENDING ,8 ,1 ); +/* Slave State */ +FIELD (FLEXCOMM_I2C_STAT ,SLVSTATE ,9 ,2 ); +/* Slave Not Stretching */ +FIELD (FLEXCOMM_I2C_STAT ,SLVNOTSTR ,11 ,1 ); +/* Slave address match Index T */ +FIELD (FLEXCOMM_I2C_STAT ,SLVIDX ,12 ,2 ); +/* Slave selected flag */ +FIELD (FLEXCOMM_I2C_STAT ,SLVSEL ,14 ,1 ); +/* Slave Deselected flag */ +FIELD (FLEXCOMM_I2C_STAT ,SLVDESEL ,15 ,1 ); +/* Monitor Ready */ +FIELD (FLEXCOMM_I2C_STAT ,MONRDY ,16 ,1 ); +/* Monitor Overflow flag */ +FIELD (FLEXCOMM_I2C_STAT ,MONOV ,17 ,1 ); +/* Monitor Active flag */ +FIELD (FLEXCOMM_I2C_STAT ,MONACTIVE ,18 ,1 ); +/* Monitor Idle flag */ +FIELD (FLEXCOMM_I2C_STAT ,MONIDLE ,19 ,1 ); +/* Event Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_STAT ,EVENTTIMEOUT ,24 ,1 ); +/* SCL Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_STAT ,SCLTIMEOUT ,25 ,1 ); + +/* Interrupt Enable Set Register */ +REG32 (FLEXCOMM_I2C_INTENSET ,2056 ); +/* Master Pending interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MSTPENDINGEN ,0 ,1 ); +/* Master Arbitration Loss interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MSTARBLOSSEN ,4 ,1 ); +/* Master Start/Stop Error interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MSTSTSTPERREN ,6 ,1 ); +/* Slave Pending interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SLVPENDINGEN ,8 ,1 ); +/* Slave Not Stretching interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SLVNOTSTREN ,11 ,1 ); +/* Slave Deselect interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SLVDESELEN ,15 ,1 ); +/* Monitor data Ready interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MONRDYEN ,16 ,1 ); +/* Monitor Overrun interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MONOVEN ,17 ,1 ); +/* Monitor Idle interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MONIDLEEN ,19 ,1 ); +/* Event Time-out interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,EVENTTIMEOUTEN ,24 ,1 ); +/* SCL Time-out interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SCLTIMEOUTEN ,25 ,1 ); + +/* Interrupt Enable Clear Register */ +REG32 (FLEXCOMM_I2C_INTENCLR ,2060 ); +/* Master Pending interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MSTPENDINGCLR ,0 ,1 ); +/* Master Arbitration Loss interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MSTARBLOSSCLR ,4 ,1 ); +/* Master Start/Stop Error interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MSTSTSTPERRCLR ,6 ,1 ); +/* Slave Pending interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SLVPENDINGCLR ,8 ,1 ); +/* Slave Not Stretching interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SLVNOTSTRCLR ,11 ,1 ); +/* Slave Deselect interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SLVDESELCLR ,15 ,1 ); +/* Monitor data Ready interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MONRDYCLR ,16 ,1 ); +/* Monitor Overrun interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MONOVCLR ,17 ,1 ); +/* Monitor Idle interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MONIDLECLR ,19 ,1 ); +/* Event time-out interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,EVENTTIMEOUTCLR ,24 ,1 ); +/* SCL time-out interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SCLTIMEOUTCLR ,25 ,1 ); + +/* Time-out Register */ +REG32 (FLEXCOMM_I2C_TIMEOUT ,2064 ); +/* Time-out time value, the bottom 4 bits */ +FIELD (FLEXCOMM_I2C_TIMEOUT ,TOMIN ,0 ,4 ); +/* Time-out time value */ +FIELD (FLEXCOMM_I2C_TIMEOUT ,TO ,4 ,12 ); + +/* Clock Divider Register */ +REG32 (FLEXCOMM_I2C_CLKDIV ,2068 ); +/* Divider Value */ +FIELD (FLEXCOMM_I2C_CLKDIV ,DIVVAL ,0 ,16 ); + +/* Interrupt Status Register */ +REG32 (FLEXCOMM_I2C_INTSTAT ,2072 ); +/* Master Pending */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MSTPENDING ,0 ,1 ); +/* Master Arbitration Loss flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MSTARBLOSS ,4 ,1 ); +/* Master Start/Stop Error flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MSTSTSTPERR ,6 ,1 ); +/* Slave Pending */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SLVPENDING ,8 ,1 ); +/* Slave Not Stretching status */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SLVNOTSTR ,11 ,1 ); +/* Slave Deselected flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SLVDESEL ,15 ,1 ); +/* Monitor Ready */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MONRDY ,16 ,1 ); +/* Monitor Overflow flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MONOV ,17 ,1 ); +/* Monitor Idle flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MONIDLE ,19 ,1 ); +/* Event Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,EVENTTIMEOUT ,24 ,1 ); +/* SCL Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SCLTIMEOUT ,25 ,1 ); + +/* Master Control Register */ +REG32 (FLEXCOMM_I2C_MSTCTL ,2080 ); +/* Master Continue(write-only) */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTCONTINUE ,0 ,1 ); +/* Master Start control(write-only) */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTSTART ,1 ,1 ); +/* Master Stop control(write-only) */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTSTOP ,2 ,1 ); +/* Master DMA enable */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTDMA ,3 ,1 ); + +/* Master Timing Register */ +REG32 (FLEXCOMM_I2C_MSTTIME ,2084 ); +/* Master SCL Low time */ +FIELD (FLEXCOMM_I2C_MSTTIME ,MSTSCLLOW ,0 ,3 ); +/* Master SCL High time */ +FIELD (FLEXCOMM_I2C_MSTTIME ,MSTSCLHIGH ,4 ,3 ); + +/* Master Data Register */ +REG32 (FLEXCOMM_I2C_MSTDAT ,2088 ); +/* Master function data register */ +FIELD (FLEXCOMM_I2C_MSTDAT ,DATA ,0 ,8 ); + +/* Slave Control Register */ +REG32 (FLEXCOMM_I2C_SLVCTL ,2112 ); +/* Slave Continue */ +FIELD (FLEXCOMM_I2C_SLVCTL ,SLVCONTINUE ,0 ,1 ); +/* Slave NACK */ +FIELD (FLEXCOMM_I2C_SLVCTL ,SLVNACK ,1 ,1 ); +/* Slave DMA enable */ +FIELD (FLEXCOMM_I2C_SLVCTL ,SLVDMA ,3 ,1 ); +/* Automatic Acknowledge */ +FIELD (FLEXCOMM_I2C_SLVCTL ,AUTOACK ,8 ,1 ); +/* Automatic Match Read */ +FIELD (FLEXCOMM_I2C_SLVCTL ,AUTOMATCHREAD ,9 ,1 ); + +/* Slave Data Register */ +REG32 (FLEXCOMM_I2C_SLVDAT ,2116 ); +/* Slave function data register */ +FIELD (FLEXCOMM_I2C_SLVDAT ,DATA ,0 ,8 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR0 ,2120 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR0 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR0 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR0 ,AUTONACK ,15 ,1 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR1 ,2124 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR1 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR1 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR1 ,AUTONACK ,15 ,1 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR2 ,2128 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR2 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR2 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR2 ,AUTONACK ,15 ,1 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR3 ,2132 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR3 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR3 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR3 ,AUTONACK ,15 ,1 ); + +/* Slave Qualification for Address 0 Register */ +REG32 (FLEXCOMM_I2C_SLVQUAL0 ,2136 ); +/* Qualify mode for slave address 0 */ +FIELD (FLEXCOMM_I2C_SLVQUAL0 ,QUALMODE0 ,0 ,1 ); +/* Slave address Qualifier for address 0 */ +FIELD (FLEXCOMM_I2C_SLVQUAL0 ,SLVQUAL0 ,1 ,7 ); + +/* Monitor Receiver Data Register */ +REG32 (FLEXCOMM_I2C_MONRXDAT ,2176 ); +/* Monitor function Receiver Data */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONRXDAT ,0 ,8 ); +/* Monitor Received Start */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONSTART ,8 ,1 ); +/* Monitor Received Repeated Start */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONRESTART ,9 ,1 ); +/* Monitor Received NACK */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONNACK ,10 ,1 ); + +/* Peripheral Identification Register */
include/hw/arm/svd/flexcomm_i2c.h line 255
Quoted 10 lines
include/hw/arm/svd/flexcomm_i2c.h new file +10
-0+REG32 (FLEXCOMM_I2C_ID ,4092 ); +/* Aperture */ +FIELD (FLEXCOMM_I2C_ID ,APERTURE ,0 ,8 ); +/* Minor revision of module implementation */ +FIELD (FLEXCOMM_I2C_ID ,MINOR_REV ,8 ,4 ); +/* Major revision of module implementation */ +FIELD (FLEXCOMM_I2C_ID ,MAJOR_REV ,12 ,4 ); +/* Module identifier for the selected function */ +FIELD (FLEXCOMM_I2C_ID ,ID ,16 ,16 ); +
Are any of the below enums even used? Or for that matter, most of the above fields?
If these are just here for documentation, I would prefer English text; it's more dense and easier to read. It's very difficult to tie all this together into a cohesive view of the device registers.
The .c file itself seems ok.
-corey
Quoted 1,340 lines
include/hw/arm/svd/flexcomm_i2c.h new file +935
-0+ +typedef enum { +/* +* Disabled. The I2C Master function is disabled. When disabled, the Master +* configuration settings are not changed, but the Master function is +* internally reset. +*/ +FLEXCOMM_I2C_CFG_MSTEN_DISABLED =0 , +/* Enabled. The I2C Master function is enabled. */ +FLEXCOMM_I2C_CFG_MSTEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_MSTEN_Enum ; + +typedef enum { +/* +* Disabled. The I2C slave function is disabled. When disabled, the Slave +* configuration settings are not changed, but the Slave function is +* internally reset. +*/ +FLEXCOMM_I2C_CFG_SLVEN_DISABLED =0 , +/* Enabled. The I2C slave function is enabled. */ +FLEXCOMM_I2C_CFG_SLVEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_SLVEN_Enum ; + +typedef enum { +/* +* Disabled. The I2C Monitor function is disabled. When disabled, the +* Monitor function configuration settings are not changed, but the Monitor +* function is internally reset. +*/ +FLEXCOMM_I2C_CFG_MONEN_DISABLED =0 , +/* Enabled. The I2C Monitor function is enabled. */ +FLEXCOMM_I2C_CFG_MONEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_MONEN_Enum ; + +typedef enum { +/* +* Disabled. The time-out function is disabled. When disabled, the time-out +* function is internally reset. +*/ +FLEXCOMM_I2C_CFG_TIMEOUTEN_DISABLED =0 , +/* +* Enabled. The time-out function is enabled. Both types of time-out flags +* will be generated and will cause interrupts if those flags are enabled. +* Typically, only one time-out flag will be used in a system. +*/ +FLEXCOMM_I2C_CFG_TIMEOUTEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_TIMEOUTEN_Enum ; + +typedef enum { +/* +* Disabled. The Monitor function will not perform clock stretching. +* Software or DMA may not always be able to read data provided by the +* Monitor function before it (the data) is overwritten. This mode can be +* used when non-invasive monitoring is critical. +*/ +FLEXCOMM_I2C_CFG_MONCLKSTR_DISABLED =0 , +/* +* Enabled. The Monitor function will perform clock stretching, to ensure +* that the software or DMA can read all incoming data supplied by the +* Monitor function. +*/ +FLEXCOMM_I2C_CFG_MONCLKSTR_ENABLED =1 , +}FLEXCOMM_I2C_CFG_MONCLKSTR_Enum ; + +typedef enum { +/* Fast mode Plus enable */ +FLEXCOMM_I2C_CFG_HSCAPABLE_FAST_MODE_PLUS =0 , +/* High Speed mode enable */ +FLEXCOMM_I2C_CFG_HSCAPABLE_HIGH_SPEED =1 , +}FLEXCOMM_I2C_CFG_HSCAPABLE_Enum ; + +typedef enum { +/* +* In progress. Communication is in progress and the Master function is +* busy and cannot currently accept a command. +*/ +FLEXCOMM_I2C_STAT_MSTPENDING_IN_PROGRESS =0 , +/* +* Pending. The Master function needs software service or is in the idle +* state. If the master is not in the idle state, then the master is +* waiting to receive or transmit data, or is waiting for the NACK bit. +*/ +FLEXCOMM_I2C_STAT_MSTPENDING_PENDING =1 , +}FLEXCOMM_I2C_STAT_MSTPENDING_Enum ; + +typedef enum { +/* +* Idle. The Master function is available to be used for a new transaction. +*/ +FLEXCOMM_I2C_STAT_MSTSTATE_IDLE =0 , +/* +* Receive ready. Received data is available (in Master Receiver mode). +* Address plus Read was previously sent and Acknowledged by a slave. +*/ +FLEXCOMM_I2C_STAT_MSTSTATE_RECEIVE_READY =1 , +/* +* Transmit ready. Data can be transmitted (in Master Transmitter mode). +* Address plus Write was previously sent and Acknowledged by a slave. +*/ +FLEXCOMM_I2C_STAT_MSTSTATE_TRANSMIT_READY =2 , +/* NACK Address. Slave NACKed address. */ +FLEXCOMM_I2C_STAT_MSTSTATE_NACK_ADDRESS =3 , +/* NACK Data. Slave NACKed transmitted data. */ +FLEXCOMM_I2C_STAT_MSTSTATE_NACK_DATA =4 , +}FLEXCOMM_I2C_STAT_MSTSTATE_Enum ; + +typedef enum { +/* No Arbitration Loss has occurred */ +FLEXCOMM_I2C_STAT_MSTARBLOSS_NO_LOSS =0 , +/* +* Arbitration loss. The Master function has experienced an Arbitration +* Loss. At this point, the Master function has already stopped driving the +* bus and has gone into an idle state. Software can respond by doing +* nothing, or by sending a Start (to attempt to gain control of the bus +* when the bus next becomes idle). +*/ +FLEXCOMM_I2C_STAT_MSTARBLOSS_ARBITRATION_LOSS =1 , +}FLEXCOMM_I2C_STAT_MSTARBLOSS_Enum ; + +typedef enum { +/* No Start/Stop Error has occurred. */ +FLEXCOMM_I2C_STAT_MSTSTSTPERR_NO_ERROR =0 , +/* +* The Master function has experienced a Start/Stop Error. A Start or Stop +* was detected at a time when Start or Stop is not allowed by the I2C +* specification. The Master interface has stopped driving the bus and gone +* into an idle state; no action is required. A request for a Start could +* be made, or software could attempt to make sure that the bus has not +* stalled. +*/ +FLEXCOMM_I2C_STAT_MSTSTSTPERR_ERROR =1 , +}FLEXCOMM_I2C_STAT_MSTSTSTPERR_Enum ; + +typedef enum { +/* +* In progress. The Slave function does not currently need software +* service. +*/ +FLEXCOMM_I2C_STAT_SLVPENDING_IN_PROGRESS =0 , +/* +* Pending. The Slave function needs software service. Information about +* what is needed is in the Slave state field (SLVSTATE). +*/ +FLEXCOMM_I2C_STAT_SLVPENDING_PENDING =1 , +}FLEXCOMM_I2C_STAT_SLVPENDING_Enum ; + +typedef enum { +/* +* Slave address. Address plus R/W received. At least one of the 4 slave +* addresses has been matched by hardware. +*/ +FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_ADDRESS =0 , +/* Slave receive. Received data is available (in Slave Receiver mode). */ +FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_RECEIVE =1 , +/* Slave transmit. Data can be transmitted (in Slave Transmitter mode). */ +FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_TRANSMIT =2 , +}FLEXCOMM_I2C_STAT_SLVSTATE_Enum ; + +typedef enum { +/* +* Stretching. The slave function is currently stretching the I2C bus +* clock. Deep-Sleepmode cannot be entered at this time. +*/ +FLEXCOMM_I2C_STAT_SLVNOTSTR_STRETCHING =0 , +/* +* Not stretching. The slave function is not currently stretching the I2C +* bus clock. Deep-sleep mode can be entered at this time. +*/ +FLEXCOMM_I2C_STAT_SLVNOTSTR_NOT_STRETCHING =1 , +}FLEXCOMM_I2C_STAT_SLVNOTSTR_Enum ; + +typedef enum { +/* Address 0. Slave address 0 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS0 =0 , +/* Address 1. Slave address 1 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS1 =1 , +/* Address 2. Slave address 2 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS2 =2 , +/* Address 3. Slave address 3 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS3 =3 , +}FLEXCOMM_I2C_STAT_SLVIDX_Enum ; + +typedef enum { +/* Not selected. The Slave function is not currently selected. */ +FLEXCOMM_I2C_STAT_SLVSEL_NOT_SELECTED =0 , +/* Selected. The Slave function is currently selected. */ +FLEXCOMM_I2C_STAT_SLVSEL_SELECTED =1 , +}FLEXCOMM_I2C_STAT_SLVSEL_Enum ; + +typedef enum { +/* +* Not deselected. The Slave function has not become deselected. This does +* not mean that the Slave is currently selected. That information is in +* the SLVSEL flag. +*/ +FLEXCOMM_I2C_STAT_SLVDESEL_NOT_DESELECTED =0 , +/* +* Deselected. The Slave function has become deselected. This is +* specifically caused by the SLVSEL flag changing from 1 to 0. See SLVSEL +* for details about when that event occurs. +*/ +FLEXCOMM_I2C_STAT_SLVDESEL_DESELECTED =1 , +}FLEXCOMM_I2C_STAT_SLVDESEL_Enum ; + +typedef enum { +/* No data. The Monitor function does not currently have data available. */ +FLEXCOMM_I2C_STAT_MONRDY_NO_DATA =0 , +/* Data waiting. The Monitor function has data waiting to be read. */ +FLEXCOMM_I2C_STAT_MONRDY_DATA_WAITING =1 , +}FLEXCOMM_I2C_STAT_MONRDY_Enum ; + +typedef enum { +/* No overrun. Monitor data has not overrun. */ +FLEXCOMM_I2C_STAT_MONOV_NO_OVERRUN =0 , +/* +* Overrun. A Monitor data overrun has occurred. An overrun can only happen +* when Monitor clock stretching not enabled via the CFG[MONCLKSTR] bit. +* Writing 1 to MONOV bit clears the MONOV flag. +*/ +FLEXCOMM_I2C_STAT_MONOV_OVERRUN =1 , +}FLEXCOMM_I2C_STAT_MONOV_Enum ; + +typedef enum { +/* Inactive. The Monitor function considers the I2C bus to be inactive. */ +FLEXCOMM_I2C_STAT_MONACTIVE_INACTIVE =0 , +/* Active. The Monitor function considers the I2C bus to be active. */ +FLEXCOMM_I2C_STAT_MONACTIVE_ACTIVE =1 , +}FLEXCOMM_I2C_STAT_MONACTIVE_Enum ; + +typedef enum { +/* +* Not idle. The I2C bus is not idle, or MONIDLE flag has been cleared by +* software. +*/ +FLEXCOMM_I2C_STAT_MONIDLE_NOT_IDLE =0 , +/* +* Idle. The I2C bus has gone idle at least once, since the last time +* MONIDLE flag was cleared by software. +*/ +FLEXCOMM_I2C_STAT_MONIDLE_IDLE =1 , +}FLEXCOMM_I2C_STAT_MONIDLE_Enum ; + +typedef enum { +/* No time-out. I2C bus events have not caused a time-out. */ +FLEXCOMM_I2C_STAT_EVENTTIMEOUT_NO_TIMEOUT =0 , +/* +* Event time-out. The time between I2C bus events has been longer than the +* time specified by the TIMEOUT register. +*/ +FLEXCOMM_I2C_STAT_EVENTTIMEOUT_EVEN_TIMEOUT =1 , +}FLEXCOMM_I2C_STAT_EVENTTIMEOUT_Enum ; + +typedef enum { +/* No time-out. SCL low time has not caused a time-out. */ +FLEXCOMM_I2C_STAT_SCLTIMEOUT_NO_TIMEOUT =0 , +/* Time-out. SCL low time has caused a time-out. */ +FLEXCOMM_I2C_STAT_SCLTIMEOUT_TIMEOUT =1 , +}FLEXCOMM_I2C_STAT_SCLTIMEOUT_Enum ; + +typedef enum { +/* Disabled. The MstPending interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_DISABLED =0 , +/* Enabled. The MstPending interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_Enum ; + +typedef enum { +/* Disabled. The MstArbLoss interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_DISABLED =0 , +/* Enabled. The MstArbLoss interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_Enum ; + +typedef enum { +/* Disabled. The MstStStpErr interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_DISABLED =0 , +/* Enabled. The MstStStpErr interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_Enum ; + +typedef enum { +/* Disabled. The SlvPending interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_DISABLED =0 , +/* Enabled. The SlvPending interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_Enum ; + +typedef enum { +/* Disabled. The SlvNotStr interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_DISABLED =0 , +/* Enabled. The SlvNotStr interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_Enum ; + +typedef enum { +/* Disabled. The SlvDeSel interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SLVDESELEN_DISABLED =0 , +/* Enabled. The SlvDeSel interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SLVDESELEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SLVDESELEN_Enum ; + +typedef enum { +/* Disabled. The MonRdy interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MONRDYEN_DISABLED =0 , +/* Enabled. The MonRdy interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MONRDYEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MONRDYEN_Enum ; + +typedef enum { +/* Disabled. The MonOv interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MONOVEN_DISABLED =0 , +/* Enabled. The MonOv interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MONOVEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MONOVEN_Enum ; + +typedef enum { +/* Disabled. The MonIdle interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MONIDLEEN_DISABLED =0 , +/* Enabled. The MonIdle interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MONIDLEEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MONIDLEEN_Enum ; + +typedef enum { +/* Disabled. The Event time-out interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_DISABLED =0 , +/* Enabled. The Event time-out interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_Enum ; + +typedef enum { +/* Disabled. The SCL time-out interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_DISABLED =0 , +/* Enabled. The SCL time-out interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_CLEAR_MSTPENDING =1 , +}FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_CLEAR_MSTARBLOSS =1 , +}FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_CLEAR_MSTSTSTPERR =1 , +}FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_CLEAR_SLVPENDING =1 , +}FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_CLEAR_SLVNOTSTR =1 , +}FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_CLEAR_SLVDESEL =1 , +}FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MONRDYCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MONRDYCLR_CLEAR_MONRDY =1 , +}FLEXCOMM_I2C_INTENCLR_MONRDYCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MONOVCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MONOVCLR_CLEAR_MONOV =1 , +}FLEXCOMM_I2C_INTENCLR_MONOVCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MONIDLECLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MONIDLECLR_CLEAR_MONIDLE =1 , +}FLEXCOMM_I2C_INTENCLR_MONIDLECLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_CLEAR_EVENTTIMEOUT =1 , +}FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_CLEAR_SCLTIMEOUT =1 , +}FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_Enum ; + +typedef enum { +/* A time-out will occur after 16 counts of the I2C function clock. */ +FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT16 =0 , +/* A time-out will occur after 32 counts of the I2C function clock. */ +FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT32 =1 , +/* A time-out will occur after 65,536 counts of the I2C function clock. */ +FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT65K =4095 , +}FLEXCOMM_I2C_TIMEOUT_TO_Enum ; + +typedef enum { +/* FCLK is used directly by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKUNDIVIDED =0 , +/* FCLK is divided by 2 before being used by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV2 =1 , +/* FCLK is divided by 3 before being used by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV3 =2 , +/* FCLK is divided by 65,536 before being used by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV65K =65535 , +}FLEXCOMM_I2C_CLKDIV_DIVVAL_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MSTPENDING_MSTPENDING_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MSTPENDING_MSTPENDING_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MSTPENDING_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_MSTARBLOSS_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_MSTARBLOSS_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_MSTSTSTPERR_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_MSTSTSTPERR_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SLVPENDING_SLVPENDING_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SLVPENDING_SLVPENDING_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SLVPENDING_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_SLVNOTSTR_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_SLVNOTSTR_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SLVDESEL_SLVDESEL_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SLVDESEL_SLVDESEL_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SLVDESEL_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MONRDY_MONRDY_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MONRDY_MONRDY_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MONRDY_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MONOV_MONOV_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MONOV_MONOV_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MONOV_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MONIDLE_MONIDLE_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MONIDLE_MONIDLE_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MONIDLE_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_EVENTTIMEOUT_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_EVENTTIMEOUT_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_SCLTIMEOUT_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_SCLTIMEOUT_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_NO_EFFECT =0 , +/* +* Continue. Informs the Master function to continue to the next operation. +* This action must done after writing transmit data, reading received +* data, or any other housekeeping related to the next bus operation. +*/ +FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_CONTINUE =1 , +}FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_MSTCTL_MSTSTART_NO_EFFECT =0 , +/* +* Start. A Start will be generated on the I2C bus at the next allowed +* time. +*/ +FLEXCOMM_I2C_MSTCTL_MSTSTART_START =1 , +}FLEXCOMM_I2C_MSTCTL_MSTSTART_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_MSTCTL_MSTSTOP_NO_EFFECT =0 , +/* +* Stop. A Stop will be generated on the I2C bus at the next allowed time, +* preceded by a NACK to the slave if the master is receiving data from the +* slave (in Master Receiver mode). +*/ +FLEXCOMM_I2C_MSTCTL_MSTSTOP_STOP =1 , +}FLEXCOMM_I2C_MSTCTL_MSTSTOP_Enum ; + +typedef enum { +/* Disable. No DMA requests are generated for master operation. */ +FLEXCOMM_I2C_MSTCTL_MSTDMA_DISABLED =0 , +/* +* Enable. A DMA request is generated for I2C master data operations. When +* this I2C master is generating Acknowledge bits in Master Receiver mode, +* the acknowledge is generated automatically. +*/ +FLEXCOMM_I2C_MSTCTL_MSTDMA_ENABLED =1 , +}FLEXCOMM_I2C_MSTCTL_MSTDMA_Enum ; + +typedef enum { +/* +* 2 clocks. Minimum SCL low time is 2 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_2CLOCKS =0 , +/* +* 3 clocks. Minimum SCL low time is 3 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_3CLOCKS =1 , +/* +* 4 clocks. Minimum SCL low time is 4 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_4CLOCKS =2 , +/* +* 5 clocks. Minimum SCL low time is 5 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_5CLOCKS =3 , +/* +* 6 clocks. Minimum SCL low time is 6 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_6CLOCKS =4 , +/* +* 7 clocks. Minimum SCL low time is 7 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_7CLOCKS =5 , +/* +* 8 clocks. Minimum SCL low time is 8 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_8CLOCKS =6 , +/* +* 9 clocks. Minimum SCL low time is 9 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_9CLOCKS =7 , +}FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_Enum ; + +typedef enum { +/* +* 2 clocks. Minimum SCL high time is 2 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_2CLOCKS =0 , +/* +* 3 clocks. Minimum SCL high time is 3 clocks of the I2C clock pre-divider +* . +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_3CLOCKS =1 , +/* +* 4 clocks. Minimum SCL high time is 4 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_4CLOCKS =2 , +/* +* 5 clocks. Minimum SCL high time is 5 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_5CLOCKS =3 , +/* +* 6 clocks. Minimum SCL high time is 6 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_6CLOCKS =4 , +/* +* 7 clocks. Minimum SCL high time is 7 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_7CLOCKS =5 , +/* +* 8 clocks. Minimum SCL high time is 8 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_8CLOCKS =6 , +/* +* 9 clocks. Minimum SCL high time is 9 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_9CLOCKS =7 , +}FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_NO_EFFECT =0 , +/* +* Continue. Informs the Slave function to continue to the next operation, +* by clearing the STAT[SLVPENDING] flag. This must be done after writing +* transmit data, reading received data, or any other housekeeping related +* to the next bus operation. Automatic Operation has different +* requirements. SLVCONTINUE should not be set unless SLVPENDING = 1. +*/ +FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_CONTINUE =1 , +}FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_SLVCTL_SLVNACK_NO_EFFECT =0 , +/* +* NACK. Causes the Slave function to NACK the master when the slave is +* receiving data from the master (in Slave Receiver mode). +*/ +FLEXCOMM_I2C_SLVCTL_SLVNACK_NACK =1 , +}FLEXCOMM_I2C_SLVCTL_SLVNACK_Enum ; + +typedef enum { +/* Disabled. No DMA requests are issued for Slave mode operation. */ +FLEXCOMM_I2C_SLVCTL_SLVDMA_DISABLED =0 , +/* +* Enabled. DMA requests are issued for I2C slave data transmission and +* reception. +*/ +FLEXCOMM_I2C_SLVCTL_SLVDMA_ENABLED =1 , +}FLEXCOMM_I2C_SLVCTL_SLVDMA_Enum ; + +typedef enum { +/* +* Normal, non-automatic operation. If AUTONACK = 0, then a SlvPending +* interrupt is generated when a matching address is received. If AUTONACK +* = 1, then received addresses are NACKed (ignored). +*/ +FLEXCOMM_I2C_SLVCTL_AUTOACK_NORMAL =0 , +/* +* A header with matching SLVADR0 and matching direction as set by +* AUTOMATCHREAD will be ACKed immediately, allowing the master to move on +* to the data bytes. If the address matches SLVADR0, but the direction +* does not match AUTOMATCHREAD, then the behavior will depend on the +* SLVADR0[AUTONACK] bit: if AUTONACK is set, then it will be Nacked; if +* AUTONACK is clear, then a SlvPending interrupt is generated. +*/ +FLEXCOMM_I2C_SLVCTL_AUTOACK_AUTOMATIC_ACK =1 , +}FLEXCOMM_I2C_SLVCTL_AUTOACK_Enum ; + +typedef enum { +/* In Automatic Mode, the expected next operation is an I2C write. */ +FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_I2C_WRITE =0 , +/* In Automatic Mode, the expected next operation is an I2C read. */ +FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_I2C_READ =1 , +}FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR0_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR0_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR0_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR0_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR0_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR0_AUTONACK_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR1_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR1_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR1_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR1_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR1_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR1_AUTONACK_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR2_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR2_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR2_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR2_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR2_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR2_AUTONACK_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR3_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR3_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR3_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR3_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR3_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR3_AUTONACK_Enum ; + +typedef enum { +/* +* Mask. The SLVQUAL0 field is used as a logical mask for matching address +* 0. +*/ +FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_MASK =0 , +/* +* Extend. The SLVQUAL0 field is used to extend address 0 matching in a +* range of addresses. +*/ +FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_EXTEND =1 , +}FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_Enum ; + +typedef enum { +/* +* No start detected. The Monitor function has not detected a Start event +* on the I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONSTART_NO_START_DETECTED =0 , +/* +* Start detected. The Monitor function has detected a Start event on the +* I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONSTART_START_DETECTED =1 , +}FLEXCOMM_I2C_MONRXDAT_MONSTART_Enum ; + +typedef enum { +/* +* No repeated start detected. The Monitor function has not detected a +* Repeated Start event on the I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONRESTART_NOT_DETECTED =0 , +/* +* Repeated start detected. The Monitor function has detected a Repeated +* Start event on the I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONRESTART_DETECTED =1 , +}FLEXCOMM_I2C_MONRXDAT_MONRESTART_Enum ; + +typedef enum { +/* +* Acknowledged. The data currently being provided by the Monitor function +* was acknowledged by at least one master or slave receiver. +*/ +FLEXCOMM_I2C_MONRXDAT_MONNACK_ACKNOWLEDGED =0 , +/* +* Not acknowledged. The data currently being provided by the Monitor +* function was not acknowledged by any receiver. +*/ +FLEXCOMM_I2C_MONRXDAT_MONNACK_NOT_ACKNOWLEDGED =1 , +}FLEXCOMM_I2C_MONRXDAT_MONNACK_Enum ; + + +#define FLEXCOMM_I2C_REGISTER_ACCESS_INFO_ARRAY (_name) \ + struct RegisterAccessInfo _name[FLEXCOMM_I2C_REGS_NO] = { \ + [0 ... FLEXCOMM_I2C_REGS_NO - 1] = { \ + .name = "", \ + .addr = -1, \ + }, \ + [R_FLEXCOMM_I2C_CFG] = { \ + .name = "CFG", \ + .addr = 0x800, \ + .ro = 0xFFFFFFC0, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_STAT] = { \ + .name = "STAT", \ + .addr = 0x804, \ + .ro = 0xFCF57FAF, \ + .reset = 0x801, \ + }, \ + [R_FLEXCOMM_I2C_INTENSET] = { \ + .name = "INTENSET", \ + .addr = 0x808, \ + .ro = 0xFCF476AE, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_INTENCLR] = { \ + .name = "INTENCLR", \ + .addr = 0x80C, \ + .ro = 0xFCF476AE, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_TIMEOUT] = { \ + .name = "TIMEOUT", \ + .addr = 0x810, \ + .ro = 0xFFFF0000, \ + .reset = 0xFFFF, \ + }, \ + [R_FLEXCOMM_I2C_CLKDIV] = { \ + .name = "CLKDIV", \ + .addr = 0x814, \ + .ro = 0xFFFF0000, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_INTSTAT] = { \ + .name = "INTSTAT", \ + .addr = 0x818, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x801, \ + }, \ + [R_FLEXCOMM_I2C_MSTCTL] = { \ + .name = "MSTCTL", \ + .addr = 0x820, \ + .ro = 0xFFFFFFF0, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_MSTTIME] = { \ + .name = "MSTTIME", \ + .addr = 0x824, \ + .ro = 0xFFFFFF88, \ + .reset = 0x77, \ + }, \ + [R_FLEXCOMM_I2C_MSTDAT] = { \ + .name = "MSTDAT", \ + .addr = 0x828, \ + .ro = 0xFFFFFF00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVCTL] = { \ + .name = "SLVCTL", \ + .addr = 0x840, \ + .ro = 0xFFFFFCF4, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVDAT] = { \ + .name = "SLVDAT", \ + .addr = 0x844, \ + .ro = 0xFFFFFF00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR0] = { \ + .name = "SLVADR0", \ + .addr = 0x848, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR1] = { \ + .name = "SLVADR1", \ + .addr = 0x84C, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR2] = { \ + .name = "SLVADR2", \ + .addr = 0x850, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR3] = { \ + .name = "SLVADR3", \ + .addr = 0x854, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVQUAL0] = { \ + .name = "SLVQUAL0", \ + .addr = 0x858, \ + .ro = 0xFFFFFF00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_MONRXDAT] = { \ + .name = "MONRXDAT", \ + .addr = 0x880, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_ID] = { \ + .name = "ID", \ + .addr = 0xFFC, \ + .ro = 0xFFFFFFFF, \ + .reset = 0xE0301300, \ + }, \ + }include/hw/i2c/flexcomm_i2c.h new file +40
-0@@ -0,0 +1,40 @@ +/* +* QEMU model for NXP's FLEXCOMM I2C +* +* Copyright (c) 2024 Google LLC +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef HW_FLEXCOMM_I2C_H +#define HW_FLEXCOMM_I2C_H + +#include "hw/i2c/i2c.h" +#include "hw/misc/flexcomm_function.h" + +#define TYPE_FLEXCOMM_I2C "flexcomm-i2c" +OBJECT_DECLARE_TYPE (FlexcommI2cState, FlexcommI2cClass,FLEXCOMM_I2C ); + +struct FlexcommI2cState { +FlexcommFunction parent_obj; + +I2CBus *bus; +}; + +struct FlexcommI2cClass { +FlexcommFunctionClass parent_obj; + +FlexcommFunctionSelect select; +}; + +#define MSTSTATE_IDLE 0 +#define MSTSTATE_RXRDY 1 +#define MSTSTATE_TXRDY 2 +#define MSTSTATE_NAKADR 3 +#define MSTSTATE_NAKDAT 4 + + +#endif /* HW_FLEXCOMM_I2C_H */ include/hw/misc/flexcomm.h +2
-0@@ -16,6 +16,7 @@#include "hw/arm/svd/flexcomm.h" #include "qemu/fifo32.h" #include "hw/char/flexcomm_usart.h" +#include "hw/i2c/flexcomm_i2c.h" #define FLEXCOMM_FUNC_USART 0#define FLEXCOMM_FUNC_SPI 1@@ -48,6 +49,7 @@ struct FlexcommState {Fifo32 rx_fifo;Fifo32 tx_fifo;FlexcommUsartState usart; + FlexcommI2cState i2c; };#endif /* HW_FLEXCOMM_H */ hw/i2c/flexcomm_i2c.c new file +250
-0@@ -0,0 +1,250 @@ +/* +* QEMU model for NXP's FLEXCOMM I2C +* +* Copyright (c) 2024 Google LLC +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "exec/address-spaces.h" +#include "qapi/error.h" +#include "trace.h" +#include "hw/i2c/flexcomm_i2c.h" +#include "hw/arm/svd/flexcomm_i2c.h" + +#define REG (s, reg) (s->regs[R_FLEXCOMM_I2C_##reg]) +#define RF_WR (s, reg, field, val) \ + ARRAY_FIELD_DP32(s->regs, FLEXCOMM_I2C_##reg, field, val) +#define RF_RD (s, reg, field) \ + ARRAY_FIELD_EX32(s->regs, FLEXCOMM_I2C_##reg, field) + +static FLEXCOMM_I2C_REGISTER_ACCESS_INFO_ARRAY (reg_info); + +static void flexcomm_i2c_reset (FlexcommFunction *f) +{ +for (int i =0 ; i <FLEXCOMM_I2C_REGS_NO ; i++) { +hwaddr addr = reg_info[i].addr; + +if (addr !=-1 ) { +struct RegisterInfo ri = { + .data = &f->regs[addr /4 ], + .data_size =4 , + .access = ®_info[i], + }; + +register_reset (&ri); + } + } +} + +static void flexcomm_i2c_irq_update (FlexcommFunction *f) +{ +bool enabled =RF_RD (f,CFG ,MSTEN ); +bool irq, per_irqs; + +REG (f,INTSTAT ) =REG (f,STAT ) ® (f,INTENSET ); + per_irqs =REG (f,INTSTAT ) !=0 ; + + irq = enabled && per_irqs; + +trace_flexcomm_i2c_irq (DEVICE (f)->id, irq, per_irqs, enabled); +flexcomm_set_irq (f, irq); +} + +static MemTxResult flexcomm_i2c_reg_read (void *opaque,hwaddr addr, +uint64_t *data,unsigned size, +MemTxAttrs attrs) +{ +FlexcommFunction *f =FLEXCOMM_FUNCTION (opaque); +MemTxResult ret =MEMTX_OK ; +const struct RegisterAccessInfo *rai = ®_info[addr /4 ]; + +if (size !=4 ) { + ret =MEMTX_ERROR ; + goto out; + } + + *data = f->regs[addr /4 ]; + +flexcomm_i2c_irq_update (f); + +out: +trace_flexcomm_i2c_reg_read (DEVICE (f)->id, rai->name, addr, *data); +return ret; +} + +static MemTxResult flexcomm_i2c_reg_write (void *opaque,hwaddr addr, +uint64_t value,unsigned size, +MemTxAttrs attrs) +{ +FlexcommFunction *f =FLEXCOMM_FUNCTION (opaque); +FlexcommI2cState *s =FLEXCOMM_I2C (opaque); +const struct RegisterAccessInfo *rai = ®_info[addr /4 ]; +struct RegisterInfo ri = { + .data = &f->regs[addr /4 ], + .data_size =4 , + .access = rai, + }; + +trace_flexcomm_i2c_reg_write (DEVICE (f)->id, rai->name, addr, value); + +if (size !=4 ) { +return MEMTX_ERROR ; + } + +switch (addr) { +case A_FLEXCOMM_I2C_CFG : + { +register_write (&ri, value, ~0 ,NULL , false); +if (RF_RD (f,CFG ,SLVEN )) { +qemu_log_mask (LOG_GUEST_ERROR ,"I2C slave not supported" ); + } +if (RF_RD (f,CFG ,MONEN )) { +qemu_log_mask (LOG_GUEST_ERROR ,"I2C monitoring not supported" ); + } +break ; + } +case A_FLEXCOMM_I2C_INTENCLR : + { +REG (f,INTENSET ) &= ~value; +break ; + } +case A_FLEXCOMM_I2C_TIMEOUT : + { +register_write (&ri, value, ~0 ,NULL , false); +/* The bottom 4 bits are hard-wired to 0xF */ +RF_WR (f,TIMEOUT ,TOMIN ,0xf ); +break ; + } +case A_FLEXCOMM_I2C_MSTCTL : + { +register_write (&ri, value, ~0 ,NULL , false); +if (RF_RD (f,MSTCTL ,MSTSTART )) { +uint8_t i2c_addr =RF_RD (f,MSTDAT ,DATA ); +bool recv = i2c_addr &1 ; + +trace_flexcomm_i2c_start (DEVICE (s)->id, i2c_addr, recv); +if (i2c_start_transfer (s->bus, i2c_addr, recv)) { +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_NAKADR ); +trace_flexcomm_i2c_nak (DEVICE (s)->id); + }else { +if (recv) { +uint8_t data =i2c_recv (s->bus); + +RF_WR (f,MSTDAT ,DATA , data); +trace_flexcomm_i2c_rx (DEVICE (s)->id, data); +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_RXRDY ); + }else { +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_TXRDY ); + } + } + } +if (RF_RD (f,MSTCTL ,MSTSTOP )) { +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_IDLE ); +i2c_end_transfer (s->bus); + } +if (RF_RD (f,MSTCTL ,MSTCONTINUE )) { +if (RF_RD (f,STAT ,MSTSTATE ) ==MSTSTATE_TXRDY ) { +uint8_t data =RF_RD (f,MSTDAT ,DATA ); + +trace_flexcomm_i2c_tx (DEVICE (s)->id, data); +if (i2c_send (s->bus, data)) { +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_NAKDAT ); + } + }else if (RF_RD (f,STAT ,MSTSTATE ) ==MSTSTATE_RXRDY ) { +uint8_t data =i2c_recv (s->bus); + +RF_WR (f,MSTDAT ,DATA , data); +trace_flexcomm_i2c_rx (DEVICE (s)->id, data); + } + } +break ; + } +case A_FLEXCOMM_I2C_STAT : + { +/* write 1 to clear bits */ +REG (f,STAT ) &= ~value; +break ; + } +case A_FLEXCOMM_I2C_SLVCTL : +case A_FLEXCOMM_I2C_SLVDAT : +case A_FLEXCOMM_I2C_SLVADR0 : +case A_FLEXCOMM_I2C_SLVADR1 : +case A_FLEXCOMM_I2C_SLVADR2 : +case A_FLEXCOMM_I2C_SLVADR3 : +case A_FLEXCOMM_I2C_SLVQUAL0 : + { +qemu_log_mask (LOG_GUEST_ERROR ,"I2C slave not supported\n" ); +break ; + } +default : +register_write (&ri, value, ~0 ,NULL , false); +break ; + } + +flexcomm_i2c_irq_update (f); + +return MEMTX_OK ; +} + +static void flexcomm_i2c_select (FlexcommFunction *f,bool selected) +{ +FlexcommI2cClass *ic =FLEXCOMM_I2C_GET_CLASS (f); + +if (selected) { +flexcomm_i2c_reset (f); + } + ic->select (f, selected); +} + +static const MemoryRegionOps flexcomm_i2c_ops = { + .read_with_attrs = flexcomm_i2c_reg_read, + .write_with_attrs = flexcomm_i2c_reg_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .valid = { + .min_access_size =4 , + .max_access_size =4 , + .unaligned = false, + }, +}; + +static void flexcomm_i2c_realize (DeviceState *dev,Error **errp) +{ +FlexcommI2cState *s =FLEXCOMM_I2C (dev); + + s->bus =i2c_init_bus (DEVICE (s),"bus" ); +} + +static void flexcomm_i2c_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +FlexcommFunctionClass *fc =FLEXCOMM_FUNCTION_CLASS (klass); +FlexcommI2cClass *ic =FLEXCOMM_I2C_CLASS (klass); + + dc->realize = flexcomm_i2c_realize; + ic->select = fc->select; + fc->select = flexcomm_i2c_select; + fc->name ="i2c" ; + fc->mmio_ops = &flexcomm_i2c_ops; +} + +static const TypeInfo flexcomm_i2c_types[] = { + { + .name =TYPE_FLEXCOMM_I2C , + .parent =TYPE_FLEXCOMM_FUNCTION , + .instance_size =sizeof (FlexcommI2cState), + .class_init = flexcomm_i2c_class_init, + .class_size =sizeof (FlexcommI2cClass), + }, +}; + +DEFINE_TYPES (flexcomm_i2c_types);hw/misc/flexcomm.c +3
-0@@ -24,6 +24,7 @@#include "hw/misc/flexcomm.h" #include "hw/arm/svd/flexcomm_usart.h" #include "hw/char/flexcomm_usart.h" +#include "hw/i2c/flexcomm_i2c.h" #define REG (s, reg) (s->regs[R_FLEXCOMM_##reg])#define RF_WR (s, reg, field, val) \@@ -220,6 +221,7 @@ static void flexcomm_init(Object *obj)sysbus_init_mmio (SYS_BUS_DEVICE (obj), &s->container);sysbus_init_irq (sbd, &s->irq);object_initialize_child (obj,"usart" , &s->usart,TYPE_FLEXCOMM_USART ); +object_initialize_child (obj,"i2c" , &s->i2c,TYPE_FLEXCOMM_I2C ); }static void flexcomm_finalize (Object *obj)@@ -250,6 +252,7 @@ static void flexcomm_realize(DeviceState *dev, Error **errp)memory_region_add_subregion_overlap (&s->container,0 , &s->mmio,-1 );flexcomm_func_realize_and_unref (FLEXCOMM_FUNCTION (&s->usart), errp); +flexcomm_func_realize_and_unref (FLEXCOMM_FUNCTION (&s->i2c), errp); }static const VMStateDescription vmstate_flexcomm = {hw/arm/svd/meson.build +3
-0@@ -7,4 +7,7 @@ if get_option('mcux-soc-svd') run_target('svd-flexcomm-usart', command: svd_gen_header + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_usart.h', '-p', 'USART0', '-t', 'FLEXCOMM_USART']) + run_target('svd-flexcomm-i2c', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_i2c.h', + '-p', 'I2C0', '-t', 'FLEXCOMM_I2C']) endifhw/i2c/meson.build +1
-0@@ -18,4 +18,5 @@ i2c_ss.add(when: 'CONFIG_PPC4XX', if_true: files('ppc4xx_i2c.c')) i2c_ss.add(when: 'CONFIG_PCA954X', if_true: files('i2c_mux_pca954x.c')) i2c_ss.add(when: 'CONFIG_PMBUS', if_true: files('pmbus_device.c')) i2c_ss.add(when: 'CONFIG_BCM2835_I2C', if_true: files('bcm2835_i2c.c')) +i2c_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm_i2c.c')) system_ss.add_all(when: 'CONFIG_I2C', if_true: i2c_ss)hw/i2c/trace-events +10
-0@@ -51,3 +51,13 @@ npcm7xx_smbus_recv_fifo(const char *id, uint8_t received, uint8_t expected) "%s pca954x_write_bytes(uint8_t value) "PCA954X write data: 0x%02x" pca954x_read_data(uint8_t value) "PCA954X read data: 0x%02x" + +# flexcomm_i2c.c + +flexcomm_i2c_reg_read(const char *id, const char *reg_name, uint32_t addr, uint32_t val) " %s: %s[0x%04x] -> 0x%08x" +flexcomm_i2c_reg_write(const char *id, const char *reg_name, uint32_t addr, uint32_t val) "%s: %s[0x%04x] <- 0x%08x" +flexcomm_i2c_start(const char *id, uint8_t addr, uint8_t recv) "%s: 0x%02x %d" +flexcomm_i2c_rx(const char *id, uint8_t data) "%s: <- 0x%02x" +flexcomm_i2c_tx(const char *id, uint8_t data) "%s: -> 0x%02x" +flexcomm_i2c_nak(const char *id) "%s: <- nak" +flexcomm_i2c_irq(const char *id, bool irq, bool perirqs, bool enabled) "%s: %d %d %d"hw/misc/Kconfig +1
-0@@ -215,5 +215,6 @@ config XLNX_VERSAL_TRNG config FLEXCOMM bool + select I2C source macio/KconfigSignature · 1 line
2.46.0.662.g92d0881bb0-goog
Re: [PATCH 08/25] hw/i2c: add support for flexcomm i2c
Quoted 292 lines · Corey Minyard
Quoted 276 lines · Octavian Purdila
Add support for NXP's flexcomm i2c. It does not support slave mode or DMA.
The patch includes an automatically generated header which contains the register layout and helpers.
The header can be regenerated with the svd-flexcomm-i2c target when the build is configured with --enable-mcux-soc-svd.
Signed-off-by Octavian Purdila <[email protected]>--- include/hw/arm/svd/flexcomm_i2c.h | 1190 +++++++++++++++++++++++++++++ include/hw/i2c/flexcomm_i2c.h | 40 + include/hw/misc/flexcomm.h | 2 + hw/i2c/flexcomm_i2c.c | 250 ++++++ hw/misc/flexcomm.c | 3 + hw/arm/svd/meson.build | 3 + hw/i2c/meson.build | 1 + hw/i2c/trace-events | 10 + hw/misc/Kconfig | 1 + 9 files changed, 1500 insertions(+) create mode 100644 include/hw/arm/svd/flexcomm_i2c.h create mode 100644 include/hw/i2c/flexcomm_i2c.h create mode 100644 hw/i2c/flexcomm_i2c.cinclude/hw/arm/svd/flexcomm_i2c.h new file +245
-0@@ -0,0 +1,1190 @@ +/* +* Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause +* +* Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml +*/ +#pragma once + +#include "hw/register.h" + +/* I2C Bus Interface */ +#define FLEXCOMM_I2C_REGS_NO (1024) + +/* Configuration Register */ +REG32 (FLEXCOMM_I2C_CFG ,2048 ); +/* Master Enable */ +FIELD (FLEXCOMM_I2C_CFG ,MSTEN ,0 ,1 ); +/* Slave Enable */ +FIELD (FLEXCOMM_I2C_CFG ,SLVEN ,1 ,1 ); +/* Monitor Enable */ +FIELD (FLEXCOMM_I2C_CFG ,MONEN ,2 ,1 ); +/* I2C bus Time-out Enable */ +FIELD (FLEXCOMM_I2C_CFG ,TIMEOUTEN ,3 ,1 ); +/* Monitor function Clock Stretching */ +FIELD (FLEXCOMM_I2C_CFG ,MONCLKSTR ,4 ,1 ); +/* High Speed mode Capable enable */ +FIELD (FLEXCOMM_I2C_CFG ,HSCAPABLE ,5 ,1 ); + +/* Status Register */ +REG32 (FLEXCOMM_I2C_STAT ,2052 ); +/* Master Pending */ +FIELD (FLEXCOMM_I2C_STAT ,MSTPENDING ,0 ,1 ); +/* Master State code */ +FIELD (FLEXCOMM_I2C_STAT ,MSTSTATE ,1 ,3 ); +/* Master Arbitration Loss flag */ +FIELD (FLEXCOMM_I2C_STAT ,MSTARBLOSS ,4 ,1 ); +/* Master Start/Stop Error flag */ +FIELD (FLEXCOMM_I2C_STAT ,MSTSTSTPERR ,6 ,1 ); +/* Slave Pending */ +FIELD (FLEXCOMM_I2C_STAT ,SLVPENDING ,8 ,1 ); +/* Slave State */ +FIELD (FLEXCOMM_I2C_STAT ,SLVSTATE ,9 ,2 ); +/* Slave Not Stretching */ +FIELD (FLEXCOMM_I2C_STAT ,SLVNOTSTR ,11 ,1 ); +/* Slave address match Index T */ +FIELD (FLEXCOMM_I2C_STAT ,SLVIDX ,12 ,2 ); +/* Slave selected flag */ +FIELD (FLEXCOMM_I2C_STAT ,SLVSEL ,14 ,1 ); +/* Slave Deselected flag */ +FIELD (FLEXCOMM_I2C_STAT ,SLVDESEL ,15 ,1 ); +/* Monitor Ready */ +FIELD (FLEXCOMM_I2C_STAT ,MONRDY ,16 ,1 ); +/* Monitor Overflow flag */ +FIELD (FLEXCOMM_I2C_STAT ,MONOV ,17 ,1 ); +/* Monitor Active flag */ +FIELD (FLEXCOMM_I2C_STAT ,MONACTIVE ,18 ,1 ); +/* Monitor Idle flag */ +FIELD (FLEXCOMM_I2C_STAT ,MONIDLE ,19 ,1 ); +/* Event Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_STAT ,EVENTTIMEOUT ,24 ,1 ); +/* SCL Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_STAT ,SCLTIMEOUT ,25 ,1 ); + +/* Interrupt Enable Set Register */ +REG32 (FLEXCOMM_I2C_INTENSET ,2056 ); +/* Master Pending interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MSTPENDINGEN ,0 ,1 ); +/* Master Arbitration Loss interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MSTARBLOSSEN ,4 ,1 ); +/* Master Start/Stop Error interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MSTSTSTPERREN ,6 ,1 ); +/* Slave Pending interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SLVPENDINGEN ,8 ,1 ); +/* Slave Not Stretching interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SLVNOTSTREN ,11 ,1 ); +/* Slave Deselect interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SLVDESELEN ,15 ,1 ); +/* Monitor data Ready interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MONRDYEN ,16 ,1 ); +/* Monitor Overrun interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MONOVEN ,17 ,1 ); +/* Monitor Idle interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MONIDLEEN ,19 ,1 ); +/* Event Time-out interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,EVENTTIMEOUTEN ,24 ,1 ); +/* SCL Time-out interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SCLTIMEOUTEN ,25 ,1 ); + +/* Interrupt Enable Clear Register */ +REG32 (FLEXCOMM_I2C_INTENCLR ,2060 ); +/* Master Pending interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MSTPENDINGCLR ,0 ,1 ); +/* Master Arbitration Loss interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MSTARBLOSSCLR ,4 ,1 ); +/* Master Start/Stop Error interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MSTSTSTPERRCLR ,6 ,1 ); +/* Slave Pending interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SLVPENDINGCLR ,8 ,1 ); +/* Slave Not Stretching interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SLVNOTSTRCLR ,11 ,1 ); +/* Slave Deselect interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SLVDESELCLR ,15 ,1 ); +/* Monitor data Ready interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MONRDYCLR ,16 ,1 ); +/* Monitor Overrun interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MONOVCLR ,17 ,1 ); +/* Monitor Idle interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MONIDLECLR ,19 ,1 ); +/* Event time-out interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,EVENTTIMEOUTCLR ,24 ,1 ); +/* SCL time-out interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SCLTIMEOUTCLR ,25 ,1 ); + +/* Time-out Register */ +REG32 (FLEXCOMM_I2C_TIMEOUT ,2064 ); +/* Time-out time value, the bottom 4 bits */ +FIELD (FLEXCOMM_I2C_TIMEOUT ,TOMIN ,0 ,4 ); +/* Time-out time value */ +FIELD (FLEXCOMM_I2C_TIMEOUT ,TO ,4 ,12 ); + +/* Clock Divider Register */ +REG32 (FLEXCOMM_I2C_CLKDIV ,2068 ); +/* Divider Value */ +FIELD (FLEXCOMM_I2C_CLKDIV ,DIVVAL ,0 ,16 ); + +/* Interrupt Status Register */ +REG32 (FLEXCOMM_I2C_INTSTAT ,2072 ); +/* Master Pending */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MSTPENDING ,0 ,1 ); +/* Master Arbitration Loss flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MSTARBLOSS ,4 ,1 ); +/* Master Start/Stop Error flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MSTSTSTPERR ,6 ,1 ); +/* Slave Pending */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SLVPENDING ,8 ,1 ); +/* Slave Not Stretching status */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SLVNOTSTR ,11 ,1 ); +/* Slave Deselected flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SLVDESEL ,15 ,1 ); +/* Monitor Ready */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MONRDY ,16 ,1 ); +/* Monitor Overflow flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MONOV ,17 ,1 ); +/* Monitor Idle flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MONIDLE ,19 ,1 ); +/* Event Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,EVENTTIMEOUT ,24 ,1 ); +/* SCL Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SCLTIMEOUT ,25 ,1 ); + +/* Master Control Register */ +REG32 (FLEXCOMM_I2C_MSTCTL ,2080 ); +/* Master Continue(write-only) */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTCONTINUE ,0 ,1 ); +/* Master Start control(write-only) */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTSTART ,1 ,1 ); +/* Master Stop control(write-only) */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTSTOP ,2 ,1 ); +/* Master DMA enable */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTDMA ,3 ,1 ); + +/* Master Timing Register */ +REG32 (FLEXCOMM_I2C_MSTTIME ,2084 ); +/* Master SCL Low time */ +FIELD (FLEXCOMM_I2C_MSTTIME ,MSTSCLLOW ,0 ,3 ); +/* Master SCL High time */ +FIELD (FLEXCOMM_I2C_MSTTIME ,MSTSCLHIGH ,4 ,3 ); + +/* Master Data Register */ +REG32 (FLEXCOMM_I2C_MSTDAT ,2088 ); +/* Master function data register */ +FIELD (FLEXCOMM_I2C_MSTDAT ,DATA ,0 ,8 ); + +/* Slave Control Register */ +REG32 (FLEXCOMM_I2C_SLVCTL ,2112 ); +/* Slave Continue */ +FIELD (FLEXCOMM_I2C_SLVCTL ,SLVCONTINUE ,0 ,1 ); +/* Slave NACK */ +FIELD (FLEXCOMM_I2C_SLVCTL ,SLVNACK ,1 ,1 ); +/* Slave DMA enable */ +FIELD (FLEXCOMM_I2C_SLVCTL ,SLVDMA ,3 ,1 ); +/* Automatic Acknowledge */ +FIELD (FLEXCOMM_I2C_SLVCTL ,AUTOACK ,8 ,1 ); +/* Automatic Match Read */ +FIELD (FLEXCOMM_I2C_SLVCTL ,AUTOMATCHREAD ,9 ,1 ); + +/* Slave Data Register */ +REG32 (FLEXCOMM_I2C_SLVDAT ,2116 ); +/* Slave function data register */ +FIELD (FLEXCOMM_I2C_SLVDAT ,DATA ,0 ,8 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR0 ,2120 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR0 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR0 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR0 ,AUTONACK ,15 ,1 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR1 ,2124 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR1 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR1 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR1 ,AUTONACK ,15 ,1 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR2 ,2128 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR2 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR2 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR2 ,AUTONACK ,15 ,1 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR3 ,2132 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR3 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR3 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR3 ,AUTONACK ,15 ,1 ); + +/* Slave Qualification for Address 0 Register */ +REG32 (FLEXCOMM_I2C_SLVQUAL0 ,2136 ); +/* Qualify mode for slave address 0 */ +FIELD (FLEXCOMM_I2C_SLVQUAL0 ,QUALMODE0 ,0 ,1 ); +/* Slave address Qualifier for address 0 */ +FIELD (FLEXCOMM_I2C_SLVQUAL0 ,SLVQUAL0 ,1 ,7 ); + +/* Monitor Receiver Data Register */ +REG32 (FLEXCOMM_I2C_MONRXDAT ,2176 ); +/* Monitor function Receiver Data */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONRXDAT ,0 ,8 ); +/* Monitor Received Start */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONSTART ,8 ,1 ); +/* Monitor Received Repeated Start */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONRESTART ,9 ,1 ); +/* Monitor Received NACK */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONNACK ,10 ,1 ); + +/* Peripheral Identification Register */ include/hw/arm/svd/flexcomm_i2c.h line 255
Quoted 10 lines
include/hw/arm/svd/flexcomm_i2c.h new file +10
-0+REG32 (FLEXCOMM_I2C_ID ,4092 ); +/* Aperture */ +FIELD (FLEXCOMM_I2C_ID ,APERTURE ,0 ,8 ); +/* Minor revision of module implementation */ +FIELD (FLEXCOMM_I2C_ID ,MINOR_REV ,8 ,4 ); +/* Major revision of module implementation */ +FIELD (FLEXCOMM_I2C_ID ,MAJOR_REV ,12 ,4 ); +/* Module identifier for the selected function */ +FIELD (FLEXCOMM_I2C_ID ,ID ,16 ,16 ); +Are any of the below enums even used? Or for that matter, most of the above fields?
Quoted 4 lines
If these are just here for documentation, I would prefer English text; it's more dense and easier to read. It's very difficult to tie all this together into a cohesive view of the device registers.
Since this is autogenerated for the full set of the device registers there will be fields that are not used either because the emulation is incomplete or because they don't have effect for emulation.
I think it is still valuable to have this generated automatically instead of doing it by hand.
Would adding options to only generate certain definitions help? As long as we are reasonable with the granularity (e.g. register level) I think it could trim *most* of the unused generated code without becoming too tedious on how to instruct the tool to generate the code. However, I expect to still have *some* unused generated code.
Quoted 1,344 lines
The .c file itself seems ok.
-corey
Quoted 1,340 lines
include/hw/arm/svd/flexcomm_i2c.h new file +935
-0+ +typedef enum { +/* +* Disabled. The I2C Master function is disabled. When disabled, the Master +* configuration settings are not changed, but the Master function is +* internally reset. +*/ +FLEXCOMM_I2C_CFG_MSTEN_DISABLED =0 , +/* Enabled. The I2C Master function is enabled. */ +FLEXCOMM_I2C_CFG_MSTEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_MSTEN_Enum ; + +typedef enum { +/* +* Disabled. The I2C slave function is disabled. When disabled, the Slave +* configuration settings are not changed, but the Slave function is +* internally reset. +*/ +FLEXCOMM_I2C_CFG_SLVEN_DISABLED =0 , +/* Enabled. The I2C slave function is enabled. */ +FLEXCOMM_I2C_CFG_SLVEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_SLVEN_Enum ; + +typedef enum { +/* +* Disabled. The I2C Monitor function is disabled. When disabled, the +* Monitor function configuration settings are not changed, but the Monitor +* function is internally reset. +*/ +FLEXCOMM_I2C_CFG_MONEN_DISABLED =0 , +/* Enabled. The I2C Monitor function is enabled. */ +FLEXCOMM_I2C_CFG_MONEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_MONEN_Enum ; + +typedef enum { +/* +* Disabled. The time-out function is disabled. When disabled, the time-out +* function is internally reset. +*/ +FLEXCOMM_I2C_CFG_TIMEOUTEN_DISABLED =0 , +/* +* Enabled. The time-out function is enabled. Both types of time-out flags +* will be generated and will cause interrupts if those flags are enabled. +* Typically, only one time-out flag will be used in a system. +*/ +FLEXCOMM_I2C_CFG_TIMEOUTEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_TIMEOUTEN_Enum ; + +typedef enum { +/* +* Disabled. The Monitor function will not perform clock stretching. +* Software or DMA may not always be able to read data provided by the +* Monitor function before it (the data) is overwritten. This mode can be +* used when non-invasive monitoring is critical. +*/ +FLEXCOMM_I2C_CFG_MONCLKSTR_DISABLED =0 , +/* +* Enabled. The Monitor function will perform clock stretching, to ensure +* that the software or DMA can read all incoming data supplied by the +* Monitor function. +*/ +FLEXCOMM_I2C_CFG_MONCLKSTR_ENABLED =1 , +}FLEXCOMM_I2C_CFG_MONCLKSTR_Enum ; + +typedef enum { +/* Fast mode Plus enable */ +FLEXCOMM_I2C_CFG_HSCAPABLE_FAST_MODE_PLUS =0 , +/* High Speed mode enable */ +FLEXCOMM_I2C_CFG_HSCAPABLE_HIGH_SPEED =1 , +}FLEXCOMM_I2C_CFG_HSCAPABLE_Enum ; + +typedef enum { +/* +* In progress. Communication is in progress and the Master function is +* busy and cannot currently accept a command. +*/ +FLEXCOMM_I2C_STAT_MSTPENDING_IN_PROGRESS =0 , +/* +* Pending. The Master function needs software service or is in the idle +* state. If the master is not in the idle state, then the master is +* waiting to receive or transmit data, or is waiting for the NACK bit. +*/ +FLEXCOMM_I2C_STAT_MSTPENDING_PENDING =1 , +}FLEXCOMM_I2C_STAT_MSTPENDING_Enum ; + +typedef enum { +/* +* Idle. The Master function is available to be used for a new transaction. +*/ +FLEXCOMM_I2C_STAT_MSTSTATE_IDLE =0 , +/* +* Receive ready. Received data is available (in Master Receiver mode). +* Address plus Read was previously sent and Acknowledged by a slave. +*/ +FLEXCOMM_I2C_STAT_MSTSTATE_RECEIVE_READY =1 , +/* +* Transmit ready. Data can be transmitted (in Master Transmitter mode). +* Address plus Write was previously sent and Acknowledged by a slave. +*/ +FLEXCOMM_I2C_STAT_MSTSTATE_TRANSMIT_READY =2 , +/* NACK Address. Slave NACKed address. */ +FLEXCOMM_I2C_STAT_MSTSTATE_NACK_ADDRESS =3 , +/* NACK Data. Slave NACKed transmitted data. */ +FLEXCOMM_I2C_STAT_MSTSTATE_NACK_DATA =4 , +}FLEXCOMM_I2C_STAT_MSTSTATE_Enum ; + +typedef enum { +/* No Arbitration Loss has occurred */ +FLEXCOMM_I2C_STAT_MSTARBLOSS_NO_LOSS =0 , +/* +* Arbitration loss. The Master function has experienced an Arbitration +* Loss. At this point, the Master function has already stopped driving the +* bus and has gone into an idle state. Software can respond by doing +* nothing, or by sending a Start (to attempt to gain control of the bus +* when the bus next becomes idle). +*/ +FLEXCOMM_I2C_STAT_MSTARBLOSS_ARBITRATION_LOSS =1 , +}FLEXCOMM_I2C_STAT_MSTARBLOSS_Enum ; + +typedef enum { +/* No Start/Stop Error has occurred. */ +FLEXCOMM_I2C_STAT_MSTSTSTPERR_NO_ERROR =0 , +/* +* The Master function has experienced a Start/Stop Error. A Start or Stop +* was detected at a time when Start or Stop is not allowed by the I2C +* specification. The Master interface has stopped driving the bus and gone +* into an idle state; no action is required. A request for a Start could +* be made, or software could attempt to make sure that the bus has not +* stalled. +*/ +FLEXCOMM_I2C_STAT_MSTSTSTPERR_ERROR =1 , +}FLEXCOMM_I2C_STAT_MSTSTSTPERR_Enum ; + +typedef enum { +/* +* In progress. The Slave function does not currently need software +* service. +*/ +FLEXCOMM_I2C_STAT_SLVPENDING_IN_PROGRESS =0 , +/* +* Pending. The Slave function needs software service. Information about +* what is needed is in the Slave state field (SLVSTATE). +*/ +FLEXCOMM_I2C_STAT_SLVPENDING_PENDING =1 , +}FLEXCOMM_I2C_STAT_SLVPENDING_Enum ; + +typedef enum { +/* +* Slave address. Address plus R/W received. At least one of the 4 slave +* addresses has been matched by hardware. +*/ +FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_ADDRESS =0 , +/* Slave receive. Received data is available (in Slave Receiver mode). */ +FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_RECEIVE =1 , +/* Slave transmit. Data can be transmitted (in Slave Transmitter mode). */ +FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_TRANSMIT =2 , +}FLEXCOMM_I2C_STAT_SLVSTATE_Enum ; + +typedef enum { +/* +* Stretching. The slave function is currently stretching the I2C bus +* clock. Deep-Sleepmode cannot be entered at this time. +*/ +FLEXCOMM_I2C_STAT_SLVNOTSTR_STRETCHING =0 , +/* +* Not stretching. The slave function is not currently stretching the I2C +* bus clock. Deep-sleep mode can be entered at this time. +*/ +FLEXCOMM_I2C_STAT_SLVNOTSTR_NOT_STRETCHING =1 , +}FLEXCOMM_I2C_STAT_SLVNOTSTR_Enum ; + +typedef enum { +/* Address 0. Slave address 0 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS0 =0 , +/* Address 1. Slave address 1 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS1 =1 , +/* Address 2. Slave address 2 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS2 =2 , +/* Address 3. Slave address 3 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS3 =3 , +}FLEXCOMM_I2C_STAT_SLVIDX_Enum ; + +typedef enum { +/* Not selected. The Slave function is not currently selected. */ +FLEXCOMM_I2C_STAT_SLVSEL_NOT_SELECTED =0 , +/* Selected. The Slave function is currently selected. */ +FLEXCOMM_I2C_STAT_SLVSEL_SELECTED =1 , +}FLEXCOMM_I2C_STAT_SLVSEL_Enum ; + +typedef enum { +/* +* Not deselected. The Slave function has not become deselected. This does +* not mean that the Slave is currently selected. That information is in +* the SLVSEL flag. +*/ +FLEXCOMM_I2C_STAT_SLVDESEL_NOT_DESELECTED =0 , +/* +* Deselected. The Slave function has become deselected. This is +* specifically caused by the SLVSEL flag changing from 1 to 0. See SLVSEL +* for details about when that event occurs. +*/ +FLEXCOMM_I2C_STAT_SLVDESEL_DESELECTED =1 , +}FLEXCOMM_I2C_STAT_SLVDESEL_Enum ; + +typedef enum { +/* No data. The Monitor function does not currently have data available. */ +FLEXCOMM_I2C_STAT_MONRDY_NO_DATA =0 , +/* Data waiting. The Monitor function has data waiting to be read. */ +FLEXCOMM_I2C_STAT_MONRDY_DATA_WAITING =1 , +}FLEXCOMM_I2C_STAT_MONRDY_Enum ; + +typedef enum { +/* No overrun. Monitor data has not overrun. */ +FLEXCOMM_I2C_STAT_MONOV_NO_OVERRUN =0 , +/* +* Overrun. A Monitor data overrun has occurred. An overrun can only happen +* when Monitor clock stretching not enabled via the CFG[MONCLKSTR] bit. +* Writing 1 to MONOV bit clears the MONOV flag. +*/ +FLEXCOMM_I2C_STAT_MONOV_OVERRUN =1 , +}FLEXCOMM_I2C_STAT_MONOV_Enum ; + +typedef enum { +/* Inactive. The Monitor function considers the I2C bus to be inactive. */ +FLEXCOMM_I2C_STAT_MONACTIVE_INACTIVE =0 , +/* Active. The Monitor function considers the I2C bus to be active. */ +FLEXCOMM_I2C_STAT_MONACTIVE_ACTIVE =1 , +}FLEXCOMM_I2C_STAT_MONACTIVE_Enum ; + +typedef enum { +/* +* Not idle. The I2C bus is not idle, or MONIDLE flag has been cleared by +* software. +*/ +FLEXCOMM_I2C_STAT_MONIDLE_NOT_IDLE =0 , +/* +* Idle. The I2C bus has gone idle at least once, since the last time +* MONIDLE flag was cleared by software. +*/ +FLEXCOMM_I2C_STAT_MONIDLE_IDLE =1 , +}FLEXCOMM_I2C_STAT_MONIDLE_Enum ; + +typedef enum { +/* No time-out. I2C bus events have not caused a time-out. */ +FLEXCOMM_I2C_STAT_EVENTTIMEOUT_NO_TIMEOUT =0 , +/* +* Event time-out. The time between I2C bus events has been longer than the +* time specified by the TIMEOUT register. +*/ +FLEXCOMM_I2C_STAT_EVENTTIMEOUT_EVEN_TIMEOUT =1 , +}FLEXCOMM_I2C_STAT_EVENTTIMEOUT_Enum ; + +typedef enum { +/* No time-out. SCL low time has not caused a time-out. */ +FLEXCOMM_I2C_STAT_SCLTIMEOUT_NO_TIMEOUT =0 , +/* Time-out. SCL low time has caused a time-out. */ +FLEXCOMM_I2C_STAT_SCLTIMEOUT_TIMEOUT =1 , +}FLEXCOMM_I2C_STAT_SCLTIMEOUT_Enum ; + +typedef enum { +/* Disabled. The MstPending interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_DISABLED =0 , +/* Enabled. The MstPending interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_Enum ; + +typedef enum { +/* Disabled. The MstArbLoss interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_DISABLED =0 , +/* Enabled. The MstArbLoss interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_Enum ; + +typedef enum { +/* Disabled. The MstStStpErr interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_DISABLED =0 , +/* Enabled. The MstStStpErr interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_Enum ; + +typedef enum { +/* Disabled. The SlvPending interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_DISABLED =0 , +/* Enabled. The SlvPending interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_Enum ; + +typedef enum { +/* Disabled. The SlvNotStr interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_DISABLED =0 , +/* Enabled. The SlvNotStr interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_Enum ; + +typedef enum { +/* Disabled. The SlvDeSel interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SLVDESELEN_DISABLED =0 , +/* Enabled. The SlvDeSel interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SLVDESELEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SLVDESELEN_Enum ; + +typedef enum { +/* Disabled. The MonRdy interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MONRDYEN_DISABLED =0 , +/* Enabled. The MonRdy interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MONRDYEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MONRDYEN_Enum ; + +typedef enum { +/* Disabled. The MonOv interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MONOVEN_DISABLED =0 , +/* Enabled. The MonOv interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MONOVEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MONOVEN_Enum ; + +typedef enum { +/* Disabled. The MonIdle interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MONIDLEEN_DISABLED =0 , +/* Enabled. The MonIdle interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MONIDLEEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MONIDLEEN_Enum ; + +typedef enum { +/* Disabled. The Event time-out interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_DISABLED =0 , +/* Enabled. The Event time-out interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_Enum ; + +typedef enum { +/* Disabled. The SCL time-out interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_DISABLED =0 , +/* Enabled. The SCL time-out interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_CLEAR_MSTPENDING =1 , +}FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_CLEAR_MSTARBLOSS =1 , +}FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_CLEAR_MSTSTSTPERR =1 , +}FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_CLEAR_SLVPENDING =1 , +}FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_CLEAR_SLVNOTSTR =1 , +}FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_CLEAR_SLVDESEL =1 , +}FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MONRDYCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MONRDYCLR_CLEAR_MONRDY =1 , +}FLEXCOMM_I2C_INTENCLR_MONRDYCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MONOVCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MONOVCLR_CLEAR_MONOV =1 , +}FLEXCOMM_I2C_INTENCLR_MONOVCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MONIDLECLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MONIDLECLR_CLEAR_MONIDLE =1 , +}FLEXCOMM_I2C_INTENCLR_MONIDLECLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_CLEAR_EVENTTIMEOUT =1 , +}FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_CLEAR_SCLTIMEOUT =1 , +}FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_Enum ; + +typedef enum { +/* A time-out will occur after 16 counts of the I2C function clock. */ +FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT16 =0 , +/* A time-out will occur after 32 counts of the I2C function clock. */ +FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT32 =1 , +/* A time-out will occur after 65,536 counts of the I2C function clock. */ +FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT65K =4095 , +}FLEXCOMM_I2C_TIMEOUT_TO_Enum ; + +typedef enum { +/* FCLK is used directly by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKUNDIVIDED =0 , +/* FCLK is divided by 2 before being used by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV2 =1 , +/* FCLK is divided by 3 before being used by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV3 =2 , +/* FCLK is divided by 65,536 before being used by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV65K =65535 , +}FLEXCOMM_I2C_CLKDIV_DIVVAL_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MSTPENDING_MSTPENDING_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MSTPENDING_MSTPENDING_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MSTPENDING_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_MSTARBLOSS_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_MSTARBLOSS_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_MSTSTSTPERR_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_MSTSTSTPERR_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SLVPENDING_SLVPENDING_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SLVPENDING_SLVPENDING_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SLVPENDING_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_SLVNOTSTR_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_SLVNOTSTR_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SLVDESEL_SLVDESEL_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SLVDESEL_SLVDESEL_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SLVDESEL_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MONRDY_MONRDY_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MONRDY_MONRDY_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MONRDY_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MONOV_MONOV_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MONOV_MONOV_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MONOV_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MONIDLE_MONIDLE_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MONIDLE_MONIDLE_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MONIDLE_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_EVENTTIMEOUT_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_EVENTTIMEOUT_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_SCLTIMEOUT_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_SCLTIMEOUT_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_NO_EFFECT =0 , +/* +* Continue. Informs the Master function to continue to the next operation. +* This action must done after writing transmit data, reading received +* data, or any other housekeeping related to the next bus operation. +*/ +FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_CONTINUE =1 , +}FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_MSTCTL_MSTSTART_NO_EFFECT =0 , +/* +* Start. A Start will be generated on the I2C bus at the next allowed +* time. +*/ +FLEXCOMM_I2C_MSTCTL_MSTSTART_START =1 , +}FLEXCOMM_I2C_MSTCTL_MSTSTART_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_MSTCTL_MSTSTOP_NO_EFFECT =0 , +/* +* Stop. A Stop will be generated on the I2C bus at the next allowed time, +* preceded by a NACK to the slave if the master is receiving data from the +* slave (in Master Receiver mode). +*/ +FLEXCOMM_I2C_MSTCTL_MSTSTOP_STOP =1 , +}FLEXCOMM_I2C_MSTCTL_MSTSTOP_Enum ; + +typedef enum { +/* Disable. No DMA requests are generated for master operation. */ +FLEXCOMM_I2C_MSTCTL_MSTDMA_DISABLED =0 , +/* +* Enable. A DMA request is generated for I2C master data operations. When +* this I2C master is generating Acknowledge bits in Master Receiver mode, +* the acknowledge is generated automatically. +*/ +FLEXCOMM_I2C_MSTCTL_MSTDMA_ENABLED =1 , +}FLEXCOMM_I2C_MSTCTL_MSTDMA_Enum ; + +typedef enum { +/* +* 2 clocks. Minimum SCL low time is 2 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_2CLOCKS =0 , +/* +* 3 clocks. Minimum SCL low time is 3 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_3CLOCKS =1 , +/* +* 4 clocks. Minimum SCL low time is 4 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_4CLOCKS =2 , +/* +* 5 clocks. Minimum SCL low time is 5 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_5CLOCKS =3 , +/* +* 6 clocks. Minimum SCL low time is 6 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_6CLOCKS =4 , +/* +* 7 clocks. Minimum SCL low time is 7 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_7CLOCKS =5 , +/* +* 8 clocks. Minimum SCL low time is 8 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_8CLOCKS =6 , +/* +* 9 clocks. Minimum SCL low time is 9 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_9CLOCKS =7 , +}FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_Enum ; + +typedef enum { +/* +* 2 clocks. Minimum SCL high time is 2 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_2CLOCKS =0 , +/* +* 3 clocks. Minimum SCL high time is 3 clocks of the I2C clock pre-divider +* . +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_3CLOCKS =1 , +/* +* 4 clocks. Minimum SCL high time is 4 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_4CLOCKS =2 , +/* +* 5 clocks. Minimum SCL high time is 5 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_5CLOCKS =3 , +/* +* 6 clocks. Minimum SCL high time is 6 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_6CLOCKS =4 , +/* +* 7 clocks. Minimum SCL high time is 7 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_7CLOCKS =5 , +/* +* 8 clocks. Minimum SCL high time is 8 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_8CLOCKS =6 , +/* +* 9 clocks. Minimum SCL high time is 9 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_9CLOCKS =7 , +}FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_NO_EFFECT =0 , +/* +* Continue. Informs the Slave function to continue to the next operation, +* by clearing the STAT[SLVPENDING] flag. This must be done after writing +* transmit data, reading received data, or any other housekeeping related +* to the next bus operation. Automatic Operation has different +* requirements. SLVCONTINUE should not be set unless SLVPENDING = 1. +*/ +FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_CONTINUE =1 , +}FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_SLVCTL_SLVNACK_NO_EFFECT =0 , +/* +* NACK. Causes the Slave function to NACK the master when the slave is +* receiving data from the master (in Slave Receiver mode). +*/ +FLEXCOMM_I2C_SLVCTL_SLVNACK_NACK =1 , +}FLEXCOMM_I2C_SLVCTL_SLVNACK_Enum ; + +typedef enum { +/* Disabled. No DMA requests are issued for Slave mode operation. */ +FLEXCOMM_I2C_SLVCTL_SLVDMA_DISABLED =0 , +/* +* Enabled. DMA requests are issued for I2C slave data transmission and +* reception. +*/ +FLEXCOMM_I2C_SLVCTL_SLVDMA_ENABLED =1 , +}FLEXCOMM_I2C_SLVCTL_SLVDMA_Enum ; + +typedef enum { +/* +* Normal, non-automatic operation. If AUTONACK = 0, then a SlvPending +* interrupt is generated when a matching address is received. If AUTONACK +* = 1, then received addresses are NACKed (ignored). +*/ +FLEXCOMM_I2C_SLVCTL_AUTOACK_NORMAL =0 , +/* +* A header with matching SLVADR0 and matching direction as set by +* AUTOMATCHREAD will be ACKed immediately, allowing the master to move on +* to the data bytes. If the address matches SLVADR0, but the direction +* does not match AUTOMATCHREAD, then the behavior will depend on the +* SLVADR0[AUTONACK] bit: if AUTONACK is set, then it will be Nacked; if +* AUTONACK is clear, then a SlvPending interrupt is generated. +*/ +FLEXCOMM_I2C_SLVCTL_AUTOACK_AUTOMATIC_ACK =1 , +}FLEXCOMM_I2C_SLVCTL_AUTOACK_Enum ; + +typedef enum { +/* In Automatic Mode, the expected next operation is an I2C write. */ +FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_I2C_WRITE =0 , +/* In Automatic Mode, the expected next operation is an I2C read. */ +FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_I2C_READ =1 , +}FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR0_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR0_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR0_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR0_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR0_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR0_AUTONACK_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR1_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR1_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR1_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR1_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR1_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR1_AUTONACK_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR2_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR2_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR2_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR2_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR2_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR2_AUTONACK_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR3_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR3_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR3_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR3_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR3_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR3_AUTONACK_Enum ; + +typedef enum { +/* +* Mask. The SLVQUAL0 field is used as a logical mask for matching address +* 0. +*/ +FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_MASK =0 , +/* +* Extend. The SLVQUAL0 field is used to extend address 0 matching in a +* range of addresses. +*/ +FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_EXTEND =1 , +}FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_Enum ; + +typedef enum { +/* +* No start detected. The Monitor function has not detected a Start event +* on the I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONSTART_NO_START_DETECTED =0 , +/* +* Start detected. The Monitor function has detected a Start event on the +* I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONSTART_START_DETECTED =1 , +}FLEXCOMM_I2C_MONRXDAT_MONSTART_Enum ; + +typedef enum { +/* +* No repeated start detected. The Monitor function has not detected a +* Repeated Start event on the I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONRESTART_NOT_DETECTED =0 , +/* +* Repeated start detected. The Monitor function has detected a Repeated +* Start event on the I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONRESTART_DETECTED =1 , +}FLEXCOMM_I2C_MONRXDAT_MONRESTART_Enum ; + +typedef enum { +/* +* Acknowledged. The data currently being provided by the Monitor function +* was acknowledged by at least one master or slave receiver. +*/ +FLEXCOMM_I2C_MONRXDAT_MONNACK_ACKNOWLEDGED =0 , +/* +* Not acknowledged. The data currently being provided by the Monitor +* function was not acknowledged by any receiver. +*/ +FLEXCOMM_I2C_MONRXDAT_MONNACK_NOT_ACKNOWLEDGED =1 , +}FLEXCOMM_I2C_MONRXDAT_MONNACK_Enum ; + + +#define FLEXCOMM_I2C_REGISTER_ACCESS_INFO_ARRAY (_name) \ + struct RegisterAccessInfo _name[FLEXCOMM_I2C_REGS_NO] = { \ + [0 ... FLEXCOMM_I2C_REGS_NO - 1] = { \ + .name = "", \ + .addr = -1, \ + }, \ + [R_FLEXCOMM_I2C_CFG] = { \ + .name = "CFG", \ + .addr = 0x800, \ + .ro = 0xFFFFFFC0, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_STAT] = { \ + .name = "STAT", \ + .addr = 0x804, \ + .ro = 0xFCF57FAF, \ + .reset = 0x801, \ + }, \ + [R_FLEXCOMM_I2C_INTENSET] = { \ + .name = "INTENSET", \ + .addr = 0x808, \ + .ro = 0xFCF476AE, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_INTENCLR] = { \ + .name = "INTENCLR", \ + .addr = 0x80C, \ + .ro = 0xFCF476AE, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_TIMEOUT] = { \ + .name = "TIMEOUT", \ + .addr = 0x810, \ + .ro = 0xFFFF0000, \ + .reset = 0xFFFF, \ + }, \ + [R_FLEXCOMM_I2C_CLKDIV] = { \ + .name = "CLKDIV", \ + .addr = 0x814, \ + .ro = 0xFFFF0000, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_INTSTAT] = { \ + .name = "INTSTAT", \ + .addr = 0x818, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x801, \ + }, \ + [R_FLEXCOMM_I2C_MSTCTL] = { \ + .name = "MSTCTL", \ + .addr = 0x820, \ + .ro = 0xFFFFFFF0, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_MSTTIME] = { \ + .name = "MSTTIME", \ + .addr = 0x824, \ + .ro = 0xFFFFFF88, \ + .reset = 0x77, \ + }, \ + [R_FLEXCOMM_I2C_MSTDAT] = { \ + .name = "MSTDAT", \ + .addr = 0x828, \ + .ro = 0xFFFFFF00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVCTL] = { \ + .name = "SLVCTL", \ + .addr = 0x840, \ + .ro = 0xFFFFFCF4, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVDAT] = { \ + .name = "SLVDAT", \ + .addr = 0x844, \ + .ro = 0xFFFFFF00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR0] = { \ + .name = "SLVADR0", \ + .addr = 0x848, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR1] = { \ + .name = "SLVADR1", \ + .addr = 0x84C, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR2] = { \ + .name = "SLVADR2", \ + .addr = 0x850, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR3] = { \ + .name = "SLVADR3", \ + .addr = 0x854, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVQUAL0] = { \ + .name = "SLVQUAL0", \ + .addr = 0x858, \ + .ro = 0xFFFFFF00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_MONRXDAT] = { \ + .name = "MONRXDAT", \ + .addr = 0x880, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_ID] = { \ + .name = "ID", \ + .addr = 0xFFC, \ + .ro = 0xFFFFFFFF, \ + .reset = 0xE0301300, \ + }, \ + }include/hw/i2c/flexcomm_i2c.h new file +40
-0@@ -0,0 +1,40 @@ +/* +* QEMU model for NXP's FLEXCOMM I2C +* +* Copyright (c) 2024 Google LLC +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef HW_FLEXCOMM_I2C_H +#define HW_FLEXCOMM_I2C_H + +#include "hw/i2c/i2c.h" +#include "hw/misc/flexcomm_function.h" + +#define TYPE_FLEXCOMM_I2C "flexcomm-i2c" +OBJECT_DECLARE_TYPE (FlexcommI2cState, FlexcommI2cClass,FLEXCOMM_I2C ); + +struct FlexcommI2cState { +FlexcommFunction parent_obj; + +I2CBus *bus; +}; + +struct FlexcommI2cClass { +FlexcommFunctionClass parent_obj; + +FlexcommFunctionSelect select; +}; + +#define MSTSTATE_IDLE 0 +#define MSTSTATE_RXRDY 1 +#define MSTSTATE_TXRDY 2 +#define MSTSTATE_NAKADR 3 +#define MSTSTATE_NAKDAT 4 + + +#endif /* HW_FLEXCOMM_I2C_H */ include/hw/misc/flexcomm.h +2
-0@@ -16,6 +16,7 @@#include "hw/arm/svd/flexcomm.h" #include "qemu/fifo32.h" #include "hw/char/flexcomm_usart.h" +#include "hw/i2c/flexcomm_i2c.h" #define FLEXCOMM_FUNC_USART 0#define FLEXCOMM_FUNC_SPI 1@@ -48,6 +49,7 @@ struct FlexcommState {Fifo32 rx_fifo;Fifo32 tx_fifo;FlexcommUsartState usart; + FlexcommI2cState i2c; };#endif /* HW_FLEXCOMM_H */ hw/i2c/flexcomm_i2c.c new file +250
-0@@ -0,0 +1,250 @@ +/* +* QEMU model for NXP's FLEXCOMM I2C +* +* Copyright (c) 2024 Google LLC +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "exec/address-spaces.h" +#include "qapi/error.h" +#include "trace.h" +#include "hw/i2c/flexcomm_i2c.h" +#include "hw/arm/svd/flexcomm_i2c.h" + +#define REG (s, reg) (s->regs[R_FLEXCOMM_I2C_##reg]) +#define RF_WR (s, reg, field, val) \ + ARRAY_FIELD_DP32(s->regs, FLEXCOMM_I2C_##reg, field, val) +#define RF_RD (s, reg, field) \ + ARRAY_FIELD_EX32(s->regs, FLEXCOMM_I2C_##reg, field) + +static FLEXCOMM_I2C_REGISTER_ACCESS_INFO_ARRAY (reg_info); + +static void flexcomm_i2c_reset (FlexcommFunction *f) +{ +for (int i =0 ; i <FLEXCOMM_I2C_REGS_NO ; i++) { +hwaddr addr = reg_info[i].addr; + +if (addr !=-1 ) { +struct RegisterInfo ri = { + .data = &f->regs[addr /4 ], + .data_size =4 , + .access = ®_info[i], + }; + +register_reset (&ri); + } + } +} + +static void flexcomm_i2c_irq_update (FlexcommFunction *f) +{ +bool enabled =RF_RD (f,CFG ,MSTEN ); +bool irq, per_irqs; + +REG (f,INTSTAT ) =REG (f,STAT ) ® (f,INTENSET ); + per_irqs =REG (f,INTSTAT ) !=0 ; + + irq = enabled && per_irqs; + +trace_flexcomm_i2c_irq (DEVICE (f)->id, irq, per_irqs, enabled); +flexcomm_set_irq (f, irq); +} + +static MemTxResult flexcomm_i2c_reg_read (void *opaque,hwaddr addr, +uint64_t *data,unsigned size, +MemTxAttrs attrs) +{ +FlexcommFunction *f =FLEXCOMM_FUNCTION (opaque); +MemTxResult ret =MEMTX_OK ; +const struct RegisterAccessInfo *rai = ®_info[addr /4 ]; + +if (size !=4 ) { + ret =MEMTX_ERROR ; + goto out; + } + + *data = f->regs[addr /4 ]; + +flexcomm_i2c_irq_update (f); + +out: +trace_flexcomm_i2c_reg_read (DEVICE (f)->id, rai->name, addr, *data); +return ret; +} + +static MemTxResult flexcomm_i2c_reg_write (void *opaque,hwaddr addr, +uint64_t value,unsigned size, +MemTxAttrs attrs) +{ +FlexcommFunction *f =FLEXCOMM_FUNCTION (opaque); +FlexcommI2cState *s =FLEXCOMM_I2C (opaque); +const struct RegisterAccessInfo *rai = ®_info[addr /4 ]; +struct RegisterInfo ri = { + .data = &f->regs[addr /4 ], + .data_size =4 , + .access = rai, + }; + +trace_flexcomm_i2c_reg_write (DEVICE (f)->id, rai->name, addr, value); + +if (size !=4 ) { +return MEMTX_ERROR ; + } + +switch (addr) { +case A_FLEXCOMM_I2C_CFG : + { +register_write (&ri, value, ~0 ,NULL , false); +if (RF_RD (f,CFG ,SLVEN )) { +qemu_log_mask (LOG_GUEST_ERROR ,"I2C slave not supported" ); + } +if (RF_RD (f,CFG ,MONEN )) { +qemu_log_mask (LOG_GUEST_ERROR ,"I2C monitoring not supported" ); + } +break ; + } +case A_FLEXCOMM_I2C_INTENCLR : + { +REG (f,INTENSET ) &= ~value; +break ; + } +case A_FLEXCOMM_I2C_TIMEOUT : + { +register_write (&ri, value, ~0 ,NULL , false); +/* The bottom 4 bits are hard-wired to 0xF */ +RF_WR (f,TIMEOUT ,TOMIN ,0xf ); +break ; + } +case A_FLEXCOMM_I2C_MSTCTL : + { +register_write (&ri, value, ~0 ,NULL , false); +if (RF_RD (f,MSTCTL ,MSTSTART )) { +uint8_t i2c_addr =RF_RD (f,MSTDAT ,DATA ); +bool recv = i2c_addr &1 ; + +trace_flexcomm_i2c_start (DEVICE (s)->id, i2c_addr, recv); +if (i2c_start_transfer (s->bus, i2c_addr, recv)) { +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_NAKADR ); +trace_flexcomm_i2c_nak (DEVICE (s)->id); + }else { +if (recv) { +uint8_t data =i2c_recv (s->bus); + +RF_WR (f,MSTDAT ,DATA , data); +trace_flexcomm_i2c_rx (DEVICE (s)->id, data); +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_RXRDY ); + }else { +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_TXRDY ); + } + } + } +if (RF_RD (f,MSTCTL ,MSTSTOP )) { +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_IDLE ); +i2c_end_transfer (s->bus); + } +if (RF_RD (f,MSTCTL ,MSTCONTINUE )) { +if (RF_RD (f,STAT ,MSTSTATE ) ==MSTSTATE_TXRDY ) { +uint8_t data =RF_RD (f,MSTDAT ,DATA ); + +trace_flexcomm_i2c_tx (DEVICE (s)->id, data); +if (i2c_send (s->bus, data)) { +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_NAKDAT ); + } + }else if (RF_RD (f,STAT ,MSTSTATE ) ==MSTSTATE_RXRDY ) { +uint8_t data =i2c_recv (s->bus); + +RF_WR (f,MSTDAT ,DATA , data); +trace_flexcomm_i2c_rx (DEVICE (s)->id, data); + } + } +break ; + } +case A_FLEXCOMM_I2C_STAT : + { +/* write 1 to clear bits */ +REG (f,STAT ) &= ~value; +break ; + } +case A_FLEXCOMM_I2C_SLVCTL : +case A_FLEXCOMM_I2C_SLVDAT : +case A_FLEXCOMM_I2C_SLVADR0 : +case A_FLEXCOMM_I2C_SLVADR1 : +case A_FLEXCOMM_I2C_SLVADR2 : +case A_FLEXCOMM_I2C_SLVADR3 : +case A_FLEXCOMM_I2C_SLVQUAL0 : + { +qemu_log_mask (LOG_GUEST_ERROR ,"I2C slave not supported\n" ); +break ; + } +default : +register_write (&ri, value, ~0 ,NULL , false); +break ; + } + +flexcomm_i2c_irq_update (f); + +return MEMTX_OK ; +} + +static void flexcomm_i2c_select (FlexcommFunction *f,bool selected) +{ +FlexcommI2cClass *ic =FLEXCOMM_I2C_GET_CLASS (f); + +if (selected) { +flexcomm_i2c_reset (f); + } + ic->select (f, selected); +} + +static const MemoryRegionOps flexcomm_i2c_ops = { + .read_with_attrs = flexcomm_i2c_reg_read, + .write_with_attrs = flexcomm_i2c_reg_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .valid = { + .min_access_size =4 , + .max_access_size =4 , + .unaligned = false, + }, +}; + +static void flexcomm_i2c_realize (DeviceState *dev,Error **errp) +{ +FlexcommI2cState *s =FLEXCOMM_I2C (dev); + + s->bus =i2c_init_bus (DEVICE (s),"bus" ); +} + +static void flexcomm_i2c_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +FlexcommFunctionClass *fc =FLEXCOMM_FUNCTION_CLASS (klass); +FlexcommI2cClass *ic =FLEXCOMM_I2C_CLASS (klass); + + dc->realize = flexcomm_i2c_realize; + ic->select = fc->select; + fc->select = flexcomm_i2c_select; + fc->name ="i2c" ; + fc->mmio_ops = &flexcomm_i2c_ops; +} + +static const TypeInfo flexcomm_i2c_types[] = { + { + .name =TYPE_FLEXCOMM_I2C , + .parent =TYPE_FLEXCOMM_FUNCTION , + .instance_size =sizeof (FlexcommI2cState), + .class_init = flexcomm_i2c_class_init, + .class_size =sizeof (FlexcommI2cClass), + }, +}; + +DEFINE_TYPES (flexcomm_i2c_types);hw/misc/flexcomm.c +3
-0@@ -24,6 +24,7 @@#include "hw/misc/flexcomm.h" #include "hw/arm/svd/flexcomm_usart.h" #include "hw/char/flexcomm_usart.h" +#include "hw/i2c/flexcomm_i2c.h" #define REG (s, reg) (s->regs[R_FLEXCOMM_##reg])#define RF_WR (s, reg, field, val) \@@ -220,6 +221,7 @@ static void flexcomm_init(Object *obj)sysbus_init_mmio (SYS_BUS_DEVICE (obj), &s->container);sysbus_init_irq (sbd, &s->irq);object_initialize_child (obj,"usart" , &s->usart,TYPE_FLEXCOMM_USART ); +object_initialize_child (obj,"i2c" , &s->i2c,TYPE_FLEXCOMM_I2C ); }static void flexcomm_finalize (Object *obj)@@ -250,6 +252,7 @@ static void flexcomm_realize(DeviceState *dev, Error **errp)memory_region_add_subregion_overlap (&s->container,0 , &s->mmio,-1 );flexcomm_func_realize_and_unref (FLEXCOMM_FUNCTION (&s->usart), errp); +flexcomm_func_realize_and_unref (FLEXCOMM_FUNCTION (&s->i2c), errp); }static const VMStateDescription vmstate_flexcomm = {hw/arm/svd/meson.build +3
-0@@ -7,4 +7,7 @@ if get_option('mcux-soc-svd') run_target('svd-flexcomm-usart', command: svd_gen_header + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_usart.h', '-p', 'USART0', '-t', 'FLEXCOMM_USART']) + run_target('svd-flexcomm-i2c', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_i2c.h', + '-p', 'I2C0', '-t', 'FLEXCOMM_I2C']) endifhw/i2c/meson.build +1
-0@@ -18,4 +18,5 @@ i2c_ss.add(when: 'CONFIG_PPC4XX', if_true: files('ppc4xx_i2c.c')) i2c_ss.add(when: 'CONFIG_PCA954X', if_true: files('i2c_mux_pca954x.c')) i2c_ss.add(when: 'CONFIG_PMBUS', if_true: files('pmbus_device.c')) i2c_ss.add(when: 'CONFIG_BCM2835_I2C', if_true: files('bcm2835_i2c.c')) +i2c_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm_i2c.c')) system_ss.add_all(when: 'CONFIG_I2C', if_true: i2c_ss)hw/i2c/trace-events +10
-0@@ -51,3 +51,13 @@ npcm7xx_smbus_recv_fifo(const char *id, uint8_t received, uint8_t expected) "%s pca954x_write_bytes(uint8_t value) "PCA954X write data: 0x%02x" pca954x_read_data(uint8_t value) "PCA954X read data: 0x%02x" + +# flexcomm_i2c.c + +flexcomm_i2c_reg_read(const char *id, const char *reg_name, uint32_t addr, uint32_t val) " %s: %s[0x%04x] -> 0x%08x" +flexcomm_i2c_reg_write(const char *id, const char *reg_name, uint32_t addr, uint32_t val) "%s: %s[0x%04x] <- 0x%08x" +flexcomm_i2c_start(const char *id, uint8_t addr, uint8_t recv) "%s: 0x%02x %d" +flexcomm_i2c_rx(const char *id, uint8_t data) "%s: <- 0x%02x" +flexcomm_i2c_tx(const char *id, uint8_t data) "%s: -> 0x%02x" +flexcomm_i2c_nak(const char *id) "%s: <- nak" +flexcomm_i2c_irq(const char *id, bool irq, bool perirqs, bool enabled) "%s: %d %d %d"hw/misc/Kconfig +1
-1@@ -215,5 +215,6 @@ config XLNX_VERSAL_TRNG config FLEXCOMM bool + select I2C source macio/Kconfig --2.46.0.662.g92d0881bb0-goog
Re: [PATCH 08/25] hw/i2c: add support for flexcomm i2c
Quoted 302 lines · Octavian Purdila
Quoted 292 lines · On Wed, Sep 18, 2024 at 1:17???PM Corey Minyard <[email protected]> wrote:
Quoted 276 lines · Octavian Purdila
Add support for NXP's flexcomm i2c. It does not support slave mode or DMA.
The patch includes an automatically generated header which contains the register layout and helpers.
The header can be regenerated with the svd-flexcomm-i2c target when the build is configured with --enable-mcux-soc-svd.
Signed-off-by Octavian Purdila <[email protected]>--- include/hw/arm/svd/flexcomm_i2c.h | 1190 +++++++++++++++++++++++++++++ include/hw/i2c/flexcomm_i2c.h | 40 + include/hw/misc/flexcomm.h | 2 + hw/i2c/flexcomm_i2c.c | 250 ++++++ hw/misc/flexcomm.c | 3 + hw/arm/svd/meson.build | 3 + hw/i2c/meson.build | 1 + hw/i2c/trace-events | 10 + hw/misc/Kconfig | 1 + 9 files changed, 1500 insertions(+) create mode 100644 include/hw/arm/svd/flexcomm_i2c.h create mode 100644 include/hw/i2c/flexcomm_i2c.h create mode 100644 hw/i2c/flexcomm_i2c.cinclude/hw/arm/svd/flexcomm_i2c.h new file +245
-0@@ -0,0 +1,1190 @@ +/* +* Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause +* +* Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml +*/ +#pragma once + +#include "hw/register.h" + +/* I2C Bus Interface */ +#define FLEXCOMM_I2C_REGS_NO (1024) + +/* Configuration Register */ +REG32 (FLEXCOMM_I2C_CFG ,2048 ); +/* Master Enable */ +FIELD (FLEXCOMM_I2C_CFG ,MSTEN ,0 ,1 ); +/* Slave Enable */ +FIELD (FLEXCOMM_I2C_CFG ,SLVEN ,1 ,1 ); +/* Monitor Enable */ +FIELD (FLEXCOMM_I2C_CFG ,MONEN ,2 ,1 ); +/* I2C bus Time-out Enable */ +FIELD (FLEXCOMM_I2C_CFG ,TIMEOUTEN ,3 ,1 ); +/* Monitor function Clock Stretching */ +FIELD (FLEXCOMM_I2C_CFG ,MONCLKSTR ,4 ,1 ); +/* High Speed mode Capable enable */ +FIELD (FLEXCOMM_I2C_CFG ,HSCAPABLE ,5 ,1 ); + +/* Status Register */ +REG32 (FLEXCOMM_I2C_STAT ,2052 ); +/* Master Pending */ +FIELD (FLEXCOMM_I2C_STAT ,MSTPENDING ,0 ,1 ); +/* Master State code */ +FIELD (FLEXCOMM_I2C_STAT ,MSTSTATE ,1 ,3 ); +/* Master Arbitration Loss flag */ +FIELD (FLEXCOMM_I2C_STAT ,MSTARBLOSS ,4 ,1 ); +/* Master Start/Stop Error flag */ +FIELD (FLEXCOMM_I2C_STAT ,MSTSTSTPERR ,6 ,1 ); +/* Slave Pending */ +FIELD (FLEXCOMM_I2C_STAT ,SLVPENDING ,8 ,1 ); +/* Slave State */ +FIELD (FLEXCOMM_I2C_STAT ,SLVSTATE ,9 ,2 ); +/* Slave Not Stretching */ +FIELD (FLEXCOMM_I2C_STAT ,SLVNOTSTR ,11 ,1 ); +/* Slave address match Index T */ +FIELD (FLEXCOMM_I2C_STAT ,SLVIDX ,12 ,2 ); +/* Slave selected flag */ +FIELD (FLEXCOMM_I2C_STAT ,SLVSEL ,14 ,1 ); +/* Slave Deselected flag */ +FIELD (FLEXCOMM_I2C_STAT ,SLVDESEL ,15 ,1 ); +/* Monitor Ready */ +FIELD (FLEXCOMM_I2C_STAT ,MONRDY ,16 ,1 ); +/* Monitor Overflow flag */ +FIELD (FLEXCOMM_I2C_STAT ,MONOV ,17 ,1 ); +/* Monitor Active flag */ +FIELD (FLEXCOMM_I2C_STAT ,MONACTIVE ,18 ,1 ); +/* Monitor Idle flag */ +FIELD (FLEXCOMM_I2C_STAT ,MONIDLE ,19 ,1 ); +/* Event Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_STAT ,EVENTTIMEOUT ,24 ,1 ); +/* SCL Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_STAT ,SCLTIMEOUT ,25 ,1 ); + +/* Interrupt Enable Set Register */ +REG32 (FLEXCOMM_I2C_INTENSET ,2056 ); +/* Master Pending interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MSTPENDINGEN ,0 ,1 ); +/* Master Arbitration Loss interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MSTARBLOSSEN ,4 ,1 ); +/* Master Start/Stop Error interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MSTSTSTPERREN ,6 ,1 ); +/* Slave Pending interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SLVPENDINGEN ,8 ,1 ); +/* Slave Not Stretching interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SLVNOTSTREN ,11 ,1 ); +/* Slave Deselect interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SLVDESELEN ,15 ,1 ); +/* Monitor data Ready interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MONRDYEN ,16 ,1 ); +/* Monitor Overrun interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MONOVEN ,17 ,1 ); +/* Monitor Idle interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MONIDLEEN ,19 ,1 ); +/* Event Time-out interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,EVENTTIMEOUTEN ,24 ,1 ); +/* SCL Time-out interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SCLTIMEOUTEN ,25 ,1 ); + +/* Interrupt Enable Clear Register */ +REG32 (FLEXCOMM_I2C_INTENCLR ,2060 ); +/* Master Pending interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MSTPENDINGCLR ,0 ,1 ); +/* Master Arbitration Loss interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MSTARBLOSSCLR ,4 ,1 ); +/* Master Start/Stop Error interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MSTSTSTPERRCLR ,6 ,1 ); +/* Slave Pending interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SLVPENDINGCLR ,8 ,1 ); +/* Slave Not Stretching interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SLVNOTSTRCLR ,11 ,1 ); +/* Slave Deselect interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SLVDESELCLR ,15 ,1 ); +/* Monitor data Ready interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MONRDYCLR ,16 ,1 ); +/* Monitor Overrun interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MONOVCLR ,17 ,1 ); +/* Monitor Idle interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MONIDLECLR ,19 ,1 ); +/* Event time-out interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,EVENTTIMEOUTCLR ,24 ,1 ); +/* SCL time-out interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SCLTIMEOUTCLR ,25 ,1 ); + +/* Time-out Register */ +REG32 (FLEXCOMM_I2C_TIMEOUT ,2064 ); +/* Time-out time value, the bottom 4 bits */ +FIELD (FLEXCOMM_I2C_TIMEOUT ,TOMIN ,0 ,4 ); +/* Time-out time value */ +FIELD (FLEXCOMM_I2C_TIMEOUT ,TO ,4 ,12 ); + +/* Clock Divider Register */ +REG32 (FLEXCOMM_I2C_CLKDIV ,2068 ); +/* Divider Value */ +FIELD (FLEXCOMM_I2C_CLKDIV ,DIVVAL ,0 ,16 ); + +/* Interrupt Status Register */ +REG32 (FLEXCOMM_I2C_INTSTAT ,2072 ); +/* Master Pending */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MSTPENDING ,0 ,1 ); +/* Master Arbitration Loss flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MSTARBLOSS ,4 ,1 ); +/* Master Start/Stop Error flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MSTSTSTPERR ,6 ,1 ); +/* Slave Pending */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SLVPENDING ,8 ,1 ); +/* Slave Not Stretching status */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SLVNOTSTR ,11 ,1 ); +/* Slave Deselected flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SLVDESEL ,15 ,1 ); +/* Monitor Ready */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MONRDY ,16 ,1 ); +/* Monitor Overflow flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MONOV ,17 ,1 ); +/* Monitor Idle flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MONIDLE ,19 ,1 ); +/* Event Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,EVENTTIMEOUT ,24 ,1 ); +/* SCL Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SCLTIMEOUT ,25 ,1 ); + +/* Master Control Register */ +REG32 (FLEXCOMM_I2C_MSTCTL ,2080 ); +/* Master Continue(write-only) */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTCONTINUE ,0 ,1 ); +/* Master Start control(write-only) */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTSTART ,1 ,1 ); +/* Master Stop control(write-only) */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTSTOP ,2 ,1 ); +/* Master DMA enable */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTDMA ,3 ,1 ); + +/* Master Timing Register */ +REG32 (FLEXCOMM_I2C_MSTTIME ,2084 ); +/* Master SCL Low time */ +FIELD (FLEXCOMM_I2C_MSTTIME ,MSTSCLLOW ,0 ,3 ); +/* Master SCL High time */ +FIELD (FLEXCOMM_I2C_MSTTIME ,MSTSCLHIGH ,4 ,3 ); + +/* Master Data Register */ +REG32 (FLEXCOMM_I2C_MSTDAT ,2088 ); +/* Master function data register */ +FIELD (FLEXCOMM_I2C_MSTDAT ,DATA ,0 ,8 ); + +/* Slave Control Register */ +REG32 (FLEXCOMM_I2C_SLVCTL ,2112 ); +/* Slave Continue */ +FIELD (FLEXCOMM_I2C_SLVCTL ,SLVCONTINUE ,0 ,1 ); +/* Slave NACK */ +FIELD (FLEXCOMM_I2C_SLVCTL ,SLVNACK ,1 ,1 ); +/* Slave DMA enable */ +FIELD (FLEXCOMM_I2C_SLVCTL ,SLVDMA ,3 ,1 ); +/* Automatic Acknowledge */ +FIELD (FLEXCOMM_I2C_SLVCTL ,AUTOACK ,8 ,1 ); +/* Automatic Match Read */ +FIELD (FLEXCOMM_I2C_SLVCTL ,AUTOMATCHREAD ,9 ,1 ); + +/* Slave Data Register */ +REG32 (FLEXCOMM_I2C_SLVDAT ,2116 ); +/* Slave function data register */ +FIELD (FLEXCOMM_I2C_SLVDAT ,DATA ,0 ,8 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR0 ,2120 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR0 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR0 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR0 ,AUTONACK ,15 ,1 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR1 ,2124 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR1 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR1 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR1 ,AUTONACK ,15 ,1 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR2 ,2128 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR2 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR2 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR2 ,AUTONACK ,15 ,1 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR3 ,2132 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR3 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR3 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR3 ,AUTONACK ,15 ,1 ); + +/* Slave Qualification for Address 0 Register */ +REG32 (FLEXCOMM_I2C_SLVQUAL0 ,2136 ); +/* Qualify mode for slave address 0 */ +FIELD (FLEXCOMM_I2C_SLVQUAL0 ,QUALMODE0 ,0 ,1 ); +/* Slave address Qualifier for address 0 */ +FIELD (FLEXCOMM_I2C_SLVQUAL0 ,SLVQUAL0 ,1 ,7 ); + +/* Monitor Receiver Data Register */ +REG32 (FLEXCOMM_I2C_MONRXDAT ,2176 ); +/* Monitor function Receiver Data */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONRXDAT ,0 ,8 ); +/* Monitor Received Start */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONSTART ,8 ,1 ); +/* Monitor Received Repeated Start */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONRESTART ,9 ,1 ); +/* Monitor Received NACK */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONNACK ,10 ,1 ); + +/* Peripheral Identification Register */ include/hw/arm/svd/flexcomm_i2c.h line 255
Quoted 10 lines
include/hw/arm/svd/flexcomm_i2c.h new file +10
-0+REG32 (FLEXCOMM_I2C_ID ,4092 ); +/* Aperture */ +FIELD (FLEXCOMM_I2C_ID ,APERTURE ,0 ,8 ); +/* Minor revision of module implementation */ +FIELD (FLEXCOMM_I2C_ID ,MINOR_REV ,8 ,4 ); +/* Major revision of module implementation */ +FIELD (FLEXCOMM_I2C_ID ,MAJOR_REV ,12 ,4 ); +/* Module identifier for the selected function */ +FIELD (FLEXCOMM_I2C_ID ,ID ,16 ,16 ); +Are any of the below enums even used? Or for that matter, most of the above fields?
Quoted 4 lines
If these are just here for documentation, I would prefer English text; it's more dense and easier to read. It's very difficult to tie all this together into a cohesive view of the device registers.
Since this is autogenerated for the full set of the device registers there will be fields that are not used either because the emulation is incomplete or because they don't have effect for emulation.
Quoted 8 lines
I think it is still valuable to have this generated automatically instead of doing it by hand.
Would adding options to only generate certain definitions help? As long as we are reasonable with the granularity (e.g. register level) I think it could trim *most* of the unused generated code without becoming too tedious on how to instruct the tool to generate the code. However, I expect to still have *some* unused generated code.
Generally it's frowned upon to have a ton of extra stuff that's not used. I would think some is ok, like defining bits in registers that aren't used yet, but I have no idea how all the enums below here actually tie into anything. I'm guessing these are just bitmasks into registers, but really, it's a lot easier to read if you have something like:
/*
* The I2C Master function enable. When disabled, the Master
* configuration settings are not changed, but the Master function is
* internally reset.
*/
#define FLEXCOMM_I2C_CFG_MSTEN (1 << 4)
and them have them grouped together with the register they belong to. I don't know how you would even use these enums. AFAICT, none of them are used.
And the whole idea of this is to make the code more readable. So if you define these things, you should use them. Look around through the code of other devices to get a feel of how things are done.
-corey
Quoted 1,346 lines
Quoted 1,346 lines
The .c file itself seems ok.
-corey
Quoted 1,340 lines
include/hw/arm/svd/flexcomm_i2c.h new file +935
-0+ +typedef enum { +/* +* Disabled. The I2C Master function is disabled. When disabled, the Master +* configuration settings are not changed, but the Master function is +* internally reset. +*/ +FLEXCOMM_I2C_CFG_MSTEN_DISABLED =0 , +/* Enabled. The I2C Master function is enabled. */ +FLEXCOMM_I2C_CFG_MSTEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_MSTEN_Enum ; + +typedef enum { +/* +* Disabled. The I2C slave function is disabled. When disabled, the Slave +* configuration settings are not changed, but the Slave function is +* internally reset. +*/ +FLEXCOMM_I2C_CFG_SLVEN_DISABLED =0 , +/* Enabled. The I2C slave function is enabled. */ +FLEXCOMM_I2C_CFG_SLVEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_SLVEN_Enum ; + +typedef enum { +/* +* Disabled. The I2C Monitor function is disabled. When disabled, the +* Monitor function configuration settings are not changed, but the Monitor +* function is internally reset. +*/ +FLEXCOMM_I2C_CFG_MONEN_DISABLED =0 , +/* Enabled. The I2C Monitor function is enabled. */ +FLEXCOMM_I2C_CFG_MONEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_MONEN_Enum ; + +typedef enum { +/* +* Disabled. The time-out function is disabled. When disabled, the time-out +* function is internally reset. +*/ +FLEXCOMM_I2C_CFG_TIMEOUTEN_DISABLED =0 , +/* +* Enabled. The time-out function is enabled. Both types of time-out flags +* will be generated and will cause interrupts if those flags are enabled. +* Typically, only one time-out flag will be used in a system. +*/ +FLEXCOMM_I2C_CFG_TIMEOUTEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_TIMEOUTEN_Enum ; + +typedef enum { +/* +* Disabled. The Monitor function will not perform clock stretching. +* Software or DMA may not always be able to read data provided by the +* Monitor function before it (the data) is overwritten. This mode can be +* used when non-invasive monitoring is critical. +*/ +FLEXCOMM_I2C_CFG_MONCLKSTR_DISABLED =0 , +/* +* Enabled. The Monitor function will perform clock stretching, to ensure +* that the software or DMA can read all incoming data supplied by the +* Monitor function. +*/ +FLEXCOMM_I2C_CFG_MONCLKSTR_ENABLED =1 , +}FLEXCOMM_I2C_CFG_MONCLKSTR_Enum ; + +typedef enum { +/* Fast mode Plus enable */ +FLEXCOMM_I2C_CFG_HSCAPABLE_FAST_MODE_PLUS =0 , +/* High Speed mode enable */ +FLEXCOMM_I2C_CFG_HSCAPABLE_HIGH_SPEED =1 , +}FLEXCOMM_I2C_CFG_HSCAPABLE_Enum ; + +typedef enum { +/* +* In progress. Communication is in progress and the Master function is +* busy and cannot currently accept a command. +*/ +FLEXCOMM_I2C_STAT_MSTPENDING_IN_PROGRESS =0 , +/* +* Pending. The Master function needs software service or is in the idle +* state. If the master is not in the idle state, then the master is +* waiting to receive or transmit data, or is waiting for the NACK bit. +*/ +FLEXCOMM_I2C_STAT_MSTPENDING_PENDING =1 , +}FLEXCOMM_I2C_STAT_MSTPENDING_Enum ; + +typedef enum { +/* +* Idle. The Master function is available to be used for a new transaction. +*/ +FLEXCOMM_I2C_STAT_MSTSTATE_IDLE =0 , +/* +* Receive ready. Received data is available (in Master Receiver mode). +* Address plus Read was previously sent and Acknowledged by a slave. +*/ +FLEXCOMM_I2C_STAT_MSTSTATE_RECEIVE_READY =1 , +/* +* Transmit ready. Data can be transmitted (in Master Transmitter mode). +* Address plus Write was previously sent and Acknowledged by a slave. +*/ +FLEXCOMM_I2C_STAT_MSTSTATE_TRANSMIT_READY =2 , +/* NACK Address. Slave NACKed address. */ +FLEXCOMM_I2C_STAT_MSTSTATE_NACK_ADDRESS =3 , +/* NACK Data. Slave NACKed transmitted data. */ +FLEXCOMM_I2C_STAT_MSTSTATE_NACK_DATA =4 , +}FLEXCOMM_I2C_STAT_MSTSTATE_Enum ; + +typedef enum { +/* No Arbitration Loss has occurred */ +FLEXCOMM_I2C_STAT_MSTARBLOSS_NO_LOSS =0 , +/* +* Arbitration loss. The Master function has experienced an Arbitration +* Loss. At this point, the Master function has already stopped driving the +* bus and has gone into an idle state. Software can respond by doing +* nothing, or by sending a Start (to attempt to gain control of the bus +* when the bus next becomes idle). +*/ +FLEXCOMM_I2C_STAT_MSTARBLOSS_ARBITRATION_LOSS =1 , +}FLEXCOMM_I2C_STAT_MSTARBLOSS_Enum ; + +typedef enum { +/* No Start/Stop Error has occurred. */ +FLEXCOMM_I2C_STAT_MSTSTSTPERR_NO_ERROR =0 , +/* +* The Master function has experienced a Start/Stop Error. A Start or Stop +* was detected at a time when Start or Stop is not allowed by the I2C +* specification. The Master interface has stopped driving the bus and gone +* into an idle state; no action is required. A request for a Start could +* be made, or software could attempt to make sure that the bus has not +* stalled. +*/ +FLEXCOMM_I2C_STAT_MSTSTSTPERR_ERROR =1 , +}FLEXCOMM_I2C_STAT_MSTSTSTPERR_Enum ; + +typedef enum { +/* +* In progress. The Slave function does not currently need software +* service. +*/ +FLEXCOMM_I2C_STAT_SLVPENDING_IN_PROGRESS =0 , +/* +* Pending. The Slave function needs software service. Information about +* what is needed is in the Slave state field (SLVSTATE). +*/ +FLEXCOMM_I2C_STAT_SLVPENDING_PENDING =1 , +}FLEXCOMM_I2C_STAT_SLVPENDING_Enum ; + +typedef enum { +/* +* Slave address. Address plus R/W received. At least one of the 4 slave +* addresses has been matched by hardware. +*/ +FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_ADDRESS =0 , +/* Slave receive. Received data is available (in Slave Receiver mode). */ +FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_RECEIVE =1 , +/* Slave transmit. Data can be transmitted (in Slave Transmitter mode). */ +FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_TRANSMIT =2 , +}FLEXCOMM_I2C_STAT_SLVSTATE_Enum ; + +typedef enum { +/* +* Stretching. The slave function is currently stretching the I2C bus +* clock. Deep-Sleepmode cannot be entered at this time. +*/ +FLEXCOMM_I2C_STAT_SLVNOTSTR_STRETCHING =0 , +/* +* Not stretching. The slave function is not currently stretching the I2C +* bus clock. Deep-sleep mode can be entered at this time. +*/ +FLEXCOMM_I2C_STAT_SLVNOTSTR_NOT_STRETCHING =1 , +}FLEXCOMM_I2C_STAT_SLVNOTSTR_Enum ; + +typedef enum { +/* Address 0. Slave address 0 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS0 =0 , +/* Address 1. Slave address 1 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS1 =1 , +/* Address 2. Slave address 2 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS2 =2 , +/* Address 3. Slave address 3 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS3 =3 , +}FLEXCOMM_I2C_STAT_SLVIDX_Enum ; + +typedef enum { +/* Not selected. The Slave function is not currently selected. */ +FLEXCOMM_I2C_STAT_SLVSEL_NOT_SELECTED =0 , +/* Selected. The Slave function is currently selected. */ +FLEXCOMM_I2C_STAT_SLVSEL_SELECTED =1 , +}FLEXCOMM_I2C_STAT_SLVSEL_Enum ; + +typedef enum { +/* +* Not deselected. The Slave function has not become deselected. This does +* not mean that the Slave is currently selected. That information is in +* the SLVSEL flag. +*/ +FLEXCOMM_I2C_STAT_SLVDESEL_NOT_DESELECTED =0 , +/* +* Deselected. The Slave function has become deselected. This is +* specifically caused by the SLVSEL flag changing from 1 to 0. See SLVSEL +* for details about when that event occurs. +*/ +FLEXCOMM_I2C_STAT_SLVDESEL_DESELECTED =1 , +}FLEXCOMM_I2C_STAT_SLVDESEL_Enum ; + +typedef enum { +/* No data. The Monitor function does not currently have data available. */ +FLEXCOMM_I2C_STAT_MONRDY_NO_DATA =0 , +/* Data waiting. The Monitor function has data waiting to be read. */ +FLEXCOMM_I2C_STAT_MONRDY_DATA_WAITING =1 , +}FLEXCOMM_I2C_STAT_MONRDY_Enum ; + +typedef enum { +/* No overrun. Monitor data has not overrun. */ +FLEXCOMM_I2C_STAT_MONOV_NO_OVERRUN =0 , +/* +* Overrun. A Monitor data overrun has occurred. An overrun can only happen +* when Monitor clock stretching not enabled via the CFG[MONCLKSTR] bit. +* Writing 1 to MONOV bit clears the MONOV flag. +*/ +FLEXCOMM_I2C_STAT_MONOV_OVERRUN =1 , +}FLEXCOMM_I2C_STAT_MONOV_Enum ; + +typedef enum { +/* Inactive. The Monitor function considers the I2C bus to be inactive. */ +FLEXCOMM_I2C_STAT_MONACTIVE_INACTIVE =0 , +/* Active. The Monitor function considers the I2C bus to be active. */ +FLEXCOMM_I2C_STAT_MONACTIVE_ACTIVE =1 , +}FLEXCOMM_I2C_STAT_MONACTIVE_Enum ; + +typedef enum { +/* +* Not idle. The I2C bus is not idle, or MONIDLE flag has been cleared by +* software. +*/ +FLEXCOMM_I2C_STAT_MONIDLE_NOT_IDLE =0 , +/* +* Idle. The I2C bus has gone idle at least once, since the last time +* MONIDLE flag was cleared by software. +*/ +FLEXCOMM_I2C_STAT_MONIDLE_IDLE =1 , +}FLEXCOMM_I2C_STAT_MONIDLE_Enum ; + +typedef enum { +/* No time-out. I2C bus events have not caused a time-out. */ +FLEXCOMM_I2C_STAT_EVENTTIMEOUT_NO_TIMEOUT =0 , +/* +* Event time-out. The time between I2C bus events has been longer than the +* time specified by the TIMEOUT register. +*/ +FLEXCOMM_I2C_STAT_EVENTTIMEOUT_EVEN_TIMEOUT =1 , +}FLEXCOMM_I2C_STAT_EVENTTIMEOUT_Enum ; + +typedef enum { +/* No time-out. SCL low time has not caused a time-out. */ +FLEXCOMM_I2C_STAT_SCLTIMEOUT_NO_TIMEOUT =0 , +/* Time-out. SCL low time has caused a time-out. */ +FLEXCOMM_I2C_STAT_SCLTIMEOUT_TIMEOUT =1 , +}FLEXCOMM_I2C_STAT_SCLTIMEOUT_Enum ; + +typedef enum { +/* Disabled. The MstPending interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_DISABLED =0 , +/* Enabled. The MstPending interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_Enum ; + +typedef enum { +/* Disabled. The MstArbLoss interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_DISABLED =0 , +/* Enabled. The MstArbLoss interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_Enum ; + +typedef enum { +/* Disabled. The MstStStpErr interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_DISABLED =0 , +/* Enabled. The MstStStpErr interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_Enum ; + +typedef enum { +/* Disabled. The SlvPending interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_DISABLED =0 , +/* Enabled. The SlvPending interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_Enum ; + +typedef enum { +/* Disabled. The SlvNotStr interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_DISABLED =0 , +/* Enabled. The SlvNotStr interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_Enum ; + +typedef enum { +/* Disabled. The SlvDeSel interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SLVDESELEN_DISABLED =0 , +/* Enabled. The SlvDeSel interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SLVDESELEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SLVDESELEN_Enum ; + +typedef enum { +/* Disabled. The MonRdy interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MONRDYEN_DISABLED =0 , +/* Enabled. The MonRdy interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MONRDYEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MONRDYEN_Enum ; + +typedef enum { +/* Disabled. The MonOv interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MONOVEN_DISABLED =0 , +/* Enabled. The MonOv interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MONOVEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MONOVEN_Enum ; + +typedef enum { +/* Disabled. The MonIdle interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MONIDLEEN_DISABLED =0 , +/* Enabled. The MonIdle interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MONIDLEEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MONIDLEEN_Enum ; + +typedef enum { +/* Disabled. The Event time-out interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_DISABLED =0 , +/* Enabled. The Event time-out interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_Enum ; + +typedef enum { +/* Disabled. The SCL time-out interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_DISABLED =0 , +/* Enabled. The SCL time-out interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_CLEAR_MSTPENDING =1 , +}FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_CLEAR_MSTARBLOSS =1 , +}FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_CLEAR_MSTSTSTPERR =1 , +}FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_CLEAR_SLVPENDING =1 , +}FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_CLEAR_SLVNOTSTR =1 , +}FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_CLEAR_SLVDESEL =1 , +}FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MONRDYCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MONRDYCLR_CLEAR_MONRDY =1 , +}FLEXCOMM_I2C_INTENCLR_MONRDYCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MONOVCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MONOVCLR_CLEAR_MONOV =1 , +}FLEXCOMM_I2C_INTENCLR_MONOVCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MONIDLECLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MONIDLECLR_CLEAR_MONIDLE =1 , +}FLEXCOMM_I2C_INTENCLR_MONIDLECLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_CLEAR_EVENTTIMEOUT =1 , +}FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_CLEAR_SCLTIMEOUT =1 , +}FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_Enum ; + +typedef enum { +/* A time-out will occur after 16 counts of the I2C function clock. */ +FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT16 =0 , +/* A time-out will occur after 32 counts of the I2C function clock. */ +FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT32 =1 , +/* A time-out will occur after 65,536 counts of the I2C function clock. */ +FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT65K =4095 , +}FLEXCOMM_I2C_TIMEOUT_TO_Enum ; + +typedef enum { +/* FCLK is used directly by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKUNDIVIDED =0 , +/* FCLK is divided by 2 before being used by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV2 =1 , +/* FCLK is divided by 3 before being used by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV3 =2 , +/* FCLK is divided by 65,536 before being used by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV65K =65535 , +}FLEXCOMM_I2C_CLKDIV_DIVVAL_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MSTPENDING_MSTPENDING_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MSTPENDING_MSTPENDING_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MSTPENDING_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_MSTARBLOSS_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_MSTARBLOSS_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_MSTSTSTPERR_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_MSTSTSTPERR_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SLVPENDING_SLVPENDING_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SLVPENDING_SLVPENDING_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SLVPENDING_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_SLVNOTSTR_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_SLVNOTSTR_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SLVDESEL_SLVDESEL_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SLVDESEL_SLVDESEL_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SLVDESEL_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MONRDY_MONRDY_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MONRDY_MONRDY_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MONRDY_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MONOV_MONOV_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MONOV_MONOV_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MONOV_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MONIDLE_MONIDLE_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MONIDLE_MONIDLE_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MONIDLE_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_EVENTTIMEOUT_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_EVENTTIMEOUT_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_SCLTIMEOUT_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_SCLTIMEOUT_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_NO_EFFECT =0 , +/* +* Continue. Informs the Master function to continue to the next operation. +* This action must done after writing transmit data, reading received +* data, or any other housekeeping related to the next bus operation. +*/ +FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_CONTINUE =1 , +}FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_MSTCTL_MSTSTART_NO_EFFECT =0 , +/* +* Start. A Start will be generated on the I2C bus at the next allowed +* time. +*/ +FLEXCOMM_I2C_MSTCTL_MSTSTART_START =1 , +}FLEXCOMM_I2C_MSTCTL_MSTSTART_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_MSTCTL_MSTSTOP_NO_EFFECT =0 , +/* +* Stop. A Stop will be generated on the I2C bus at the next allowed time, +* preceded by a NACK to the slave if the master is receiving data from the +* slave (in Master Receiver mode). +*/ +FLEXCOMM_I2C_MSTCTL_MSTSTOP_STOP =1 , +}FLEXCOMM_I2C_MSTCTL_MSTSTOP_Enum ; + +typedef enum { +/* Disable. No DMA requests are generated for master operation. */ +FLEXCOMM_I2C_MSTCTL_MSTDMA_DISABLED =0 , +/* +* Enable. A DMA request is generated for I2C master data operations. When +* this I2C master is generating Acknowledge bits in Master Receiver mode, +* the acknowledge is generated automatically. +*/ +FLEXCOMM_I2C_MSTCTL_MSTDMA_ENABLED =1 , +}FLEXCOMM_I2C_MSTCTL_MSTDMA_Enum ; + +typedef enum { +/* +* 2 clocks. Minimum SCL low time is 2 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_2CLOCKS =0 , +/* +* 3 clocks. Minimum SCL low time is 3 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_3CLOCKS =1 , +/* +* 4 clocks. Minimum SCL low time is 4 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_4CLOCKS =2 , +/* +* 5 clocks. Minimum SCL low time is 5 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_5CLOCKS =3 , +/* +* 6 clocks. Minimum SCL low time is 6 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_6CLOCKS =4 , +/* +* 7 clocks. Minimum SCL low time is 7 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_7CLOCKS =5 , +/* +* 8 clocks. Minimum SCL low time is 8 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_8CLOCKS =6 , +/* +* 9 clocks. Minimum SCL low time is 9 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_9CLOCKS =7 , +}FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_Enum ; + +typedef enum { +/* +* 2 clocks. Minimum SCL high time is 2 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_2CLOCKS =0 , +/* +* 3 clocks. Minimum SCL high time is 3 clocks of the I2C clock pre-divider +* . +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_3CLOCKS =1 , +/* +* 4 clocks. Minimum SCL high time is 4 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_4CLOCKS =2 , +/* +* 5 clocks. Minimum SCL high time is 5 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_5CLOCKS =3 , +/* +* 6 clocks. Minimum SCL high time is 6 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_6CLOCKS =4 , +/* +* 7 clocks. Minimum SCL high time is 7 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_7CLOCKS =5 , +/* +* 8 clocks. Minimum SCL high time is 8 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_8CLOCKS =6 , +/* +* 9 clocks. Minimum SCL high time is 9 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_9CLOCKS =7 , +}FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_NO_EFFECT =0 , +/* +* Continue. Informs the Slave function to continue to the next operation, +* by clearing the STAT[SLVPENDING] flag. This must be done after writing +* transmit data, reading received data, or any other housekeeping related +* to the next bus operation. Automatic Operation has different +* requirements. SLVCONTINUE should not be set unless SLVPENDING = 1. +*/ +FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_CONTINUE =1 , +}FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_SLVCTL_SLVNACK_NO_EFFECT =0 , +/* +* NACK. Causes the Slave function to NACK the master when the slave is +* receiving data from the master (in Slave Receiver mode). +*/ +FLEXCOMM_I2C_SLVCTL_SLVNACK_NACK =1 , +}FLEXCOMM_I2C_SLVCTL_SLVNACK_Enum ; + +typedef enum { +/* Disabled. No DMA requests are issued for Slave mode operation. */ +FLEXCOMM_I2C_SLVCTL_SLVDMA_DISABLED =0 , +/* +* Enabled. DMA requests are issued for I2C slave data transmission and +* reception. +*/ +FLEXCOMM_I2C_SLVCTL_SLVDMA_ENABLED =1 , +}FLEXCOMM_I2C_SLVCTL_SLVDMA_Enum ; + +typedef enum { +/* +* Normal, non-automatic operation. If AUTONACK = 0, then a SlvPending +* interrupt is generated when a matching address is received. If AUTONACK +* = 1, then received addresses are NACKed (ignored). +*/ +FLEXCOMM_I2C_SLVCTL_AUTOACK_NORMAL =0 , +/* +* A header with matching SLVADR0 and matching direction as set by +* AUTOMATCHREAD will be ACKed immediately, allowing the master to move on +* to the data bytes. If the address matches SLVADR0, but the direction +* does not match AUTOMATCHREAD, then the behavior will depend on the +* SLVADR0[AUTONACK] bit: if AUTONACK is set, then it will be Nacked; if +* AUTONACK is clear, then a SlvPending interrupt is generated. +*/ +FLEXCOMM_I2C_SLVCTL_AUTOACK_AUTOMATIC_ACK =1 , +}FLEXCOMM_I2C_SLVCTL_AUTOACK_Enum ; + +typedef enum { +/* In Automatic Mode, the expected next operation is an I2C write. */ +FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_I2C_WRITE =0 , +/* In Automatic Mode, the expected next operation is an I2C read. */ +FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_I2C_READ =1 , +}FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR0_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR0_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR0_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR0_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR0_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR0_AUTONACK_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR1_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR1_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR1_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR1_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR1_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR1_AUTONACK_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR2_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR2_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR2_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR2_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR2_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR2_AUTONACK_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR3_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR3_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR3_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR3_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR3_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR3_AUTONACK_Enum ; + +typedef enum { +/* +* Mask. The SLVQUAL0 field is used as a logical mask for matching address +* 0. +*/ +FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_MASK =0 , +/* +* Extend. The SLVQUAL0 field is used to extend address 0 matching in a +* range of addresses. +*/ +FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_EXTEND =1 , +}FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_Enum ; + +typedef enum { +/* +* No start detected. The Monitor function has not detected a Start event +* on the I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONSTART_NO_START_DETECTED =0 , +/* +* Start detected. The Monitor function has detected a Start event on the +* I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONSTART_START_DETECTED =1 , +}FLEXCOMM_I2C_MONRXDAT_MONSTART_Enum ; + +typedef enum { +/* +* No repeated start detected. The Monitor function has not detected a +* Repeated Start event on the I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONRESTART_NOT_DETECTED =0 , +/* +* Repeated start detected. The Monitor function has detected a Repeated +* Start event on the I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONRESTART_DETECTED =1 , +}FLEXCOMM_I2C_MONRXDAT_MONRESTART_Enum ; + +typedef enum { +/* +* Acknowledged. The data currently being provided by the Monitor function +* was acknowledged by at least one master or slave receiver. +*/ +FLEXCOMM_I2C_MONRXDAT_MONNACK_ACKNOWLEDGED =0 , +/* +* Not acknowledged. The data currently being provided by the Monitor +* function was not acknowledged by any receiver. +*/ +FLEXCOMM_I2C_MONRXDAT_MONNACK_NOT_ACKNOWLEDGED =1 , +}FLEXCOMM_I2C_MONRXDAT_MONNACK_Enum ; + + +#define FLEXCOMM_I2C_REGISTER_ACCESS_INFO_ARRAY (_name) \ + struct RegisterAccessInfo _name[FLEXCOMM_I2C_REGS_NO] = { \ + [0 ... FLEXCOMM_I2C_REGS_NO - 1] = { \ + .name = "", \ + .addr = -1, \ + }, \ + [R_FLEXCOMM_I2C_CFG] = { \ + .name = "CFG", \ + .addr = 0x800, \ + .ro = 0xFFFFFFC0, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_STAT] = { \ + .name = "STAT", \ + .addr = 0x804, \ + .ro = 0xFCF57FAF, \ + .reset = 0x801, \ + }, \ + [R_FLEXCOMM_I2C_INTENSET] = { \ + .name = "INTENSET", \ + .addr = 0x808, \ + .ro = 0xFCF476AE, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_INTENCLR] = { \ + .name = "INTENCLR", \ + .addr = 0x80C, \ + .ro = 0xFCF476AE, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_TIMEOUT] = { \ + .name = "TIMEOUT", \ + .addr = 0x810, \ + .ro = 0xFFFF0000, \ + .reset = 0xFFFF, \ + }, \ + [R_FLEXCOMM_I2C_CLKDIV] = { \ + .name = "CLKDIV", \ + .addr = 0x814, \ + .ro = 0xFFFF0000, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_INTSTAT] = { \ + .name = "INTSTAT", \ + .addr = 0x818, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x801, \ + }, \ + [R_FLEXCOMM_I2C_MSTCTL] = { \ + .name = "MSTCTL", \ + .addr = 0x820, \ + .ro = 0xFFFFFFF0, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_MSTTIME] = { \ + .name = "MSTTIME", \ + .addr = 0x824, \ + .ro = 0xFFFFFF88, \ + .reset = 0x77, \ + }, \ + [R_FLEXCOMM_I2C_MSTDAT] = { \ + .name = "MSTDAT", \ + .addr = 0x828, \ + .ro = 0xFFFFFF00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVCTL] = { \ + .name = "SLVCTL", \ + .addr = 0x840, \ + .ro = 0xFFFFFCF4, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVDAT] = { \ + .name = "SLVDAT", \ + .addr = 0x844, \ + .ro = 0xFFFFFF00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR0] = { \ + .name = "SLVADR0", \ + .addr = 0x848, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR1] = { \ + .name = "SLVADR1", \ + .addr = 0x84C, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR2] = { \ + .name = "SLVADR2", \ + .addr = 0x850, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR3] = { \ + .name = "SLVADR3", \ + .addr = 0x854, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVQUAL0] = { \ + .name = "SLVQUAL0", \ + .addr = 0x858, \ + .ro = 0xFFFFFF00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_MONRXDAT] = { \ + .name = "MONRXDAT", \ + .addr = 0x880, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_ID] = { \ + .name = "ID", \ + .addr = 0xFFC, \ + .ro = 0xFFFFFFFF, \ + .reset = 0xE0301300, \ + }, \ + }include/hw/i2c/flexcomm_i2c.h new file +40
-0@@ -0,0 +1,40 @@ +/* +* QEMU model for NXP's FLEXCOMM I2C +* +* Copyright (c) 2024 Google LLC +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef HW_FLEXCOMM_I2C_H +#define HW_FLEXCOMM_I2C_H + +#include "hw/i2c/i2c.h" +#include "hw/misc/flexcomm_function.h" + +#define TYPE_FLEXCOMM_I2C "flexcomm-i2c" +OBJECT_DECLARE_TYPE (FlexcommI2cState, FlexcommI2cClass,FLEXCOMM_I2C ); + +struct FlexcommI2cState { +FlexcommFunction parent_obj; + +I2CBus *bus; +}; + +struct FlexcommI2cClass { +FlexcommFunctionClass parent_obj; + +FlexcommFunctionSelect select; +}; + +#define MSTSTATE_IDLE 0 +#define MSTSTATE_RXRDY 1 +#define MSTSTATE_TXRDY 2 +#define MSTSTATE_NAKADR 3 +#define MSTSTATE_NAKDAT 4 + + +#endif /* HW_FLEXCOMM_I2C_H */ include/hw/misc/flexcomm.h +2
-0@@ -16,6 +16,7 @@#include "hw/arm/svd/flexcomm.h" #include "qemu/fifo32.h" #include "hw/char/flexcomm_usart.h" +#include "hw/i2c/flexcomm_i2c.h" #define FLEXCOMM_FUNC_USART 0#define FLEXCOMM_FUNC_SPI 1@@ -48,6 +49,7 @@ struct FlexcommState {Fifo32 rx_fifo;Fifo32 tx_fifo;FlexcommUsartState usart; + FlexcommI2cState i2c; };#endif /* HW_FLEXCOMM_H */ hw/i2c/flexcomm_i2c.c new file +250
-0@@ -0,0 +1,250 @@ +/* +* QEMU model for NXP's FLEXCOMM I2C +* +* Copyright (c) 2024 Google LLC +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "exec/address-spaces.h" +#include "qapi/error.h" +#include "trace.h" +#include "hw/i2c/flexcomm_i2c.h" +#include "hw/arm/svd/flexcomm_i2c.h" + +#define REG (s, reg) (s->regs[R_FLEXCOMM_I2C_##reg]) +#define RF_WR (s, reg, field, val) \ + ARRAY_FIELD_DP32(s->regs, FLEXCOMM_I2C_##reg, field, val) +#define RF_RD (s, reg, field) \ + ARRAY_FIELD_EX32(s->regs, FLEXCOMM_I2C_##reg, field) + +static FLEXCOMM_I2C_REGISTER_ACCESS_INFO_ARRAY (reg_info); + +static void flexcomm_i2c_reset (FlexcommFunction *f) +{ +for (int i =0 ; i <FLEXCOMM_I2C_REGS_NO ; i++) { +hwaddr addr = reg_info[i].addr; + +if (addr !=-1 ) { +struct RegisterInfo ri = { + .data = &f->regs[addr /4 ], + .data_size =4 , + .access = ®_info[i], + }; + +register_reset (&ri); + } + } +} + +static void flexcomm_i2c_irq_update (FlexcommFunction *f) +{ +bool enabled =RF_RD (f,CFG ,MSTEN ); +bool irq, per_irqs; + +REG (f,INTSTAT ) =REG (f,STAT ) ® (f,INTENSET ); + per_irqs =REG (f,INTSTAT ) !=0 ; + + irq = enabled && per_irqs; + +trace_flexcomm_i2c_irq (DEVICE (f)->id, irq, per_irqs, enabled); +flexcomm_set_irq (f, irq); +} + +static MemTxResult flexcomm_i2c_reg_read (void *opaque,hwaddr addr, +uint64_t *data,unsigned size, +MemTxAttrs attrs) +{ +FlexcommFunction *f =FLEXCOMM_FUNCTION (opaque); +MemTxResult ret =MEMTX_OK ; +const struct RegisterAccessInfo *rai = ®_info[addr /4 ]; + +if (size !=4 ) { + ret =MEMTX_ERROR ; + goto out; + } + + *data = f->regs[addr /4 ]; + +flexcomm_i2c_irq_update (f); + +out: +trace_flexcomm_i2c_reg_read (DEVICE (f)->id, rai->name, addr, *data); +return ret; +} + +static MemTxResult flexcomm_i2c_reg_write (void *opaque,hwaddr addr, +uint64_t value,unsigned size, +MemTxAttrs attrs) +{ +FlexcommFunction *f =FLEXCOMM_FUNCTION (opaque); +FlexcommI2cState *s =FLEXCOMM_I2C (opaque); +const struct RegisterAccessInfo *rai = ®_info[addr /4 ]; +struct RegisterInfo ri = { + .data = &f->regs[addr /4 ], + .data_size =4 , + .access = rai, + }; + +trace_flexcomm_i2c_reg_write (DEVICE (f)->id, rai->name, addr, value); + +if (size !=4 ) { +return MEMTX_ERROR ; + } + +switch (addr) { +case A_FLEXCOMM_I2C_CFG : + { +register_write (&ri, value, ~0 ,NULL , false); +if (RF_RD (f,CFG ,SLVEN )) { +qemu_log_mask (LOG_GUEST_ERROR ,"I2C slave not supported" ); + } +if (RF_RD (f,CFG ,MONEN )) { +qemu_log_mask (LOG_GUEST_ERROR ,"I2C monitoring not supported" ); + } +break ; + } +case A_FLEXCOMM_I2C_INTENCLR : + { +REG (f,INTENSET ) &= ~value; +break ; + } +case A_FLEXCOMM_I2C_TIMEOUT : + { +register_write (&ri, value, ~0 ,NULL , false); +/* The bottom 4 bits are hard-wired to 0xF */ +RF_WR (f,TIMEOUT ,TOMIN ,0xf ); +break ; + } +case A_FLEXCOMM_I2C_MSTCTL : + { +register_write (&ri, value, ~0 ,NULL , false); +if (RF_RD (f,MSTCTL ,MSTSTART )) { +uint8_t i2c_addr =RF_RD (f,MSTDAT ,DATA ); +bool recv = i2c_addr &1 ; + +trace_flexcomm_i2c_start (DEVICE (s)->id, i2c_addr, recv); +if (i2c_start_transfer (s->bus, i2c_addr, recv)) { +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_NAKADR ); +trace_flexcomm_i2c_nak (DEVICE (s)->id); + }else { +if (recv) { +uint8_t data =i2c_recv (s->bus); + +RF_WR (f,MSTDAT ,DATA , data); +trace_flexcomm_i2c_rx (DEVICE (s)->id, data); +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_RXRDY ); + }else { +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_TXRDY ); + } + } + } +if (RF_RD (f,MSTCTL ,MSTSTOP )) { +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_IDLE ); +i2c_end_transfer (s->bus); + } +if (RF_RD (f,MSTCTL ,MSTCONTINUE )) { +if (RF_RD (f,STAT ,MSTSTATE ) ==MSTSTATE_TXRDY ) { +uint8_t data =RF_RD (f,MSTDAT ,DATA ); + +trace_flexcomm_i2c_tx (DEVICE (s)->id, data); +if (i2c_send (s->bus, data)) { +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_NAKDAT ); + } + }else if (RF_RD (f,STAT ,MSTSTATE ) ==MSTSTATE_RXRDY ) { +uint8_t data =i2c_recv (s->bus); + +RF_WR (f,MSTDAT ,DATA , data); +trace_flexcomm_i2c_rx (DEVICE (s)->id, data); + } + } +break ; + } +case A_FLEXCOMM_I2C_STAT : + { +/* write 1 to clear bits */ +REG (f,STAT ) &= ~value; +break ; + } +case A_FLEXCOMM_I2C_SLVCTL : +case A_FLEXCOMM_I2C_SLVDAT : +case A_FLEXCOMM_I2C_SLVADR0 : +case A_FLEXCOMM_I2C_SLVADR1 : +case A_FLEXCOMM_I2C_SLVADR2 : +case A_FLEXCOMM_I2C_SLVADR3 : +case A_FLEXCOMM_I2C_SLVQUAL0 : + { +qemu_log_mask (LOG_GUEST_ERROR ,"I2C slave not supported\n" ); +break ; + } +default : +register_write (&ri, value, ~0 ,NULL , false); +break ; + } + +flexcomm_i2c_irq_update (f); + +return MEMTX_OK ; +} + +static void flexcomm_i2c_select (FlexcommFunction *f,bool selected) +{ +FlexcommI2cClass *ic =FLEXCOMM_I2C_GET_CLASS (f); + +if (selected) { +flexcomm_i2c_reset (f); + } + ic->select (f, selected); +} + +static const MemoryRegionOps flexcomm_i2c_ops = { + .read_with_attrs = flexcomm_i2c_reg_read, + .write_with_attrs = flexcomm_i2c_reg_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .valid = { + .min_access_size =4 , + .max_access_size =4 , + .unaligned = false, + }, +}; + +static void flexcomm_i2c_realize (DeviceState *dev,Error **errp) +{ +FlexcommI2cState *s =FLEXCOMM_I2C (dev); + + s->bus =i2c_init_bus (DEVICE (s),"bus" ); +} + +static void flexcomm_i2c_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +FlexcommFunctionClass *fc =FLEXCOMM_FUNCTION_CLASS (klass); +FlexcommI2cClass *ic =FLEXCOMM_I2C_CLASS (klass); + + dc->realize = flexcomm_i2c_realize; + ic->select = fc->select; + fc->select = flexcomm_i2c_select; + fc->name ="i2c" ; + fc->mmio_ops = &flexcomm_i2c_ops; +} + +static const TypeInfo flexcomm_i2c_types[] = { + { + .name =TYPE_FLEXCOMM_I2C , + .parent =TYPE_FLEXCOMM_FUNCTION , + .instance_size =sizeof (FlexcommI2cState), + .class_init = flexcomm_i2c_class_init, + .class_size =sizeof (FlexcommI2cClass), + }, +}; + +DEFINE_TYPES (flexcomm_i2c_types);hw/misc/flexcomm.c +3
-0@@ -24,6 +24,7 @@#include "hw/misc/flexcomm.h" #include "hw/arm/svd/flexcomm_usart.h" #include "hw/char/flexcomm_usart.h" +#include "hw/i2c/flexcomm_i2c.h" #define REG (s, reg) (s->regs[R_FLEXCOMM_##reg])#define RF_WR (s, reg, field, val) \@@ -220,6 +221,7 @@ static void flexcomm_init(Object *obj)sysbus_init_mmio (SYS_BUS_DEVICE (obj), &s->container);sysbus_init_irq (sbd, &s->irq);object_initialize_child (obj,"usart" , &s->usart,TYPE_FLEXCOMM_USART ); +object_initialize_child (obj,"i2c" , &s->i2c,TYPE_FLEXCOMM_I2C ); }static void flexcomm_finalize (Object *obj)@@ -250,6 +252,7 @@ static void flexcomm_realize(DeviceState *dev, Error **errp)memory_region_add_subregion_overlap (&s->container,0 , &s->mmio,-1 );flexcomm_func_realize_and_unref (FLEXCOMM_FUNCTION (&s->usart), errp); +flexcomm_func_realize_and_unref (FLEXCOMM_FUNCTION (&s->i2c), errp); }static const VMStateDescription vmstate_flexcomm = {hw/arm/svd/meson.build +3
-0@@ -7,4 +7,7 @@ if get_option('mcux-soc-svd') run_target('svd-flexcomm-usart', command: svd_gen_header + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_usart.h', '-p', 'USART0', '-t', 'FLEXCOMM_USART']) + run_target('svd-flexcomm-i2c', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_i2c.h', + '-p', 'I2C0', '-t', 'FLEXCOMM_I2C']) endifhw/i2c/meson.build +1
-0@@ -18,4 +18,5 @@ i2c_ss.add(when: 'CONFIG_PPC4XX', if_true: files('ppc4xx_i2c.c')) i2c_ss.add(when: 'CONFIG_PCA954X', if_true: files('i2c_mux_pca954x.c')) i2c_ss.add(when: 'CONFIG_PMBUS', if_true: files('pmbus_device.c')) i2c_ss.add(when: 'CONFIG_BCM2835_I2C', if_true: files('bcm2835_i2c.c')) +i2c_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm_i2c.c')) system_ss.add_all(when: 'CONFIG_I2C', if_true: i2c_ss)hw/i2c/trace-events +10
-0@@ -51,3 +51,13 @@ npcm7xx_smbus_recv_fifo(const char *id, uint8_t received, uint8_t expected) "%s pca954x_write_bytes(uint8_t value) "PCA954X write data: 0x%02x" pca954x_read_data(uint8_t value) "PCA954X read data: 0x%02x" + +# flexcomm_i2c.c + +flexcomm_i2c_reg_read(const char *id, const char *reg_name, uint32_t addr, uint32_t val) " %s: %s[0x%04x] -> 0x%08x" +flexcomm_i2c_reg_write(const char *id, const char *reg_name, uint32_t addr, uint32_t val) "%s: %s[0x%04x] <- 0x%08x" +flexcomm_i2c_start(const char *id, uint8_t addr, uint8_t recv) "%s: 0x%02x %d" +flexcomm_i2c_rx(const char *id, uint8_t data) "%s: <- 0x%02x" +flexcomm_i2c_tx(const char *id, uint8_t data) "%s: -> 0x%02x" +flexcomm_i2c_nak(const char *id) "%s: <- nak" +flexcomm_i2c_irq(const char *id, bool irq, bool perirqs, bool enabled) "%s: %d %d %d"hw/misc/Kconfig +1
-1@@ -215,5 +215,6 @@ config XLNX_VERSAL_TRNG config FLEXCOMM bool + select I2C source macio/Kconfig --2.46.0.662.g92d0881bb0-goog
Re: [PATCH 08/25] hw/i2c: add support for flexcomm i2c
Quoted 327 lines · Corey Minyard
Quoted 302 lines · Octavian Purdila
Quoted 292 lines · On Wed, Sep 18, 2024 at 1:17???PM Corey Minyard <[email protected]> wrote:
Quoted 276 lines · Octavian Purdila
Add support for NXP's flexcomm i2c. It does not support slave mode or DMA.
The patch includes an automatically generated header which contains the register layout and helpers.
The header can be regenerated with the svd-flexcomm-i2c target when the build is configured with --enable-mcux-soc-svd.
Signed-off-by Octavian Purdila <[email protected]>--- include/hw/arm/svd/flexcomm_i2c.h | 1190 +++++++++++++++++++++++++++++ include/hw/i2c/flexcomm_i2c.h | 40 + include/hw/misc/flexcomm.h | 2 + hw/i2c/flexcomm_i2c.c | 250 ++++++ hw/misc/flexcomm.c | 3 + hw/arm/svd/meson.build | 3 + hw/i2c/meson.build | 1 + hw/i2c/trace-events | 10 + hw/misc/Kconfig | 1 + 9 files changed, 1500 insertions(+) create mode 100644 include/hw/arm/svd/flexcomm_i2c.h create mode 100644 include/hw/i2c/flexcomm_i2c.h create mode 100644 hw/i2c/flexcomm_i2c.cinclude/hw/arm/svd/flexcomm_i2c.h new file +245
-0@@ -0,0 +1,1190 @@ +/* +* Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause +* +* Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml +*/ +#pragma once + +#include "hw/register.h" + +/* I2C Bus Interface */ +#define FLEXCOMM_I2C_REGS_NO (1024) + +/* Configuration Register */ +REG32 (FLEXCOMM_I2C_CFG ,2048 ); +/* Master Enable */ +FIELD (FLEXCOMM_I2C_CFG ,MSTEN ,0 ,1 ); +/* Slave Enable */ +FIELD (FLEXCOMM_I2C_CFG ,SLVEN ,1 ,1 ); +/* Monitor Enable */ +FIELD (FLEXCOMM_I2C_CFG ,MONEN ,2 ,1 ); +/* I2C bus Time-out Enable */ +FIELD (FLEXCOMM_I2C_CFG ,TIMEOUTEN ,3 ,1 ); +/* Monitor function Clock Stretching */ +FIELD (FLEXCOMM_I2C_CFG ,MONCLKSTR ,4 ,1 ); +/* High Speed mode Capable enable */ +FIELD (FLEXCOMM_I2C_CFG ,HSCAPABLE ,5 ,1 ); + +/* Status Register */ +REG32 (FLEXCOMM_I2C_STAT ,2052 ); +/* Master Pending */ +FIELD (FLEXCOMM_I2C_STAT ,MSTPENDING ,0 ,1 ); +/* Master State code */ +FIELD (FLEXCOMM_I2C_STAT ,MSTSTATE ,1 ,3 ); +/* Master Arbitration Loss flag */ +FIELD (FLEXCOMM_I2C_STAT ,MSTARBLOSS ,4 ,1 ); +/* Master Start/Stop Error flag */ +FIELD (FLEXCOMM_I2C_STAT ,MSTSTSTPERR ,6 ,1 ); +/* Slave Pending */ +FIELD (FLEXCOMM_I2C_STAT ,SLVPENDING ,8 ,1 ); +/* Slave State */ +FIELD (FLEXCOMM_I2C_STAT ,SLVSTATE ,9 ,2 ); +/* Slave Not Stretching */ +FIELD (FLEXCOMM_I2C_STAT ,SLVNOTSTR ,11 ,1 ); +/* Slave address match Index T */ +FIELD (FLEXCOMM_I2C_STAT ,SLVIDX ,12 ,2 ); +/* Slave selected flag */ +FIELD (FLEXCOMM_I2C_STAT ,SLVSEL ,14 ,1 ); +/* Slave Deselected flag */ +FIELD (FLEXCOMM_I2C_STAT ,SLVDESEL ,15 ,1 ); +/* Monitor Ready */ +FIELD (FLEXCOMM_I2C_STAT ,MONRDY ,16 ,1 ); +/* Monitor Overflow flag */ +FIELD (FLEXCOMM_I2C_STAT ,MONOV ,17 ,1 ); +/* Monitor Active flag */ +FIELD (FLEXCOMM_I2C_STAT ,MONACTIVE ,18 ,1 ); +/* Monitor Idle flag */ +FIELD (FLEXCOMM_I2C_STAT ,MONIDLE ,19 ,1 ); +/* Event Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_STAT ,EVENTTIMEOUT ,24 ,1 ); +/* SCL Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_STAT ,SCLTIMEOUT ,25 ,1 ); + +/* Interrupt Enable Set Register */ +REG32 (FLEXCOMM_I2C_INTENSET ,2056 ); +/* Master Pending interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MSTPENDINGEN ,0 ,1 ); +/* Master Arbitration Loss interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MSTARBLOSSEN ,4 ,1 ); +/* Master Start/Stop Error interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MSTSTSTPERREN ,6 ,1 ); +/* Slave Pending interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SLVPENDINGEN ,8 ,1 ); +/* Slave Not Stretching interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SLVNOTSTREN ,11 ,1 ); +/* Slave Deselect interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SLVDESELEN ,15 ,1 ); +/* Monitor data Ready interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MONRDYEN ,16 ,1 ); +/* Monitor Overrun interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MONOVEN ,17 ,1 ); +/* Monitor Idle interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,MONIDLEEN ,19 ,1 ); +/* Event Time-out interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,EVENTTIMEOUTEN ,24 ,1 ); +/* SCL Time-out interrupt Enable */ +FIELD (FLEXCOMM_I2C_INTENSET ,SCLTIMEOUTEN ,25 ,1 ); + +/* Interrupt Enable Clear Register */ +REG32 (FLEXCOMM_I2C_INTENCLR ,2060 ); +/* Master Pending interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MSTPENDINGCLR ,0 ,1 ); +/* Master Arbitration Loss interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MSTARBLOSSCLR ,4 ,1 ); +/* Master Start/Stop Error interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MSTSTSTPERRCLR ,6 ,1 ); +/* Slave Pending interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SLVPENDINGCLR ,8 ,1 ); +/* Slave Not Stretching interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SLVNOTSTRCLR ,11 ,1 ); +/* Slave Deselect interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SLVDESELCLR ,15 ,1 ); +/* Monitor data Ready interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MONRDYCLR ,16 ,1 ); +/* Monitor Overrun interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MONOVCLR ,17 ,1 ); +/* Monitor Idle interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,MONIDLECLR ,19 ,1 ); +/* Event time-out interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,EVENTTIMEOUTCLR ,24 ,1 ); +/* SCL time-out interrupt clear */ +FIELD (FLEXCOMM_I2C_INTENCLR ,SCLTIMEOUTCLR ,25 ,1 ); + +/* Time-out Register */ +REG32 (FLEXCOMM_I2C_TIMEOUT ,2064 ); +/* Time-out time value, the bottom 4 bits */ +FIELD (FLEXCOMM_I2C_TIMEOUT ,TOMIN ,0 ,4 ); +/* Time-out time value */ +FIELD (FLEXCOMM_I2C_TIMEOUT ,TO ,4 ,12 ); + +/* Clock Divider Register */ +REG32 (FLEXCOMM_I2C_CLKDIV ,2068 ); +/* Divider Value */ +FIELD (FLEXCOMM_I2C_CLKDIV ,DIVVAL ,0 ,16 ); + +/* Interrupt Status Register */ +REG32 (FLEXCOMM_I2C_INTSTAT ,2072 ); +/* Master Pending */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MSTPENDING ,0 ,1 ); +/* Master Arbitration Loss flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MSTARBLOSS ,4 ,1 ); +/* Master Start/Stop Error flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MSTSTSTPERR ,6 ,1 ); +/* Slave Pending */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SLVPENDING ,8 ,1 ); +/* Slave Not Stretching status */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SLVNOTSTR ,11 ,1 ); +/* Slave Deselected flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SLVDESEL ,15 ,1 ); +/* Monitor Ready */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MONRDY ,16 ,1 ); +/* Monitor Overflow flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MONOV ,17 ,1 ); +/* Monitor Idle flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,MONIDLE ,19 ,1 ); +/* Event Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,EVENTTIMEOUT ,24 ,1 ); +/* SCL Time-out Interrupt flag */ +FIELD (FLEXCOMM_I2C_INTSTAT ,SCLTIMEOUT ,25 ,1 ); + +/* Master Control Register */ +REG32 (FLEXCOMM_I2C_MSTCTL ,2080 ); +/* Master Continue(write-only) */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTCONTINUE ,0 ,1 ); +/* Master Start control(write-only) */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTSTART ,1 ,1 ); +/* Master Stop control(write-only) */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTSTOP ,2 ,1 ); +/* Master DMA enable */ +FIELD (FLEXCOMM_I2C_MSTCTL ,MSTDMA ,3 ,1 ); + +/* Master Timing Register */ +REG32 (FLEXCOMM_I2C_MSTTIME ,2084 ); +/* Master SCL Low time */ +FIELD (FLEXCOMM_I2C_MSTTIME ,MSTSCLLOW ,0 ,3 ); +/* Master SCL High time */ +FIELD (FLEXCOMM_I2C_MSTTIME ,MSTSCLHIGH ,4 ,3 ); + +/* Master Data Register */ +REG32 (FLEXCOMM_I2C_MSTDAT ,2088 ); +/* Master function data register */ +FIELD (FLEXCOMM_I2C_MSTDAT ,DATA ,0 ,8 ); + +/* Slave Control Register */ +REG32 (FLEXCOMM_I2C_SLVCTL ,2112 ); +/* Slave Continue */ +FIELD (FLEXCOMM_I2C_SLVCTL ,SLVCONTINUE ,0 ,1 ); +/* Slave NACK */ +FIELD (FLEXCOMM_I2C_SLVCTL ,SLVNACK ,1 ,1 ); +/* Slave DMA enable */ +FIELD (FLEXCOMM_I2C_SLVCTL ,SLVDMA ,3 ,1 ); +/* Automatic Acknowledge */ +FIELD (FLEXCOMM_I2C_SLVCTL ,AUTOACK ,8 ,1 ); +/* Automatic Match Read */ +FIELD (FLEXCOMM_I2C_SLVCTL ,AUTOMATCHREAD ,9 ,1 ); + +/* Slave Data Register */ +REG32 (FLEXCOMM_I2C_SLVDAT ,2116 ); +/* Slave function data register */ +FIELD (FLEXCOMM_I2C_SLVDAT ,DATA ,0 ,8 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR0 ,2120 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR0 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR0 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR0 ,AUTONACK ,15 ,1 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR1 ,2124 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR1 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR1 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR1 ,AUTONACK ,15 ,1 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR2 ,2128 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR2 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR2 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR2 ,AUTONACK ,15 ,1 ); + +/* Slave Address Register */ +REG32 (FLEXCOMM_I2C_SLVADR3 ,2132 ); +/* Slave Address n Disable */ +FIELD (FLEXCOMM_I2C_SLVADR3 ,SADISABLE ,0 ,1 ); +/* Slave Address. */ +FIELD (FLEXCOMM_I2C_SLVADR3 ,SLVADR ,1 ,7 ); +/* Automatic NACK operation */ +FIELD (FLEXCOMM_I2C_SLVADR3 ,AUTONACK ,15 ,1 ); + +/* Slave Qualification for Address 0 Register */ +REG32 (FLEXCOMM_I2C_SLVQUAL0 ,2136 ); +/* Qualify mode for slave address 0 */ +FIELD (FLEXCOMM_I2C_SLVQUAL0 ,QUALMODE0 ,0 ,1 ); +/* Slave address Qualifier for address 0 */ +FIELD (FLEXCOMM_I2C_SLVQUAL0 ,SLVQUAL0 ,1 ,7 ); + +/* Monitor Receiver Data Register */ +REG32 (FLEXCOMM_I2C_MONRXDAT ,2176 ); +/* Monitor function Receiver Data */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONRXDAT ,0 ,8 ); +/* Monitor Received Start */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONSTART ,8 ,1 ); +/* Monitor Received Repeated Start */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONRESTART ,9 ,1 ); +/* Monitor Received NACK */ +FIELD (FLEXCOMM_I2C_MONRXDAT ,MONNACK ,10 ,1 ); + +/* Peripheral Identification Register */ include/hw/arm/svd/flexcomm_i2c.h line 255
Quoted 10 lines
include/hw/arm/svd/flexcomm_i2c.h new file +10
-0+REG32 (FLEXCOMM_I2C_ID ,4092 ); +/* Aperture */ +FIELD (FLEXCOMM_I2C_ID ,APERTURE ,0 ,8 ); +/* Minor revision of module implementation */ +FIELD (FLEXCOMM_I2C_ID ,MINOR_REV ,8 ,4 ); +/* Major revision of module implementation */ +FIELD (FLEXCOMM_I2C_ID ,MAJOR_REV ,12 ,4 ); +/* Module identifier for the selected function */ +FIELD (FLEXCOMM_I2C_ID ,ID ,16 ,16 ); +Are any of the below enums even used? Or for that matter, most of the above fields?
Quoted 4 lines
If these are just here for documentation, I would prefer English text; it's more dense and easier to read. It's very difficult to tie all this together into a cohesive view of the device registers.
Since this is autogenerated for the full set of the device registers there will be fields that are not used either because the emulation is incomplete or because they don't have effect for emulation.
Quoted 8 lines
I think it is still valuable to have this generated automatically instead of doing it by hand.
Would adding options to only generate certain definitions help? As long as we are reasonable with the granularity (e.g. register level) I think it could trim *most* of the unused generated code without becoming too tedious on how to instruct the tool to generate the code. However, I expect to still have *some* unused generated code.
Generally it's frowned upon to have a ton of extra stuff that's not used. I would think some is ok, like defining bits in registers that aren't used yet, but I have no idea how all the enums below here actually tie into anything. I'm guessing these are just bitmasks into registers, but really, it's a lot easier to read if you have something like:
/*
* The I2C Master function enable. When disabled, the Master
* configuration settings are not changed, but the Master function is
* internally reset.
*/
#defineFLEXCOMM_I2C_CFG_MSTEN(1 << 4)
Quoted 4 lines
and them have them grouped together with the register they belong to. I don't know how you would even use these enums. AFAICT, none of them are used.
Ah, I see. You are right, it is not useful for 1 bit fields, I'll fix the generator to skip these for bits.
The purpose of the enums is for the case where a certain field can have more than two options. To give an example that is used:
typedef enum {
FLEXCOMM_I2C_STAT_MSTSTATE_IDLE = 0, FLEXCOMM_I2C_STAT_MSTSTATE_RECEIVE_READY = 1, FLEXCOMM_I2C_STAT_MSTSTATE_TRANSMIT_READY = 2, FLEXCOMM_I2C_STAT_MSTSTATE_NACK_ADDRESS = 3, FLEXCOMM_I2C_STAT_MSTSTATE_NACK_DATA = 4,
} FLEXCOMM_I2C_STAT_MSTSTATE_Enum;
Quoted 4 lines
And the whole idea of this is to make the code more readable. So if you define these things, you should use them. Look around through the code of other devices to get a feel of how things are done.
Thanks for the review and sorry for the rough edges, I should have caught the bits enums thing.
Quoted 1,348 lines
-corey
Quoted 1,346 lines
Quoted 1,346 lines
The .c file itself seems ok.
-corey
Quoted 1,340 lines
include/hw/arm/svd/flexcomm_i2c.h new file +935
-0+ +typedef enum { +/* +* Disabled. The I2C Master function is disabled. When disabled, the Master +* configuration settings are not changed, but the Master function is +* internally reset. +*/ +FLEXCOMM_I2C_CFG_MSTEN_DISABLED =0 , +/* Enabled. The I2C Master function is enabled. */ +FLEXCOMM_I2C_CFG_MSTEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_MSTEN_Enum ; + +typedef enum { +/* +* Disabled. The I2C slave function is disabled. When disabled, the Slave +* configuration settings are not changed, but the Slave function is +* internally reset. +*/ +FLEXCOMM_I2C_CFG_SLVEN_DISABLED =0 , +/* Enabled. The I2C slave function is enabled. */ +FLEXCOMM_I2C_CFG_SLVEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_SLVEN_Enum ; + +typedef enum { +/* +* Disabled. The I2C Monitor function is disabled. When disabled, the +* Monitor function configuration settings are not changed, but the Monitor +* function is internally reset. +*/ +FLEXCOMM_I2C_CFG_MONEN_DISABLED =0 , +/* Enabled. The I2C Monitor function is enabled. */ +FLEXCOMM_I2C_CFG_MONEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_MONEN_Enum ; + +typedef enum { +/* +* Disabled. The time-out function is disabled. When disabled, the time-out +* function is internally reset. +*/ +FLEXCOMM_I2C_CFG_TIMEOUTEN_DISABLED =0 , +/* +* Enabled. The time-out function is enabled. Both types of time-out flags +* will be generated and will cause interrupts if those flags are enabled. +* Typically, only one time-out flag will be used in a system. +*/ +FLEXCOMM_I2C_CFG_TIMEOUTEN_ENABLED =1 , +}FLEXCOMM_I2C_CFG_TIMEOUTEN_Enum ; + +typedef enum { +/* +* Disabled. The Monitor function will not perform clock stretching. +* Software or DMA may not always be able to read data provided by the +* Monitor function before it (the data) is overwritten. This mode can be +* used when non-invasive monitoring is critical. +*/ +FLEXCOMM_I2C_CFG_MONCLKSTR_DISABLED =0 , +/* +* Enabled. The Monitor function will perform clock stretching, to ensure +* that the software or DMA can read all incoming data supplied by the +* Monitor function. +*/ +FLEXCOMM_I2C_CFG_MONCLKSTR_ENABLED =1 , +}FLEXCOMM_I2C_CFG_MONCLKSTR_Enum ; + +typedef enum { +/* Fast mode Plus enable */ +FLEXCOMM_I2C_CFG_HSCAPABLE_FAST_MODE_PLUS =0 , +/* High Speed mode enable */ +FLEXCOMM_I2C_CFG_HSCAPABLE_HIGH_SPEED =1 , +}FLEXCOMM_I2C_CFG_HSCAPABLE_Enum ; + +typedef enum { +/* +* In progress. Communication is in progress and the Master function is +* busy and cannot currently accept a command. +*/ +FLEXCOMM_I2C_STAT_MSTPENDING_IN_PROGRESS =0 , +/* +* Pending. The Master function needs software service or is in the idle +* state. If the master is not in the idle state, then the master is +* waiting to receive or transmit data, or is waiting for the NACK bit. +*/ +FLEXCOMM_I2C_STAT_MSTPENDING_PENDING =1 , +}FLEXCOMM_I2C_STAT_MSTPENDING_Enum ; + +typedef enum { +/* +* Idle. The Master function is available to be used for a new transaction. +*/ +FLEXCOMM_I2C_STAT_MSTSTATE_IDLE =0 , +/* +* Receive ready. Received data is available (in Master Receiver mode). +* Address plus Read was previously sent and Acknowledged by a slave. +*/ +FLEXCOMM_I2C_STAT_MSTSTATE_RECEIVE_READY =1 , +/* +* Transmit ready. Data can be transmitted (in Master Transmitter mode). +* Address plus Write was previously sent and Acknowledged by a slave. +*/ +FLEXCOMM_I2C_STAT_MSTSTATE_TRANSMIT_READY =2 , +/* NACK Address. Slave NACKed address. */ +FLEXCOMM_I2C_STAT_MSTSTATE_NACK_ADDRESS =3 , +/* NACK Data. Slave NACKed transmitted data. */ +FLEXCOMM_I2C_STAT_MSTSTATE_NACK_DATA =4 , +}FLEXCOMM_I2C_STAT_MSTSTATE_Enum ; + +typedef enum { +/* No Arbitration Loss has occurred */ +FLEXCOMM_I2C_STAT_MSTARBLOSS_NO_LOSS =0 , +/* +* Arbitration loss. The Master function has experienced an Arbitration +* Loss. At this point, the Master function has already stopped driving the +* bus and has gone into an idle state. Software can respond by doing +* nothing, or by sending a Start (to attempt to gain control of the bus +* when the bus next becomes idle). +*/ +FLEXCOMM_I2C_STAT_MSTARBLOSS_ARBITRATION_LOSS =1 , +}FLEXCOMM_I2C_STAT_MSTARBLOSS_Enum ; + +typedef enum { +/* No Start/Stop Error has occurred. */ +FLEXCOMM_I2C_STAT_MSTSTSTPERR_NO_ERROR =0 , +/* +* The Master function has experienced a Start/Stop Error. A Start or Stop +* was detected at a time when Start or Stop is not allowed by the I2C +* specification. The Master interface has stopped driving the bus and gone +* into an idle state; no action is required. A request for a Start could +* be made, or software could attempt to make sure that the bus has not +* stalled. +*/ +FLEXCOMM_I2C_STAT_MSTSTSTPERR_ERROR =1 , +}FLEXCOMM_I2C_STAT_MSTSTSTPERR_Enum ; + +typedef enum { +/* +* In progress. The Slave function does not currently need software +* service. +*/ +FLEXCOMM_I2C_STAT_SLVPENDING_IN_PROGRESS =0 , +/* +* Pending. The Slave function needs software service. Information about +* what is needed is in the Slave state field (SLVSTATE). +*/ +FLEXCOMM_I2C_STAT_SLVPENDING_PENDING =1 , +}FLEXCOMM_I2C_STAT_SLVPENDING_Enum ; + +typedef enum { +/* +* Slave address. Address plus R/W received. At least one of the 4 slave +* addresses has been matched by hardware. +*/ +FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_ADDRESS =0 , +/* Slave receive. Received data is available (in Slave Receiver mode). */ +FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_RECEIVE =1 , +/* Slave transmit. Data can be transmitted (in Slave Transmitter mode). */ +FLEXCOMM_I2C_STAT_SLVSTATE_SLAVE_TRANSMIT =2 , +}FLEXCOMM_I2C_STAT_SLVSTATE_Enum ; + +typedef enum { +/* +* Stretching. The slave function is currently stretching the I2C bus +* clock. Deep-Sleepmode cannot be entered at this time. +*/ +FLEXCOMM_I2C_STAT_SLVNOTSTR_STRETCHING =0 , +/* +* Not stretching. The slave function is not currently stretching the I2C +* bus clock. Deep-sleep mode can be entered at this time. +*/ +FLEXCOMM_I2C_STAT_SLVNOTSTR_NOT_STRETCHING =1 , +}FLEXCOMM_I2C_STAT_SLVNOTSTR_Enum ; + +typedef enum { +/* Address 0. Slave address 0 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS0 =0 , +/* Address 1. Slave address 1 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS1 =1 , +/* Address 2. Slave address 2 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS2 =2 , +/* Address 3. Slave address 3 was matched. */ +FLEXCOMM_I2C_STAT_SLVIDX_ADDRESS3 =3 , +}FLEXCOMM_I2C_STAT_SLVIDX_Enum ; + +typedef enum { +/* Not selected. The Slave function is not currently selected. */ +FLEXCOMM_I2C_STAT_SLVSEL_NOT_SELECTED =0 , +/* Selected. The Slave function is currently selected. */ +FLEXCOMM_I2C_STAT_SLVSEL_SELECTED =1 , +}FLEXCOMM_I2C_STAT_SLVSEL_Enum ; + +typedef enum { +/* +* Not deselected. The Slave function has not become deselected. This does +* not mean that the Slave is currently selected. That information is in +* the SLVSEL flag. +*/ +FLEXCOMM_I2C_STAT_SLVDESEL_NOT_DESELECTED =0 , +/* +* Deselected. The Slave function has become deselected. This is +* specifically caused by the SLVSEL flag changing from 1 to 0. See SLVSEL +* for details about when that event occurs. +*/ +FLEXCOMM_I2C_STAT_SLVDESEL_DESELECTED =1 , +}FLEXCOMM_I2C_STAT_SLVDESEL_Enum ; + +typedef enum { +/* No data. The Monitor function does not currently have data available. */ +FLEXCOMM_I2C_STAT_MONRDY_NO_DATA =0 , +/* Data waiting. The Monitor function has data waiting to be read. */ +FLEXCOMM_I2C_STAT_MONRDY_DATA_WAITING =1 , +}FLEXCOMM_I2C_STAT_MONRDY_Enum ; + +typedef enum { +/* No overrun. Monitor data has not overrun. */ +FLEXCOMM_I2C_STAT_MONOV_NO_OVERRUN =0 , +/* +* Overrun. A Monitor data overrun has occurred. An overrun can only happen +* when Monitor clock stretching not enabled via the CFG[MONCLKSTR] bit. +* Writing 1 to MONOV bit clears the MONOV flag. +*/ +FLEXCOMM_I2C_STAT_MONOV_OVERRUN =1 , +}FLEXCOMM_I2C_STAT_MONOV_Enum ; + +typedef enum { +/* Inactive. The Monitor function considers the I2C bus to be inactive. */ +FLEXCOMM_I2C_STAT_MONACTIVE_INACTIVE =0 , +/* Active. The Monitor function considers the I2C bus to be active. */ +FLEXCOMM_I2C_STAT_MONACTIVE_ACTIVE =1 , +}FLEXCOMM_I2C_STAT_MONACTIVE_Enum ; + +typedef enum { +/* +* Not idle. The I2C bus is not idle, or MONIDLE flag has been cleared by +* software. +*/ +FLEXCOMM_I2C_STAT_MONIDLE_NOT_IDLE =0 , +/* +* Idle. The I2C bus has gone idle at least once, since the last time +* MONIDLE flag was cleared by software. +*/ +FLEXCOMM_I2C_STAT_MONIDLE_IDLE =1 , +}FLEXCOMM_I2C_STAT_MONIDLE_Enum ; + +typedef enum { +/* No time-out. I2C bus events have not caused a time-out. */ +FLEXCOMM_I2C_STAT_EVENTTIMEOUT_NO_TIMEOUT =0 , +/* +* Event time-out. The time between I2C bus events has been longer than the +* time specified by the TIMEOUT register. +*/ +FLEXCOMM_I2C_STAT_EVENTTIMEOUT_EVEN_TIMEOUT =1 , +}FLEXCOMM_I2C_STAT_EVENTTIMEOUT_Enum ; + +typedef enum { +/* No time-out. SCL low time has not caused a time-out. */ +FLEXCOMM_I2C_STAT_SCLTIMEOUT_NO_TIMEOUT =0 , +/* Time-out. SCL low time has caused a time-out. */ +FLEXCOMM_I2C_STAT_SCLTIMEOUT_TIMEOUT =1 , +}FLEXCOMM_I2C_STAT_SCLTIMEOUT_Enum ; + +typedef enum { +/* Disabled. The MstPending interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_DISABLED =0 , +/* Enabled. The MstPending interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MSTPENDINGEN_Enum ; + +typedef enum { +/* Disabled. The MstArbLoss interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_DISABLED =0 , +/* Enabled. The MstArbLoss interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MSTARBLOSSEN_Enum ; + +typedef enum { +/* Disabled. The MstStStpErr interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_DISABLED =0 , +/* Enabled. The MstStStpErr interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MSTSTSTPERREN_Enum ; + +typedef enum { +/* Disabled. The SlvPending interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_DISABLED =0 , +/* Enabled. The SlvPending interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SLVPENDINGEN_Enum ; + +typedef enum { +/* Disabled. The SlvNotStr interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_DISABLED =0 , +/* Enabled. The SlvNotStr interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SLVNOTSTREN_Enum ; + +typedef enum { +/* Disabled. The SlvDeSel interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SLVDESELEN_DISABLED =0 , +/* Enabled. The SlvDeSel interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SLVDESELEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SLVDESELEN_Enum ; + +typedef enum { +/* Disabled. The MonRdy interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MONRDYEN_DISABLED =0 , +/* Enabled. The MonRdy interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MONRDYEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MONRDYEN_Enum ; + +typedef enum { +/* Disabled. The MonOv interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MONOVEN_DISABLED =0 , +/* Enabled. The MonOv interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MONOVEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MONOVEN_Enum ; + +typedef enum { +/* Disabled. The MonIdle interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_MONIDLEEN_DISABLED =0 , +/* Enabled. The MonIdle interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_MONIDLEEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_MONIDLEEN_Enum ; + +typedef enum { +/* Disabled. The Event time-out interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_DISABLED =0 , +/* Enabled. The Event time-out interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_EVENTTIMEOUTEN_Enum ; + +typedef enum { +/* Disabled. The SCL time-out interrupt is disabled. */ +FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_DISABLED =0 , +/* Enabled. The SCL time-out interrupt is enabled. */ +FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_ENABLED =1 , +}FLEXCOMM_I2C_INTENSET_SCLTIMEOUTEN_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_CLEAR_MSTPENDING =1 , +}FLEXCOMM_I2C_INTENCLR_MSTPENDINGCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_CLEAR_MSTARBLOSS =1 , +}FLEXCOMM_I2C_INTENCLR_MSTARBLOSSCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_CLEAR_MSTSTSTPERR =1 , +}FLEXCOMM_I2C_INTENCLR_MSTSTSTPERRCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_CLEAR_SLVPENDING =1 , +}FLEXCOMM_I2C_INTENCLR_SLVPENDINGCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_CLEAR_SLVNOTSTR =1 , +}FLEXCOMM_I2C_INTENCLR_SLVNOTSTRCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_CLEAR_SLVDESEL =1 , +}FLEXCOMM_I2C_INTENCLR_SLVDESELCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MONRDYCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MONRDYCLR_CLEAR_MONRDY =1 , +}FLEXCOMM_I2C_INTENCLR_MONRDYCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MONOVCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MONOVCLR_CLEAR_MONOV =1 , +}FLEXCOMM_I2C_INTENCLR_MONOVCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_MONIDLECLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_MONIDLECLR_CLEAR_MONIDLE =1 , +}FLEXCOMM_I2C_INTENCLR_MONIDLECLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_CLEAR_EVENTTIMEOUT =1 , +}FLEXCOMM_I2C_INTENCLR_EVENTTIMEOUTCLR_Enum ; + +typedef enum { +/* No effect on interrupt */ +FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_NO_EFFECT =0 , +/* Clears the interrupt bit in INTENSET register */ +FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_CLEAR_SCLTIMEOUT =1 , +}FLEXCOMM_I2C_INTENCLR_SCLTIMEOUTCLR_Enum ; + +typedef enum { +/* A time-out will occur after 16 counts of the I2C function clock. */ +FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT16 =0 , +/* A time-out will occur after 32 counts of the I2C function clock. */ +FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT32 =1 , +/* A time-out will occur after 65,536 counts of the I2C function clock. */ +FLEXCOMM_I2C_TIMEOUT_TO_TIMEOUT65K =4095 , +}FLEXCOMM_I2C_TIMEOUT_TO_Enum ; + +typedef enum { +/* FCLK is used directly by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKUNDIVIDED =0 , +/* FCLK is divided by 2 before being used by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV2 =1 , +/* FCLK is divided by 3 before being used by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV3 =2 , +/* FCLK is divided by 65,536 before being used by the I2C. */ +FLEXCOMM_I2C_CLKDIV_DIVVAL_FCLKDIV65K =65535 , +}FLEXCOMM_I2C_CLKDIV_DIVVAL_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MSTPENDING_MSTPENDING_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MSTPENDING_MSTPENDING_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MSTPENDING_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_MSTARBLOSS_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_MSTARBLOSS_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MSTARBLOSS_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_MSTSTSTPERR_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_MSTSTSTPERR_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MSTSTSTPERR_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SLVPENDING_SLVPENDING_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SLVPENDING_SLVPENDING_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SLVPENDING_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_SLVNOTSTR_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_SLVNOTSTR_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SLVNOTSTR_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SLVDESEL_SLVDESEL_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SLVDESEL_SLVDESEL_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SLVDESEL_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MONRDY_MONRDY_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MONRDY_MONRDY_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MONRDY_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MONOV_MONOV_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MONOV_MONOV_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MONOV_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_MONIDLE_MONIDLE_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_MONIDLE_MONIDLE_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_MONIDLE_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_EVENTTIMEOUT_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_EVENTTIMEOUT_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_EVENTTIMEOUT_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_SCLTIMEOUT_ISNOTACTIVE =0 , +/* Active */ +FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_SCLTIMEOUT_ISACTIVE =1 , +}FLEXCOMM_I2C_INTSTAT_SCLTIMEOUT_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_NO_EFFECT =0 , +/* +* Continue. Informs the Master function to continue to the next operation. +* This action must done after writing transmit data, reading received +* data, or any other housekeeping related to the next bus operation. +*/ +FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_CONTINUE =1 , +}FLEXCOMM_I2C_MSTCTL_MSTCONTINUE_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_MSTCTL_MSTSTART_NO_EFFECT =0 , +/* +* Start. A Start will be generated on the I2C bus at the next allowed +* time. +*/ +FLEXCOMM_I2C_MSTCTL_MSTSTART_START =1 , +}FLEXCOMM_I2C_MSTCTL_MSTSTART_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_MSTCTL_MSTSTOP_NO_EFFECT =0 , +/* +* Stop. A Stop will be generated on the I2C bus at the next allowed time, +* preceded by a NACK to the slave if the master is receiving data from the +* slave (in Master Receiver mode). +*/ +FLEXCOMM_I2C_MSTCTL_MSTSTOP_STOP =1 , +}FLEXCOMM_I2C_MSTCTL_MSTSTOP_Enum ; + +typedef enum { +/* Disable. No DMA requests are generated for master operation. */ +FLEXCOMM_I2C_MSTCTL_MSTDMA_DISABLED =0 , +/* +* Enable. A DMA request is generated for I2C master data operations. When +* this I2C master is generating Acknowledge bits in Master Receiver mode, +* the acknowledge is generated automatically. +*/ +FLEXCOMM_I2C_MSTCTL_MSTDMA_ENABLED =1 , +}FLEXCOMM_I2C_MSTCTL_MSTDMA_Enum ; + +typedef enum { +/* +* 2 clocks. Minimum SCL low time is 2 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_2CLOCKS =0 , +/* +* 3 clocks. Minimum SCL low time is 3 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_3CLOCKS =1 , +/* +* 4 clocks. Minimum SCL low time is 4 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_4CLOCKS =2 , +/* +* 5 clocks. Minimum SCL low time is 5 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_5CLOCKS =3 , +/* +* 6 clocks. Minimum SCL low time is 6 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_6CLOCKS =4 , +/* +* 7 clocks. Minimum SCL low time is 7 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_7CLOCKS =5 , +/* +* 8 clocks. Minimum SCL low time is 8 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_8CLOCKS =6 , +/* +* 9 clocks. Minimum SCL low time is 9 clocks of the I2C clock pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_MSTSCLLOW_9CLOCKS =7 , +}FLEXCOMM_I2C_MSTTIME_MSTSCLLOW_Enum ; + +typedef enum { +/* +* 2 clocks. Minimum SCL high time is 2 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_2CLOCKS =0 , +/* +* 3 clocks. Minimum SCL high time is 3 clocks of the I2C clock pre-divider +* . +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_3CLOCKS =1 , +/* +* 4 clocks. Minimum SCL high time is 4 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_4CLOCKS =2 , +/* +* 5 clocks. Minimum SCL high time is 5 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_5CLOCKS =3 , +/* +* 6 clocks. Minimum SCL high time is 6 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_6CLOCKS =4 , +/* +* 7 clocks. Minimum SCL high time is 7 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_7CLOCKS =5 , +/* +* 8 clocks. Minimum SCL high time is 8 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_8CLOCKS =6 , +/* +* 9 clocks. Minimum SCL high time is 9 clocks of the I2C clock +* pre-divider. +*/ +FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_MSTSCLHIGH_9CLOCKS =7 , +}FLEXCOMM_I2C_MSTTIME_MSTSCLHIGH_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_NO_EFFECT =0 , +/* +* Continue. Informs the Slave function to continue to the next operation, +* by clearing the STAT[SLVPENDING] flag. This must be done after writing +* transmit data, reading received data, or any other housekeeping related +* to the next bus operation. Automatic Operation has different +* requirements. SLVCONTINUE should not be set unless SLVPENDING = 1. +*/ +FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_CONTINUE =1 , +}FLEXCOMM_I2C_SLVCTL_SLVCONTINUE_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_I2C_SLVCTL_SLVNACK_NO_EFFECT =0 , +/* +* NACK. Causes the Slave function to NACK the master when the slave is +* receiving data from the master (in Slave Receiver mode). +*/ +FLEXCOMM_I2C_SLVCTL_SLVNACK_NACK =1 , +}FLEXCOMM_I2C_SLVCTL_SLVNACK_Enum ; + +typedef enum { +/* Disabled. No DMA requests are issued for Slave mode operation. */ +FLEXCOMM_I2C_SLVCTL_SLVDMA_DISABLED =0 , +/* +* Enabled. DMA requests are issued for I2C slave data transmission and +* reception. +*/ +FLEXCOMM_I2C_SLVCTL_SLVDMA_ENABLED =1 , +}FLEXCOMM_I2C_SLVCTL_SLVDMA_Enum ; + +typedef enum { +/* +* Normal, non-automatic operation. If AUTONACK = 0, then a SlvPending +* interrupt is generated when a matching address is received. If AUTONACK +* = 1, then received addresses are NACKed (ignored). +*/ +FLEXCOMM_I2C_SLVCTL_AUTOACK_NORMAL =0 , +/* +* A header with matching SLVADR0 and matching direction as set by +* AUTOMATCHREAD will be ACKed immediately, allowing the master to move on +* to the data bytes. If the address matches SLVADR0, but the direction +* does not match AUTOMATCHREAD, then the behavior will depend on the +* SLVADR0[AUTONACK] bit: if AUTONACK is set, then it will be Nacked; if +* AUTONACK is clear, then a SlvPending interrupt is generated. +*/ +FLEXCOMM_I2C_SLVCTL_AUTOACK_AUTOMATIC_ACK =1 , +}FLEXCOMM_I2C_SLVCTL_AUTOACK_Enum ; + +typedef enum { +/* In Automatic Mode, the expected next operation is an I2C write. */ +FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_I2C_WRITE =0 , +/* In Automatic Mode, the expected next operation is an I2C read. */ +FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_I2C_READ =1 , +}FLEXCOMM_I2C_SLVCTL_AUTOMATCHREAD_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR0_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR0_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR0_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR0_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR0_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR0_AUTONACK_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR1_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR1_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR1_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR1_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR1_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR1_AUTONACK_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR2_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR2_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR2_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR2_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR2_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR2_AUTONACK_Enum ; + +typedef enum { +/* Enabled. Slave Address n is enabled. */ +FLEXCOMM_I2C_SLVADR3_SADISABLE_ENABLED =0 , +/* Ignored. Slave Address n is ignored. */ +FLEXCOMM_I2C_SLVADR3_SADISABLE_DISABLED =1 , +}FLEXCOMM_I2C_SLVADR3_SADISABLE_Enum ; + +typedef enum { +/* Normal operation, matching I2C addresses are not ignored. */ +FLEXCOMM_I2C_SLVADR3_AUTONACK_NORMAL =0 , +/* +* Automatic-only mode. All incoming addresses are ignored (NACKed), unless +* AUTOACK is set, and the address matches SLVADRn, and AUTOMATCHREAD +* matches the direction. +*/ +FLEXCOMM_I2C_SLVADR3_AUTONACK_AUTOMATIC =1 , +}FLEXCOMM_I2C_SLVADR3_AUTONACK_Enum ; + +typedef enum { +/* +* Mask. The SLVQUAL0 field is used as a logical mask for matching address +* 0. +*/ +FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_MASK =0 , +/* +* Extend. The SLVQUAL0 field is used to extend address 0 matching in a +* range of addresses. +*/ +FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_EXTEND =1 , +}FLEXCOMM_I2C_SLVQUAL0_QUALMODE0_Enum ; + +typedef enum { +/* +* No start detected. The Monitor function has not detected a Start event +* on the I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONSTART_NO_START_DETECTED =0 , +/* +* Start detected. The Monitor function has detected a Start event on the +* I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONSTART_START_DETECTED =1 , +}FLEXCOMM_I2C_MONRXDAT_MONSTART_Enum ; + +typedef enum { +/* +* No repeated start detected. The Monitor function has not detected a +* Repeated Start event on the I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONRESTART_NOT_DETECTED =0 , +/* +* Repeated start detected. The Monitor function has detected a Repeated +* Start event on the I2C bus. +*/ +FLEXCOMM_I2C_MONRXDAT_MONRESTART_DETECTED =1 , +}FLEXCOMM_I2C_MONRXDAT_MONRESTART_Enum ; + +typedef enum { +/* +* Acknowledged. The data currently being provided by the Monitor function +* was acknowledged by at least one master or slave receiver. +*/ +FLEXCOMM_I2C_MONRXDAT_MONNACK_ACKNOWLEDGED =0 , +/* +* Not acknowledged. The data currently being provided by the Monitor +* function was not acknowledged by any receiver. +*/ +FLEXCOMM_I2C_MONRXDAT_MONNACK_NOT_ACKNOWLEDGED =1 , +}FLEXCOMM_I2C_MONRXDAT_MONNACK_Enum ; + + +#define FLEXCOMM_I2C_REGISTER_ACCESS_INFO_ARRAY (_name) \ + struct RegisterAccessInfo _name[FLEXCOMM_I2C_REGS_NO] = { \ + [0 ... FLEXCOMM_I2C_REGS_NO - 1] = { \ + .name = "", \ + .addr = -1, \ + }, \ + [R_FLEXCOMM_I2C_CFG] = { \ + .name = "CFG", \ + .addr = 0x800, \ + .ro = 0xFFFFFFC0, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_STAT] = { \ + .name = "STAT", \ + .addr = 0x804, \ + .ro = 0xFCF57FAF, \ + .reset = 0x801, \ + }, \ + [R_FLEXCOMM_I2C_INTENSET] = { \ + .name = "INTENSET", \ + .addr = 0x808, \ + .ro = 0xFCF476AE, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_INTENCLR] = { \ + .name = "INTENCLR", \ + .addr = 0x80C, \ + .ro = 0xFCF476AE, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_TIMEOUT] = { \ + .name = "TIMEOUT", \ + .addr = 0x810, \ + .ro = 0xFFFF0000, \ + .reset = 0xFFFF, \ + }, \ + [R_FLEXCOMM_I2C_CLKDIV] = { \ + .name = "CLKDIV", \ + .addr = 0x814, \ + .ro = 0xFFFF0000, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_INTSTAT] = { \ + .name = "INTSTAT", \ + .addr = 0x818, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x801, \ + }, \ + [R_FLEXCOMM_I2C_MSTCTL] = { \ + .name = "MSTCTL", \ + .addr = 0x820, \ + .ro = 0xFFFFFFF0, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_MSTTIME] = { \ + .name = "MSTTIME", \ + .addr = 0x824, \ + .ro = 0xFFFFFF88, \ + .reset = 0x77, \ + }, \ + [R_FLEXCOMM_I2C_MSTDAT] = { \ + .name = "MSTDAT", \ + .addr = 0x828, \ + .ro = 0xFFFFFF00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVCTL] = { \ + .name = "SLVCTL", \ + .addr = 0x840, \ + .ro = 0xFFFFFCF4, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVDAT] = { \ + .name = "SLVDAT", \ + .addr = 0x844, \ + .ro = 0xFFFFFF00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR0] = { \ + .name = "SLVADR0", \ + .addr = 0x848, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR1] = { \ + .name = "SLVADR1", \ + .addr = 0x84C, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR2] = { \ + .name = "SLVADR2", \ + .addr = 0x850, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVADR3] = { \ + .name = "SLVADR3", \ + .addr = 0x854, \ + .ro = 0xFFFF7F00, \ + .reset = 0x1, \ + }, \ + [R_FLEXCOMM_I2C_SLVQUAL0] = { \ + .name = "SLVQUAL0", \ + .addr = 0x858, \ + .ro = 0xFFFFFF00, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_MONRXDAT] = { \ + .name = "MONRXDAT", \ + .addr = 0x880, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_I2C_ID] = { \ + .name = "ID", \ + .addr = 0xFFC, \ + .ro = 0xFFFFFFFF, \ + .reset = 0xE0301300, \ + }, \ + }include/hw/i2c/flexcomm_i2c.h new file +40
-0@@ -0,0 +1,40 @@ +/* +* QEMU model for NXP's FLEXCOMM I2C +* +* Copyright (c) 2024 Google LLC +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef HW_FLEXCOMM_I2C_H +#define HW_FLEXCOMM_I2C_H + +#include "hw/i2c/i2c.h" +#include "hw/misc/flexcomm_function.h" + +#define TYPE_FLEXCOMM_I2C "flexcomm-i2c" +OBJECT_DECLARE_TYPE (FlexcommI2cState, FlexcommI2cClass,FLEXCOMM_I2C ); + +struct FlexcommI2cState { +FlexcommFunction parent_obj; + +I2CBus *bus; +}; + +struct FlexcommI2cClass { +FlexcommFunctionClass parent_obj; + +FlexcommFunctionSelect select; +}; + +#define MSTSTATE_IDLE 0 +#define MSTSTATE_RXRDY 1 +#define MSTSTATE_TXRDY 2 +#define MSTSTATE_NAKADR 3 +#define MSTSTATE_NAKDAT 4 + + +#endif /* HW_FLEXCOMM_I2C_H */ include/hw/misc/flexcomm.h +2
-0@@ -16,6 +16,7 @@#include "hw/arm/svd/flexcomm.h" #include "qemu/fifo32.h" #include "hw/char/flexcomm_usart.h" +#include "hw/i2c/flexcomm_i2c.h" #define FLEXCOMM_FUNC_USART 0#define FLEXCOMM_FUNC_SPI 1@@ -48,6 +49,7 @@ struct FlexcommState {Fifo32 rx_fifo;Fifo32 tx_fifo;FlexcommUsartState usart; + FlexcommI2cState i2c; };#endif /* HW_FLEXCOMM_H */ hw/i2c/flexcomm_i2c.c new file +250
-0@@ -0,0 +1,250 @@ +/* +* QEMU model for NXP's FLEXCOMM I2C +* +* Copyright (c) 2024 Google LLC +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "exec/address-spaces.h" +#include "qapi/error.h" +#include "trace.h" +#include "hw/i2c/flexcomm_i2c.h" +#include "hw/arm/svd/flexcomm_i2c.h" + +#define REG (s, reg) (s->regs[R_FLEXCOMM_I2C_##reg]) +#define RF_WR (s, reg, field, val) \ + ARRAY_FIELD_DP32(s->regs, FLEXCOMM_I2C_##reg, field, val) +#define RF_RD (s, reg, field) \ + ARRAY_FIELD_EX32(s->regs, FLEXCOMM_I2C_##reg, field) + +static FLEXCOMM_I2C_REGISTER_ACCESS_INFO_ARRAY (reg_info); + +static void flexcomm_i2c_reset (FlexcommFunction *f) +{ +for (int i =0 ; i <FLEXCOMM_I2C_REGS_NO ; i++) { +hwaddr addr = reg_info[i].addr; + +if (addr !=-1 ) { +struct RegisterInfo ri = { + .data = &f->regs[addr /4 ], + .data_size =4 , + .access = ®_info[i], + }; + +register_reset (&ri); + } + } +} + +static void flexcomm_i2c_irq_update (FlexcommFunction *f) +{ +bool enabled =RF_RD (f,CFG ,MSTEN ); +bool irq, per_irqs; + +REG (f,INTSTAT ) =REG (f,STAT ) ® (f,INTENSET ); + per_irqs =REG (f,INTSTAT ) !=0 ; + + irq = enabled && per_irqs; + +trace_flexcomm_i2c_irq (DEVICE (f)->id, irq, per_irqs, enabled); +flexcomm_set_irq (f, irq); +} + +static MemTxResult flexcomm_i2c_reg_read (void *opaque,hwaddr addr, +uint64_t *data,unsigned size, +MemTxAttrs attrs) +{ +FlexcommFunction *f =FLEXCOMM_FUNCTION (opaque); +MemTxResult ret =MEMTX_OK ; +const struct RegisterAccessInfo *rai = ®_info[addr /4 ]; + +if (size !=4 ) { + ret =MEMTX_ERROR ; + goto out; + } + + *data = f->regs[addr /4 ]; + +flexcomm_i2c_irq_update (f); + +out: +trace_flexcomm_i2c_reg_read (DEVICE (f)->id, rai->name, addr, *data); +return ret; +} + +static MemTxResult flexcomm_i2c_reg_write (void *opaque,hwaddr addr, +uint64_t value,unsigned size, +MemTxAttrs attrs) +{ +FlexcommFunction *f =FLEXCOMM_FUNCTION (opaque); +FlexcommI2cState *s =FLEXCOMM_I2C (opaque); +const struct RegisterAccessInfo *rai = ®_info[addr /4 ]; +struct RegisterInfo ri = { + .data = &f->regs[addr /4 ], + .data_size =4 , + .access = rai, + }; + +trace_flexcomm_i2c_reg_write (DEVICE (f)->id, rai->name, addr, value); + +if (size !=4 ) { +return MEMTX_ERROR ; + } + +switch (addr) { +case A_FLEXCOMM_I2C_CFG : + { +register_write (&ri, value, ~0 ,NULL , false); +if (RF_RD (f,CFG ,SLVEN )) { +qemu_log_mask (LOG_GUEST_ERROR ,"I2C slave not supported" ); + } +if (RF_RD (f,CFG ,MONEN )) { +qemu_log_mask (LOG_GUEST_ERROR ,"I2C monitoring not supported" ); + } +break ; + } +case A_FLEXCOMM_I2C_INTENCLR : + { +REG (f,INTENSET ) &= ~value; +break ; + } +case A_FLEXCOMM_I2C_TIMEOUT : + { +register_write (&ri, value, ~0 ,NULL , false); +/* The bottom 4 bits are hard-wired to 0xF */ +RF_WR (f,TIMEOUT ,TOMIN ,0xf ); +break ; + } +case A_FLEXCOMM_I2C_MSTCTL : + { +register_write (&ri, value, ~0 ,NULL , false); +if (RF_RD (f,MSTCTL ,MSTSTART )) { +uint8_t i2c_addr =RF_RD (f,MSTDAT ,DATA ); +bool recv = i2c_addr &1 ; + +trace_flexcomm_i2c_start (DEVICE (s)->id, i2c_addr, recv); +if (i2c_start_transfer (s->bus, i2c_addr, recv)) { +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_NAKADR ); +trace_flexcomm_i2c_nak (DEVICE (s)->id); + }else { +if (recv) { +uint8_t data =i2c_recv (s->bus); + +RF_WR (f,MSTDAT ,DATA , data); +trace_flexcomm_i2c_rx (DEVICE (s)->id, data); +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_RXRDY ); + }else { +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_TXRDY ); + } + } + } +if (RF_RD (f,MSTCTL ,MSTSTOP )) { +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_IDLE ); +i2c_end_transfer (s->bus); + } +if (RF_RD (f,MSTCTL ,MSTCONTINUE )) { +if (RF_RD (f,STAT ,MSTSTATE ) ==MSTSTATE_TXRDY ) { +uint8_t data =RF_RD (f,MSTDAT ,DATA ); + +trace_flexcomm_i2c_tx (DEVICE (s)->id, data); +if (i2c_send (s->bus, data)) { +RF_WR (f,STAT ,MSTSTATE ,MSTSTATE_NAKDAT ); + } + }else if (RF_RD (f,STAT ,MSTSTATE ) ==MSTSTATE_RXRDY ) { +uint8_t data =i2c_recv (s->bus); + +RF_WR (f,MSTDAT ,DATA , data); +trace_flexcomm_i2c_rx (DEVICE (s)->id, data); + } + } +break ; + } +case A_FLEXCOMM_I2C_STAT : + { +/* write 1 to clear bits */ +REG (f,STAT ) &= ~value; +break ; + } +case A_FLEXCOMM_I2C_SLVCTL : +case A_FLEXCOMM_I2C_SLVDAT : +case A_FLEXCOMM_I2C_SLVADR0 : +case A_FLEXCOMM_I2C_SLVADR1 : +case A_FLEXCOMM_I2C_SLVADR2 : +case A_FLEXCOMM_I2C_SLVADR3 : +case A_FLEXCOMM_I2C_SLVQUAL0 : + { +qemu_log_mask (LOG_GUEST_ERROR ,"I2C slave not supported\n" ); +break ; + } +default : +register_write (&ri, value, ~0 ,NULL , false); +break ; + } + +flexcomm_i2c_irq_update (f); + +return MEMTX_OK ; +} + +static void flexcomm_i2c_select (FlexcommFunction *f,bool selected) +{ +FlexcommI2cClass *ic =FLEXCOMM_I2C_GET_CLASS (f); + +if (selected) { +flexcomm_i2c_reset (f); + } + ic->select (f, selected); +} + +static const MemoryRegionOps flexcomm_i2c_ops = { + .read_with_attrs = flexcomm_i2c_reg_read, + .write_with_attrs = flexcomm_i2c_reg_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .valid = { + .min_access_size =4 , + .max_access_size =4 , + .unaligned = false, + }, +}; + +static void flexcomm_i2c_realize (DeviceState *dev,Error **errp) +{ +FlexcommI2cState *s =FLEXCOMM_I2C (dev); + + s->bus =i2c_init_bus (DEVICE (s),"bus" ); +} + +static void flexcomm_i2c_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +FlexcommFunctionClass *fc =FLEXCOMM_FUNCTION_CLASS (klass); +FlexcommI2cClass *ic =FLEXCOMM_I2C_CLASS (klass); + + dc->realize = flexcomm_i2c_realize; + ic->select = fc->select; + fc->select = flexcomm_i2c_select; + fc->name ="i2c" ; + fc->mmio_ops = &flexcomm_i2c_ops; +} + +static const TypeInfo flexcomm_i2c_types[] = { + { + .name =TYPE_FLEXCOMM_I2C , + .parent =TYPE_FLEXCOMM_FUNCTION , + .instance_size =sizeof (FlexcommI2cState), + .class_init = flexcomm_i2c_class_init, + .class_size =sizeof (FlexcommI2cClass), + }, +}; + +DEFINE_TYPES (flexcomm_i2c_types);hw/misc/flexcomm.c +3
-0@@ -24,6 +24,7 @@#include "hw/misc/flexcomm.h" #include "hw/arm/svd/flexcomm_usart.h" #include "hw/char/flexcomm_usart.h" +#include "hw/i2c/flexcomm_i2c.h" #define REG (s, reg) (s->regs[R_FLEXCOMM_##reg])#define RF_WR (s, reg, field, val) \@@ -220,6 +221,7 @@ static void flexcomm_init(Object *obj)sysbus_init_mmio (SYS_BUS_DEVICE (obj), &s->container);sysbus_init_irq (sbd, &s->irq);object_initialize_child (obj,"usart" , &s->usart,TYPE_FLEXCOMM_USART ); +object_initialize_child (obj,"i2c" , &s->i2c,TYPE_FLEXCOMM_I2C ); }static void flexcomm_finalize (Object *obj)@@ -250,6 +252,7 @@ static void flexcomm_realize(DeviceState *dev, Error **errp)memory_region_add_subregion_overlap (&s->container,0 , &s->mmio,-1 );flexcomm_func_realize_and_unref (FLEXCOMM_FUNCTION (&s->usart), errp); +flexcomm_func_realize_and_unref (FLEXCOMM_FUNCTION (&s->i2c), errp); }static const VMStateDescription vmstate_flexcomm = {hw/arm/svd/meson.build +3
-0@@ -7,4 +7,7 @@ if get_option('mcux-soc-svd') run_target('svd-flexcomm-usart', command: svd_gen_header + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_usart.h', '-p', 'USART0', '-t', 'FLEXCOMM_USART']) + run_target('svd-flexcomm-i2c', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_i2c.h', + '-p', 'I2C0', '-t', 'FLEXCOMM_I2C']) endifhw/i2c/meson.build +1
-0@@ -18,4 +18,5 @@ i2c_ss.add(when: 'CONFIG_PPC4XX', if_true: files('ppc4xx_i2c.c')) i2c_ss.add(when: 'CONFIG_PCA954X', if_true: files('i2c_mux_pca954x.c')) i2c_ss.add(when: 'CONFIG_PMBUS', if_true: files('pmbus_device.c')) i2c_ss.add(when: 'CONFIG_BCM2835_I2C', if_true: files('bcm2835_i2c.c')) +i2c_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm_i2c.c')) system_ss.add_all(when: 'CONFIG_I2C', if_true: i2c_ss)hw/i2c/trace-events +10
-0@@ -51,3 +51,13 @@ npcm7xx_smbus_recv_fifo(const char *id, uint8_t received, uint8_t expected) "%s pca954x_write_bytes(uint8_t value) "PCA954X write data: 0x%02x" pca954x_read_data(uint8_t value) "PCA954X read data: 0x%02x" + +# flexcomm_i2c.c + +flexcomm_i2c_reg_read(const char *id, const char *reg_name, uint32_t addr, uint32_t val) " %s: %s[0x%04x] -> 0x%08x" +flexcomm_i2c_reg_write(const char *id, const char *reg_name, uint32_t addr, uint32_t val) "%s: %s[0x%04x] <- 0x%08x" +flexcomm_i2c_start(const char *id, uint8_t addr, uint8_t recv) "%s: 0x%02x %d" +flexcomm_i2c_rx(const char *id, uint8_t data) "%s: <- 0x%02x" +flexcomm_i2c_tx(const char *id, uint8_t data) "%s: -> 0x%02x" +flexcomm_i2c_nak(const char *id) "%s: <- nak" +flexcomm_i2c_irq(const char *id, bool irq, bool perirqs, bool enabled) "%s: %d %d %d"hw/misc/Kconfig +1
-1@@ -215,5 +215,6 @@ config XLNX_VERSAL_TRNG config FLEXCOMM bool + select I2C source macio/Kconfig --2.46.0.662.g92d0881bb0-goog
Re: [PATCH 08/25] hw/i2c: add support for flexcomm i2c
In reply to Corey MinyardQuoted 7 lines · Corey Minyard
Generally it's frowned upon to have a ton of extra stuff that's not used. I would think some is ok, like defining bits in registers that aren't used yet, but I have no idea how all the enums below here actually tie into anything. I'm guessing these are just bitmasks into registers, but really, it's a lot easier to read if you have something like:
Quoted 6 lines
/*
* The I2C Master function enable. When disabled, the Master
* configuration settings are not changed, but the Master function is
* internally reset.
*/
#defineFLEXCOMM_I2C_CFG_MSTEN(1 << 4)
The FIELD macro already gives you that:
FIELD(FLEXCOMM_I2C_CFG, MSTEN, startbit, len);
will define an R_FLEXCOMM_I2C_CFG_MSTEN_MASK (which is (1 << startbit) for the 'len == 1' case).
You can also set and read a 1 bit field the same as any other, with the FIELD_DP32/FIELD_EX32 macros, so you don't often need to directly use the MASK macro:
s->cfg = FIELD_DP32(s->cfg, CFG, MSTEN, 1);
and
if (FIELD_EX32(s->cfg, CFG, MSTEN)) {
...}
The FIELD() macros are a bit unwieldy sometimes but the advantage over ad-hoc #defines is that they're consistent for every field in every register.
I agree that providing enums for the possible values for 1-bit fields is a bit superfluous.
thanks
-- PMM
Re: [PATCH 08/25] hw/i2c: add support for flexcomm i2c
Quoted 28 lines · Peter Maydell
Quoted 7 lines · Corey Minyard
Generally it's frowned upon to have a ton of extra stuff that's not used. I would think some is ok, like defining bits in registers that aren't used yet, but I have no idea how all the enums below here actually tie into anything. I'm guessing these are just bitmasks into registers, but really, it's a lot easier to read if you have something like:
Quoted 6 lines
/*
* The I2C Master function enable. When disabled, the Master
* configuration settings are not changed, but the Master function is
* internally reset.
*/
#defineFLEXCOMM_I2C_CFG_MSTEN(1 << 4)The FIELD macro already gives you that:
FIELD(FLEXCOMM_I2C_CFG, MSTEN, startbit, len);
will define anR_FLEXCOMM_I2C_CFG_MSTEN_MASK(which is (1 << startbit) for the 'len == 1' case).You can also set and read a 1 bit field the same as any other, with the FIELD_DP32/FIELD_EX32 macros, so you don't often need to directly use the MASK macro:
s->cfg=FIELD_DP32(s->cfg, CFG, MSTEN, 1);
andif (FIELD_EX32(s->cfg, CFG, MSTEN)) { ...
Quoted 9 lines
}
The
FIELD()macros are a bit unwieldy sometimes but the advantage over ad-hoc #defines is that they're consistent for every field in every register.I agree that providing enums for the possible values for 1-bit fields is a bit superfluous.
I went ahead and removed those 1-bit enum values and added support to filter register/fields when generating the code. Also converted the enums to defines to make these a little bit more compact as I don't think we have any advantage over the enums?
So with the following invocation:
run_target('svd-flexcomm-i2c', command: svd_gen_header +
[ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_i2c.h',
'-p', 'I2C0', '-t', 'FLEXCOMM_I2C',
'--fields', 'CFG TIMEOUT:TOMIN MSTCTL MSTDATSTAT:MSTPENDING,MSTSTATE INT*:MSTPENDING* SLV*:'])
I am getting the below generated file. Note that the register info is generated for all registers because this information is used to initialize the reset values, mask writes appropriately in registers and trace register access.
Please let me know if this looks good or if there are any other tweaks I could make.
/*
* Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause *
* Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml */
#pragma once
#include "hw/register.h"
/* I2C Bus Interface */
#define FLEXCOMM_I2C_REGS_NO (1024)
/* Configuration Register */REG32(FLEXCOMM_I2C_CFG, 0x800);
/* Master Enable */FIELD(FLEXCOMM_I2C_CFG, MSTEN, 0, 1);
/* Slave Enable */FIELD(FLEXCOMM_I2C_CFG, SLVEN, 1, 1);
/* Monitor Enable */FIELD(FLEXCOMM_I2C_CFG, MONEN, 2, 1);
/* I2C bus Time-out Enable */FIELD(FLEXCOMM_I2C_CFG, TIMEOUTEN, 3, 1);
/* Monitor function Clock Stretching */FIELD(FLEXCOMM_I2C_CFG, MONCLKSTR, 4, 1);
/* High Speed mode Capable enable */FIELD(FLEXCOMM_I2C_CFG, HSCAPABLE, 5, 1);
/* Status Register */REG32(FLEXCOMM_I2C_STAT, 0x804);
/* Master Pending */FIELD(FLEXCOMM_I2C_STAT, MSTPENDING, 0, 1);
/* Master State code */FIELD(FLEXCOMM_I2C_STAT, MSTSTATE, 1, 3);
/* Idle. The Master function is available to be used for a new transaction. */ #define FLEXCOMM_I2C_STAT_MSTSTATE_IDLE 0
/*
* Receive ready. Received data is available (in Master Receiver mode). Address
* plus Read was previously sent and Acknowledged by a slave.
*/
#define FLEXCOMM_I2C_STAT_MSTSTATE_RECEIVE_READY 1
/*
* Transmit ready. Data can be transmitted (in Master Transmitter mode).
* Address plus Write was previously sent and Acknowledged by a slave. */
#define FLEXCOMM_I2C_STAT_MSTSTATE_TRANSMIT_READY 2
/* NACK Address. Slave NACKed address. */
#define FLEXCOMM_I2C_STAT_MSTSTATE_NACK_ADDRESS 3
/* NACK Data. Slave NACKed transmitted data. */
#define FLEXCOMM_I2C_STAT_MSTSTATE_NACK_DATA 4
/* Interrupt Enable Set Register */REG32(FLEXCOMM_I2C_INTENSET, 0x808);
/* Master Pending interrupt Enable */FIELD(FLEXCOMM_I2C_INTENSET, MSTPENDINGEN, 0, 1);
/* Interrupt Enable Clear Register */ REG32(FLEXCOMM_I2C_INTENCLR, 0x80C);
/* Master Pending interrupt clear */ FIELD(FLEXCOMM_I2C_INTENCLR, MSTPENDINGCLR, 0, 1);
/* Time-out Register */REG32(FLEXCOMM_I2C_TIMEOUT, 0x810);
/* Time-out time value, the bottom 4 bits */FIELD(FLEXCOMM_I2C_TIMEOUT, TOMIN, 0, 4);
/* Interrupt Status Register */REG32(FLEXCOMM_I2C_INTSTAT, 0x818);
/* Master Pending */FIELD(FLEXCOMM_I2C_INTSTAT, MSTPENDING, 0, 1);
/* Master Control Register */REG32(FLEXCOMM_I2C_MSTCTL, 0x820);
/* Master Continue(write-only) */FIELD(FLEXCOMM_I2C_MSTCTL, MSTCONTINUE, 0, 1);
/* Master Start control(write-only) */FIELD(FLEXCOMM_I2C_MSTCTL, MSTSTART, 1, 1);
/* Master Stop control(write-only) */FIELD(FLEXCOMM_I2C_MSTCTL, MSTSTOP, 2, 1);
/* Master DMA enable */FIELD(FLEXCOMM_I2C_MSTCTL, MSTDMA, 3, 1);
/* Master Data Register */REG32(FLEXCOMM_I2C_MSTDAT, 0x828);
/* Master function data register */FIELD(FLEXCOMM_I2C_MSTDAT, DATA, 0, 8);
/* Slave Control Register */REG32(FLEXCOMM_I2C_SLVCTL, 0x840);
/* Slave Data Register */REG32(FLEXCOMM_I2C_SLVDAT, 0x844);
/* Slave Address Register */REG32(FLEXCOMM_I2C_SLVADR0, 0x848);
/* Slave Address Register */REG32(FLEXCOMM_I2C_SLVADR1, 0x84C);
/* Slave Address Register */REG32(FLEXCOMM_I2C_SLVADR2, 0x850);
/* Slave Address Register */REG32(FLEXCOMM_I2C_SLVADR3, 0x854);
/* Slave Qualification for Address 0 Register */REG32(FLEXCOMM_I2C_SLVQUAL0, 0x858);
#define FLEXCOMM_I2C_REGISTER_ACCESS_INFO_ARRAY(_name) \
struct RegisterAccessInfo _name[FLEXCOMM_I2C_REGS_NO] = { \
[0 ... FLEXCOMM_I2C_REGS_NO - 1] = { \
.name = "", \
.addr = -1, \
}, \
[0x200] = { \
.name = "CFG", \
.addr = 0x800, \
.ro = 0xFFFFFFC0, \
.reset = 0x0, \
}, \
[0x201] = { \
.name = "STAT", \
.addr = 0x804, \
.ro = 0xFCF57FAF, \
.reset = 0x801, \
}, \
[0x202] = { \
.name = "INTENSET", \
.addr = 0x808, \
.ro = 0xFCF476AE, \
.reset = 0x0, \
}, \
[0x203] = { \
.name = "INTENCLR", \
.addr = 0x80C, \
.ro = 0xFCF476AE, \
.reset = 0x0, \
}, \
[0x204] = { \
.name = "TIMEOUT", \
.addr = 0x810, \
.ro = 0xFFFF0000, \
.reset = 0xFFFF, \
}, \
[0x205] = { \
.name = "CLKDIV", \
.addr = 0x814, \
.ro = 0xFFFF0000, \
.reset = 0x0, \
}, \
[0x206] = { \
.name = "INTSTAT", \
.addr = 0x818, \
.ro = 0xFFFFFFFF, \
.reset = 0x801, \
}, \
[0x208] = { \
.name = "MSTCTL", \
.addr = 0x820, \
.ro = 0xFFFFFFF0, \
.reset = 0x0, \
}, \
[0x209] = { \
.name = "MSTTIME", \
.addr = 0x824, \
.ro = 0xFFFFFF88, \
.reset = 0x77, \
}, \
[0x20A] = { \
.name = "MSTDAT", \
.addr = 0x828, \
.ro = 0xFFFFFF00, \
.reset = 0x0, \
}, \
[0x210] = { \
.name = "SLVCTL", \
.addr = 0x840, \
.ro = 0xFFFFFCF4, \
.reset = 0x0, \
}, \
[0x211] = { \
.name = "SLVDAT", \
.addr = 0x844, \
.ro = 0xFFFFFF00, \
.reset = 0x0, \
}, \
[0x212] = { \
.name = "SLVADR0", \
.addr = 0x848, \
.ro = 0xFFFF7F00, \
.reset = 0x1, \
}, \
[0x213] = { \
.name = "SLVADR1", \
.addr = 0x84C, \
.ro = 0xFFFF7F00, \
.reset = 0x1, \
}, \
[0x214] = { \
.name = "SLVADR2", \
.addr = 0x850, \
.ro = 0xFFFF7F00, \
.reset = 0x1, \
}, \
[0x215] = { \
.name = "SLVADR3", \
.addr = 0x854, \
.ro = 0xFFFF7F00, \
.reset = 0x1, \
}, \
[0x216] = { \
.name = "SLVQUAL0", \
.addr = 0x858, \
.ro = 0xFFFFFF00, \
.reset = 0x0, \
}, \
[0x220] = { \
.name = "MONRXDAT", \
.addr = 0x880, \
.ro = 0xFFFFFFFF, \
.reset = 0x0, \
}, \
[0x3FF] = { \
.name = "ID", \
.addr = 0xFFC, \
.ro = 0xFFFFFFFF, \
.reset = 0xE0301300, \
}, \
}Re: [PATCH 08/25] hw/i2c: add support for flexcomm i2c
Thanks, this all looks good to me. And FIELD() is the right way to go, as Peter said.
-corey
Quoted 290 lines · Octavian Purdila
Quoted 28 lines · Peter Maydell
Quoted 7 lines · Corey Minyard
Generally it's frowned upon to have a ton of extra stuff that's not used. I would think some is ok, like defining bits in registers that aren't used yet, but I have no idea how all the enums below here actually tie into anything. I'm guessing these are just bitmasks into registers, but really, it's a lot easier to read if you have something like:
Quoted 6 lines
/*
* The I2C Master function enable. When disabled, the Master
* configuration settings are not changed, but the Master function is
* internally reset.
*/
#defineFLEXCOMM_I2C_CFG_MSTEN(1 << 4)The FIELD macro already gives you that:
FIELD(FLEXCOMM_I2C_CFG, MSTEN, startbit, len);
will define anR_FLEXCOMM_I2C_CFG_MSTEN_MASK(which is (1 << startbit) for the 'len == 1' case).You can also set and read a 1 bit field the same as any other, with the FIELD_DP32/FIELD_EX32 macros, so you don't often need to directly use the MASK macro:
s->cfg=FIELD_DP32(s->cfg, CFG, MSTEN, 1);
andif (FIELD_EX32(s->cfg, CFG, MSTEN)) { ...Quoted 9 lines
}
The
FIELD()macros are a bit unwieldy sometimes but the advantage over ad-hoc #defines is that they're consistent for every field in every register.I agree that providing enums for the possible values for 1-bit fields is a bit superfluous.
I went ahead and removed those 1-bit enum values and added support to filter register/fields when generating the code. Also converted the enums to defines to make these a little bit more compact as I don't think we have any advantage over the enums?
So with the following invocation:
run_target('svd-flexcomm-i2c', command:
svd_gen_header+[ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_i2c.h', '-p', 'I2C0', '-t', 'FLEXCOMM_I2C', '--fields', 'CFG TIMEOUT:TOMIN MSTCTL MSTDATSTAT:MSTPENDING,MSTSTATE INT*:MSTPENDING* SLV*:'])
I am getting the below generated file. Note that the register info is generated for all registers because this information is used to initialize the reset values, mask writes appropriately in registers and trace register access.
Please let me know if this looks good or if there are any other tweaks I could make.
/*
* Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause *
* Automatically generated bysvd-gen-header.pyfrom MIMXRT595S_cm33.xml */
#pragma once#include "
hw/register.h"/* I2C Bus Interface */
#defineFLEXCOMM_I2C_REGS_NO(1024)/* Configuration Register */
REG32(FLEXCOMM_I2C_CFG, 0x800);
/* Master Enable */FIELD(FLEXCOMM_I2C_CFG, MSTEN, 0, 1);
/* Slave Enable */FIELD(FLEXCOMM_I2C_CFG, SLVEN, 1, 1);
/* Monitor Enable */FIELD(FLEXCOMM_I2C_CFG, MONEN, 2, 1);
/* I2C bus Time-out Enable */FIELD(FLEXCOMM_I2C_CFG, TIMEOUTEN, 3, 1);
/* Monitor function Clock Stretching */FIELD(FLEXCOMM_I2C_CFG, MONCLKSTR, 4, 1);
/* High Speed mode Capable enable */FIELD(FLEXCOMM_I2C_CFG, HSCAPABLE, 5, 1);/* Status Register */
REG32(FLEXCOMM_I2C_STAT, 0x804);
/* Master Pending */FIELD(FLEXCOMM_I2C_STAT, MSTPENDING, 0, 1);
/* Master State code */FIELD(FLEXCOMM_I2C_STAT, MSTSTATE, 1, 3);
/* Idle. The Master function is available to be used for a new transaction. */ #defineFLEXCOMM_I2C_STAT_MSTSTATE_IDLE0
/*
* Receive ready. Received data is available (in Master Receiver mode). Address
* plus Read was previously sent and Acknowledged by a slave.
*/
#defineFLEXCOMM_I2C_STAT_MSTSTATE_RECEIVE_READY1
/*
* Transmit ready. Data can be transmitted (in Master Transmitter mode).
* Address plus Write was previously sent and Acknowledged by a slave. */
#defineFLEXCOMM_I2C_STAT_MSTSTATE_TRANSMIT_READY2
/* NACK Address. Slave NACKed address. */
#defineFLEXCOMM_I2C_STAT_MSTSTATE_NACK_ADDRESS3
/* NACK Data. Slave NACKed transmitted data. */
#defineFLEXCOMM_I2C_STAT_MSTSTATE_NACK_DATA4/* Interrupt Enable Set Register */
REG32(FLEXCOMM_I2C_INTENSET, 0x808);
/* Master Pending interrupt Enable */FIELD(FLEXCOMM_I2C_INTENSET, MSTPENDINGEN, 0, 1);/* Interrupt Enable Clear Register */
REG32(FLEXCOMM_I2C_INTENCLR, 0x80C);
/* Master Pending interrupt clear */FIELD(FLEXCOMM_I2C_INTENCLR, MSTPENDINGCLR, 0, 1);/* Time-out Register */
REG32(FLEXCOMM_I2C_TIMEOUT, 0x810);
/* Time-out time value, the bottom 4 bits */FIELD(FLEXCOMM_I2C_TIMEOUT, TOMIN, 0, 4);/* Interrupt Status Register */
REG32(FLEXCOMM_I2C_INTSTAT, 0x818);
/* Master Pending */FIELD(FLEXCOMM_I2C_INTSTAT, MSTPENDING, 0, 1);/* Master Control Register */
REG32(FLEXCOMM_I2C_MSTCTL, 0x820);
/* Master Continue(write-only) */FIELD(FLEXCOMM_I2C_MSTCTL, MSTCONTINUE, 0, 1);
/* Master Start control(write-only) */FIELD(FLEXCOMM_I2C_MSTCTL, MSTSTART, 1, 1);
/* Master Stop control(write-only) */FIELD(FLEXCOMM_I2C_MSTCTL, MSTSTOP, 2, 1);
/* Master DMA enable */FIELD(FLEXCOMM_I2C_MSTCTL, MSTDMA, 3, 1);/* Master Data Register */
REG32(FLEXCOMM_I2C_MSTDAT, 0x828);
/* Master function data register */FIELD(FLEXCOMM_I2C_MSTDAT, DATA, 0, 8);/* Slave Control Register */
REG32(FLEXCOMM_I2C_SLVCTL, 0x840);/* Slave Data Register */
REG32(FLEXCOMM_I2C_SLVDAT, 0x844);/* Slave Address Register */
REG32(FLEXCOMM_I2C_SLVADR0, 0x848);/* Slave Address Register */
REG32(FLEXCOMM_I2C_SLVADR1, 0x84C);/* Slave Address Register */
REG32(FLEXCOMM_I2C_SLVADR2, 0x850);/* Slave Address Register */
REG32(FLEXCOMM_I2C_SLVADR3, 0x854);/* Slave Qualification for Address 0 Register */
REG32(FLEXCOMM_I2C_SLVQUAL0, 0x858);#define FLEXCOMM_I2C_REGISTER_ACCESS_INFO_ARRAY(_name) \ struct RegisterAccessInfo _name[FLEXCOMM_I2C_REGS_NO] = { \ [0 ... FLEXCOMM_I2C_REGS_NO - 1] = { \ .name = "", \ .addr = -1, \ }, \ [0x200] = { \ .name = "CFG", \ .addr = 0x800, \ .ro = 0xFFFFFFC0, \ .reset = 0x0, \ }, \ [0x201] = { \ .name = "STAT", \ .addr = 0x804, \ .ro = 0xFCF57FAF, \ .reset = 0x801, \ }, \ [0x202] = { \ .name = "INTENSET", \ .addr = 0x808, \ .ro = 0xFCF476AE, \ .reset = 0x0, \ }, \ [0x203] = { \ .name = "INTENCLR", \ .addr = 0x80C, \ .ro = 0xFCF476AE, \ .reset = 0x0, \ }, \ [0x204] = { \ .name = "TIMEOUT", \ .addr = 0x810, \ .ro = 0xFFFF0000, \ .reset = 0xFFFF, \ }, \ [0x205] = { \ .name = "CLKDIV", \ .addr = 0x814, \ .ro = 0xFFFF0000, \ .reset = 0x0, \ }, \ [0x206] = { \ .name = "INTSTAT", \ .addr = 0x818, \ .ro = 0xFFFFFFFF, \ .reset = 0x801, \ }, \ [0x208] = { \ .name = "MSTCTL", \ .addr = 0x820, \ .ro = 0xFFFFFFF0, \ .reset = 0x0, \ }, \ [0x209] = { \ .name = "MSTTIME", \ .addr = 0x824, \ .ro = 0xFFFFFF88, \ .reset = 0x77, \ }, \ [0x20A] = { \ .name = "MSTDAT", \ .addr = 0x828, \ .ro = 0xFFFFFF00, \ .reset = 0x0, \ }, \ [0x210] = { \ .name = "SLVCTL", \ .addr = 0x840, \ .ro = 0xFFFFFCF4, \ .reset = 0x0, \ }, \ [0x211] = { \ .name = "SLVDAT", \ .addr = 0x844, \ .ro = 0xFFFFFF00, \ .reset = 0x0, \ }, \ [0x212] = { \ .name = "SLVADR0", \ .addr = 0x848, \ .ro = 0xFFFF7F00, \ .reset = 0x1, \ }, \ [0x213] = { \ .name = "SLVADR1", \ .addr = 0x84C, \ .ro = 0xFFFF7F00, \ .reset = 0x1, \ }, \ [0x214] = { \ .name = "SLVADR2", \ .addr = 0x850, \ .ro = 0xFFFF7F00, \ .reset = 0x1, \ }, \ [0x215] = { \ .name = "SLVADR3", \ .addr = 0x854, \ .ro = 0xFFFF7F00, \ .reset = 0x1, \ }, \ [0x216] = { \ .name = "SLVQUAL0", \ .addr = 0x858, \ .ro = 0xFFFFFF00, \ .reset = 0x0, \ }, \ [0x220] = { \ .name = "MONRXDAT", \ .addr = 0x880, \ .ro = 0xFFFFFFFF, \ .reset = 0x0, \ }, \ [0x3FF] = { \ .name = "ID", \ .addr = 0xFFC, \ .ro = 0xFFFFFFFF, \ .reset = 0xE0301300, \ }, \ }
PATCH 9/25 hw/ssi: add support for flexcomm spi
In reply to Octavian PurdilaFrom: Sebastian Ene <[email protected]>
Add support for NXP's flexcomm spi. It supports FIFO access, interrupts and master mode only. It does not support DMA.
The patch includes an automatically generated header which contains the register layout and helpers.
The header can be regenerated with the svd-flexcomm-spi target when the build is configured with --enable-mcux-soc-svd.
[tavip: add suport for CFG.SPOL, CFG.LSBF, TX control flags per FIFO entry and 8/16 bit access to FIFORD and FIFOWR, convert to Resettable interface, add support for migration]
--- include/hw/arm/svd/flexcomm_spi.h | 1036 +++++++++++++++++++++++++++++ include/hw/misc/flexcomm.h | 2 + include/hw/ssi/flexcomm_spi.h | 36 + hw/misc/flexcomm.c | 3 + hw/ssi/flexcomm_spi.c | 422 ++++++++++++ hw/arm/svd/meson.build | 3 + hw/misc/Kconfig | 1 + hw/ssi/meson.build | 1 + hw/ssi/trace-events | 5 + 9 files changed, 1509 insertions(+) create mode 100644 include/hw/arm/svd/flexcomm_spi.h create mode 100644 include/hw/ssi/flexcomm_spi.h create mode 100644 hw/ssi/flexcomm_spi.c
include/hw/arm/svd/flexcomm_spi.h new file +1036 -0
@@ -0,0 +1,1036 @@ +/* +* Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause +* +* Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml +*/ +#pragma once + +#include "hw/register.h" + +/* Serial Peripheral Interfaces (SPI) */ +#define FLEXCOMM_SPI_REGS_NO (1024) + +/* Configuration Register */ +REG32 (FLEXCOMM_SPI_CFG ,1024 ); +/* SPI Enable */ +FIELD (FLEXCOMM_SPI_CFG ,ENABLE ,0 ,1 ); +/* Master Mode Select */ +FIELD (FLEXCOMM_SPI_CFG ,MASTER ,2 ,1 ); +/* LSB First Mode Enable */ +FIELD (FLEXCOMM_SPI_CFG ,LSBF ,3 ,1 ); +/* Clock Phase Select */ +FIELD (FLEXCOMM_SPI_CFG ,CPHA ,4 ,1 ); +/* Clock Polarity Select */ +FIELD (FLEXCOMM_SPI_CFG ,CPOL ,5 ,1 ); +/* Loopback Mode Enable */ +FIELD (FLEXCOMM_SPI_CFG ,LOOP ,7 ,1 ); +/* SSEL0 Polarity Select */ +FIELD (FLEXCOMM_SPI_CFG ,SPOL0 ,8 ,1 ); +/* SSEL1 Polarity Select */ +FIELD (FLEXCOMM_SPI_CFG ,SPOL1 ,9 ,1 ); +/* SSEL2 Polarity Select */ +FIELD (FLEXCOMM_SPI_CFG ,SPOL2 ,10 ,1 ); +/* SSEL3 Polarity Select */ +FIELD (FLEXCOMM_SPI_CFG ,SPOL3 ,11 ,1 ); + +/* Delay Register */ +REG32 (FLEXCOMM_SPI_DLY ,1028 ); +/* Pre-Delay */ +FIELD (FLEXCOMM_SPI_DLY ,PRE_DELAY ,0 ,4 ); +/* Post-Delay */ +FIELD (FLEXCOMM_SPI_DLY ,POST_DELAY ,4 ,4 ); +/* Frame Delay */ +FIELD (FLEXCOMM_SPI_DLY ,FRAME_DELAY ,8 ,4 ); +/* Transfer Delay */ +FIELD (FLEXCOMM_SPI_DLY ,TRANSFER_DELAY ,12 ,4 ); + +/* Status Register */ +REG32 (FLEXCOMM_SPI_STAT ,1032 ); +/* Slave Select Assert */ +FIELD (FLEXCOMM_SPI_STAT ,SSA ,4 ,1 ); +/* Slave Select Deassert */ +FIELD (FLEXCOMM_SPI_STAT ,SSD ,5 ,1 ); +/* Stalled Status Flag */ +FIELD (FLEXCOMM_SPI_STAT ,STALLED ,6 ,1 ); +/* End Transfer Control */ +FIELD (FLEXCOMM_SPI_STAT ,ENDTRANSFER ,7 ,1 ); +/* Master Idle Status Flag */ +FIELD (FLEXCOMM_SPI_STAT ,MSTIDLE ,8 ,1 ); + +/* Interrupt Enable Register */ +REG32 (FLEXCOMM_SPI_INTENSET ,1036 ); +/* Slave Select Assert Interrupt Enable */ +FIELD (FLEXCOMM_SPI_INTENSET ,SSAEN ,4 ,1 ); +/* Slave Select Deassert Interrupt Enable */ +FIELD (FLEXCOMM_SPI_INTENSET ,SSDEN ,5 ,1 ); +/* Master Idle Interrupt Enable */ +FIELD (FLEXCOMM_SPI_INTENSET ,MSTIDLEEN ,8 ,1 ); + +/* Interrupt Enable Clear Register */ +REG32 (FLEXCOMM_SPI_INTENCLR ,1040 ); +/* Slave Select Assert Interrupt Enable */ +FIELD (FLEXCOMM_SPI_INTENCLR ,SSAEN ,4 ,1 ); +/* Slave Select Deassert Interrupt Enable */ +FIELD (FLEXCOMM_SPI_INTENCLR ,SSDEN ,5 ,1 ); +/* Master Idle Interrupt Enable */ +FIELD (FLEXCOMM_SPI_INTENCLR ,MSTIDLE ,8 ,1 ); + +/* Clock Divider Register */ +REG32 (FLEXCOMM_SPI_DIV ,1060 ); +/* Rate Divider Value */ +FIELD (FLEXCOMM_SPI_DIV ,DIVVAL ,0 ,16 ); + +/* Interrupt Status Register */ +REG32 (FLEXCOMM_SPI_INTSTAT ,1064 ); +/* Slave Select Assert Interrupt */ +FIELD (FLEXCOMM_SPI_INTSTAT ,SSA ,4 ,1 ); +/* Slave Select Deassert Interrupt */ +FIELD (FLEXCOMM_SPI_INTSTAT ,SSD ,5 ,1 ); +/* Master Idle Status Flag Interrupt */ +FIELD (FLEXCOMM_SPI_INTSTAT ,MSTIDLE ,8 ,1 ); + +/* FIFO Configuration Register */ +REG32 (FLEXCOMM_SPI_FIFOCFG ,3584 ); +/* Enable the Transmit FIFO */ +FIELD (FLEXCOMM_SPI_FIFOCFG ,ENABLETX ,0 ,1 ); +/* Enable the Receive FIFO */ +FIELD (FLEXCOMM_SPI_FIFOCFG ,ENABLERX ,1 ,1 ); +/* FIFO Size Configuration */ +FIELD (FLEXCOMM_SPI_FIFOCFG ,SIZE ,4 ,2 ); +/* DMA Configuration for Transmit */ +FIELD (FLEXCOMM_SPI_FIFOCFG ,DMATX ,12 ,1 ); +/* DMA Configuration for Receive */ +FIELD (FLEXCOMM_SPI_FIFOCFG ,DMARX ,13 ,1 ); +/* Wake-up for Transmit FIFO Level */ +FIELD (FLEXCOMM_SPI_FIFOCFG ,WAKETX ,14 ,1 ); +/* Wake-up for Receive FIFO Level */ +FIELD (FLEXCOMM_SPI_FIFOCFG ,WAKERX ,15 ,1 ); +/* Empty Command for the Transmit FIFO */ +FIELD (FLEXCOMM_SPI_FIFOCFG ,EMPTYTX ,16 ,1 ); +/* Empty Command for the Receive FIFO */ +FIELD (FLEXCOMM_SPI_FIFOCFG ,EMPTYRX ,17 ,1 ); +/* Pop FIFO for Debug Reads */ +FIELD (FLEXCOMM_SPI_FIFOCFG ,POPDBG ,18 ,1 ); + +/* FIFO Status Register */ +REG32 (FLEXCOMM_SPI_FIFOSTAT ,3588 ); +/* TX FIFO Error */ +FIELD (FLEXCOMM_SPI_FIFOSTAT ,TXERR ,0 ,1 ); +/* RX FIFO Error */ +FIELD (FLEXCOMM_SPI_FIFOSTAT ,RXERR ,1 ,1 ); +/* Peripheral Interrupt */ +FIELD (FLEXCOMM_SPI_FIFOSTAT ,PERINT ,3 ,1 ); +/* Transmit FIFO Empty */ +FIELD (FLEXCOMM_SPI_FIFOSTAT ,TXEMPTY ,4 ,1 ); +/* Transmit FIFO is Not Full */ +FIELD (FLEXCOMM_SPI_FIFOSTAT ,TXNOTFULL ,5 ,1 ); +/* Receive FIFO is Not Empty */ +FIELD (FLEXCOMM_SPI_FIFOSTAT ,RXNOTEMPTY ,6 ,1 ); +/* Receive FIFO is Full */ +FIELD (FLEXCOMM_SPI_FIFOSTAT ,RXFULL ,7 ,1 ); +/* Transmit FIFO Current Level */ +FIELD (FLEXCOMM_SPI_FIFOSTAT ,TXLVL ,8 ,5 ); +/* Receive FIFO Current Level */ +FIELD (FLEXCOMM_SPI_FIFOSTAT ,RXLVL ,16 ,5 ); + +/* FIFO Trigger Register */ +REG32 (FLEXCOMM_SPI_FIFOTRIG ,3592 ); +/* Transmit FIFO Level Trigger Enable */ +FIELD (FLEXCOMM_SPI_FIFOTRIG ,TXLVLENA ,0 ,1 ); +/* Receive FIFO Level Trigger Enable */ +FIELD (FLEXCOMM_SPI_FIFOTRIG ,RXLVLENA ,1 ,1 ); +/* Transmit FIFO Level Trigger Point */ +FIELD (FLEXCOMM_SPI_FIFOTRIG ,TXLVL ,8 ,4 ); +/* Receive FIFO Level Trigger Point */ +FIELD (FLEXCOMM_SPI_FIFOTRIG ,RXLVL ,16 ,4 ); + +/* FIFO Interrupt Enable Register */ +REG32 (FLEXCOMM_SPI_FIFOINTENSET ,3600 ); +/* TX Error Interrupt Enable */ +FIELD (FLEXCOMM_SPI_FIFOINTENSET ,TXERR ,0 ,1 ); +/* Receive Error Interrupt Enable */ +FIELD (FLEXCOMM_SPI_FIFOINTENSET ,RXERR ,1 ,1 ); +/* Transmit FIFO Level Interrupt Enable */ +FIELD (FLEXCOMM_SPI_FIFOINTENSET ,TXLVL ,2 ,1 ); +/* Receive FIFO Level Interrupt Enable */ +FIELD (FLEXCOMM_SPI_FIFOINTENSET ,RXLVL ,3 ,1 ); + +/* FIFO Interrupt Enable Clear Register */ +REG32 (FLEXCOMM_SPI_FIFOINTENCLR ,3604 ); +/* TX Error Interrupt Enable */ +FIELD (FLEXCOMM_SPI_FIFOINTENCLR ,TXERR ,0 ,1 ); +/* Receive Error Interrupt Enable */ +FIELD (FLEXCOMM_SPI_FIFOINTENCLR ,RXERR ,1 ,1 ); +/* Transmit FIFO Level Interrupt Enable */ +FIELD (FLEXCOMM_SPI_FIFOINTENCLR ,TXLVL ,2 ,1 ); +/* Receive FIFO Level Interrupt Enable */ +FIELD (FLEXCOMM_SPI_FIFOINTENCLR ,RXLVL ,3 ,1 ); + +/* FIFO Interrupt Status Register */ +REG32 (FLEXCOMM_SPI_FIFOINTSTAT ,3608 ); +/* TX FIFO Error Interrupt Status */ +FIELD (FLEXCOMM_SPI_FIFOINTSTAT ,TXERR ,0 ,1 ); +/* RX FIFO Error Interrupt Status */ +FIELD (FLEXCOMM_SPI_FIFOINTSTAT ,RXERR ,1 ,1 ); +/* Transmit FIFO Level Interrupt Status */ +FIELD (FLEXCOMM_SPI_FIFOINTSTAT ,TXLVL ,2 ,1 ); +/* Receive FIFO Level Interrupt Status */ +FIELD (FLEXCOMM_SPI_FIFOINTSTAT ,RXLVL ,3 ,1 ); +/* Peripheral Interrupt Status */ +FIELD (FLEXCOMM_SPI_FIFOINTSTAT ,PERINT ,4 ,1 ); + +/* FIFO Write Data Register */ +REG32 (FLEXCOMM_SPI_FIFOWR ,3616 ); +/* Transmit Data to the FIFO */ +FIELD (FLEXCOMM_SPI_FIFOWR ,TXDATA ,0 ,16 ); +/* Transmit Slave Select 0 */ +FIELD (FLEXCOMM_SPI_FIFOWR ,TXSSEL0_N ,16 ,1 ); +/* Transmit Slave Select 1 */ +FIELD (FLEXCOMM_SPI_FIFOWR ,TXSSEL1_N ,17 ,1 ); +/* Transmit Slave Select 2 */ +FIELD (FLEXCOMM_SPI_FIFOWR ,TXSSEL2_N ,18 ,1 ); +/* Transmit Slave Select 3 */ +FIELD (FLEXCOMM_SPI_FIFOWR ,TXSSEL3_N ,19 ,1 ); +/* End of Transfer */ +FIELD (FLEXCOMM_SPI_FIFOWR ,EOT ,20 ,1 ); +/* End of Frame */ +FIELD (FLEXCOMM_SPI_FIFOWR ,EOF ,21 ,1 ); +/* Receive Ignore */ +FIELD (FLEXCOMM_SPI_FIFOWR ,RXIGNORE ,22 ,1 ); +/* Transmit Ignore */ +FIELD (FLEXCOMM_SPI_FIFOWR ,TXIGNORE ,23 ,1 ); +/* Data Length */ +FIELD (FLEXCOMM_SPI_FIFOWR ,LEN ,24 ,4 ); + +/* FIFO Read Data Register */ +REG32 (FLEXCOMM_SPI_FIFORD ,3632 ); +/* Received Data from the FIFO */ +FIELD (FLEXCOMM_SPI_FIFORD ,RXDATA ,0 ,16 ); +/* Slave Select 0 for Receive */ +FIELD (FLEXCOMM_SPI_FIFORD ,RXSSEL0_N ,16 ,1 ); +/* Slave Select 1 for Receive */ +FIELD (FLEXCOMM_SPI_FIFORD ,RXSSEL1_N ,17 ,1 ); +/* Slave Select 2 for Receive */ +FIELD (FLEXCOMM_SPI_FIFORD ,RXSSEL2_N ,18 ,1 ); +/* Slave Select 3 for Receive */ +FIELD (FLEXCOMM_SPI_FIFORD ,RXSSEL3_N ,19 ,1 ); +/* Start of Transfer Flag */ +FIELD (FLEXCOMM_SPI_FIFORD ,SOT ,20 ,1 ); + +/* FIFO Data Read with no FIFO Pop Register */ +REG32 (FLEXCOMM_SPI_FIFORDNOPOP ,3648 ); +/* Received Data from the FIFO */ +FIELD (FLEXCOMM_SPI_FIFORDNOPOP ,RXDATA ,0 ,16 ); +/* Slave Select 0 for Receive */ +FIELD (FLEXCOMM_SPI_FIFORDNOPOP ,RXSSEL0_N ,16 ,1 ); +/* Slave Select 1 for Receive */ +FIELD (FLEXCOMM_SPI_FIFORDNOPOP ,RXSSEL1_N ,17 ,1 ); +/* Slave Select 2 for Receive */ +FIELD (FLEXCOMM_SPI_FIFORDNOPOP ,RXSSEL2_N ,18 ,1 ); +/* Slave Select 3 for Receive */ +FIELD (FLEXCOMM_SPI_FIFORDNOPOP ,RXSSEL3_N ,19 ,1 ); +/* Start of Transfer Flag */ +FIELD (FLEXCOMM_SPI_FIFORDNOPOP ,SOT ,20 ,1 ); + +/* FIFO Size Register */ +REG32 (FLEXCOMM_SPI_FIFOSIZE ,3656 ); +/* FIFO Size */ +FIELD (FLEXCOMM_SPI_FIFOSIZE ,FIFOSIZE ,0 ,5 ); + +/* Peripheral Identification Register */ +REG32 (FLEXCOMM_SPI_ID ,4092 ); +/* Aperture */ +FIELD (FLEXCOMM_SPI_ID ,APERTURE ,0 ,8 ); +/* Minor revision of module implementation */ +FIELD (FLEXCOMM_SPI_ID ,MINOR_REV ,8 ,4 ); +/* Major revision of module implementation */ +FIELD (FLEXCOMM_SPI_ID ,MAJOR_REV ,12 ,4 ); +/* Module identifier for the selected function */ +FIELD (FLEXCOMM_SPI_ID ,ID ,16 ,16 ); + + +typedef enum { +/* +* Disabled. The SPI is disabled and the internal state machine and +* counters are reset. +*/ +FLEXCOMM_SPI_CFG_ENABLE_DISABLED =0 , +/* Enabled. The SPI is enabled for operation. */ +FLEXCOMM_SPI_CFG_ENABLE_ENABLED =1 , +}FLEXCOMM_SPI_CFG_ENABLE_Enum ; + +typedef enum { +/* +* Slave mode. The SPI will operate in slave mode. SCK, MOSI, and the SSEL +* signals are inputs; MISO is an output. +*/ +FLEXCOMM_SPI_CFG_MASTER_SLAVE_MODE =0 , +/* +* Master mode. The SPI will operate in master mode. SCK, MOSI, and the +* SSEL signals are outputs; MISO is an input. +*/ +FLEXCOMM_SPI_CFG_MASTER_MASTER_MODE =1 , +}FLEXCOMM_SPI_CFG_MASTER_Enum ; + +typedef enum { +/* +* Standard. Data is transmitted and received in standard MSB-first order. +*/ +FLEXCOMM_SPI_CFG_LSBF_STANDARD =0 , +/* +* Reverse. Data is transmitted and received in reverse order (LSB first). +*/ +FLEXCOMM_SPI_CFG_LSBF_REVERSE =1 , +}FLEXCOMM_SPI_CFG_LSBF_Enum ; + +typedef enum { +/* Change */ +FLEXCOMM_SPI_CFG_CPHA_CHANGE =0 , +/* Capture */ +FLEXCOMM_SPI_CFG_CPHA_CAPTURE =1 , +}FLEXCOMM_SPI_CFG_CPHA_Enum ; + +typedef enum { +/* Low. The rest state of the clock (between transfers) is low. */ +FLEXCOMM_SPI_CFG_CPOL_LOW =0 , +/* High. The rest state of the clock (between transfers) is high. */ +FLEXCOMM_SPI_CFG_CPOL_HIGH =1 , +}FLEXCOMM_SPI_CFG_CPOL_Enum ; + +typedef enum { +/* Disabled */ +FLEXCOMM_SPI_CFG_LOOP_DISABLED =0 , +/* Enabled */ +FLEXCOMM_SPI_CFG_LOOP_ENABLED =1 , +}FLEXCOMM_SPI_CFG_LOOP_Enum ; + +typedef enum { +/* Low. The SSEL0 pin is active low. */ +FLEXCOMM_SPI_CFG_SPOL0_LOW =0 , +/* High. The SSEL0 pin is active high. */ +FLEXCOMM_SPI_CFG_SPOL0_HIGH =1 , +}FLEXCOMM_SPI_CFG_SPOL0_Enum ; + +typedef enum { +/* Low. The SSEL1 pin is active low. */ +FLEXCOMM_SPI_CFG_SPOL1_LOW =0 , +/* High. The SSEL1 pin is active high. */ +FLEXCOMM_SPI_CFG_SPOL1_HIGH =1 , +}FLEXCOMM_SPI_CFG_SPOL1_Enum ; + +typedef enum { +/* Low. The SSEL2 pin is active low. */ +FLEXCOMM_SPI_CFG_SPOL2_LOW =0 , +/* High. The SSEL2 pin is active high. */ +FLEXCOMM_SPI_CFG_SPOL2_HIGH =1 , +}FLEXCOMM_SPI_CFG_SPOL2_Enum ; + +typedef enum { +/* Low. The SSEL3 pin is active low. */ +FLEXCOMM_SPI_CFG_SPOL3_LOW =0 , +/* High. The SSEL3 pin is active high. */ +FLEXCOMM_SPI_CFG_SPOL3_HIGH =1 , +}FLEXCOMM_SPI_CFG_SPOL3_Enum ; + +typedef enum { +/* No additional time is inserted */ +FLEXCOMM_SPI_DLY_PRE_DELAY_PRE_DELAY0 =0 , +/* 1 SPI clock time is inserted */ +FLEXCOMM_SPI_DLY_PRE_DELAY_PRE_DELAY1 =1 , +/* 2 SPI clock times are inserted */ +FLEXCOMM_SPI_DLY_PRE_DELAY_PRE_DELAY2 =2 , +/* 15 SPI clock times are inserted */ +FLEXCOMM_SPI_DLY_PRE_DELAY_PRE_DELAY15 =15 , +}FLEXCOMM_SPI_DLY_PRE_DELAY_Enum ; + +typedef enum { +/* No additional time is inserted */ +FLEXCOMM_SPI_DLY_POST_DELAY_POST_DELAY0 =0 , +/* 1 SPI clock time is inserted */ +FLEXCOMM_SPI_DLY_POST_DELAY_POST_DELAY1 =1 , +/* 2 SPI clock times are inserted */ +FLEXCOMM_SPI_DLY_POST_DELAY_POST_DELAY2 =2 , +/* 15 SPI clock times are inserted */ +FLEXCOMM_SPI_DLY_POST_DELAY_POST_DELAY15 =15 , +}FLEXCOMM_SPI_DLY_POST_DELAY_Enum ; + +typedef enum { +/* No additional time is inserted */ +FLEXCOMM_SPI_DLY_FRAME_DELAY_FRAME_DELAY0 =0 , +/* 1 SPI clock time is inserted */ +FLEXCOMM_SPI_DLY_FRAME_DELAY_FRAME_DELAY1 =1 , +/* 2 SPI clock times are inserted */ +FLEXCOMM_SPI_DLY_FRAME_DELAY_FRAME_DELAY2 =2 , +/* 15 SPI clock times are inserted */ +FLEXCOMM_SPI_DLY_FRAME_DELAY_FRAME_DELAY15 =15 , +}FLEXCOMM_SPI_DLY_FRAME_DELAY_Enum ; + +typedef enum { +/* +* The minimum time that SSEL is deasserted is 1 SPI clock time (zero-added +* time) +*/ +FLEXCOMM_SPI_DLY_TRANSFER_DELAY_TRANSFER_DELAY1 =0 , +/* The minimum time that SSEL is deasserted is 2 SPI clock times */ +FLEXCOMM_SPI_DLY_TRANSFER_DELAY_TRANSFER_DELAY2 =1 , +/* The minimum time that SSEL is deasserted is 3 SPI clock times */ +FLEXCOMM_SPI_DLY_TRANSFER_DELAY_TRANSFER_DELAY3 =2 , +/* The minimum time that SSEL is deasserted is 16 SPI clock times */ +FLEXCOMM_SPI_DLY_TRANSFER_DELAY_TRANSFER_DELAY16 =15 , +}FLEXCOMM_SPI_DLY_TRANSFER_DELAY_Enum ; + +typedef enum { +/* +* Disabled. No interrupt will be generated when any Slave Select +* transitions from deasserted to asserted. +*/ +FLEXCOMM_SPI_INTENSET_SSAEN_DISABLED =0 , +/* +* Enabled. An interrupt will be generated when any Slave Select +* transitions from deasserted to asserted. +*/ +FLEXCOMM_SPI_INTENSET_SSAEN_ENABLED =1 , +}FLEXCOMM_SPI_INTENSET_SSAEN_Enum ; + +typedef enum { +/* +* Disabled. No interrupt will be generated when all asserted Slave Selects +* transition to deasserted. +*/ +FLEXCOMM_SPI_INTENSET_SSDEN_DISABLED =0 , +/* +* Enabled. An interrupt will be generated when all asserted Slave Selects +* transition to deasserted. +*/ +FLEXCOMM_SPI_INTENSET_SSDEN_ENABLED =1 , +}FLEXCOMM_SPI_INTENSET_SSDEN_Enum ; + +typedef enum { +/* No interrupt will be generated when the SPI master function is idle. */ +FLEXCOMM_SPI_INTENSET_MSTIDLEEN_DISABLED =0 , +/* +* An interrupt will be generated when the SPI master function is fully +* idle. +*/ +FLEXCOMM_SPI_INTENSET_MSTIDLEEN_ENABLED =1 , +}FLEXCOMM_SPI_INTENSET_MSTIDLEEN_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_SPI_INTENCLR_SSAEN_NO_EFFECT =0 , +/* Clear the Slave Select Assert Interrupt Enable bit (INTENSET[SSAEN]) */ +FLEXCOMM_SPI_INTENCLR_SSAEN_CLEAR_THE_SSAEN =1 , +}FLEXCOMM_SPI_INTENCLR_SSAEN_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_SPI_INTENCLR_SSDEN_NO_EFFECT =0 , +/* Clear the Slave Select Deassert Interrupt Enable bit (INTENSET[SSDEN]) */ +FLEXCOMM_SPI_INTENCLR_SSDEN_CLEAR_THE_SSDEN =1 , +}FLEXCOMM_SPI_INTENCLR_SSDEN_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_SPI_INTENCLR_MSTIDLE_NO_EFFECT =0 , +/* Clear the Master Idle Interrupt Enable bit (INTENSET[MSTIDLE]) */ +FLEXCOMM_SPI_INTENCLR_MSTIDLE_CLEAR_THE_MSTIDLE =1 , +}FLEXCOMM_SPI_INTENCLR_MSTIDLE_Enum ; + +typedef enum { +/* Disabled */ +FLEXCOMM_SPI_INTSTAT_SSA_SSA_INTERRUPT_DISABLED =0 , +/* Enabled */ +FLEXCOMM_SPI_INTSTAT_SSA_SSA_INTERRUPT_ENABLED =1 , +}FLEXCOMM_SPI_INTSTAT_SSA_Enum ; + +typedef enum { +/* Disabled */ +FLEXCOMM_SPI_INTSTAT_SSD_SSD_INTERRUPT_DISABLED =0 , +/* Enabled */ +FLEXCOMM_SPI_INTSTAT_SSD_SSD_INTERRUPT_ENABLED =1 , +}FLEXCOMM_SPI_INTSTAT_SSD_Enum ; + +typedef enum { +/* Disabled */ +FLEXCOMM_SPI_INTSTAT_MSTIDLE_MSTIDLE_INTERRUPT_DISABLED =0 , +/* Enabled */ +FLEXCOMM_SPI_INTSTAT_MSTIDLE_MSTIDLE_INTERRUPT_ENABLED =1 , +}FLEXCOMM_SPI_INTSTAT_MSTIDLE_Enum ; + +typedef enum { +/* The transmit FIFO is not enabled */ +FLEXCOMM_SPI_FIFOCFG_ENABLETX_DISABLED =0 , +/* The transmit FIFO is enabled */ +FLEXCOMM_SPI_FIFOCFG_ENABLETX_ENABLED =1 , +}FLEXCOMM_SPI_FIFOCFG_ENABLETX_Enum ; + +typedef enum { +/* The receive FIFO is not enabled */ +FLEXCOMM_SPI_FIFOCFG_ENABLERX_DISABLED =0 , +/* The receive FIFO is enabled */ +FLEXCOMM_SPI_FIFOCFG_ENABLERX_ENABLED =1 , +}FLEXCOMM_SPI_FIFOCFG_ENABLERX_Enum ; + +typedef enum { +/* FIFO is configured as 16 entries of 8 bits. */ +FLEXCOMM_SPI_FIFOCFG_SIZE_SIZE16ENTRIES8BITS =0 , +/* FIFO is configured as 8 entries of 16 bits. */ +FLEXCOMM_SPI_FIFOCFG_SIZE_SIZE8ENTRIES16BITS =1 , +/* Not used */ +FLEXCOMM_SPI_FIFOCFG_SIZE_SIZEINVALID2 =2 , +/* Not used */ +FLEXCOMM_SPI_FIFOCFG_SIZE_SIZEINVALID3 =3 , +}FLEXCOMM_SPI_FIFOCFG_SIZE_Enum ; + +typedef enum { +/* DMA is not used for the transmit function */ +FLEXCOMM_SPI_FIFOCFG_DMATX_DISABLED =0 , +/* +* Issues DMA request for the transmit function if the FIFO is not full. +* Generally, data interrupts would be disabled if DMA is enabled. +*/ +FLEXCOMM_SPI_FIFOCFG_DMATX_ENABLED =1 , +}FLEXCOMM_SPI_FIFOCFG_DMATX_Enum ; + +typedef enum { +/* DMA is not used for the receive function. */ +FLEXCOMM_SPI_FIFOCFG_DMARX_DISABLED =0 , +/* +* Issues a DMA request for the receive function if the FIFO is not empty. +* Generally, data interrupts would be disabled if DMA is enabled. +*/ +FLEXCOMM_SPI_FIFOCFG_DMARX_ENABLED =1 , +}FLEXCOMM_SPI_FIFOCFG_DMARX_Enum ; + +typedef enum { +/* +* Only enabled interrupts will wake up the device form reduced power modes +*/ +FLEXCOMM_SPI_FIFOCFG_WAKETX_DISABLED =0 , +/* +* A device wake-up for DMA will occur if the transmit FIFO level reaches +* the value specified by TXLVL in FIFOTRIG, even when the TXLVL interrupt +* is not enabled. +*/ +FLEXCOMM_SPI_FIFOCFG_WAKETX_ENABLED =1 , +}FLEXCOMM_SPI_FIFOCFG_WAKETX_Enum ; + +typedef enum { +/* +* Only enabled interrupts will wake up the device form reduced power +* modes. +*/ +FLEXCOMM_SPI_FIFOCFG_WAKERX_DISABLED =0 , +/* +* A device wake-up for DMA will occur if the receive FIFO level reaches +* the value specified by FIFOTRIG[RXLVL], even when the RXLVL interrupt is +* not enabled. +*/ +FLEXCOMM_SPI_FIFOCFG_WAKERX_ENABLED =1 , +}FLEXCOMM_SPI_FIFOCFG_WAKERX_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_SPI_FIFOCFG_EMPTYTX_NO_EFFECT =0 , +/* The TX FIFO is emptied */ +FLEXCOMM_SPI_FIFOCFG_EMPTYTX_EMPTY_THE_TX_FIFO =1 , +}FLEXCOMM_SPI_FIFOCFG_EMPTYTX_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_SPI_FIFOCFG_EMPTYRX_NO_EFFECT =0 , +/* The RX FIFO is emptied */ +FLEXCOMM_SPI_FIFOCFG_EMPTYRX_EMPTY_THE_RX_FIFO =1 , +}FLEXCOMM_SPI_FIFOCFG_EMPTYRX_Enum ; + +typedef enum { +/* Debug reads of the FIFO do not pop the FIFO */ +FLEXCOMM_SPI_FIFOCFG_POPDBG_DO_NOT_POP =0 , +/* A debug read will cause the FIFO to pop */ +FLEXCOMM_SPI_FIFOCFG_POPDBG_POP =1 , +}FLEXCOMM_SPI_FIFOCFG_POPDBG_Enum ; + +typedef enum { +/* A transmit FIFO error has not occurred. */ +FLEXCOMM_SPI_FIFOSTAT_TXERR_NO_TXERR =0 , +/* +* A transmit FIFO error has occurred. This error could be an overflow +* caused by pushing data into a full FIFO, or by an underflow if the FIFO +* is empty when data is needed. +*/ +FLEXCOMM_SPI_FIFOSTAT_TXERR_TXERR =1 , +}FLEXCOMM_SPI_FIFOSTAT_TXERR_Enum ; + +typedef enum { +/* A receive FIFO overflow has not occurred */ +FLEXCOMM_SPI_FIFOSTAT_RXERR_NO_RXERR =0 , +/* +* A receive FIFO overflow has occurred, caused by software or DMA not +* emptying the FIFO fast enough +*/ +FLEXCOMM_SPI_FIFOSTAT_RXERR_RXERR =1 , +}FLEXCOMM_SPI_FIFOSTAT_RXERR_Enum ; + +typedef enum { +/* The peripheral function has not asserted an interrupt */ +FLEXCOMM_SPI_FIFOSTAT_PERINT_NO_PERINT =0 , +/* +* Indicates that the peripheral function has asserted an interrupt. More +* information can be found by reading the peripheral's status register +* (STAT). +*/ +FLEXCOMM_SPI_FIFOSTAT_PERINT_PERINT =1 , +}FLEXCOMM_SPI_FIFOSTAT_PERINT_Enum ; + +typedef enum { +/* The transmit FIFO is not empty */ +FLEXCOMM_SPI_FIFOSTAT_TXEMPTY_TXFIFO_ISNOTEMPTY =0 , +/* +* The transmit FIFO is empty, although the peripheral may still be +* processing the last piece of data. +*/ +FLEXCOMM_SPI_FIFOSTAT_TXEMPTY_TXFIFO_ISEMPTY =1 , +}FLEXCOMM_SPI_FIFOSTAT_TXEMPTY_Enum ; + +typedef enum { +/* The transmit FIFO is full and another write would cause it to overflow */ +FLEXCOMM_SPI_FIFOSTAT_TXNOTFULL_TXFIFO_ISFULL =0 , +/* The transmit FIFO is not full, so more data can be written */ +FLEXCOMM_SPI_FIFOSTAT_TXNOTFULL_TXFIFO_ISNOTFULL =1 , +}FLEXCOMM_SPI_FIFOSTAT_TXNOTFULL_Enum ; + +typedef enum { +/* When 0, the receive FIFO is empty */ +FLEXCOMM_SPI_FIFOSTAT_RXNOTEMPTY_RXFIFO_ISEMPTY =0 , +/* When 1, the receive FIFO is not empty, so data can be read */ +FLEXCOMM_SPI_FIFOSTAT_RXNOTEMPTY_RXFIFO_ISNOTEMPTY =1 , +}FLEXCOMM_SPI_FIFOSTAT_RXNOTEMPTY_Enum ; + +typedef enum { +/* The receive FIFO is not full */ +FLEXCOMM_SPI_FIFOSTAT_RXFULL_RXFIFO_ISNOTFULL =0 , +/* +* The receive FIFO is full. To prevent the peripheral from causing an +* overflow, data should be read out. +*/ +FLEXCOMM_SPI_FIFOSTAT_RXFULL_RXFIFO_ISFULL =1 , +}FLEXCOMM_SPI_FIFOSTAT_RXFULL_Enum ; + +typedef enum { +/* Transmit FIFO level does not generate a FIFO level trigger */ +FLEXCOMM_SPI_FIFOTRIG_TXLVLENA_DISABLED =0 , +/* +* An trigger will be generated if the transmit FIFO level reaches the +* value specified by the FIFOTRIG[TXLVL] field. +*/ +FLEXCOMM_SPI_FIFOTRIG_TXLVLENA_ENABLED =1 , +}FLEXCOMM_SPI_FIFOTRIG_TXLVLENA_Enum ; + +typedef enum { +/* Receive FIFO level does not generate a FIFO level trigger */ +FLEXCOMM_SPI_FIFOTRIG_RXLVLENA_DISABLED =0 , +/* +* An trigger will be generated if the receive FIFO level reaches the value +* specified by the FIFOTRIG[RXLVL] field. +*/ +FLEXCOMM_SPI_FIFOTRIG_RXLVLENA_ENABLED =1 , +}FLEXCOMM_SPI_FIFOTRIG_RXLVLENA_Enum ; + +typedef enum { +/* Trigger when the TX FIFO becomes empty */ +FLEXCOMM_SPI_FIFOTRIG_TXLVL_TXLVL0 =0 , +/* Trigger when the TX FIFO level decreases to 1 entry */ +FLEXCOMM_SPI_FIFOTRIG_TXLVL_TXLVL1 =1 , +/* +* Trigger when the TX FIFO level decreases to 15 entries (is no longer +* full) +*/ +FLEXCOMM_SPI_FIFOTRIG_TXLVL_TXLVL15 =15 , +}FLEXCOMM_SPI_FIFOTRIG_TXLVL_Enum ; + +typedef enum { +/* Trigger when the RX FIFO has received 1 entry (is no longer empty) */ +FLEXCOMM_SPI_FIFOTRIG_RXLVL_RXLVL1 =0 , +/* Trigger when the RX FIFO has received 2 entries */ +FLEXCOMM_SPI_FIFOTRIG_RXLVL_RXLVL2 =1 , +/* Trigger when the RX FIFO has received 16 entries (has become full) */ +FLEXCOMM_SPI_FIFOTRIG_RXLVL_RXLVL15 =15 , +}FLEXCOMM_SPI_FIFOTRIG_RXLVL_Enum ; + +typedef enum { +/* No interrupt will be generated for a transmit error */ +FLEXCOMM_SPI_FIFOINTENSET_TXERR_DISABLED =0 , +/* An interrupt will be generated when a transmit error occurs */ +FLEXCOMM_SPI_FIFOINTENSET_TXERR_ENABLED =1 , +}FLEXCOMM_SPI_FIFOINTENSET_TXERR_Enum ; + +typedef enum { +/* No interrupt will be generated for a receive error */ +FLEXCOMM_SPI_FIFOINTENSET_RXERR_DISABLED =0 , +/* An interrupt will be generated when a receive error occurs */ +FLEXCOMM_SPI_FIFOINTENSET_RXERR_ENABLED =1 , +}FLEXCOMM_SPI_FIFOINTENSET_RXERR_Enum ; + +typedef enum { +/* No interrupt will be generated based on the TX FIFO level */ +FLEXCOMM_SPI_FIFOINTENSET_TXLVL_DISABLED =0 , +/* +* If FIFOTRIG[TXLVLENA]=1, then an interrupt will be generated when the TX +* FIFO level decreases to the level specified by FIFOTRIG[TXLVL] +*/ +FLEXCOMM_SPI_FIFOINTENSET_TXLVL_ENABLED =1 , +}FLEXCOMM_SPI_FIFOINTENSET_TXLVL_Enum ; + +typedef enum { +/* No interrupt will be generated based on the RX FIFO level */ +FLEXCOMM_SPI_FIFOINTENSET_RXLVL_DISABLED =0 , +/* +* If FIFOTRIG[RXLVLENA]=1, then an interrupt will be generated when the RX +* FIFO level increases to the level specified by FIFOTRIG[RXLVL] +*/ +FLEXCOMM_SPI_FIFOINTENSET_RXLVL_ENABLED =1 , +}FLEXCOMM_SPI_FIFOINTENSET_RXLVL_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_SPI_FIFOINTENCLR_TXERR_NO_EFFECT =0 , +/* Clear the TX Error Interrupt Enable bit FIFOINTENSET[TXERR] */ +FLEXCOMM_SPI_FIFOINTENCLR_TXERR_CLEAR_THE_TXERR =1 , +}FLEXCOMM_SPI_FIFOINTENCLR_TXERR_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_SPI_FIFOINTENCLR_RXERR_NO_EFFECT =0 , +/* Clear the Receive Error Interrupt Enable bit FIFOINTENSET[RXERR] */ +FLEXCOMM_SPI_FIFOINTENCLR_RXERR_CLEAR_THE_RXERR =1 , +}FLEXCOMM_SPI_FIFOINTENCLR_RXERR_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_SPI_FIFOINTENCLR_TXLVL_NO_EFFECT =0 , +/* Clear the Transmit FIFO Level Interrupt Enable bit FIFOINTENSET[TXLVL] */ +FLEXCOMM_SPI_FIFOINTENCLR_TXLVL_CLEAR_THE_TXLVL =1 , +}FLEXCOMM_SPI_FIFOINTENCLR_TXLVL_Enum ; + +typedef enum { +/* No effect */ +FLEXCOMM_SPI_FIFOINTENCLR_RXLVL_NO_EFFECT =0 , +/* Clear the Receive FIFO Level Interrupt Enable bit FIFOINTENSET[RXLVL] */ +FLEXCOMM_SPI_FIFOINTENCLR_RXLVL_CLEAR_THE_RXLVL =1 , +}FLEXCOMM_SPI_FIFOINTENCLR_RXLVL_Enum ; + +typedef enum { +/* Not pending */ +FLEXCOMM_SPI_FIFOINTSTAT_TXERR_TXERR_ISNOTPENDING =0 , +/* Pending */ +FLEXCOMM_SPI_FIFOINTSTAT_TXERR_TXERR_ISPENDING =1 , +}FLEXCOMM_SPI_FIFOINTSTAT_TXERR_Enum ; + +typedef enum { +/* Not pending */ +FLEXCOMM_SPI_FIFOINTSTAT_RXERR_RXERR_ISNOTPENDING =0 , +/* Pending */ +FLEXCOMM_SPI_FIFOINTSTAT_RXERR_RXERR_ISPENDING =1 , +}FLEXCOMM_SPI_FIFOINTSTAT_RXERR_Enum ; + +typedef enum { +/* Not pending */ +FLEXCOMM_SPI_FIFOINTSTAT_TXLVL_TXLVL_ISNOTPENDING =0 , +/* Pending */ +FLEXCOMM_SPI_FIFOINTSTAT_TXLVL_TXLVL_ISPENDING =1 , +}FLEXCOMM_SPI_FIFOINTSTAT_TXLVL_Enum ; + +typedef enum { +/* Not pending */ +FLEXCOMM_SPI_FIFOINTSTAT_RXLVL_RXLVL_ISNOTPENDING =0 , +/* Pending */ +FLEXCOMM_SPI_FIFOINTSTAT_RXLVL_RXLVL_ISPENDING =1 , +}FLEXCOMM_SPI_FIFOINTSTAT_RXLVL_Enum ; + +typedef enum { +/* Not pending */ +FLEXCOMM_SPI_FIFOINTSTAT_PERINT_PERINT_ISNOTPENDING =0 , +/* Pending */ +FLEXCOMM_SPI_FIFOINTSTAT_PERINT_PERINT_ISPENDING =1 , +}FLEXCOMM_SPI_FIFOINTSTAT_PERINT_Enum ; + +typedef enum { +/* SSEL0 is asserted */ +FLEXCOMM_SPI_FIFOWR_TXSSEL0_N_ASSERTED =0 , +/* SSEL0 is not asserted */ +FLEXCOMM_SPI_FIFOWR_TXSSEL0_N_NOT_ASSERTED =1 , +}FLEXCOMM_SPI_FIFOWR_TXSSEL0_N_Enum ; + +typedef enum { +/* SSEL1 is asserted */ +FLEXCOMM_SPI_FIFOWR_TXSSEL1_N_ASSERTED =0 , +/* SSEL1 is not asserted */ +FLEXCOMM_SPI_FIFOWR_TXSSEL1_N_NOT_ASSERTED =1 , +}FLEXCOMM_SPI_FIFOWR_TXSSEL1_N_Enum ; + +typedef enum { +/* SSEL2 is asserted */ +FLEXCOMM_SPI_FIFOWR_TXSSEL2_N_ASSERTED =0 , +/* SSEL2 is not asserted */ +FLEXCOMM_SPI_FIFOWR_TXSSEL2_N_NOT_ASSERTED =1 , +}FLEXCOMM_SPI_FIFOWR_TXSSEL2_N_Enum ; + +typedef enum { +/* SSEL3 is asserted */ +FLEXCOMM_SPI_FIFOWR_TXSSEL3_N_ASSERTED =0 , +/* SSEL3 is not asserted */ +FLEXCOMM_SPI_FIFOWR_TXSSEL3_N_NOT_ASSERTED =1 , +}FLEXCOMM_SPI_FIFOWR_TXSSEL3_N_Enum ; + +typedef enum { +/* +* SSEL is not deasserted. This piece of data is not treated as the end of +* a transfer. SSEL will not be deasserted at the end of this data. +*/ +FLEXCOMM_SPI_FIFOWR_EOT_NOT_DEASSERTED =0 , +/* +* SSEL is deasserted. This piece of data is treated as the end of a +* transfer. SSEL will be deasserted at the end of this piece of data. +*/ +FLEXCOMM_SPI_FIFOWR_EOT_DEASSERTED =1 , +}FLEXCOMM_SPI_FIFOWR_EOT_Enum ; + +typedef enum { +/* +* Data not EOF. This piece of data transmitted is not treated as the end +* of a frame. +*/ +FLEXCOMM_SPI_FIFOWR_EOF_NOT_EOF =0 , +/* +* Data EOF. This piece of data is treated as the end of a frame, causing +* the Frame_delay time to be inserted before subsequent data is +* transmitted. +*/ +FLEXCOMM_SPI_FIFOWR_EOF_EOF =1 , +}FLEXCOMM_SPI_FIFOWR_EOF_Enum ; + +typedef enum { +/* +* Read received data. Received data must be read, to allow transmission to +* proceed. SPI transmit will halt when the receive data FIFO is full. In +* slave mode, an overrun error will occur if received data is not read +* before new data is received. +*/ +FLEXCOMM_SPI_FIFOWR_RXIGNORE_READ =0 , +/* +* Ignore received data. Received data is ignored, allowing transmission +* without reading unneeded received data. No receiver flags are generated. +*/ +FLEXCOMM_SPI_FIFOWR_RXIGNORE_IGNORE =1 , +}FLEXCOMM_SPI_FIFOWR_RXIGNORE_Enum ; + +typedef enum { +/* Write transmit data */ +FLEXCOMM_SPI_FIFOWR_TXIGNORE_WRITETXDATA =0 , +/* Ignore transmit data */ +FLEXCOMM_SPI_FIFOWR_TXIGNORE_IGNORETXDATA =1 , +}FLEXCOMM_SPI_FIFOWR_TXIGNORE_Enum ; + +typedef enum { +/* Data transfer is 4 bits in length */ +FLEXCOMM_SPI_FIFOWR_LEN_LEN_4BITS =3 , +/* Data transfer is 5 bits in length */ +FLEXCOMM_SPI_FIFOWR_LEN_LEN_5BITS =4 , +/* Data transfer is 16 bits in length */ +FLEXCOMM_SPI_FIFOWR_LEN_LEN_16BITS =15 , +}FLEXCOMM_SPI_FIFOWR_LEN_Enum ; + +typedef enum { +/* Slave Select 0 is active */ +FLEXCOMM_SPI_FIFORD_RXSSEL0_N_RXSSEL0_ISACTIVE =0 , +/* Slave Select 0 is not active */ +FLEXCOMM_SPI_FIFORD_RXSSEL0_N_RXSSEL0_ISNOTACTIVE =1 , +}FLEXCOMM_SPI_FIFORD_RXSSEL0_N_Enum ; + +typedef enum { +/* Slave Select 1 is active */ +FLEXCOMM_SPI_FIFORD_RXSSEL1_N_RXSSEL1_ISACTIVE =0 , +/* Slave Select 1 is not active */ +FLEXCOMM_SPI_FIFORD_RXSSEL1_N_RXSSEL1_ISNOTACTIVE =1 , +}FLEXCOMM_SPI_FIFORD_RXSSEL1_N_Enum ; + +typedef enum { +/* Slave Select 2 is active */ +FLEXCOMM_SPI_FIFORD_RXSSEL2_N_RXSSEL2_ISACTIVE =0 , +/* Slave Select 2 is not active */ +FLEXCOMM_SPI_FIFORD_RXSSEL2_N_RXSSEL2_ISNOTACTIVE =1 , +}FLEXCOMM_SPI_FIFORD_RXSSEL2_N_Enum ; + +typedef enum { +/* Slave Select 3 is active */ +FLEXCOMM_SPI_FIFORD_RXSSEL3_N_RXSSEL3_ISACTIVE =0 , +/* Slave Select 3 is not active */ +FLEXCOMM_SPI_FIFORD_RXSSEL3_N_RXSSEL3_ISNOTACTIVE =1 , +}FLEXCOMM_SPI_FIFORD_RXSSEL3_N_Enum ; + +typedef enum { +/* +* This is not the 1st data after the SSELs went from deasserted to +* asserted +*/ +FLEXCOMM_SPI_FIFORD_SOT_SOT0 =0 , +/* +* This is the 1st data after the SSELs went from deasserted to asserted +* (i.e., any previous transfer has ended). This information can be used to +* identify the 1st piece of data in cases where the transfer length is +* greater than 16 bits. +*/ +FLEXCOMM_SPI_FIFORD_SOT_SOT1 =1 , +}FLEXCOMM_SPI_FIFORD_SOT_Enum ; + +typedef enum { +/* Not selected */ +FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL0_N_NOT_SELECTED =0 , +/* Selected */ +FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL0_N_RXSSEL0_N_SELECTED =1 , +}FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL0_N_Enum ; + +typedef enum { +/* Not selected */ +FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL1_N_NOT_SELECTED =0 , +/* Selected */ +FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL1_N_RXSSEL1_N_SELECTED =1 , +}FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL1_N_Enum ; + +typedef enum { +/* Not selected */ +FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL2_N_NOT_SELECTED =0 , +/* Selected */ +FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL2_N_RXSSEL2_N_SELECTED =1 , +}FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL2_N_Enum ; + +typedef enum { +/* Not selected */ +FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL3_N_NOT_SELECTED =0 , +/* Selected */ +FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL3_N_RXSSEL3_N_SELECTED =1 , +}FLEXCOMM_SPI_FIFORDNOPOP_RXSSEL3_N_Enum ; + +typedef enum { +/* Not active */ +FLEXCOMM_SPI_FIFORDNOPOP_SOT_SOT_NOT_ACTIVE =0 , +/* Active */ +FLEXCOMM_SPI_FIFORDNOPOP_SOT_SOT_ACTIVE =1 , +}FLEXCOMM_SPI_FIFORDNOPOP_SOT_Enum ; + + +#define FLEXCOMM_SPI_REGISTER_ACCESS_INFO_ARRAY (_name) \ + struct RegisterAccessInfo _name[FLEXCOMM_SPI_REGS_NO] = { \ + [0 ... FLEXCOMM_SPI_REGS_NO - 1] = { \ + .name = "", \ + .addr = -1, \ + }, \ + [R_FLEXCOMM_SPI_CFG] = { \ + .name = "CFG", \ + .addr = 0x400, \ + .ro = 0xFFFFF042, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_SPI_DLY] = { \ + .name = "DLY", \ + .addr = 0x404, \ + .ro = 0xFFFF0000, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_SPI_STAT] = { \ + .name = "STAT", \ + .addr = 0x408, \ + .ro = 0xFFFFFF4F, \ + .reset = 0x100, \ + }, \ + [R_FLEXCOMM_SPI_INTENSET] = { \ + .name = "INTENSET", \ + .addr = 0x40C, \ + .ro = 0xFFFFFECF, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_SPI_INTENCLR] = { \ + .name = "INTENCLR", \ + .addr = 0x410, \ + .ro = 0xFFFFFECF, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_SPI_DIV] = { \ + .name = "DIV", \ + .addr = 0x424, \ + .ro = 0xFFFF0000, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_SPI_INTSTAT] = { \ + .name = "INTSTAT", \ + .addr = 0x428, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFOCFG] = { \ + .name = "FIFOCFG", \ + .addr = 0xE00, \ + .ro = 0xFFF80FFC, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFOSTAT] = { \ + .name = "FIFOSTAT", \ + .addr = 0xE04, \ + .ro = 0xFFFFFFFC, \ + .reset = 0x30, \ + }, \ + [R_FLEXCOMM_SPI_FIFOTRIG] = { \ + .name = "FIFOTRIG", \ + .addr = 0xE08, \ + .ro = 0xFFF0F0FC, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFOINTENSET] = { \ + .name = "FIFOINTENSET", \ + .addr = 0xE10, \ + .ro = 0xFFFFFFF0, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFOINTENCLR] = { \ + .name = "FIFOINTENCLR", \ + .addr = 0xE14, \ + .ro = 0xFFFFFFF0, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFOINTSTAT] = { \ + .name = "FIFOINTSTAT", \ + .addr = 0xE18, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFOWR] = { \ + .name = "FIFOWR", \ + .addr = 0xE20, \ + .ro = 0xF0000000, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFORD] = { \ + .name = "FIFORD", \ + .addr = 0xE30, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFORDNOPOP] = { \ + .name = "FIFORDNOPOP", \ + .addr = 0xE40, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_SPI_FIFOSIZE] = { \ + .name = "FIFOSIZE", \ + .addr = 0xE48, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + [R_FLEXCOMM_SPI_ID] = { \ + .name = "ID", \ + .addr = 0xFFC, \ + .ro = 0xFFFFFFFF, \ + .reset = 0xE0201200, \ + }, \ + }
include/hw/misc/flexcomm.h +2 -0
@@ -17,6 +17,7 @@#include "qemu/fifo32.h" #include "hw/char/flexcomm_usart.h" #include "hw/i2c/flexcomm_i2c.h" +#include "hw/ssi/flexcomm_spi.h" #define FLEXCOMM_FUNC_USART 0#define FLEXCOMM_FUNC_SPI 1
@@ -50,6 +51,7 @@ struct FlexcommState {Fifo32 tx_fifo;FlexcommUsartState usart;FlexcommI2cState i2c; + FlexcommSpiState spi; };#endif /* HW_FLEXCOMM_H */
include/hw/ssi/flexcomm_spi.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* QEMU model for NXP's FLEXCOMM SPI +* +* Copyright (c) 2024 Google LLC +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef HW_FLEXCOMM_SPI_H +#define HW_FLEXCOMM_SPI_H + +#include "hw/misc/flexcomm_function.h" +#include "hw/ssi/ssi.h" + +#define TYPE_FLEXCOMM_SPI "flexcomm-spi" +OBJECT_DECLARE_TYPE (FlexcommSpiState, FlexcommSpiClass,FLEXCOMM_SPI ); + +struct FlexcommSpiState { +FlexcommFunction parent_obj; + +SSIBus *bus; +qemu_irq cs[4 ]; +bool cs_asserted[4 ]; +uint32_t tx_ctrl; +}; + +struct FlexcommSpiClass { +FlexcommFunctionClass parent_obj; + +FlexcommFunctionSelect select; +}; + +#endif /* HW_FLEXCOMM_SPI_H */
hw/misc/flexcomm.c +3 -0
@@ -25,6 +25,7 @@#include "hw/arm/svd/flexcomm_usart.h" #include "hw/char/flexcomm_usart.h" #include "hw/i2c/flexcomm_i2c.h" +#include "hw/ssi/flexcomm_spi.h" #define REG (s, reg) (s->regs[R_FLEXCOMM_##reg])#define RF_WR (s, reg, field, val) \
@@ -222,6 +223,7 @@ static void flexcomm_init(Object *obj)sysbus_init_irq (sbd, &s->irq);object_initialize_child (obj,"usart" , &s->usart,TYPE_FLEXCOMM_USART );object_initialize_child (obj,"i2c" , &s->i2c,TYPE_FLEXCOMM_I2C ); +object_initialize_child (obj,"spi" , &s->spi,TYPE_FLEXCOMM_SPI ); }static void flexcomm_finalize (Object *obj)
@@ -253,6 +255,7 @@ static void flexcomm_realize(DeviceState *dev, Error **errp)memory_region_add_subregion_overlap (&s->container,0 , &s->mmio,-1 );flexcomm_func_realize_and_unref (FLEXCOMM_FUNCTION (&s->usart), errp);flexcomm_func_realize_and_unref (FLEXCOMM_FUNCTION (&s->i2c), errp); +flexcomm_func_realize_and_unref (FLEXCOMM_FUNCTION (&s->spi), errp); }static const VMStateDescription vmstate_flexcomm = {
hw/ssi/flexcomm_spi.c new file +422 -0
422 lines not on this page · raw message
hw/arm/svd/meson.build +3 -0
@@ -10,4 +10,7 @@ if get_option('mcux-soc-svd') run_target('svd-flexcomm-i2c', command: svd_gen_header + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_i2c.h', '-p', 'I2C0', '-t', 'FLEXCOMM_I2C']) + run_target('svd-flexcomm-spi', command: svd_gen_header + + [ '-i', rt595, '-o', '@SOURCE_ROOT@/include/hw/arm/svd/flexcomm_spi.h', + '-p', 'SPI0', '-t', 'FLEXCOMM_SPI']) endif
hw/misc/Kconfig +1 -0
@@ -216,5 +216,6 @@ config XLNX_VERSAL_TRNG config FLEXCOMM bool select I2C + select SSI source macio/Kconfig
hw/ssi/meson.build +1 -0
@@ -13,3 +13,4 @@ system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_spi.c')) system_ss.add(when: 'CONFIG_IBEX', if_true: files('ibex_spi_host.c')) system_ss.add(when: 'CONFIG_BCM2835_SPI', if_true: files('bcm2835_spi.c')) system_ss.add(when: 'CONFIG_PNV_SPI', if_true: files('pnv_spi.c')) +system_ss.add(when: 'CONFIG_FLEXCOMM', if_true: files('flexcomm_spi.c'))
hw/ssi/trace-events +5 -0
@@ -53,3 +53,8 @@ pnv_spi_rx_read_N2frame(void) "" pnv_spi_shift_rx(uint8_t byte, uint32_t index) "byte = 0x%2.2x into RDR from payload index %d" pnv_spi_sequencer_stop_requested(const char* reason) "due to %s" pnv_spi_RDR_match(const char* result) "%s" + +# flexcomm_spi.c +flexcomm_spi_reg_read(const char *id, const char *reg_name, uint32_t addr, uint32_t val) " %s: %s[0x%04x] -> 0x%08x" +flexcomm_spi_reg_write(const char *id, const char *reg_name, uint32_t addr, uint32_t val) "%s: %s[0x%04x] <- 0x%08x" +flexcomm_spi_irq(const char *id, bool irq, bool fifoirqs, bool perirqs, bool enabled) "%s: %d %d %d %d"
Signature · 1 line
2.46.0.662.g92d0881bb0-goog
PATCH 10/25 hw/misc: add support for RT500's clock controller
In reply to Octavian PurdilaIt supports system and audio PLL initialization and SYSTICK and OSTIMER clock source selection.
The patch includes automatically generated headers which contains the register layout and helpers.
The headers can be regenerated with the svd-rt500-clkctl0 and svd-rt500-clkctl1 targets when the build is configured with --enable-mcux-soc-svd.
--- include/hw/arm/svd/rt500_clkctl0.h | 2483 ++++++++++++++++++++ include/hw/arm/svd/rt500_clkctl1.h | 3396 ++++++++++++++++++++++++++++ include/hw/misc/rt500_clk_freqs.h | 18 + include/hw/misc/rt500_clkctl0.h | 35 + include/hw/misc/rt500_clkctl1.h | 36 + hw/misc/rt500_clkctl0.c | 253 +++ hw/misc/rt500_clkctl1.c | 238 ++ hw/arm/Kconfig | 5 + hw/arm/svd/meson.build | 6 + hw/misc/Kconfig | 3 + hw/misc/meson.build | 1 + hw/misc/trace-events | 8 + 12 files changed, 6482 insertions(+) create mode 100644 include/hw/arm/svd/rt500_clkctl0.h create mode 100644 include/hw/arm/svd/rt500_clkctl1.h create mode 100644 include/hw/misc/rt500_clk_freqs.h create mode 100644 include/hw/misc/rt500_clkctl0.h create mode 100644 include/hw/misc/rt500_clkctl1.h create mode 100644 hw/misc/rt500_clkctl0.c create mode 100644 hw/misc/rt500_clkctl1.c
include/hw/arm/svd/rt500_clkctl0.h new file +2483 -0
@@ -0,0 +1,2483 @@ +/* +* Copyright 2016-2023 NXP SPDX-License-Identifier: BSD-3-Clause +* +* Automatically generated by svd-gen-header.py from MIMXRT595S_cm33.xml +*/ +#pragma once + +#include "hw/register.h" + +/* Clock Controller 0 */ +#define RT500_CLKCTL0_REGS_NO (490) + +/* Clock Control 0 */ +REG32 (RT500_CLKCTL0_PSCCTL0 ,16 ); +/* DSP clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,DSP_CLK ,1 ,1 ); +/* 128KB ROM Controller clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,ROM_CTRLR_CLK ,2 ,1 ); +/* AXI Switch clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,AXI_SWITCH_CLK ,3 ,1 ); +/* AXI Controller clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,AXI_CTLR_CLK ,4 ,1 ); +/* POWERQUAD clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,POWERQUAD_CLK ,8 ,1 ); +/* CASPER clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,CASPER_CLK ,9 ,1 ); +/* HASHCRYPT clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,HASHCRYPT_CLK ,10 ,1 ); +/* PUF clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,PUF_CLK ,11 ,1 ); +/* Random Number Generator (RNG) clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,RNG_CLK ,12 ,1 ); +/* FLEXSPI0 / OTFAD clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,FLEXSPI0_OTFAD_CLK ,16 ,1 ); +/* OTP Controller clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,OTP_CTLR_CLK ,17 ,1 ); +/* FLEXSPI1 clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,FLEXSPI1_CLK ,18 ,1 ); +/* USB HS PHY clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,USBHS_PHY_CLK ,20 ,1 ); +/* USB HS Device clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,USBHS_DEVICE_CLK ,21 ,1 ); +/* USB HS Host clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,USBHS_HOST_CLK ,22 ,1 ); +/* USB HS SRAM clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,USBHS_SRAM_CLK ,23 ,1 ); +/* SCT clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,SCT_CLK ,24 ,1 ); +/* GPU clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,GPU_CLK ,26 ,1 ); +/* Display Controller clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,DISPLAY_CTLR_CLK ,27 ,1 ); +/* MIPI-DSI Controller clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,MIPI_DSI_CTLR_CLK ,28 ,1 ); +/* Smart DMA clock control */ +FIELD (RT500_CLKCTL0_PSCCTL0 ,SMARTDMA_CLK ,30 ,1 ); + +/* Clock Control 1 */ +REG32 (RT500_CLKCTL0_PSCCTL1 ,20 ); +/* SDIO0 clock control */ +FIELD (RT500_CLKCTL0_PSCCTL1 ,SDIO0_CLK ,2 ,1 ); +/* SDIO1 clock control */ +FIELD (RT500_CLKCTL0_PSCCTL1 ,SDIO1_CLK ,3 ,1 ); +/* ACMP0 clock control */ +FIELD (RT500_CLKCTL0_PSCCTL1 ,ACMP0_CLK ,15 ,1 ); +/* ADC0 clock control */ +FIELD (RT500_CLKCTL0_PSCCTL1 ,ADC0_CLK ,16 ,1 ); +/* SHSGPIO0 clock control */ +FIELD (RT500_CLKCTL0_PSCCTL1 ,SHSGPIO0_CLK ,24 ,1 ); + +/* Clock Control 2 */ +REG32 (RT500_CLKCTL0_PSCCTL2 ,24 ); +/* Micro-Tick Timer 0 clock control */ +FIELD (RT500_CLKCTL0_PSCCTL2 ,UTICK0_CLK ,0 ,1 ); +/* Watchdog Timer 0 clock control */ +FIELD (RT500_CLKCTL0_PSCCTL2 ,WWDT0_CLK ,1 ,1 ); +/* Power Management Controller clock control */ +FIELD (RT500_CLKCTL0_PSCCTL2 ,PMC_CLK ,29 ,1 ); + +/* Clock Control 0 Set */ +REG32 (RT500_CLKCTL0_PSCCTL0_SET ,64 ); +/* DSP clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,DSP_CLK ,1 ,1 ); +/* 128KB ROM Controller clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,ROM_CTRLR_CLK ,2 ,1 ); +/* AXI Switch clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,AXI_SWITCH_CLK ,3 ,1 ); +/* AXI Controller clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,AXI_CTLR_CLK ,4 ,1 ); +/* POWERQUAD clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,POWERQUAD_CLK ,8 ,1 ); +/* CASPER clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,CASPER_CLK ,9 ,1 ); +/* HASHCRYPT clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,HASHCRYPT_CLK ,10 ,1 ); +/* PUF clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,PUF_CLK ,11 ,1 ); +/* Random Number Generator (RNG) clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,RNG_CLK ,12 ,1 ); +/* FLEXSPI0 / OTFAD clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,FLEXSPI0_OTFAD_CLK ,16 ,1 ); +/* OTP Controller clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,OTP_CTLR_CLK ,17 ,1 ); +/* FLEXSPI1 clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,FLEXSPI1_CLK ,18 ,1 ); +/* USB HS PHY clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,USBHS_PHY_CLK ,20 ,1 ); +/* USB HS Device clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,USBHS_DEVICE_CLK ,21 ,1 ); +/* USB HS Host clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,USBHS_HOST_CLK ,22 ,1 ); +/* USB HS SRAM clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,USBHS_SRAM_CLK ,23 ,1 ); +/* SCT clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,SCT_CLK ,24 ,1 ); +/* GPU clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,GPU_CLK ,26 ,1 ); +/* Display Controller clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,DISPLAY_CTLR_CLK ,27 ,1 ); +/* MIPI-DSI Controller clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,MIPI_DSI_CTLR_CLK ,28 ,1 ); +/* Smart DMA clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_SET ,SMARTDMA_CLK ,30 ,1 ); + +/* Clock Control 1 Set */ +REG32 (RT500_CLKCTL0_PSCCTL1_SET ,68 ); +/* SDIO0 clock set */ +FIELD (RT500_CLKCTL0_PSCCTL1_SET ,SDIO0_CLK ,2 ,1 ); +/* SDIO1 clock set */ +FIELD (RT500_CLKCTL0_PSCCTL1_SET ,SDIO1_CLK ,3 ,1 ); +/* ACMP0 clock set */ +FIELD (RT500_CLKCTL0_PSCCTL1_SET ,ACMP0_CLK ,15 ,1 ); +/* ADC0 clock set */ +FIELD (RT500_CLKCTL0_PSCCTL1_SET ,ADC0_CLK ,16 ,1 ); +/* SHSGPIO0 clock set */ +FIELD (RT500_CLKCTL0_PSCCTL1_SET ,SHSGPIO0_CLK ,24 ,1 ); + +/* Clock Control 2 Set */ +REG32 (RT500_CLKCTL0_PSCCTL2_SET ,72 ); +/* Micro-Tick Timer 0 clock set */ +FIELD (RT500_CLKCTL0_PSCCTL2_SET ,UTICK0_CLK ,0 ,1 ); +/* Watchdog Timer 0 clock set */ +FIELD (RT500_CLKCTL0_PSCCTL2_SET ,WWDT0_CLK ,1 ,1 ); +/* Power Management Controller clock set */ +FIELD (RT500_CLKCTL0_PSCCTL2_SET ,PMC ,29 ,1 ); + +/* Clock Control 0 Clear */ +REG32 (RT500_CLKCTL0_PSCCTL0_CLR ,112 ); +/* DSP clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,DSP_CLK ,1 ,1 ); +/* 128KB ROM Controller clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,ROM_CTRLR_CLK ,2 ,1 ); +/* AXI Switch clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,AXI_SWITCH_CLK ,3 ,1 ); +/* AXI Controller clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,AXI_CTLR_CLK ,4 ,1 ); +/* POWERQUAD clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,POWERQUAD_CLK ,8 ,1 ); +/* CASPER clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,CASPER_CLK ,9 ,1 ); +/* HASHCRYPT clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,HASHCRYPT_CLK ,10 ,1 ); +/* PUF clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,PUF_CLK ,11 ,1 ); +/* RNG clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,RNG_CLK ,12 ,1 ); +/* FLEXSPI0 / OTFAD clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,FLEXSPI0_OTFAD_CLK ,16 ,1 ); +/* OTP Controller clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,OTP_CTLR_CLK ,17 ,1 ); +/* FLEXSPI1 clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,FLEXSPI1_CLK ,18 ,1 ); +/* USB HS PHY clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,USBHS_PHY_CLK ,20 ,1 ); +/* USB HS Device clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,USBHS_DEVICE_CLK ,21 ,1 ); +/* USB HS Host clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,USBHS_HOST_CLK ,22 ,1 ); +/* USB HS SRAM clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,USBHS_SRAM_CLK ,23 ,1 ); +/* SCT clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,SCT_CLK ,24 ,1 ); +/* GPU clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,GPU_CLK ,26 ,1 ); +/* Display Controller clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,DISPLAY_CTLR_CLK ,27 ,1 ); +/* MIPI-DSI Controller clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,MIPI_DSI_CTLR_CLK ,28 ,1 ); +/* Smart DMA clock set */ +FIELD (RT500_CLKCTL0_PSCCTL0_CLR ,SMARTDMA_CLK ,30 ,1 ); + +/* Clock Control 1 Clear */ +REG32 (RT500_CLKCTL0_PSCCTL1_CLR ,116 ); +/* SDIO0 clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL1_CLR ,SDIO0_CLK ,2 ,1 ); +/* SDIO1 clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL1_CLR ,SDIO1_CLK ,3 ,1 ); +/* ACMP0 clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL1_CLR ,ACMP0_CLK ,15 ,1 ); +/* ADC0 clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL1_CLR ,ADC0_CLK ,16 ,1 ); +/* SHSGPIO0 clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL1_CLR ,SHSGPIO0_CLK ,24 ,1 ); + +/* Clock Control 2 Clear */ +REG32 (RT500_CLKCTL0_PSCCTL2_CLR ,120 ); +/* Micro-Tick Timer 0 clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL2_CLR ,UTICK0_CLK ,0 ,1 ); +/* Watchdog Timer 0 clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL2_CLR ,WWDT0_CLK ,1 ,1 ); +/* Power Management Controller clock clear */ +FIELD (RT500_CLKCTL0_PSCCTL2_CLR ,PMC_CLK ,29 ,1 ); + +/* Free Running Oscillator Control */ +REG32 (RT500_CLKCTL0_FRO_CONTROL ,128 ); +/* Expected Count */ +FIELD (RT500_CLKCTL0_FRO_CONTROL ,EXP_COUNT ,0 ,16 ); +/* Threshold Range Upper Limit */ +FIELD (RT500_CLKCTL0_FRO_CONTROL ,THRESH_RANGE_UP ,16 ,5 ); +/* Threshold Range Lower Limit */ +FIELD (RT500_CLKCTL0_FRO_CONTROL ,THRESH_RANGE_LOW ,21 ,5 ); +/* Enable Tuning */ +FIELD (RT500_CLKCTL0_FRO_CONTROL ,ENA_TUNE ,31 ,1 ); + +/* Free Running Oscillator Captured Value */ +REG32 (RT500_CLKCTL0_FRO_CAPVAL ,132 ); +/* Captured Value */ +FIELD (RT500_CLKCTL0_FRO_CAPVAL ,CAPVAL ,0 ,16 ); +/* Data Valid */ +FIELD (RT500_CLKCTL0_FRO_CAPVAL ,DATA_VALID ,31 ,1 ); + +/* Free Running Oscillator Trim */ +REG32 (RT500_CLKCTL0_FRO_RDTRIM ,140 ); +/* It is the trim value supplied to the oscillator */ +FIELD (RT500_CLKCTL0_FRO_RDTRIM ,TRIM ,0 ,11 ); + +/* Free Running OscillatorSC Trim */ +REG32 (RT500_CLKCTL0_FRO_SCTRIM ,144 ); +/* sc_trim value for the oscillator. */ +FIELD (RT500_CLKCTL0_FRO_SCTRIM ,TRIM ,0 ,6 ); + +/* FRO Clock Divider */ +REG32 (RT500_CLKCTL0_FRODIVSEL ,264 ); +/* Select clock */ +FIELD (RT500_CLKCTL0_FRODIVSEL ,SEL ,0 ,2 ); + +/* FRO Clock Status */ +REG32 (RT500_CLKCTL0_FROCLKSTATUS ,268 ); +/* FRO Clock OK */ +FIELD (RT500_CLKCTL0_FROCLKSTATUS ,CLK_OK ,0 ,1 ); + +/* FRO Enable Register */ +REG32 (RT500_CLKCTL0_FRODIVOEN ,272 ); +/* FRO Divided-by-1 Clock Enable */ +FIELD (RT500_CLKCTL0_FRODIVOEN ,FRO_DIV1_O_EN ,0 ,1 ); +/* FRO Divided-by-2 Clock Enable */ +FIELD (RT500_CLKCTL0_FRODIVOEN ,FRO_DIV2_O_EN ,1 ,1 ); +/* FRO Divided-by-4 Clock Enable */ +FIELD (RT500_CLKCTL0_FRODIVOEN ,FRO_DIV4_O_EN ,2 ,1 ); +/* FRO Divided-by-8 Clock Enable */ +FIELD (RT500_CLKCTL0_FRODIVOEN ,FRO_DIV8_O_EN ,3 ,1 ); +/* FRO Divided-by-16 Clock Enable */ +FIELD (RT500_CLKCTL0_FRODIVOEN ,FRO_DIV16_O_EN ,4 ,1 ); + +/* Low Frequency Clock Divider */ +REG32 (RT500_CLKCTL0_LOWFREQCLKDIV ,304 ); +/* Low Frequency Clock Divider Value */ +FIELD (RT500_CLKCTL0_LOWFREQCLKDIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_LOWFREQCLKDIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_LOWFREQCLKDIV ,HALT ,30 ,1 ); +/* Divider Status Flag */ +FIELD (RT500_CLKCTL0_LOWFREQCLKDIV ,REQFLAG ,31 ,1 ); + +/* System Oscillator Control 0 */ +REG32 (RT500_CLKCTL0_SYSOSCCTL0 ,352 ); +/* Low Power Mode Enable */ +FIELD (RT500_CLKCTL0_SYSOSCCTL0 ,LP_ENABLE ,0 ,1 ); +/* Bypass Enable */ +FIELD (RT500_CLKCTL0_SYSOSCCTL0 ,BYPASS_ENABLE ,1 ,1 ); + +/* OSC Clock Source Select */ +REG32 (RT500_CLKCTL0_SYSOSCBYPASS ,360 ); +/* Select SYSOSC Bypass */ +FIELD (RT500_CLKCTL0_SYSOSCBYPASS ,SEL ,0 ,3 ); + +/* Low Power Oscillator Control 0 */ +REG32 (RT500_CLKCTL0_LPOSCCTL0 ,400 ); +/* LPOSC Clock Ready */ +FIELD (RT500_CLKCTL0_LPOSCCTL0 ,CLKRDY ,31 ,1 ); + +/* 32 KHz Oscillator Control 0 */ +REG32 (RT500_CLKCTL0_OSC32KHZCTL0 ,448 ); +/* 32 KHz Oscillator Enable */ +FIELD (RT500_CLKCTL0_OSC32KHZCTL0 ,ENA32KHZ ,0 ,1 ); + +/* System PLL 0 Clock Select */ +REG32 (RT500_CLKCTL0_SYSPLL0CLKSEL ,512 ); +/* System PLL0 Reference Input Clock Source */ +FIELD (RT500_CLKCTL0_SYSPLL0CLKSEL ,SEL ,0 ,3 ); + +/* System PLL0 Control 0 */ +REG32 (RT500_CLKCTL0_SYSPLL0CTL0 ,516 ); +/* SYSPLL0 BYPASS Mode */ +FIELD (RT500_CLKCTL0_SYSPLL0CTL0 ,BYPASS ,0 ,1 ); +/* SYSPLL0 Reset */ +FIELD (RT500_CLKCTL0_SYSPLL0CTL0 ,RESET ,1 ,1 ); +/* Hold Ring Off Control */ +FIELD (RT500_CLKCTL0_SYSPLL0CTL0 ,HOLDRINGOFF_ENA ,13 ,1 ); +/* Multiplication Factor */ +FIELD (RT500_CLKCTL0_SYSPLL0CTL0 ,MULT ,16 ,8 ); + +/* System PLL0 Lock Time Div2 */ +REG32 (RT500_CLKCTL0_SYSPLL0LOCKTIMEDIV2 ,524 ); +/* SYSPLL0 Lock Time Divide-by-2 */ +FIELD (RT500_CLKCTL0_SYSPLL0LOCKTIMEDIV2 ,LOCKTIMEDIV2 ,0 ,16 ); + +/* System PLL0 Numerator */ +REG32 (RT500_CLKCTL0_SYSPLL0NUM ,528 ); +/* Numerator of the SYSPLL0 fractional loop divider */ +FIELD (RT500_CLKCTL0_SYSPLL0NUM ,NUM ,0 ,30 ); + +/* System PLL0 Denominator */ +REG32 (RT500_CLKCTL0_SYSPLL0DENOM ,532 ); +/* Denominator of the SYSPLL0 fractional loop divider */ +FIELD (RT500_CLKCTL0_SYSPLL0DENOM ,DENOM ,0 ,30 ); + +/* System PLL0 PFD */ +REG32 (RT500_CLKCTL0_SYSPLL0PFD ,536 ); +/* PLL Fractional Divider 0 */ +FIELD (RT500_CLKCTL0_SYSPLL0PFD ,PFD0 ,0 ,6 ); +/* PFD0 Clock Ready Status Flag */ +FIELD (RT500_CLKCTL0_SYSPLL0PFD ,PFD0_CLKRDY ,6 ,1 ); +/* PFD0 Clock Gate */ +FIELD (RT500_CLKCTL0_SYSPLL0PFD ,PFD0_CLKGATE ,7 ,1 ); +/* PLL Fractional Divider 1 */ +FIELD (RT500_CLKCTL0_SYSPLL0PFD ,PFD1 ,8 ,6 ); +/* PFD1 Clock Ready Status Flag */ +FIELD (RT500_CLKCTL0_SYSPLL0PFD ,PFD1_CLKRDY ,14 ,1 ); +/* PFD1 Clock Gate */ +FIELD (RT500_CLKCTL0_SYSPLL0PFD ,PFD1_CLKGATE ,15 ,1 ); +/* PLL Fractional Divider 2 */ +FIELD (RT500_CLKCTL0_SYSPLL0PFD ,PFD2 ,16 ,6 ); +/* PFD2 Clock Ready Status Flag */ +FIELD (RT500_CLKCTL0_SYSPLL0PFD ,PFD2_CLKRDY ,22 ,1 ); +/* PFD2 Clock Gate */ +FIELD (RT500_CLKCTL0_SYSPLL0PFD ,PFD2_CLKGATE ,23 ,1 ); +/* PLL Fractional Divider 3 */ +FIELD (RT500_CLKCTL0_SYSPLL0PFD ,PFD3 ,24 ,6 ); +/* PFD3 Clock Ready Status Flag */ +FIELD (RT500_CLKCTL0_SYSPLL0PFD ,PFD3_CLKRDY ,30 ,1 ); +/* PFD3 Clock Gate */ +FIELD (RT500_CLKCTL0_SYSPLL0PFD ,PFD3_CLKGATE ,31 ,1 ); + +/* Main PLL Clock Divider */ +REG32 (RT500_CLKCTL0_MAINPLLCLKDIV ,576 ); +/* Low Frequency Clock Divider Value */ +FIELD (RT500_CLKCTL0_MAINPLLCLKDIV ,DIV ,0 ,8 ); +/* Resets the divider counter */ +FIELD (RT500_CLKCTL0_MAINPLLCLKDIV ,RESET ,29 ,1 ); +/* Halts the divider counter */ +FIELD (RT500_CLKCTL0_MAINPLLCLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_MAINPLLCLKDIV ,REQFLAG ,31 ,1 ); + +/* DSP PLL Clock Divider */ +REG32 (RT500_CLKCTL0_DSPPLLCLKDIV ,580 ); +/* Low Frequency Clock Divider Value */ +FIELD (RT500_CLKCTL0_DSPPLLCLKDIV ,DIV ,0 ,8 ); +/* Resets the divider counter */ +FIELD (RT500_CLKCTL0_DSPPLLCLKDIV ,RESET ,29 ,1 ); +/* Halts the divider counter */ +FIELD (RT500_CLKCTL0_DSPPLLCLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_DSPPLLCLKDIV ,REQFLAG ,31 ,1 ); + +/* AUX0 PLL Clock Divider */ +REG32 (RT500_CLKCTL0_AUX0PLLCLKDIV ,584 ); +/* Low Frequency Clock Divider Value */ +FIELD (RT500_CLKCTL0_AUX0PLLCLKDIV ,DIV ,0 ,8 ); +/* Resets the divider counter */ +FIELD (RT500_CLKCTL0_AUX0PLLCLKDIV ,RESET ,29 ,1 ); +/* Halts the divider counter */ +FIELD (RT500_CLKCTL0_AUX0PLLCLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_AUX0PLLCLKDIV ,REQFLAG ,31 ,1 ); + +/* AUX1 PLL Clock Divider */ +REG32 (RT500_CLKCTL0_AUX1PLLCLKDIV ,588 ); +/* Low Frequency Clock Divider Value */ +FIELD (RT500_CLKCTL0_AUX1PLLCLKDIV ,DIV ,0 ,8 ); +/* Resets the divider counter */ +FIELD (RT500_CLKCTL0_AUX1PLLCLKDIV ,RESET ,29 ,1 ); +/* Halts the divider counter */ +FIELD (RT500_CLKCTL0_AUX1PLLCLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_AUX1PLLCLKDIV ,REQFLAG ,31 ,1 ); + +/* System CPU AHB Clock Divider */ +REG32 (RT500_CLKCTL0_SYSCPUAHBCLKDIV ,1024 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_SYSCPUAHBCLKDIV ,DIV ,0 ,8 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_SYSCPUAHBCLKDIV ,REQFLAG ,31 ,1 ); + +/* Main Clock Select A */ +REG32 (RT500_CLKCTL0_MAINCLKSELA ,1072 ); +/* Control Main 1st Stage Control Clock Source */ +FIELD (RT500_CLKCTL0_MAINCLKSELA ,SEL ,0 ,2 ); + +/* Main Clock Select B */ +REG32 (RT500_CLKCTL0_MAINCLKSELB ,1076 ); +/* Main Clock Source Selection */ +FIELD (RT500_CLKCTL0_MAINCLKSELB ,SEL ,0 ,2 ); + +/* PFC divider 0 (trace clock) */ +REG32 (RT500_CLKCTL0_PFC0DIV ,1280 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_PFC0DIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_PFC0DIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_PFC0DIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_PFC0DIV ,REQFLAG ,31 ,1 ); + +/* PFC divider 1 (USB HS PHY bus clock) */ +REG32 (RT500_CLKCTL0_PFC1DIV ,1284 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_PFC1DIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_PFC1DIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_PFC1DIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_PFC1DIV ,REQFLAG ,31 ,1 ); + +/* FlexSPI0 Functional Clock Select */ +REG32 (RT500_CLKCTL0_FLEXSPI0FCLKSEL ,1568 ); +/* Select Clock Source */ +FIELD (RT500_CLKCTL0_FLEXSPI0FCLKSEL ,SEL ,0 ,3 ); + +/* FlexSPI0 Functional Clock Divider */ +REG32 (RT500_CLKCTL0_FLEXSPI0FCLKDIV ,1572 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_FLEXSPI0FCLKDIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_FLEXSPI0FCLKDIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_FLEXSPI0FCLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_FLEXSPI0FCLKDIV ,REQFLAG ,31 ,1 ); + +/* FlexSPI1 Functional Clock Select */ +REG32 (RT500_CLKCTL0_FLEXSPI1FCLKSEL ,1584 ); +/* Select Clock Source */ +FIELD (RT500_CLKCTL0_FLEXSPI1FCLKSEL ,SEL ,0 ,3 ); + +/* FlexSPI1 Functional Clock Divider */ +REG32 (RT500_CLKCTL0_FLEXSPI1FCLKDIV ,1588 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_FLEXSPI1FCLKDIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_FLEXSPI1FCLKDIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_FLEXSPI1FCLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_FLEXSPI1FCLKDIV ,REQFLAG ,31 ,1 ); + +/* SCT Functional Clock Select */ +REG32 (RT500_CLKCTL0_SCTFCLKSEL ,1600 ); +/* Select Clock Source */ +FIELD (RT500_CLKCTL0_SCTFCLKSEL ,SEL ,0 ,3 ); + +/* SCT Functional Clock Divider */ +REG32 (RT500_CLKCTL0_SCTIN7CLKDIV ,1604 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_SCTIN7CLKDIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_SCTIN7CLKDIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_SCTIN7CLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_SCTIN7CLKDIV ,REQFLAG ,31 ,1 ); + +/* High Speed USB Functional Clock Select */ +REG32 (RT500_CLKCTL0_USBHSFCLKSEL ,1632 ); +/* Select Clock Source */ +FIELD (RT500_CLKCTL0_USBHSFCLKSEL ,SEL ,0 ,3 ); + +/* High Speed USB Functional Clock Divider */ +REG32 (RT500_CLKCTL0_USBHSFCLKDIV ,1636 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_USBHSFCLKDIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_USBHSFCLKDIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_USBHSFCLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_USBHSFCLKDIV ,REQFLAG ,31 ,1 ); + +/* SDIO0 Functional Clock Select */ +REG32 (RT500_CLKCTL0_SDIO0FCLKSEL ,1664 ); +/* Select Clock Source */ +FIELD (RT500_CLKCTL0_SDIO0FCLKSEL ,SEL ,0 ,3 ); + +/* SDIO0 Functional Clock Divider */ +REG32 (RT500_CLKCTL0_SDIO0FCLKDIV ,1668 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_SDIO0FCLKDIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_SDIO0FCLKDIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_SDIO0FCLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_SDIO0FCLKDIV ,REQFLAG ,31 ,1 ); + +/* SDIO1 Functional Clock Select */ +REG32 (RT500_CLKCTL0_SDIO1FCLKSEL ,1680 ); +/* Select Clock Source */ +FIELD (RT500_CLKCTL0_SDIO1FCLKSEL ,SEL ,0 ,3 ); + +/* SDIO1 Functional Clock Divider */ +REG32 (RT500_CLKCTL0_SDIO1FCLKDIV ,1684 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_SDIO1FCLKDIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_SDIO1FCLKDIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_SDIO1FCLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_SDIO1FCLKDIV ,REQFLAG ,31 ,1 ); + +/* ADC0 Functional Clock Select 0 */ +REG32 (RT500_CLKCTL0_ADC0FCLKSEL0 ,1744 ); +/* Select Clock Source */ +FIELD (RT500_CLKCTL0_ADC0FCLKSEL0 ,SEL ,0 ,3 ); + +/* ADC0 Functional Clock Select 1 */ +REG32 (RT500_CLKCTL0_ADC0FCLKSEL1 ,1748 ); +/* Select Clock Source */ +FIELD (RT500_CLKCTL0_ADC0FCLKSEL1 ,SEL ,0 ,3 ); + +/* ADC0 Functional Clock Divider */ +REG32 (RT500_CLKCTL0_ADC0FCLKDIV ,1752 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_ADC0FCLKDIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_ADC0FCLKDIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_ADC0FCLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_ADC0FCLKDIV ,REQFLAG ,31 ,1 ); + +/* UTICK Functional Clock Select */ +REG32 (RT500_CLKCTL0_UTICKFCLKSEL ,1792 ); +/* Select Clock Source */ +FIELD (RT500_CLKCTL0_UTICKFCLKSEL ,SEL ,0 ,3 ); + +/* WDT0 Functional Clock Select */ +REG32 (RT500_CLKCTL0_WDT0FCLKSEL ,1824 ); +/* Select Clock Source */ +FIELD (RT500_CLKCTL0_WDT0FCLKSEL ,SEL ,0 ,3 ); + +/* 32 KHz Wake Clock Source Select */ +REG32 (RT500_CLKCTL0_A32KHZWAKECLKSEL ,1840 ); +/* Select Clock Source */ +FIELD (RT500_CLKCTL0_A32KHZWAKECLKSEL ,SEL ,0 ,3 ); + +/* 32 KHz Wake Clock Divider */ +REG32 (RT500_CLKCTL0_A32KHZWAKECLKDIV ,1844 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_A32KHZWAKECLKDIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_A32KHZWAKECLKDIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_A32KHZWAKECLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_A32KHZWAKECLKDIV ,REQFLAG ,31 ,1 ); + +/* SYSTICK Functional Clock Select */ +REG32 (RT500_CLKCTL0_SYSTICKFCLKSEL ,1888 ); +/* Select Clock Source */ +FIELD (RT500_CLKCTL0_SYSTICKFCLKSEL ,SEL ,0 ,3 ); + +/* SYSTICK Functional Clock Divider */ +REG32 (RT500_CLKCTL0_SYSTICKFCLKDIV ,1892 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_SYSTICKFCLKDIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_SYSTICKFCLKDIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_SYSTICKFCLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_SYSTICKFCLKDIV ,REQFLAG ,31 ,1 ); + +/* MIPI-DSI PHY Clock Select */ +REG32 (RT500_CLKCTL0_DPHYCLKSEL ,1904 ); +/* Select Clock Source */ +FIELD (RT500_CLKCTL0_DPHYCLKSEL ,SEL ,0 ,3 ); + +/* MIPI-DSI PHY Clock Divider */ +REG32 (RT500_CLKCTL0_DPHYCLKDIV ,1908 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_DPHYCLKDIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_DPHYCLKDIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_DPHYCLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_DPHYCLKDIV ,REQFLAG ,31 ,1 ); + +/* MIPI-DSI DPHY Escape Mode Clock Select */ +REG32 (RT500_CLKCTL0_DPHYESCCLKSEL ,1912 ); +/* Select Clock Source */ +FIELD (RT500_CLKCTL0_DPHYESCCLKSEL ,SEL ,0 ,3 ); + +/* MIPI-DSI DPHY Escape Mode Receive Clock Divider */ +REG32 (RT500_CLKCTL0_DPHYESCRXCLKDIV ,1916 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_DPHYESCRXCLKDIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_DPHYESCRXCLKDIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_DPHYESCRXCLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_DPHYESCRXCLKDIV ,REQFLAG ,31 ,1 ); + +/* MIPI-DSI DPHY Escape Mode Tramsmit Clock Divider */ +REG32 (RT500_CLKCTL0_DPHYESCTXCLKDIV ,1920 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_DPHYESCTXCLKDIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_DPHYESCTXCLKDIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_DPHYESCTXCLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_DPHYESCTXCLKDIV ,REQFLAG ,31 ,1 ); + +/* GPU Clock Select */ +REG32 (RT500_CLKCTL0_GPUCLKSEL ,1936 ); +/* Select Clock Source */ +FIELD (RT500_CLKCTL0_GPUCLKSEL ,SEL ,0 ,3 ); + +/* GPU Clock Divider */ +REG32 (RT500_CLKCTL0_GPUCLKDIV ,1940 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_GPUCLKDIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_GPUCLKDIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_GPUCLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_GPUCLKDIV ,REQFLAG ,31 ,1 ); + +/* LCDIF Pixel Clock Select */ +REG32 (RT500_CLKCTL0_DCPIXELCLKSEL ,1952 ); +/* Select Clock Source */ +FIELD (RT500_CLKCTL0_DCPIXELCLKSEL ,SEL ,0 ,3 ); + +/* LCDIF Pixel Clock Divider */ +REG32 (RT500_CLKCTL0_DCPIXELCLKDIV ,1956 ); +/* Clock Divider Value Selection */ +FIELD (RT500_CLKCTL0_DCPIXELCLKDIV ,DIV ,0 ,8 ); +/* Reset the Divider Counter */ +FIELD (RT500_CLKCTL0_DCPIXELCLKDIV ,RESET ,29 ,1 ); +/* Halt the Divider Counter */ +FIELD (RT500_CLKCTL0_DCPIXELCLKDIV ,HALT ,30 ,1 ); +/* Divider status flag */ +FIELD (RT500_CLKCTL0_DCPIXELCLKDIV ,REQFLAG ,31 ,1 ); + + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_DSP_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_DSP_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_DSP_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_ROM_CTRLR_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_ROM_CTRLR_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_ROM_CTRLR_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_AXI_SWITCH_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_AXI_SWITCH_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_AXI_SWITCH_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_AXI_CTLR_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_AXI_CTLR_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_AXI_CTLR_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_POWERQUAD_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_POWERQUAD_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_POWERQUAD_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_CASPER_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_CASPER_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_CASPER_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_HASHCRYPT_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_HASHCRYPT_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_HASHCRYPT_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_PUF_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_PUF_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_PUF_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_RNG_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_RNG_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_RNG_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_FLEXSPI0_OTFAD_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_FLEXSPI0_OTFAD_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_FLEXSPI0_OTFAD_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_OTP_CTLR_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_OTP_CTLR_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_OTP_CTLR_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_FLEXSPI1_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_FLEXSPI1_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_FLEXSPI1_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_USBHS_PHY_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_USBHS_PHY_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_USBHS_PHY_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_USBHS_DEVICE_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_USBHS_DEVICE_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_USBHS_DEVICE_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_USBHS_HOST_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_USBHS_HOST_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_USBHS_HOST_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_USBHS_SRAM_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_USBHS_SRAM_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_USBHS_SRAM_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_SCT_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_SCT_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_SCT_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_GPU_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_GPU_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_GPU_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_DISPLAY_CTLR_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_DISPLAY_CTLR_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_DISPLAY_CTLR_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_MIPI_DSI_CTLR_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_MIPI_DSI_CTLR_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_MIPI_DSI_CTLR_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL0_SMARTDMA_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL0_SMARTDMA_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL0_SMARTDMA_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL1_SDIO0_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL1_SDIO0_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL1_SDIO0_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL1_SDIO1_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL1_SDIO1_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL1_SDIO1_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL1_ACMP0_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL1_ACMP0_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL1_ACMP0_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL1_ADC0_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL1_ADC0_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL1_ADC0_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL1_SHSGPIO0_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL1_SHSGPIO0_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL1_SHSGPIO0_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL2_UTICK0_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL2_UTICK0_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL2_UTICK0_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL2_WWDT0_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL2_WWDT0_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL2_WWDT0_CLK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_PSCCTL2_PMC_CLK_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_PSCCTL2_PMC_CLK_CLK_ENABLE =1 , +}RT500_CLKCTL0_PSCCTL2_PMC_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_DSP_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_DSP_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_DSP_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_ROM_CTRLR_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_ROM_CTRLR_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_ROM_CTRLR_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_AXI_SWITCH_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_AXI_SWITCH_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_AXI_SWITCH_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_AXI_CTLR_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_AXI_CTLR_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_AXI_CTLR_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_POWERQUAD_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_POWERQUAD_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_POWERQUAD_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_CASPER_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_CASPER_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_CASPER_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_HASHCRYPT_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_HASHCRYPT_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_HASHCRYPT_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_PUF_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_PUF_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_PUF_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_RNG_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_RNG_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_RNG_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_FLEXSPI0_OTFAD_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_FLEXSPI0_OTFAD_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_FLEXSPI0_OTFAD_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_OTP_CTLR_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_OTP_CTLR_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_OTP_CTLR_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_FLEXSPI1_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_FLEXSPI1_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_FLEXSPI1_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_USBHS_PHY_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_USBHS_PHY_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_USBHS_PHY_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_USBHS_DEVICE_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_USBHS_DEVICE_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_USBHS_DEVICE_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_USBHS_HOST_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_USBHS_HOST_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_USBHS_HOST_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_USBHS_SRAM_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_USBHS_SRAM_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_USBHS_SRAM_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_SCT_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_SCT_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_SCT_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_GPU_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_GPU_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_GPU_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_DISPLAY_CTLR_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_DISPLAY_CTLR_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_DISPLAY_CTLR_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_MIPI_DSI_CTLR_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_MIPI_DSI_CTLR_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_MIPI_DSI_CTLR_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_SET_SMARTDMA_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_SET_SMARTDMA_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL0_SET_SMARTDMA_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL1_SET_SDIO0_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL1 register */ +RT500_CLKCTL0_PSCCTL1_SET_SDIO0_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL1_SET_SDIO0_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL1_SET_SDIO1_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL1 register */ +RT500_CLKCTL0_PSCCTL1_SET_SDIO1_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL1_SET_SDIO1_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL1_SET_ACMP0_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL1 register */ +RT500_CLKCTL0_PSCCTL1_SET_ACMP0_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL1_SET_ACMP0_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL1_SET_ADC0_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL1 register */ +RT500_CLKCTL0_PSCCTL1_SET_ADC0_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL1_SET_ADC0_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL1_SET_SHSGPIO0_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL1 register */ +RT500_CLKCTL0_PSCCTL1_SET_SHSGPIO0_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL1_SET_SHSGPIO0_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL2_SET_UTICK0_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL2 register */ +RT500_CLKCTL0_PSCCTL2_SET_UTICK0_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL2_SET_UTICK0_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL2_SET_WWDT0_CLK_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL2 register */ +RT500_CLKCTL0_PSCCTL2_SET_WWDT0_CLK_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL2_SET_WWDT0_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL2_SET_PMC_NO_EFFECT =0 , +/* Sets the corresponding bit in PSCCTL2 register */ +RT500_CLKCTL0_PSCCTL2_SET_PMC_CLK_ENABLE_SET =1 , +}RT500_CLKCTL0_PSCCTL2_SET_PMC_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_DSP_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_DSP_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_DSP_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_ROM_CTRLR_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_ROM_CTRLR_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_ROM_CTRLR_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_AXI_SWITCH_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_AXI_SWITCH_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_AXI_SWITCH_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_AXI_CTLR_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_AXI_CTLR_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_AXI_CTLR_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_POWERQUAD_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_POWERQUAD_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_POWERQUAD_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_CASPER_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_CASPER_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_CASPER_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_HASHCRYPT_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_HASHCRYPT_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_HASHCRYPT_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_PUF_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_PUF_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_PUF_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_RNG_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_RNG_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_RNG_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_FLEXSPI0_OTFAD_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_FLEXSPI0_OTFAD_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_FLEXSPI0_OTFAD_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_OTP_CTLR_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_OTP_CTLR_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_OTP_CTLR_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_FLEXSPI1_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_FLEXSPI1_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_FLEXSPI1_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_USBHS_PHY_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_USBHS_PHY_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_USBHS_PHY_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_USBHS_DEVICE_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_USBHS_DEVICE_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_USBHS_DEVICE_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_USBHS_HOST_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_USBHS_HOST_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_USBHS_HOST_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_USBHS_SRAM_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_USBHS_SRAM_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_USBHS_SRAM_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_SCT_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_SCT_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_SCT_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_GPU_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_GPU_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_GPU_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_DISPLAY_CTLR_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_DISPLAY_CTLR_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_DISPLAY_CTLR_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_MIPI_DSI_CTLR_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_MIPI_DSI_CTLR_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_MIPI_DSI_CTLR_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL0_CLR_SMARTDMA_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL0 register */ +RT500_CLKCTL0_PSCCTL0_CLR_SMARTDMA_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL0_CLR_SMARTDMA_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL1_CLR_SDIO0_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL1 register */ +RT500_CLKCTL0_PSCCTL1_CLR_SDIO0_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL1_CLR_SDIO0_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL1_CLR_SDIO1_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL1 register */ +RT500_CLKCTL0_PSCCTL1_CLR_SDIO1_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL1_CLR_SDIO1_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL1_CLR_ACMP0_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL1 register */ +RT500_CLKCTL0_PSCCTL1_CLR_ACMP0_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL1_CLR_ACMP0_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL1_CLR_ADC0_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL1 register */ +RT500_CLKCTL0_PSCCTL1_CLR_ADC0_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL1_CLR_ADC0_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL1_CLR_SHSGPIO0_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL1 register */ +RT500_CLKCTL0_PSCCTL1_CLR_SHSGPIO0_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL1_CLR_SHSGPIO0_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL2_CLR_UTICK0_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL2 register */ +RT500_CLKCTL0_PSCCTL2_CLR_UTICK0_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL2_CLR_UTICK0_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL2_CLR_WWDT0_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL2 register */ +RT500_CLKCTL0_PSCCTL2_CLR_WWDT0_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL2_CLR_WWDT0_CLK_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PSCCTL2_CLR_PMC_CLK_NO_EFFECT =0 , +/* Clears the corresponding bit in PSCCTL2 register */ +RT500_CLKCTL0_PSCCTL2_CLR_PMC_CLK_CLK_ENABLE_CLEAR =1 , +}RT500_CLKCTL0_PSCCTL2_CLR_PMC_CLK_Enum ; + +typedef enum { +/* Stop tuning */ +RT500_CLKCTL0_FRO_CONTROL_ENA_TUNE_ENA_TUNE_CLEAR =0 , +/* Start tuning */ +RT500_CLKCTL0_FRO_CONTROL_ENA_TUNE_ENA_TUNE_START =1 , +}RT500_CLKCTL0_FRO_CONTROL_ENA_TUNE_Enum ; + +typedef enum { +/* CAPVAL data is not valid */ +RT500_CLKCTL0_FRO_CAPVAL_DATA_VALID_DATA_NOT_VALID =0 , +/* CAPVAL data is valid */ +RT500_CLKCTL0_FRO_CAPVAL_DATA_VALID_DATA_VALID =1 , +}RT500_CLKCTL0_FRO_CAPVAL_DATA_VALID_Enum ; + +typedef enum { +/* FRO_DIV2 */ +RT500_CLKCTL0_FRODIVSEL_SEL_DIVIDEBY2 =0 , +/* FRO_DIV4 */ +RT500_CLKCTL0_FRODIVSEL_SEL_DIVIDEBY4 =1 , +/* FRO_DIV8 */ +RT500_CLKCTL0_FRODIVSEL_SEL_DIVIDEBY8 =2 , +/* FRO_DIV16 */ +RT500_CLKCTL0_FRODIVSEL_SEL_DIVIDEBY16 =3 , +}RT500_CLKCTL0_FRODIVSEL_SEL_Enum ; + +typedef enum { +/* FRO clock has not yet reached 10% frequency accuracy */ +RT500_CLKCTL0_FROCLKSTATUS_CLK_OK_CLK_NOT_OK =0 , +/* FRO clock has reached 10% frequency accuracy */ +RT500_CLKCTL0_FROCLKSTATUS_CLK_OK_CLK_OK =1 , +}RT500_CLKCTL0_FROCLKSTATUS_CLK_OK_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_FRODIVOEN_FRO_DIV1_O_EN_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_FRODIVOEN_FRO_DIV1_O_EN_CLK_ENABLE =1 , +}RT500_CLKCTL0_FRODIVOEN_FRO_DIV1_O_EN_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_FRODIVOEN_FRO_DIV2_O_EN_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_FRODIVOEN_FRO_DIV2_O_EN_CLK_ENABLE =1 , +}RT500_CLKCTL0_FRODIVOEN_FRO_DIV2_O_EN_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_FRODIVOEN_FRO_DIV4_O_EN_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_FRODIVOEN_FRO_DIV4_O_EN_CLK_ENABLE =1 , +}RT500_CLKCTL0_FRODIVOEN_FRO_DIV4_O_EN_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_FRODIVOEN_FRO_DIV8_O_EN_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_FRODIVOEN_FRO_DIV8_O_EN_CLK_ENABLE =1 , +}RT500_CLKCTL0_FRODIVOEN_FRO_DIV8_O_EN_Enum ; + +typedef enum { +/* Disable clock */ +RT500_CLKCTL0_FRODIVOEN_FRO_DIV16_O_EN_CLK_DISABLE =0 , +/* Enable clock */ +RT500_CLKCTL0_FRODIVOEN_FRO_DIV16_O_EN_CLK_ENABLE =1 , +}RT500_CLKCTL0_FRODIVOEN_FRO_DIV16_O_EN_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_LOWFREQCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_LOWFREQCLKDIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_LOWFREQCLKDIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_LOWFREQCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_LOWFREQCLKDIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_LOWFREQCLKDIV_HALT_Enum ; + +typedef enum { +/* The Divider change has finished */ +RT500_CLKCTL0_LOWFREQCLKDIV_REQFLAG_REQFLAG_CHANGE_FINISHED =0 , +/* The Divider value has changed */ +RT500_CLKCTL0_LOWFREQCLKDIV_REQFLAG_REQFLAG_CHANGED =1 , +}RT500_CLKCTL0_LOWFREQCLKDIV_REQFLAG_Enum ; + +typedef enum { +/* Enable High Gain Mode (HP) */ +RT500_CLKCTL0_SYSOSCCTL0_LP_ENABLE_HIGH_GAIN_ENABLE =0 , +/* Enable Low Power mode (LP) */ +RT500_CLKCTL0_SYSOSCCTL0_LP_ENABLE_LOW_POWER_ENABLE =1 , +}RT500_CLKCTL0_SYSOSCCTL0_LP_ENABLE_Enum ; + +typedef enum { +/* Enable Normal mode. Oscillation with crystal connected. */ +RT500_CLKCTL0_SYSOSCCTL0_BYPASS_ENABLE_NORMAL_ENABLE =0 , +/* +* Enable Bypass mode. In this mode a clock can be directly input into the +* XTALIN pin. +*/ +RT500_CLKCTL0_SYSOSCCTL0_BYPASS_ENABLE_BYPASS_ENABLE =1 , +}RT500_CLKCTL0_SYSOSCCTL0_BYPASS_ENABLE_Enum ; + +typedef enum { +/* Select OSC Clock */ +RT500_CLKCTL0_SYSOSCBYPASS_SEL_SYOSC_CLOCK =0 , +/* Select Clock IN clock */ +RT500_CLKCTL0_SYSOSCBYPASS_SEL_CLOCK_IN =1 , +/* None; this may be selected to reduce power when no output is needed */ +RT500_CLKCTL0_SYSOSCBYPASS_SEL_NONE =7 , +}RT500_CLKCTL0_SYSOSCBYPASS_SEL_Enum ; + +typedef enum { +/* LPOSC clock is not ready */ +RT500_CLKCTL0_LPOSCCTL0_CLKRDY_CLK_NOT_READY =0 , +/* LPOSC clock is ready */ +RT500_CLKCTL0_LPOSCCTL0_CLKRDY_CLK_READY =1 , +}RT500_CLKCTL0_LPOSCCTL0_CLKRDY_Enum ; + +typedef enum { +/* Disable oscillator */ +RT500_CLKCTL0_OSC32KHZCTL0_ENA32KHZ_ENA32KHZ_DISABLE =0 , +/* Enable oscillator */ +RT500_CLKCTL0_OSC32KHZCTL0_ENA32KHZ_ENA32KHZ_ENABLE =1 , +}RT500_CLKCTL0_OSC32KHZCTL0_ENA32KHZ_Enum ; + +typedef enum { +/* FRO_DIV8 Clock */ +RT500_CLKCTL0_SYSPLL0CLKSEL_SEL_FRRO_DIV8 =0 , +/* OSC_CLK clock */ +RT500_CLKCTL0_SYSPLL0CLKSEL_SEL_OSC_CLK =1 , +/* None, output gated to reduce power */ +RT500_CLKCTL0_SYSPLL0CLKSEL_SEL_NONE =7 , +}RT500_CLKCTL0_SYSPLL0CLKSEL_SEL_Enum ; + +typedef enum { +/* PFD outputs are PFD-programmed clocks */ +RT500_CLKCTL0_SYSPLL0CTL0_BYPASS_PFD =0 , +/* +* Bypass Mode: PFD outputs are sourced directly from rhe reference input +* clock +*/ +RT500_CLKCTL0_SYSPLL0CTL0_BYPASS_BYPASS =1 , +}RT500_CLKCTL0_SYSPLL0CTL0_BYPASS_Enum ; + +typedef enum { +/* SYSPLL0 reset is removed */ +RT500_CLKCTL0_SYSPLL0CTL0_RESET_NO_RESET =0 , +/* SYSPLL0 is placed into reset */ +RT500_CLKCTL0_SYSPLL0CTL0_RESET_RESET =1 , +}RT500_CLKCTL0_SYSPLL0CTL0_RESET_Enum ; + +typedef enum { +/* Disable */ +RT500_CLKCTL0_SYSPLL0CTL0_HOLDRINGOFF_ENA_DISABLE =0 , +/* Enable */ +RT500_CLKCTL0_SYSPLL0CTL0_HOLDRINGOFF_ENA_ENABLE =1 , +}RT500_CLKCTL0_SYSPLL0CTL0_HOLDRINGOFF_ENA_Enum ; + +typedef enum { +/* Multiply by 16 */ +RT500_CLKCTL0_SYSPLL0CTL0_MULT_DIV16 =16 , +/* Multiply by 17 */ +RT500_CLKCTL0_SYSPLL0CTL0_MULT_DIV17 =17 , +/* Multiply by 18 */ +RT500_CLKCTL0_SYSPLL0CTL0_MULT_DIV18 =18 , +/* Multiply by 19 */ +RT500_CLKCTL0_SYSPLL0CTL0_MULT_DIV19 =19 , +/* Multiply by 20 */ +RT500_CLKCTL0_SYSPLL0CTL0_MULT_DIV20 =20 , +/* Multiply by 21 */ +RT500_CLKCTL0_SYSPLL0CTL0_MULT_DIV21 =21 , +/* Multiply by 22 */ +RT500_CLKCTL0_SYSPLL0CTL0_MULT_DIV22 =22 , +}RT500_CLKCTL0_SYSPLL0CTL0_MULT_Enum ; + +typedef enum { +/* PFD0 clock is not ready */ +RT500_CLKCTL0_SYSPLL0PFD_PFD0_CLKRDY_NOTREADY =0 , +/* PFD0 clock is ready */ +RT500_CLKCTL0_SYSPLL0PFD_PFD0_CLKRDY_READY =1 , +}RT500_CLKCTL0_SYSPLL0PFD_PFD0_CLKRDY_Enum ; + +typedef enum { +/* PFD0 clock is not gated */ +RT500_CLKCTL0_SYSPLL0PFD_PFD0_CLKGATE_NOTGATED =0 , +/* PFD0 clock is gated */ +RT500_CLKCTL0_SYSPLL0PFD_PFD0_CLKGATE_GATED =1 , +}RT500_CLKCTL0_SYSPLL0PFD_PFD0_CLKGATE_Enum ; + +typedef enum { +/* PFD1 clock is not ready */ +RT500_CLKCTL0_SYSPLL0PFD_PFD1_CLKRDY_NOTREADY =0 , +/* PFD1 clock is ready */ +RT500_CLKCTL0_SYSPLL0PFD_PFD1_CLKRDY_READY =1 , +}RT500_CLKCTL0_SYSPLL0PFD_PFD1_CLKRDY_Enum ; + +typedef enum { +/* PFD1 clock is not gated */ +RT500_CLKCTL0_SYSPLL0PFD_PFD1_CLKGATE_NOTGATED =0 , +/* PFD1 clock is gated */ +RT500_CLKCTL0_SYSPLL0PFD_PFD1_CLKGATE_GATED =1 , +}RT500_CLKCTL0_SYSPLL0PFD_PFD1_CLKGATE_Enum ; + +typedef enum { +/* PFD2 clock is not ready */ +RT500_CLKCTL0_SYSPLL0PFD_PFD2_CLKRDY_NOTREADY =0 , +/* PFD2 clock is ready */ +RT500_CLKCTL0_SYSPLL0PFD_PFD2_CLKRDY_READY =1 , +}RT500_CLKCTL0_SYSPLL0PFD_PFD2_CLKRDY_Enum ; + +typedef enum { +/* PFD2 clock is not gated */ +RT500_CLKCTL0_SYSPLL0PFD_PFD2_CLKGATE_NOTGATED =0 , +/* PFD2 clock is gated */ +RT500_CLKCTL0_SYSPLL0PFD_PFD2_CLKGATE_GATED =1 , +}RT500_CLKCTL0_SYSPLL0PFD_PFD2_CLKGATE_Enum ; + +typedef enum { +/* PFD3 clock is not ready */ +RT500_CLKCTL0_SYSPLL0PFD_PFD3_CLKRDY_NOTREADY =0 , +/* PFD3 clock is ready */ +RT500_CLKCTL0_SYSPLL0PFD_PFD3_CLKRDY_READY =1 , +}RT500_CLKCTL0_SYSPLL0PFD_PFD3_CLKRDY_Enum ; + +typedef enum { +/* PFD3 clock is not gated */ +RT500_CLKCTL0_SYSPLL0PFD_PFD3_CLKGATE_NOTGATED =0 , +/* PFD3 clock is gated */ +RT500_CLKCTL0_SYSPLL0PFD_PFD3_CLKGATE_GATED =1 , +}RT500_CLKCTL0_SYSPLL0PFD_PFD3_CLKGATE_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_SYSCPUAHBCLKDIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_SYSCPUAHBCLKDIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_SYSCPUAHBCLKDIV_REQFLAG_Enum ; + +typedef enum { +/* Low Power Oscillator Clock (LPOSC) */ +RT500_CLKCTL0_MAINCLKSELA_SEL_LPOSC =0 , +/* FRODIV which is the output of the FRODIVSEL mux */ +RT500_CLKCTL0_MAINCLKSELA_SEL_FRO_8 =1 , +/* OSC_CLK clock */ +RT500_CLKCTL0_MAINCLKSELA_SEL_OSC_CLK =2 , +/* FRO_DIV1 clock */ +RT500_CLKCTL0_MAINCLKSELA_SEL_FRO =3 , +}RT500_CLKCTL0_MAINCLKSELA_SEL_Enum ; + +typedef enum { +/* MAINCLKSELA 1st Stage Clock */ +RT500_CLKCTL0_MAINCLKSELB_SEL_MAINCLKSELA =0 , +/* Main System PLL Clock */ +RT500_CLKCTL0_MAINCLKSELB_SEL_SYSPLL =1 , +/* RTC 32 KHz Clock */ +RT500_CLKCTL0_MAINCLKSELB_SEL_RTC32KHZ =2 , +}RT500_CLKCTL0_MAINCLKSELB_SEL_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PFC0DIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_PFC0DIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_PFC0DIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PFC0DIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_PFC0DIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_PFC0DIV_HALT_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_PFC0DIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_PFC0DIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_PFC0DIV_REQFLAG_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PFC1DIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_PFC1DIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_PFC1DIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_PFC1DIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_PFC1DIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_PFC1DIV_HALT_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_PFC1DIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_PFC1DIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_PFC1DIV_REQFLAG_Enum ; + +typedef enum { +/* Main Clock */ +RT500_CLKCTL0_FLEXSPI0FCLKSEL_SEL_MAIN =0 , +/* Main System PLL Clock */ +RT500_CLKCTL0_FLEXSPI0FCLKSEL_SEL_PLL =1 , +/* SYSPLL0 AUX0_PLL_Clock */ +RT500_CLKCTL0_FLEXSPI0FCLKSEL_SEL_AUX0_PLL =2 , +/* FRO_DIV1 Clock */ +RT500_CLKCTL0_FLEXSPI0FCLKSEL_SEL_FRO_192M =3 , +/* SYSPLL0 AUX1_PLL_Clock */ +RT500_CLKCTL0_FLEXSPI0FCLKSEL_SEL_AUX1_PLL =4 , +/* None; this may be selected to reduce power when no output is needed. */ +RT500_CLKCTL0_FLEXSPI0FCLKSEL_SEL_NONE =7 , +}RT500_CLKCTL0_FLEXSPI0FCLKSEL_SEL_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_FLEXSPI0FCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_FLEXSPI0FCLKDIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_FLEXSPI0FCLKDIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_FLEXSPI0FCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_FLEXSPI0FCLKDIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_FLEXSPI0FCLKDIV_HALT_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_FLEXSPI0FCLKDIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_FLEXSPI0FCLKDIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_FLEXSPI0FCLKDIV_REQFLAG_Enum ; + +typedef enum { +/* Main Clock */ +RT500_CLKCTL0_FLEXSPI1FCLKSEL_SEL_MAIN =0 , +/* Main System PLL Clock */ +RT500_CLKCTL0_FLEXSPI1FCLKSEL_SEL_PLL =1 , +/* SYSPLL0 AUX0_PLL_Clock */ +RT500_CLKCTL0_FLEXSPI1FCLKSEL_SEL_AUX0_PLL =2 , +/* FRO_DIV1 Clock */ +RT500_CLKCTL0_FLEXSPI1FCLKSEL_SEL_FRO_192M =3 , +/* SYSPLL0 AUX1_PLL_Clock */ +RT500_CLKCTL0_FLEXSPI1FCLKSEL_SEL_AUX1_PLL =4 , +/* None; this may be selected to reduce power when no output is needed. */ +RT500_CLKCTL0_FLEXSPI1FCLKSEL_SEL_NONE =7 , +}RT500_CLKCTL0_FLEXSPI1FCLKSEL_SEL_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_FLEXSPI1FCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_FLEXSPI1FCLKDIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_FLEXSPI1FCLKDIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_FLEXSPI1FCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_FLEXSPI1FCLKDIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_FLEXSPI1FCLKDIV_HALT_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_FLEXSPI1FCLKDIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_FLEXSPI1FCLKDIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_FLEXSPI1FCLKDIV_REQFLAG_Enum ; + +typedef enum { +/* Main Clock */ +RT500_CLKCTL0_SCTFCLKSEL_SEL_MAIN =0 , +/* Main System PLL Clock */ +RT500_CLKCTL0_SCTFCLKSEL_SEL_PLL =1 , +/* SYSPLL0 AUX0_PLL_Clock */ +RT500_CLKCTL0_SCTFCLKSEL_SEL_AUX0_PLL =2 , +/* FRO_DIV1 Clock */ +RT500_CLKCTL0_SCTFCLKSEL_SEL_FRO_192M =3 , +/* SYSPLL0 AUX1_PLL_Clock */ +RT500_CLKCTL0_SCTFCLKSEL_SEL_AUX1_PLL =4 , +/* AUDIO PLL Clock */ +RT500_CLKCTL0_SCTFCLKSEL_SEL_AUDIO_PLL =5 , +/* None; this may be selected to reduce power when no output is needed. */ +RT500_CLKCTL0_SCTFCLKSEL_SEL_NONE =7 , +}RT500_CLKCTL0_SCTFCLKSEL_SEL_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_SCTIN7CLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_SCTIN7CLKDIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_SCTIN7CLKDIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_SCTIN7CLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_SCTIN7CLKDIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_SCTIN7CLKDIV_HALT_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_SCTIN7CLKDIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_SCTIN7CLKDIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_SCTIN7CLKDIV_REQFLAG_Enum ; + +typedef enum { +/* OSC_CLK Clock */ +RT500_CLKCTL0_USBHSFCLKSEL_SEL_OSC_CLK =0 , +/* Main Clock */ +RT500_CLKCTL0_USBHSFCLKSEL_SEL_MAIN =1 , +/* AUX0_PLL_CLOCK */ +RT500_CLKCTL0_USBHSFCLKSEL_SEL_AUX0_PLL_CLOCK =3 , +/* None; this may be selected to reduce power when no output is needed. */ +RT500_CLKCTL0_USBHSFCLKSEL_SEL_NONE =7 , +}RT500_CLKCTL0_USBHSFCLKSEL_SEL_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_USBHSFCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_USBHSFCLKDIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_USBHSFCLKDIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_USBHSFCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_USBHSFCLKDIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_USBHSFCLKDIV_HALT_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_USBHSFCLKDIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_USBHSFCLKDIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_USBHSFCLKDIV_REQFLAG_Enum ; + +typedef enum { +/* Main Clock */ +RT500_CLKCTL0_SDIO0FCLKSEL_SEL_MAIN =0 , +/* System PLL Clock */ +RT500_CLKCTL0_SDIO0FCLKSEL_SEL_PLL =1 , +/* SYSPLL0 AUX0_PLL_Clock */ +RT500_CLKCTL0_SDIO0FCLKSEL_SEL_AUX0_PLL =2 , +/* FRO_DIV2 */ +RT500_CLKCTL0_SDIO0FCLKSEL_SEL_FRO_DIV2 =3 , +/* SYSPLL0 AUX1_PLL_Clock */ +RT500_CLKCTL0_SDIO0FCLKSEL_SEL_AUX1_PLL =4 , +/* None; this may be selected to reduce power when no output is needed. */ +RT500_CLKCTL0_SDIO0FCLKSEL_SEL_NONE =7 , +}RT500_CLKCTL0_SDIO0FCLKSEL_SEL_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_SDIO0FCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_SDIO0FCLKDIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_SDIO0FCLKDIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_SDIO0FCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_SDIO0FCLKDIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_SDIO0FCLKDIV_HALT_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_SDIO0FCLKDIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_SDIO0FCLKDIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_SDIO0FCLKDIV_REQFLAG_Enum ; + +typedef enum { +/* Main Clock */ +RT500_CLKCTL0_SDIO1FCLKSEL_SEL_MAIN =0 , +/* Main System PLL Clock */ +RT500_CLKCTL0_SDIO1FCLKSEL_SEL_PLL =1 , +/* SYSPLL0 AUX0_PLL_Clock */ +RT500_CLKCTL0_SDIO1FCLKSEL_SEL_AUX0_PLL =2 , +/* FRO_DIV2 */ +RT500_CLKCTL0_SDIO1FCLKSEL_SEL_FRO_DIV2 =3 , +/* SYSPLL0 AUX1_PLL_Clock */ +RT500_CLKCTL0_SDIO1FCLKSEL_SEL_AUX1_PLL =4 , +/* None; this may be selected to reduce power when no output is needed. */ +RT500_CLKCTL0_SDIO1FCLKSEL_SEL_NONE =7 , +}RT500_CLKCTL0_SDIO1FCLKSEL_SEL_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_SDIO1FCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_SDIO1FCLKDIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_SDIO1FCLKDIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_SDIO1FCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_SDIO1FCLKDIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_SDIO1FCLKDIV_HALT_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_SDIO1FCLKDIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_SDIO1FCLKDIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_SDIO1FCLKDIV_REQFLAG_Enum ; + +typedef enum { +/* OSC_CLK Clock */ +RT500_CLKCTL0_ADC0FCLKSEL0_SEL_OSC_CLK =0 , +/* Low Power Oscillator Clock (LPOSC) */ +RT500_CLKCTL0_ADC0FCLKSEL0_SEL_LPOSC =1 , +/* FRO_DIV4 */ +RT500_CLKCTL0_ADC0FCLKSEL0_SEL_FRO_DIV4 =2 , +/* None; this may be selected to reduce power when no output is needed. */ +RT500_CLKCTL0_ADC0FCLKSEL0_SEL_NONE =7 , +}RT500_CLKCTL0_ADC0FCLKSEL0_SEL_Enum ; + +typedef enum { +/* ADC0FCLKSEL0 Multiplexed Output */ +RT500_CLKCTL0_ADC0FCLKSEL1_SEL_ADC0FCLKSEL0_MUX =0 , +/* SYSPLL0 MAIN_CLK (PFD0 Output) */ +RT500_CLKCTL0_ADC0FCLKSEL1_SEL_SYSPLL0_MAIN =1 , +/* SYSPLL0 AUX0_PLL_Clock */ +RT500_CLKCTL0_ADC0FCLKSEL1_SEL_SYSPLL0_AUX0_PLL =2 , +/* SYSPLL0 AUX1_PLL_Clock */ +RT500_CLKCTL0_ADC0FCLKSEL1_SEL_SYSPLL0_AUX1_PLL =3 , +/* None; this may be selected to reduce power when no output is needed. */ +RT500_CLKCTL0_ADC0FCLKSEL1_SEL_NONE =7 , +}RT500_CLKCTL0_ADC0FCLKSEL1_SEL_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_ADC0FCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_ADC0FCLKDIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_ADC0FCLKDIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_ADC0FCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_ADC0FCLKDIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_ADC0FCLKDIV_HALT_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_ADC0FCLKDIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_ADC0FCLKDIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_ADC0FCLKDIV_REQFLAG_Enum ; + +typedef enum { +/* Low Power Oscillator Clock (LPOSC) */ +RT500_CLKCTL0_UTICKFCLKSEL_SEL_LPOSC =0 , +/* None; this may be selected to reduce power when no output is needed. */ +RT500_CLKCTL0_UTICKFCLKSEL_SEL_NONE =7 , +}RT500_CLKCTL0_UTICKFCLKSEL_SEL_Enum ; + +typedef enum { +/* Low Power Oscillator Clock (LPOSC) */ +RT500_CLKCTL0_WDT0FCLKSEL_SEL_LPOSC =0 , +/* None; this may be selected to reduce power when no output is needed. */ +RT500_CLKCTL0_WDT0FCLKSEL_SEL_NONE =7 , +}RT500_CLKCTL0_WDT0FCLKSEL_SEL_Enum ; + +typedef enum { +/* 32 KHz */ +RT500_CLKCTL0_A32KHZWAKECLKSEL_SEL_A32KHZ =0 , +/* Low Power Oscillator Clock (LPOSC); divided by 32 by default */ +RT500_CLKCTL0_A32KHZWAKECLKSEL_SEL_LPOSC =1 , +/* None; this may be selected to reduce power when no output is needed. */ +RT500_CLKCTL0_A32KHZWAKECLKSEL_SEL_NONE =7 , +}RT500_CLKCTL0_A32KHZWAKECLKSEL_SEL_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_A32KHZWAKECLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_A32KHZWAKECLKDIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_A32KHZWAKECLKDIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_A32KHZWAKECLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_A32KHZWAKECLKDIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_A32KHZWAKECLKDIV_HALT_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_A32KHZWAKECLKDIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_A32KHZWAKECLKDIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_A32KHZWAKECLKDIV_REQFLAG_Enum ; + +typedef enum { +/* Systick Divider Output Clock */ +RT500_CLKCTL0_SYSTICKFCLKSEL_SEL_SYSTICK_DIV_OUTPUT =0 , +/* Low Power Oscillator Clock (LPOSC) */ +RT500_CLKCTL0_SYSTICKFCLKSEL_SEL_LPOSC =1 , +/* 32 KHz RTC Clock */ +RT500_CLKCTL0_SYSTICKFCLKSEL_SEL_A32KHZ_RTC =2 , +/* None; this may be selected to reduce power when no output is needed. */ +RT500_CLKCTL0_SYSTICKFCLKSEL_SEL_NONE =7 , +}RT500_CLKCTL0_SYSTICKFCLKSEL_SEL_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_SYSTICKFCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_SYSTICKFCLKDIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_SYSTICKFCLKDIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_SYSTICKFCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_SYSTICKFCLKDIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_SYSTICKFCLKDIV_HALT_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_SYSTICKFCLKDIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_SYSTICKFCLKDIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_SYSTICKFCLKDIV_REQFLAG_Enum ; + +typedef enum { +/* FRO_DIV1 Clock */ +RT500_CLKCTL0_DPHYCLKSEL_SEL_FRO =0 , +/* SYSPLL0 MAIN_CLK (PFD0 Output) */ +RT500_CLKCTL0_DPHYCLKSEL_SEL_SYSPLL0_MAIN =1 , +/* SYSPLL0 AUX0_PLL_Clock */ +RT500_CLKCTL0_DPHYCLKSEL_SEL_SYSPLL0_AUX0 =2 , +/* SYSPLL0 AUX1_PLL_Clock */ +RT500_CLKCTL0_DPHYCLKSEL_SEL_SYSPLL0_AUX1 =3 , +/* None; this may be selected to reduce power when no output is needed. */ +RT500_CLKCTL0_DPHYCLKSEL_SEL_NONE =7 , +}RT500_CLKCTL0_DPHYCLKSEL_SEL_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_DPHYCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_DPHYCLKDIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_DPHYCLKDIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_DPHYCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_DPHYCLKDIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_DPHYCLKDIV_HALT_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_DPHYCLKDIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_DPHYCLKDIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_DPHYCLKDIV_REQFLAG_Enum ; + +typedef enum { +/* FRO_DIV1 clock */ +RT500_CLKCTL0_DPHYESCCLKSEL_SEL_FRO_DIV1 =0 , +/* FRO_DIV16 Clock */ +RT500_CLKCTL0_DPHYESCCLKSEL_SEL_FRO_DIV16 =1 , +/* None; this may be selected to reduce power when no output is needed. */ +RT500_CLKCTL0_DPHYESCCLKSEL_SEL_NONE =7 , +}RT500_CLKCTL0_DPHYESCCLKSEL_SEL_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_DPHYESCRXCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_DPHYESCRXCLKDIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_DPHYESCRXCLKDIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_DPHYESCRXCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_DPHYESCRXCLKDIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_DPHYESCRXCLKDIV_HALT_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_DPHYESCRXCLKDIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_DPHYESCRXCLKDIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_DPHYESCRXCLKDIV_REQFLAG_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_DPHYESCTXCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_DPHYESCTXCLKDIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_DPHYESCTXCLKDIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_DPHYESCTXCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_DPHYESCTXCLKDIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_DPHYESCTXCLKDIV_HALT_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_DPHYESCTXCLKDIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_DPHYESCTXCLKDIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_DPHYESCTXCLKDIV_REQFLAG_Enum ; + +typedef enum { +/* Main Clock */ +RT500_CLKCTL0_GPUCLKSEL_SEL_MAIN =0 , +/* FRO_DIV1 clock */ +RT500_CLKCTL0_GPUCLKSEL_SEL_FRO =1 , +/* SYSPLL0 MAIN_CLK (PFD0 Output) */ +RT500_CLKCTL0_GPUCLKSEL_SEL_SYSPLL0_MAIN =2 , +/* SYSPLL0 AUX0_PLL_Clock */ +RT500_CLKCTL0_GPUCLKSEL_SEL_SYSPLL0_AUX0 =3 , +/* SYSPLL0 AUX1_PLL_Clock */ +RT500_CLKCTL0_GPUCLKSEL_SEL_SYSPLL0_AUX1 =4 , +/* None; this may be selected to reduce power when no output is needed. */ +RT500_CLKCTL0_GPUCLKSEL_SEL_NONE =7 , +}RT500_CLKCTL0_GPUCLKSEL_SEL_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_GPUCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_GPUCLKDIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_GPUCLKDIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_GPUCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_GPUCLKDIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_GPUCLKDIV_HALT_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_GPUCLKDIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_GPUCLKDIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_GPUCLKDIV_REQFLAG_Enum ; + +typedef enum { +/* MIPI-DSI PHY Clock */ +RT500_CLKCTL0_DCPIXELCLKSEL_SEL_MIPI_DSI_PHY =0 , +/* Main Clock */ +RT500_CLKCTL0_DCPIXELCLKSEL_SEL_MAIN =1 , +/* FRO_DIV1 Clock */ +RT500_CLKCTL0_DCPIXELCLKSEL_SEL_FRO =2 , +/* SYSPLL0 MAIN_CLK (PFD0 Output) */ +RT500_CLKCTL0_DCPIXELCLKSEL_SEL_SYSPLL0_MAIN =3 , +/* SYSPLL0 AUX0_PLL_Clock */ +RT500_CLKCTL0_DCPIXELCLKSEL_SEL_SYSPLL0_AUX0 =4 , +/* SYSPLL0 AUX1_PLL_Clock */ +RT500_CLKCTL0_DCPIXELCLKSEL_SEL_SYSPLL0_AUX1 =5 , +/* None; this may be selected to reduce power when no output is needed. */ +RT500_CLKCTL0_DCPIXELCLKSEL_SEL_NONE =7 , +}RT500_CLKCTL0_DCPIXELCLKSEL_SEL_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_DCPIXELCLKDIV_RESET_DIVIDER_COUNTER_NOT_RESET =0 , +/* Reset the Divider Counter */ +RT500_CLKCTL0_DCPIXELCLKDIV_RESET_DIVIDER_COUNTER_RESET =1 , +}RT500_CLKCTL0_DCPIXELCLKDIV_RESET_Enum ; + +typedef enum { +/* No effect */ +RT500_CLKCTL0_DCPIXELCLKDIV_HALT_DIVIDER_COUNTER_NOT_HALT =0 , +/* Halt (stop) the Divider Counter */ +RT500_CLKCTL0_DCPIXELCLKDIV_HALT_DIVIDER_COUNTER_HALT =1 , +}RT500_CLKCTL0_DCPIXELCLKDIV_HALT_Enum ; + +typedef enum { +/* The change to the divider value has finished */ +RT500_CLKCTL0_DCPIXELCLKDIV_REQFLAG_DIVIDER_READY =0 , +/* A change is being made to the divider value */ +RT500_CLKCTL0_DCPIXELCLKDIV_REQFLAG_DIVIDER_NOT_READY =1 , +}RT500_CLKCTL0_DCPIXELCLKDIV_REQFLAG_Enum ; + + +#define RT500_CLKCTL0_REGISTER_ACCESS_INFO_ARRAY (_name) \ + struct RegisterAccessInfo _name[RT500_CLKCTL0_REGS_NO] = { \ + [0 ... RT500_CLKCTL0_REGS_NO - 1] = { \ + .name = "", \ + .addr = -1, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL0] = { \ + .name = "PSCCTL0", \ + .addr = 0x10, \ + .ro = 0xA208E0E1, \ + .reset = 0x5, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL1] = { \ + .name = "PSCCTL1", \ + .addr = 0x14, \ + .ro = 0xFEFE7FF3, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL2] = { \ + .name = "PSCCTL2", \ + .addr = 0x18, \ + .ro = 0xDFFFFFFC, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL0_SET] = { \ + .name = "PSCCTL0_SET", \ + .addr = 0x40, \ + .ro = 0xA208E0E1, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL1_SET] = { \ + .name = "PSCCTL1_SET", \ + .addr = 0x44, \ + .ro = 0xFEFE7FF3, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL2_SET] = { \ + .name = "PSCCTL2_SET", \ + .addr = 0x48, \ + .ro = 0xDFFFFFFC, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL0_CLR] = { \ + .name = "PSCCTL0_CLR", \ + .addr = 0x70, \ + .ro = 0xA208E0E1, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL1_CLR] = { \ + .name = "PSCCTL1_CLR", \ + .addr = 0x74, \ + .ro = 0xFEFE7FF3, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_PSCCTL2_CLR] = { \ + .name = "PSCCTL2_CLR", \ + .addr = 0x78, \ + .ro = 0xDFFFFFFC, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_FRO_CONTROL] = { \ + .name = "FRO_CONTROL", \ + .addr = 0x80, \ + .ro = 0x7C000000, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_FRO_CAPVAL] = { \ + .name = "FRO_CAPVAL", \ + .addr = 0x84, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_FRO_RDTRIM] = { \ + .name = "FRO_RDTRIM", \ + .addr = 0x8C, \ + .ro = 0xFFFFF800, \ + .reset = 0x3BF, \ + }, \ + [R_RT500_CLKCTL0_FRO_SCTRIM] = { \ + .name = "FRO_SCTRIM", \ + .addr = 0x90, \ + .ro = 0xFFFFFFC0, \ + .reset = 0x20, \ + }, \ + [R_RT500_CLKCTL0_FRODIVSEL] = { \ + .name = "FRODIVSEL", \ + .addr = 0x108, \ + .ro = 0xFFFFFFFC, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_FROCLKSTATUS] = { \ + .name = "FROCLKSTATUS", \ + .addr = 0x10C, \ + .ro = 0xFFFFFFFF, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_FRODIVOEN] = { \ + .name = "FRODIVOEN", \ + .addr = 0x110, \ + .ro = 0xFFFFFFE0, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_LOWFREQCLKDIV] = { \ + .name = "LOWFREQCLKDIV", \ + .addr = 0x130, \ + .ro = 0x1FFFFF00, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_SYSOSCCTL0] = { \ + .name = "SYSOSCCTL0", \ + .addr = 0x160, \ + .ro = 0xFFFFFFFC, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_SYSOSCBYPASS] = { \ + .name = "SYSOSCBYPASS", \ + .addr = 0x168, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_LPOSCCTL0] = { \ + .name = "LPOSCCTL0", \ + .addr = 0x190, \ + .ro = 0x7FFFFFFF, \ + .reset = 0x807BC4D4, \ + }, \ + [R_RT500_CLKCTL0_OSC32KHZCTL0] = { \ + .name = "OSC32KHZCTL0", \ + .addr = 0x1C0, \ + .ro = 0xFFFFFFFE, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_SYSPLL0CLKSEL] = { \ + .name = "SYSPLL0CLKSEL", \ + .addr = 0x200, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x7, \ + }, \ + [R_RT500_CLKCTL0_SYSPLL0CTL0] = { \ + .name = "SYSPLL0CTL0", \ + .addr = 0x204, \ + .ro = 0xFF00DFFC, \ + .reset = 0x160002, \ + }, \ + [R_RT500_CLKCTL0_SYSPLL0LOCKTIMEDIV2] = { \ + .name = "SYSPLL0LOCKTIMEDIV2", \ + .addr = 0x20C, \ + .ro = 0xFFFF0000, \ + .reset = 0xCAFE, \ + }, \ + [R_RT500_CLKCTL0_SYSPLL0NUM] = { \ + .name = "SYSPLL0NUM", \ + .addr = 0x210, \ + .ro = 0xC0000000, \ + .reset = 0x4DD2F15, \ + }, \ + [R_RT500_CLKCTL0_SYSPLL0DENOM] = { \ + .name = "SYSPLL0DENOM", \ + .addr = 0x214, \ + .ro = 0xC0000000, \ + .reset = 0x1FFFFFDB, \ + }, \ + [R_RT500_CLKCTL0_SYSPLL0PFD] = { \ + .name = "SYSPLL0PFD", \ + .addr = 0x218, \ + .ro = 0x0, \ + .reset = 0x80808080, \ + }, \ + [R_RT500_CLKCTL0_MAINPLLCLKDIV] = { \ + .name = "MAINPLLCLKDIV", \ + .addr = 0x240, \ + .ro = 0x1FFFFF00, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_DSPPLLCLKDIV] = { \ + .name = "DSPPLLCLKDIV", \ + .addr = 0x244, \ + .ro = 0x1FFFFF00, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_AUX0PLLCLKDIV] = { \ + .name = "AUX0PLLCLKDIV", \ + .addr = 0x248, \ + .ro = 0x1FFFFF00, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_AUX1PLLCLKDIV] = { \ + .name = "AUX1PLLCLKDIV", \ + .addr = 0x24C, \ + .ro = 0x1FFFFF00, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_SYSCPUAHBCLKDIV] = { \ + .name = "SYSCPUAHBCLKDIV", \ + .addr = 0x400, \ + .ro = 0x7FFFFF00, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_MAINCLKSELA] = { \ + .name = "MAINCLKSELA", \ + .addr = 0x430, \ + .ro = 0xFFFFFFFC, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_MAINCLKSELB] = { \ + .name = "MAINCLKSELB", \ + .addr = 0x434, \ + .ro = 0xFFFFFFFC, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_PFC0DIV] = { \ + .name = "PFC0DIV", \ + .addr = 0x500, \ + .ro = 0x1FFFFF00, \ + .reset = 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_PFC1DIV] = { \ + .name = "PFC1DIV", \ + .addr = 0x504, \ + .ro = 0x1FFFFF00, \ + .reset = 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_FLEXSPI0FCLKSEL] = { \ + .name = "FLEXSPI0FCLKSEL", \ + .addr = 0x620, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x7, \ + }, \ + [R_RT500_CLKCTL0_FLEXSPI0FCLKDIV] = { \ + .name = "FLEXSPI0FCLKDIV", \ + .addr = 0x624, \ + .ro = 0x1FFFFF00, \ + .reset = 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_FLEXSPI1FCLKSEL] = { \ + .name = "FLEXSPI1FCLKSEL", \ + .addr = 0x630, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x7, \ + }, \ + [R_RT500_CLKCTL0_FLEXSPI1FCLKDIV] = { \ + .name = "FLEXSPI1FCLKDIV", \ + .addr = 0x634, \ + .ro = 0x1FFFFF00, \ + .reset = 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_SCTFCLKSEL] = { \ + .name = "SCTFCLKSEL", \ + .addr = 0x640, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x7, \ + }, \ + [R_RT500_CLKCTL0_SCTIN7CLKDIV] = { \ + .name = "SCTIN7CLKDIV", \ + .addr = 0x644, \ + .ro = 0x1FFFFF00, \ + .reset = 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_USBHSFCLKSEL] = { \ + .name = "USBHSFCLKSEL", \ + .addr = 0x660, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x7, \ + }, \ + [R_RT500_CLKCTL0_USBHSFCLKDIV] = { \ + .name = "USBHSFCLKDIV", \ + .addr = 0x664, \ + .ro = 0x1FFFFF00, \ + .reset = 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_SDIO0FCLKSEL] = { \ + .name = "SDIO0FCLKSEL", \ + .addr = 0x680, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x7, \ + }, \ + [R_RT500_CLKCTL0_SDIO0FCLKDIV] = { \ + .name = "SDIO0FCLKDIV", \ + .addr = 0x684, \ + .ro = 0x1FFFFF00, \ + .reset = 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_SDIO1FCLKSEL] = { \ + .name = "SDIO1FCLKSEL", \ + .addr = 0x690, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x7, \ + }, \ + [R_RT500_CLKCTL0_SDIO1FCLKDIV] = { \ + .name = "SDIO1FCLKDIV", \ + .addr = 0x694, \ + .ro = 0x1FFFFF00, \ + .reset = 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_ADC0FCLKSEL0] = { \ + .name = "ADC0FCLKSEL0", \ + .addr = 0x6D0, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x7, \ + }, \ + [R_RT500_CLKCTL0_ADC0FCLKSEL1] = { \ + .name = "ADC0FCLKSEL1", \ + .addr = 0x6D4, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x7, \ + }, \ + [R_RT500_CLKCTL0_ADC0FCLKDIV] = { \ + .name = "ADC0FCLKDIV", \ + .addr = 0x6D8, \ + .ro = 0x1FFFFF00, \ + .reset = 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_UTICKFCLKSEL] = { \ + .name = "UTICKFCLKSEL", \ + .addr = 0x700, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x7, \ + }, \ + [R_RT500_CLKCTL0_WDT0FCLKSEL] = { \ + .name = "WDT0FCLKSEL", \ + .addr = 0x720, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x0, \ + }, \ + [R_RT500_CLKCTL0_A32KHZWAKECLKSEL] = { \ + .name = "A32KHZWAKECLKSEL", \ + .addr = 0x730, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x1, \ + }, \ + [R_RT500_CLKCTL0_A32KHZWAKECLKDIV] = { \ + .name = "A32KHZWAKECLKDIV", \ + .addr = 0x734, \ + .ro = 0x1FFFFF00, \ + .reset = 0x1F, \ + }, \ + [R_RT500_CLKCTL0_SYSTICKFCLKSEL] = { \ + .name = "SYSTICKFCLKSEL", \ + .addr = 0x760, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x7, \ + }, \ + [R_RT500_CLKCTL0_SYSTICKFCLKDIV] = { \ + .name = "SYSTICKFCLKDIV", \ + .addr = 0x764, \ + .ro = 0x1FFFFF00, \ + .reset = 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_DPHYCLKSEL] = { \ + .name = "DPHYCLKSEL", \ + .addr = 0x770, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x7, \ + }, \ + [R_RT500_CLKCTL0_DPHYCLKDIV] = { \ + .name = "DPHYCLKDIV", \ + .addr = 0x774, \ + .ro = 0x1FFFFF00, \ + .reset = 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_DPHYESCCLKSEL] = { \ + .name = "DPHYESCCLKSEL", \ + .addr = 0x778, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x7, \ + }, \ + [R_RT500_CLKCTL0_DPHYESCRXCLKDIV] = { \ + .name = "DPHYESCRXCLKDIV", \ + .addr = 0x77C, \ + .ro = 0x1FFFFF00, \ + .reset = 0x40000010, \ + }, \ + [R_RT500_CLKCTL0_DPHYESCTXCLKDIV] = { \ + .name = "DPHYESCTXCLKDIV", \ + .addr = 0x780, \ + .ro = 0x1FFFFF00, \ + .reset = 0x40000011, \ + }, \ + [R_RT500_CLKCTL0_GPUCLKSEL] = { \ + .name = "GPUCLKSEL", \ + .addr = 0x790, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x7, \ + }, \ + [R_RT500_CLKCTL0_GPUCLKDIV] = { \ + .name = "GPUCLKDIV", \ + .addr = 0x794, \ + .ro = 0x1FFFFF00, \ + .reset = 0x40000000, \ + }, \ + [R_RT500_CLKCTL0_DCPIXELCLKSEL] = { \ + .name = "DCPIXELCLKSEL", \ + .addr = 0x7A0, \ + .ro = 0xFFFFFFF8, \ + .reset = 0x7, \ + }, \ + [R_RT500_CLKCTL0_DCPIXELCLKDIV] = { \ + .name = "DCPIXELCLKDIV", \ + .addr = 0x7A4, \ + .ro = 0x1FFFFF00, \ + .reset = 0x40000000, \ + }, \ + }
include/hw/arm/svd/rt500_clkctl1.h new file +3396 -0
517 lines not on this page · raw message
include/hw/misc/rt500_clk_freqs.h new file +18 -0
Lines of this file are not shown. View the raw message.
include/hw/misc/rt500_clkctl0.h new file +35 -0
Lines of this file are not shown. View the raw message.
include/hw/misc/rt500_clkctl1.h new file +36 -0
Lines of this file are not shown. View the raw message.
hw/misc/rt500_clkctl0.c new file +253 -0
253 lines not on this page · raw message
hw/misc/rt500_clkctl1.c new file +238 -0
238 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.46.0.662.g92d0881bb0-goog
Part of the diff is not shown here. View the raw message.