aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/mc34708.h
blob: 17447dc965ef723e2edab57ae3b190d6ec54037b (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
 * mc34708.h - regulators for the Freescale mc34708 PMIC
 * Copyright (C) 2004-2011 Freescale Semiconductor, Inc.
 *  based on:
 *  Copyright (C) 2010 Yong Shen <yong.shen@linaro.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#ifndef __LINUX_REGULATOR_MC34708_H
#define __LINUX_REGULATOR_MC34708_H

#include <linux/regulator/driver.h>

struct mc34708_regulator {
	struct regulator_desc desc;
	int reg;
	int enable_bit;
	int vsel_reg;
	int vsel_shift;
	int vsel_mask;
	int hi_bit;
	int const *voltages;
};

struct mc34708_regulator_priv {
	struct mc_pmic *mc34708;
	struct mc34708_regulator *mc34708_regulators;
	struct regulator_dev *regulators[];
};

int mc34708_sw_regulator(struct regulator_dev *rdev);
int mc34708_sw_regulator_is_enabled(struct regulator_dev *rdev);
int mc34708_get_best_voltage_index(struct regulator_dev *rdev,
				   int min_uV, int max_uV);
int mc34708_regulator_list_voltage(struct regulator_dev *rdev,
				   unsigned selector);
int mc34708_fixed_regulator_set_voltage(struct regulator_dev *rdev,
					int min_uV, int max_uV,
					unsigned *selector);
int mc34708_fixed_regulator_get_voltage(struct regulator_dev *rdev);

#define MC34708_DEFINE(prefix, _name, _reg, _vsel_reg, _voltages, _ops)	\
	[prefix ## _name] = {				\
		.desc = {						\
			.name = #prefix "_" #_name,			\
			.n_voltages = ARRAY_SIZE(_voltages),		\
			.ops = &_ops,			\
			.type = REGULATOR_VOLTAGE,			\
			.id = prefix ## _name,		\
			.owner = THIS_MODULE,				\
		},							\
		.reg = prefix ## _reg,				\
		.enable_bit = prefix ## _reg ## _ ## _name ## EN,	\
		.vsel_reg = prefix ## _vsel_reg,			\
		.vsel_shift = prefix ## _vsel_reg ## _ ## _name ## VSEL,\
		.vsel_mask = prefix ## _vsel_reg ## _ ## _name ## VSEL_M,\
		.voltages =  _voltages,					\
	}

#define MC34708_FIXED_DEFINE(prefix, _name, _reg, _voltages, _ops)	\
	[prefix ## _name] = {				\
		.desc = {						\
			.name = #prefix "_" #_name,			\
			.n_voltages = ARRAY_SIZE(_voltages),		\
			.ops = &_ops,		\
			.type = REGULATOR_VOLTAGE,			\
			.id = prefix ## _name,		\
			.owner = THIS_MODULE,				\
		},							\
		.reg = prefix ## _reg,				\
		.enable_bit = prefix ## _reg ## _ ## _name ## EN,	\
		.voltages =  _voltages,					\
	}

#endif