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: spi: add mspm0 driver #5

Open
wants to merge 8 commits into
base: mspm0_upstream
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions boards/ti/lp_mspm0g3507/Kconfig.lp_mspm0g3507
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2024 Texas Instruments
# SPDX-License-Identifier: Apache-2.0

config BOARD_LP_MSPM0G3507
select SOC_MSPM0G350X
10 changes: 10 additions & 0 deletions boards/ti/lp_mspm0g3507/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: Apache-2.0

board_runner_args(openocd "--cmd-pre-load=reset init")
# unprotect sectors before running
board_runner_args(openocd "--cmd-pre-load=flash protect 1 0 last off")
board_runner_args(openocd "--cmd-pre-load=flash erase_sector 1 0 last")

#board_runner_args(openocd "--cmd-reset-halt=flash info 1")

include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
5 changes: 5 additions & 0 deletions boards/ti/lp_mspm0g3507/board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
board:
name: lp_mspm0g3507
vendor: ti
socs:
- name: mspm0g350x
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
132 changes: 132 additions & 0 deletions boards/ti/lp_mspm0g3507/docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
.. _lp_mspm0g3507:

MSPM0G3507 LaunchPad
########################

Overview
********

MSPM0G350x microcontrollers (MCUs) are part of the MSP highly integrated, ultra-low-power 32-bit MCU
family based on the enhanced Arm® Cortex®-M0+ 32-bit core platform operating at up to 80-MHz frequency.
These cost-optimized MCUs offer high-performance analog peripheral integration, support extended temperature
ranges from -40°C to 125°C, and operate with supply voltages ranging from 1.62 V to 3.6 V.
The MSPM0G350x devices provide up to 128KB embedded flash program memory with built-in error correction
code (ECC) and up to 32KB SRAM with ECC and hardware parity option. These MCUs also incorporate a
memory protection unit, 7-channel DMA, math accelerator, and a variety of high-performance analog peripherals
such as two 12-bit 4-Msps ADCs, configurable internal shared voltage reference, one 12-bit 1-Msps DAC, three
high speed comparators with built-in reference DACs, two zero-drift zero-crossover op-amps with programmable
gain, and one general-purpose amplifier. These devices also offer intelligent digital peripherals such as two
16-bit advanced control timers, five general-purpose timers (with one 16-bit general-purpose timer for QEI
interface, two 16-bit general-purpose timers for STANDBY mode, and one 32-bit general-purpose timer), two
windowed-watchdog timers, and one RTC with alarm and calendar modes. These devices provide data integrity
and encryption peripherals (AES, CRC, TRNG) and enhanced communication interfaces (four UART, two I2C,
two SPI, CAN 2.0/FD).

.. figure:: img/lp_mspm0g3507.png
:align: center
:alt: MSPM0G3507 LaunchPad development board

Features:
=========

- Onboard XDS110 debug probe
- EnergyTrace technology available for ultra-low-power debugging
- 2 buttons, 1 LED and 1 RGB LED for user interaction
- Temperature sensor circuit
- Light sensor circuit
- External OPA2365 (default buffer mode) for ADC (up to 4 Msps) evaluation
- Onboard 32.768-kHz and 40-MHz crystals
- RC filter for ADC input (unpopulated by default)

Details on the MSPM0G3507 LaunchPad can be found on the `TI LP_MSPM0G3507 Product Page`_.

Supported Features
==================

The MSPM0G3507 LaunchPad development board configuration supports the following hardware features:

+-----------+------------+-----------------------+
| Interface | Controller | Driver/Component |
+===========+============+=======================+
| NVIC | on-chip | nested vectored |
| | | interrupt controller |
+-----------+------------+-----------------------+
| SYSTICK | on-chip | system clock |
+-----------+------------+-----------------------+
| UART | on-chip | serial |
+-----------+------------+-----------------------+
| GPIO | on-chip | gpio |
+-----------+------------+-----------------------+
| PINMUX | on-chip | pinctrl |
+-----------+------------+-----------------------+

More details about the supported peripherals are available in `MSPM0G3507 TRM`_.
Other hardware features are not currently supported by the Zephyr kernel.

Building and Flashing
*********************

Building
========

Follow the :ref:`getting_started` instructions for Zephyr application development.

For example, to build the :ref:`hello_world` application for the MSPM0G3507 LaunchPad:

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: lp_mspm0g3507
:goals: build

The resulting ``zephyr.bin`` binary in the build directory can be flashed onto
MSPM0G3507 LaunchPad using the steps mentioned below.

Flashing
========

`UniFlash`_ is used to program the flash memory. Only bin loading is currently supported.
Make sure to select the checkbox for binary loading.

Debugging
=========

The flashing method described above does not include symbols. Thus, debugging requires an additional step to load the symbols.
This section shows how to debug the MSPM0G3507 LaunchPad board using `CCS IDE`_. More information
on debugging using CCS can be found in `CCS User's Guide`_.

In general, the steps for debugging in CCS are:

1. Open CCS
2. Go to Window > Show View > Target Configruation
3. Import target confguration by right clicking User Defined, selecting Import target configuration and pointing to the lp_mspm0g3507/support/MSPM0G3507.ccxml
4. Launch target configuration by right clicking the new MSPM0G3507.ccxml file and clicking Launch target configuration
5. Plug in the device and connect to it by going to Run > Connect Target
6. Go to Run > Load > Load Symbols and load in the zephyr.elf file loaded
7. Use CCS to debug

References
**********

TI MSPM0 MCU Page:
https://www.ti.com/microcontrollers-mcus-processors/arm-based-microcontrollers/arm-cortex-m0-mcus/overview.html

TI MSPM0G3507 Product Page:
https://www.ti.com/product/MSPM0G3507

TI MSPM0 SDK:
https://www.ti.com/tool/MSPM0-SDK

.. _CCS User's Guide:
https://software-dl.ti.com/ccs/esd/documents/users_guide/index.html

.. _MSPM0G3507 TRM:
https://www.ti.com/lit/slau846

.. _TI LP_MSPM0G3507 Product Page:
https://www.ti.com/tool/LP-MSPM0G3507

.. _UniFlash:
http://processors.wiki.ti.com/index.php/UniFlash_v4_Quick_Guide#Command_Line_Interface

.. _CCS IDE:
http://www.ti.com/tool/ccstudio
75 changes: 75 additions & 0 deletions boards/ti/lp_mspm0g3507/lp_mspm0g3507.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/* SPDX-License-Identifier: Apache-2.0 */

/dts-v1/;

#include <ti/mspm0g1x0x_g3x0x/mspm0g3507.dtsi>
#include <ti/mspm0g1x0x_g3x0x/mspm0g350x-pinctrl.dtsi>
#include <zephyr/dt-bindings/input/input-event-codes.h>

/ {
model = "TI LP_MSPM0G3507";
compatible = "ti,mspm0g3507";

aliases {
led0 = &led0;
led1 = &led1;
sw0 = &btn0;
sw1 = &btn1;
};

chosen {
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
};

leds {
compatible = "gpio-leds";
led0: led_0 {
gpios = <&gpiob 22 GPIO_ACTIVE_HIGH>;
label = "Blue LED";
};
led1: led_1 {
gpios = <&gpiob 26 GPIO_ACTIVE_HIGH>;
label = "Red LED";
};
led2: led_2 {
gpios = <&gpiob 27 GPIO_ACTIVE_HIGH>;
label = "Green LED";
};
};

keys {
compatible = "gpio-keys";
btn0: btn_0 {
gpios = <&gpiob 21 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
label = "Switch 3";
zephyr,code = <INPUT_KEY_0>;
};
btn1: btn_1 {
gpios = <&gpioa 18 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
label = "Switch 2";
zephyr,code = <INPUT_KEY_1>;
};
};
};

&cpu0 {
clock-frequency = <32000000>;
};

&gpioa {
status = "okay";
};

&gpiob {
status = "okay";
};

&uart0 {
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&uart0_tx_pa10 &uart0_rx_pa11>;
pinctrl-names = "default";
};
15 changes: 15 additions & 0 deletions boards/ti/lp_mspm0g3507/lp_mspm0g3507.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
identifier: lp_mspm0g3507
name: LP_MSPM0G3507
type: mcu
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
ram: 32
flash: 128
supported:
- gpio
- pinctrl
- uart
vendor: ti
16 changes: 16 additions & 0 deletions boards/ti/lp_mspm0g3507/lp_mspm0g3507_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-License-Identifier: Apache-2.0

CONFIG_CORTEX_M_SYSTICK=y

# Enable gpio driver
CONFIG_GPIO=y

# Enable uart driver
CONFIG_SERIAL=y

# Enable console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

# Enable pinctrl
CONFIG_PINCTRL=y
4 changes: 4 additions & 0 deletions boards/ti/lp_mspm0g3507/support/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source [find interface/xds110.cfg]
adapter speed 10000

source [find target/ti_mspm0.cfg]
1 change: 1 addition & 0 deletions drivers/gpio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ zephyr_library_sources_ifdef(CONFIG_GPIO_AXP192 gpio_axp192.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_TELINK_B91 gpio_b91.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_INFINEON_CAT1 gpio_ifx_cat1.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_CC13XX_CC26XX gpio_cc13xx_cc26xx.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_MSPM0 gpio_mspm0.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_CC32XX gpio_cc32xx.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_CMSDK_AHB gpio_cmsdk_ahb.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_DW gpio_dw.c)
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ source "drivers/gpio/Kconfig.cc13xx_cc26xx"

source "drivers/gpio/Kconfig.cc32xx"

source "drivers/gpio/Kconfig.mspm0"

source "drivers/gpio/Kconfig.sifive"

source "drivers/gpio/Kconfig.esp32"
Expand Down
11 changes: 11 additions & 0 deletions drivers/gpio/Kconfig.mspm0
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# TI MSPM0 GPIO configuration options

# Copyright (c) 2024 Texas Instruments
# SPDX-License-Identifier: Apache-2.0

config GPIO_MSPM0
bool "TI SimpleLink MSPM0 GPIO driver"
default y
depends on DT_HAS_TI_MSPM0_GPIO_ENABLED
help
Enable the TI MSPM0 GPIO driver.
11 changes: 11 additions & 0 deletions drivers/gpio/Kconfig.mspm0g3xxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# TI MSPM0G3XXX GPIO configuration options

# Copyright (c) 2024 Texas Instruments
# SPDX-License-Identifier: Apache-2.0

config GPIO_MSPM0G3XXX
bool "TI SimpleLink MSPM0G3XXX GPIO driver"
default y
depends on DT_HAS_TI_MSPM0G3XXX_GPIO_ENABLED
help
Enable the TI MSPM0G3XXX GPIO driver.
Loading
Loading