/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Copyright (C) 2013 Google, Inc
 *
 * (C) Copyright 2012
 * Pavel Herrmann <morpheus.ibis@gmail.com>
 * Marek Vasut <marex@denx.de>
 */

#ifndef _DM_DEVICE_INTERNAL_H
#define _DM_DEVICE_INTERNAL_H

#include <event.h>
#include <linker_lists.h>
#include <dm/ofnode.h>

struct device_node;
struct udevice;

/*
 * These two macros DM_DEVICE_INST and DM_DEVICE_REF are only allowed in code
 * generated by dtoc, because the ordering is important and if other instances
 * creep in then they may mess up the ordering expected by dtoc.
 *
 * It is OK to use them with 'extern' though, since that does not actually
 * add a new record to the linker_list.
 */

/**
 * DM_DEVICE_INST() - Declare a bound device ready for run-time use
 *
 * This adds an actual struct udevice to a list which is found by driver model
 * on start-up.
 *
 * For example:
 *
 * extern U_BOOT_DRIVER(sandbox_fixed_clock);
 * extern DM_UCLASS_INST(clk);
 *
 * DM_DEVICE_INST(clk_fixed) = {
 *	.driver		= DM_DRIVER_REF(sandbox_fixed_clock),
 *	.name		= "sandbox_fixed_clock",
 *	.plat_		= &_sandbox_fixed_clock_plat_clk_fixed,
 *	.uclass		= DM_UCLASS_REF(clk),
 *	...
 *	.seq_		= 0,
 * };
 *
 * @_name: Name of the udevice. This must be a valid C identifier, used by the
 *	linker_list.
 */
#define DM_DEVICE_INST(_name)						\
	ll_entry_declare(struct udevice, _name, udevice)

/**
 * DM_DEVICE_REF() - Get a reference to a device
 *
 * This is useful in data structures and code for referencing a udevice at
 * build time. Before this is used, an extern DM_DEVICE_INST() must have been
 * declared.
 *
 * For example:
 *
 * extern DM_DEVICE_INST(clk_fixed);
 *
 * struct udevice *devs[] = {
 *	DM_DEVICE_REF(clk_fixed),
 * };
 *
 * @_name: Name of the udevice. This must be a valid C identifier, used by the
 *	linker_list
 * @returns struct udevice * for the device
 */
#define DM_DEVICE_REF(_name)						\
	ll_entry_ref(struct udevice, _name, udevice)

/**
 * DM_DEVICE_GET() - Get a pointer to a given device
 *
 * This is similar to DM_DEVICE_REF() except that it does not need the extern
 * declaration before it. However it cannot be used in a data structures, only
 * in code within a function.
 *
 * For example:
 *
 * void some_function() {
 *	struct udevice *dev = DM_DEVICE_GET(clk_fixed);
 * ...
 * }
 */
#define DM_DEVICE_GET(__name)						\
	ll_entry_get(struct udevice, __name, udevice)

/**
 * device_bind() - Create a device and bind it to a driver
 *
 * Called to set up a new device attached to a driver. The device will either
 * have plat, or a device tree node which can be used to create the
 * plat.
 *
 * Once bound a device exists but is not yet active until device_probe() is
 * called.
 *
 * @parent: Pointer to device's parent, under which this driver will exist
 * @drv: Device's driver
 * @name: Name of device (e.g. device tree node name)
 * @plat: Pointer to data for this device - the structure is device-
 * specific but may include the device's I/O address, etc.. This is NULL for
 * devices which use device tree.
 * @ofnode: Devicetree node for this device. This is ofnode_null() for
 * devices which don't use devicetree or don't have a node.
 * @devp: if non-NULL, returns a pointer to the bound device
 * Return: 0 if OK, -ve on error
 */
int device_bind(struct udevice *parent, const struct driver *drv,
		const char *name, void *plat, ofnode node,
		struct udevice **devp);

/**
 * device_bind_with_driver_data() - Create a device and bind it to a driver
 *
 * Called to set up a new device attached to a driver, in the case where the
 * driver was matched to the device by means of a match table that provides
 * driver_data.
 *
 * Once bound a device exists but is not yet active until device_probe() is
 * called.
 *
 * @parent: Pointer to device's parent, under which this driver will exist
 * @drv: Device's driver
 * @name: Name of device (e.g. device tree node name)
 * @driver_data: The driver_data field from the driver's match table.
 * @node: Device tree node for this device. This is invalid for devices which
 * don't use device tree.
 * @devp: if non-NULL, returns a pointer to the bound device
 * Return: 0 if OK, -ve on error
 */
int device_bind_with_driver_data(struct udevice *parent,
				 const struct driver *drv, const char *name,
				 ulong driver_data, ofnode node,
				 struct udevice **devp);
/**
 * device_bind_by_name: Create a device and bind it to a driver
 *
 * This is a helper function used to bind devices which do not use device
 * tree.
 *
 * @parent: Pointer to device's parent
 * @pre_reloc_only: If true, bind the driver only if its DM_FLAG_PRE_RELOC flag
 * is set. If false bind the driver always.
 * @info: Name and plat for this device
 * @devp: if non-NULL, returns a pointer to the bound device
 * Return: 0 if OK, -ve on error
 */
int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
			const struct driver_info *info, struct udevice **devp);

/**
 * device_reparent: reparent the device to a new parent
 *
 * @dev: pointer to device to be reparented
 * @new_parent: pointer to new parent device
 * Return: 0 if OK, -ve on error
 */
int device_reparent(struct udevice *dev, struct udevice *new_parent);

/**
 * device_of_to_plat() - Read platform data for a device
 *
 * Read platform data for a device (typically from the device tree) so that
 * the information needed to probe the device is present.
 *
 * This may cause some others devices to be probed if this one depends on them,
 * e.g. a GPIO line will cause a GPIO device to be probed.
 *
 * All private data associated with the device is allocated.
 *
 * @dev: Pointer to device to process
 * Return: 0 if OK, -ve on error
 */
int device_of_to_plat(struct udevice *dev);

/**
 * device_probe() - Probe a device, activating it
 *
 * Activate a device so that it is ready for use. All its parents are probed
 * first.
 *
 * @dev: Pointer to device to probe
 * Return: 0 if OK, -ve on error
 */
int device_probe(struct udevice *dev);

/**
 * device_remove() - Remove a device, de-activating it
 *
 * De-activate a device so that it is no longer ready for use. All its
 * children are deactivated first.
 *
 * @dev: Pointer to device to remove
 * @flags: Flags for selective device removal (DM_REMOVE_...)
 * Return: 0 if OK, -EKEYREJECTED if not removed due to flags, -EPROBE_DEFER if
 *	this is a vital device and flags is DM_REMOVE_NON_VITAL, other -ve on
 *	error (such an error here is normally a very bad thing)
 */
#if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
int device_remove(struct udevice *dev, uint flags);
#else
static inline int device_remove(struct udevice *dev, uint flags) { return 0; }
#endif

/**
 * device_unbind() - Unbind a device, destroying it
 *
 * Unbind a device and remove all memory used by it
 *
 * @dev: Pointer to device to unbind
 * Return: 0 if OK, -ve on error
 */
#if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
int device_unbind(struct udevice *dev);
#else
static inline int device_unbind(struct udevice *dev) { return 0; }
#endif

#if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
void device_free(struct udevice *dev);
#else
static inline void device_free(struct udevice *dev) {}
#endif

/**
 * device_chld_unbind() - Unbind all device's children from the device if bound
 *			  to drv
 *
 * On error, the function continues to unbind all children, and reports the
 * first error.
 *
 * @dev:	The device that is to be stripped of its children
 * @drv:	The targeted driver
 * Return: 0 on success, -ve on error
 */
#if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
int device_chld_unbind(struct udevice *dev, struct driver *drv);
#else
static inline int device_chld_unbind(struct udevice *dev, struct driver *drv)
{
	return 0;
}
#endif

/**
 * device_chld_remove() - Stop all device's children
 *
 * This continues through all children recursively stopping part-way through if
 * an error occurs. Return values of -EKEYREJECTED are ignored and processing
 * continues, since they just indicate that the child did not elect to be
 * removed based on the value of @flags. Return values of -EPROBE_DEFER cause
 * processing of other children to continue, but the function will return
 * -EPROBE_DEFER.
 *
 * @dev:	The device whose children are to be removed
 * @drv:	The targeted driver
 * @flags:	Flag, if this functions is called in the pre-OS stage
 * Return: 0 on success, -EPROBE_DEFER if any child failed to remove, other
 *	-ve on error
 */
#if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
int device_chld_remove(struct udevice *dev, struct driver *drv,
		       uint flags);
#else
static inline int device_chld_remove(struct udevice *dev, struct driver *drv,
				     uint flags)
{
	return 0;
}
#endif

/**
 * dev_set_priv() - Set the private data for a device
 *
 * This is normally handled by driver model, which automatically allocates
 * private data when an 'auto' size if provided by the driver.
 *
 * Use this function to override normal operation for special situations, such
 * as needing to allocate a variable amount of data.
 *
 * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
 * model code, since the pointer must be within the gd->dm_priv_base region.
 *
 * @dev		Device to check
 * @priv	New private-data pointer
 */
void dev_set_priv(struct udevice *dev, void *priv);

/**
 * dev_set_parent_priv() - Set the parent-private data for a device
 *
 * This is normally handled by driver model, which automatically allocates
 * parent-private data when an 'auto' size if provided by the driver.
 *
 * Use this function to override normal operation for special situations, such
 * as needing to allocate a variable amount of data.
 *
 * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
 * model code, since the pointer must be within the gd->dm_priv_base region.
 *
 * @dev:	Device to update
 * @parent_priv: New parent-private data
 */
void dev_set_parent_priv(struct udevice *dev, void *parent_priv);

/**
 * dev_set_uclass_priv() - Set the uclass private data for a device
 *
 * This is normally handled by driver model, which automatically allocates
 * uclass-private data when an 'auto' size if provided by the driver.
 *
 * Use this function to override normal operation for special situations, such
 * as needing to allocate a variable amount of data.
 *
 * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
 * model code, since the pointer must be within the gd->dm_priv_base region.
 *
 * @dev:	Device to update
 * @uclass_priv: New uclass private data
 */
void dev_set_uclass_priv(struct udevice *dev, void *uclass_priv);

/**
 * dev_set_plat() - Set the platform data for a device
 *
 * This is normally handled by driver model, which automatically allocates
 * platform data when an 'auto' size if provided by the driver.
 *
 * Use this function to override normal operation for special situations, such
 * as needing to allocate a variable amount of data.
 *
 * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
 * model code, since the pointer must be within the gd->dm_priv_base region.
 *
 * @dev		Device to check
 * @plat	New platform-data pointer
 */
void dev_set_plat(struct udevice *dev, void *priv);

/**
 * dev_set_parent_plat() - Set the parent platform data for a device
 *
 * This is normally handled by driver model, which automatically allocates
 * parent platform data when an 'auto' size if provided by the driver.
 *
 * Use this function to override normal operation for special situations, such
 * as needing to allocate a variable amount of data.
 *
 * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
 * model code, since the pointer must be within the gd->dm_priv_base region.
 *
 * @dev:	Device to update
 * @parent_plat: New parent platform data
 */
void dev_set_parent_plat(struct udevice *dev, void *parent_plat);

/**
 * dev_set_uclass_plat() - Set the uclass platform data for a device
 *
 * This is normally handled by driver model, which automatically allocates
 * uclass platform data when an 'auto' size if provided by the driver.
 *
 * Use this function to override normal operation for special situations, such
 * as needing to allocate a variable amount of data.
 *
 * If OF_PLATDATA_RT is enabled, this function cannot be used out of core driver
 * model code, since the pointer must be within the gd->dm_priv_base region.
 *
 * @dev:	Device to update
 * @uclass_plat: New uclass platform data
 */
void dev_set_uclass_plat(struct udevice *dev, void *uclass_plat);

/**
 * simple_bus_translate() - translate a bus address to a system address
 *
 * This handles the 'ranges' property in a simple bus. It translates the
 * device address @addr to a system address using this property.
 *
 * @dev:	Simple bus device (parent of target device)
 * @addr:	Address to translate
 * Return: new address
 */
fdt_addr_t simple_bus_translate(struct udevice *dev, fdt_addr_t addr);

/* Cast away any volatile pointer */
#define DM_ROOT_NON_CONST		(((gd_t *)gd)->dm_root)
#define DM_UCLASS_ROOT_NON_CONST	(((gd_t *)gd)->uclass_root)
#define DM_UCLASS_ROOT_S_NON_CONST	(((gd_t *)gd)->uclass_root_s)

/* device resource management */
#ifdef CONFIG_DEVRES

/**
 * devres_release_probe - Release managed resources allocated after probing
 * @dev: Device to release resources for
 *
 * Release all resources allocated for @dev when it was probed or later.
 * This function is called on driver removal.
 */
void devres_release_probe(struct udevice *dev);

/**
 * devres_release_all - Release all managed resources
 * @dev: Device to release resources for
 *
 * Release all resources associated with @dev.  This function is
 * called on driver unbinding.
 */
void devres_release_all(struct udevice *dev);

#else /* ! CONFIG_DEVRES */

static inline void devres_release_probe(struct udevice *dev)
{
}

static inline void devres_release_all(struct udevice *dev)
{
}

#endif /* ! CONFIG_DEVRES */

static inline int device_notify(const struct udevice *dev, enum event_t type)
{
#if CONFIG_IS_ENABLED(DM_EVENT)
	return event_notify(type, &dev, sizeof(dev));
#else
	return 0;
#endif
}
#endif
