blob: 66b19dd1f18615e47dab1684d0758ff4f1c9da83 [file] [log] [blame]
Antti Palosaari27cfc852011-04-07 16:27:43 -03001/*
2 * Sony CXD2820R demodulator driver
3 *
4 * Copyright (C) 2010 Antti Palosaari <crope@iki.fi>
5 *
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.
10 *
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.
15 *
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.
19 */
20
21
22#ifndef CXD2820R_PRIV_H
23#define CXD2820R_PRIV_H
24
Steve Kerrison9ac51c52011-05-02 18:19:13 -030025#include <linux/dvb/version.h>
Antti Palosaari27cfc852011-04-07 16:27:43 -030026#include "dvb_frontend.h"
27#include "dvb_math.h"
28#include "cxd2820r.h"
Antti Palosaari1e8f31f2012-07-19 21:10:36 -030029#include <linux/gpio.h>
Antti Palosaari2832fd32016-08-08 20:13:45 -030030#include <linux/math64.h>
Antti Palosaari27cfc852011-04-07 16:27:43 -030031
Antti Palosaari27cfc852011-04-07 16:27:43 -030032struct reg_val_mask {
33 u32 reg;
34 u8 val;
35 u8 mask;
36};
37
Antti Palosaarifcd09f62016-08-08 15:54:10 -030038#define CXD2820R_CLK 41000000
39
Antti Palosaari27cfc852011-04-07 16:27:43 -030040struct cxd2820r_priv {
41 struct i2c_adapter *i2c;
Manu Abraham14c03862011-11-24 11:59:53 -030042 struct dvb_frontend fe;
Antti Palosaari27cfc852011-04-07 16:27:43 -030043 struct cxd2820r_config cfg;
Antti Palosaari4aa4fd82016-08-09 14:58:21 -030044 u64 post_bit_error_prev_dvbv3;
Antti Palosaari2832fd32016-08-08 20:13:45 -030045 u64 post_bit_error;
Antti Palosaari27cfc852011-04-07 16:27:43 -030046
Antti Palosaari1d44ccb2011-05-25 12:42:52 -030047 bool ber_running;
Antti Palosaari27cfc852011-04-07 16:27:43 -030048
49 u8 bank[2];
Antti Palosaari1e8f31f2012-07-19 21:10:36 -030050#define GPIO_COUNT 3
51 u8 gpio[GPIO_COUNT];
52#ifdef CONFIG_GPIOLIB
53 struct gpio_chip gpio_chip;
54#endif
Antti Palosaari2e1ea062011-05-03 20:21:59 -030055
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -030056 enum fe_delivery_system delivery_system;
Antti Palosaari1d44ccb2011-05-25 12:42:52 -030057 bool last_tune_failed; /* for switch between T and T2 tune */
Antti Palosaari27cfc852011-04-07 16:27:43 -030058};
59
Steve Kerrison9ac51c52011-05-02 18:19:13 -030060/* cxd2820r_core.c */
61
62extern int cxd2820r_debug;
63
Antti Palosaari1e8f31f2012-07-19 21:10:36 -030064int cxd2820r_gpio(struct dvb_frontend *fe, u8 *gpio);
Steve Kerrison9ac51c52011-05-02 18:19:13 -030065
66int cxd2820r_wr_reg_mask(struct cxd2820r_priv *priv, u32 reg, u8 val,
67 u8 mask);
Antti Palosaari2e1ea062011-05-03 20:21:59 -030068
Steve Kerrison9ac51c52011-05-02 18:19:13 -030069int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
70 int len);
Antti Palosaari2e1ea062011-05-03 20:21:59 -030071
Steve Kerrison9ac51c52011-05-02 18:19:13 -030072int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
73 int len);
74
75int cxd2820r_rd_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
76 int len);
77
78int cxd2820r_wr_reg(struct cxd2820r_priv *priv, u32 reg, u8 val);
79
80int cxd2820r_rd_reg(struct cxd2820r_priv *priv, u32 reg, u8 *val);
81
82/* cxd2820r_c.c */
83
Mauro Carvalho Chehab7e3e68b2016-02-04 12:58:30 -020084int cxd2820r_get_frontend_c(struct dvb_frontend *fe,
85 struct dtv_frontend_properties *p);
Steve Kerrison9ac51c52011-05-02 18:19:13 -030086
Mauro Carvalho Chehabf311f682011-12-30 22:22:10 -030087int cxd2820r_set_frontend_c(struct dvb_frontend *fe);
Antti Palosaari2e1ea062011-05-03 20:21:59 -030088
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -030089int cxd2820r_read_status_c(struct dvb_frontend *fe, enum fe_status *status);
Steve Kerrison9ac51c52011-05-02 18:19:13 -030090
Steve Kerrison9ac51c52011-05-02 18:19:13 -030091int cxd2820r_init_c(struct dvb_frontend *fe);
92
93int cxd2820r_sleep_c(struct dvb_frontend *fe);
94
95int cxd2820r_get_tune_settings_c(struct dvb_frontend *fe,
96 struct dvb_frontend_tune_settings *s);
97
98/* cxd2820r_t.c */
99
Mauro Carvalho Chehab7e3e68b2016-02-04 12:58:30 -0200100int cxd2820r_get_frontend_t(struct dvb_frontend *fe,
101 struct dtv_frontend_properties *p);
Steve Kerrison9ac51c52011-05-02 18:19:13 -0300102
Mauro Carvalho Chehabf311f682011-12-30 22:22:10 -0300103int cxd2820r_set_frontend_t(struct dvb_frontend *fe);
Antti Palosaari2e1ea062011-05-03 20:21:59 -0300104
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300105int cxd2820r_read_status_t(struct dvb_frontend *fe, enum fe_status *status);
Steve Kerrison9ac51c52011-05-02 18:19:13 -0300106
Steve Kerrison9ac51c52011-05-02 18:19:13 -0300107int cxd2820r_init_t(struct dvb_frontend *fe);
108
109int cxd2820r_sleep_t(struct dvb_frontend *fe);
110
111int cxd2820r_get_tune_settings_t(struct dvb_frontend *fe,
112 struct dvb_frontend_tune_settings *s);
113
114/* cxd2820r_t2.c */
115
Mauro Carvalho Chehab7e3e68b2016-02-04 12:58:30 -0200116int cxd2820r_get_frontend_t2(struct dvb_frontend *fe,
117 struct dtv_frontend_properties *p);
Steve Kerrison9ac51c52011-05-02 18:19:13 -0300118
Mauro Carvalho Chehabf311f682011-12-30 22:22:10 -0300119int cxd2820r_set_frontend_t2(struct dvb_frontend *fe);
Antti Palosaari2e1ea062011-05-03 20:21:59 -0300120
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300121int cxd2820r_read_status_t2(struct dvb_frontend *fe, enum fe_status *status);
Steve Kerrison9ac51c52011-05-02 18:19:13 -0300122
Steve Kerrison9ac51c52011-05-02 18:19:13 -0300123int cxd2820r_init_t2(struct dvb_frontend *fe);
124
125int cxd2820r_sleep_t2(struct dvb_frontend *fe);
126
127int cxd2820r_get_tune_settings_t2(struct dvb_frontend *fe,
128 struct dvb_frontend_tune_settings *s);
Antti Palosaari2e1ea062011-05-03 20:21:59 -0300129
Antti Palosaari27cfc852011-04-07 16:27:43 -0300130#endif /* CXD2820R_PRIV_H */