cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

core.h (4766B)


      1/* SPDX-License-Identifier: GPL-2.0-only */
      2/*
      3 * drivers/mfd/mfd-core.h
      4 *
      5 * core MFD support
      6 * Copyright (c) 2006 Ian Molton
      7 * Copyright (c) 2007 Dmitry Baryshkov
      8 */
      9
     10#ifndef MFD_CORE_H
     11#define MFD_CORE_H
     12
     13#include <linux/platform_device.h>
     14
     15#define MFD_RES_SIZE(arr) (sizeof(arr) / sizeof(struct resource))
     16
     17#define MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, _compat, _of_reg, _use_of_reg, _match) \
     18	{								\
     19		.name = (_name),					\
     20		.resources = (_res),					\
     21		.num_resources = MFD_RES_SIZE((_res)),			\
     22		.platform_data = (_pdata),				\
     23		.pdata_size = (_pdsize),				\
     24		.of_compatible = (_compat),				\
     25		.of_reg = (_of_reg),					\
     26		.use_of_reg = (_use_of_reg),				\
     27		.acpi_match = (_match),					\
     28		.id = (_id),						\
     29	}
     30
     31#define MFD_CELL_OF_REG(_name, _res, _pdata, _pdsize, _id, _compat, _of_reg) \
     32	MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, _compat, _of_reg, true, NULL)
     33
     34#define MFD_CELL_OF(_name, _res, _pdata, _pdsize, _id, _compat) \
     35	MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, _compat, 0, false, NULL)
     36
     37#define MFD_CELL_ACPI(_name, _res, _pdata, _pdsize, _id, _match) \
     38	MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, NULL, 0, false, _match)
     39
     40#define MFD_CELL_BASIC(_name, _res, _pdata, _pdsize, _id) \
     41	MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, NULL, 0, false, NULL)
     42
     43#define MFD_CELL_RES(_name, _res) \
     44	MFD_CELL_ALL(_name, _res, NULL, 0, 0, NULL, 0, false, NULL)
     45
     46#define MFD_CELL_NAME(_name) \
     47	MFD_CELL_ALL(_name, NULL, NULL, 0, 0, NULL, 0, false, NULL)
     48
     49#define MFD_DEP_LEVEL_NORMAL 0
     50#define MFD_DEP_LEVEL_HIGH 1
     51
     52struct irq_domain;
     53struct software_node;
     54
     55/* Matches ACPI PNP id, either _HID or _CID, or ACPI _ADR */
     56struct mfd_cell_acpi_match {
     57	const char			*pnpid;
     58	const unsigned long long	adr;
     59};
     60
     61/*
     62 * This struct describes the MFD part ("cell").
     63 * After registration the copy of this structure will become the platform data
     64 * of the resulting platform_device
     65 */
     66struct mfd_cell {
     67	const char		*name;
     68	int			id;
     69	int			level;
     70
     71	int			(*enable)(struct platform_device *dev);
     72	int			(*disable)(struct platform_device *dev);
     73
     74	int			(*suspend)(struct platform_device *dev);
     75	int			(*resume)(struct platform_device *dev);
     76
     77	/* platform data passed to the sub devices drivers */
     78	void			*platform_data;
     79	size_t			pdata_size;
     80
     81	/* Software node for the device. */
     82	const struct software_node *swnode;
     83
     84	/*
     85	 * Device Tree compatible string
     86	 * See: Documentation/devicetree/usage-model.rst Chapter 2.2 for details
     87	 */
     88	const char		*of_compatible;
     89
     90	/*
     91	 * Address as defined in Device Tree.  Used to compement 'of_compatible'
     92	 * (above) when matching OF nodes with devices that have identical
     93	 * compatible strings
     94	 */
     95	const u64 of_reg;
     96
     97	/* Set to 'true' to use 'of_reg' (above) - allows for of_reg=0 */
     98	bool use_of_reg;
     99
    100	/* Matches ACPI */
    101	const struct mfd_cell_acpi_match	*acpi_match;
    102
    103	/*
    104	 * These resources can be specified relative to the parent device.
    105	 * For accessing hardware you should use resources from the platform dev
    106	 */
    107	int			num_resources;
    108	const struct resource	*resources;
    109
    110	/* don't check for resource conflicts */
    111	bool			ignore_resource_conflicts;
    112
    113	/*
    114	 * Disable runtime PM callbacks for this subdevice - see
    115	 * pm_runtime_no_callbacks().
    116	 */
    117	bool			pm_runtime_no_callbacks;
    118
    119	/* A list of regulator supplies that should be mapped to the MFD
    120	 * device rather than the child device when requested
    121	 */
    122	const char * const	*parent_supplies;
    123	int			num_parent_supplies;
    124};
    125
    126/*
    127 * Convenience functions for clients using shared cells.  Refcounting
    128 * happens automatically, with the cell's enable/disable callbacks
    129 * being called only when a device is first being enabled or no other
    130 * clients are making use of it.
    131 */
    132extern int mfd_cell_enable(struct platform_device *pdev);
    133extern int mfd_cell_disable(struct platform_device *pdev);
    134
    135/*
    136 * Given a platform device that's been created by mfd_add_devices(), fetch
    137 * the mfd_cell that created it.
    138 */
    139static inline const struct mfd_cell *mfd_get_cell(struct platform_device *pdev)
    140{
    141	return pdev->mfd_cell;
    142}
    143
    144extern int mfd_add_devices(struct device *parent, int id,
    145			   const struct mfd_cell *cells, int n_devs,
    146			   struct resource *mem_base,
    147			   int irq_base, struct irq_domain *irq_domain);
    148
    149static inline int mfd_add_hotplug_devices(struct device *parent,
    150		const struct mfd_cell *cells, int n_devs)
    151{
    152	return mfd_add_devices(parent, PLATFORM_DEVID_AUTO, cells, n_devs,
    153			NULL, 0, NULL);
    154}
    155
    156extern void mfd_remove_devices(struct device *parent);
    157extern void mfd_remove_devices_late(struct device *parent);
    158
    159extern int devm_mfd_add_devices(struct device *dev, int id,
    160				const struct mfd_cell *cells, int n_devs,
    161				struct resource *mem_base,
    162				int irq_base, struct irq_domain *irq_domain);
    163#endif