Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Montage Technology M88DS3103/M88RS6000 demodulator driver
0004  *
0005  * Copyright (C) 2013 Antti Palosaari <crope@iki.fi>
0006  */
0007 
0008 #ifndef M88DS3103_PRIV_H
0009 #define M88DS3103_PRIV_H
0010 
0011 #include <media/dvb_frontend.h>
0012 #include "m88ds3103.h"
0013 #include <media/dvb_math.h>
0014 #include <linux/firmware.h>
0015 #include <linux/i2c-mux.h>
0016 #include <linux/regmap.h>
0017 #include <linux/math64.h>
0018 
0019 #define M88DS3103B_FIRMWARE "dvb-demod-m88ds3103b.fw"
0020 #define M88DS3103_FIRMWARE  "dvb-demod-m88ds3103.fw"
0021 #define M88RS6000_FIRMWARE  "dvb-demod-m88rs6000.fw"
0022 
0023 #define M88RS6000_CHIP_ID 0x74
0024 #define M88DS3103_CHIP_ID 0x70
0025 
0026 #define M88DS3103_CHIPTYPE_3103   0
0027 #define M88DS3103_CHIPTYPE_RS6000 1
0028 #define M88DS3103_CHIPTYPE_3103B  2
0029 
0030 struct m88ds3103_dev {
0031     struct i2c_client *client;
0032     struct i2c_client *dt_client;
0033     struct regmap_config regmap_config;
0034     struct regmap *regmap;
0035     struct m88ds3103_config config;
0036     const struct m88ds3103_config *cfg;
0037     struct dvb_frontend fe;
0038     enum fe_delivery_system delivery_system;
0039     enum fe_status fe_status;
0040     u32 dvbv3_ber; /* for old DVBv3 API read_ber */
0041     bool warm; /* FW running */
0042     struct i2c_mux_core *muxc;
0043     /* auto detect chip id to do different config */
0044     u8 chip_id;
0045     /* chip type to differentiate m88rs6000 from m88ds3103b */
0046     u8 chiptype;
0047     /* main mclk is calculated for M88RS6000 dynamically */
0048     s32 mclk;
0049     u64 post_bit_error;
0050     u64 post_bit_count;
0051     u8 dt_addr;
0052 };
0053 
0054 struct m88ds3103_reg_val {
0055     u8 reg;
0056     u8 val;
0057 };
0058 
0059 static const struct m88ds3103_reg_val m88ds3103_dvbs_init_reg_vals[] = {
0060     {0x23, 0x07},
0061     {0x08, 0x03},
0062     {0x0c, 0x02},
0063     {0x21, 0x54},
0064     {0x25, 0x8a},
0065     {0x27, 0x31},
0066     {0x30, 0x08},
0067     {0x31, 0x40},
0068     {0x32, 0x32},
0069     {0x35, 0xff},
0070     {0x3a, 0x00},
0071     {0x37, 0x10},
0072     {0x38, 0x10},
0073     {0x39, 0x02},
0074     {0x42, 0x60},
0075     {0x4a, 0x80},
0076     {0x4b, 0x04},
0077     {0x4d, 0x91},
0078     {0x5d, 0xc8},
0079     {0x50, 0x36},
0080     {0x51, 0x36},
0081     {0x52, 0x36},
0082     {0x53, 0x36},
0083     {0x56, 0x01},
0084     {0x63, 0x0f},
0085     {0x64, 0x30},
0086     {0x65, 0x40},
0087     {0x68, 0x26},
0088     {0x69, 0x4c},
0089     {0x70, 0x20},
0090     {0x71, 0x70},
0091     {0x72, 0x04},
0092     {0x73, 0x00},
0093     {0x70, 0x40},
0094     {0x71, 0x70},
0095     {0x72, 0x04},
0096     {0x73, 0x00},
0097     {0x70, 0x60},
0098     {0x71, 0x70},
0099     {0x72, 0x04},
0100     {0x73, 0x00},
0101     {0x70, 0x80},
0102     {0x71, 0x70},
0103     {0x72, 0x04},
0104     {0x73, 0x00},
0105     {0x70, 0xa0},
0106     {0x71, 0x70},
0107     {0x72, 0x04},
0108     {0x73, 0x00},
0109     {0x70, 0x1f},
0110     {0x76, 0x38},
0111     {0x77, 0xa6},
0112     {0x78, 0x0c},
0113     {0x79, 0x80},
0114     {0x7f, 0x14},
0115     {0x7c, 0x00},
0116     {0xae, 0x82},
0117     {0x80, 0x64},
0118     {0x81, 0x66},
0119     {0x82, 0x44},
0120     {0x85, 0x04},
0121     {0xcd, 0xf4},
0122     {0x90, 0x33},
0123     {0xa0, 0x44},
0124     {0xc0, 0x08},
0125     {0xc3, 0x10},
0126     {0xc4, 0x08},
0127     {0xc5, 0xf0},
0128     {0xc6, 0xff},
0129     {0xc7, 0x00},
0130     {0xc8, 0x1a},
0131     {0xc9, 0x80},
0132     {0xe0, 0xf8},
0133     {0xe6, 0x8b},
0134     {0xd0, 0x40},
0135     {0xf8, 0x20},
0136     {0xfa, 0x0f},
0137     {0x00, 0x00},
0138     {0xbd, 0x01},
0139     {0xb8, 0x00},
0140 };
0141 
0142 static const struct m88ds3103_reg_val m88ds3103_dvbs2_init_reg_vals[] = {
0143     {0x23, 0x07},
0144     {0x08, 0x07},
0145     {0x0c, 0x02},
0146     {0x21, 0x54},
0147     {0x25, 0x8a},
0148     {0x27, 0x31},
0149     {0x30, 0x08},
0150     {0x32, 0x32},
0151     {0x35, 0xff},
0152     {0x3a, 0x00},
0153     {0x37, 0x10},
0154     {0x38, 0x10},
0155     {0x39, 0x02},
0156     {0x42, 0x60},
0157     {0x4a, 0x80},
0158     {0x4b, 0x04},
0159     {0x4d, 0x91},
0160     {0x5d, 0xc8},
0161     {0x50, 0x36},
0162     {0x51, 0x36},
0163     {0x52, 0x36},
0164     {0x53, 0x36},
0165     {0x56, 0x01},
0166     {0x63, 0x0f},
0167     {0x64, 0x10},
0168     {0x65, 0x20},
0169     {0x68, 0x46},
0170     {0x69, 0xcd},
0171     {0x70, 0x20},
0172     {0x71, 0x70},
0173     {0x72, 0x04},
0174     {0x73, 0x00},
0175     {0x70, 0x40},
0176     {0x71, 0x70},
0177     {0x72, 0x04},
0178     {0x73, 0x00},
0179     {0x70, 0x60},
0180     {0x71, 0x70},
0181     {0x72, 0x04},
0182     {0x73, 0x00},
0183     {0x70, 0x80},
0184     {0x71, 0x70},
0185     {0x72, 0x04},
0186     {0x73, 0x00},
0187     {0x70, 0xa0},
0188     {0x71, 0x70},
0189     {0x72, 0x04},
0190     {0x73, 0x00},
0191     {0x70, 0x1f},
0192     {0x76, 0x38},
0193     {0x77, 0xa6},
0194     {0x78, 0x0c},
0195     {0x79, 0x80},
0196     {0x7f, 0x14},
0197     {0x85, 0x08},
0198     {0xcd, 0xf4},
0199     {0x90, 0x33},
0200     {0x86, 0x00},
0201     {0x87, 0x0f},
0202     {0x89, 0x00},
0203     {0x8b, 0x44},
0204     {0x8c, 0x66},
0205     {0x9d, 0xc1},
0206     {0x8a, 0x10},
0207     {0xad, 0x40},
0208     {0xa0, 0x44},
0209     {0xc0, 0x08},
0210     {0xc1, 0x10},
0211     {0xc2, 0x08},
0212     {0xc3, 0x10},
0213     {0xc4, 0x08},
0214     {0xc5, 0xf0},
0215     {0xc6, 0xff},
0216     {0xc7, 0x00},
0217     {0xc8, 0x1a},
0218     {0xc9, 0x80},
0219     {0xca, 0x23},
0220     {0xcb, 0x24},
0221     {0xcc, 0xf4},
0222     {0xce, 0x74},
0223     {0x00, 0x00},
0224     {0xbd, 0x01},
0225     {0xb8, 0x00},
0226 };
0227 
0228 static const struct m88ds3103_reg_val m88rs6000_dvbs_init_reg_vals[] = {
0229     {0x23, 0x07},
0230     {0x08, 0x03},
0231     {0x0c, 0x02},
0232     {0x20, 0x00},
0233     {0x21, 0x54},
0234     {0x25, 0x82},
0235     {0x27, 0x31},
0236     {0x30, 0x08},
0237     {0x31, 0x40},
0238     {0x32, 0x32},
0239     {0x33, 0x35},
0240     {0x35, 0xff},
0241     {0x3a, 0x00},
0242     {0x37, 0x10},
0243     {0x38, 0x10},
0244     {0x39, 0x02},
0245     {0x42, 0x60},
0246     {0x4a, 0x80},
0247     {0x4b, 0x04},
0248     {0x4d, 0x91},
0249     {0x5d, 0xc8},
0250     {0x50, 0x36},
0251     {0x51, 0x36},
0252     {0x52, 0x36},
0253     {0x53, 0x36},
0254     {0x63, 0x0f},
0255     {0x64, 0x30},
0256     {0x65, 0x40},
0257     {0x68, 0x26},
0258     {0x69, 0x4c},
0259     {0x70, 0x20},
0260     {0x71, 0x70},
0261     {0x72, 0x04},
0262     {0x73, 0x00},
0263     {0x70, 0x40},
0264     {0x71, 0x70},
0265     {0x72, 0x04},
0266     {0x73, 0x00},
0267     {0x70, 0x60},
0268     {0x71, 0x70},
0269     {0x72, 0x04},
0270     {0x73, 0x00},
0271     {0x70, 0x80},
0272     {0x71, 0x70},
0273     {0x72, 0x04},
0274     {0x73, 0x00},
0275     {0x70, 0xa0},
0276     {0x71, 0x70},
0277     {0x72, 0x04},
0278     {0x73, 0x00},
0279     {0x70, 0x1f},
0280     {0x76, 0x38},
0281     {0x77, 0xa6},
0282     {0x78, 0x0c},
0283     {0x79, 0x80},
0284     {0x7f, 0x14},
0285     {0x7c, 0x00},
0286     {0xae, 0x82},
0287     {0x80, 0x64},
0288     {0x81, 0x66},
0289     {0x82, 0x44},
0290     {0x85, 0x04},
0291     {0xcd, 0xf4},
0292     {0x90, 0x33},
0293     {0xa0, 0x44},
0294     {0xbe, 0x00},
0295     {0xc0, 0x08},
0296     {0xc3, 0x10},
0297     {0xc4, 0x08},
0298     {0xc5, 0xf0},
0299     {0xc6, 0xff},
0300     {0xc7, 0x00},
0301     {0xc8, 0x1a},
0302     {0xc9, 0x80},
0303     {0xe0, 0xf8},
0304     {0xe6, 0x8b},
0305     {0xd0, 0x40},
0306     {0xf8, 0x20},
0307     {0xfa, 0x0f},
0308     {0x00, 0x00},
0309     {0xbd, 0x01},
0310     {0xb8, 0x00},
0311     {0x29, 0x11},
0312 };
0313 
0314 static const struct m88ds3103_reg_val m88rs6000_dvbs2_init_reg_vals[] = {
0315     {0x23, 0x07},
0316     {0x08, 0x07},
0317     {0x0c, 0x02},
0318     {0x20, 0x00},
0319     {0x21, 0x54},
0320     {0x25, 0x82},
0321     {0x27, 0x31},
0322     {0x30, 0x08},
0323     {0x32, 0x32},
0324     {0x33, 0x35},
0325     {0x35, 0xff},
0326     {0x3a, 0x00},
0327     {0x37, 0x10},
0328     {0x38, 0x10},
0329     {0x39, 0x02},
0330     {0x42, 0x60},
0331     {0x4a, 0x80},
0332     {0x4b, 0x04},
0333     {0x4d, 0x91},
0334     {0x5d, 0xc8},
0335     {0x50, 0x36},
0336     {0x51, 0x36},
0337     {0x52, 0x36},
0338     {0x53, 0x36},
0339     {0x63, 0x0f},
0340     {0x64, 0x10},
0341     {0x65, 0x20},
0342     {0x68, 0x46},
0343     {0x69, 0xcd},
0344     {0x70, 0x20},
0345     {0x71, 0x70},
0346     {0x72, 0x04},
0347     {0x73, 0x00},
0348     {0x70, 0x40},
0349     {0x71, 0x70},
0350     {0x72, 0x04},
0351     {0x73, 0x00},
0352     {0x70, 0x60},
0353     {0x71, 0x70},
0354     {0x72, 0x04},
0355     {0x73, 0x00},
0356     {0x70, 0x80},
0357     {0x71, 0x70},
0358     {0x72, 0x04},
0359     {0x73, 0x00},
0360     {0x70, 0xa0},
0361     {0x71, 0x70},
0362     {0x72, 0x04},
0363     {0x73, 0x00},
0364     {0x70, 0x1f},
0365     {0x76, 0x38},
0366     {0x77, 0xa6},
0367     {0x78, 0x0c},
0368     {0x79, 0x80},
0369     {0x7f, 0x14},
0370     {0x85, 0x08},
0371     {0xcd, 0xf4},
0372     {0x90, 0x33},
0373     {0x86, 0x00},
0374     {0x87, 0x0f},
0375     {0x89, 0x00},
0376     {0x8b, 0x44},
0377     {0x8c, 0x66},
0378     {0x9d, 0xc1},
0379     {0x8a, 0x10},
0380     {0xad, 0x40},
0381     {0xa0, 0x44},
0382     {0xbe, 0x00},
0383     {0xc0, 0x08},
0384     {0xc1, 0x10},
0385     {0xc2, 0x08},
0386     {0xc3, 0x10},
0387     {0xc4, 0x08},
0388     {0xc5, 0xf0},
0389     {0xc6, 0xff},
0390     {0xc7, 0x00},
0391     {0xc8, 0x1a},
0392     {0xc9, 0x80},
0393     {0xca, 0x23},
0394     {0xcb, 0x24},
0395     {0xcc, 0xf4},
0396     {0xce, 0x74},
0397     {0x00, 0x00},
0398     {0xbd, 0x01},
0399     {0xb8, 0x00},
0400     {0x29, 0x01},
0401 };
0402 #endif