blob: b7ba6fbae6cd0a02b3a46d1d04d8c995718e4445 [file] [log] [blame]
Damir Didjusto1a353ce2013-04-02 11:45:47 -07001/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef __MFD_TABLA_PDATA_H__
14
15#define __MFD_TABLA_PDATA_H__
16
17#include <linux/slimbus/slimbus.h>
18
Bhalchandra Gajare15dbeaa2012-06-26 12:53:07 -070019#define MICBIAS_EXT_BYP_CAP 0x00
20#define MICBIAS_NO_EXT_BYP_CAP 0x01
21
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053022#define SITAR_LDOH_1P95_V 0x0
23#define SITAR_LDOH_2P35_V 0x1
24#define SITAR_LDOH_2P75_V 0x2
25#define SITAR_LDOH_2P85_V 0x3
26
27#define SITAR_CFILT1_SEL 0x0
28#define SITAR_CFILT2_SEL 0x1
29#define SITAR_CFILT3_SEL 0x2
30
Joonwoo Parka8890262012-10-15 12:04:27 -070031#define WCD9XXX_LDOH_1P95_V 0x0
32#define WCD9XXX_LDOH_2P35_V 0x1
33#define WCD9XXX_LDOH_2P75_V 0x2
34#define WCD9XXX_LDOH_2P85_V 0x3
35#define WCD9XXX_LDOH_3P0_V 0x3
36
Patrick Lai3043fba2011-08-01 14:15:57 -070037#define TABLA_LDOH_1P95_V 0x0
38#define TABLA_LDOH_2P35_V 0x1
39#define TABLA_LDOH_2P75_V 0x2
40#define TABLA_LDOH_2P85_V 0x3
41
42#define TABLA_CFILT1_SEL 0x0
43#define TABLA_CFILT2_SEL 0x1
44#define TABLA_CFILT3_SEL 0x2
45
Santosh Mardi22920282011-10-26 02:38:40 +053046#define MAX_AMIC_CHANNEL 7
47
Patrick Lai49efeac2011-11-03 11:01:12 -070048#define TABLA_OCP_300_MA 0x0
49#define TABLA_OCP_350_MA 0x2
50#define TABLA_OCP_365_MA 0x3
51#define TABLA_OCP_150_MA 0x4
52#define TABLA_OCP_190_MA 0x6
53#define TABLA_OCP_220_MA 0x7
54
55#define TABLA_DCYCLE_255 0x0
56#define TABLA_DCYCLE_511 0x1
57#define TABLA_DCYCLE_767 0x2
58#define TABLA_DCYCLE_1023 0x3
59#define TABLA_DCYCLE_1279 0x4
60#define TABLA_DCYCLE_1535 0x5
61#define TABLA_DCYCLE_1791 0x6
62#define TABLA_DCYCLE_2047 0x7
63#define TABLA_DCYCLE_2303 0x8
64#define TABLA_DCYCLE_2559 0x9
65#define TABLA_DCYCLE_2815 0xA
66#define TABLA_DCYCLE_3071 0xB
67#define TABLA_DCYCLE_3327 0xC
68#define TABLA_DCYCLE_3583 0xD
69#define TABLA_DCYCLE_3839 0xE
70#define TABLA_DCYCLE_4095 0xF
71
Damir Didjusto1a353ce2013-04-02 11:45:47 -070072#define TAIKO_MCLK_CLK_12P288MHZ 12288000
73#define TAIKO_MCLK_CLK_9P6HZ 9600000
74
75/* Only valid for 9.6 MHz mclk */
76#define TAIKO_DMIC_SAMPLE_RATE_2P4MHZ 2400000
77#define TAIKO_DMIC_SAMPLE_RATE_3P2MHZ 3200000
78#define TAIKO_DMIC_SAMPLE_RATE_4P8MHZ 4800000
79
80/* Only valid for 12.288 MHz mclk */
81#define TAIKO_DMIC_SAMPLE_RATE_3P072MHZ 3072000
82#define TAIKO_DMIC_SAMPLE_RATE_4P096MHZ 4096000
83#define TAIKO_DMIC_SAMPLE_RATE_6P144MHZ 6144000
84
85#define TAIKO_DMIC_SAMPLE_RATE_UNDEFINED 0
86
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +053087struct wcd9xxx_amic {
Santosh Mardi22920282011-10-26 02:38:40 +053088 /*legacy mode, txfe_enable and txfe_buff take 7 input
89 * each bit represent the channel / TXFE number
90 * and numbered as below
91 * bit 0 = channel 1 / TXFE1_ENABLE / TXFE1_BUFF
92 * bit 1 = channel 2 / TXFE2_ENABLE / TXFE2_BUFF
93 * ...
94 * bit 7 = channel 7 / TXFE7_ENABLE / TXFE7_BUFF
95 */
96 u8 legacy_mode:MAX_AMIC_CHANNEL;
97 u8 txfe_enable:MAX_AMIC_CHANNEL;
98 u8 txfe_buff:MAX_AMIC_CHANNEL;
99 u8 use_pdata:MAX_AMIC_CHANNEL;
100};
101
Patrick Lai3043fba2011-08-01 14:15:57 -0700102/* Each micbias can be assigned to one of three cfilters
103 * Vbatt_min >= .15V + ldoh_v
104 * ldoh_v >= .15v + cfiltx_mv
105 * If ldoh_v = 1.95 160 mv < cfiltx_mv < 1800 mv
106 * If ldoh_v = 2.35 200 mv < cfiltx_mv < 2200 mv
107 * If ldoh_v = 2.75 240 mv < cfiltx_mv < 2600 mv
108 * If ldoh_v = 2.85 250 mv < cfiltx_mv < 2700 mv
109 */
110
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530111struct wcd9xxx_micbias_setting {
Patrick Lai3043fba2011-08-01 14:15:57 -0700112 u8 ldoh_v;
113 u32 cfilt1_mv; /* in mv */
114 u32 cfilt2_mv; /* in mv */
115 u32 cfilt3_mv; /* in mv */
Bhalchandra Gajare15dbeaa2012-06-26 12:53:07 -0700116 /* Different WCD9xxx series codecs may not
117 * have 4 mic biases. If a codec has fewer
118 * mic biases, some of these properties will
119 * not be used.
120 */
Patrick Lai3043fba2011-08-01 14:15:57 -0700121 u8 bias1_cfilt_sel;
122 u8 bias2_cfilt_sel;
123 u8 bias3_cfilt_sel;
124 u8 bias4_cfilt_sel;
Bhalchandra Gajare15dbeaa2012-06-26 12:53:07 -0700125 u8 bias1_cap_mode;
126 u8 bias2_cap_mode;
127 u8 bias3_cap_mode;
128 u8 bias4_cap_mode;
Joonwoo Park88bfa842013-04-15 16:59:21 -0700129 bool bias2_is_headset_only;
Patrick Lai3043fba2011-08-01 14:15:57 -0700130};
131
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530132struct wcd9xxx_ocp_setting {
Patrick Lai49efeac2011-11-03 11:01:12 -0700133 unsigned int use_pdata:1; /* 0 - use sys default as recommended */
134 unsigned int num_attempts:4; /* up to 15 attempts */
135 unsigned int run_time:4; /* in duty cycle */
136 unsigned int wait_time:4; /* in duty cycle */
137 unsigned int hph_ocp_limit:3; /* Headphone OCP current limit */
138};
139
Joonwoo Park5d170a42013-04-10 15:16:36 -0700140#define WCD9XXX_MAX_REGULATOR 8
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530141/*
142 * format : TABLA_<POWER_SUPPLY_PIN_NAME>_CUR_MAX
143 *
144 * <POWER_SUPPLY_PIN_NAME> from Tabla objective spec
145*/
146
147#define WCD9XXX_CDC_VDDA_CP_CUR_MAX 500000
148#define WCD9XXX_CDC_VDDA_RX_CUR_MAX 20000
149#define WCD9XXX_CDC_VDDA_TX_CUR_MAX 20000
150#define WCD9XXX_VDDIO_CDC_CUR_MAX 5000
151
152#define WCD9XXX_VDDD_CDC_D_CUR_MAX 5000
153#define WCD9XXX_VDDD_CDC_A_CUR_MAX 5000
154
Joonwoo Park448a8fc2013-04-10 15:25:58 -0700155#define WCD9XXX_VDD_SPKDRV_NAME "cdc-vdd-spkdrv"
156
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530157struct wcd9xxx_regulator {
158 const char *name;
159 int min_uV;
160 int max_uV;
161 int optimum_uA;
Joonwoo Park5d170a42013-04-10 15:16:36 -0700162 bool ondemand;
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530163 struct regulator *regulator;
164};
165
166struct wcd9xxx_pdata {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700167 int irq;
168 int irq_base;
169 int num_irqs;
170 int reset_gpio;
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530171 struct wcd9xxx_amic amic_settings;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700172 struct slim_device slimbus_slave_device;
Asish Bhattacharyab1aeae22012-02-15 08:29:28 +0530173 struct wcd9xxx_micbias_setting micbias;
174 struct wcd9xxx_ocp_setting ocp;
Joonwoo Park5d170a42013-04-10 15:16:36 -0700175 struct wcd9xxx_regulator regulator[WCD9XXX_MAX_REGULATOR];
Venkat Sudhira50a3762012-11-26 12:12:15 -0800176 u32 mclk_rate;
Damir Didjusto1a353ce2013-04-02 11:45:47 -0700177 u32 dmic_sample_rate;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700178};
179
180#endif