Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Copyright (C) 2015 Texas Instruments Incorporated - https://www.ti.com/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Author: Andrew F. Davis <afd@ti.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * This program is free software; you can redistribute it and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * modify it under the terms of the GNU General Public License version 2 as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * published by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * This program is distributed "as is" WITHOUT ANY WARRANTY of any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * kind, whether expressed or implied; without even the implied warranty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * GNU General Public License version 2 for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * Based on the TPS65912 driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/regulator/driver.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/mfd/tps65086.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) enum tps65086_regulators { BUCK1, BUCK2, BUCK3, BUCK4, BUCK5, BUCK6, LDOA1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	LDOA2, LDOA3, SWA1, SWB1, SWB2, VTT };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define TPS65086_REGULATOR(_name, _of, _id, _nv, _vr, _vm, _er, _em, _lr, _dr, _dm)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	[_id] = {							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 		.desc = {						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 			.name			= _name,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 			.of_match		= of_match_ptr(_of),	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 			.regulators_node	= "regulators",		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 			.of_parse_cb		= tps65086_of_parse_cb,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 			.id			= _id,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 			.ops			= &reg_ops,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 			.n_voltages		= _nv,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 			.type			= REGULATOR_VOLTAGE,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 			.owner			= THIS_MODULE,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 			.vsel_reg		= _vr,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 			.vsel_mask		= _vm,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 			.enable_reg		= _er,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 			.enable_mask		= _em,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 			.volt_table		= NULL,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 			.linear_ranges		= _lr,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 			.n_linear_ranges	= ARRAY_SIZE(_lr),	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		},							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		.decay_reg = _dr,					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		.decay_mask = _dm,					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define TPS65086_SWITCH(_name, _of, _id, _er, _em)			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	[_id] = {							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		.desc = {						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 			.name			= _name,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 			.of_match		= of_match_ptr(_of),	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 			.regulators_node	= "regulators",		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 			.of_parse_cb		= tps65086_of_parse_cb,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 			.id			= _id,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 			.ops			= &switch_ops,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 			.type			= REGULATOR_VOLTAGE,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 			.owner			= THIS_MODULE,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 			.enable_reg		= _er,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 			.enable_mask		= _em,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		},							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) struct tps65086_regulator {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	struct regulator_desc desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	unsigned int decay_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	unsigned int decay_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) static const struct linear_range tps65086_10mv_ranges[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	REGULATOR_LINEAR_RANGE(410000, 0x1, 0x7F, 10000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) static const struct linear_range tps65086_buck126_25mv_ranges[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	REGULATOR_LINEAR_RANGE(1000000, 0x1, 0x18, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	REGULATOR_LINEAR_RANGE(1025000, 0x19, 0x7F, 25000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) static const struct linear_range tps65086_buck345_25mv_ranges[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	REGULATOR_LINEAR_RANGE(425000, 0x1, 0x7F, 25000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) static const struct linear_range tps65086_ldoa1_ranges[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	REGULATOR_LINEAR_RANGE(1350000, 0x0, 0x0, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	REGULATOR_LINEAR_RANGE(1500000, 0x1, 0x7, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	REGULATOR_LINEAR_RANGE(2300000, 0x8, 0xB, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	REGULATOR_LINEAR_RANGE(2850000, 0xC, 0xD, 150000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	REGULATOR_LINEAR_RANGE(3300000, 0xE, 0xE, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) static const struct linear_range tps65086_ldoa23_ranges[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	REGULATOR_LINEAR_RANGE(700000, 0x0, 0xD, 50000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	REGULATOR_LINEAR_RANGE(1400000, 0xE, 0xF, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /* Operations permitted on regulators */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static const struct regulator_ops reg_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	.enable			= regulator_enable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	.disable		= regulator_disable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	.is_enabled		= regulator_is_enabled_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	.map_voltage		= regulator_map_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	.list_voltage		= regulator_list_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /* Operations permitted on load switches */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static const struct regulator_ops switch_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	.enable			= regulator_enable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	.disable		= regulator_disable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	.is_enabled		= regulator_is_enabled_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static int tps65086_of_parse_cb(struct device_node *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 				const struct regulator_desc *desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 				struct regulator_config *config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static struct tps65086_regulator regulators[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	TPS65086_REGULATOR("BUCK1", "buck1", BUCK1, 0x80, TPS65086_BUCK1CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			   BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 			   tps65086_10mv_ranges, TPS65086_BUCK1CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 			   BIT(0)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	TPS65086_REGULATOR("BUCK2", "buck2", BUCK2, 0x80, TPS65086_BUCK2CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			   BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			   tps65086_10mv_ranges, TPS65086_BUCK2CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 			   BIT(0)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	TPS65086_REGULATOR("BUCK3", "buck3", BUCK3, 0x80, TPS65086_BUCK3VID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 			   BUCK_VID_MASK, TPS65086_BUCK123CTRL, BIT(2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 			   tps65086_10mv_ranges, TPS65086_BUCK3DECAY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			   BIT(0)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	TPS65086_REGULATOR("BUCK4", "buck4", BUCK4, 0x80, TPS65086_BUCK4VID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 			   BUCK_VID_MASK, TPS65086_BUCK4CTRL, BIT(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 			   tps65086_10mv_ranges, TPS65086_BUCK4VID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 			   BIT(0)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	TPS65086_REGULATOR("BUCK5", "buck5", BUCK5, 0x80, TPS65086_BUCK5VID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			   BUCK_VID_MASK, TPS65086_BUCK5CTRL, BIT(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			   tps65086_10mv_ranges, TPS65086_BUCK5CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 			   BIT(0)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	TPS65086_REGULATOR("BUCK6", "buck6", BUCK6, 0x80, TPS65086_BUCK6VID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 			   BUCK_VID_MASK, TPS65086_BUCK6CTRL, BIT(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 			   tps65086_10mv_ranges, TPS65086_BUCK6CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 			   BIT(0)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	TPS65086_REGULATOR("LDOA1", "ldoa1", LDOA1, 0xF, TPS65086_LDOA1CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 			   VDOA1_VID_MASK, TPS65086_LDOA1CTRL, BIT(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 			   tps65086_ldoa1_ranges, 0, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	TPS65086_REGULATOR("LDOA2", "ldoa2", LDOA2, 0x10, TPS65086_LDOA2VID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 			   VDOA23_VID_MASK, TPS65086_LDOA2CTRL, BIT(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 			   tps65086_ldoa23_ranges, 0, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	TPS65086_REGULATOR("LDOA3", "ldoa3", LDOA3, 0x10, TPS65086_LDOA3VID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 			   VDOA23_VID_MASK, TPS65086_LDOA3CTRL, BIT(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 			   tps65086_ldoa23_ranges, 0, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	TPS65086_SWITCH("SWA1", "swa1", SWA1, TPS65086_SWVTT_EN, BIT(5)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	TPS65086_SWITCH("SWB1", "swb1", SWB1, TPS65086_SWVTT_EN, BIT(6)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	TPS65086_SWITCH("SWB2", "swb2", SWB2, TPS65086_SWVTT_EN, BIT(7)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	TPS65086_SWITCH("VTT", "vtt", VTT, TPS65086_SWVTT_EN, BIT(4)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) static int tps65086_of_parse_cb(struct device_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 				const struct regulator_desc *desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 				struct regulator_config *config)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	/* Check for 25mV step mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	if (of_property_read_bool(node, "ti,regulator-step-size-25mv")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		switch (desc->id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		case BUCK1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		case BUCK2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		case BUCK6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 			regulators[desc->id].desc.linear_ranges =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 				tps65086_buck126_25mv_ranges;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 			regulators[desc->id].desc.n_linear_ranges =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 				ARRAY_SIZE(tps65086_buck126_25mv_ranges);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		case BUCK3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		case BUCK4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		case BUCK5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 			regulators[desc->id].desc.linear_ranges =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 				tps65086_buck345_25mv_ranges;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 			regulators[desc->id].desc.n_linear_ranges =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 				ARRAY_SIZE(tps65086_buck345_25mv_ranges);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 			dev_warn(config->dev, "25mV step mode only valid for BUCK regulators\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	/* Check for decay mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	if (desc->id <= BUCK6 && of_property_read_bool(node, "ti,regulator-decay")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		ret = regmap_write_bits(config->regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 					regulators[desc->id].decay_reg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 					regulators[desc->id].decay_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 					regulators[desc->id].decay_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 			dev_err(config->dev, "Error setting decay\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) static int tps65086_regulator_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	struct tps65086 *tps = dev_get_drvdata(pdev->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	struct regulator_config config = { };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	struct regulator_dev *rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	platform_set_drvdata(pdev, tps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	config.dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	config.dev->of_node = tps->dev->of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	config.driver_data = tps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	config.regmap = tps->regmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	for (i = 0; i < ARRAY_SIZE(regulators); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		rdev = devm_regulator_register(&pdev->dev, &regulators[i].desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 					       &config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		if (IS_ERR(rdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 			dev_err(tps->dev, "failed to register %s regulator\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 				pdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 			return PTR_ERR(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) static const struct platform_device_id tps65086_regulator_id_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	{ "tps65086-regulator", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	{ /* sentinel */ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) MODULE_DEVICE_TABLE(platform, tps65086_regulator_id_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) static struct platform_driver tps65086_regulator_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		.name = "tps65086-regulator",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	.probe = tps65086_regulator_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	.id_table = tps65086_regulator_id_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) module_platform_driver(tps65086_regulator_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) MODULE_DESCRIPTION("TPS65086 Regulator driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) MODULE_LICENSE("GPL v2");