Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 modules/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ source "modules/Kconfig.libmetal"
source "modules/lvgl/Kconfig"
source "modules/Kconfig.mcux"
source "modules/Kconfig.microchip"
source "modules/Kconfig.mspm0"
source "modules/Kconfig.nuvoton"
source "modules/Kconfig.open-amp"
source "modules/Kconfig.picolibc"
Expand Down
7 changes: 7 additions & 0 deletions modules/Kconfig.mspm0
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# MSPM0 SDK configuration

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

config HAS_MSPM0_SDK
bool
5 changes: 5 additions & 0 deletions soc/ti/mspm0/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "SoC Linker Script")

add_subdirectory(${SOC_SERIES})
9 changes: 9 additions & 0 deletions soc/ti/mspm0/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Texas Instruments MSPM0 Family
# Copyright (c) 2024 Texas Instruments
# SPDX-License-Identifier: Apache-2.0

if SOC_FAMILY_TI_MSPM0

rsource "*/Kconfig"

endif # SOC_FAMILY_TI_MSPM0
8 changes: 8 additions & 0 deletions soc/ti/mspm0/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2024 Texas Instruments

if SOC_FAMILY_TI_MSPM0

rsource "*/Kconfig.defconfig"

endif # SOC_FAMILY_TI_MSPM0
12 changes: 12 additions & 0 deletions soc/ti/mspm0/Kconfig.soc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Texas Instruments MSPM0 Family

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

config SOC_FAMILY_TI_MSPM0
bool

config SOC_FAMILY
default "ti_mspm0" if SOC_FAMILY_TI_MSPM0

rsource "*/Kconfig.soc"
22 changes: 22 additions & 0 deletions soc/ti/mspm0/mspm0g1x0x_g3x0x/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-License-Identifier: Apache-2.0

if(CONFIG_SOC_MSPM0G1106)
zephyr_compile_definitions(-D__MSPM0G1106__)
elseif(CONFIG_SOC_MSPM0G1107)
zephyr_compile_definitions(-D__MSPM0G1107__)
elseif(CONFIG_SOC_MSPM0G1506)
zephyr_compile_definitions(-D__MSPM0G1506__)
elseif(CONFIG_SOC_MSPM0G1507)
zephyr_compile_definitions(-D__MSPM0G1507__)
elseif(CONFIG_SOC_MSPM0G3106)
zephyr_compile_definitions(-D__MSPM0G3106__)
elseif(CONFIG_SOC_MSPM0G3107)
zephyr_compile_definitions(-D__MSPM0G3107__)
elseif(CONFIG_SOC_MSPM0G3506)
zephyr_compile_definitions(-D__MSPM0G3506__)
elseif(CONFIG_SOC_MSPM0G3507)
zephyr_compile_definitions(-D__MSPM0G3507__)
endif()
Comment on lines +3 to +19
Copy link
Member

Choose a reason for hiding this comment

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

lookd like a HAL requirement, move to glue code.


zephyr_sources(soc.c)
zephyr_include_directories(.)
14 changes: 14 additions & 0 deletions soc/ti/mspm0/mspm0g1x0x_g3x0x/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# TI MSPM0G1X0X_G3X0X

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

config SOC_SERIES_MSPM0G1X0X_G3X0X
select ARM
select CPU_CORTEX_M0PLUS
select CPU_CORTEX_M_HAS_VTOR
select CPU_HAS_ARM_MPU
select CPU_CORTEX_M_HAS_SYSTICK
select BUILD_OUTPUT_HEX
select HAS_MSPM0_SDK
select CLOCK_CONTROL
17 changes: 17 additions & 0 deletions soc/ti/mspm0/mspm0g1x0x_g3x0x/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# TI MSPM0G1X0X_G3X0X

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

if SOC_SERIES_MSPM0G1X0X_G3X0X

DT_MSPM0_CLKMUX_PATH := $(dt_nodelabel_path,clkmux)
DT_MSPM0_CLKMUX_CPU_FREQ := $(dt_node_int_prop_int,$(DT_MSPM0_CLKMUX_PATH),clock-frequency)

config NUM_IRQS
default 32

config SYS_CLOCK_HW_CYCLES_PER_SEC
default "$(DT_MSPM0_CLKMUX_CPU_FREQ)" if "$(dt_nodelabel_enabled,clkmux)"

endif # SOC_SERIES_MSPM0G1X0X_G3X0X
53 changes: 53 additions & 0 deletions soc/ti/mspm0/mspm0g1x0x_g3x0x/Kconfig.soc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright (c) 2024 Texas Instruments
# SPDX-License-Identifier: Apache-2.0

config SOC_SERIES_MSPM0G1X0X_G3X0X
bool
select SOC_FAMILY_TI_MSPM0
help
Enable support for TI MSPM0G1X0X_G3X0X SoCs

config SOC_MSPM0G1106
bool
select SOC_SERIES_MSPM0G1X0X_G3X0X

config SOC_MSPM0G1107
bool
select SOC_SERIES_MSPM0G1X0X_G3X0X

config SOC_MSPM0G1506
bool
select SOC_SERIES_MSPM0G1X0X_G3X0X

config SOC_MSPM0G1507
bool
select SOC_SERIES_MSPM0G1X0X_G3X0X

config SOC_MSPM0G3106
bool
select SOC_SERIES_MSPM0G1X0X_G3X0X

config SOC_MSPM0G3107
bool
select SOC_SERIES_MSPM0G1X0X_G3X0X

config SOC_MSPM0G3506
bool
select SOC_SERIES_MSPM0G1X0X_G3X0X

config SOC_MSPM0G3507
bool
select SOC_SERIES_MSPM0G1X0X_G3X0X

config SOC_SERIES
default "mspm0g1x0x_g3x0x" if SOC_SERIES_MSPM0G1X0X_G3X0X

config SOC
default "mspm0g1106" if SOC_MSPM0G1106
default "mspm0g1107" if SOC_MSPM0G1107
default "mspm0g1506" if SOC_MSPM0G1506
default "mspm0g1507" if SOC_MSPM0G1507
default "mspm0g3106" if SOC_MSPM0G3106
default "mspm0g3107" if SOC_MSPM0G3107
default "mspm0g3506" if SOC_MSPM0G3506
default "mspm0g3507" if SOC_MSPM0G3507
49 changes: 49 additions & 0 deletions soc/ti/mspm0/mspm0g1x0x_g3x0x/pinctrl_soc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) (2024) Texas Instruments
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef SOC_TI_MSPM0_M0G1X0X_G3X0X_PINCTRL_SOC_H_
#define SOC_TI_MSPM0_M0G1X0X_G3X0X_PINCTRL_SOC_H_

#include <zephyr/devicetree.h>
#include <zephyr/types.h>
#include <zephyr/dt-bindings/pinctrl/mspm0-pinctrl.h>

#define MSP_GPIO_RESISTOR_PULL_DOWN (16)
#define MSP_GPIO_RESISTOR_PULL_UP (17)
#define MSP_GPIO_INPUT_ENABLE (18)
#define MSP_GPIO_HYSTERESIS_ENABLED (19)
#define MSP_GPIO_OPEN_DRAIN_OUTPUT (25)
#define MSP_GPIO_INVERSION_ENABLED (26)

#define MSP_GPIO_HIGH_DRIVE (20)

#define MSP_PINMUX_INIT(node_id) DT_PROP(node_id, pinmux)

#define MSP_PIN_CONTROL_IOMUX_INIT(node_id) \
((DT_PROP(node_id, bias_pull_up) << MSP_GPIO_RESISTOR_PULL_UP) | \
(DT_PROP(node_id, bias_pull_down) << MSP_GPIO_RESISTOR_PULL_DOWN) | \
(DT_PROP(node_id, drive_open_drain) << MSP_GPIO_OPEN_DRAIN_OUTPUT) | \
(DT_PROP(node_id, ti_hysteresis) << MSP_GPIO_HYSTERESIS_ENABLED) | \
(DT_PROP(node_id, ti_invert) << MSP_GPIO_INVERSION_ENABLED) | \
(DT_PROP(node_id, input_enable) << MSP_GPIO_INPUT_ENABLE))

typedef struct pinctrl_soc_pin {
/* PINCM register index and pin function */
uint32_t pinmux;
/* IOMUX Pin Control Management (direction, inversion, pullups) */
uint32_t iomux;
} pinctrl_soc_pin_t;

#define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) \
{.pinmux = MSP_PINMUX_INIT(DT_PROP_BY_IDX(node_id, prop, idx)), \
.iomux = MSP_PIN_CONTROL_IOMUX_INIT(DT_PROP_BY_IDX(node_id, prop, idx))},

#define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \
{ \
DT_FOREACH_PROP_ELEM(node_id, prop, Z_PINCTRL_STATE_PIN_INIT) \
}

#endif /* SOC_TI_MSPM0_M0G1X0X_G3X0X_PINCTRL_SOC_H_ */
25 changes: 25 additions & 0 deletions soc/ti/mspm0/mspm0g1x0x_g3x0x/soc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2024 Texas Instruments
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/kernel.h>
#include <zephyr/init.h>
#include <soc.h>

void soc_early_init_hook(void)
{
/* Reset and enable GPIO banks */
DL_GPIO_reset(GPIOA);
DL_GPIO_reset(GPIOB);

DL_GPIO_enablePower(GPIOA);
DL_GPIO_enablePower(GPIOB);
Copy link
Member

Choose a reason for hiding this comment

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

Any specific reason why is this not in drivers/gpio/gpio_mspm0.c ? I also noticed your comment in there /* Powering up of GPIOs is part of soc.c */

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Generally they are all powered on at once because the GPIO ports must be powered on to enable pinmuxing for non-gpio related applications

Copy link
Member

Choose a reason for hiding this comment

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

Then let the prio handles the ordering. It makes sense to move this part to GPIO driver changes IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then we'd need every module to depend on GPIO, right?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, any IP which is using pins needs GPIO. That's the default behavior AFAIK. Disabling gpio node in dts will makes basic samples to fail.


/* Allow delay time to settle */
delay_cycles(POWER_STARTUP_DELAY);
Copy link
Member

Choose a reason for hiding this comment

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

why?

git diff soc/
diff --git a/soc/ti/mspm0/mspm0g1x0x_g3x0x/soc.c b/soc/ti/mspm0/mspm0g1x0x_g3x0x/soc.c
index be97c00770c..816facb99c8 100644
--- a/soc/ti/mspm0/mspm0g1x0x_g3x0x/soc.c
+++ b/soc/ti/mspm0/mspm0g1x0x_g3x0x/soc.c
@@ -5,8 +5,8 @@
  */
 
 #include <zephyr/init.h>
+#include <ti/driverlib/driverlib.h>
 #include <ti/driverlib/m0p/dl_core.h>
-#include <soc.h>
 
 static int ti_mspm0g_init(void)
 {
@@ -17,9 +17,6 @@ static int ti_mspm0g_init(void)
        DL_GPIO_enablePower(GPIOA);
        DL_GPIO_enablePower(GPIOB);
 
-       /* Allow delay time to settle */
-       delay_cycles(POWER_STARTUP_DELAY);
-
        /* Low Power Mode is configured to be SLEEP0 */
        DL_SYSCTL_setBORThreshold(DL_SYSCTL_BOR_THRESHOLD_LEVEL_0);

this works fine in my end. Also there is no reference to delay/sleep in the TRM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a peripheral settling time after poweron, the startup delay is worst case.

Copy link
Member

Choose a reason for hiding this comment

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

Is this documented in TRM or datasheet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it's section 2.2.7, the note is below:
image

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I see the comments added to the macro. This applies to all the IP's, I understand. Let's keep the value 4 as stated by the TRM.


/* Low Power Mode is configured to be SLEEP0 */
DL_SYSCTL_setBORThreshold(DL_SYSCTL_BOR_THRESHOLD_LEVEL_0);
}
37 changes: 37 additions & 0 deletions soc/ti/mspm0/mspm0g1x0x_g3x0x/soc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2024 Texas Instruments
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef SOC_TI_MSPM0_SOC_H_
#define SOC_TI_MSPM0_SOC_H_

#define SYSCONFIG_WEAK __attribute__((weak))

#include <ti/devices/msp/msp.h>
#include <ti/driverlib/driverlib.h>
#include <ti/driverlib/m0p/dl_core.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
* Per TRM Section 2.2.7 Peripheral Power Enable Control:
*
* After setting the ENABLE | KEY bits in the PWREN Register to enable a
* peripheral, wait at least 4 ULPCLK clock cycles before accessing the rest of
* the peripheral's memory-mapped registers. The 4 cycles allow for the bus
* isolation signals at the peripheral's bus interface to update.
*
* ULPCLK will either be equivalent or half of the main MCLK and CPUCLK,
* yielding the delay time of 8 cycles
*/
#define POWER_STARTUP_DELAY (8)

#ifdef __cplusplus
}
#endif
Comment on lines +10 to +35
Copy link
Member

Choose a reason for hiding this comment

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

soc.h is purely for CMSIS glueing, this looks wrong


#endif /* SOC_TI_MSPM0_SOC_H_ */
13 changes: 13 additions & 0 deletions soc/ti/mspm0/soc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
family:
- name: ti_mspm0
series:
- name: mspm0g1x0x_g3x0x
socs:
- name: mspm0g1106
- name: mspm0g1107
- name: mspm0g1506
- name: mspm0g1507
- name: mspm0g3106
- name: mspm0g3107
- name: mspm0g3506
- name: mspm0g3507