Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Elonics E4000 silicon tuner driver
0004  *
0005  * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
0006  */
0007 
0008 #ifndef E4000_PRIV_H
0009 #define E4000_PRIV_H
0010 
0011 #include "e4000.h"
0012 #include <linux/math64.h>
0013 #include <media/v4l2-ctrls.h>
0014 #include <media/v4l2-subdev.h>
0015 #include <linux/regmap.h>
0016 
0017 struct e4000_dev {
0018     struct i2c_client *client;
0019     struct regmap *regmap;
0020     u32 clk;
0021     struct dvb_frontend *fe;
0022     struct v4l2_subdev sd;
0023     bool active;
0024     unsigned int f_frequency;
0025     unsigned int f_bandwidth;
0026 
0027     /* Controls */
0028     struct v4l2_ctrl_handler hdl;
0029     struct v4l2_ctrl *bandwidth_auto;
0030     struct v4l2_ctrl *bandwidth;
0031     struct v4l2_ctrl *lna_gain_auto;
0032     struct v4l2_ctrl *lna_gain;
0033     struct v4l2_ctrl *mixer_gain_auto;
0034     struct v4l2_ctrl *mixer_gain;
0035     struct v4l2_ctrl *if_gain_auto;
0036     struct v4l2_ctrl *if_gain;
0037     struct v4l2_ctrl *pll_lock;
0038 };
0039 
0040 struct e4000_pll {
0041     u32 freq;
0042     u8 div_out_reg;
0043     u8 div_out;
0044 };
0045 
0046 static const struct e4000_pll e4000_pll_lut[] = {
0047 /*                                      VCO min    VCO max */
0048     {   72400000, 0x0f, 48 }, /* .......... 3475200000 */
0049     {   81200000, 0x0e, 40 }, /* 2896000000 3248000000 */
0050     {  108300000, 0x0d, 32 }, /* 2598400000 3465600000 */
0051     {  162500000, 0x0c, 24 }, /* 2599200000 3900000000 */
0052     {  216600000, 0x0b, 16 }, /* 2600000000 3465600000 */
0053     {  325000000, 0x0a, 12 }, /* 2599200000 3900000000 */
0054     {  350000000, 0x09,  8 }, /* 2600000000 2800000000 */
0055     {  432000000, 0x03,  8 }, /* 2800000000 3456000000 */
0056     {  667000000, 0x02,  6 }, /* 2592000000 4002000000 */
0057     { 1200000000, 0x01,  4 }, /* 2668000000 4800000000 */
0058     { 0xffffffff, 0x00,  2 }, /* 2400000000 .......... */
0059 };
0060 
0061 struct e4000_lna_filter {
0062     u32 freq;
0063     u8 val;
0064 };
0065 
0066 static const struct e4000_lna_filter e400_lna_filter_lut[] = {
0067     {  370000000,  0 },
0068     {  392500000,  1 },
0069     {  415000000,  2 },
0070     {  437500000,  3 },
0071     {  462500000,  4 },
0072     {  490000000,  5 },
0073     {  522500000,  6 },
0074     {  557500000,  7 },
0075     {  595000000,  8 },
0076     {  642500000,  9 },
0077     {  695000000, 10 },
0078     {  740000000, 11 },
0079     {  800000000, 12 },
0080     {  865000000, 13 },
0081     {  930000000, 14 },
0082     { 1000000000, 15 },
0083     { 1310000000,  0 },
0084     { 1340000000,  1 },
0085     { 1385000000,  2 },
0086     { 1427500000,  3 },
0087     { 1452500000,  4 },
0088     { 1475000000,  5 },
0089     { 1510000000,  6 },
0090     { 1545000000,  7 },
0091     { 1575000000,  8 },
0092     { 1615000000,  9 },
0093     { 1650000000, 10 },
0094     { 1670000000, 11 },
0095     { 1690000000, 12 },
0096     { 1710000000, 13 },
0097     { 1735000000, 14 },
0098     { 0xffffffff, 15 },
0099 };
0100 
0101 struct e4000_band {
0102     u32 freq;
0103     u8 reg07_val;
0104     u8 reg78_val;
0105 };
0106 
0107 static const struct e4000_band e4000_band_lut[] = {
0108     {  140000000, 0x01, 0x03 },
0109     {  350000000, 0x03, 0x03 },
0110     { 1000000000, 0x05, 0x03 },
0111     { 0xffffffff, 0x07, 0x00 },
0112 };
0113 
0114 struct e4000_if_filter {
0115     u32 freq;
0116     u8 reg11_val;
0117     u8 reg12_val;
0118 };
0119 
0120 static const struct e4000_if_filter e4000_if_filter_lut[] = {
0121     {    4300000, 0xfd, 0x1f },
0122     {    4400000, 0xfd, 0x1e },
0123     {    4480000, 0xfc, 0x1d },
0124     {    4560000, 0xfc, 0x1c },
0125     {    4600000, 0xfc, 0x1b },
0126     {    4800000, 0xfc, 0x1a },
0127     {    4900000, 0xfc, 0x19 },
0128     {    5000000, 0xfc, 0x18 },
0129     {    5100000, 0xfc, 0x17 },
0130     {    5200000, 0xfc, 0x16 },
0131     {    5400000, 0xfc, 0x15 },
0132     {    5500000, 0xfc, 0x14 },
0133     {    5600000, 0xfc, 0x13 },
0134     {    5800000, 0xfb, 0x12 },
0135     {    5900000, 0xfb, 0x11 },
0136     {    6000000, 0xfb, 0x10 },
0137     {    6200000, 0xfb, 0x0f },
0138     {    6400000, 0xfa, 0x0e },
0139     {    6600000, 0xfa, 0x0d },
0140     {    6800000, 0xf9, 0x0c },
0141     {    7200000, 0xf9, 0x0b },
0142     {    7400000, 0xf9, 0x0a },
0143     {    7600000, 0xf8, 0x09 },
0144     {    7800000, 0xf8, 0x08 },
0145     {    8200000, 0xf8, 0x07 },
0146     {    8600000, 0xf7, 0x06 },
0147     {    8800000, 0xf7, 0x05 },
0148     {    9200000, 0xf7, 0x04 },
0149     {    9600000, 0xf6, 0x03 },
0150     {   10000000, 0xf6, 0x02 },
0151     {   10600000, 0xf5, 0x01 },
0152     {   11000000, 0xf5, 0x00 },
0153     { 0xffffffff, 0x00, 0x20 },
0154 };
0155 
0156 struct e4000_if_gain {
0157     u8 reg16_val;
0158     u8 reg17_val;
0159 };
0160 
0161 static const struct e4000_if_gain e4000_if_gain_lut[] = {
0162     {0x00, 0x00},
0163     {0x20, 0x00},
0164     {0x40, 0x00},
0165     {0x02, 0x00},
0166     {0x22, 0x00},
0167     {0x42, 0x00},
0168     {0x04, 0x00},
0169     {0x24, 0x00},
0170     {0x44, 0x00},
0171     {0x01, 0x00},
0172     {0x21, 0x00},
0173     {0x41, 0x00},
0174     {0x03, 0x00},
0175     {0x23, 0x00},
0176     {0x43, 0x00},
0177     {0x05, 0x00},
0178     {0x25, 0x00},
0179     {0x45, 0x00},
0180     {0x07, 0x00},
0181     {0x27, 0x00},
0182     {0x47, 0x00},
0183     {0x0f, 0x00},
0184     {0x2f, 0x00},
0185     {0x4f, 0x00},
0186     {0x17, 0x00},
0187     {0x37, 0x00},
0188     {0x57, 0x00},
0189     {0x1f, 0x00},
0190     {0x3f, 0x00},
0191     {0x5f, 0x00},
0192     {0x1f, 0x01},
0193     {0x3f, 0x01},
0194     {0x5f, 0x01},
0195     {0x1f, 0x02},
0196     {0x3f, 0x02},
0197     {0x5f, 0x02},
0198     {0x1f, 0x03},
0199     {0x3f, 0x03},
0200     {0x5f, 0x03},
0201     {0x1f, 0x04},
0202     {0x3f, 0x04},
0203     {0x5f, 0x04},
0204     {0x1f, 0x0c},
0205     {0x3f, 0x0c},
0206     {0x5f, 0x0c},
0207     {0x1f, 0x14},
0208     {0x3f, 0x14},
0209     {0x5f, 0x14},
0210     {0x1f, 0x1c},
0211     {0x3f, 0x1c},
0212     {0x5f, 0x1c},
0213     {0x1f, 0x24},
0214     {0x3f, 0x24},
0215     {0x5f, 0x24},
0216     {0x7f, 0x24},
0217 };
0218 
0219 #endif