Skip to content

Commit

Permalink
Remove CM7_GPIO[2|3] from CM4
Browse files Browse the repository at this point in the history
See notes in the patching file. It's a bit verbose because svdtools
doesn't have first-class support for what we want. However, it does the
job of removing the invalid GPIOs from the CM4 register access layer.
  • Loading branch information
mciantyre committed Jul 31, 2022
1 parent a7534d8 commit dd88a9a
Show file tree
Hide file tree
Showing 8 changed files with 1,175 additions and 1,416 deletions.
59 changes: 54 additions & 5 deletions devices/imxrt1176_cm4.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
_svd: "../svd/imxrt1176_cm4.svd"

_delete:
- AUDIO_PLL
- VIDEO_PLL
- ETHERNET_PLL

# TODO figure out which patches apply

DMA1:
Expand All @@ -26,6 +21,60 @@ DMA1:
"TCD*_BITER_ELINKNO": {}
"TCD*_BITER_ELINKYES": {}

# Remove the CM7_GPIO[2|3] peripherals.
#
# This is a verbose workaround for https://github.com/stm32-rs/svdtools/issues/30.
# Also identified in https://github.com/stm32-rs/svdtools/issues/9#issuecomment-605467243
# The goal is to remove the CM7_GPIO[2|3], then fix the rest of the GPIOs so that they
# derive from another GPIO. I tried combinations of rebases and renames without luck.
# So the process follows
#
# 1. Remove GPIO2 and CM7_GPIO3.
# 2. Rename CM7_GPIO2 to GPIO2, and fix up addresses n'at. (Effectively removes CM7_GPIO2.)
# 3. (Re)Add the interrupts for GPIO2.
# 4. Change all other GPIO derivations to point at GPIO2.

_delete:
- GPIO2
- CM7_GPIO3

# Removing these because they're all aliased, and they're all
# (incorrectly) pointing at address zero.
- AUDIO_PLL
- VIDEO_PLL
- ETHERNET_PLL

_modify:
CM7_GPIO2:
name: GPIO2
baseAddress: 0x40130000
addressBlock:
offset: 0
size: 0x90
usage: registers

GPIO2:
_add:
_interrupts:
GPIO2_Combined_0_15:
value: 102
GPIO2_Combined_16_31:
value: 103

_derive:
GPIO1: GPIO2
GPIO3: GPIO2
GPIO4: GPIO2
GPIO5: GPIO2
GPIO6: GPIO2
GPIO7: GPIO2
GPIO8: GPIO2
GPIO9: GPIO2
GPIO10: GPIO2
GPIO11: GPIO2
GPIO12: GPIO2
GPIO13: GPIO2

# All of the directives below this comment are removing or simplifying
# duplicated enumeratedValue fields in select register fields. These prevent
# compilation due to duplicate symbols.
Expand Down
2 changes: 2 additions & 0 deletions devices/imxrt1176_cm7.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
_svd: "../svd/imxrt1176_cm7.svd"

_delete:
# Removing these because they're all aliased, and they're all
# (incorrectly) pointing at address zero.
- AUDIO_PLL
- VIDEO_PLL
- ETHERNET_PLL
Expand Down
2 changes: 1 addition & 1 deletion imxrtral.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ def from_svd(cls, svd, node, register_ctx):
df = node.attrib['derivedFrom']
df_node = svd.find(f".//peripheral[name='{df}']")
if df_node is None:
raise ValueError(f"Can't find derivedFrom[{df}]")
raise ValueError(f"Can't find derivedFrom[{df}] for peripheral {name}")
desc = get_string(df_node, 'description', default=desc)
addr = get_int(node, 'baseAddress', addr)
registers = df_node.find('registers')
Expand Down
272 changes: 0 additions & 272 deletions src/imxrt117/imxrt1176_cm4/cm7_gpio.rs

This file was deleted.

9 changes: 2 additions & 7 deletions src/imxrt117/imxrt1176_cm4/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ pub use super::instances::sram;
pub use super::instances::ssarc_hp;
pub use super::instances::ssarc_lp;
pub use super::instances::xrdc2_d;
pub mod cm7_gpio;
pub mod gpio;
pub mod lmem;
pub mod mcm;
Expand Down Expand Up @@ -295,10 +294,8 @@ pub struct Peripherals {
pub XRDC2_D0: xrdc2_d::Instance<0>,
pub XRDC2_D1: xrdc2_d::Instance<1>,
pub CDOG: cdog::Instance<0>,
pub CM7_GPIO2: cm7_gpio::Instance<2>,
pub CM7_GPIO3: cm7_gpio::Instance<3>,
pub GPIO1: gpio::Instance<1>,
pub GPIO2: gpio::Instance<2>,
pub GPIO1: gpio::Instance<1>,
pub GPIO3: gpio::Instance<3>,
pub GPIO4: gpio::Instance<4>,
pub GPIO5: gpio::Instance<5>,
Expand Down Expand Up @@ -501,10 +498,8 @@ impl Peripherals {
XRDC2_D0: xrdc2_d::XRDC2_D0::steal(),
XRDC2_D1: xrdc2_d::XRDC2_D1::steal(),
CDOG: cdog::CDOG::steal(),
CM7_GPIO2: cm7_gpio::CM7_GPIO2::steal(),
CM7_GPIO3: cm7_gpio::CM7_GPIO3::steal(),
GPIO1: gpio::GPIO1::steal(),
GPIO2: gpio::GPIO2::steal(),
GPIO1: gpio::GPIO1::steal(),
GPIO3: gpio::GPIO3::steal(),
GPIO4: gpio::GPIO4::steal(),
GPIO5: gpio::GPIO5::steal(),
Expand Down
Loading

0 comments on commit dd88a9a

Please sign in to comment.