xref: /openbsd/sys/dev/ofw/ofw_regulator.h (revision 09467b48)
1 /*	$OpenBSD: ofw_regulator.h,v 1.7 2019/02/20 07:36:37 patrick Exp $	*/
2 /*
3  * Copyright (c) 2016 Mark Kettenis
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #ifndef _DEV_OFW_REGULATOR_H_
19 #define _DEV_OFW_REGULATOR_H_
20 
21 struct regulator_device {
22 	int	rd_node;
23 	void	*rd_cookie;
24 	uint32_t (*rd_get_voltage)(void *);
25 	int	(*rd_set_voltage)(void *, uint32_t);
26 	uint32_t (*rd_get_current)(void *);
27 	int	(*rd_set_current)(void *, uint32_t);
28 	int	(*rd_enable)(void *, int);
29 
30 	uint32_t rd_volt_min, rd_volt_max;
31 	uint32_t rd_amp_min, rd_amp_max;
32 	uint32_t rd_ramp_delay;
33 
34 	LIST_ENTRY(regulator_device) rd_list;
35 	uint32_t rd_phandle;
36 };
37 
38 void	regulator_register(struct regulator_device *);
39 
40 int	regulator_enable(uint32_t);
41 int	regulator_disable(uint32_t);
42 uint32_t regulator_get_voltage(uint32_t);
43 int	regulator_set_voltage(uint32_t, uint32_t);
44 uint32_t regulator_get_current(uint32_t);
45 int	regulator_set_current(uint32_t, uint32_t);
46 
47 #endif /* _DEV_OFW_REGULATOR_H_ */
48