Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * FCI FC2580 silicon tuner driver
0004  *
0005  * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
0006  */
0007 
0008 #ifndef FC2580_PRIV_H
0009 #define FC2580_PRIV_H
0010 
0011 #include "fc2580.h"
0012 #include <media/v4l2-ctrls.h>
0013 #include <media/v4l2-subdev.h>
0014 #include <linux/regmap.h>
0015 #include <linux/math64.h>
0016 
0017 struct fc2580_reg_val {
0018     u8 reg;
0019     u8 val;
0020 };
0021 
0022 static const struct fc2580_reg_val fc2580_init_reg_vals[] = {
0023     {0x00, 0x00},
0024     {0x12, 0x86},
0025     {0x14, 0x5c},
0026     {0x16, 0x3c},
0027     {0x1f, 0xd2},
0028     {0x09, 0xd7},
0029     {0x0b, 0xd5},
0030     {0x0c, 0x32},
0031     {0x0e, 0x43},
0032     {0x21, 0x0a},
0033     {0x22, 0x82},
0034     {0x45, 0x10},
0035     {0x4c, 0x00},
0036     {0x3f, 0x88},
0037     {0x02, 0x0e},
0038     {0x58, 0x14},
0039 };
0040 
0041 struct fc2580_pll {
0042     u32 freq;
0043     u8 div_out;
0044     u8 band;
0045 };
0046 
0047 static const struct fc2580_pll fc2580_pll_lut[] = {
0048     /*                            VCO min    VCO max */
0049     { 400000000, 12, 0x80}, /* .......... 4800000000 */
0050     {1000000000,  4, 0x00}, /* 1600000000 4000000000 */
0051     {0xffffffff,  2, 0x40}, /* 2000000000 .......... */
0052 };
0053 
0054 struct fc2580_if_filter {
0055     u32 freq;
0056     u8 r36_val;
0057     u8 r39_val;
0058 };
0059 
0060 static const struct fc2580_if_filter fc2580_if_filter_lut[] = {
0061     {   6000000, 0x18, 0x00},
0062     {   7000000, 0x18, 0x80},
0063     {   8000000, 0x18, 0x80},
0064     {0xffffffff, 0x18, 0x80},
0065 };
0066 
0067 struct fc2580_freq_regs {
0068     u32 freq;
0069     u8 r25_val;
0070     u8 r27_val;
0071     u8 r28_val;
0072     u8 r29_val;
0073     u8 r2b_val;
0074     u8 r2c_val;
0075     u8 r2d_val;
0076     u8 r30_val;
0077     u8 r44_val;
0078     u8 r50_val;
0079     u8 r53_val;
0080     u8 r5f_val;
0081     u8 r61_val;
0082     u8 r62_val;
0083     u8 r63_val;
0084     u8 r67_val;
0085     u8 r68_val;
0086     u8 r69_val;
0087     u8 r6a_val;
0088     u8 r6b_val;
0089     u8 r6c_val;
0090     u8 r6d_val;
0091     u8 r6e_val;
0092     u8 r6f_val;
0093 };
0094 
0095 /* XXX: 0xff is used for don't-care! */
0096 static const struct fc2580_freq_regs fc2580_freq_regs_lut[] = {
0097     { 400000000,
0098         0xff, 0x77, 0x33, 0x40, 0xff, 0xff, 0xff, 0x09, 0xff, 0x8c,
0099         0x50, 0x0f, 0x07, 0x00, 0x15, 0x03, 0x05, 0x10, 0x12, 0x08,
0100         0x0a, 0x78, 0x32, 0x54},
0101     { 538000000,
0102         0xf0, 0x77, 0x53, 0x60, 0xff, 0xff, 0x9f, 0x09, 0xff, 0x8c,
0103         0x50, 0x13, 0x07, 0x06, 0x15, 0x06, 0x08, 0x10, 0x12, 0x0b,
0104         0x0c, 0x78, 0x32, 0x14},
0105     { 794000000,
0106         0xf0, 0x77, 0x53, 0x60, 0xff, 0xff, 0x9f, 0x09, 0xff, 0x8c,
0107         0x50, 0x15, 0x03, 0x03, 0x15, 0x03, 0x05, 0x0c, 0x0e, 0x0b,
0108         0x0c, 0x78, 0x32, 0x14},
0109     {1000000000,
0110         0xf0, 0x77, 0x53, 0x60, 0xff, 0xff, 0x8f, 0x09, 0xff, 0x8c,
0111         0x50, 0x15, 0x07, 0x06, 0x15, 0x07, 0x09, 0x10, 0x12, 0x0b,
0112         0x0c, 0x78, 0x32, 0x14},
0113     {0xffffffff,
0114         0xff, 0xff, 0xff, 0xff, 0x70, 0x37, 0xe7, 0x09, 0x20, 0x8c,
0115         0x50, 0x0f, 0x0f, 0x00, 0x13, 0x00, 0x02, 0x0c, 0x0e, 0x08,
0116         0x0a, 0xa0, 0x50, 0x14},
0117 };
0118 
0119 struct fc2580_dev {
0120     u32 clk;
0121     struct i2c_client *client;
0122     struct regmap *regmap;
0123     struct v4l2_subdev subdev;
0124     bool active;
0125     unsigned int f_frequency;
0126     unsigned int f_bandwidth;
0127 
0128     /* Controls */
0129     struct v4l2_ctrl_handler hdl;
0130     struct v4l2_ctrl *bandwidth_auto;
0131     struct v4l2_ctrl *bandwidth;
0132 };
0133 
0134 #endif