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: Introduce gd32 adc driver #42215

Merged
merged 6 commits into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MAINTAINERS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,7 @@ GD32 Platforms:
- gmarull
collaborators:
- soburi
- cameled
files:
- boards/arm/gd32*/
- boards/riscv/gd32*/
Expand Down
3 changes: 3 additions & 0 deletions boards/arm/gd32f350r_eval/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ The board configuration supports the following hardware features:
* - PINMUX
- :kconfig:option:`CONFIG_PINCTRL`
- :dtcompatible:`gd,gd32-pinctrl-af`
* - ADC
- :kconfig:option:`CONFIG_ADC`
- :dtcompatible:`gd,gd32-adc`

Serial Port
===========
Expand Down
6 changes: 6 additions & 0 deletions boards/arm/gd32f350r_eval/gd32f350r_eval-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@
pinmux = <USART0_TX_PA9>, <USART0_RX_PA10>;
};
};

adc0_default: adc0_default {
group1 {
pinmux = <ADC_IN11_PC1>;
};
};
};
8 changes: 8 additions & 0 deletions boards/arm/gd32f350r_eval/gd32f350r_eval.dts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@
pinctrl-0 = <&usart0_default>;
pinctrl-names = "default";
};

&adc0 {
status = "okay";
/* Set ADC0 clock source to RCU_ADCCK_APB2_DIV4. */
rcu-clock-source = <4>;
pinctrl-0 = <&adc0_default>;
pinctrl-names = "default";
};
3 changes: 2 additions & 1 deletion boards/arm/gd32f403z_eval/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ The board configuration supports the following hardware features:
+-----------+------------+-----------------------+
| UART | on-chip | serial port-polling |
+-----------+------------+-----------------------+

| ADC | on-chip | ADC |
+-----------+------------+-----------------------+

Serial Port
===========
Expand Down
6 changes: 6 additions & 0 deletions boards/arm/gd32f403z_eval/gd32f403z_eval-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
};
};

adc0_default: adc0_default {
group1 {
pinmux = <ADC012_IN13_PC3>;
};
};

pwm0_default: pwm0_default {
group1 {
pinmux = <TIMER0_CH0_PA8_OUT_NORMP>;
Expand Down
6 changes: 6 additions & 0 deletions boards/arm/gd32f403z_eval/gd32f403z_eval.dts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@
status = "okay";
};

&adc0 {
cameled marked this conversation as resolved.
Show resolved Hide resolved
status = "okay";
pinctrl-0 = <&adc0_default>;
pinctrl-names = "default";
};

&usart0 {
status = "okay";
current-speed = <115200>;
Expand Down
3 changes: 3 additions & 0 deletions boards/arm/gd32f450i_eval/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ The board configuration supports the following hardware features:
* - EEPROM
- :kconfig:option:`CONFIG_EEPROM`
- :dtcompatible:`atmel,at24`
* - ADC
- :kconfig:option:`CONFIG_ADC`
- :dtcompatible:`gd,gd32-adc`

Serial Port
===========
Expand Down
6 changes: 6 additions & 0 deletions boards/arm/gd32f450i_eval/gd32f450i_eval-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
};
};

adc0_default: adc0_default {
group1 {
pinmux = <ADC012_IN13_PC3>;
};
};

dac_default: dac_default {
group1 {
pinmux = <DAC_OUT0_PA4>;
Expand Down
6 changes: 6 additions & 0 deletions boards/arm/gd32f450i_eval/gd32f450i_eval.dts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@
pinctrl-names = "default";
};

&adc0 {
status = "okay";
pinctrl-0 = <&adc0_default>;
pinctrl-names = "default";
};

&dac {
status = "okay";
pinctrl-0 = <&dac_default>;
Expand Down
3 changes: 3 additions & 0 deletions boards/riscv/gd32vf103v_eval/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ The board configuration supports the following hardware features:
* - USART
- :kconfig:option:`CONFIG_SERIAL`
- :dtcompatible:`gd,gd32-usart`
* - ADC
- :kconfig:option:`CONFIG_ADC`
- :dtcompatible:`gd,gd32-adc`

Serial Port
===========
Expand Down
6 changes: 6 additions & 0 deletions boards/riscv/gd32vf103v_eval/gd32vf103v_eval-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@
<SPI0_MISO_PA6_OUT_NORMP>;
};
};

adc0_default: adc0_default {
group1 {
pinmux = <ADC01_IN13_PC3>;
};
};
};
6 changes: 6 additions & 0 deletions boards/riscv/gd32vf103v_eval/gd32vf103v_eval.dts
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,9 @@
jedec-id = [c8 40 15];
};
};

&adc0 {
status = "okay";
pinctrl-0 = <&adc0_default>;
pinctrl-names = "default";
};
1 change: 1 addition & 0 deletions drivers/adc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ zephyr_library_sources_ifdef(CONFIG_ADC_EMUL adc_emul.c)
zephyr_library_sources_ifdef(CONFIG_ADC_XEC_V2 adc_mchp_xec_v2.c)
zephyr_library_sources_ifdef(CONFIG_ADC_TEST adc_test.c)
zephyr_library_sources_ifdef(CONFIG_ADC_ADS1X1X adc_ads1x1x.c)
zephyr_library_sources_ifdef(CONFIG_ADC_GD32 adc_gd32.c)
2 changes: 2 additions & 0 deletions drivers/adc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,6 @@ source "drivers/adc/Kconfig.test"

source "drivers/adc/Kconfig.ads1x1x"

source "drivers/adc/Kconfig.gd32"

endif # ADC
13 changes: 13 additions & 0 deletions drivers/adc/Kconfig.gd32
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ADC configuration options

# Copyright (c) 2021 BrainCo Inc.
# SPDX-License-Identifier: Apache-2.0

DT_COMPAT_GD_GD32_ADC := gd,gd32-adc

config ADC_GD32
bool "GD32 ADC driver"
depends on (SOC_FAMILY_GD32 || SOC_SERIES_GD32VF103)
default $(dt_compat_enabled,$(DT_COMPAT_GD_GD32_ADC))
help
Enable GigaDevice GD32 ADC driver
Loading