ev11l78a: initial import of the UPD301C Basic Sink board.
This board is a relatively inexpensive development kit for USB-PD
controllers, using an UPD301C controller.
This Zephyr config includes support for:
* UART (present on he debug header of the board), tested with the
hello_world sample application;
* the one standalone LED (CAP_MIS), tested with the blinky sample
application;
* the rotary encoder (PDO_SEL), via ADC, tested with the adc sample
application;
* the current sense amplifier (I_SENSE), currently untested;
* the SPI bus, connected internally in the UPD301C to the UPD350;
* the I2C bus, exposed on the debug header, currently untested.
Note that the drivers.uart.async_api.rtt has to be disabled, as it is
for other m0 boards with no dma or it fails to build.
Signed-off-by: Diego Elio Pettenò <flameeyes@meta.com>
diff --git a/boards/arm/ev11l78a/Kconfig.board b/boards/arm/ev11l78a/Kconfig.board
new file mode 100644
index 0000000..629eb3c
--- /dev/null
+++ b/boards/arm/ev11l78a/Kconfig.board
@@ -0,0 +1,8 @@
+# Microchip EV11L78A Board configuration
+
+# Copyright (c) 2023 Meta Platforms, Inc. and its affiliates.
+# SPDX-License-Identifier: Apache-2.0
+
+config BOARD_EV11L78A
+ bool "Microchip EV11L78A"
+ depends on SOC_PART_NUMBER_SAMD20E16
diff --git a/boards/arm/ev11l78a/Kconfig.defconfig b/boards/arm/ev11l78a/Kconfig.defconfig
new file mode 100644
index 0000000..54b7410
--- /dev/null
+++ b/boards/arm/ev11l78a/Kconfig.defconfig
@@ -0,0 +1,8 @@
+# Microchip EV11L78A Board configuration
+
+# Copyright (c) 2023 Meta Platforms, Inc. and its affiliates.
+# SPDX-License-Identifier: Apache-2.0
+
+config BOARD
+ default "ev11l78a"
+ depends on BOARD_EV11L78A
diff --git a/boards/arm/ev11l78a/board.cmake b/boards/arm/ev11l78a/board.cmake
new file mode 100644
index 0000000..64df342
--- /dev/null
+++ b/boards/arm/ev11l78a/board.cmake
@@ -0,0 +1,4 @@
+# Copyright (c) 2018 Sean Nyekjaer
+# SPDX-License-Identifier: Apache-2.0
+
+include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
diff --git a/boards/arm/ev11l78a/doc/img/ev11l78a.jpg b/boards/arm/ev11l78a/doc/img/ev11l78a.jpg
new file mode 100644
index 0000000..ef762a5
--- /dev/null
+++ b/boards/arm/ev11l78a/doc/img/ev11l78a.jpg
Binary files differ
diff --git a/boards/arm/ev11l78a/doc/index.rst b/boards/arm/ev11l78a/doc/index.rst
new file mode 100644
index 0000000..894cda9
--- /dev/null
+++ b/boards/arm/ev11l78a/doc/index.rst
@@ -0,0 +1,92 @@
+.. _ev11l78a:
+
+UPD301C Basic Sink Application Example
+######################################
+
+Overview
+********
+
+The UPD301C Basic Sink Application Example Evaluation Kit (EV11L78A)
+is a low-cost evaluation platform for Microchip's UPD301C Standalone
+Programmable USB Power Delivery (PD) Controller. This RoHS-compliant
+evaluation platform comes in a small form factor and adheres to the
+USB Type-C™ Connector Specification and USB PD 3.0 specification.
+
+.. figure:: img/ev11l78a.jpg
+ :width: 500px
+ :align: center
+ :alt: EV11L78A
+
+ UPD301C Basic Sink Application Example (Credit: `Microchip Technology`_)
+
+Hardware
+********
+
+- ATSAMD20E16 ARM Cortex-M0+ processor at 48 MHz
+- UPD301C combines a SAMD20 core and a UPD350 USB-PD controller
+- Sink PDO Selector Switch
+- Onboard LED Voltmeter
+
+Supported Features
+==================
+
+The ev11l78a board configuration supports the following hardware
+features:
+
++-----------+------------+------------------------------------------+
+| Interface | Controller | Driver/Component |
++===========+============+==========================================+
+| NVIC | on-chip | nested vector interrupt controller |
++-----------+------------+------------------------------------------+
+| Flash | on-chip | Can be used with LittleFS to store files |
++-----------+------------+------------------------------------------+
+| SYSTICK | on-chip | systick |
++-----------+------------+------------------------------------------+
+| WDT | on-chip | Watchdog |
++-----------+------------+------------------------------------------+
+| GPIO | on-chip | I/O ports |
++-----------+------------+------------------------------------------+
+| USART | on-chip | Serial ports |
++-----------+------------+------------------------------------------+
+| SPI | on-chip | Serial Peripheral Interface ports |
++-----------+------------+------------------------------------------+
+| I2C | on-chip | I²C ports |
++-----------+------------+------------------------------------------+
+| ADC | on-chip | Analog-to-Digital Converter |
++-----------+------------+------------------------------------------+
+
+Other hardware features are not currently supported by Zephyr.
+
+Refer to the `EV11L78A Schematics`_ for a detailed hardware diagram.
+
+The default configuration can be found in the Kconfig
+:zephyr_file:`boards/arm/ev11l78a/ev11l78a_defconfig`.
+
+Serial Port
+===========
+
+The SAMD20 MCU has 6 SERCOM based USARTs. One of the USARTs
+(SERCOM1) is available on the Debug/Status header.
+
+SPI Port
+========
+
+The SAMD20 MCU has 6 SERCOM based SPIs. One of the SPIs (SERCOM0)
+is internally connected between the SAMD20 core and the UPD350.
+
+I²C Port
+========
+
+The SAMD20 MCU has 6 SERCOM based I2Cs. One of the I2Cs (SERCOM3)
+is available on the Debug/Status header.
+
+References
+**********
+
+.. target-notes::
+
+.. _Microchip Technology:
+ https://www.microchip.com/en-us/development-tool/ev11l78a
+
+.. _EV11L78A Schematics:
+ https://ww1.microchip.com/downloads/aemDocuments/documents/UNG/ProductDocuments/SupportingCollateral/03-00056-R1.0.PDF
diff --git a/boards/arm/ev11l78a/ev11l78a-pinctrl.dtsi b/boards/arm/ev11l78a/ev11l78a-pinctrl.dtsi
new file mode 100644
index 0000000..38a7979
--- /dev/null
+++ b/boards/arm/ev11l78a/ev11l78a-pinctrl.dtsi
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2023, Meta Platforms, Inc. and its affiliates.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <dt-bindings/pinctrl/samd20eXab-pinctrl.h>
+
+&pinctrl {
+ sercom0_spi_default: sercom0_spi_default {
+ group1 {
+ pinmux = <PA8C_SERCOM0_PAD0>,
+ <PA9C_SERCOM0_PAD1>,
+ <PA11C_SERCOM0_PAD3>;
+ };
+ };
+
+ sercom1_uart_default: sercom1_uart_default {
+ group1 {
+ pinmux = <PA18C_SERCOM1_PAD2>,
+ <PA19C_SERCOM1_PAD3>;
+ };
+ };
+
+ sercom3_i2c_default: sercom3_i2c_default {
+ group1 {
+ pinmux = <PA17D_SERCOM3_PAD1>,
+ <PA18D_SERCOM3_PAD2>;
+ };
+ };
+
+ adc_default: adc_default {
+ group1 {
+ pinmux = <PA4B_ADC_AIN4>,
+ <PA5B_ADC_AIN5>;
+ };
+ };
+};
diff --git a/boards/arm/ev11l78a/ev11l78a.dts b/boards/arm/ev11l78a/ev11l78a.dts
new file mode 100644
index 0000000..0096fe9
--- /dev/null
+++ b/boards/arm/ev11l78a/ev11l78a.dts
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2023, Meta Platforms, Inc. and its affiliates.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/dts-v1/;
+#include <freq.h>
+#include <atmel/samd20.dtsi>
+#include "ev11l78a-pinctrl.dtsi"
+
+/ {
+ model = "Microchip EV11L78A";
+ compatible = "atmel,samd20e16", "atmel,samd20";
+
+ aliases {
+ led0 = &cap_mis_led;
+ spi0 = &sercom0;
+ i2c0 = &sercom3;
+ };
+
+ chosen {
+ zephyr,console = &sercom1;
+ zephyr,shell-uart = &sercom1;
+ zephyr,sram = &sram0;
+ zephyr,flash = &flash0;
+ };
+
+ leds {
+ compatible = "gpio-leds";
+ cap_mis_led: led_0 {
+ gpios = <&porta 23 GPIO_ACTIVE_HIGH>;
+ label = "CAP_MIS";
+ };
+ };
+
+ csa_i_sense: i_sense {
+ compatible = "current-sense-amplifier";
+ io-channels = <&adc 5>;
+ sense-resistor-micro-ohms = <4000>;
+ sense-gain-mult = <100>;
+ };
+
+};
+
+&cpu0 {
+ clock-frequency = <DT_FREQ_M(48)>;
+};
+
+&sercom0 {
+ status = "okay";
+ compatible = "atmel,sam0-spi";
+ dipo = <0>;
+ dopo = <2>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ cs-gpios = <&porta 10 GPIO_ACTIVE_LOW>;
+
+ pinctrl-0 = <&sercom0_spi_default>;
+ pinctrl-names = "default";
+};
+
+&sercom1 {
+ status = "okay";
+ compatible = "atmel,sam0-uart";
+ current-speed = <115200>;
+ rxpo = <3>;
+ txpo = <1>;
+
+ pinctrl-0 = <&sercom1_uart_default>;
+ pinctrl-names = "default";
+};
+
+&sercom3 {
+ status = "okay";
+ compatible = "atmel,sam0-i2c";
+ clock-frequency = <I2C_BITRATE_HIGH>;
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ pinctrl-0 = <&sercom3_i2c_default>;
+ pinctrl-names = "default";
+};
+
+&flash0 {
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ /*
+ * The final 16 KiB is reserved for the application.
+ * Storage partition will be used by FCB/LittleFS/NVS
+ * if enabled.
+ */
+ storage_partition: partition@3c000 {
+ label = "storage";
+ reg = <0x0003c000 0x00004000>;
+ };
+ };
+};
+
+&adc {
+ status = "okay";
+ prescaler = <32>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ channel@4 {
+ reg = <4>;
+ zephyr,gain = "ADC_GAIN_1_2";
+ zephyr,reference = "ADC_REF_VDD_1_2";
+ zephyr,vref-mv = <1650>;
+ zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
+ zephyr,resolution = <12>;
+ zephyr,input-positive = <4>;
+ };
+
+ pinctrl-0 = <&adc_default>;
+ pinctrl-names = "default";
+};
diff --git a/boards/arm/ev11l78a/ev11l78a.yaml b/boards/arm/ev11l78a/ev11l78a.yaml
new file mode 100644
index 0000000..c181bd1
--- /dev/null
+++ b/boards/arm/ev11l78a/ev11l78a.yaml
@@ -0,0 +1,16 @@
+identifier: ev11l78a
+name: UPD301C Basic Sink Application Example
+type: mcu
+arch: arm
+ram: 32
+flash: 64
+toolchain:
+ - zephyr
+ - gnuarmemb
+ - xtools
+supported:
+ - adc
+ - gpio
+ - i2c
+ - spi
+ - uart
diff --git a/boards/arm/ev11l78a/ev11l78a_defconfig b/boards/arm/ev11l78a/ev11l78a_defconfig
new file mode 100644
index 0000000..51b5780
--- /dev/null
+++ b/boards/arm/ev11l78a/ev11l78a_defconfig
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: Apache-2.0
+
+CONFIG_SOC_SERIES_SAMD20=y
+CONFIG_SOC_PART_NUMBER_SAMD20E16=y
+CONFIG_SOC_ATMEL_SAMD_OSC8M=y
+CONFIG_SOC_ATMEL_SAMD_OSC8M_AS_MAIN=y
+CONFIG_BOARD_EV11L78A=y
+CONFIG_BUILD_OUTPUT_HEX=y
+CONFIG_CONSOLE=y
+CONFIG_GPIO=y
+CONFIG_SERIAL=y
+CONFIG_UART_CONSOLE=y
+CONFIG_UART_INTERRUPT_DRIVEN=y
diff --git a/boards/arm/ev11l78a/pre_dt_board.cmake b/boards/arm/ev11l78a/pre_dt_board.cmake
new file mode 100644
index 0000000..9be9a0b
--- /dev/null
+++ b/boards/arm/ev11l78a/pre_dt_board.cmake
@@ -0,0 +1,7 @@
+# Copyright (c) 2021 Linaro Limited
+# SPDX-License-Identifier: Apache-2.0
+
+# Suppress "unique_unit_address_if_enabled" to handle the following overlaps:
+# - /soc/pinmux@41004400 & /soc/gpio@41004400
+# - /soc/pinmux@41004480 & /soc/gpio@41004480
+list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")
diff --git a/boards/arm/ev11l78a/support/openocd.cfg b/boards/arm/ev11l78a/support/openocd.cfg
new file mode 100644
index 0000000..d9dbdff
--- /dev/null
+++ b/boards/arm/ev11l78a/support/openocd.cfg
@@ -0,0 +1,22 @@
+source [find interface/jlink.cfg]
+transport select swd
+
+# chip name
+set CHIPNAME at91samd20e16
+set ENDIAN little
+set CPUTAPID 0x0bc11477
+
+source [find target/at91samdXX.cfg]
+
+reset_config trst_and_srst separate
+
+$_TARGETNAME configure -event gdb-attach {
+ echo "Debugger attaching: halting execution"
+ reset halt
+ gdb_breakpoint_override hard
+}
+
+$_TARGETNAME configure -event gdb-detach {
+ echo "Debugger detaching: resuming execution"
+ resume
+}
diff --git a/samples/drivers/adc/boards/ev11l78a.overlay b/samples/drivers/adc/boards/ev11l78a.overlay
new file mode 100644
index 0000000..cd436fe
--- /dev/null
+++ b/samples/drivers/adc/boards/ev11l78a.overlay
@@ -0,0 +1,11 @@
+/*
+ * Copyright (c) 2023, Meta Platforms, Inc. and its affiliates.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/ {
+ zephyr,user {
+ /* pin 4 ADC(+) */
+ io-channels = <&adc 4>;
+ };
+};
diff --git a/tests/drivers/adc/adc_api/boards/ev11l78a.overlay b/tests/drivers/adc/adc_api/boards/ev11l78a.overlay
new file mode 100644
index 0000000..cd436fe
--- /dev/null
+++ b/tests/drivers/adc/adc_api/boards/ev11l78a.overlay
@@ -0,0 +1,11 @@
+/*
+ * Copyright (c) 2023, Meta Platforms, Inc. and its affiliates.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/ {
+ zephyr,user {
+ /* pin 4 ADC(+) */
+ io-channels = <&adc 4>;
+ };
+};
diff --git a/tests/drivers/uart/uart_async_api/testcase.yaml b/tests/drivers/uart/uart_async_api/testcase.yaml
index aa68939..324c9a9 100644
--- a/tests/drivers/uart/uart_async_api/testcase.yaml
+++ b/tests/drivers/uart/uart_async_api/testcase.yaml
@@ -20,6 +20,7 @@
- wio_terminal
- xiao_esp32c3
- atsamd20_xpro
+ - ev11l78a
tags:
- drivers
- uart