mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 06:59:41 +03:00
Add reset_reset() and reset_reset_bulk() functions to the reset controller API. These functions assert and then deassert reset signals in a single call, providing a convenient way to pulse/toggle a reset line. This mimics the Linux kernel's reset_control_reset() and reset_control_bulk_reset() APIs. The new functions are useful for drivers that need to cycle a reset line during initialization or error recovery but with also passing delay parameter. If a driver implements the rst_reset op, it will be called directly with the delay parameter. Otherwise, the reset core performs reset_assert(), optional udelay(), and reset_deassert() as fallback. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Michal Simek <michal.simek@amd.com> Link: https://lore.kernel.org/r/55ddd313c9e7b2d4dc79ab36bdd0040f871610f6.1779709539.git.michal.simek@amd.com
109 lines
3.4 KiB
C
109 lines
3.4 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Copyright (c) 2016, NVIDIA CORPORATION.
|
|
*/
|
|
|
|
#ifndef _RESET_UCLASS_H
|
|
#define _RESET_UCLASS_H
|
|
|
|
/* See reset.h for background documentation. */
|
|
|
|
#include <reset.h>
|
|
|
|
struct ofnode_phandle_args;
|
|
struct udevice;
|
|
|
|
/**
|
|
* struct reset_ops - The functions that a reset controller driver must
|
|
* implement.
|
|
*/
|
|
struct reset_ops {
|
|
/**
|
|
* of_xlate - Translate a client's device-tree (OF) reset specifier.
|
|
*
|
|
* The reset core calls this function as the first step in implementing
|
|
* a client's reset_get_by_*() call.
|
|
*
|
|
* If this function pointer is set to NULL, the reset core will use a
|
|
* default implementation, which assumes #reset-cells = <1>, and that
|
|
* the DT cell contains a simple integer reset signal ID.
|
|
*
|
|
* At present, the reset API solely supports device-tree. If this
|
|
* changes, other xxx_xlate() functions may be added to support those
|
|
* other mechanisms.
|
|
*
|
|
* @reset_ctl: The reset control struct to hold the translation result.
|
|
* @args: The reset specifier values from device tree.
|
|
* @return 0 if OK, or a negative error code.
|
|
*/
|
|
int (*of_xlate)(struct reset_ctl *reset_ctl,
|
|
struct ofnode_phandle_args *args);
|
|
/**
|
|
* request - Request a translated reset control.
|
|
*
|
|
* The reset core calls this function as the second step in
|
|
* implementing a client's reset_get_by_*() call, following a
|
|
* successful xxx_xlate() call.
|
|
*
|
|
* @reset_ctl: The reset control struct to request; this has been
|
|
* filled in by a previoux xxx_xlate() function call.
|
|
* @return 0 if OK, or a negative error code.
|
|
*/
|
|
int (*request)(struct reset_ctl *reset_ctl);
|
|
/**
|
|
* rfree - Free a previously requested reset control.
|
|
*
|
|
* This is the implementation of the client reset_free() API.
|
|
*
|
|
* @reset_ctl: The reset control to free.
|
|
* @return 0 if OK, or a negative error code.
|
|
*/
|
|
int (*rfree)(struct reset_ctl *reset_ctl);
|
|
/**
|
|
* rst_assert - Assert a reset signal.
|
|
*
|
|
* Note: This function is named rst_assert not assert to avoid
|
|
* conflicting with global macro assert().
|
|
*
|
|
* @reset_ctl: The reset signal to assert.
|
|
* @return 0 if OK, or a negative error code.
|
|
*/
|
|
int (*rst_assert)(struct reset_ctl *reset_ctl);
|
|
/**
|
|
* rst_deassert - Deassert a reset signal.
|
|
*
|
|
* @reset_ctl: The reset signal to deassert.
|
|
* @return 0 if OK, or a negative error code.
|
|
*/
|
|
int (*rst_deassert)(struct reset_ctl *reset_ctl);
|
|
/**
|
|
* rst_reset - Reset a HW module.
|
|
*
|
|
* This optional function triggers a reset pulse on the reset line.
|
|
* If not implemented, reset_reset() falls back to rst_assert(),
|
|
* udelay(@delay_us), then rst_deassert(); that delay is therefore
|
|
* observed only on the fallback path.
|
|
*
|
|
* When rst_reset is provided, @delay_us is controller-specific: the
|
|
* implementation should honour it if the hardware needs a minimum
|
|
* assertion time before release. It may ignore @delay_us when the
|
|
* pulse shape is fixed elsewhere (for example a firmware pulse).
|
|
*
|
|
* @reset_ctl: The reset signal to pulse.
|
|
* @delay_us: Minimum delay in microseconds between assert and
|
|
* deassert where applicable; see above.
|
|
* @return 0 if OK, or a negative error code.
|
|
*/
|
|
int (*rst_reset)(struct reset_ctl *reset_ctl, ulong delay_us);
|
|
/**
|
|
* rst_status - Check reset signal status.
|
|
*
|
|
* @reset_ctl: The reset signal to check.
|
|
* @return 0 if deasserted, positive if asserted, or a negative
|
|
* error code.
|
|
*/
|
|
int (*rst_status)(struct reset_ctl *reset_ctl);
|
|
};
|
|
|
|
#endif
|