Skip to content

Add shared TLV320AIC3204 driver and simplify XK-EVK-XU316 I2C plumbing - #81

Open
xross wants to merge 1 commit into
xmos:developfrom
xross:feature/tlv320aic3204-driver
Open

Add shared TLV320AIC3204 driver and simplify XK-EVK-XU316 I2C plumbing#81
xross wants to merge 1 commit into
xmos:developfrom
xross:feature/tlv320aic3204-driver

Conversation

@xross

@xross xross commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

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.

@xross
xross force-pushed the feature/tlv320aic3204-driver branch 3 times, most recently from 7d7ddbd to d137f42 Compare August 25, 2026 14:13
@xross
xross requested review from ed-xmos and a lite review from Copilot August 25, 2026 14:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_if connection (breaking API change) and updated examples/docs accordingly.
  • Declared lib_locks as 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
xross force-pushed the feature/tlv320aic3204-driver branch from d137f42 to ec8a552 Compare August 25, 2026 15:30


void tile_0_main(chanend_t c){
void tile_0_main(SERVER_INTERFACE(i2c_master_if, i_i2c)){

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of xccompat

@ed-xmos ed-xmos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useful tidy up. No issues spotted. Wondering if this wasn't an opportunity to change files to C though?

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.

3 participants