brintos

brintos / linux-shallow public Read only

0
0
Text · 2.9 KiB · e5fac85 Raw
84 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * Copyright (C) 2023, STMicroelectronics - All Rights Reserved4 */5 6#ifndef _STM32_FIREWALL_H7#define _STM32_FIREWALL_H8 9#include <linux/kernel.h>10#include <linux/list.h>11#include <linux/of.h>12#include <linux/platform_device.h>13#include <linux/types.h>14 15/**16 * STM32_PERIPHERAL_FIREWALL:		This type of firewall protects peripherals17 * STM32_MEMORY_FIREWALL:		This type of firewall protects memories/subsets of memory18 *					zones19 * STM32_NOTYPE_FIREWALL:		Undefined firewall type20 */21 22#define STM32_PERIPHERAL_FIREWALL	BIT(1)23#define STM32_MEMORY_FIREWALL		BIT(2)24#define STM32_NOTYPE_FIREWALL		BIT(3)25 26/**27 * struct stm32_firewall_controller - Information on firewall controller supplying services28 *29 * @name:			Name of the firewall controller30 * @dev:			Device reference of the firewall controller31 * @mmio:			Base address of the firewall controller32 * @entry:			List entry of the firewall controller list33 * @type:			Type of firewall34 * @max_entries:		Number of entries covered by the firewall35 * @grant_access:		Callback used to grant access for a device access against a36 *				firewall controller37 * @release_access:		Callback used to release resources taken by a device when access was38 *				granted39 * @grant_memory_range_access:	Callback used to grant access for a device to a given memory region40 */41struct stm32_firewall_controller {42	const char *name;43	struct device *dev;44	void __iomem *mmio;45	struct list_head entry;46	unsigned int type;47	unsigned int max_entries;48 49	int (*grant_access)(struct stm32_firewall_controller *ctrl, u32 id);50	void (*release_access)(struct stm32_firewall_controller *ctrl, u32 id);51	int (*grant_memory_range_access)(struct stm32_firewall_controller *ctrl, phys_addr_t paddr,52					 size_t size);53};54 55/**56 * stm32_firewall_controller_register - Register a firewall controller to the STM32 firewall57 *					framework58 * @firewall_controller:	Firewall controller to register59 *60 * Returns 0 in case of success or -ENODEV if no controller was given.61 */62int stm32_firewall_controller_register(struct stm32_firewall_controller *firewall_controller);63 64/**65 * stm32_firewall_controller_unregister - Unregister a firewall controller from the STM3266 *					  firewall framework67 * @firewall_controller:	Firewall controller to unregister68 */69void stm32_firewall_controller_unregister(struct stm32_firewall_controller *firewall_controller);70 71/**72 * stm32_firewall_populate_bus - Populate device tree nodes that have a correct firewall73 *				 configuration. This is used at boot-time only, as a sanity check74 *				 between device tree and firewalls hardware configurations to75 *				 prevent a kernel crash when a device driver is not granted access76 *77 * @firewall_controller:	Firewall controller which nodes will be populated or not78 *79 * Returns 0 in case of success or appropriate errno code if error occurred.80 */81int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_controller);82 83#endif /* _STM32_FIREWALL_H */84