2019-06-24 11:03:33 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Disruptive Technologies Research AS
|
|
|
|
* Sven Schwermer <sven.svenschwermer@disruptive-technologies.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _REGULATOR_COMMON_H
|
|
|
|
#define _REGULATOR_COMMON_H
|
|
|
|
|
|
|
|
#include <asm/gpio.h>
|
|
|
|
|
2020-12-03 23:55:23 +00:00
|
|
|
struct regulator_common_plat {
|
2019-06-24 11:03:33 +00:00
|
|
|
struct gpio_desc gpio; /* GPIO for regulator enable control */
|
|
|
|
unsigned int startup_delay_us;
|
|
|
|
unsigned int off_on_delay_us;
|
2023-04-19 13:45:24 +00:00
|
|
|
unsigned int enable_count;
|
2019-06-24 11:03:33 +00:00
|
|
|
};
|
|
|
|
|
2020-12-03 23:55:21 +00:00
|
|
|
int regulator_common_of_to_plat(struct udevice *dev,
|
2023-04-19 13:45:25 +00:00
|
|
|
struct regulator_common_plat *plat, const
|
2020-12-03 23:55:23 +00:00
|
|
|
char *enable_gpio_name);
|
2019-06-24 11:03:33 +00:00
|
|
|
int regulator_common_get_enable(const struct udevice *dev,
|
2023-04-19 13:45:25 +00:00
|
|
|
struct regulator_common_plat *plat);
|
2023-04-19 13:45:24 +00:00
|
|
|
/*
|
|
|
|
* Enable or Disable a regulator
|
|
|
|
*
|
|
|
|
* This is a reentrant function and subsequent calls that enable will
|
|
|
|
* increase an internal counter, and disable calls will decrease the counter.
|
|
|
|
* The actual resource will be enabled when the counter gets to 1 coming from 0,
|
|
|
|
* and disabled when it reaches 0 coming from 1.
|
|
|
|
*
|
|
|
|
* @dev: regulator device
|
2023-04-19 13:45:25 +00:00
|
|
|
* @plat: Platform data
|
2023-04-19 13:45:24 +00:00
|
|
|
* @enable: bool indicating whether to enable or disable the regulator
|
|
|
|
* @return:
|
|
|
|
* 0 on Success
|
|
|
|
* -EBUSY if the regulator cannot be disabled because it's requested by
|
|
|
|
* another device
|
|
|
|
* -EALREADY if the regulator has already been enabled or has already been
|
|
|
|
* disabled
|
|
|
|
* -EACCES if there is no possibility to enable/disable the regulator
|
|
|
|
* -ve on different error situation
|
|
|
|
*/
|
2019-06-24 11:03:33 +00:00
|
|
|
int regulator_common_set_enable(const struct udevice *dev,
|
2023-04-19 13:45:25 +00:00
|
|
|
struct regulator_common_plat *plat, bool enable);
|
2019-06-24 11:03:33 +00:00
|
|
|
|
|
|
|
#endif /* _REGULATOR_COMMON_H */
|