18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * FCI FC2580 silicon tuner driver 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2012 Antti Palosaari <crope@iki.fi> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef FC2580_PRIV_H 98c2ecf20Sopenharmony_ci#define FC2580_PRIV_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include "fc2580.h" 128c2ecf20Sopenharmony_ci#include <media/v4l2-ctrls.h> 138c2ecf20Sopenharmony_ci#include <media/v4l2-subdev.h> 148c2ecf20Sopenharmony_ci#include <linux/regmap.h> 158c2ecf20Sopenharmony_ci#include <linux/math64.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cistruct fc2580_reg_val { 188c2ecf20Sopenharmony_ci u8 reg; 198c2ecf20Sopenharmony_ci u8 val; 208c2ecf20Sopenharmony_ci}; 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistatic const struct fc2580_reg_val fc2580_init_reg_vals[] = { 238c2ecf20Sopenharmony_ci {0x00, 0x00}, 248c2ecf20Sopenharmony_ci {0x12, 0x86}, 258c2ecf20Sopenharmony_ci {0x14, 0x5c}, 268c2ecf20Sopenharmony_ci {0x16, 0x3c}, 278c2ecf20Sopenharmony_ci {0x1f, 0xd2}, 288c2ecf20Sopenharmony_ci {0x09, 0xd7}, 298c2ecf20Sopenharmony_ci {0x0b, 0xd5}, 308c2ecf20Sopenharmony_ci {0x0c, 0x32}, 318c2ecf20Sopenharmony_ci {0x0e, 0x43}, 328c2ecf20Sopenharmony_ci {0x21, 0x0a}, 338c2ecf20Sopenharmony_ci {0x22, 0x82}, 348c2ecf20Sopenharmony_ci {0x45, 0x10}, 358c2ecf20Sopenharmony_ci {0x4c, 0x00}, 368c2ecf20Sopenharmony_ci {0x3f, 0x88}, 378c2ecf20Sopenharmony_ci {0x02, 0x0e}, 388c2ecf20Sopenharmony_ci {0x58, 0x14}, 398c2ecf20Sopenharmony_ci}; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistruct fc2580_pll { 428c2ecf20Sopenharmony_ci u32 freq; 438c2ecf20Sopenharmony_ci u8 div_out; 448c2ecf20Sopenharmony_ci u8 band; 458c2ecf20Sopenharmony_ci}; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_cistatic const struct fc2580_pll fc2580_pll_lut[] = { 488c2ecf20Sopenharmony_ci /* VCO min VCO max */ 498c2ecf20Sopenharmony_ci { 400000000, 12, 0x80}, /* .......... 4800000000 */ 508c2ecf20Sopenharmony_ci {1000000000, 4, 0x00}, /* 1600000000 4000000000 */ 518c2ecf20Sopenharmony_ci {0xffffffff, 2, 0x40}, /* 2000000000 .......... */ 528c2ecf20Sopenharmony_ci}; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_cistruct fc2580_if_filter { 558c2ecf20Sopenharmony_ci u32 freq; 568c2ecf20Sopenharmony_ci u8 r36_val; 578c2ecf20Sopenharmony_ci u8 r39_val; 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic const struct fc2580_if_filter fc2580_if_filter_lut[] = { 618c2ecf20Sopenharmony_ci { 6000000, 0x18, 0x00}, 628c2ecf20Sopenharmony_ci { 7000000, 0x18, 0x80}, 638c2ecf20Sopenharmony_ci { 8000000, 0x18, 0x80}, 648c2ecf20Sopenharmony_ci {0xffffffff, 0x18, 0x80}, 658c2ecf20Sopenharmony_ci}; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cistruct fc2580_freq_regs { 688c2ecf20Sopenharmony_ci u32 freq; 698c2ecf20Sopenharmony_ci u8 r25_val; 708c2ecf20Sopenharmony_ci u8 r27_val; 718c2ecf20Sopenharmony_ci u8 r28_val; 728c2ecf20Sopenharmony_ci u8 r29_val; 738c2ecf20Sopenharmony_ci u8 r2b_val; 748c2ecf20Sopenharmony_ci u8 r2c_val; 758c2ecf20Sopenharmony_ci u8 r2d_val; 768c2ecf20Sopenharmony_ci u8 r30_val; 778c2ecf20Sopenharmony_ci u8 r44_val; 788c2ecf20Sopenharmony_ci u8 r50_val; 798c2ecf20Sopenharmony_ci u8 r53_val; 808c2ecf20Sopenharmony_ci u8 r5f_val; 818c2ecf20Sopenharmony_ci u8 r61_val; 828c2ecf20Sopenharmony_ci u8 r62_val; 838c2ecf20Sopenharmony_ci u8 r63_val; 848c2ecf20Sopenharmony_ci u8 r67_val; 858c2ecf20Sopenharmony_ci u8 r68_val; 868c2ecf20Sopenharmony_ci u8 r69_val; 878c2ecf20Sopenharmony_ci u8 r6a_val; 888c2ecf20Sopenharmony_ci u8 r6b_val; 898c2ecf20Sopenharmony_ci u8 r6c_val; 908c2ecf20Sopenharmony_ci u8 r6d_val; 918c2ecf20Sopenharmony_ci u8 r6e_val; 928c2ecf20Sopenharmony_ci u8 r6f_val; 938c2ecf20Sopenharmony_ci}; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci/* XXX: 0xff is used for don't-care! */ 968c2ecf20Sopenharmony_cistatic const struct fc2580_freq_regs fc2580_freq_regs_lut[] = { 978c2ecf20Sopenharmony_ci { 400000000, 988c2ecf20Sopenharmony_ci 0xff, 0x77, 0x33, 0x40, 0xff, 0xff, 0xff, 0x09, 0xff, 0x8c, 998c2ecf20Sopenharmony_ci 0x50, 0x0f, 0x07, 0x00, 0x15, 0x03, 0x05, 0x10, 0x12, 0x08, 1008c2ecf20Sopenharmony_ci 0x0a, 0x78, 0x32, 0x54}, 1018c2ecf20Sopenharmony_ci { 538000000, 1028c2ecf20Sopenharmony_ci 0xf0, 0x77, 0x53, 0x60, 0xff, 0xff, 0x9f, 0x09, 0xff, 0x8c, 1038c2ecf20Sopenharmony_ci 0x50, 0x13, 0x07, 0x06, 0x15, 0x06, 0x08, 0x10, 0x12, 0x0b, 1048c2ecf20Sopenharmony_ci 0x0c, 0x78, 0x32, 0x14}, 1058c2ecf20Sopenharmony_ci { 794000000, 1068c2ecf20Sopenharmony_ci 0xf0, 0x77, 0x53, 0x60, 0xff, 0xff, 0x9f, 0x09, 0xff, 0x8c, 1078c2ecf20Sopenharmony_ci 0x50, 0x15, 0x03, 0x03, 0x15, 0x03, 0x05, 0x0c, 0x0e, 0x0b, 1088c2ecf20Sopenharmony_ci 0x0c, 0x78, 0x32, 0x14}, 1098c2ecf20Sopenharmony_ci {1000000000, 1108c2ecf20Sopenharmony_ci 0xf0, 0x77, 0x53, 0x60, 0xff, 0xff, 0x8f, 0x09, 0xff, 0x8c, 1118c2ecf20Sopenharmony_ci 0x50, 0x15, 0x07, 0x06, 0x15, 0x07, 0x09, 0x10, 0x12, 0x0b, 1128c2ecf20Sopenharmony_ci 0x0c, 0x78, 0x32, 0x14}, 1138c2ecf20Sopenharmony_ci {0xffffffff, 1148c2ecf20Sopenharmony_ci 0xff, 0xff, 0xff, 0xff, 0x70, 0x37, 0xe7, 0x09, 0x20, 0x8c, 1158c2ecf20Sopenharmony_ci 0x50, 0x0f, 0x0f, 0x00, 0x13, 0x00, 0x02, 0x0c, 0x0e, 0x08, 1168c2ecf20Sopenharmony_ci 0x0a, 0xa0, 0x50, 0x14}, 1178c2ecf20Sopenharmony_ci}; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_cistruct fc2580_dev { 1208c2ecf20Sopenharmony_ci u32 clk; 1218c2ecf20Sopenharmony_ci struct i2c_client *client; 1228c2ecf20Sopenharmony_ci struct regmap *regmap; 1238c2ecf20Sopenharmony_ci struct v4l2_subdev subdev; 1248c2ecf20Sopenharmony_ci bool active; 1258c2ecf20Sopenharmony_ci unsigned int f_frequency; 1268c2ecf20Sopenharmony_ci unsigned int f_bandwidth; 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci /* Controls */ 1298c2ecf20Sopenharmony_ci struct v4l2_ctrl_handler hdl; 1308c2ecf20Sopenharmony_ci struct v4l2_ctrl *bandwidth_auto; 1318c2ecf20Sopenharmony_ci struct v4l2_ctrl *bandwidth; 1328c2ecf20Sopenharmony_ci}; 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci#endif 135