19a0bf528SMauro Carvalho Chehab /* 29a0bf528SMauro Carvalho Chehab * Afatech AF9013 demodulator driver 39a0bf528SMauro Carvalho Chehab * 49a0bf528SMauro Carvalho Chehab * Copyright (C) 2007 Antti Palosaari <crope@iki.fi> 59a0bf528SMauro Carvalho Chehab * Copyright (C) 2011 Antti Palosaari <crope@iki.fi> 69a0bf528SMauro Carvalho Chehab * 79a0bf528SMauro Carvalho Chehab * Thanks to Afatech who kindly provided information. 89a0bf528SMauro Carvalho Chehab * 99a0bf528SMauro Carvalho Chehab * This program is free software; you can redistribute it and/or modify 109a0bf528SMauro Carvalho Chehab * it under the terms of the GNU General Public License as published by 119a0bf528SMauro Carvalho Chehab * the Free Software Foundation; either version 2 of the License, or 129a0bf528SMauro Carvalho Chehab * (at your option) any later version. 139a0bf528SMauro Carvalho Chehab * 149a0bf528SMauro Carvalho Chehab * This program is distributed in the hope that it will be useful, 159a0bf528SMauro Carvalho Chehab * but WITHOUT ANY WARRANTY; without even the implied warranty of 169a0bf528SMauro Carvalho Chehab * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 179a0bf528SMauro Carvalho Chehab * GNU General Public License for more details. 189a0bf528SMauro Carvalho Chehab * 199a0bf528SMauro Carvalho Chehab */ 209a0bf528SMauro Carvalho Chehab 219a0bf528SMauro Carvalho Chehab #ifndef AF9013_H 229a0bf528SMauro Carvalho Chehab #define AF9013_H 239a0bf528SMauro Carvalho Chehab 249a0bf528SMauro Carvalho Chehab #include <linux/dvb/frontend.h> 259a0bf528SMauro Carvalho Chehab 2682d1ce3eSAntti Palosaari /* 2782d1ce3eSAntti Palosaari * I2C address: 0x1c, 0x1d 289a0bf528SMauro Carvalho Chehab */ 299a0bf528SMauro Carvalho Chehab 3082d1ce3eSAntti Palosaari /** 3182d1ce3eSAntti Palosaari * struct af9013_platform_data - Platform data for the af9013 driver 3282d1ce3eSAntti Palosaari * @clk: Clock frequency. 3382d1ce3eSAntti Palosaari * @tuner: Used tuner model. 3482d1ce3eSAntti Palosaari * @if_frequency: IF frequency. 3582d1ce3eSAntti Palosaari * @ts_mode: TS mode. 36eaa455f0SAntti Palosaari * @ts_output_pin: TS output pin. 3782d1ce3eSAntti Palosaari * @spec_inv: Input spectrum inverted. 3882d1ce3eSAntti Palosaari * @api_version: Firmware API version. 3982d1ce3eSAntti Palosaari * @gpio: GPIOs. 4082d1ce3eSAntti Palosaari * @get_dvb_frontend: Get DVB frontend callback. 41*be9b53c8SMauro Carvalho Chehab * 42*be9b53c8SMauro Carvalho Chehab * AF9013/5 GPIOs (mostly guessed): 43*be9b53c8SMauro Carvalho Chehab * * demod#1-gpio#0 - set demod#2 i2c-addr for dual devices 44*be9b53c8SMauro Carvalho Chehab * * demod#1-gpio#1 - xtal setting (?) 45*be9b53c8SMauro Carvalho Chehab * * demod#1-gpio#3 - tuner#1 46*be9b53c8SMauro Carvalho Chehab * * demod#2-gpio#0 - tuner#2 47*be9b53c8SMauro Carvalho Chehab * * demod#2-gpio#1 - xtal setting (?) 489a0bf528SMauro Carvalho Chehab */ 4982d1ce3eSAntti Palosaari struct af9013_platform_data { 509a0bf528SMauro Carvalho Chehab /* 519a0bf528SMauro Carvalho Chehab * 20480000, 25000000, 28000000, 28800000 529a0bf528SMauro Carvalho Chehab */ 5382d1ce3eSAntti Palosaari u32 clk; 549a0bf528SMauro Carvalho Chehab #define AF9013_TUNER_MXL5003D 3 /* MaxLinear */ 559a0bf528SMauro Carvalho Chehab #define AF9013_TUNER_MXL5005D 13 /* MaxLinear */ 569a0bf528SMauro Carvalho Chehab #define AF9013_TUNER_MXL5005R 30 /* MaxLinear */ 579a0bf528SMauro Carvalho Chehab #define AF9013_TUNER_ENV77H11D5 129 /* Panasonic */ 589a0bf528SMauro Carvalho Chehab #define AF9013_TUNER_MT2060 130 /* Microtune */ 599a0bf528SMauro Carvalho Chehab #define AF9013_TUNER_MC44S803 133 /* Freescale */ 609a0bf528SMauro Carvalho Chehab #define AF9013_TUNER_QT1010 134 /* Quantek */ 619a0bf528SMauro Carvalho Chehab #define AF9013_TUNER_UNKNOWN 140 /* for can tuners ? */ 629a0bf528SMauro Carvalho Chehab #define AF9013_TUNER_MT2060_2 147 /* Microtune */ 639a0bf528SMauro Carvalho Chehab #define AF9013_TUNER_TDA18271 156 /* NXP */ 649a0bf528SMauro Carvalho Chehab #define AF9013_TUNER_QT1010A 162 /* Quantek */ 659a0bf528SMauro Carvalho Chehab #define AF9013_TUNER_MXL5007T 177 /* MaxLinear */ 669a0bf528SMauro Carvalho Chehab #define AF9013_TUNER_TDA18218 179 /* NXP */ 679a0bf528SMauro Carvalho Chehab u8 tuner; 689a0bf528SMauro Carvalho Chehab u32 if_frequency; 6982d1ce3eSAntti Palosaari #define AF9013_TS_MODE_USB 0 7082d1ce3eSAntti Palosaari #define AF9013_TS_MODE_PARALLEL 1 7182d1ce3eSAntti Palosaari #define AF9013_TS_MODE_SERIAL 2 7282d1ce3eSAntti Palosaari u8 ts_mode; 73eaa455f0SAntti Palosaari u8 ts_output_pin; 749a0bf528SMauro Carvalho Chehab bool spec_inv; 759a0bf528SMauro Carvalho Chehab u8 api_version[4]; 769a0bf528SMauro Carvalho Chehab #define AF9013_GPIO_ON (1 << 0) 779a0bf528SMauro Carvalho Chehab #define AF9013_GPIO_EN (1 << 1) 789a0bf528SMauro Carvalho Chehab #define AF9013_GPIO_O (1 << 2) 799a0bf528SMauro Carvalho Chehab #define AF9013_GPIO_I (1 << 3) 809a0bf528SMauro Carvalho Chehab #define AF9013_GPIO_LO (AF9013_GPIO_ON|AF9013_GPIO_EN) 819a0bf528SMauro Carvalho Chehab #define AF9013_GPIO_HI (AF9013_GPIO_ON|AF9013_GPIO_EN|AF9013_GPIO_O) 829a0bf528SMauro Carvalho Chehab #define AF9013_GPIO_TUNER_ON (AF9013_GPIO_ON|AF9013_GPIO_EN) 839a0bf528SMauro Carvalho Chehab #define AF9013_GPIO_TUNER_OFF (AF9013_GPIO_ON|AF9013_GPIO_EN|AF9013_GPIO_O) 849a0bf528SMauro Carvalho Chehab u8 gpio[4]; 8582d1ce3eSAntti Palosaari 8682d1ce3eSAntti Palosaari struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *); 8782d1ce3eSAntti Palosaari 8882d1ce3eSAntti Palosaari /* private: For legacy media attach wrapper. Do not set value. */ 8982d1ce3eSAntti Palosaari bool attach_in_use; 9082d1ce3eSAntti Palosaari u8 i2c_addr; 9182d1ce3eSAntti Palosaari u32 clock; 929a0bf528SMauro Carvalho Chehab }; 939a0bf528SMauro Carvalho Chehab 9482d1ce3eSAntti Palosaari #define af9013_config af9013_platform_data 9582d1ce3eSAntti Palosaari #define AF9013_TS_USB AF9013_TS_MODE_USB 9682d1ce3eSAntti Palosaari #define AF9013_TS_PARALLEL AF9013_TS_MODE_PARALLEL 9782d1ce3eSAntti Palosaari #define AF9013_TS_SERIAL AF9013_TS_MODE_SERIAL 9882d1ce3eSAntti Palosaari 999b174527SArnd Bergmann #if IS_REACHABLE(CONFIG_DVB_AF9013) 100*be9b53c8SMauro Carvalho Chehab /** 101*be9b53c8SMauro Carvalho Chehab * Attach an af9013 demod 102*be9b53c8SMauro Carvalho Chehab * 103*be9b53c8SMauro Carvalho Chehab * @config: pointer to &struct af9013_config with demod configuration. 104*be9b53c8SMauro Carvalho Chehab * @i2c: i2c adapter to use. 105*be9b53c8SMauro Carvalho Chehab * 106*be9b53c8SMauro Carvalho Chehab * return: FE pointer on success, NULL on failure. 107*be9b53c8SMauro Carvalho Chehab */ 1089a0bf528SMauro Carvalho Chehab extern struct dvb_frontend *af9013_attach(const struct af9013_config *config, 1099a0bf528SMauro Carvalho Chehab struct i2c_adapter *i2c); 1109a0bf528SMauro Carvalho Chehab #else 1119a0bf528SMauro Carvalho Chehab static inline struct dvb_frontend *af9013_attach( 1129a0bf528SMauro Carvalho Chehab const struct af9013_config *config, struct i2c_adapter *i2c) 1139a0bf528SMauro Carvalho Chehab { 1148df379c5SAntti Palosaari pr_warn("%s: driver disabled by Kconfig\n", __func__); 1159a0bf528SMauro Carvalho Chehab return NULL; 1169a0bf528SMauro Carvalho Chehab } 1179a0bf528SMauro Carvalho Chehab #endif /* CONFIG_DVB_AF9013 */ 1189a0bf528SMauro Carvalho Chehab 1199a0bf528SMauro Carvalho Chehab #endif /* AF9013_H */ 120