Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Stephen Warren | 185ad87 | 2016-06-17 09:43:58 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2016, NVIDIA CORPORATION. |
Stephen Warren | 185ad87 | 2016-06-17 09:43:58 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef _RESET_UCLASS_H |
| 7 | #define _RESET_UCLASS_H |
| 8 | |
| 9 | /* See reset.h for background documentation. */ |
| 10 | |
| 11 | #include <reset.h> |
| 12 | |
Simon Glass | aec8cc0 | 2017-05-18 20:09:50 -0600 | [diff] [blame] | 13 | struct ofnode_phandle_args; |
Stephen Warren | 185ad87 | 2016-06-17 09:43:58 -0600 | [diff] [blame] | 14 | struct udevice; |
| 15 | |
| 16 | /** |
| 17 | * struct reset_ops - The functions that a reset controller driver must |
| 18 | * implement. |
| 19 | */ |
| 20 | struct reset_ops { |
| 21 | /** |
| 22 | * of_xlate - Translate a client's device-tree (OF) reset specifier. |
| 23 | * |
| 24 | * The reset core calls this function as the first step in implementing |
| 25 | * a client's reset_get_by_*() call. |
| 26 | * |
| 27 | * If this function pointer is set to NULL, the reset core will use a |
| 28 | * default implementation, which assumes #reset-cells = <1>, and that |
| 29 | * the DT cell contains a simple integer reset signal ID. |
| 30 | * |
| 31 | * At present, the reset API solely supports device-tree. If this |
| 32 | * changes, other xxx_xlate() functions may be added to support those |
| 33 | * other mechanisms. |
| 34 | * |
| 35 | * @reset_ctl: The reset control struct to hold the translation result. |
| 36 | * @args: The reset specifier values from device tree. |
| 37 | * @return 0 if OK, or a negative error code. |
| 38 | */ |
| 39 | int (*of_xlate)(struct reset_ctl *reset_ctl, |
Simon Glass | aec8cc0 | 2017-05-18 20:09:50 -0600 | [diff] [blame] | 40 | struct ofnode_phandle_args *args); |
Stephen Warren | 185ad87 | 2016-06-17 09:43:58 -0600 | [diff] [blame] | 41 | /** |
| 42 | * request - Request a translated reset control. |
| 43 | * |
| 44 | * The reset core calls this function as the second step in |
| 45 | * implementing a client's reset_get_by_*() call, following a |
| 46 | * successful xxx_xlate() call. |
| 47 | * |
| 48 | * @reset_ctl: The reset control struct to request; this has been |
| 49 | * filled in by a previoux xxx_xlate() function call. |
| 50 | * @return 0 if OK, or a negative error code. |
| 51 | */ |
| 52 | int (*request)(struct reset_ctl *reset_ctl); |
| 53 | /** |
| 54 | * free - Free a previously requested reset control. |
| 55 | * |
| 56 | * This is the implementation of the client reset_free() API. |
| 57 | * |
| 58 | * @reset_ctl: The reset control to free. |
| 59 | * @return 0 if OK, or a negative error code. |
| 60 | */ |
| 61 | int (*free)(struct reset_ctl *reset_ctl); |
| 62 | /** |
| 63 | * rst_assert - Assert a reset signal. |
| 64 | * |
| 65 | * Note: This function is named rst_assert not assert to avoid |
| 66 | * conflicting with global macro assert(). |
| 67 | * |
| 68 | * @reset_ctl: The reset signal to assert. |
| 69 | * @return 0 if OK, or a negative error code. |
| 70 | */ |
| 71 | int (*rst_assert)(struct reset_ctl *reset_ctl); |
| 72 | /** |
| 73 | * rst_deassert - Deassert a reset signal. |
| 74 | * |
| 75 | * @reset_ctl: The reset signal to deassert. |
| 76 | * @return 0 if OK, or a negative error code. |
| 77 | */ |
| 78 | int (*rst_deassert)(struct reset_ctl *reset_ctl); |
| 79 | }; |
| 80 | |
| 81 | #endif |