blob: 0013075d4cda0615c9f0a254c786d35ebb0eec79 [file] [log] [blame]
Mark Brown3cc72982012-06-19 16:31:53 +01001/*
2 * Platform data for Arizona devices
3 *
4 * Copyright 2012 Wolfson Microelectronics. PLC.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef _ARIZONA_PDATA_H
12#define _ARIZONA_PDATA_H
13
Charles Keepax49010332015-02-25 15:37:13 +000014#include <dt-bindings/mfd/arizona.h>
Richard Fitzgeraldaaa84e62017-04-18 11:43:52 +010015#include <linux/regulator/arizona-ldo1.h>
Richard Fitzgerald22161f32017-04-18 11:43:49 +010016#include <linux/regulator/arizona-micsupp.h>
Charles Keepax49010332015-02-25 15:37:13 +000017
Mark Brown3cc72982012-06-19 16:31:53 +010018#define ARIZONA_GPN_DIR_MASK 0x8000 /* GPN_DIR */
19#define ARIZONA_GPN_DIR_SHIFT 15 /* GPN_DIR */
20#define ARIZONA_GPN_DIR_WIDTH 1 /* GPN_DIR */
Mark Brown3cc72982012-06-19 16:31:53 +010021#define ARIZONA_GPN_PU_MASK 0x4000 /* GPN_PU */
22#define ARIZONA_GPN_PU_SHIFT 14 /* GPN_PU */
23#define ARIZONA_GPN_PU_WIDTH 1 /* GPN_PU */
Mark Brown3cc72982012-06-19 16:31:53 +010024#define ARIZONA_GPN_PD_MASK 0x2000 /* GPN_PD */
25#define ARIZONA_GPN_PD_SHIFT 13 /* GPN_PD */
26#define ARIZONA_GPN_PD_WIDTH 1 /* GPN_PD */
Mark Brown3cc72982012-06-19 16:31:53 +010027#define ARIZONA_GPN_LVL_MASK 0x0800 /* GPN_LVL */
28#define ARIZONA_GPN_LVL_SHIFT 11 /* GPN_LVL */
29#define ARIZONA_GPN_LVL_WIDTH 1 /* GPN_LVL */
Mark Brown3cc72982012-06-19 16:31:53 +010030#define ARIZONA_GPN_POL_MASK 0x0400 /* GPN_POL */
31#define ARIZONA_GPN_POL_SHIFT 10 /* GPN_POL */
32#define ARIZONA_GPN_POL_WIDTH 1 /* GPN_POL */
Mark Brown3cc72982012-06-19 16:31:53 +010033#define ARIZONA_GPN_OP_CFG_MASK 0x0200 /* GPN_OP_CFG */
34#define ARIZONA_GPN_OP_CFG_SHIFT 9 /* GPN_OP_CFG */
35#define ARIZONA_GPN_OP_CFG_WIDTH 1 /* GPN_OP_CFG */
Mark Brown3cc72982012-06-19 16:31:53 +010036#define ARIZONA_GPN_DB_MASK 0x0100 /* GPN_DB */
37#define ARIZONA_GPN_DB_SHIFT 8 /* GPN_DB */
38#define ARIZONA_GPN_DB_WIDTH 1 /* GPN_DB */
39#define ARIZONA_GPN_FN_MASK 0x007F /* GPN_FN - [6:0] */
40#define ARIZONA_GPN_FN_SHIFT 0 /* GPN_FN - [6:0] */
41#define ARIZONA_GPN_FN_WIDTH 7 /* GPN_FN - [6:0] */
42
43#define ARIZONA_MAX_GPIO 5
44
Mark Browne102bef2012-07-10 12:37:58 +010045#define ARIZONA_MAX_INPUT 4
Mark Brown3cc72982012-06-19 16:31:53 +010046
Mark Brown3d91f822013-01-29 00:47:37 +080047#define ARIZONA_MAX_MICBIAS 3
48
Mark Browne102bef2012-07-10 12:37:58 +010049#define ARIZONA_MAX_OUTPUT 6
Mark Brown3cc72982012-06-19 16:31:53 +010050
Mark Brownc94aa302013-01-17 16:35:14 +090051#define ARIZONA_MAX_AIF 3
52
Mark Brown9dd555e2012-11-26 21:17:21 +000053#define ARIZONA_HAP_ACT_ERM 0
54#define ARIZONA_HAP_ACT_LRA 2
55
Mark Brown2a51da02012-07-09 19:33:14 +010056#define ARIZONA_MAX_PDM_SPK 2
Mark Brown3cc72982012-06-19 16:31:53 +010057
58struct regulator_init_data;
Charles Keepaxc1860462018-03-12 15:52:00 +000059struct gpio_desc;
Mark Brown3cc72982012-06-19 16:31:53 +010060
Mark Brown3d91f822013-01-29 00:47:37 +080061struct arizona_micbias {
62 int mV; /** Regulated voltage */
63 unsigned int ext_cap:1; /** External capacitor fitted */
64 unsigned int discharge:1; /** Actively discharge */
Charles Keepaxf773fc62013-05-21 14:56:58 +010065 unsigned int soft_start:1; /** Disable aggressive startup ramp rate */
Mark Brown544c7aa2013-01-29 18:44:41 +080066 unsigned int bypass:1; /** Use bypass mode */
Mark Brown3d91f822013-01-29 00:47:37 +080067};
68
Mark Brown3cc72982012-06-19 16:31:53 +010069struct arizona_micd_config {
70 unsigned int src;
71 unsigned int bias;
72 bool gpio;
73};
74
Mark Brown6fed4d82013-04-01 22:03:06 +010075struct arizona_micd_range {
76 int max; /** Ohms */
77 int key; /** Key to report to input layer */
78};
79
Mark Brown3cc72982012-06-19 16:31:53 +010080struct arizona_pdata {
Charles Keepaxc1860462018-03-12 15:52:00 +000081 struct gpio_desc *reset; /** GPIO controlling /RESET, if any */
Mark Brown3cc72982012-06-19 16:31:53 +010082
83 /** Regulator configuration for MICVDD */
Richard Fitzgerald22161f32017-04-18 11:43:49 +010084 struct arizona_micsupp_pdata micvdd;
Mark Brown3cc72982012-06-19 16:31:53 +010085
86 /** Regulator configuration for LDO1 */
Richard Fitzgeraldaaa84e62017-04-18 11:43:52 +010087 struct arizona_ldo1_pdata ldo1;
Mark Brown3cc72982012-06-19 16:31:53 +010088
89 /** If a direct 32kHz clock is provided on an MCLK specify it here */
90 int clk32k_src;
91
Mark Brownf8a09412013-03-22 12:59:33 +010092 /** Mode for primary IRQ (defaults to active low) */
93 unsigned int irq_flags;
Mark Brown3cc72982012-06-19 16:31:53 +010094
95 /* Base GPIO */
96 int gpio_base;
97
98 /** Pin state for GPIO pins */
Charles Keepax6e00ff02015-03-29 12:45:42 +010099 unsigned int gpio_defaults[ARIZONA_MAX_GPIO];
Mark Brown3cc72982012-06-19 16:31:53 +0100100
Mark Brownc94aa302013-01-17 16:35:14 +0900101 /**
102 * Maximum number of channels clocks will be generated for,
103 * useful for systems where and I2S bus with multiple data
104 * lines is mastered.
105 */
Charles Keepax00b6e9f2015-06-19 11:24:27 +0100106 unsigned int max_channels_clocked[ARIZONA_MAX_AIF];
Mark Brownc94aa302013-01-17 16:35:14 +0900107
Mark Brown92a49872013-01-11 08:55:39 +0900108 /** GPIO5 is used for jack detection */
109 bool jd_gpio5;
110
Mark Browne56a0a52013-04-01 19:03:52 +0100111 /** Internal pull on GPIO5 is disabled when used for jack detection */
112 bool jd_gpio5_nopull;
113
Richard Fitzgeralda288d642014-05-23 12:54:57 +0100114 /** set to true if jackdet contact opens on insert */
115 bool jd_invert;
116
Mark Browndd235ee2013-01-11 08:55:51 +0900117 /** Use the headphone detect circuit to identify the accessory */
118 bool hpdet_acc_id;
119
Mark Brown9c2ba272013-02-25 23:42:31 +0000120 /** Check for line output with HPDET method */
121 bool hpdet_acc_id_line;
122
Mark Brown1eda6aa2013-01-11 08:55:54 +0900123 /** GPIO used for mic isolation with HPDET */
124 int hpdet_id_gpio;
125
Inha Song9e86b2a2015-05-04 13:42:13 +0900126 /** Channel to use for headphone detection */
127 unsigned int hpdet_channel;
128
Charles Keepaxe76e3972015-09-16 10:42:13 +0100129 /** Use software comparison to determine mic presence */
130 bool micd_software_compare;
131
Mark Browncd59e792013-04-01 19:21:48 +0100132 /** Extra debounce timeout used during initial mic detection (ms) */
Charles Keepax00b6e9f2015-06-19 11:24:27 +0100133 unsigned int micd_detect_debounce;
Mark Browncd59e792013-04-01 19:21:48 +0100134
Mark Brown3cc72982012-06-19 16:31:53 +0100135 /** GPIO for mic detection polarity */
136 int micd_pol_gpio;
137
Mark Brownb17e5462013-01-11 08:55:24 +0900138 /** Mic detect ramp rate */
Charles Keepax00b6e9f2015-06-19 11:24:27 +0100139 unsigned int micd_bias_start_time;
Mark Brownb17e5462013-01-11 08:55:24 +0900140
Mark Brown2e033db2013-01-21 17:36:33 +0900141 /** Mic detect sample rate */
Charles Keepax00b6e9f2015-06-19 11:24:27 +0100142 unsigned int micd_rate;
Mark Brown2e033db2013-01-21 17:36:33 +0900143
144 /** Mic detect debounce level */
Charles Keepax00b6e9f2015-06-19 11:24:27 +0100145 unsigned int micd_dbtime;
Mark Brown2e033db2013-01-21 17:36:33 +0900146
Mark Brown7abd4e22013-04-01 19:25:55 +0100147 /** Mic detect timeout (ms) */
Charles Keepax00b6e9f2015-06-19 11:24:27 +0100148 unsigned int micd_timeout;
Mark Brown7abd4e22013-04-01 19:25:55 +0100149
Mark Brownbbbd46e2013-01-10 19:38:43 +0000150 /** Force MICBIAS on for mic detect */
151 bool micd_force_micbias;
152
Mark Brown6fed4d82013-04-01 22:03:06 +0100153 /** Mic detect level parameters */
154 const struct arizona_micd_range *micd_ranges;
155 int num_micd_ranges;
156
Mark Brown3cc72982012-06-19 16:31:53 +0100157 /** Headset polarity configurations */
158 struct arizona_micd_config *micd_configs;
159 int num_micd_configs;
160
161 /** Reference voltage for DMIC inputs */
162 int dmic_ref[ARIZONA_MAX_INPUT];
163
Mark Brown3d91f822013-01-29 00:47:37 +0800164 /** MICBIAS configurations */
165 struct arizona_micbias micbias[ARIZONA_MAX_MICBIAS];
166
Richard Fitzgeraldfc027d12015-05-01 16:15:12 +0100167 /**
168 * Mode of input structures
169 * One of the ARIZONA_INMODE_xxx values
Richard Fitzgerald6887b042015-07-03 16:16:35 +0100170 * wm5102/wm5110/wm8280/wm8997: [0]=IN1 [1]=IN2 [2]=IN3 [3]=IN4
171 * wm8998: [0]=IN1A [1]=IN2A [2]=IN1B [3]=IN2B
Richard Fitzgeraldfc027d12015-05-01 16:15:12 +0100172 */
Mark Brown3cc72982012-06-19 16:31:53 +0100173 int inmode[ARIZONA_MAX_INPUT];
174
175 /** Mode for outputs */
Charles Keepaxf199d392015-12-14 10:19:11 +0000176 int out_mono[ARIZONA_MAX_OUTPUT];
Mark Brown3cc72982012-06-19 16:31:53 +0100177
Charles Keepax85e7dd32017-09-04 16:41:53 +0100178 /** Limit output volumes */
179 unsigned int out_vol_limit[2 * ARIZONA_MAX_OUTPUT];
180
Mark Brown3cc72982012-06-19 16:31:53 +0100181 /** PDM speaker mute setting */
182 unsigned int spk_mute[ARIZONA_MAX_PDM_SPK];
183
184 /** PDM speaker format */
185 unsigned int spk_fmt[ARIZONA_MAX_PDM_SPK];
Mark Brown9dd555e2012-11-26 21:17:21 +0000186
187 /** Haptic actuator type */
188 unsigned int hap_act;
Mark Brown3092f802013-03-24 23:05:58 +0000189
190 /** GPIO for primary IRQ (used for edge triggered emulation) */
191 int irq_gpio;
Charles Keepax1ce37682015-09-16 10:42:14 +0100192
193 /** General purpose switch control */
194 unsigned int gpsw;
Mark Brown3cc72982012-06-19 16:31:53 +0100195};
196
197#endif