// SPDX-License-Identifier: GPL-2.0-or-later /* * drivers/media/radio/si470x/radio-si470x-i2c.c * * I2C driver for radios with Silicon Labs Si470x FM Radio Receivers * * Copyright (c) 2009 Samsung Electronics Co.Ltd * Author: Joonyoung Shim <[email protected]> */ /* driver definitions */ #define DRIVER_AUTHOR … #define DRIVER_CARD … #define DRIVER_DESC … #define DRIVER_VERSION … /* kernel includes */ #include <linux/i2c.h> #include <linux/slab.h> #include <linux/delay.h> #include <linux/gpio/consumer.h> #include <linux/interrupt.h> #include "radio-si470x.h" /* I2C Device ID List */ static const struct i2c_device_id si470x_i2c_id[] = …; MODULE_DEVICE_TABLE(i2c, si470x_i2c_id); /************************************************************************** * Module Parameters **************************************************************************/ /* Radio Nr */ static int radio_nr = …; module_param(radio_nr, int, 0444); MODULE_PARM_DESC(…) …; /* RDS buffer blocks */ static unsigned int rds_buf = …; module_param(rds_buf, uint, 0444); MODULE_PARM_DESC(…) …; /* RDS maximum block errors */ static unsigned short max_rds_errors = …; /* 0 means 0 errors requiring correction */ /* 1 means 1-2 errors requiring correction (used by original USBRadio.exe) */ /* 2 means 3-5 errors requiring correction */ /* 3 means 6+ errors or errors in checkword, correction not possible */ module_param(max_rds_errors, ushort, 0644); MODULE_PARM_DESC(…) …; /************************************************************************** * I2C Definitions **************************************************************************/ /* Write starts with the upper byte of register 0x02 */ #define WRITE_REG_NUM … #define WRITE_INDEX(i) … /* Read starts with the upper byte of register 0x0a */ #define READ_REG_NUM … #define READ_INDEX(i) … /************************************************************************** * General Driver Functions - REGISTERs **************************************************************************/ /* * si470x_get_register - read register */ static int si470x_get_register(struct si470x_device *radio, int regnr) { … } /* * si470x_set_register - write register */ static int si470x_set_register(struct si470x_device *radio, int regnr) { … } /************************************************************************** * General Driver Functions - ENTIRE REGISTERS **************************************************************************/ /* * si470x_get_all_registers - read entire registers */ static int si470x_get_all_registers(struct si470x_device *radio) { … } /************************************************************************** * File Operations Interface **************************************************************************/ /* * si470x_fops_open - file open */ static int si470x_fops_open(struct file *file) { … } /* * si470x_fops_release - file release */ static int si470x_fops_release(struct file *file) { … } /************************************************************************** * Video4Linux Interface **************************************************************************/ /* * si470x_vidioc_querycap - query device capabilities */ static int si470x_vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *capability) { … } /************************************************************************** * I2C Interface **************************************************************************/ /* * si470x_i2c_interrupt - interrupt handler */ static irqreturn_t si470x_i2c_interrupt(int irq, void *dev_id) { … } /* * si470x_i2c_probe - probe for the device */ static int si470x_i2c_probe(struct i2c_client *client) { … } /* * si470x_i2c_remove - remove the device */ static void si470x_i2c_remove(struct i2c_client *client) { … } #ifdef CONFIG_PM_SLEEP /* * si470x_i2c_suspend - suspend the device */ static int si470x_i2c_suspend(struct device *dev) { … } /* * si470x_i2c_resume - resume the device */ static int si470x_i2c_resume(struct device *dev) { … } static SIMPLE_DEV_PM_OPS(si470x_i2c_pm, si470x_i2c_suspend, si470x_i2c_resume); #endif #if IS_ENABLED(CONFIG_OF) static const struct of_device_id si470x_of_match[] = …; MODULE_DEVICE_TABLE(of, si470x_of_match); #endif /* * si470x_i2c_driver - i2c driver interface */ static struct i2c_driver si470x_i2c_driver = …; module_i2c_driver(…) …; MODULE_LICENSE(…) …; MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(…); MODULE_VERSION(…);