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