/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Copyright (c) 2015 Google, Inc
 * Written by Simon Glass <sjg@chromium.org>
 * Copyright (c) 2016, NVIDIA CORPORATION.
 */

#ifndef _CLK_H_
#define _CLK_H_

#include <dm/ofnode.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/types.h>

/**
 * DOC: Overview
 *
 * A clock is a hardware signal that oscillates autonomously at a specific
 * frequency and duty cycle. Most hardware modules require one or more clock
 * signal to drive their operation. Clock signals are typically generated
 * externally to the HW module consuming them, by an entity this API calls a
 * clock provider. This API provides a standard means for drivers to enable and
 * disable clocks, and to set the rate at which they oscillate.
 *
 * A driver that implements UCLASS_CLK is a clock provider. A provider will
 * often implement multiple separate clocks, since the hardware it manages
 * often has this capability. clk-uclass.h describes the interface which
 * clock providers must implement.
 *
 * Clock consumers/clients are the HW modules driven by the clock signals. This
 * header file describes the API used by drivers for those HW modules.
 */

struct udevice;

/**
 * struct clk - A handle to (allowing control of) a single clock.
 * @dev: The device which implements the clock signal.
 * @rate: The clock rate (in HZ).
 * @flags: Flags used across common clock structure (e.g. %CLK_)
 *         Clock IP blocks specific flags (i.e. mux, div, gate, etc) are defined
 *         in struct's for those devices (e.g. &struct clk_mux).
 * @enable_count: The number of times this clock has been enabled.
 * @id: The clock signal ID within the provider.
 * @data: An optional data field for scenarios where a single integer ID is not
 *	  sufficient. If used, it can be populated through an .of_xlate op and
 *	  processed during the various clock ops.
 *
 * Clients provide storage for clock handles. The content of the structure is
 * managed solely by the clock API and clock drivers. A clock struct is
 * initialized by "get"ing the clock struct. The clock struct is passed to all
 * other clock APIs to identify which clock signal to operate upon.
 *
 * Should additional information to identify and configure any clock signal
 * for any provider be required in the future, the struct could be expanded to
 * either (a) add more fields to allow clock providers to store additional
 * information, or (b) replace the id field with an opaque pointer, which the
 * provider would dynamically allocated during its .of_xlate op, and process
 * during is .request op. This may require the addition of an extra op to clean
 * up the allocation.
 */
struct clk {
	struct udevice *dev;
	long long rate;	/* in HZ */
	u32 flags;
	int enable_count;
	/*
	 * Written by of_xlate. In the future, we might add more fields here.
	 */
	unsigned long id;
	unsigned long data;
};

/**
 * struct clk_bulk - A handle to (allowing control of) a bulk of clocks.
 * @clks: An array of clock handles.
 * @count: The number of clock handles in the clks array.
 *
 * Clients provide storage for the clock bulk. The content of the structure is
 * managed solely by the clock API. A clock bulk struct is
 * initialized by "get"ing the clock bulk struct.
 * The clock bulk struct is passed to all other bulk clock APIs to apply
 * the API to all the clock in the bulk struct.
 */
struct clk_bulk {
	struct clk *clks;
	unsigned int count;
};

struct phandle_1_arg;

#if CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(CLK)
/**
 * clk_get_by_phandle() - Get a clock by its phandle information (of-platadata)
 * @dev: Device containing the phandle
 * @cells: Phandle info
 * @clk: A pointer to a clock struct to initialise
 *
 * This function is used when of-platdata is enabled.
 *
 * This looks up a clock using the phandle info. With dtoc, each phandle in the
 * 'clocks' property is transformed into an idx representing the device.
 * For example::
 *
 *	clocks = <&dpll_mpu_ck 23>;
 *
 * might result in::
 *
 *	.clocks = {1, {23}},},
 *
 * indicating that the clock is udevice idx 1 in dt-plat.c with an argument of
 * 23. This function can return a valid clock given the above information. In
 * this example it would return a clock containing the 'dpll_mpu_ck' device and
 * the clock ID 23.
 *
 * Return: 0 if OK, or a negative error code.
 */
int clk_get_by_phandle(struct udevice *dev, const struct phandle_1_arg *cells,
		       struct clk *clk);

/**
 * clk_get_by_index() - Get/request a clock by integer index.
 * @dev:	The client device.
 * @index:	The index of the clock to request, within the client's list of
 *		clocks.
 * @clk:	A pointer to a clock struct to initialize.
 *
 * This looks up and requests a clock. The index is relative to the client
 * device; each device is assumed to have n clocks associated with it somehow,
 * and this function finds and requests one of them. The mapping of client
 * device clock indices to provider clocks may be via device-tree properties,
 * board-provided mapping tables, or some other mechanism.
 *
 * Return: 0 if OK, or a negative error code.
 */
int clk_get_by_index(struct udevice *dev, int index, struct clk *clk);

/**
 * clk_get_by_index_nodev() - Get/request a clock by integer index without a
 *                            device.
 * @node:	The client ofnode.
 * @index:	The index of the clock to request, within the client's list of
 *		clocks.
 * @clk:	A pointer to a clock struct to initialize.
 *
 * Return: 0 if OK, or a negative error code.
 */
int clk_get_by_index_nodev(ofnode node, int index, struct clk *clk);

/**
 * clk_get_bulk() - Get/request all clocks of a device.
 * @dev:	The client device.
 * @bulk:	A pointer to a clock bulk struct to initialize.
 *
 * This looks up and requests all clocks of the client device; each device is
 * assumed to have n clocks associated with it somehow, and this function finds
 * and requests all of them in a separate structure. The mapping of client
 * device clock indices to provider clocks may be via device-tree properties,
 * board-provided mapping tables, or some other mechanism.
 *
 * Return: 0 if OK, or a negative error code.
 */
int clk_get_bulk(struct udevice *dev, struct clk_bulk *bulk);

/**
 * clk_get_by_name() - Get/request a clock by name.
 * @dev:	The client device.
 * @name:	The name of the clock to request, within the client's list of
 *		clocks.
 * @clk:	A pointer to a clock struct to initialize.
 *
 * This looks up and requests a clock. The name is relative to the client
 * device; each device is assumed to have n clocks associated with it somehow,
 * and this function finds and requests one of them. The mapping of client
 * device clock names to provider clocks may be via device-tree properties,
 * board-provided mapping tables, or some other mechanism.
 *
 * Return: 0 if OK, or a negative error code.
 */
int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk);

/**
 * clk_get_by_name_nodev - Get/request a clock by name without a device.
 * @node:	The client ofnode.
 * @name:	The name of the clock to request, within the client's list of
 *		clocks.
 * @clk:	A pointer to a clock struct to initialize.
 *
 * Return: 0 if OK, or a negative error code.
 */
int clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk);

/**
 * devm_clk_get() - lookup and obtain a managed reference to a clock producer.
 * @dev: device for clock "consumer"
 * @id: clock consumer ID
 *
 * The implementation uses @dev and @id to determine the clock consumer, and
 * thereby the clock producer. (IOW, @id may be identical strings, but clk_get
 * may return different clock producers depending on @dev.)
 *
 * Drivers must assume that the clock source is not enabled.
 *
 * The clock will automatically be freed when the device is unbound
 * from the bus.
 *
 * Return:
 * a struct clk corresponding to the clock producer, or
 * valid IS_ERR() condition containing errno
 */
struct clk *devm_clk_get(struct udevice *dev, const char *id);

/**
 * devm_clk_get_optional() - lookup and obtain a managed reference to an
 *                           optional clock producer.
 * @dev: device for clock "consumer"
 * @id: clock consumer ID
 *
 * Behaves the same as devm_clk_get() except where there is no clock producer.
 * In this case, instead of returning -%ENOENT, the function returns NULL.
 */
static inline struct clk *devm_clk_get_optional(struct udevice *dev,
						const char *id)
{
	struct clk *clk = devm_clk_get(dev, id);

	if (PTR_ERR(clk) == -ENODATA)
		return NULL;

	return clk;
}

/**
 * clk_release_all() - Disable (turn off)/Free an array of previously
 * requested clocks.
 * @clk:	A clock struct array that was previously successfully
 *		requested by clk_request/get_by_*().
 * @count:	Number of clock contained in the array
 *
 * For each clock contained in the clock array, this function will check if
 * clock has been previously requested and then will disable and free it.
 *
 * Return: zero on success, or -ve error code.
 */
int clk_release_all(struct clk *clk, int count);

/**
 * devm_clk_put	- "free" a managed clock source
 * @dev: device used to acquire the clock
 * @clk: clock source acquired with devm_clk_get()
 *
 * Note: drivers must ensure that all clk_enable calls made on this
 * clock source are balanced by clk_disable calls prior to calling
 * this function.
 *
 * clk_put should not be called from within interrupt context.
 */
void devm_clk_put(struct udevice *dev, struct clk *clk);

#else

static inline int clk_get_by_phandle(struct udevice *dev, const
				     struct phandle_1_arg *cells,
				     struct clk *clk)
{
	return -ENOSYS;
}

static inline int clk_get_by_index(struct udevice *dev, int index,
				   struct clk *clk)
{
	return -ENOSYS;
}

static inline int clk_get_by_index_nodev(ofnode node, int index,
					 struct clk *clk)
{
	return -ENOSYS;
}

static inline int clk_get_bulk(struct udevice *dev, struct clk_bulk *bulk)
{
	return -ENOSYS;
}

static inline int clk_get_by_name(struct udevice *dev, const char *name,
			   struct clk *clk)
{
	return -ENOSYS;
}

static inline struct clk *devm_clk_get(struct udevice *dev, const char *id)
{
	return ERR_PTR(-ENOSYS);
}

static inline struct clk *devm_clk_get_optional(struct udevice *dev,
						const char *id)
{
	return ERR_PTR(-ENOSYS);
}

static inline int
clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk)
{
	return -ENOSYS;
}

static inline int clk_release_all(struct clk *clk, int count)
{
	return -ENOSYS;
}

static inline void devm_clk_put(struct udevice *dev, struct clk *clk)
{
}
#endif

/**
 * clk_get_by_name_optional() - Get/request a optional clock by name.
 * @dev:	The client device.
 * @name:	The name of the clock to request, within the client's list of
 *		clocks.
 * @clk:	A pointer to a clock struct to initialize.
 *
 * Behaves the same as clk_get_by_name(), except when there is no clock
 * provider. In the latter case, return 0.
 *
 * Return: 0 if OK, or a negative error code.
 */
static inline int clk_get_by_name_optional(struct udevice *dev,
					   const char *name, struct clk *clk)
{
	int ret;

	ret = clk_get_by_name(dev, name, clk);
	if (ret == -ENODATA)
		return 0;

	return ret;
}

/**
 * clk_get_by_name_nodev_optional - Get/request an optinonal clock by name
 *		without a device.
 * @node:	The client ofnode.
 * @name:	The name of the clock to request, within the client's list of
 *		clocks.
 * @clk:	A pointer to a clock struct to initialize.
 *
 * Behaves the same as clk_get_by_name_nodev() except where there is
 * no clock producer, in this case, skip the error number -%ENODATA, and
 * the function returns 0.
 */
static inline int clk_get_by_name_nodev_optional(ofnode node, const char *name,
						 struct clk *clk)
{
	int ret;

	ret = clk_get_by_name_nodev(node, name, clk);
	if (ret == -ENODATA)
		return 0;

	return ret;
}

/**
 * enum clk_defaults_stage - What stage clk_set_defaults() is called at
 * @CLK_DEFAULTS_PRE: Called before probe. Setting of defaults for clocks owned
 *                    by this clock driver will be defered until after probing.
 * @CLK_DEFAULTS_POST: Called after probe. Only defaults for clocks owned by
 *                     this clock driver will be set.
 * @CLK_DEFAULTS_POST_FORCE: Called after probe, and always set defaults, even
 *                           before relocation. Usually, defaults are not set
 *                           pre-relocation to avoid setting them twice (when
 *                           the device is probed again post-relocation). This
 *                           may incur a performance cost as device tree
 *                           properties must be parsed for a second time.
 *                           However, when not using SPL, pre-relocation may be
 *                           the only time we can set defaults for some clocks
 *                           (such as those used for the RAM we will relocate
 *                           into).
 */
enum clk_defaults_stage {
	CLK_DEFAULTS_PRE = 0,
	CLK_DEFAULTS_POST = 1,
	CLK_DEFAULTS_POST_FORCE,
};

#if CONFIG_IS_ENABLED(OF_REAL) && CONFIG_IS_ENABLED(CLK)
/**
 * clk_set_defaults - Process ``assigned-{clocks/clock-parents/clock-rates}``
 *                    properties to configure clocks
 * @dev:        A device to process (the ofnode associated with this device
 *              will be processed).
 * @stage:	The stage of the probing process this function is called during.
 *
 * Return: zero on success, or -ve error code.
 */
int clk_set_defaults(struct udevice *dev, enum clk_defaults_stage stage);
#else
static inline int clk_set_defaults(struct udevice *dev, int stage)
{
	return 0;
}
#endif

/**
 * clk_release_bulk() - Disable (turn off)/Free an array of previously
 * requested clocks in a clock bulk struct.
 * @bulk:	A clock bulk struct that was previously successfully
 *		requested by clk_get_bulk().
 *
 * For each clock contained in the clock bulk struct, this function will check
 * if clock has been previously requested and then will disable and free it.
 *
 * Return: zero on success, or -ve error code.
 */
static inline int clk_release_bulk(struct clk_bulk *bulk)
{
	return clk_release_all(bulk->clks, bulk->count);
}

#if CONFIG_IS_ENABLED(CLK)
/**
 * clk_request() - Request a clock by provider-specific ID.
 * @dev:	The clock provider device.
 * @clk:	A pointer to a clock struct to initialize. The caller must
 *		have already initialized any field in this struct which the
 *		clock provider uses to identify the clock.
 *
 * This requests a clock using a provider-specific ID. Generally, this function
 * should not be used, since clk_get_by_index/name() provide an interface that
 * better separates clients from intimate knowledge of clock providers.
 * However, this function may be useful in core SoC-specific code.
 *
 * Return: 0 if OK, or a negative error code.
 */
int clk_request(struct udevice *dev, struct clk *clk);

/**
 * clk_free() - Free a previously requested clock.
 * @clk:	A clock struct that was previously successfully requested by
 *		clk_request/get_by_*().
 *
 * Free resources allocated by clk_request() (or any clk_get_* function).
 */
void clk_free(struct clk *clk);

/**
 * clk_get_rate() - Get current clock rate.
 * @clk:	A clock struct that was previously successfully requested by
 *		clk_request/get_by_*().
 *
 * Return: clock rate in Hz on success, 0 for invalid clock, or -ve error code
 *	   for other errors.
 */
ulong clk_get_rate(struct clk *clk);

/**
 * clk_get_parent() - Get current clock's parent.
 * @clk:	A clock struct that was previously successfully requested by
 *		clk_request/get_by_*().
 *
 * Return: pointer to parent's struct clk, or error code passed as pointer
 */
struct clk *clk_get_parent(struct clk *clk);

/**
 * clk_get_parent_rate() - Get parent of current clock rate.
 * @clk:	A clock struct that was previously successfully requested by
 *		clk_request/get_by_*().
 *
 * Return: clock rate in Hz, or -ve error code.
 */
long long clk_get_parent_rate(struct clk *clk);

/**
 * clk_round_rate() - Adjust a rate to the exact rate a clock can provide
 * @clk: A clock struct that was previously successfully requested by
 *       clk_request/get_by_*().
 * @rate: desired clock rate in Hz.
 *
 * This answers the question "if I were to pass @rate to clk_set_rate(),
 * what clock rate would I end up with?" without changing the hardware
 * in any way. In other words::
 *
 *   rate = clk_round_rate(clk, r);
 *
 * and::
 *
 *   rate = clk_set_rate(clk, r);
 *
 * are equivalent except the former does not modify the clock hardware
 * in any way.
 *
 * Return: rounded rate in Hz, or -ve error code.
 */
ulong clk_round_rate(struct clk *clk, ulong rate);

/**
 * clk_set_rate() - Set current clock rate.
 * @clk:	A clock struct that was previously successfully requested by
 *		clk_request/get_by_*().
 * @rate:	New clock rate in Hz.
 *
 * Return: new rate, or -ve error code.
 */
ulong clk_set_rate(struct clk *clk, ulong rate);

/**
 * clk_set_parent() - Set current clock parent.
 * @clk:	A clock struct that was previously successfully requested by
 *		clk_request/get_by_*().
 * @parent:	A clock struct that was previously successfully requested by
 *		clk_request/get_by_*().
 *
 * Return: new rate, or -ve error code.
 */
int clk_set_parent(struct clk *clk, struct clk *parent);

/**
 * clk_enable() - Enable (turn on) a clock.
 * @clk:	A clock struct that was previously successfully requested by
 *		clk_request/get_by_*().
 *
 * Return: zero on success, or -ve error code.
 */
int clk_enable(struct clk *clk);

/**
 * clk_enable_bulk() - Enable (turn on) all clocks in a clock bulk struct.
 * @bulk:	A clock bulk struct that was previously successfully requested
 *		by clk_get_bulk().
 *
 * Return: zero on success, or -ve error code.
 */
int clk_enable_bulk(struct clk_bulk *bulk);

/**
 * clk_disable() - Disable (turn off) a clock.
 * @clk:	A clock struct that was previously successfully requested by
 *		clk_request/get_by_*().
 *
 * Return: zero on success, or -ve error code.
 */
int clk_disable(struct clk *clk);

/**
 * clk_disable_bulk() - Disable (turn off) all clocks in a clock bulk struct.
 * @bulk:	A clock bulk struct that was previously successfully requested
 *		by clk_get_bulk().
 *
 * Return: zero on success, or -ve error code.
 */
int clk_disable_bulk(struct clk_bulk *bulk);

/**
 * clk_is_match - check if two clk's point to the same hardware clock
 * @p: clk compared against q
 * @q: clk compared against p
 *
 * Return:
 * %true if the two struct clk pointers both point to the same hardware clock
 * node, and %false otherwise. Note that two %NULL clks are treated as matching.
 */
bool clk_is_match(const struct clk *p, const struct clk *q);

/**
 * clk_get_by_id() - Get the clock by its ID
 * @id:	The clock ID to search for
 * @clkp:	A pointer to clock struct that has been found among added clocks
 *              to UCLASS_CLK
 *
 * Return: zero on success, or -ENOENT on error
 */
int clk_get_by_id(ulong id, struct clk **clkp);

/**
 * clk_dev_binded() - Check whether the clk has a device binded
 * @clk:	A pointer to the clk
 *
 * Return: true on binded, or false on no
 */
bool clk_dev_binded(struct clk *clk);

#else /* CONFIG_IS_ENABLED(CLK) */

static inline int clk_request(struct udevice *dev, struct clk *clk)
{
	return -ENOSYS;
}

static inline void clk_free(struct clk *clk)
{
	return;
}

static inline ulong clk_get_rate(struct clk *clk)
{
	return -ENOSYS;
}

static inline struct clk *clk_get_parent(struct clk *clk)
{
	return ERR_PTR(-ENOSYS);
}

static inline long long clk_get_parent_rate(struct clk *clk)
{
	return -ENOSYS;
}

static inline ulong clk_round_rate(struct clk *clk, ulong rate)
{
	return -ENOSYS;
}

static inline ulong clk_set_rate(struct clk *clk, ulong rate)
{
	return -ENOSYS;
}

static inline int clk_set_parent(struct clk *clk, struct clk *parent)
{
	return -ENOSYS;
}

static inline int clk_enable(struct clk *clk)
{
	return 0;
}

static inline int clk_enable_bulk(struct clk_bulk *bulk)
{
	return 0;
}

static inline int clk_disable(struct clk *clk)
{
	return 0;
}

static inline int clk_disable_bulk(struct clk_bulk *bulk)
{
	return 0;
}

static inline bool clk_is_match(const struct clk *p, const struct clk *q)
{
	return false;
}

static inline int clk_get_by_id(ulong id, struct clk **clkp)
{
	return -ENOSYS;
}

static inline bool clk_dev_binded(struct clk *clk)
{
	return false;
}
#endif /* CONFIG_IS_ENABLED(CLK) */

/**
 * clk_valid() - check if clk is valid
 * @clk:	the clock to check
 *
 * Return: true if valid, or false
 */
static inline bool clk_valid(struct clk *clk)
{
	return clk && !!clk->dev;
}

int soc_clk_dump(void);

#endif

#define clk_prepare_enable(clk) clk_enable(clk)
#define clk_disable_unprepare(clk) clk_disable(clk)
