1 /* 2 * Afatech AF9013 demodulator driver 3 * 4 * Copyright (C) 2007 Antti Palosaari <crope@iki.fi> 5 * Copyright (C) 2011 Antti Palosaari <crope@iki.fi> 6 * 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 * 19 */ 20 21 #ifndef AF9013_H 22 #define AF9013_H 23 24 #include <linux/dvb/frontend.h> 25 26 /* 27 * I2C address: 0x1c, 0x1d 28 */ 29 30 /** 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. 36 * @ts_output_pin: TS output pin. 37 * @spec_inv: Input spectrum inverted. 38 * @api_version: Firmware API version. 39 * @gpio: GPIOs. 40 * @get_dvb_frontend: Get DVB frontend callback. 41 * 42 * AF9013/5 GPIOs (mostly guessed): 43 * * demod#1-gpio#0 - set demod#2 i2c-addr for dual devices 44 * * demod#1-gpio#1 - xtal setting (?) 45 * * demod#1-gpio#3 - tuner#1 46 * * demod#2-gpio#0 - tuner#2 47 * * demod#2-gpio#1 - xtal setting (?) 48 */ 49 struct af9013_platform_data { 50 /* 51 * 20480000, 25000000, 28000000, 28800000 52 */ 53 u32 clk; 54 #define AF9013_TUNER_MXL5003D 3 /* MaxLinear */ 55 #define AF9013_TUNER_MXL5005D 13 /* MaxLinear */ 56 #define AF9013_TUNER_MXL5005R 30 /* MaxLinear */ 57 #define AF9013_TUNER_ENV77H11D5 129 /* Panasonic */ 58 #define AF9013_TUNER_MT2060 130 /* Microtune */ 59 #define AF9013_TUNER_MC44S803 133 /* Freescale */ 60 #define AF9013_TUNER_QT1010 134 /* Quantek */ 61 #define AF9013_TUNER_UNKNOWN 140 /* for can tuners ? */ 62 #define AF9013_TUNER_MT2060_2 147 /* Microtune */ 63 #define AF9013_TUNER_TDA18271 156 /* NXP */ 64 #define AF9013_TUNER_QT1010A 162 /* Quantek */ 65 #define AF9013_TUNER_MXL5007T 177 /* MaxLinear */ 66 #define AF9013_TUNER_TDA18218 179 /* NXP */ 67 u8 tuner; 68 u32 if_frequency; 69 #define AF9013_TS_MODE_USB 0 70 #define AF9013_TS_MODE_PARALLEL 1 71 #define AF9013_TS_MODE_SERIAL 2 72 u8 ts_mode; 73 u8 ts_output_pin; 74 bool spec_inv; 75 u8 api_version[4]; 76 #define AF9013_GPIO_ON (1 << 0) 77 #define AF9013_GPIO_EN (1 << 1) 78 #define AF9013_GPIO_O (1 << 2) 79 #define AF9013_GPIO_I (1 << 3) 80 #define AF9013_GPIO_LO (AF9013_GPIO_ON|AF9013_GPIO_EN) 81 #define AF9013_GPIO_HI (AF9013_GPIO_ON|AF9013_GPIO_EN|AF9013_GPIO_O) 82 #define AF9013_GPIO_TUNER_ON (AF9013_GPIO_ON|AF9013_GPIO_EN) 83 #define AF9013_GPIO_TUNER_OFF (AF9013_GPIO_ON|AF9013_GPIO_EN|AF9013_GPIO_O) 84 u8 gpio[4]; 85 86 struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *); 87 88 /* private: For legacy media attach wrapper. Do not set value. */ 89 bool attach_in_use; 90 u8 i2c_addr; 91 u32 clock; 92 }; 93 94 #define af9013_config af9013_platform_data 95 #define AF9013_TS_USB AF9013_TS_MODE_USB 96 #define AF9013_TS_PARALLEL AF9013_TS_MODE_PARALLEL 97 #define AF9013_TS_SERIAL AF9013_TS_MODE_SERIAL 98 99 #if IS_REACHABLE(CONFIG_DVB_AF9013) 100 /** 101 * Attach an af9013 demod 102 * 103 * @config: pointer to &struct af9013_config with demod configuration. 104 * @i2c: i2c adapter to use. 105 * 106 * return: FE pointer on success, NULL on failure. 107 */ 108 extern struct dvb_frontend *af9013_attach(const struct af9013_config *config, 109 struct i2c_adapter *i2c); 110 #else 111 static inline struct dvb_frontend *af9013_attach( 112 const struct af9013_config *config, struct i2c_adapter *i2c) 113 { 114 pr_warn("%s: driver disabled by Kconfig\n", __func__); 115 return NULL; 116 } 117 #endif /* CONFIG_DVB_AF9013 */ 118 119 #endif /* AF9013_H */ 120