Skip to content

Commit dbb8ee3

Browse files
frank-kuedanieldegrasse
authored andcommitted
drivers: reset: Add MPFS MSS driver
Add driver for Microchip PolarFire SoC (MPFS) peripheral clock and soft reset control. Normally, the peripheral clocks and reset state are controlled by the Hart Software Services (HSS) running on the Monitor processor. As an alternative to using HSS services, applications can now enable the reset controller in a device tree overly, for example: &reset { status = "okay"; }; &uart4 { resets = <&reset MSS_RESET_ID_MMUART4>; }; Embedded the reset controller node in system controller node. Signed-off-by: Frank Kühndel <frank.kuehndel@embedded-brains.de> Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de> Signed-off-by: Conor Paxton <conor.paxton@microchip.com>
1 parent 6efb1b4 commit dbb8ee3

File tree

7 files changed

+178
-0
lines changed

7 files changed

+178
-0
lines changed

drivers/reset/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ zephyr_library_sources_ifdef(CONFIG_RESET_NPCX reset_npcx.c)
1313
zephyr_library_sources_ifdef(CONFIG_RESET_NXP_SYSCON reset_lpc_syscon.c)
1414
zephyr_library_sources_ifdef(CONFIG_RESET_NXP_RSTCTL reset_nxp_rstctl.c)
1515
zephyr_library_sources_ifdef(CONFIG_RESET_MMIO reset_mmio.c)
16+
zephyr_library_sources_ifdef(CONFIG_RESET_MCHP_MSS reset_mchp_mss.c)

drivers/reset/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ rsource "Kconfig.npcx"
3737
rsource "Kconfig.lpc_syscon"
3838
rsource "Kconfig.nxp_rstctl"
3939
rsource "Kconfig.mmio"
40+
rsource "Kconfig.mchp_mss"
4041

4142
endif # RESET

drivers/reset/Kconfig.mchp_mss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2025 Microchip Technology Inc
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config RESET_MCHP_MSS
5+
bool "Microchip PolarFire SoC and PIC64GX reset driver"
6+
depends on DT_HAS_MICROCHIP_MPFS_RESET_ENABLED
7+
help
8+
This option enables the reset driver for Microchip's PolarFire SoC
9+
and PIC64GX platform.

drivers/reset/reset_mchp_mss.c

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Copyright (C) 2025 embedded brains GmbH & Co. KG
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#define DT_DRV_COMPAT microchip_mpfs_reset
8+
9+
#include <zephyr/arch/cpu.h>
10+
#include <zephyr/device.h>
11+
#include <zephyr/drivers/reset.h>
12+
13+
#define SUBBLK_CLOCK_CR_OFFSET 0x84U
14+
15+
#define SOFT_RESET_CR_OFFSET 0x88U
16+
17+
#define RESET_MSS_REG_BIT(id) ((id) & 0x1fU)
18+
19+
/* Bit 17 is related to the FPGA, bits 30 and 31 are reserved */
20+
#define RESET_MSS_VALID_BITS 0x3ffdffffU
21+
22+
struct reset_mss_config {
23+
uintptr_t base;
24+
};
25+
26+
static int reset_mss_status(const struct device *dev, uint32_t id, uint8_t *status)
27+
{
28+
const struct reset_mss_config *config = dev->config;
29+
30+
/* Device is in reset if the clock is turned off or held in soft reset */
31+
*status = sys_test_bit(config->base + SUBBLK_CLOCK_CR_OFFSET, RESET_MSS_REG_BIT(id)) == 0 ||
32+
sys_test_bit(config->base + SOFT_RESET_CR_OFFSET, RESET_MSS_REG_BIT(id) != 0);
33+
34+
return 0;
35+
}
36+
37+
static int reset_mss_line_assert(const struct device *dev, uint32_t id)
38+
{
39+
const struct reset_mss_config *config = dev->config;
40+
unsigned int bit = RESET_MSS_REG_BIT(id);
41+
42+
if (!IS_BIT_SET(RESET_MSS_VALID_BITS, bit)) {
43+
return -EINVAL;
44+
}
45+
46+
/* Turn off clock */
47+
sys_clear_bit(config->base + SUBBLK_CLOCK_CR_OFFSET, bit);
48+
49+
/* Hold in reset */
50+
sys_set_bit(config->base + SOFT_RESET_CR_OFFSET, bit);
51+
52+
return 0;
53+
}
54+
55+
static int reset_mss_line_deassert(const struct device *dev, uint32_t id)
56+
{
57+
const struct reset_mss_config *config = dev->config;
58+
unsigned int bit = RESET_MSS_REG_BIT(id);
59+
60+
if (!IS_BIT_SET(RESET_MSS_VALID_BITS, bit)) {
61+
return -EINVAL;
62+
}
63+
64+
/* Turn on clock */
65+
sys_set_bit(config->base + SUBBLK_CLOCK_CR_OFFSET, bit);
66+
67+
/* Remove soft reset */
68+
sys_clear_bit(config->base + SOFT_RESET_CR_OFFSET, bit);
69+
70+
return 0;
71+
}
72+
73+
static int reset_mss_line_toggle(const struct device *dev, uint32_t id)
74+
{
75+
reset_mss_line_assert(dev, id);
76+
reset_mss_line_deassert(dev, id);
77+
78+
return 0;
79+
}
80+
81+
static DEVICE_API(reset, reset_mss_driver_api) = {
82+
.status = reset_mss_status,
83+
.line_assert = reset_mss_line_assert,
84+
.line_deassert = reset_mss_line_deassert,
85+
.line_toggle = reset_mss_line_toggle
86+
};
87+
88+
static const struct reset_mss_config reset_mss_config = {
89+
.base = DT_REG_ADDR(DT_INST_PARENT(0))
90+
};
91+
92+
DEVICE_DT_INST_DEFINE(0, NULL, NULL, NULL, &reset_mss_config, PRE_KERNEL_1,
93+
CONFIG_RESET_INIT_PRIORITY, &reset_mss_driver_api);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# Copyright (C) 2025 embedded brains GmbH & Co. KG
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
description: Microchip MPFS Reset Controller (SOFT_RESET_CR, SUBBLK_CLOCK_CR)
8+
9+
compatible: "microchip,mpfs-reset"
10+
11+
include: [base.yaml, reset-controller.yaml]
12+
13+
properties:
14+
"#reset-cells":
15+
const: 1
16+
17+
reset-cells:
18+
- id

dts/riscv/microchip/mpfs.dtsi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <skeleton.dtsi>
88
#include <zephyr/dt-bindings/gpio/gpio.h>
9+
#include <zephyr/dt-bindings/reset/mchp_mss_reset.h>
910

1011
/ {
1112
#address-cells = <1>;
@@ -150,6 +151,16 @@
150151
status = "disabled";
151152
};
152153

154+
mpfs_top_sysreg: syscon@20002000 {
155+
compatible = "syscon";
156+
reg = <0x20002000 0x1000>;
157+
reset: reset {
158+
compatible = "microchip,mpfs-reset";
159+
#reset-cells = <1>;
160+
status = "disabled";
161+
};
162+
};
163+
153164
uart0: uart@20000000 {
154165
compatible = "ns16550";
155166
reg = <0x20000000 0x1000>;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (C) 2025 embedded brains GmbH & Co. KG
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_RESET_MCHP_MSS_RESET_H_
8+
#define ZEPHYR_INCLUDE_DT_BINDINGS_RESET_MCHP_MSS_RESET_H_
9+
10+
/*
11+
* The reset ID encodes the bit index of the SUBBLK_CLOCK_CR and SOFT_RESET_CR
12+
* registers associated with the device.
13+
*/
14+
#define MSS_RESET_ID_ENVM 0x0
15+
#define MSS_RESET_ID_MAC0 0x1
16+
#define MSS_RESET_ID_MAC1 0x2
17+
#define MSS_RESET_ID_MMC 0x3
18+
#define MSS_RESET_ID_TIMER 0x4
19+
#define MSS_RESET_ID_MMUART0 0x5
20+
#define MSS_RESET_ID_MMUART1 0x6
21+
#define MSS_RESET_ID_MMUART2 0x7
22+
#define MSS_RESET_ID_MMUART3 0x8
23+
#define MSS_RESET_ID_MMUART4 0x9
24+
#define MSS_RESET_ID_SPI0 0xa
25+
#define MSS_RESET_ID_SPI1 0xb
26+
#define MSS_RESET_ID_I2C0 0xc
27+
#define MSS_RESET_ID_I2C1 0xd
28+
#define MSS_RESET_ID_CAN0 0xe
29+
#define MSS_RESET_ID_CAN1 0xf
30+
#define MSS_RESET_ID_USB 0x10
31+
#define MSS_RESET_ID_RSVD 0x11
32+
#define MSS_RESET_ID_RTC 0x12
33+
#define MSS_RESET_ID_QSPI 0x13
34+
#define MSS_RESET_ID_GPIO0 0x14
35+
#define MSS_RESET_ID_GPIO1 0x15
36+
#define MSS_RESET_ID_GPIO2 0x16
37+
#define MSS_RESET_ID_DDRC 0x17
38+
#define MSS_RESET_ID_FIC0 0x18
39+
#define MSS_RESET_ID_FIC1 0x19
40+
#define MSS_RESET_ID_FIC2 0x1a
41+
#define MSS_RESET_ID_FIC3 0x1b
42+
#define MSS_RESET_ID_ATHENA 0x1c
43+
#define MSS_RESET_ID_CFM 0x1d
44+
45+
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_RESET_MCHP_MSS_RESET_H_ */

0 commit comments

Comments
 (0)