summaryrefslogtreecommitdiff
path: root/include/regulator.h
blob: 9dae7233c15fea6b52ed0a4647a10b51a01d28ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef __CROS_EC_REGULATOR_H
#define __CROS_EC_REGULATOR_H

#include "common.h"

/*
 * Board dependent hooks on voltage regulators.
 *
 * These functions should be implemented by boards which
 * CONFIG_HOSTCMD_REGULATOR is defined.
 */

/*
 * Get basic info of voltage regulator for given index.
 *
 * Note that the maximum length of name is EC_REGULATOR_NAME_MAX_LEN, and the
 * maximum length of the voltages_mv list is EC_REGULATOR_VOLTAGE_MAX_COUNT.
 */
int board_regulator_get_info(uint32_t index, char *name,
			     uint16_t *voltage_count, uint16_t *voltages_mv);

/*
 * Configure the regulator as enabled / disabled.
 */
int board_regulator_enable(uint32_t index, uint8_t enable);

/*
 * Query if the regulator is enabled.
 */
int board_regulator_is_enabled(uint32_t index, uint8_t *enabled);

/*
 * Set voltage for the voltage regulator within the range specified.
 *
 * The driver should select the voltage in range closest to min_mv.
 *
 * Also note that this might be called before the regulator is enabled, and the
 * setting should be in effect after the regulator is enabled.
 */
int board_regulator_set_voltage(uint32_t index, uint32_t min_mv,
				uint32_t max_mv);

/*
 * Get the currently configured voltage for the voltage regulator.
 *
 * Note that this might be called before the regulator is enabled.
 */
int board_regulator_get_voltage(uint32_t index, uint32_t *voltage_mv);

#endif /* !defined(__CROS_EC_REGULATOR_H) */