Linux-libre 5.3.12-gnu
[librecmc/linux-libre.git] / include / linux / mfd / wm831x / pdata.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * include/linux/mfd/wm831x/pdata.h -- Platform data for WM831x
4  *
5  * Copyright 2009 Wolfson Microelectronics PLC.
6  *
7  * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
8  */
9
10 #ifndef __MFD_WM831X_PDATA_H__
11 #define __MFD_WM831X_PDATA_H__
12
13 struct wm831x;
14 struct regulator_init_data;
15
16 struct wm831x_backlight_pdata {
17         int isink;     /** ISINK to use, 1 or 2 */
18         int max_uA;    /** Maximum current to allow */
19 };
20
21 struct wm831x_backup_pdata {
22         int charger_enable;
23         int no_constant_voltage;  /** Disable constant voltage charging */
24         int vlim;   /** Voltage limit in millivolts */
25         int ilim;   /** Current limit in microamps */
26 };
27
28 struct wm831x_battery_pdata {
29         int enable;         /** Enable charging */
30         int fast_enable;    /** Enable fast charging */
31         int off_mask;       /** Mask OFF while charging */
32         int trickle_ilim;   /** Trickle charge current limit, in mA */
33         int vsel;           /** Target voltage, in mV */
34         int eoc_iterm;      /** End of trickle charge current, in mA */
35         int fast_ilim;      /** Fast charge current limit, in mA */
36         int timeout;        /** Charge cycle timeout, in minutes */
37 };
38
39 /**
40  * Configuration for the WM831x DC-DC BuckWise convertors.  This
41  * should be passed as driver_data in the regulator_init_data.
42  *
43  * Currently all the configuration is for the fast DVS switching
44  * support of the devices.  This allows MFPs on the device to be
45  * configured as an input to switch between two output voltages,
46  * allowing voltage transitions without the expense of an access over
47  * I2C or SPI buses.
48  */
49 struct wm831x_buckv_pdata {
50         int dvs_control_src; /** Hardware DVS source to use (1 or 2) */
51         int dvs_init_state;  /** DVS state to expect on startup */
52         int dvs_state_gpio;  /** CPU GPIO to use for monitoring status */
53 };
54
55 /* Sources for status LED configuration.  Values are register values
56  * plus 1 to allow for a zero default for preserve.
57  */
58 enum wm831x_status_src {
59         WM831X_STATUS_PRESERVE = 0,  /* Keep the current hardware setting */
60         WM831X_STATUS_OTP = 1,
61         WM831X_STATUS_POWER = 2,
62         WM831X_STATUS_CHARGER = 3,
63         WM831X_STATUS_MANUAL = 4,
64 };
65
66 struct wm831x_status_pdata {
67         enum wm831x_status_src default_src;
68         const char *name;
69         const char *default_trigger;
70 };
71
72 struct wm831x_touch_pdata {
73         int fivewire;          /** 1 for five wire mode, 0 for 4 wire */
74         int isel;              /** Current for pen down (uA) */
75         int rpu;               /** Pen down sensitivity resistor divider */
76         int pressure;          /** Report pressure (boolean) */
77         unsigned int data_irq; /** Touch data ready IRQ */
78         int data_irqf;         /** IRQ flags for data ready IRQ */
79         unsigned int pd_irq;   /** Touch pendown detect IRQ */
80         int pd_irqf;           /** IRQ flags for pen down IRQ */
81 };
82
83 enum wm831x_watchdog_action {
84         WM831X_WDOG_NONE = 0,
85         WM831X_WDOG_INTERRUPT = 1,
86         WM831X_WDOG_RESET = 2,
87         WM831X_WDOG_WAKE = 3,
88 };
89
90 struct wm831x_watchdog_pdata {
91         enum wm831x_watchdog_action primary, secondary;
92         int update_gpio;
93         unsigned int software:1;
94 };
95
96 #define WM831X_MAX_STATUS 2
97 #define WM831X_MAX_DCDC   4
98 #define WM831X_MAX_EPE    2
99 #define WM831X_MAX_LDO    11
100 #define WM831X_MAX_ISINK  2
101
102 #define WM831X_GPIO_CONFIGURE 0x10000
103 #define WM831X_GPIO_NUM 16
104
105 struct wm831x_pdata {
106         /** Used to distinguish multiple WM831x chips */
107         int wm831x_num;
108
109         /** Called before subdevices are set up */
110         int (*pre_init)(struct wm831x *wm831x);
111         /** Called after subdevices are set up */
112         int (*post_init)(struct wm831x *wm831x);
113
114         /** Put the /IRQ line into CMOS mode */
115         bool irq_cmos;
116
117         /** Disable the touchscreen */
118         bool disable_touch;
119
120         /** The driver should initiate a power off sequence during shutdown */
121         bool soft_shutdown;
122
123         int irq_base;
124         int gpio_base;
125         int gpio_defaults[WM831X_GPIO_NUM];
126         struct wm831x_backlight_pdata *backlight;
127         struct wm831x_backup_pdata *backup;
128         struct wm831x_battery_pdata *battery;
129         struct wm831x_touch_pdata *touch;
130         struct wm831x_watchdog_pdata *watchdog;
131
132         /** LED1 = 0 and so on */
133         struct wm831x_status_pdata *status[WM831X_MAX_STATUS];
134         /** DCDC1 = 0 and so on */
135         struct regulator_init_data *dcdc[WM831X_MAX_DCDC];
136         /** EPE1 = 0 and so on */
137         struct regulator_init_data *epe[WM831X_MAX_EPE];
138         /** LDO1 = 0 and so on */
139         struct regulator_init_data *ldo[WM831X_MAX_LDO];
140         /** ISINK1 = 0 and so on*/
141         struct regulator_init_data *isink[WM831X_MAX_ISINK];
142 };
143
144 #endif