1 /* $OpenBSD: ofw_regulator.h,v 1.9 2024/06/14 20:00:32 kettenis 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 uint32_t rd_coupled; 35 uint32_t rd_max_spread; 36 37 LIST_ENTRY(regulator_device) rd_list; 38 uint32_t rd_phandle; 39 }; 40 41 void regulator_register(struct regulator_device *); 42 43 int regulator_enable(uint32_t); 44 int regulator_disable(uint32_t); 45 uint32_t regulator_get_voltage(uint32_t); 46 int regulator_set_voltage(uint32_t, uint32_t); 47 uint32_t regulator_get_current(uint32_t); 48 int regulator_set_current(uint32_t, uint32_t); 49 50 struct regulator_notifier { 51 uint32_t rn_phandle; 52 void *rn_cookie; 53 void (*rn_notify)(void *, uint32_t); 54 55 LIST_ENTRY(regulator_notifier) rn_list; 56 }; 57 58 void regulator_notify(struct regulator_notifier *); 59 60 #endif /* _DEV_OFW_REGULATOR_H_ */ 61