Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2011 ST-Ericsson SA
0004  * Written on behalf of Linaro for ST-Ericsson
0005  *
0006  * Author: Linus Walleij <linus.walleij@linaro.org>
0007  */
0008 #ifndef MFD_TPS6105X_H
0009 #define MFD_TPS6105X_H
0010 
0011 #include <linux/i2c.h>
0012 #include <linux/regmap.h>
0013 #include <linux/regulator/machine.h>
0014 
0015 /*
0016  * Register definitions to all subdrivers
0017  */
0018 #define TPS6105X_REG_0          0x00
0019 #define TPS6105X_REG0_MODE_SHIFT    6
0020 #define TPS6105X_REG0_MODE_MASK     (0x03<<6)
0021 /* These defines for both reg0 and reg1 */
0022 #define TPS6105X_REG0_MODE_SHUTDOWN 0x00
0023 #define TPS6105X_REG0_MODE_TORCH    0x01
0024 #define TPS6105X_REG0_MODE_TORCH_FLASH  0x02
0025 #define TPS6105X_REG0_MODE_VOLTAGE  0x03
0026 #define TPS6105X_REG0_VOLTAGE_SHIFT 4
0027 #define TPS6105X_REG0_VOLTAGE_MASK  (3<<4)
0028 #define TPS6105X_REG0_VOLTAGE_450   0
0029 #define TPS6105X_REG0_VOLTAGE_500   1
0030 #define TPS6105X_REG0_VOLTAGE_525   2
0031 #define TPS6105X_REG0_VOLTAGE_500_2 3
0032 #define TPS6105X_REG0_DIMMING_SHIFT 3
0033 #define TPS6105X_REG0_TORCHC_SHIFT  0
0034 #define TPS6105X_REG0_TORCHC_MASK   (7<<0)
0035 #define TPS6105X_REG0_TORCHC_0      0x00
0036 #define TPS6105X_REG0_TORCHC_50     0x01
0037 #define TPS6105X_REG0_TORCHC_75     0x02
0038 #define TPS6105X_REG0_TORCHC_100    0x03
0039 #define TPS6105X_REG0_TORCHC_150    0x04
0040 #define TPS6105X_REG0_TORCHC_200    0x05
0041 #define TPS6105X_REG0_TORCHC_250_400    0x06
0042 #define TPS6105X_REG0_TORCHC_250_500    0x07
0043 #define TPS6105X_REG_1          0x01
0044 #define TPS6105X_REG1_MODE_SHIFT    6
0045 #define TPS6105X_REG1_MODE_MASK     (0x03<<6)
0046 #define TPS6105X_REG1_MODE_SHUTDOWN 0x00
0047 #define TPS6105X_REG1_MODE_TORCH    0x01
0048 #define TPS6105X_REG1_MODE_TORCH_FLASH  0x02
0049 #define TPS6105X_REG1_MODE_VOLTAGE  0x03
0050 #define TPS6105X_REG_2          0x02
0051 #define TPS6105X_REG_3          0x03
0052 
0053 /**
0054  * enum tps6105x_mode - desired mode for the TPS6105x
0055  * @TPS6105X_MODE_SHUTDOWN: this instance is inactive, not used for anything
0056  * @TPS61905X_MODE_TORCH: this instance is used as a LED, usually a while
0057  *  LED, for example as backlight or flashlight. If this is set, the
0058  *  TPS6105X will register to the LED framework
0059  * @TPS6105X_MODE_TORCH_FLASH: this instance is used as a flashgun, usually
0060  *  in a camera
0061  * @TPS6105X_MODE_VOLTAGE: this instance is used as a voltage regulator and
0062  *  will register to the regulator framework
0063  */
0064 enum tps6105x_mode {
0065     TPS6105X_MODE_SHUTDOWN,
0066     TPS6105X_MODE_TORCH,
0067     TPS6105X_MODE_TORCH_FLASH,
0068     TPS6105X_MODE_VOLTAGE,
0069 };
0070 
0071 /**
0072  * struct tps6105x_platform_data - TPS61905x platform data
0073  * @mode: what mode this instance shall be operated in,
0074  *  this is not selectable at runtime
0075  * @regulator_data: initialization data for the voltage
0076  *  regulator if used as a voltage source
0077  */
0078 struct tps6105x_platform_data {
0079     enum tps6105x_mode mode;
0080     struct regulator_init_data *regulator_data;
0081 };
0082 
0083 /**
0084  * struct tps6105x - state holder for the TPS6105x drivers
0085  * @i2c_client: corresponding I2C client
0086  * @regulator: regulator device if used in voltage mode
0087  * @regmap: used for i2c communcation on accessing registers
0088  */
0089 struct tps6105x {
0090     struct tps6105x_platform_data *pdata;
0091     struct i2c_client   *client;
0092     struct regulator_dev    *regulator;
0093     struct regmap       *regmap;
0094 };
0095 
0096 #endif