/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Copyright (C) 2023, STMicroelectronics - All Rights Reserved3*/45#ifndef _STM32_FIREWALL_H6#define _STM32_FIREWALL_H78#include <linux/kernel.h>9#include <linux/list.h>10#include <linux/of.h>11#include <linux/platform_device.h>12#include <linux/types.h>1314/**15* STM32_PERIPHERAL_FIREWALL: This type of firewall protects peripherals16* STM32_MEMORY_FIREWALL: This type of firewall protects memories/subsets of memory17* zones18* STM32_NOTYPE_FIREWALL: Undefined firewall type19*/2021#define STM32_PERIPHERAL_FIREWALL BIT(1)22#define STM32_MEMORY_FIREWALL BIT(2)23#define STM32_NOTYPE_FIREWALL BIT(3)2425/**26* struct stm32_firewall_controller - Information on firewall controller supplying services27*28* @name: Name of the firewall controller29* @dev: Device reference of the firewall controller30* @mmio: Base address of the firewall controller31* @entry: List entry of the firewall controller list32* @type: Type of firewall33* @max_entries: Number of entries covered by the firewall34* @grant_access: Callback used to grant access for a device access against a35* firewall controller36* @release_access: Callback used to release resources taken by a device when access was37* granted38* @grant_memory_range_access: Callback used to grant access for a device to a given memory region39*/40struct stm32_firewall_controller {41const char *name;42struct device *dev;43void __iomem *mmio;44struct list_head entry;45unsigned int type;46unsigned int max_entries;4748int (*grant_access)(struct stm32_firewall_controller *ctrl, u32 id);49void (*release_access)(struct stm32_firewall_controller *ctrl, u32 id);50int (*grant_memory_range_access)(struct stm32_firewall_controller *ctrl, phys_addr_t paddr,51size_t size);52};5354/**55* stm32_firewall_controller_register - Register a firewall controller to the STM32 firewall56* framework57* @firewall_controller: Firewall controller to register58*59* Returns 0 in case of success or -ENODEV if no controller was given.60*/61int stm32_firewall_controller_register(struct stm32_firewall_controller *firewall_controller);6263/**64* stm32_firewall_controller_unregister - Unregister a firewall controller from the STM3265* firewall framework66* @firewall_controller: Firewall controller to unregister67*/68void stm32_firewall_controller_unregister(struct stm32_firewall_controller *firewall_controller);6970/**71* stm32_firewall_populate_bus - Populate device tree nodes that have a correct firewall72* configuration. This is used at boot-time only, as a sanity check73* between device tree and firewalls hardware configurations to74* prevent a kernel crash when a device driver is not granted access75*76* @firewall_controller: Firewall controller which nodes will be populated or not77*78* Returns 0 in case of success or appropriate errno code if error occurred.79*/80int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_controller);8182#endif /* _STM32_FIREWALL_H */838485