Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Heiko Stübner | 3f0292a | 2011-10-05 12:27:05 +0200 | [diff] [blame] | 2 | /* |
| 3 | * gpio-regulator.h |
| 4 | * |
| 5 | * Copyright 2011 Heiko Stuebner <heiko@sntech.de> |
| 6 | * |
| 7 | * based on fixed.h |
| 8 | * |
| 9 | * Copyright 2008 Wolfson Microelectronics PLC. |
| 10 | * |
| 11 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> |
| 12 | * |
| 13 | * Copyright (c) 2009 Nokia Corporation |
| 14 | * Roger Quadros <ext-roger.quadros@nokia.com> |
Heiko Stübner | 3f0292a | 2011-10-05 12:27:05 +0200 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #ifndef __REGULATOR_GPIO_H |
| 18 | #define __REGULATOR_GPIO_H |
| 19 | |
Linus Walleij | d6cd33a | 2019-01-29 11:31:52 +0100 | [diff] [blame] | 20 | #include <linux/gpio/consumer.h> |
| 21 | |
Heiko Stübner | 3f0292a | 2011-10-05 12:27:05 +0200 | [diff] [blame] | 22 | struct regulator_init_data; |
| 23 | |
| 24 | enum regulator_type; |
| 25 | |
| 26 | /** |
| 27 | * struct gpio_regulator_state - state description |
| 28 | * @value: microvolts or microamps |
| 29 | * @gpios: bitfield of gpio target-states for the value |
| 30 | * |
| 31 | * This structure describes a supported setting of the regulator |
| 32 | * and the necessary gpio-state to achieve it. |
| 33 | * |
| 34 | * The n-th bit in the bitfield describes the state of the n-th GPIO |
| 35 | * from the gpios-array defined in gpio_regulator_config below. |
| 36 | */ |
| 37 | struct gpio_regulator_state { |
| 38 | int value; |
| 39 | int gpios; |
| 40 | }; |
| 41 | |
| 42 | /** |
| 43 | * struct gpio_regulator_config - config structure |
| 44 | * @supply_name: Name of the regulator supply |
Heiko Stübner | 3f0292a | 2011-10-05 12:27:05 +0200 | [diff] [blame] | 45 | * @enabled_at_boot: Whether regulator has been enabled at |
| 46 | * boot or not. 1 = Yes, 0 = No |
| 47 | * This is used to keep the regulator at |
| 48 | * the default state |
| 49 | * @startup_delay: Start-up time in microseconds |
Linus Walleij | d6cd33a | 2019-01-29 11:31:52 +0100 | [diff] [blame] | 50 | * @gflags: Array of GPIO configuration flags for initial |
| 51 | * states |
| 52 | * @ngpios: Number of GPIOs and configurations available |
Heiko Stübner | 3f0292a | 2011-10-05 12:27:05 +0200 | [diff] [blame] | 53 | * @states: Array of gpio_regulator_state entries describing |
| 54 | * the gpio state for specific voltages |
| 55 | * @nr_states: Number of states available |
| 56 | * @regulator_type: either REGULATOR_CURRENT or REGULATOR_VOLTAGE |
| 57 | * @init_data: regulator_init_data |
| 58 | * |
| 59 | * This structure contains gpio-voltage regulator configuration |
| 60 | * information that must be passed by platform code to the |
| 61 | * gpio-voltage regulator driver. |
| 62 | */ |
| 63 | struct gpio_regulator_config { |
| 64 | const char *supply_name; |
| 65 | |
Heiko Stübner | 3f0292a | 2011-10-05 12:27:05 +0200 | [diff] [blame] | 66 | unsigned enabled_at_boot:1; |
| 67 | unsigned startup_delay; |
| 68 | |
Linus Walleij | d6cd33a | 2019-01-29 11:31:52 +0100 | [diff] [blame] | 69 | enum gpiod_flags *gflags; |
| 70 | int ngpios; |
Heiko Stübner | 3f0292a | 2011-10-05 12:27:05 +0200 | [diff] [blame] | 71 | |
| 72 | struct gpio_regulator_state *states; |
| 73 | int nr_states; |
| 74 | |
| 75 | enum regulator_type type; |
| 76 | struct regulator_init_data *init_data; |
| 77 | }; |
| 78 | |
| 79 | #endif |