Skip to content

arch/arm64/imx9: Add SAR ADC support#18870

Open
jihonen wants to merge 1 commit into
apache:masterfrom
jihonen:imx9-sar-adc-support
Open

arch/arm64/imx9: Add SAR ADC support#18870
jihonen wants to merge 1 commit into
apache:masterfrom
jihonen:imx9-sar-adc-support

Conversation

@jihonen
Copy link
Copy Markdown

@jihonen jihonen commented May 12, 2026

• Add support for the i.MX9 SAR ADC block.

The driver provides initialization, de-initialization, channel-mask validation, and one-shot reads for the supported ADC channels. It also handles ADC clock bring-up, power-up, calibration, and raw 12-bit result extraction from the per-channel data registers.

Summary

Add a basic helper driver for the i.MX9 SAR ADC block in arch/arm64/src/imx9.

This adds the low-level ADC bring-up and sampling path needed for board-level analog sampling on i.MX9 systems, so board code does not need to duplicate the register setup and conversion flow.

The driver:

  • enables and disables the ADC clock tree through the i.MX9 CCM helpers
  • powers up the ADC block
  • runs the calibration sequence during initialization
  • clears stale status before the first conversion
  • starts one-shot conversions on a requested channel
  • reads the raw 12-bit result from the per-channel data register
  • reports initialization state for board code

Impact

This change adds new runtime support in arch/arm64/src/imx9 only.
Impact areas:

  • Build: imx9_sar_adc.c is compiled when CONFIG_IMX9_SAR_ADC is enabled
  • Runtime: adds ADC initialization, de-initialization, and read support for the i.MX9 SAR ADC block
  • API: adds the internal helper interface in imx9_sar_adc.h for board/arch bring-up code
  • Compatibility: no existing user-space API is changed
  • Documentation: no documentation updates were included in this change
  • Security: no security-sensitive behavior is introduced

Testing

Testing performed:

  • Built and ran on i.MX 93 hardware
  • Verified ADC reporting with listener adc_report

Observed output:

TOPIC: adc_report
  adc_report
    timestamp: 11804674 (0.001465 seconds ago)
    device_id: 9371904 (Type: 0x8F, UNKNOWN:0 (0x01))
    raw_data: [2024, 2032, 1355, 6, 0, 0, 0, 0, 0, 0, 0, 0]
    resolution: 4096
    v_ref: 1.80000
    channel_id: [0, 1, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1]

References:

  • nuttx: arch/arm64/src/imx9/imx9_sar_adc.c
  • nuttx: arch/arm64/src/imx9/imx9_sar_adc.h

Dependencies:

  • none

@github-actions github-actions Bot added Arch: arm64 Issues related to ARM64 (64-bit) architecture Size: L The size of the change in this PR is large labels May 12, 2026
@jihonen jihonen marked this pull request as ready for review May 13, 2026 11:08
@jihonen jihonen requested a review from pussuw as a code owner May 13, 2026 11:08
Comment thread arch/arm64/src/imx9/imx9_sar_adc.c Outdated
Copy link
Copy Markdown
Contributor

@acassis acassis left a comment

Choose a reason for hiding this comment

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

@jihonen Nice work! I noticed that iMX9 family is missing a landing page: https://nuttx.apache.org/docs/latest/platforms/arm64/imx9/index.html like other chips, i.e.: https://nuttx.apache.org/docs/latest/platforms/arm/s32k1xx/index.html

Could you please just add a "Supported Modules & Peripherals" there adding ADC as Yes ?

Add support for the i.MX9 SAR ADC block.

The driver provides initialization, deinitialization, channel-mask
validation, and one-shot reads for the supported ADC channels. It also
handles the ADC clock bring-up, power-up sequence, calibration, and raw
12-bit result extraction from the per-channel data registers.

Signed-off-by: Joonas Ihonen <joonas.ihonen@tii.ae>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm64 Issues related to ARM64 (64-bit) architecture Size: L The size of the change in this PR is large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants