Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 1 | /* |
| 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 Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 25 | #include <linux/dvb/version.h> |
Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 26 | #include "dvb_frontend.h" |
| 27 | #include "dvb_math.h" |
| 28 | #include "cxd2820r.h" |
Antti Palosaari | 1e8f31f | 2012-07-19 21:10:36 -0300 | [diff] [blame] | 29 | #include <linux/gpio.h> |
Antti Palosaari | 2832fd3 | 2016-08-08 20:13:45 -0300 | [diff] [blame] | 30 | #include <linux/math64.h> |
Antti Palosaari | 43e2ea6 | 2016-08-13 13:19:05 -0300 | [diff] [blame] | 31 | #include <linux/regmap.h> |
Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 32 | |
Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 33 | struct reg_val_mask { |
| 34 | u32 reg; |
| 35 | u8 val; |
| 36 | u8 mask; |
| 37 | }; |
| 38 | |
Antti Palosaari | fcd09f6 | 2016-08-08 15:54:10 -0300 | [diff] [blame] | 39 | #define CXD2820R_CLK 41000000 |
| 40 | |
Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 41 | struct cxd2820r_priv { |
Antti Palosaari | 07fdf7d | 2016-08-09 20:49:09 -0300 | [diff] [blame] | 42 | struct i2c_client *client[2]; |
Antti Palosaari | 43e2ea6 | 2016-08-13 13:19:05 -0300 | [diff] [blame] | 43 | struct regmap *regmap[2]; |
Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 44 | struct i2c_adapter *i2c; |
Manu Abraham | 14c0386 | 2011-11-24 11:59:53 -0300 | [diff] [blame] | 45 | struct dvb_frontend fe; |
Antti Palosaari | 07fdf7d | 2016-08-09 20:49:09 -0300 | [diff] [blame] | 46 | u8 ts_mode; |
| 47 | bool ts_clk_inv; |
| 48 | bool if_agc_polarity; |
| 49 | bool spec_inv; |
| 50 | |
Antti Palosaari | 4aa4fd8 | 2016-08-09 14:58:21 -0300 | [diff] [blame] | 51 | u64 post_bit_error_prev_dvbv3; |
Antti Palosaari | 2832fd3 | 2016-08-08 20:13:45 -0300 | [diff] [blame] | 52 | u64 post_bit_error; |
Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 53 | |
Antti Palosaari | 1d44ccb | 2011-05-25 12:42:52 -0300 | [diff] [blame] | 54 | bool ber_running; |
Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 55 | |
Antti Palosaari | 1e8f31f | 2012-07-19 21:10:36 -0300 | [diff] [blame] | 56 | #define GPIO_COUNT 3 |
| 57 | u8 gpio[GPIO_COUNT]; |
| 58 | #ifdef CONFIG_GPIOLIB |
| 59 | struct gpio_chip gpio_chip; |
| 60 | #endif |
Antti Palosaari | 2e1ea06 | 2011-05-03 20:21:59 -0300 | [diff] [blame] | 61 | |
Mauro Carvalho Chehab | 0df289a | 2015-06-07 14:53:52 -0300 | [diff] [blame] | 62 | enum fe_delivery_system delivery_system; |
Antti Palosaari | 1d44ccb | 2011-05-25 12:42:52 -0300 | [diff] [blame] | 63 | bool last_tune_failed; /* for switch between T and T2 tune */ |
Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 64 | }; |
| 65 | |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 66 | /* cxd2820r_core.c */ |
| 67 | |
| 68 | extern int cxd2820r_debug; |
| 69 | |
Antti Palosaari | 1e8f31f | 2012-07-19 21:10:36 -0300 | [diff] [blame] | 70 | int cxd2820r_gpio(struct dvb_frontend *fe, u8 *gpio); |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 71 | |
Antti Palosaari | 43e2ea6 | 2016-08-13 13:19:05 -0300 | [diff] [blame] | 72 | int cxd2820r_wr_reg_val_mask_tab(struct cxd2820r_priv *priv, |
| 73 | const struct reg_val_mask *tab, int tab_len); |
| 74 | |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 75 | int cxd2820r_wr_reg_mask(struct cxd2820r_priv *priv, u32 reg, u8 val, |
| 76 | u8 mask); |
Antti Palosaari | 2e1ea06 | 2011-05-03 20:21:59 -0300 | [diff] [blame] | 77 | |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 78 | int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val, |
| 79 | int len); |
Antti Palosaari | 2e1ea06 | 2011-05-03 20:21:59 -0300 | [diff] [blame] | 80 | |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 81 | int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val, |
| 82 | int len); |
| 83 | |
| 84 | int cxd2820r_rd_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val, |
| 85 | int len); |
| 86 | |
| 87 | int cxd2820r_wr_reg(struct cxd2820r_priv *priv, u32 reg, u8 val); |
| 88 | |
| 89 | int cxd2820r_rd_reg(struct cxd2820r_priv *priv, u32 reg, u8 *val); |
| 90 | |
| 91 | /* cxd2820r_c.c */ |
| 92 | |
Mauro Carvalho Chehab | 7e3e68b | 2016-02-04 12:58:30 -0200 | [diff] [blame] | 93 | int cxd2820r_get_frontend_c(struct dvb_frontend *fe, |
| 94 | struct dtv_frontend_properties *p); |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 95 | |
Mauro Carvalho Chehab | f311f68 | 2011-12-30 22:22:10 -0300 | [diff] [blame] | 96 | int cxd2820r_set_frontend_c(struct dvb_frontend *fe); |
Antti Palosaari | 2e1ea06 | 2011-05-03 20:21:59 -0300 | [diff] [blame] | 97 | |
Mauro Carvalho Chehab | 0df289a | 2015-06-07 14:53:52 -0300 | [diff] [blame] | 98 | int cxd2820r_read_status_c(struct dvb_frontend *fe, enum fe_status *status); |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 99 | |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 100 | int cxd2820r_init_c(struct dvb_frontend *fe); |
| 101 | |
| 102 | int cxd2820r_sleep_c(struct dvb_frontend *fe); |
| 103 | |
| 104 | int cxd2820r_get_tune_settings_c(struct dvb_frontend *fe, |
| 105 | struct dvb_frontend_tune_settings *s); |
| 106 | |
| 107 | /* cxd2820r_t.c */ |
| 108 | |
Mauro Carvalho Chehab | 7e3e68b | 2016-02-04 12:58:30 -0200 | [diff] [blame] | 109 | int cxd2820r_get_frontend_t(struct dvb_frontend *fe, |
| 110 | struct dtv_frontend_properties *p); |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 111 | |
Mauro Carvalho Chehab | f311f68 | 2011-12-30 22:22:10 -0300 | [diff] [blame] | 112 | int cxd2820r_set_frontend_t(struct dvb_frontend *fe); |
Antti Palosaari | 2e1ea06 | 2011-05-03 20:21:59 -0300 | [diff] [blame] | 113 | |
Mauro Carvalho Chehab | 0df289a | 2015-06-07 14:53:52 -0300 | [diff] [blame] | 114 | int cxd2820r_read_status_t(struct dvb_frontend *fe, enum fe_status *status); |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 115 | |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 116 | int cxd2820r_init_t(struct dvb_frontend *fe); |
| 117 | |
| 118 | int cxd2820r_sleep_t(struct dvb_frontend *fe); |
| 119 | |
| 120 | int cxd2820r_get_tune_settings_t(struct dvb_frontend *fe, |
| 121 | struct dvb_frontend_tune_settings *s); |
| 122 | |
| 123 | /* cxd2820r_t2.c */ |
| 124 | |
Mauro Carvalho Chehab | 7e3e68b | 2016-02-04 12:58:30 -0200 | [diff] [blame] | 125 | int cxd2820r_get_frontend_t2(struct dvb_frontend *fe, |
| 126 | struct dtv_frontend_properties *p); |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 127 | |
Mauro Carvalho Chehab | f311f68 | 2011-12-30 22:22:10 -0300 | [diff] [blame] | 128 | int cxd2820r_set_frontend_t2(struct dvb_frontend *fe); |
Antti Palosaari | 2e1ea06 | 2011-05-03 20:21:59 -0300 | [diff] [blame] | 129 | |
Mauro Carvalho Chehab | 0df289a | 2015-06-07 14:53:52 -0300 | [diff] [blame] | 130 | int cxd2820r_read_status_t2(struct dvb_frontend *fe, enum fe_status *status); |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 131 | |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 132 | int cxd2820r_init_t2(struct dvb_frontend *fe); |
| 133 | |
| 134 | int cxd2820r_sleep_t2(struct dvb_frontend *fe); |
| 135 | |
| 136 | int cxd2820r_get_tune_settings_t2(struct dvb_frontend *fe, |
| 137 | struct dvb_frontend_tune_settings *s); |
Antti Palosaari | 2e1ea06 | 2011-05-03 20:21:59 -0300 | [diff] [blame] | 138 | |
Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 139 | #endif /* CXD2820R_PRIV_H */ |