drivers: mfd: add FLEXCOM drivers for Microchip SAM devices
The FLEXCOM offers several serial communication protocols that are managed by the three sub-modules USART, SPI, and TWI (I2C). Signed-off-by: Tony Han <tony.han@microchip.com>
This commit is contained in:
parent
3e20172ccc
commit
cc206e05b9
6 changed files with 103 additions and 0 deletions
|
@ -23,4 +23,5 @@ zephyr_library_sources_ifdef(CONFIG_MFD_ITE_IT8801_ALTCTRL mfd_it8801_altctrl.c)
|
|||
zephyr_library_sources_ifdef(CONFIG_MFD_AW9523B mfd_aw9523b.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_MFD_DS3231 mfd_ds3231.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_MFD_MAX22017 mfd_max22017.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_MFD_MCHP_SAM_FLEXCOM mfd_mchp_sam_flexcom.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_MFD_PF1550 mfd_pf1550.c)
|
||||
|
|
|
@ -28,6 +28,7 @@ source "drivers/mfd/Kconfig.max20335"
|
|||
source "drivers/mfd/Kconfig.max22017"
|
||||
source "drivers/mfd/Kconfig.max31790"
|
||||
source "drivers/mfd/Kconfig.maxq10xx"
|
||||
source "drivers/mfd/Kconfig.mchp_sam"
|
||||
source "drivers/mfd/Kconfig.nct38xx"
|
||||
source "drivers/mfd/Kconfig.npm1300"
|
||||
source "drivers/mfd/Kconfig.npm2100"
|
||||
|
|
10
drivers/mfd/Kconfig.mchp_sam
Normal file
10
drivers/mfd/Kconfig.mchp_sam
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Copyright (C) 2025 Microchip Technology Inc. and its subsidiaries
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config MFD_MCHP_SAM_FLEXCOM
|
||||
bool "Driver for the Microchip SAM FLEXCOM Interface"
|
||||
default y
|
||||
depends on DT_HAS_MICROCHIP_SAM_FLEXCOM_ENABLED
|
||||
help
|
||||
Enabled the SAM FLEXCOM driver.
|
49
drivers/mfd/mfd_mchp_sam_flexcom.c
Normal file
49
drivers/mfd/mfd_mchp_sam_flexcom.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (C) 2025 Microchip Technology Inc. and its subsidiaries
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT microchip_sam_flexcom
|
||||
|
||||
#include <errno.h>
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(mfd_flexcomm, CONFIG_MFD_LOG_LEVEL);
|
||||
|
||||
struct sam_flexcomm_config {
|
||||
flexcom_registers_t *reg;
|
||||
const int mode;
|
||||
};
|
||||
|
||||
static int sam_flexcomm_init(const struct device *dev)
|
||||
{
|
||||
const struct sam_flexcomm_config *config = dev->config;
|
||||
|
||||
config->reg->FLEX_MR = (config->reg->FLEX_MR & ~FLEX_MR_OPMODE_Msk) |
|
||||
FLEX_MR_OPMODE(config->mode);
|
||||
|
||||
LOG_DBG("%s set Operating Mode to %d", dev->name, config->mode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define SAM_FLEXCOMM_INIT(n) \
|
||||
\
|
||||
static const struct sam_flexcomm_config sam_flexcomm_config_##n = { \
|
||||
.reg = (flexcom_registers_t *)DT_INST_REG_ADDR(n), \
|
||||
.mode = DT_INST_PROP(n, mchp_flexcom_mode), \
|
||||
}; \
|
||||
\
|
||||
DEVICE_DT_INST_DEFINE(n, \
|
||||
&sam_flexcomm_init, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
&sam_flexcomm_config_##n, \
|
||||
PRE_KERNEL_1, \
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \
|
||||
NULL); \
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(SAM_FLEXCOMM_INIT)
|
25
dts/bindings/mfd/microchip,sam-flexcom.yaml
Normal file
25
dts/bindings/mfd/microchip,sam-flexcom.yaml
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Copyright (C) 2025 Microchip Technology Inc. and its subsidiaries
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
description: Microchip Flexcom (Flexible Serial Communication Unit)
|
||||
|
||||
compatible: "microchip,sam-flexcom"
|
||||
|
||||
include: base.yaml
|
||||
|
||||
properties:
|
||||
reg:
|
||||
required: true
|
||||
|
||||
mchp,flexcom-mode:
|
||||
type: int
|
||||
description: Initial operating mode for FLEXCOM
|
||||
|
||||
"#address-cells":
|
||||
required: true
|
||||
const: 1
|
||||
"#size-cells":
|
||||
required: true
|
||||
const: 1
|
17
include/zephyr/dt-bindings/mfd/mfd_mchp_sam_flexcom.h
Normal file
17
include/zephyr/dt-bindings/mfd/mfd_mchp_sam_flexcom.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Copyright (C) 2025 Microchip Technology Inc. and its subsidiaries
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_MFD_MCHP_SAM_FLEXCOMM_H_
|
||||
#define ZEPHYR_INCLUDE_DT_BINDINGS_MFD_MCHP_SAM_FLEXCOMM_H_
|
||||
|
||||
/**
|
||||
* @brief FLEXCOM Operating Mode.
|
||||
*/
|
||||
#define SAM_FLEXCOM_MODE_NO_COM 0
|
||||
#define SAM_FLEXCOM_MODE_USART 1
|
||||
#define SAM_FLEXCOM_MODE_SPI 2
|
||||
#define SAM_FLEXCOM_MODE_TWI 3
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_MFD_MCHP_SAM_FLEXCOMM_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue