Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unmappable memory generator #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SpinFast
Copy link

@SpinFast SpinFast commented Nov 29, 2023

Adds a custom generator for interface based (unmappable memory) register manipulation.

Based on the i2c branch adds a interface based regblock where the interface is expected to provide a simple single register read/write fallible function pair.

Every register then can be written, read, modified similarly to how chiptool does things for mappable memory regions.

I'm testing this out in conjunction with a driver for the WM8960 on many imxrt boards

https://github.com/spinfast/wm8960-rs

@SpinFast SpinFast marked this pull request as ready for review November 30, 2023 13:36
@SpinFast
Copy link
Author

Maybe not complete or full proof yet, but the idea and code seems to be working out for me.

Moves the existing codegen into a mmio and makes it the default.
The existing mmio generator is for mappable register maps where a
simple pointer with offsets and infallible access is expected.

Adds a new iface based generator for non-memory mappable register maps
where access is expected to be fallible and require a simple read/write
interface.

The read/write register interface then provides all of the same kinds of
functions that a typical regmap block generated by chiptool would have,
with all functions being fallible.

This enables generating regmaps from yaml files for peripheral chips on
buses such as i2c or spi. No builtin notion of *how* th register map is
accessible other than a simple read function given a register address
and write function given an address and value are implementable by a
driver.

A driver using this for the WM8960 codec which requires some peculiar
attributes was used to ensure the generated code was usable.

This device in particular has some interesting quirks. The address size
is 7 bits, the value size is 9 bits, and no reads are available over i2c
for the device. Everything works as expected and the value/address
container sizes are u8 and u16 as might be expected.

Initial code was derived from the i2c branch Dario Nieuwenhuis had
created for chiptool likely for the same goal.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
@SpinFast
Copy link
Author

SpinFast commented Dec 6, 2023

@Dirbaio I'm waiting on this to publish my wm8960 crate, it would be great if this could be added and rolled into a new released version of chiptool

wm8960-rs is working well for me

@bh1xuw
Copy link

bh1xuw commented Jul 15, 2024

I've done almost the same experiments like this. https://github.com/embedded-drivers/yaml2pac

https://github.com/embedded-drivers/edrv-uart/blob/main/uart_dw_apb.yaml

I was thinking something like:

yaml2pac --memory-access i2c sensor.yaml

yaml2pac --memory-access csr riscv-csr.yaml

yaml2pac --memory-access none whatever.yaml

IMHO, it is better to keep chiptool as it is for generating MCU register blocks.(introducing unused field is no meaning to metapac crates).
The idea of mapping register blocks using YAML can be borrowed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants