18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * drivers/media/radio/si4713-i2c.h 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Property and commands definitions for Si4713 radio transmitter chip. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (c) 2008 Instituto Nokia de Tecnologia - INdT 78c2ecf20Sopenharmony_ci * Contact: Eduardo Valentin <eduardo.valentin@nokia.com> 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * This file is licensed under the terms of the GNU General Public License 108c2ecf20Sopenharmony_ci * version 2. This program is licensed "as is" without any warranty of any 118c2ecf20Sopenharmony_ci * kind, whether express or implied. 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#ifndef SI4713_I2C_H 168c2ecf20Sopenharmony_ci#define SI4713_I2C_H 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 198c2ecf20Sopenharmony_ci#include <linux/regulator/consumer.h> 208c2ecf20Sopenharmony_ci#include <linux/gpio/consumer.h> 218c2ecf20Sopenharmony_ci#include <media/v4l2-subdev.h> 228c2ecf20Sopenharmony_ci#include <media/v4l2-ctrls.h> 238c2ecf20Sopenharmony_ci#include <linux/platform_data/media/si4713.h> 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#define SI4713_PRODUCT_NUMBER 0x0D 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* Command Timeouts */ 288c2ecf20Sopenharmony_ci#define DEFAULT_TIMEOUT 500 298c2ecf20Sopenharmony_ci#define TIMEOUT_SET_PROPERTY 20 308c2ecf20Sopenharmony_ci#define TIMEOUT_TX_TUNE_POWER 30000 318c2ecf20Sopenharmony_ci#define TIMEOUT_TX_TUNE 110000 328c2ecf20Sopenharmony_ci#define TIMEOUT_POWER_UP 200000 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* 358c2ecf20Sopenharmony_ci * Command and its arguments definitions 368c2ecf20Sopenharmony_ci */ 378c2ecf20Sopenharmony_ci#define SI4713_PWUP_CTSIEN (1<<7) 388c2ecf20Sopenharmony_ci#define SI4713_PWUP_GPO2OEN (1<<6) 398c2ecf20Sopenharmony_ci#define SI4713_PWUP_PATCH (1<<5) 408c2ecf20Sopenharmony_ci#define SI4713_PWUP_XOSCEN (1<<4) 418c2ecf20Sopenharmony_ci#define SI4713_PWUP_FUNC_TX 0x02 428c2ecf20Sopenharmony_ci#define SI4713_PWUP_FUNC_PATCH 0x0F 438c2ecf20Sopenharmony_ci#define SI4713_PWUP_OPMOD_ANALOG 0x50 448c2ecf20Sopenharmony_ci#define SI4713_PWUP_OPMOD_DIGITAL 0x0F 458c2ecf20Sopenharmony_ci#define SI4713_PWUP_NARGS 2 468c2ecf20Sopenharmony_ci#define SI4713_PWUP_NRESP 1 478c2ecf20Sopenharmony_ci#define SI4713_CMD_POWER_UP 0x01 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci#define SI4713_GETREV_NRESP 9 508c2ecf20Sopenharmony_ci#define SI4713_CMD_GET_REV 0x10 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#define SI4713_PWDN_NRESP 1 538c2ecf20Sopenharmony_ci#define SI4713_CMD_POWER_DOWN 0x11 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#define SI4713_SET_PROP_NARGS 5 568c2ecf20Sopenharmony_ci#define SI4713_SET_PROP_NRESP 1 578c2ecf20Sopenharmony_ci#define SI4713_CMD_SET_PROPERTY 0x12 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#define SI4713_GET_PROP_NARGS 3 608c2ecf20Sopenharmony_ci#define SI4713_GET_PROP_NRESP 4 618c2ecf20Sopenharmony_ci#define SI4713_CMD_GET_PROPERTY 0x13 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#define SI4713_GET_STATUS_NRESP 1 648c2ecf20Sopenharmony_ci#define SI4713_CMD_GET_INT_STATUS 0x14 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#define SI4713_CMD_PATCH_ARGS 0x15 678c2ecf20Sopenharmony_ci#define SI4713_CMD_PATCH_DATA 0x16 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#define SI4713_MAX_FREQ 10800 708c2ecf20Sopenharmony_ci#define SI4713_MIN_FREQ 7600 718c2ecf20Sopenharmony_ci#define SI4713_TXFREQ_NARGS 3 728c2ecf20Sopenharmony_ci#define SI4713_TXFREQ_NRESP 1 738c2ecf20Sopenharmony_ci#define SI4713_CMD_TX_TUNE_FREQ 0x30 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#define SI4713_MAX_POWER 120 768c2ecf20Sopenharmony_ci#define SI4713_MIN_POWER 88 778c2ecf20Sopenharmony_ci#define SI4713_MAX_ANTCAP 191 788c2ecf20Sopenharmony_ci#define SI4713_MIN_ANTCAP 0 798c2ecf20Sopenharmony_ci#define SI4713_TXPWR_NARGS 4 808c2ecf20Sopenharmony_ci#define SI4713_TXPWR_NRESP 1 818c2ecf20Sopenharmony_ci#define SI4713_CMD_TX_TUNE_POWER 0x31 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#define SI4713_TXMEA_NARGS 4 848c2ecf20Sopenharmony_ci#define SI4713_TXMEA_NRESP 1 858c2ecf20Sopenharmony_ci#define SI4713_CMD_TX_TUNE_MEASURE 0x32 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci#define SI4713_INTACK_MASK 0x01 888c2ecf20Sopenharmony_ci#define SI4713_TXSTATUS_NARGS 1 898c2ecf20Sopenharmony_ci#define SI4713_TXSTATUS_NRESP 8 908c2ecf20Sopenharmony_ci#define SI4713_CMD_TX_TUNE_STATUS 0x33 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define SI4713_OVERMOD_BIT (1 << 2) 938c2ecf20Sopenharmony_ci#define SI4713_IALH_BIT (1 << 1) 948c2ecf20Sopenharmony_ci#define SI4713_IALL_BIT (1 << 0) 958c2ecf20Sopenharmony_ci#define SI4713_ASQSTATUS_NARGS 1 968c2ecf20Sopenharmony_ci#define SI4713_ASQSTATUS_NRESP 5 978c2ecf20Sopenharmony_ci#define SI4713_CMD_TX_ASQ_STATUS 0x34 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci#define SI4713_RDSBUFF_MODE_MASK 0x87 1008c2ecf20Sopenharmony_ci#define SI4713_RDSBUFF_NARGS 7 1018c2ecf20Sopenharmony_ci#define SI4713_RDSBUFF_NRESP 6 1028c2ecf20Sopenharmony_ci#define SI4713_CMD_TX_RDS_BUFF 0x35 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci#define SI4713_RDSPS_PSID_MASK 0x1F 1058c2ecf20Sopenharmony_ci#define SI4713_RDSPS_NARGS 5 1068c2ecf20Sopenharmony_ci#define SI4713_RDSPS_NRESP 1 1078c2ecf20Sopenharmony_ci#define SI4713_CMD_TX_RDS_PS 0x36 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci#define SI4713_CMD_GPO_CTL 0x80 1108c2ecf20Sopenharmony_ci#define SI4713_CMD_GPO_SET 0x81 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci/* 1138c2ecf20Sopenharmony_ci * Bits from status response 1148c2ecf20Sopenharmony_ci */ 1158c2ecf20Sopenharmony_ci#define SI4713_CTS (1<<7) 1168c2ecf20Sopenharmony_ci#define SI4713_ERR (1<<6) 1178c2ecf20Sopenharmony_ci#define SI4713_RDS_INT (1<<2) 1188c2ecf20Sopenharmony_ci#define SI4713_ASQ_INT (1<<1) 1198c2ecf20Sopenharmony_ci#define SI4713_STC_INT (1<<0) 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci/* 1228c2ecf20Sopenharmony_ci * Property definitions 1238c2ecf20Sopenharmony_ci */ 1248c2ecf20Sopenharmony_ci#define SI4713_GPO_IEN 0x0001 1258c2ecf20Sopenharmony_ci#define SI4713_DIG_INPUT_FORMAT 0x0101 1268c2ecf20Sopenharmony_ci#define SI4713_DIG_INPUT_SAMPLE_RATE 0x0103 1278c2ecf20Sopenharmony_ci#define SI4713_REFCLK_FREQ 0x0201 1288c2ecf20Sopenharmony_ci#define SI4713_REFCLK_PRESCALE 0x0202 1298c2ecf20Sopenharmony_ci#define SI4713_TX_COMPONENT_ENABLE 0x2100 1308c2ecf20Sopenharmony_ci#define SI4713_TX_AUDIO_DEVIATION 0x2101 1318c2ecf20Sopenharmony_ci#define SI4713_TX_PILOT_DEVIATION 0x2102 1328c2ecf20Sopenharmony_ci#define SI4713_TX_RDS_DEVIATION 0x2103 1338c2ecf20Sopenharmony_ci#define SI4713_TX_LINE_INPUT_LEVEL 0x2104 1348c2ecf20Sopenharmony_ci#define SI4713_TX_LINE_INPUT_MUTE 0x2105 1358c2ecf20Sopenharmony_ci#define SI4713_TX_PREEMPHASIS 0x2106 1368c2ecf20Sopenharmony_ci#define SI4713_TX_PILOT_FREQUENCY 0x2107 1378c2ecf20Sopenharmony_ci#define SI4713_TX_ACOMP_ENABLE 0x2200 1388c2ecf20Sopenharmony_ci#define SI4713_TX_ACOMP_THRESHOLD 0x2201 1398c2ecf20Sopenharmony_ci#define SI4713_TX_ACOMP_ATTACK_TIME 0x2202 1408c2ecf20Sopenharmony_ci#define SI4713_TX_ACOMP_RELEASE_TIME 0x2203 1418c2ecf20Sopenharmony_ci#define SI4713_TX_ACOMP_GAIN 0x2204 1428c2ecf20Sopenharmony_ci#define SI4713_TX_LIMITER_RELEASE_TIME 0x2205 1438c2ecf20Sopenharmony_ci#define SI4713_TX_ASQ_INTERRUPT_SOURCE 0x2300 1448c2ecf20Sopenharmony_ci#define SI4713_TX_ASQ_LEVEL_LOW 0x2301 1458c2ecf20Sopenharmony_ci#define SI4713_TX_ASQ_DURATION_LOW 0x2302 1468c2ecf20Sopenharmony_ci#define SI4713_TX_ASQ_LEVEL_HIGH 0x2303 1478c2ecf20Sopenharmony_ci#define SI4713_TX_ASQ_DURATION_HIGH 0x2304 1488c2ecf20Sopenharmony_ci#define SI4713_TX_RDS_INTERRUPT_SOURCE 0x2C00 1498c2ecf20Sopenharmony_ci#define SI4713_TX_RDS_PI 0x2C01 1508c2ecf20Sopenharmony_ci#define SI4713_TX_RDS_PS_MIX 0x2C02 1518c2ecf20Sopenharmony_ci#define SI4713_TX_RDS_PS_MISC 0x2C03 1528c2ecf20Sopenharmony_ci#define SI4713_TX_RDS_PS_REPEAT_COUNT 0x2C04 1538c2ecf20Sopenharmony_ci#define SI4713_TX_RDS_PS_MESSAGE_COUNT 0x2C05 1548c2ecf20Sopenharmony_ci#define SI4713_TX_RDS_PS_AF 0x2C06 1558c2ecf20Sopenharmony_ci#define SI4713_TX_RDS_FIFO_SIZE 0x2C07 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci#define PREEMPHASIS_USA 75 1588c2ecf20Sopenharmony_ci#define PREEMPHASIS_EU 50 1598c2ecf20Sopenharmony_ci#define PREEMPHASIS_DISABLED 0 1608c2ecf20Sopenharmony_ci#define FMPE_USA 0x00 1618c2ecf20Sopenharmony_ci#define FMPE_EU 0x01 1628c2ecf20Sopenharmony_ci#define FMPE_DISABLED 0x02 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci#define POWER_UP 0x01 1658c2ecf20Sopenharmony_ci#define POWER_DOWN 0x00 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci#define MAX_RDS_PTY 31 1688c2ecf20Sopenharmony_ci#define MAX_RDS_DEVIATION 90000 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci/* 1718c2ecf20Sopenharmony_ci * PSNAME is known to be defined as 8 character sized (RDS Spec). 1728c2ecf20Sopenharmony_ci * However, there is receivers which scroll PSNAME 8xN sized. 1738c2ecf20Sopenharmony_ci */ 1748c2ecf20Sopenharmony_ci#define MAX_RDS_PS_NAME 96 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci/* 1778c2ecf20Sopenharmony_ci * MAX_RDS_RADIO_TEXT is known to be defined as 32 (2A group) or 64 (2B group) 1788c2ecf20Sopenharmony_ci * character sized (RDS Spec). 1798c2ecf20Sopenharmony_ci * However, there is receivers which scroll them as well. 1808c2ecf20Sopenharmony_ci */ 1818c2ecf20Sopenharmony_ci#define MAX_RDS_RADIO_TEXT 384 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci#define MAX_LIMITER_RELEASE_TIME 102390 1848c2ecf20Sopenharmony_ci#define MAX_LIMITER_DEVIATION 90000 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci#define MAX_PILOT_DEVIATION 90000 1878c2ecf20Sopenharmony_ci#define MAX_PILOT_FREQUENCY 19000 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci#define MAX_ACOMP_RELEASE_TIME 1000000 1908c2ecf20Sopenharmony_ci#define MAX_ACOMP_ATTACK_TIME 5000 1918c2ecf20Sopenharmony_ci#define MAX_ACOMP_THRESHOLD 0 1928c2ecf20Sopenharmony_ci#define MIN_ACOMP_THRESHOLD (-40) 1938c2ecf20Sopenharmony_ci#define MAX_ACOMP_GAIN 20 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci/* 1968c2ecf20Sopenharmony_ci * si4713_device - private data 1978c2ecf20Sopenharmony_ci */ 1988c2ecf20Sopenharmony_cistruct si4713_device { 1998c2ecf20Sopenharmony_ci /* v4l2_subdev and i2c reference (v4l2_subdev priv data) */ 2008c2ecf20Sopenharmony_ci struct v4l2_subdev sd; 2018c2ecf20Sopenharmony_ci struct v4l2_ctrl_handler ctrl_handler; 2028c2ecf20Sopenharmony_ci /* private data structures */ 2038c2ecf20Sopenharmony_ci struct { /* si4713 control cluster */ 2048c2ecf20Sopenharmony_ci /* This is one big cluster since the mute control 2058c2ecf20Sopenharmony_ci * powers off the device and after unmuting again all 2068c2ecf20Sopenharmony_ci * controls need to be set at once. The only way of doing 2078c2ecf20Sopenharmony_ci * that is by making it one big cluster. */ 2088c2ecf20Sopenharmony_ci struct v4l2_ctrl *mute; 2098c2ecf20Sopenharmony_ci struct v4l2_ctrl *rds_ps_name; 2108c2ecf20Sopenharmony_ci struct v4l2_ctrl *rds_radio_text; 2118c2ecf20Sopenharmony_ci struct v4l2_ctrl *rds_pi; 2128c2ecf20Sopenharmony_ci struct v4l2_ctrl *rds_deviation; 2138c2ecf20Sopenharmony_ci struct v4l2_ctrl *rds_pty; 2148c2ecf20Sopenharmony_ci struct v4l2_ctrl *rds_compressed; 2158c2ecf20Sopenharmony_ci struct v4l2_ctrl *rds_art_head; 2168c2ecf20Sopenharmony_ci struct v4l2_ctrl *rds_stereo; 2178c2ecf20Sopenharmony_ci struct v4l2_ctrl *rds_ta; 2188c2ecf20Sopenharmony_ci struct v4l2_ctrl *rds_tp; 2198c2ecf20Sopenharmony_ci struct v4l2_ctrl *rds_ms; 2208c2ecf20Sopenharmony_ci struct v4l2_ctrl *rds_dyn_pty; 2218c2ecf20Sopenharmony_ci struct v4l2_ctrl *rds_alt_freqs_enable; 2228c2ecf20Sopenharmony_ci struct v4l2_ctrl *rds_alt_freqs; 2238c2ecf20Sopenharmony_ci struct v4l2_ctrl *compression_enabled; 2248c2ecf20Sopenharmony_ci struct v4l2_ctrl *compression_threshold; 2258c2ecf20Sopenharmony_ci struct v4l2_ctrl *compression_gain; 2268c2ecf20Sopenharmony_ci struct v4l2_ctrl *compression_attack_time; 2278c2ecf20Sopenharmony_ci struct v4l2_ctrl *compression_release_time; 2288c2ecf20Sopenharmony_ci struct v4l2_ctrl *pilot_tone_enabled; 2298c2ecf20Sopenharmony_ci struct v4l2_ctrl *pilot_tone_freq; 2308c2ecf20Sopenharmony_ci struct v4l2_ctrl *pilot_tone_deviation; 2318c2ecf20Sopenharmony_ci struct v4l2_ctrl *limiter_enabled; 2328c2ecf20Sopenharmony_ci struct v4l2_ctrl *limiter_deviation; 2338c2ecf20Sopenharmony_ci struct v4l2_ctrl *limiter_release_time; 2348c2ecf20Sopenharmony_ci struct v4l2_ctrl *tune_preemphasis; 2358c2ecf20Sopenharmony_ci struct v4l2_ctrl *tune_pwr_level; 2368c2ecf20Sopenharmony_ci struct v4l2_ctrl *tune_ant_cap; 2378c2ecf20Sopenharmony_ci }; 2388c2ecf20Sopenharmony_ci struct completion work; 2398c2ecf20Sopenharmony_ci struct regulator *vdd; 2408c2ecf20Sopenharmony_ci struct regulator *vio; 2418c2ecf20Sopenharmony_ci struct gpio_desc *gpio_reset; 2428c2ecf20Sopenharmony_ci struct platform_device *pd; 2438c2ecf20Sopenharmony_ci u32 power_state; 2448c2ecf20Sopenharmony_ci u32 rds_enabled; 2458c2ecf20Sopenharmony_ci u32 frequency; 2468c2ecf20Sopenharmony_ci u32 preemphasis; 2478c2ecf20Sopenharmony_ci u32 stereo; 2488c2ecf20Sopenharmony_ci u32 tune_rnl; 2498c2ecf20Sopenharmony_ci}; 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_cistruct radio_si4713_platform_data { 2528c2ecf20Sopenharmony_ci struct i2c_client *subdev; 2538c2ecf20Sopenharmony_ci}; 2548c2ecf20Sopenharmony_ci#endif /* ifndef SI4713_I2C_H */ 255