blob: a49400c0e28eac26d2a689080bb7eb209c855377 [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_H
23#define CXD2820R_H
24
25#include <linux/dvb/frontend.h>
26
27#define CXD2820R_GPIO_D (0 << 0) /* disable */
28#define CXD2820R_GPIO_E (1 << 0) /* enable */
29#define CXD2820R_GPIO_O (0 << 1) /* output */
30#define CXD2820R_GPIO_I (1 << 1) /* input */
31#define CXD2820R_GPIO_L (0 << 2) /* output low */
32#define CXD2820R_GPIO_H (1 << 2) /* output high */
33
34#define CXD2820R_TS_SERIAL 0x08
35#define CXD2820R_TS_SERIAL_MSB 0x28
36#define CXD2820R_TS_PARALLEL 0x30
37#define CXD2820R_TS_PARALLEL_MSB 0x70
38
Antti Palosaari07fdf7d2016-08-09 20:49:09 -030039/*
40 * I2C address: 0x6c, 0x6d
41 */
42
43/**
44 * struct cxd2820r_platform_data - Platform data for the cxd2820r driver
45 * @ts_mode: TS mode.
46 * @ts_clk_inv: TS clock inverted.
47 * @if_agc_polarity: IF AGC polarity.
48 * @spec_inv: Input spectrum inverted.
49 * @gpio_chip_base: GPIO.
50 * @get_dvb_frontend: Get DVB frontend.
51 */
Antti Palosaari07fdf7d2016-08-09 20:49:09 -030052struct cxd2820r_platform_data {
53 u8 ts_mode;
54 bool ts_clk_inv;
55 bool if_agc_polarity;
56 bool spec_inv;
57 int **gpio_chip_base;
58
59 struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *);
60/* private: For legacy media attach wrapper. Do not set value. */
61 bool attach_in_use;
62};
63
Mauro Carvalho Chehabbe9b53c2017-11-29 14:02:22 -050064/**
65 * struct cxd2820r_config - configuration for cxd2020r demod
66 *
67 * @i2c_address: Demodulator I2C address. Driver determines DVB-C slave I2C
68 * address automatically from master address.
69 * Default: none, must set. Values: 0x6c, 0x6d.
70 * @ts_mode: TS output mode. Default: none, must set. Values: FIXME?
71 * @ts_clock_inv: TS clock inverted. Default: 0. Values: 0, 1.
72 * @if_agc_polarity: Default: 0. Values: 0, 1
73 * @spec_inv: Spectrum inversion. Default: 0. Values: 0, 1.
74 */
Antti Palosaari27cfc852011-04-07 16:27:43 -030075struct cxd2820r_config {
76 /* Demodulator I2C address.
77 * Driver determines DVB-C slave I2C address automatically from master
78 * address.
79 * Default: none, must set
80 * Values: 0x6c, 0x6d
81 */
82 u8 i2c_address;
83
84 /* TS output mode.
85 * Default: none, must set.
86 * Values:
87 */
88 u8 ts_mode;
89
CrazyCat4d1ab182014-06-03 14:19:07 -030090 /* TS clock inverted.
91 * Default: 0
92 * Values: 0, 1
93 */
94 bool ts_clock_inv;
95
Antti Palosaari27cfc852011-04-07 16:27:43 -030096 /* IF AGC polarity.
97 * Default: 0
98 * Values: 0, 1
99 */
Antti Palosaari1d44ccb2011-05-25 12:42:52 -0300100 bool if_agc_polarity;
Antti Palosaari27cfc852011-04-07 16:27:43 -0300101
102 /* Spectrum inversion.
103 * Default: 0
104 * Values: 0, 1
105 */
Antti Palosaari1d44ccb2011-05-25 12:42:52 -0300106 bool spec_inv;
Antti Palosaari27cfc852011-04-07 16:27:43 -0300107};
108
109
Arnd Bergmann9b174522015-02-18 14:12:42 -0300110#if IS_REACHABLE(CONFIG_DVB_CXD2820R)
Mauro Carvalho Chehabbe9b53c2017-11-29 14:02:22 -0500111/**
112 * Attach a cxd2820r demod
113 *
114 * @config: pointer to &struct cxd2820r_config with demod configuration.
115 * @i2c: i2c adapter to use.
116 * @gpio_chip_base: if zero, disables GPIO setting. Otherwise, if
117 * CONFIG_GPIOLIB is set dynamically allocate
118 * gpio base; if is not set, use its value to
119 * setup the GPIO pins.
120 *
121 * return: FE pointer on success, NULL on failure.
122 */
Antti Palosaari27cfc852011-04-07 16:27:43 -0300123extern struct dvb_frontend *cxd2820r_attach(
124 const struct cxd2820r_config *config,
Antti Palosaari1e8f31f2012-07-19 21:10:36 -0300125 struct i2c_adapter *i2c,
126 int *gpio_chip_base
Antti Palosaari27cfc852011-04-07 16:27:43 -0300127);
Antti Palosaari27cfc852011-04-07 16:27:43 -0300128#else
129static inline struct dvb_frontend *cxd2820r_attach(
130 const struct cxd2820r_config *config,
Antti Palosaari1e8f31f2012-07-19 21:10:36 -0300131 struct i2c_adapter *i2c,
132 int *gpio_chip_base
Antti Palosaari27cfc852011-04-07 16:27:43 -0300133)
134{
135 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
136 return NULL;
137}
Antti Palosaari27cfc852011-04-07 16:27:43 -0300138
139#endif
140
141#endif /* CXD2820R_H */