soc: focaltech: ft9001: add SoC support

Add initial support for the FocalTech FT9001 ARM Cortex-M SoC including:
- SoC Kconfig and dtsi integration points
- Early init and core setup
- Pinctrl base definitions

This prepares the tree for the FT9001 board and drivers.

Signed-off-by: Robert Cheng <robert.cheng@focaltech-electronics.com>
This commit is contained in:
Robert Cheng
2025-10-21 10:36:20 +08:00
committed by Fabio Baltieri
parent 79f972db89
commit c3d0a3703f
13 changed files with 241 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
# Copyright (c) 2025, FocalTech Systems CO.,Ltd
# SPDX-License-Identifier: Apache-2.0
add_subdirectory(ft9001)

4
soc/focaltech/Kconfig Normal file
View File

@@ -0,0 +1,4 @@
# Copyright (c) 2025, FocalTech Systems CO.,Ltd
# SPDX-License-Identifier: Apache-2.0
rsource "*/Kconfig"

View File

@@ -0,0 +1,4 @@
# Copyright (c) 2025, FocalTech Systems CO.,Ltd
# SPDX-License-Identifier: Apache-2.0
rsource "*/Kconfig.defconfig"

View File

@@ -0,0 +1,4 @@
# Copyright (c) 2025, FocalTech Systems CO.,Ltd
# SPDX-License-Identifier: Apache-2.0
rsource "*/Kconfig.soc"

View File

@@ -0,0 +1,13 @@
# Copyright (c) 2025, FocalTech Systems CO.,Ltd
# SPDX-License-Identifier: Apache-2.0
zephyr_sources(
soc.c
xip.c
)
zephyr_include_directories(.)
zephyr_code_relocate(FILES xip.c LOCATION RAM)
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "")

View File

@@ -0,0 +1,13 @@
# Copyright (c) 2025, FocalTech Systems CO.,Ltd
# SPDX-License-Identifier: Apache-2.0
config SOC_FT9001
select ARM
select CPU_CORTEX_M4
select CPU_HAS_FPU
select CPU_HAS_ARM_MPU
select CPU_CORTEX_M_HAS_SYSTICK
select CPU_CORTEX_M_HAS_VTOR
select SOC_EARLY_INIT_HOOK
select BUILD_OUTPUT_HEX
select HAS_SEGGER_RTT if ZEPHYR_SEGGER_MODULE

View File

@@ -0,0 +1,12 @@
# Copyright (c) 2025, FocalTech Systems CO.,Ltd
# SPDX-License-Identifier: Apache-2.0
if SOC_FT9001
config SYS_CLOCK_HW_CYCLES_PER_SEC
default $(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency)
config NUM_IRQS
default 140
endif # SOC_FT9001

View File

@@ -0,0 +1,10 @@
# Copyright (c) 2025, FocalTech Systems Co., Ltd.
# SPDX-License-Identifier: Apache-2.0
config SOC_FT9001
bool
help
Build for the FocalTech FT9001 MCU (ARM Cortex-M4F).
config SOC
default "ft9001" if SOC_FT9001

View File

@@ -0,0 +1,120 @@
/*
* Copyright (c) 2025, FocalTech Systems CO.,Ltd
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief FocalTech FT9001 SoC specific helpers for pinctrl driver
*/
#ifndef ZEPHYR_SOC_ARM_FOCALTECH_FT9001_PINCTRL_SOC_H_
#define ZEPHYR_SOC_ARM_FOCALTECH_FT9001_PINCTRL_SOC_H_
#include <zephyr/devicetree.h>
#include <zephyr/types.h>
#include <zephyr/dt-bindings/pinctrl/focaltech_ft9001_pinctrl.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @cond INTERNAL_HIDDEN */
/** @brief Type for FT9001 pin configuration.
*
* Bits:
* - 0-25: FT9001_PINMUX bit field.
* - 26-31: Pin configuration bit field (@ref FT9001_PINCFG).
*/
typedef uint32_t pinctrl_soc_pin_t;
/**
* @brief Utility macro to initialize each pin.
*
* @param node_id Node identifier.
* @param prop Property name.
* @param idx Property entry index.
*/
#define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) \
(DT_PROP_BY_IDX(node_id, prop, idx) | \
((FT9001_PUPD_PULLUP * DT_PROP(node_id, bias_pull_up)) << FT9001_PUPD_POS) | \
((FT9001_PUPD_PULLDOWN * DT_PROP(node_id, bias_pull_down)) << FT9001_PUPD_POS) | \
((FT9001_OTYPE_OD * DT_PROP(node_id, drive_open_drain)) << FT9001_OTYPE_POS) | \
(DT_ENUM_IDX(node_id, slew_rate) << FT9001_OSPEED_POS)),
/**
* @brief Utility macro to initialize state pins contained in a given property.
*
* @param node_id Node identifier.
* @param prop Property name describing state pins.
*/
#define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \
{DT_FOREACH_CHILD_VARGS(DT_PHANDLE(node_id, prop), DT_FOREACH_PROP_ELEM, pinmux, \
Z_PINCTRL_STATE_PIN_INIT)}
/** @endcond */
/**
* @name FT9001 pull-up/down configuration
* @{
*/
#define FT9001_PUPD_NONE 0U /**< No pull-up/down */
#define FT9001_PUPD_PULLUP 1U /**< Pull-up */
#define FT9001_PUPD_PULLDOWN 2U /**< Pull-down */
/** @} */
/**
* @name FT9001 output type configuration
* @{
*/
#define FT9001_OTYPE_PP 0U /**< Push-pull */
#define FT9001_OTYPE_OD 1U /**< Open-drain */
/** @} */
/**
* @name FT9001 output speed configuration
* @{
*/
#define FT9001_OSPEED_10MHZ 0U /**< Maximum 10MHz */
#define FT9001_OSPEED_2MHZ 1U /**< Maximum 2MHz */
#define FT9001_OSPEED_50MHZ 2U /**< Maximum 50MHz */
#define FT9001_OSPEED_MAX 3U /**< Maximum speed */
/** @} */
/**
* @name FT9001 pin configuration bit field positions and masks
* @{
*/
#define FT9001_PUPD_POS 29U /**< PUPD field position */
#define FT9001_PUPD_MSK 0x3U /**< PUPD field mask */
#define FT9001_OTYPE_POS 28U /**< OTYPE field position */
#define FT9001_OTYPE_MSK 0x1U /**< OTYPE field mask */
#define FT9001_OSPEED_POS 26U /**< OSPEED field position */
#define FT9001_OSPEED_MSK 0x3U /**< OSPEED field mask */
/** @} */
/**
* @brief Obtain PUPD field from pinctrl_soc_pin_t configuration.
* @param pincfg pinctrl_soc_pin_t bit field value.
*/
#define FT9001_PUPD_GET(pincfg) (((pincfg) >> FT9001_PUPD_POS) & FT9001_PUPD_MSK)
/**
* @brief Obtain OTYPE field from pinctrl_soc_pin_t configuration.
* @param pincfg pinctrl_soc_pin_t bit field value.
*/
#define FT9001_OTYPE_GET(pincfg) (((pincfg) >> FT9001_OTYPE_POS) & FT9001_OTYPE_MSK)
/**
* @brief Obtain OSPEED field from pinctrl_soc_pin_t configuration.
* @param pincfg pinctrl_soc_pin_t bit field value.
*/
#define FT9001_OSPEED_GET(pincfg) (((pincfg) >> FT9001_OSPEED_POS) & FT9001_OSPEED_MSK)
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_SOC_ARM_FOCALTECH_FT9001_PINCTRL_SOC_H_ */

View File

@@ -0,0 +1,18 @@
/*
* Copyright (c) 2025, FocalTech Systems CO.,Ltd
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <soc.h>
#define XIP_CLKDIV_BOOT 1U
void xip_clock_switch(uint32_t clk_div);
void soc_early_init_hook(void)
{
#ifdef CONFIG_XIP
xip_clock_switch(XIP_CLKDIV_BOOT);
#endif
}

View File

@@ -0,0 +1,12 @@
/*
* Copyright (c) 2025, FocalTech Systems CO.,Ltd
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _SOC_ARM_FOCALTECH_FT9001_SOC_H_
#define _SOC_ARM_FOCALTECH_FT9001_SOC_H_
#include <cmsis_core_m_defaults.h>
#endif /* _SOC_ARM_FOCALTECH_FT9001_SOC_H_ */

View File

@@ -0,0 +1,25 @@
/*
* Copyright (c) 2025, FocalTech Systems CO.,Ltd
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/sys/barrier.h>
#include <zephyr/arch/common/sys_io.h>
/* clocks (soc-specific) */
#define FT9001_CLK_CFG_ADDR 0x40004008u
#define FT9001_CLK_UPD_ADDR 0x40004018u
#define FT9001_CLK_UPD_GO_MASK 0x02u
__ramfunc void xip_clock_switch(uint32_t clk_div)
{
uint32_t val = sys_read32(FT9001_CLK_CFG_ADDR);
val = (val & 0xFFFFFFF0u) | (clk_div & 0x0Fu);
sys_write32(val, FT9001_CLK_CFG_ADDR);
sys_write32(sys_read32(FT9001_CLK_UPD_ADDR) | FT9001_CLK_UPD_GO_MASK, FT9001_CLK_UPD_ADDR);
barrier_dsync_fence_full();
barrier_isync_fence_full();
}

2
soc/focaltech/soc.yml Normal file
View File

@@ -0,0 +1,2 @@
socs:
- name: ft9001