hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/include/linux/regulator/driver.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * driver.h -- SoC Regulator driver support.
34 *
....@@ -5,22 +6,18 @@
56 *
67 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
78 *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License version 2 as
10
- * published by the Free Software Foundation.
11
- *
129 * Regulator Driver Interface.
1310 */
1411
1512 #ifndef __LINUX_REGULATOR_DRIVER_H_
1613 #define __LINUX_REGULATOR_DRIVER_H_
1714
18
-#define MAX_COUPLED 4
19
-
2015 #include <linux/device.h>
16
+#include <linux/linear_range.h>
2117 #include <linux/notifier.h>
2218 #include <linux/regulator/consumer.h>
23
-#include <linux/regulator/proxy-consumer.h>
19
+#include <linux/ww_mutex.h>
20
+#include <linux/android_kabi.h>
2421
2522 struct gpio_desc;
2623 struct regmap;
....@@ -44,31 +41,13 @@
4441 REGULATOR_STATUS_UNDEFINED,
4542 };
4643
47
-/**
48
- * struct regulator_linear_range - specify linear voltage ranges
49
- *
50
- * Specify a range of voltages for regulator_map_linear_range() and
51
- * regulator_list_linear_range().
52
- *
53
- * @min_uV: Lowest voltage in range
54
- * @min_sel: Lowest selector for range
55
- * @max_sel: Highest selector for range
56
- * @uV_step: Step size
57
- */
58
-struct regulator_linear_range {
59
- unsigned int min_uV;
60
- unsigned int min_sel;
61
- unsigned int max_sel;
62
- unsigned int uV_step;
63
-};
64
-
65
-/* Initialize struct regulator_linear_range */
44
+/* Initialize struct linear_range for regulators */
6645 #define REGULATOR_LINEAR_RANGE(_min_uV, _min_sel, _max_sel, _step_uV) \
6746 { \
68
- .min_uV = _min_uV, \
47
+ .min = _min_uV, \
6948 .min_sel = _min_sel, \
7049 .max_sel = _max_sel, \
71
- .uV_step = _step_uV, \
50
+ .step = _step_uV, \
7251 }
7352
7453 /**
....@@ -139,7 +118,7 @@
139118 * suspended.
140119 * @set_suspend_mode: Set the operating mode for the regulator when the
141120 * system is suspended.
142
- *
121
+ * @resume: Resume operation of suspended regulator.
143122 * @set_pull_down: Configure the regulator to pull down when the regulator
144123 * is disabled.
145124 *
....@@ -224,6 +203,8 @@
224203 int (*resume)(struct regulator_dev *rdev);
225204
226205 int (*set_pull_down) (struct regulator_dev *);
206
+
207
+ ANDROID_KABI_RESERVE(1);
227208 };
228209
229210 /*
....@@ -245,6 +226,8 @@
245226 * @name: Identifying name for the regulator.
246227 * @supply_name: Identifying the regulator supply
247228 * @of_match: Name used to identify regulator in DT.
229
+ * @of_match_full_name: A flag to indicate that the of_match string, if
230
+ * present, should be matched against the node full_name.
248231 * @regulators_node: Name of node containing regulator definitions in DT.
249232 * @of_parse_cb: Optional callback called only if of_match is present.
250233 * Will be called for each regulator parsed from DT, during
....@@ -264,6 +247,7 @@
264247 * @continuous_voltage_range: Indicates if the regulator can set any
265248 * voltage within constrains range.
266249 * @n_voltages: Number of selectors available for ops.list_voltage().
250
+ * @n_current_limits: Number of selectors available for current limits
267251 *
268252 * @min_uV: Voltage given by the lowest selector (if linear mapping)
269253 * @uV_step: Voltage increase with each selector (if linear mapping)
....@@ -272,13 +256,26 @@
272256 * @ramp_delay: Time to settle down after voltage change (unit: uV/us)
273257 * @min_dropout_uV: The minimum dropout voltage this regulator can handle
274258 * @linear_ranges: A constant table of possible voltage ranges.
275
- * @n_linear_ranges: Number of entries in the @linear_ranges table.
259
+ * @linear_range_selectors: A constant table of voltage range selectors.
260
+ * If pickable ranges are used each range must
261
+ * have corresponding selector here.
262
+ * @n_linear_ranges: Number of entries in the @linear_ranges (and in
263
+ * linear_range_selectors if used) table(s).
276264 * @volt_table: Voltage mapping table (if table based mapping)
265
+ * @curr_table: Current limit mapping table (if table based mapping)
277266 *
278
- * @vsel_reg: Register for selector when using regulator_regmap_X_voltage_
267
+ * @vsel_range_reg: Register for range selector when using pickable ranges
268
+ * and ``regulator_map_*_voltage_*_pickable`` functions.
269
+ * @vsel_range_mask: Mask for register bitfield used for range selector
270
+ * @vsel_reg: Register for selector when using ``regulator_map_*_voltage_*``
279271 * @vsel_mask: Mask for register bitfield used for selector
280
- * @csel_reg: Register for TPS65218 LS3 current regulator
281
- * @csel_mask: Mask for TPS65218 LS3 current regulator
272
+ * @vsel_step: Specify the resolution of selector stepping when setting
273
+ * voltage. If 0, then no stepping is done (requested selector is
274
+ * set directly), if >0 then the regulator API will ramp the
275
+ * voltage up/down gradually each time increasing/decreasing the
276
+ * selector by the specified step value.
277
+ * @csel_reg: Register for current limit selector using regmap set_current_limit
278
+ * @csel_mask: Mask for register bitfield used for current limit selector
282279 * @apply_reg: Register for initiate voltage change on the output when
283280 * using regulator_set_voltage_sel_regmap
284281 * @apply_bit: Register bitfield used for initiate voltage change on the
....@@ -313,12 +310,16 @@
313310 * @enable_time: Time taken for initial enable of regulator (in uS).
314311 * @off_on_delay: guard time (in uS), before re-enabling a regulator
315312 *
313
+ * @poll_enabled_time: The polling interval (in uS) to use while checking that
314
+ * the regulator was actually enabled. Max upto enable_time.
315
+ *
316316 * @of_map_mode: Maps a hardware mode defined in a DeviceTree to a standard mode
317317 */
318318 struct regulator_desc {
319319 const char *name;
320320 const char *supply_name;
321321 const char *of_match;
322
+ bool of_match_full_name;
322323 const char *regulators_node;
323324 int (*of_parse_cb)(struct device_node *,
324325 const struct regulator_desc *,
....@@ -326,6 +327,7 @@
326327 int id;
327328 unsigned int continuous_voltage_range:1;
328329 unsigned n_voltages;
330
+ unsigned int n_current_limits;
329331 const struct regulator_ops *ops;
330332 int irq;
331333 enum regulator_type type;
....@@ -338,13 +340,19 @@
338340 unsigned int ramp_delay;
339341 int min_dropout_uV;
340342
341
- const struct regulator_linear_range *linear_ranges;
343
+ const struct linear_range *linear_ranges;
344
+ const unsigned int *linear_range_selectors;
345
+
342346 int n_linear_ranges;
343347
344348 const unsigned int *volt_table;
349
+ const unsigned int *curr_table;
345350
351
+ unsigned int vsel_range_reg;
352
+ unsigned int vsel_range_mask;
346353 unsigned int vsel_reg;
347354 unsigned int vsel_mask;
355
+ unsigned int vsel_step;
348356 unsigned int csel_reg;
349357 unsigned int csel_mask;
350358 unsigned int apply_reg;
....@@ -373,7 +381,11 @@
373381
374382 unsigned int off_on_delay;
375383
384
+ unsigned int poll_enabled_time;
385
+
376386 unsigned int (*of_map_mode)(unsigned int mode);
387
+
388
+ ANDROID_KABI_RESERVE(1);
377389 };
378390
379391 /**
....@@ -390,13 +402,7 @@
390402 * NULL).
391403 * @regmap: regmap to use for core regmap helpers if dev_get_regmap() is
392404 * insufficient.
393
- * @ena_gpio_initialized: GPIO controlling regulator enable was properly
394
- * initialized, meaning that >= 0 is a valid gpio
395
- * identifier and < 0 is a non existent gpio.
396
- * @ena_gpio: GPIO controlling regulator enable.
397
- * @ena_gpiod: GPIO descriptor controlling regulator enable.
398
- * @ena_gpio_invert: Sense for GPIO enable control.
399
- * @ena_gpio_flags: Flags to use when calling gpio_request_one()
405
+ * @ena_gpiod: GPIO controlling regulator enable.
400406 */
401407 struct regulator_config {
402408 struct device *dev;
....@@ -405,11 +411,7 @@
405411 struct device_node *of_node;
406412 struct regmap *regmap;
407413
408
- bool ena_gpio_initialized;
409
- int ena_gpio;
410414 struct gpio_desc *ena_gpiod;
411
- unsigned int ena_gpio_invert:1;
412
- unsigned int ena_gpio_flags;
413415 };
414416
415417 /*
....@@ -421,7 +423,8 @@
421423 * incremented.
422424 */
423425 struct coupling_desc {
424
- struct regulator_dev *coupled_rdevs[MAX_COUPLED];
426
+ struct regulator_dev **coupled_rdevs;
427
+ struct regulator_coupler *coupler;
425428 int n_resolved;
426429 int n_coupled;
427430 };
....@@ -452,7 +455,7 @@
452455 struct coupling_desc coupling_desc;
453456
454457 struct blocking_notifier_head notifier;
455
- struct mutex mutex; /* consumer lock */
458
+ struct ww_mutex mutex; /* consumer lock */
456459 struct task_struct *mutex_owner;
457460 int ref_cnt;
458461 struct module *owner;
....@@ -463,7 +466,6 @@
463466 struct regmap *regmap;
464467
465468 struct delayed_work disable_work;
466
- int deferred_disables;
467469
468470 void *reg_data; /* regulator_dev data */
469471
....@@ -476,7 +478,8 @@
476478
477479 /* time when this regulator was disabled last time */
478480 unsigned long last_off_jiffy;
479
- struct proxy_consumer *proxy_consumer;
481
+
482
+ ANDROID_KABI_RESERVE(1);
480483 };
481484
482485 struct regulator_dev *
....@@ -487,7 +490,6 @@
487490 const struct regulator_desc *regulator_desc,
488491 const struct regulator_config *config);
489492 void regulator_unregister(struct regulator_dev *rdev);
490
-void regulator_sync_state(struct device *dev);
491493 void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev);
492494
493495 int regulator_notifier_call_chain(struct regulator_dev *rdev,
....@@ -495,24 +497,32 @@
495497
496498 void *rdev_get_drvdata(struct regulator_dev *rdev);
497499 struct device *rdev_get_dev(struct regulator_dev *rdev);
500
+struct regmap *rdev_get_regmap(struct regulator_dev *rdev);
498501 int rdev_get_id(struct regulator_dev *rdev);
499502
500503 int regulator_mode_to_status(unsigned int);
501504
502505 int regulator_list_voltage_linear(struct regulator_dev *rdev,
503506 unsigned int selector);
507
+int regulator_list_voltage_pickable_linear_range(struct regulator_dev *rdev,
508
+ unsigned int selector);
504509 int regulator_list_voltage_linear_range(struct regulator_dev *rdev,
505510 unsigned int selector);
506511 int regulator_list_voltage_table(struct regulator_dev *rdev,
507512 unsigned int selector);
508513 int regulator_map_voltage_linear(struct regulator_dev *rdev,
509514 int min_uV, int max_uV);
515
+int regulator_map_voltage_pickable_linear_range(struct regulator_dev *rdev,
516
+ int min_uV, int max_uV);
510517 int regulator_map_voltage_linear_range(struct regulator_dev *rdev,
511518 int min_uV, int max_uV);
512519 int regulator_map_voltage_iterate(struct regulator_dev *rdev,
513520 int min_uV, int max_uV);
514521 int regulator_map_voltage_ascend(struct regulator_dev *rdev,
515522 int min_uV, int max_uV);
523
+int regulator_get_voltage_sel_pickable_regmap(struct regulator_dev *rdev);
524
+int regulator_set_voltage_sel_pickable_regmap(struct regulator_dev *rdev,
525
+ unsigned int sel);
516526 int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev);
517527 int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel);
518528 int regulator_is_enabled_regmap(struct regulator_dev *rdev);
....@@ -528,6 +538,16 @@
528538
529539 int regulator_set_active_discharge_regmap(struct regulator_dev *rdev,
530540 bool enable);
541
+int regulator_set_current_limit_regmap(struct regulator_dev *rdev,
542
+ int min_uA, int max_uA);
543
+int regulator_get_current_limit_regmap(struct regulator_dev *rdev);
531544 void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);
532545
546
+/*
547
+ * Helper functions intended to be used by regulator drivers prior registering
548
+ * their regulators.
549
+ */
550
+int regulator_desc_list_voltage_linear_range(const struct regulator_desc *desc,
551
+ unsigned int selector);
552
+
533553 #endif