blob: 353274524f1b29d72fa06dc66cd0466e1b8189ef [file] [log] [blame]
Antti Palosaari825b9672008-09-15 15:01:52 -03001/*
Antti Palosaaric89f66f2010-06-17 21:19:13 -03002 * Afatech AF9013 demodulator driver
Antti Palosaari825b9672008-09-15 15:01:52 -03003 *
4 * Copyright (C) 2007 Antti Palosaari <crope@iki.fi>
Antti Palosaarif571e002011-11-28 20:58:11 -03005 * Copyright (C) 2011 Antti Palosaari <crope@iki.fi>
Antti Palosaari825b9672008-09-15 15:01:52 -03006 *
7 * Thanks to Afatech who kindly provided information.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
Antti Palosaari825b9672008-09-15 15:01:52 -030019 */
20
Antti Palosaarif571e002011-11-28 20:58:11 -030021#ifndef AF9013_H
22#define AF9013_H
Antti Palosaari825b9672008-09-15 15:01:52 -030023
24#include <linux/dvb/frontend.h>
25
Antti Palosaari82d1ce32017-06-10 20:53:42 -030026/*
27 * I2C address: 0x1c, 0x1d
28 */
Antti Palosaarif571e002011-11-28 20:58:11 -030029
Antti Palosaari82d1ce32017-06-10 20:53:42 -030030/**
31 * struct af9013_platform_data - Platform data for the af9013 driver
32 * @clk: Clock frequency.
33 * @tuner: Used tuner model.
34 * @if_frequency: IF frequency.
35 * @ts_mode: TS mode.
Antti Palosaarieaa455f2017-06-13 20:32:15 -030036 * @ts_output_pin: TS output pin.
Antti Palosaari82d1ce32017-06-10 20:53:42 -030037 * @spec_inv: Input spectrum inverted.
38 * @api_version: Firmware API version.
39 * @gpio: GPIOs.
40 * @get_dvb_frontend: Get DVB frontend callback.
41 */
42struct af9013_platform_data {
Antti Palosaarif571e002011-11-28 20:58:11 -030043 /*
Antti Palosaarif571e002011-11-28 20:58:11 -030044 * 20480000, 25000000, 28000000, 28800000
45 */
Antti Palosaari82d1ce32017-06-10 20:53:42 -030046 u32 clk;
Antti Palosaarif571e002011-11-28 20:58:11 -030047#define AF9013_TUNER_MXL5003D 3 /* MaxLinear */
48#define AF9013_TUNER_MXL5005D 13 /* MaxLinear */
49#define AF9013_TUNER_MXL5005R 30 /* MaxLinear */
50#define AF9013_TUNER_ENV77H11D5 129 /* Panasonic */
51#define AF9013_TUNER_MT2060 130 /* Microtune */
52#define AF9013_TUNER_MC44S803 133 /* Freescale */
53#define AF9013_TUNER_QT1010 134 /* Quantek */
54#define AF9013_TUNER_UNKNOWN 140 /* for can tuners ? */
55#define AF9013_TUNER_MT2060_2 147 /* Microtune */
56#define AF9013_TUNER_TDA18271 156 /* NXP */
57#define AF9013_TUNER_QT1010A 162 /* Quantek */
58#define AF9013_TUNER_MXL5007T 177 /* MaxLinear */
59#define AF9013_TUNER_TDA18218 179 /* NXP */
60 u8 tuner;
Antti Palosaarif571e002011-11-28 20:58:11 -030061 u32 if_frequency;
Antti Palosaari82d1ce32017-06-10 20:53:42 -030062#define AF9013_TS_MODE_USB 0
63#define AF9013_TS_MODE_PARALLEL 1
64#define AF9013_TS_MODE_SERIAL 2
65 u8 ts_mode;
Antti Palosaarieaa455f2017-06-13 20:32:15 -030066 u8 ts_output_pin;
Antti Palosaarif571e002011-11-28 20:58:11 -030067 bool spec_inv;
Antti Palosaarif571e002011-11-28 20:58:11 -030068 u8 api_version[4];
Antti Palosaari825b9672008-09-15 15:01:52 -030069#define AF9013_GPIO_ON (1 << 0)
70#define AF9013_GPIO_EN (1 << 1)
71#define AF9013_GPIO_O (1 << 2)
72#define AF9013_GPIO_I (1 << 3)
Antti Palosaari825b9672008-09-15 15:01:52 -030073#define AF9013_GPIO_LO (AF9013_GPIO_ON|AF9013_GPIO_EN)
74#define AF9013_GPIO_HI (AF9013_GPIO_ON|AF9013_GPIO_EN|AF9013_GPIO_O)
Antti Palosaari825b9672008-09-15 15:01:52 -030075#define AF9013_GPIO_TUNER_ON (AF9013_GPIO_ON|AF9013_GPIO_EN)
76#define AF9013_GPIO_TUNER_OFF (AF9013_GPIO_ON|AF9013_GPIO_EN|AF9013_GPIO_O)
Antti Palosaari825b9672008-09-15 15:01:52 -030077 u8 gpio[4];
Antti Palosaari82d1ce32017-06-10 20:53:42 -030078
79 struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *);
80
81/* private: For legacy media attach wrapper. Do not set value. */
82 bool attach_in_use;
83 u8 i2c_addr;
84 u32 clock;
Antti Palosaari825b9672008-09-15 15:01:52 -030085};
86
Antti Palosaari82d1ce32017-06-10 20:53:42 -030087#define af9013_config af9013_platform_data
88#define AF9013_TS_USB AF9013_TS_MODE_USB
89#define AF9013_TS_PARALLEL AF9013_TS_MODE_PARALLEL
90#define AF9013_TS_SERIAL AF9013_TS_MODE_SERIAL
91
92/*
93 * AF9013/5 GPIOs (mostly guessed)
94 * demod#1-gpio#0 - set demod#2 i2c-addr for dual devices
95 * demod#1-gpio#1 - xtal setting (?)
96 * demod#1-gpio#3 - tuner#1
97 * demod#2-gpio#0 - tuner#2
98 * demod#2-gpio#1 - xtal setting (?)
99 */
100
Arnd Bergmann9b174522015-02-18 14:12:42 -0300101#if IS_REACHABLE(CONFIG_DVB_AF9013)
Antti Palosaari825b9672008-09-15 15:01:52 -0300102extern struct dvb_frontend *af9013_attach(const struct af9013_config *config,
103 struct i2c_adapter *i2c);
104#else
105static inline struct dvb_frontend *af9013_attach(
106const struct af9013_config *config, struct i2c_adapter *i2c)
107{
Antti Palosaari8df379c2012-09-12 20:23:43 -0300108 pr_warn("%s: driver disabled by Kconfig\n", __func__);
Antti Palosaari825b9672008-09-15 15:01:52 -0300109 return NULL;
110}
111#endif /* CONFIG_DVB_AF9013 */
112
Antti Palosaarif571e002011-11-28 20:58:11 -0300113#endif /* AF9013_H */