Home | History | Annotate | Download | only in wcd9xxx
      1 /* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
      2  *
      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 
     19 #define MICBIAS_EXT_BYP_CAP 0x00
     20 #define MICBIAS_NO_EXT_BYP_CAP 0x01
     21 
     22 #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 
     31 #define TABLA_LDOH_1P95_V 0x0
     32 #define TABLA_LDOH_2P35_V 0x1
     33 #define TABLA_LDOH_2P75_V 0x2
     34 #define TABLA_LDOH_2P85_V 0x3
     35 
     36 #define TABLA_CFILT1_SEL 0x0
     37 #define TABLA_CFILT2_SEL 0x1
     38 #define TABLA_CFILT3_SEL 0x2
     39 
     40 #define TAIKO_CFILT1_SEL 0x0
     41 #define TAIKO_CFILT2_SEL 0x1
     42 #define TAIKO_CFILT3_SEL 0x2
     43 
     44 #define TAIKO_LDOH_1P95_V 0x0
     45 #define TAIKO_LDOH_2P35_V 0x1
     46 #define TAIKO_LDOH_2P75_V 0x2
     47 #define TAIKO_LDOH_2P85_V 0x3
     48 
     49 
     50 #define MAX_AMIC_CHANNEL 7
     51 
     52 #define TABLA_OCP_300_MA 0x0
     53 #define TABLA_OCP_350_MA 0x2
     54 #define TABLA_OCP_365_MA 0x3
     55 #define TABLA_OCP_150_MA 0x4
     56 #define TABLA_OCP_190_MA 0x6
     57 #define TABLA_OCP_220_MA 0x7
     58 
     59 #define TABLA_DCYCLE_255  0x0
     60 #define TABLA_DCYCLE_511  0x1
     61 #define TABLA_DCYCLE_767  0x2
     62 #define TABLA_DCYCLE_1023 0x3
     63 #define TABLA_DCYCLE_1279 0x4
     64 #define TABLA_DCYCLE_1535 0x5
     65 #define TABLA_DCYCLE_1791 0x6
     66 #define TABLA_DCYCLE_2047 0x7
     67 #define TABLA_DCYCLE_2303 0x8
     68 #define TABLA_DCYCLE_2559 0x9
     69 #define TABLA_DCYCLE_2815 0xA
     70 #define TABLA_DCYCLE_3071 0xB
     71 #define TABLA_DCYCLE_3327 0xC
     72 #define TABLA_DCYCLE_3583 0xD
     73 #define TABLA_DCYCLE_3839 0xE
     74 #define TABLA_DCYCLE_4095 0xF
     75 
     76 struct wcd9xxx_amic {
     77 	/*legacy mode, txfe_enable and txfe_buff take 7 input
     78 	 * each bit represent the channel / TXFE number
     79 	 * and numbered as below
     80 	 * bit 0 = channel 1 / TXFE1_ENABLE / TXFE1_BUFF
     81 	 * bit 1 = channel 2 / TXFE2_ENABLE / TXFE2_BUFF
     82 	 * ...
     83 	 * bit 7 = channel 7 / TXFE7_ENABLE / TXFE7_BUFF
     84 	 */
     85 	u8 legacy_mode:MAX_AMIC_CHANNEL;
     86 	u8 txfe_enable:MAX_AMIC_CHANNEL;
     87 	u8 txfe_buff:MAX_AMIC_CHANNEL;
     88 	u8 use_pdata:MAX_AMIC_CHANNEL;
     89 };
     90 
     91 /* Each micbias can be assigned to one of three cfilters
     92  * Vbatt_min >= .15V + ldoh_v
     93  * ldoh_v >= .15v + cfiltx_mv
     94  * If ldoh_v = 1.95 160 mv < cfiltx_mv < 1800 mv
     95  * If ldoh_v = 2.35 200 mv < cfiltx_mv < 2200 mv
     96  * If ldoh_v = 2.75 240 mv < cfiltx_mv < 2600 mv
     97  * If ldoh_v = 2.85 250 mv < cfiltx_mv < 2700 mv
     98  */
     99 
    100 struct wcd9xxx_micbias_setting {
    101 	u8 ldoh_v;
    102 	u32 cfilt1_mv; /* in mv */
    103 	u32 cfilt2_mv; /* in mv */
    104 	u32 cfilt3_mv; /* in mv */
    105 	/* Different WCD9xxx series codecs may not
    106 	 * have 4 mic biases. If a codec has fewer
    107 	 * mic biases, some of these properties will
    108 	 * not be used.
    109 	 */
    110 	u8 bias1_cfilt_sel;
    111 	u8 bias2_cfilt_sel;
    112 	u8 bias3_cfilt_sel;
    113 	u8 bias4_cfilt_sel;
    114 	u8 bias1_cap_mode;
    115 	u8 bias2_cap_mode;
    116 	u8 bias3_cap_mode;
    117 	u8 bias4_cap_mode;
    118 };
    119 
    120 struct wcd9xxx_ocp_setting {
    121 	unsigned int	use_pdata:1; /* 0 - use sys default as recommended */
    122 	unsigned int	num_attempts:4; /* up to 15 attempts */
    123 	unsigned int	run_time:4; /* in duty cycle */
    124 	unsigned int	wait_time:4; /* in duty cycle */
    125 	unsigned int	hph_ocp_limit:3; /* Headphone OCP current limit */
    126 };
    127 
    128 #define MAX_REGULATOR	7
    129 /*
    130  *      format : TABLA_<POWER_SUPPLY_PIN_NAME>_CUR_MAX
    131  *
    132  *      <POWER_SUPPLY_PIN_NAME> from Tabla objective spec
    133 */
    134 
    135 #define  WCD9XXX_CDC_VDDA_CP_CUR_MAX      500000
    136 #define  WCD9XXX_CDC_VDDA_RX_CUR_MAX      20000
    137 #define  WCD9XXX_CDC_VDDA_TX_CUR_MAX      20000
    138 #define  WCD9XXX_VDDIO_CDC_CUR_MAX        5000
    139 
    140 #define  WCD9XXX_VDDD_CDC_D_CUR_MAX       5000
    141 #define  WCD9XXX_VDDD_CDC_A_CUR_MAX       5000
    142 
    143 struct wcd9xxx_regulator {
    144 	const char *name;
    145 	int min_uV;
    146 	int max_uV;
    147 	int optimum_uA;
    148 	struct regulator *regulator;
    149 };
    150 
    151 struct wcd9xxx_pdata {
    152 	int irq;
    153 	int irq_base;
    154 	int num_irqs;
    155 	int reset_gpio;
    156 	struct wcd9xxx_amic amic_settings;
    157 	struct slim_device slimbus_slave_device;
    158 	struct wcd9xxx_micbias_setting micbias;
    159 	struct wcd9xxx_ocp_setting ocp;
    160 	struct wcd9xxx_regulator regulator[MAX_REGULATOR];
    161 };
    162 
    163 #endif
    164