PM / Domains: Try power off masters in error path of __pm_genpd_poweron()
[linux/fpc-iii.git] / drivers / media / tuners / e4000_priv.h
blobd6d5d11bbfe0eee0f91c33a979c8debeafcfc1e9
1 /*
2 * Elonics E4000 silicon tuner driver
4 * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef E4000_PRIV_H
22 #define E4000_PRIV_H
24 #include "e4000.h"
25 #include <linux/math64.h>
26 #include <media/v4l2-ctrls.h>
27 #include <media/v4l2-subdev.h>
28 #include <linux/regmap.h>
30 struct e4000_dev {
31 struct i2c_client *client;
32 struct regmap *regmap;
33 u32 clk;
34 struct dvb_frontend *fe;
35 struct v4l2_subdev sd;
36 bool active;
37 unsigned int f_frequency;
38 unsigned int f_bandwidth;
40 /* Controls */
41 struct v4l2_ctrl_handler hdl;
42 struct v4l2_ctrl *bandwidth_auto;
43 struct v4l2_ctrl *bandwidth;
44 struct v4l2_ctrl *lna_gain_auto;
45 struct v4l2_ctrl *lna_gain;
46 struct v4l2_ctrl *mixer_gain_auto;
47 struct v4l2_ctrl *mixer_gain;
48 struct v4l2_ctrl *if_gain_auto;
49 struct v4l2_ctrl *if_gain;
50 struct v4l2_ctrl *pll_lock;
53 struct e4000_pll {
54 u32 freq;
55 u8 div_out_reg;
56 u8 div_out;
59 static const struct e4000_pll e4000_pll_lut[] = {
60 /* VCO min VCO max */
61 { 72400000, 0x0f, 48 }, /* .......... 3475200000 */
62 { 81200000, 0x0e, 40 }, /* 2896000000 3248000000 */
63 { 108300000, 0x0d, 32 }, /* 2598400000 3465600000 */
64 { 162500000, 0x0c, 24 }, /* 2599200000 3900000000 */
65 { 216600000, 0x0b, 16 }, /* 2600000000 3465600000 */
66 { 325000000, 0x0a, 12 }, /* 2599200000 3900000000 */
67 { 350000000, 0x09, 8 }, /* 2600000000 2800000000 */
68 { 432000000, 0x03, 8 }, /* 2800000000 3456000000 */
69 { 667000000, 0x02, 6 }, /* 2592000000 4002000000 */
70 { 1200000000, 0x01, 4 }, /* 2668000000 4800000000 */
71 { 0xffffffff, 0x00, 2 }, /* 2400000000 .......... */
74 struct e4000_lna_filter {
75 u32 freq;
76 u8 val;
79 static const struct e4000_lna_filter e400_lna_filter_lut[] = {
80 { 370000000, 0 },
81 { 392500000, 1 },
82 { 415000000, 2 },
83 { 437500000, 3 },
84 { 462500000, 4 },
85 { 490000000, 5 },
86 { 522500000, 6 },
87 { 557500000, 7 },
88 { 595000000, 8 },
89 { 642500000, 9 },
90 { 695000000, 10 },
91 { 740000000, 11 },
92 { 800000000, 12 },
93 { 865000000, 13 },
94 { 930000000, 14 },
95 { 1000000000, 15 },
96 { 1310000000, 0 },
97 { 1340000000, 1 },
98 { 1385000000, 2 },
99 { 1427500000, 3 },
100 { 1452500000, 4 },
101 { 1475000000, 5 },
102 { 1510000000, 6 },
103 { 1545000000, 7 },
104 { 1575000000, 8 },
105 { 1615000000, 9 },
106 { 1650000000, 10 },
107 { 1670000000, 11 },
108 { 1690000000, 12 },
109 { 1710000000, 13 },
110 { 1735000000, 14 },
111 { 0xffffffff, 15 },
114 struct e4000_band {
115 u32 freq;
116 u8 reg07_val;
117 u8 reg78_val;
120 static const struct e4000_band e4000_band_lut[] = {
121 { 140000000, 0x01, 0x03 },
122 { 350000000, 0x03, 0x03 },
123 { 1000000000, 0x05, 0x03 },
124 { 0xffffffff, 0x07, 0x00 },
127 struct e4000_if_filter {
128 u32 freq;
129 u8 reg11_val;
130 u8 reg12_val;
133 static const struct e4000_if_filter e4000_if_filter_lut[] = {
134 { 4300000, 0xfd, 0x1f },
135 { 4400000, 0xfd, 0x1e },
136 { 4480000, 0xfc, 0x1d },
137 { 4560000, 0xfc, 0x1c },
138 { 4600000, 0xfc, 0x1b },
139 { 4800000, 0xfc, 0x1a },
140 { 4900000, 0xfc, 0x19 },
141 { 5000000, 0xfc, 0x18 },
142 { 5100000, 0xfc, 0x17 },
143 { 5200000, 0xfc, 0x16 },
144 { 5400000, 0xfc, 0x15 },
145 { 5500000, 0xfc, 0x14 },
146 { 5600000, 0xfc, 0x13 },
147 { 5800000, 0xfb, 0x12 },
148 { 5900000, 0xfb, 0x11 },
149 { 6000000, 0xfb, 0x10 },
150 { 6200000, 0xfb, 0x0f },
151 { 6400000, 0xfa, 0x0e },
152 { 6600000, 0xfa, 0x0d },
153 { 6800000, 0xf9, 0x0c },
154 { 7200000, 0xf9, 0x0b },
155 { 7400000, 0xf9, 0x0a },
156 { 7600000, 0xf8, 0x09 },
157 { 7800000, 0xf8, 0x08 },
158 { 8200000, 0xf8, 0x07 },
159 { 8600000, 0xf7, 0x06 },
160 { 8800000, 0xf7, 0x05 },
161 { 9200000, 0xf7, 0x04 },
162 { 9600000, 0xf6, 0x03 },
163 { 10000000, 0xf6, 0x02 },
164 { 10600000, 0xf5, 0x01 },
165 { 11000000, 0xf5, 0x00 },
166 { 0xffffffff, 0x00, 0x20 },
169 struct e4000_if_gain {
170 u8 reg16_val;
171 u8 reg17_val;
174 static const struct e4000_if_gain e4000_if_gain_lut[] = {
175 {0x00, 0x00},
176 {0x20, 0x00},
177 {0x40, 0x00},
178 {0x02, 0x00},
179 {0x22, 0x00},
180 {0x42, 0x00},
181 {0x04, 0x00},
182 {0x24, 0x00},
183 {0x44, 0x00},
184 {0x01, 0x00},
185 {0x21, 0x00},
186 {0x41, 0x00},
187 {0x03, 0x00},
188 {0x23, 0x00},
189 {0x43, 0x00},
190 {0x05, 0x00},
191 {0x25, 0x00},
192 {0x45, 0x00},
193 {0x07, 0x00},
194 {0x27, 0x00},
195 {0x47, 0x00},
196 {0x0f, 0x00},
197 {0x2f, 0x00},
198 {0x4f, 0x00},
199 {0x17, 0x00},
200 {0x37, 0x00},
201 {0x57, 0x00},
202 {0x1f, 0x00},
203 {0x3f, 0x00},
204 {0x5f, 0x00},
205 {0x1f, 0x01},
206 {0x3f, 0x01},
207 {0x5f, 0x01},
208 {0x1f, 0x02},
209 {0x3f, 0x02},
210 {0x5f, 0x02},
211 {0x1f, 0x03},
212 {0x3f, 0x03},
213 {0x5f, 0x03},
214 {0x1f, 0x04},
215 {0x3f, 0x04},
216 {0x5f, 0x04},
217 {0x1f, 0x0c},
218 {0x3f, 0x0c},
219 {0x5f, 0x0c},
220 {0x1f, 0x14},
221 {0x3f, 0x14},
222 {0x5f, 0x14},
223 {0x1f, 0x1c},
224 {0x3f, 0x1c},
225 {0x5f, 0x1c},
226 {0x1f, 0x24},
227 {0x3f, 0x24},
228 {0x5f, 0x24},
229 {0x7f, 0x24},
232 #endif