blob: 2d13bbea4f3acb98a228bdcdc8f74aaa268a145b [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Mark Brown3cc72982012-06-19 16:31:53 +01002/*
3 * Platform data for Arizona devices
4 *
5 * Copyright 2012 Wolfson Microelectronics. PLC.
Mark Brown3cc72982012-06-19 16:31:53 +01006 */
7
8#ifndef _ARIZONA_PDATA_H
9#define _ARIZONA_PDATA_H
10
Charles Keepax49010332015-02-25 15:37:13 +000011#include <dt-bindings/mfd/arizona.h>
Richard Fitzgeraldaaa84e62017-04-18 11:43:52 +010012#include <linux/regulator/arizona-ldo1.h>
Richard Fitzgerald22161f32017-04-18 11:43:49 +010013#include <linux/regulator/arizona-micsupp.h>
Charles Keepax49010332015-02-25 15:37:13 +000014
Mark Brown3cc72982012-06-19 16:31:53 +010015#define ARIZONA_GPN_DIR_MASK 0x8000 /* GPN_DIR */
16#define ARIZONA_GPN_DIR_SHIFT 15 /* GPN_DIR */
17#define ARIZONA_GPN_DIR_WIDTH 1 /* GPN_DIR */
Mark Brown3cc72982012-06-19 16:31:53 +010018#define ARIZONA_GPN_PU_MASK 0x4000 /* GPN_PU */
19#define ARIZONA_GPN_PU_SHIFT 14 /* GPN_PU */
20#define ARIZONA_GPN_PU_WIDTH 1 /* GPN_PU */
Mark Brown3cc72982012-06-19 16:31:53 +010021#define ARIZONA_GPN_PD_MASK 0x2000 /* GPN_PD */
22#define ARIZONA_GPN_PD_SHIFT 13 /* GPN_PD */
23#define ARIZONA_GPN_PD_WIDTH 1 /* GPN_PD */
Mark Brown3cc72982012-06-19 16:31:53 +010024#define ARIZONA_GPN_LVL_MASK 0x0800 /* GPN_LVL */
25#define ARIZONA_GPN_LVL_SHIFT 11 /* GPN_LVL */
26#define ARIZONA_GPN_LVL_WIDTH 1 /* GPN_LVL */
Mark Brown3cc72982012-06-19 16:31:53 +010027#define ARIZONA_GPN_POL_MASK 0x0400 /* GPN_POL */
28#define ARIZONA_GPN_POL_SHIFT 10 /* GPN_POL */
29#define ARIZONA_GPN_POL_WIDTH 1 /* GPN_POL */
Mark Brown3cc72982012-06-19 16:31:53 +010030#define ARIZONA_GPN_OP_CFG_MASK 0x0200 /* GPN_OP_CFG */
31#define ARIZONA_GPN_OP_CFG_SHIFT 9 /* GPN_OP_CFG */
32#define ARIZONA_GPN_OP_CFG_WIDTH 1 /* GPN_OP_CFG */
Mark Brown3cc72982012-06-19 16:31:53 +010033#define ARIZONA_GPN_DB_MASK 0x0100 /* GPN_DB */
34#define ARIZONA_GPN_DB_SHIFT 8 /* GPN_DB */
35#define ARIZONA_GPN_DB_WIDTH 1 /* GPN_DB */
36#define ARIZONA_GPN_FN_MASK 0x007F /* GPN_FN - [6:0] */
37#define ARIZONA_GPN_FN_SHIFT 0 /* GPN_FN - [6:0] */
38#define ARIZONA_GPN_FN_WIDTH 7 /* GPN_FN - [6:0] */
39
40#define ARIZONA_MAX_GPIO 5
41
Mark Browne102bef2012-07-10 12:37:58 +010042#define ARIZONA_MAX_INPUT 4
Mark Brown3cc72982012-06-19 16:31:53 +010043
Mark Brown3d91f822013-01-29 00:47:37 +080044#define ARIZONA_MAX_MICBIAS 3
45
Mark Browne102bef2012-07-10 12:37:58 +010046#define ARIZONA_MAX_OUTPUT 6
Mark Brown3cc72982012-06-19 16:31:53 +010047
Mark Brownc94aa302013-01-17 16:35:14 +090048#define ARIZONA_MAX_AIF 3
49
Mark Brown9dd555e2012-11-26 21:17:21 +000050#define ARIZONA_HAP_ACT_ERM 0
51#define ARIZONA_HAP_ACT_LRA 2
52
Mark Brown2a51da02012-07-09 19:33:14 +010053#define ARIZONA_MAX_PDM_SPK 2
Mark Brown3cc72982012-06-19 16:31:53 +010054
55struct regulator_init_data;
Charles Keepaxc1860462018-03-12 15:52:00 +000056struct gpio_desc;
Mark Brown3cc72982012-06-19 16:31:53 +010057
Mark Brown3d91f822013-01-29 00:47:37 +080058struct arizona_micbias {
59 int mV; /** Regulated voltage */
60 unsigned int ext_cap:1; /** External capacitor fitted */
61 unsigned int discharge:1; /** Actively discharge */
Charles Keepaxf773fc62013-05-21 14:56:58 +010062 unsigned int soft_start:1; /** Disable aggressive startup ramp rate */
Mark Brown544c7aa2013-01-29 18:44:41 +080063 unsigned int bypass:1; /** Use bypass mode */
Mark Brown3d91f822013-01-29 00:47:37 +080064};
65
Mark Brown3cc72982012-06-19 16:31:53 +010066struct arizona_micd_config {
67 unsigned int src;
68 unsigned int bias;
69 bool gpio;
70};
71
Mark Brown6fed4d82013-04-01 22:03:06 +010072struct arizona_micd_range {
73 int max; /** Ohms */
74 int key; /** Key to report to input layer */
75};
76
Mark Brown3cc72982012-06-19 16:31:53 +010077struct arizona_pdata {
Charles Keepaxc1860462018-03-12 15:52:00 +000078 struct gpio_desc *reset; /** GPIO controlling /RESET, if any */
Mark Brown3cc72982012-06-19 16:31:53 +010079
80 /** Regulator configuration for MICVDD */
Richard Fitzgerald22161f32017-04-18 11:43:49 +010081 struct arizona_micsupp_pdata micvdd;
Mark Brown3cc72982012-06-19 16:31:53 +010082
83 /** Regulator configuration for LDO1 */
Richard Fitzgeraldaaa84e62017-04-18 11:43:52 +010084 struct arizona_ldo1_pdata ldo1;
Mark Brown3cc72982012-06-19 16:31:53 +010085
86 /** If a direct 32kHz clock is provided on an MCLK specify it here */
87 int clk32k_src;
88
Mark Brownf8a09412013-03-22 12:59:33 +010089 /** Mode for primary IRQ (defaults to active low) */
90 unsigned int irq_flags;
Mark Brown3cc72982012-06-19 16:31:53 +010091
92 /* Base GPIO */
93 int gpio_base;
94
95 /** Pin state for GPIO pins */
Charles Keepax6e00ff02015-03-29 12:45:42 +010096 unsigned int gpio_defaults[ARIZONA_MAX_GPIO];
Mark Brown3cc72982012-06-19 16:31:53 +010097
Mark Brownc94aa302013-01-17 16:35:14 +090098 /**
99 * Maximum number of channels clocks will be generated for,
100 * useful for systems where and I2S bus with multiple data
101 * lines is mastered.
102 */
Charles Keepax00b6e9f2015-06-19 11:24:27 +0100103 unsigned int max_channels_clocked[ARIZONA_MAX_AIF];
Mark Brownc94aa302013-01-17 16:35:14 +0900104
Mark Brown92a49872013-01-11 08:55:39 +0900105 /** GPIO5 is used for jack detection */
106 bool jd_gpio5;
107
Mark Browne56a0a52013-04-01 19:03:52 +0100108 /** Internal pull on GPIO5 is disabled when used for jack detection */
109 bool jd_gpio5_nopull;
110
Richard Fitzgeralda288d642014-05-23 12:54:57 +0100111 /** set to true if jackdet contact opens on insert */
112 bool jd_invert;
113
Mark Browndd235ee2013-01-11 08:55:51 +0900114 /** Use the headphone detect circuit to identify the accessory */
115 bool hpdet_acc_id;
116
Mark Brown9c2ba272013-02-25 23:42:31 +0000117 /** Check for line output with HPDET method */
118 bool hpdet_acc_id_line;
119
Mark Brown1eda6aa2013-01-11 08:55:54 +0900120 /** GPIO used for mic isolation with HPDET */
121 int hpdet_id_gpio;
122
Inha Song9e86b2a2015-05-04 13:42:13 +0900123 /** Channel to use for headphone detection */
124 unsigned int hpdet_channel;
125
Charles Keepaxe76e3972015-09-16 10:42:13 +0100126 /** Use software comparison to determine mic presence */
127 bool micd_software_compare;
128
Mark Browncd59e792013-04-01 19:21:48 +0100129 /** Extra debounce timeout used during initial mic detection (ms) */
Charles Keepax00b6e9f2015-06-19 11:24:27 +0100130 unsigned int micd_detect_debounce;
Mark Browncd59e792013-04-01 19:21:48 +0100131
Mark Brown3cc72982012-06-19 16:31:53 +0100132 /** GPIO for mic detection polarity */
133 int micd_pol_gpio;
134
Mark Brownb17e5462013-01-11 08:55:24 +0900135 /** Mic detect ramp rate */
Charles Keepax00b6e9f2015-06-19 11:24:27 +0100136 unsigned int micd_bias_start_time;
Mark Brownb17e5462013-01-11 08:55:24 +0900137
Mark Brown2e033db2013-01-21 17:36:33 +0900138 /** Mic detect sample rate */
Charles Keepax00b6e9f2015-06-19 11:24:27 +0100139 unsigned int micd_rate;
Mark Brown2e033db2013-01-21 17:36:33 +0900140
141 /** Mic detect debounce level */
Charles Keepax00b6e9f2015-06-19 11:24:27 +0100142 unsigned int micd_dbtime;
Mark Brown2e033db2013-01-21 17:36:33 +0900143
Mark Brown7abd4e22013-04-01 19:25:55 +0100144 /** Mic detect timeout (ms) */
Charles Keepax00b6e9f2015-06-19 11:24:27 +0100145 unsigned int micd_timeout;
Mark Brown7abd4e22013-04-01 19:25:55 +0100146
Mark Brownbbbd46e2013-01-10 19:38:43 +0000147 /** Force MICBIAS on for mic detect */
148 bool micd_force_micbias;
149
Mark Brown6fed4d82013-04-01 22:03:06 +0100150 /** Mic detect level parameters */
151 const struct arizona_micd_range *micd_ranges;
152 int num_micd_ranges;
153
Mark Brown3cc72982012-06-19 16:31:53 +0100154 /** Headset polarity configurations */
155 struct arizona_micd_config *micd_configs;
156 int num_micd_configs;
157
158 /** Reference voltage for DMIC inputs */
159 int dmic_ref[ARIZONA_MAX_INPUT];
160
Mark Brown3d91f822013-01-29 00:47:37 +0800161 /** MICBIAS configurations */
162 struct arizona_micbias micbias[ARIZONA_MAX_MICBIAS];
163
Richard Fitzgeraldfc027d12015-05-01 16:15:12 +0100164 /**
165 * Mode of input structures
166 * One of the ARIZONA_INMODE_xxx values
Richard Fitzgerald6887b042015-07-03 16:16:35 +0100167 * wm5102/wm5110/wm8280/wm8997: [0]=IN1 [1]=IN2 [2]=IN3 [3]=IN4
168 * wm8998: [0]=IN1A [1]=IN2A [2]=IN1B [3]=IN2B
Richard Fitzgeraldfc027d12015-05-01 16:15:12 +0100169 */
Mark Brown3cc72982012-06-19 16:31:53 +0100170 int inmode[ARIZONA_MAX_INPUT];
171
172 /** Mode for outputs */
Charles Keepaxf199d392015-12-14 10:19:11 +0000173 int out_mono[ARIZONA_MAX_OUTPUT];
Mark Brown3cc72982012-06-19 16:31:53 +0100174
Charles Keepax85e7dd32017-09-04 16:41:53 +0100175 /** Limit output volumes */
176 unsigned int out_vol_limit[2 * ARIZONA_MAX_OUTPUT];
177
Mark Brown3cc72982012-06-19 16:31:53 +0100178 /** PDM speaker mute setting */
179 unsigned int spk_mute[ARIZONA_MAX_PDM_SPK];
180
181 /** PDM speaker format */
182 unsigned int spk_fmt[ARIZONA_MAX_PDM_SPK];
Mark Brown9dd555e2012-11-26 21:17:21 +0000183
184 /** Haptic actuator type */
185 unsigned int hap_act;
Mark Brown3092f802013-03-24 23:05:58 +0000186
187 /** GPIO for primary IRQ (used for edge triggered emulation) */
188 int irq_gpio;
Charles Keepax1ce37682015-09-16 10:42:14 +0100189
190 /** General purpose switch control */
191 unsigned int gpsw;
Mark Brown3cc72982012-06-19 16:31:53 +0100192};
193
194#endif