xref: /openbmc/linux/drivers/reset/sti/reset-syscfg.h (revision 22d55f02)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (C) 2013 STMicroelectronics (R&D) Limited
4  * Author: Stephen Gallimore <stephen.gallimore@st.com>
5  */
6 #ifndef __STI_RESET_SYSCFG_H
7 #define __STI_RESET_SYSCFG_H
8 
9 #include <linux/device.h>
10 #include <linux/regmap.h>
11 #include <linux/reset-controller.h>
12 
13 /**
14  * Reset channel description for a system configuration register based
15  * reset controller.
16  *
17  * @compatible: Compatible string of the syscon regmap containing this
18  *              channel's control and ack (status) bits.
19  * @reset: Regmap field description of the channel's reset bit.
20  * @ack: Regmap field description of the channel's acknowledge bit.
21  */
22 struct syscfg_reset_channel_data {
23 	const char *compatible;
24 	struct reg_field reset;
25 	struct reg_field ack;
26 };
27 
28 #define _SYSCFG_RST_CH(_c, _rr, _rb, _ar, _ab)		\
29 	{ .compatible	= _c,				\
30 	  .reset	= REG_FIELD(_rr, _rb, _rb),	\
31 	  .ack		= REG_FIELD(_ar, _ab, _ab), }
32 
33 #define _SYSCFG_RST_CH_NO_ACK(_c, _rr, _rb)		\
34 	{ .compatible	= _c,			\
35 	  .reset	= REG_FIELD(_rr, _rb, _rb), }
36 
37 /**
38  * Description of a system configuration register based reset controller.
39  *
40  * @wait_for_ack: The controller will wait for reset assert and de-assert to
41  *                be "ack'd" in a channel's ack field.
42  * @active_low: Are the resets in this controller active low, i.e. clearing
43  *              the reset bit puts the hardware into reset.
44  * @nr_channels: The number of reset channels in this controller.
45  * @channels: An array of reset channel descriptions.
46  */
47 struct syscfg_reset_controller_data {
48 	bool wait_for_ack;
49 	bool active_low;
50 	int nr_channels;
51 	const struct syscfg_reset_channel_data *channels;
52 };
53 
54 /**
55  * syscfg_reset_probe(): platform device probe function used by syscfg
56  *                       reset controller drivers. This registers a reset
57  *                       controller configured by the OF match data for
58  *                       the compatible device which should be of type
59  *                       "struct syscfg_reset_controller_data".
60  *
61  * @pdev: platform device
62  */
63 int syscfg_reset_probe(struct platform_device *pdev);
64 
65 #endif /* __STI_RESET_SYSCFG_H */
66