Add shared TLV320AIC3204 driver and simplify XK-EVK-XU316 I2C plumbing - #81
Open
xross wants to merge 1 commit into
Open
Add shared TLV320AIC3204 driver and simplify XK-EVK-XU316 I2C plumbing#81xross wants to merge 1 commit into
xross wants to merge 1 commit into
Conversation
xross
force-pushed
the
feature/tlv320aic3204-driver
branch
3 times, most recently
from
August 25, 2026 14:13
7d7ddbd to
d137f42
Compare
There was a problem hiding this comment.
Pull request overview
This PR extracts the TLV320AIC3204 CODEC register configuration into a shared driver, updates the XK-EVK-XU316 board API to use an i2c_master_if connection instead of chanend-based remoting, and formalizes the existing lib_locks dependency.
Changes:
- Added a shared TLV320AIC3204 driver (
tlv320aic3204_init()/tlv320aic3204_config()) and documented its configuration options. - Reworked XK-EVK-XU316 I2C/CODEC plumbing to use a cross-tile
i2c_master_ifconnection (breaking API change) and updated examples/docs accordingly. - Declared
lib_locksas a dependency and updated docs/changelog/.gitignore.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| README.rst | Documents lib_locks as a required dependency. |
| lib_board_support/src/drivers/tlv320aic3204.xc | Adds shared TLV320AIC3204 initialization/config implementation. |
| lib_board_support/src/boards/xk_evk_xu316/xk_evk_xu316_board.xc | Switches XK-EVK-XU316 to shared CODEC init + interface-based I2C use. |
| lib_board_support/module_build_info | Adds lib_locks to module dependency list. |
| lib_board_support/lib_build_info.cmake | Adds lib_locks to registered dependent modules. |
| lib_board_support/api/drivers/tlv320aic3204.h | Introduces shared driver public types/APIs and routing options. |
| lib_board_support/api/boards/xk_evk_xu316/board.h | Updates board API to use i2c_master_if and documents new usage pattern. |
| examples/app_evk_316_simple_c/src/top_level.xc | Updates example to use cross-tile i2c_master_if instead of chanend. |
| examples/app_evk_316_simple_c/src/main.c | Updates example to use new XK-EVK-XU316 interface-based API. |
| doc/rst/lib_board_support.rst | Updates documentation to recommend interface-based cross-tile I2C pattern + adds driver API section. |
| doc/Doxyfile.inc | Adds api/drivers to Doxygen input paths. |
| CHANGELOG.rst | Records new driver, breaking API change, and dependency fix under UNRELEASED. |
| .gitignore | Ignores built documentation output directory. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+69
to
+70
| * The driver runs on the tile that owns the I2C master; boards whose ``AudioHwInit()`` | ||
| * is called from a different tile must remote the call over a channel. |
Comment on lines
+13
to
+22
| static inline void reg_write(client interface i2c_master_if i2c, unsigned reg, unsigned val) | ||
| { | ||
| i2c.write_reg(AIC3204_I2C_DEVICE_ADDR, reg, val); | ||
| } | ||
|
|
||
| static inline unsigned reg_read(client interface i2c_master_if i2c, unsigned reg) | ||
| { | ||
| i2c_regop_res_t result; | ||
| return i2c.read_reg(AIC3204_I2C_DEVICE_ADDR, reg, result); | ||
| } |
Comment on lines
+68
to
+70
| const int status = tlv320aic3204_init(i2c, codec_config); | ||
|
|
||
| assert(status == AIC3204_OK && msg("CODEC reg read problem")); |
Extract the TLV320AIC3204 configuration sequence into a shared driver so other boards with this CODEC can reuse it. The sequence programmed on XK-EVK-XU316 is unchanged. Replace the XK-EVK-XU316 chanend remoting with an i2c_master_if connection, as used by xk_audio_316_mc_ab. Interface connections may span tiles, so the adaptor task, the audioHwCmd_t enum and the unsafe global chanend all go. Breaking API change. The driver now checks every I2C access and returns AIC3204_ERR_I2C on failure, so a board that previously initialised despite a failing access will now fail init. Also declare the lib_locks dependency the XK-AUDIO-216-MC GPIO driver has always needed via swlock.
xross
force-pushed
the
feature/tlv320aic3204-driver
branch
from
August 25, 2026 15:30
d137f42 to
ec8a552
Compare
ed-xmos
reviewed
Aug 26, 2026
|
|
||
|
|
||
| void tile_0_main(chanend_t c){ | ||
| void tile_0_main(SERVER_INTERFACE(i2c_master_if, i_i2c)){ |
ed-xmos
approved these changes
Aug 26, 2026
ed-xmos
left a comment
Contributor
There was a problem hiding this comment.
Useful tidy up. No issues spotted. Wondering if this wasn't an opportunity to change files to C though?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extract the TLV320AIC3204 configuration sequence out of the XK-EVK-XU316 board file into a shared driver so that other boards carrying the same CODEC can reuse it (this CODEC is used on a few XMOS boats now). The register sequence programmed on XK-EVK-XU316 is unchanged.
Replace the chanend remoting in XK-EVK-XU316 with an i2c_master_if connection, following the pattern already used by xk_audio_316_mc_ab. An interface connection may span tiles, so the private channel-to- interface adaptor task, the audioHwCmd_t command enum and the unsafe global chanend are all no longer needed. This is a breaking API change.
Also declare the lib_locks dependency that the XK-AUDIO-216-MC GPIO driver has always required via its use of swlock.