Commit dbb8ee38 authored by Frank Kühndel's avatar Frank Kühndel Committed by Daniel DeGrasse
Browse files

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: default avatarFrank Kühndel <frank.kuehndel@embedded-brains.de>
Signed-off-by: default avatarSebastian Huber <sebastian.huber@embedded-brains.de>
Signed-off-by: default avatarConor Paxton <conor.paxton@microchip.com>
parent 6efb1b40
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -13,3 +13,4 @@ zephyr_library_sources_ifdef(CONFIG_RESET_NPCX reset_npcx.c)
zephyr_library_sources_ifdef(CONFIG_RESET_NXP_SYSCON reset_lpc_syscon.c)
zephyr_library_sources_ifdef(CONFIG_RESET_NXP_RSTCTL reset_nxp_rstctl.c)
zephyr_library_sources_ifdef(CONFIG_RESET_MMIO reset_mmio.c)
zephyr_library_sources_ifdef(CONFIG_RESET_MCHP_MSS reset_mchp_mss.c)
+1 −0
Original line number Diff line number Diff line
@@ -37,5 +37,6 @@ rsource "Kconfig.npcx"
rsource "Kconfig.lpc_syscon"
rsource "Kconfig.nxp_rstctl"
rsource "Kconfig.mmio"
rsource "Kconfig.mchp_mss"

endif # RESET
+9 −0
Original line number Diff line number Diff line
# Copyright (c) 2025 Microchip Technology Inc
# SPDX-License-Identifier: Apache-2.0

config RESET_MCHP_MSS
	bool "Microchip PolarFire SoC and PIC64GX reset driver"
	depends on DT_HAS_MICROCHIP_MPFS_RESET_ENABLED
	help
	  This option enables the reset driver for Microchip's PolarFire SoC
	  and PIC64GX platform.
+93 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 embedded brains GmbH & Co. KG
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#define DT_DRV_COMPAT microchip_mpfs_reset

#include <zephyr/arch/cpu.h>
#include <zephyr/device.h>
#include <zephyr/drivers/reset.h>

#define SUBBLK_CLOCK_CR_OFFSET 0x84U

#define SOFT_RESET_CR_OFFSET 0x88U

#define RESET_MSS_REG_BIT(id) ((id) & 0x1fU)

/* Bit 17 is related to the FPGA, bits 30 and 31 are reserved */
#define RESET_MSS_VALID_BITS 0x3ffdffffU

struct reset_mss_config {
	uintptr_t base;
};

static int reset_mss_status(const struct device *dev, uint32_t id, uint8_t *status)
{
	const struct reset_mss_config *config = dev->config;

	/* Device is in reset if the clock is turned off or held in soft reset */
	*status = sys_test_bit(config->base + SUBBLK_CLOCK_CR_OFFSET, RESET_MSS_REG_BIT(id)) == 0 ||
		  sys_test_bit(config->base + SOFT_RESET_CR_OFFSET, RESET_MSS_REG_BIT(id) != 0);

	return 0;
}

static int reset_mss_line_assert(const struct device *dev, uint32_t id)
{
	const struct reset_mss_config *config = dev->config;
	unsigned int bit = RESET_MSS_REG_BIT(id);

	if (!IS_BIT_SET(RESET_MSS_VALID_BITS, bit)) {
		return -EINVAL;
	}

	/* Turn off clock */
	sys_clear_bit(config->base + SUBBLK_CLOCK_CR_OFFSET, bit);

	/* Hold in reset */
	sys_set_bit(config->base + SOFT_RESET_CR_OFFSET, bit);

	return 0;
}

static int reset_mss_line_deassert(const struct device *dev, uint32_t id)
{
	const struct reset_mss_config *config = dev->config;
	unsigned int bit = RESET_MSS_REG_BIT(id);

	if (!IS_BIT_SET(RESET_MSS_VALID_BITS, bit)) {
		return -EINVAL;
	}

	/* Turn on clock */
	sys_set_bit(config->base + SUBBLK_CLOCK_CR_OFFSET, bit);

	/* Remove soft reset */
	sys_clear_bit(config->base + SOFT_RESET_CR_OFFSET, bit);

	return 0;
}

static int reset_mss_line_toggle(const struct device *dev, uint32_t id)
{
	reset_mss_line_assert(dev, id);
	reset_mss_line_deassert(dev, id);

	return 0;
}

static DEVICE_API(reset, reset_mss_driver_api) = {
	.status = reset_mss_status,
	.line_assert = reset_mss_line_assert,
	.line_deassert = reset_mss_line_deassert,
	.line_toggle = reset_mss_line_toggle
};

static const struct reset_mss_config reset_mss_config = {
	.base = DT_REG_ADDR(DT_INST_PARENT(0))
};

DEVICE_DT_INST_DEFINE(0, NULL, NULL, NULL, &reset_mss_config, PRE_KERNEL_1,
		      CONFIG_RESET_INIT_PRIORITY, &reset_mss_driver_api);
+18 −0
Original line number Diff line number Diff line
#
# Copyright (C) 2025 embedded brains GmbH & Co. KG
#
# SPDX-License-Identifier: Apache-2.0
#

description: Microchip MPFS Reset Controller (SOFT_RESET_CR, SUBBLK_CLOCK_CR)

compatible: "microchip,mpfs-reset"

include: [base.yaml, reset-controller.yaml]

properties:
  "#reset-cells":
    const: 1

reset-cells:
- id
Loading