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

drivers: adc: ti_k3: initial support #87462

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

Conversation

natto1784
Copy link
Contributor

This patch adds the ADC driver for TI K3 family of SoCs. Technical reference can be found in the Technical Reference Manual (TRM) of the board.

@zephyrbot zephyrbot added platform: TI SimpleLink Texas Instruments SimpleLink MCU platform: TI K3 Texas Instruments Keystone 3 Processors area: ADC Analog-to-Digital Converter (ADC) labels Mar 21, 2025
@natto1784 natto1784 marked this pull request as draft March 21, 2025 09:12
This patch adds the ADC driver for TI K3 family of SoCs. Technical
reference can be found in the Technical Reference Manual (TRM) of the
board.

Signed-off-by: Amneesh Singh <a-singh7@ti.com>
@natto1784
Copy link
Contributor Author

is checkpatch.pl reporting false-negatives here?

@carlescufi
Copy link
Member

carlescufi commented Mar 21, 2025

is checkpatch.pl reporting false-negatives here?

I don't think so, you are missing blank lines after declaring variables. Actually, it's a bit strange, I agree. It may be all these prefixed struct members that are confusing it ?

@natto1784
Copy link
Contributor Author

is checkpatch.pl reporting false-negatives here?

I don't think so, you are missing blank lines after declaring variables. Actually, it's a bit strange, I agree. It may be all these prefixed struct members that are confusing it ?

that was my first thought as well, that is likely, will read the script later


description: TI K3-family ADC

compatible: "ti,adc-k3"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I honestly see no pattern in compatible strings added by TI. The GPIO is called davince, I2C is called omap and the ADC is now called k3.

Linux documentation says [1] this ADC is compatible with AM335x and K3. So, I think this is just a general ADC block used in multiple chips. I don't think someone will boot Zephyr on AM335x anymore, but your next generation of chips will most likely use this block again. Probably looks odd when the k4 architecture uses ti,adc-k3.

It doesn't look like Zephyr supports multiple compatible strings per driver. So, I personally would just call it ti,tscadc.

1: https://www.kernel.org/doc/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that the compatible strings are indeed confusing, but I don't think adding ti,tscadc is a good idea since that would imply a touchscreen controller as well. I am at a loss here but feel free to suggest more compatible strings, maybe "ti,adc-am335x" or "ti,am335x-adc" for linux compatibility is a good idea?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@vaishnavachath any thoughts on that topic?

@natto1784 maybe ti,k3-adc is indeed the best name and future platforms just use compatible = "ti,k3-adc", "ti,k4-adc" in the device-tree. Similar what happened in Linux. Using am335 here might indicate there is actually support for that product. We also don't have to copy everything from Linux and could start fresh ... since neither the am335 nor am65 are supported.

It looks like that most compatible use <vendor>,<ip>-adc.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@dnltz @natto1784 If the driver is present in Linux kernel then we try to match the bindings and compatible with corresponding ones in Linux wherever possible, this enables future reuse of device nodes directly from Linux DT. Since the IP is same my recommendation would be to reuse the same for the benefit of reusing nodes from Linux DT and scalling acrosss platforms with Linux support becomes easier (with some minor fixups for core specific irq connectivity .etc),

#define ADC_K3_TOTAL_STEPS 16

struct adc_k3_regs {
uint8_t RESERVED_1[0x28]; /**< Reserved, offset: 0xA0 - 0x28 */
Copy link
Collaborator

Choose a reason for hiding this comment

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

@natto1784 can you please replace all __IO with volatile. These _IO definitions are not c-standard and coming from the STM32 HAL.

This should also fix these checkpatch.pl warnings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It actually comes from the cmsis module but it is an HAL regardless so I think it is better to do as you say.

Copy link
Collaborator

@dnltz dnltz Mar 24, 2025

Choose a reason for hiding this comment

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

I will update drivers/i2c/i2c_omap.c. I saw the I2C driver has an empty line in the register struct. Probably to get rid of this warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ADC Analog-to-Digital Converter (ADC) platform: TI K3 Texas Instruments Keystone 3 Processors platform: TI SimpleLink Texas Instruments SimpleLink MCU
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants