linux/drivers/i2c/busses/i2c-bcm2835.c

// SPDX-License-Identifier: GPL-2.0
/*
 * BCM2835 I2C controller driver
 */

#include <linux/clk.h>
#include <linux/clkdev.h>
#include <linux/clk-provider.h>
#include <linux/completion.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/slab.h>

#define BCM2835_I2C_C
#define BCM2835_I2C_S
#define BCM2835_I2C_DLEN
#define BCM2835_I2C_A
#define BCM2835_I2C_FIFO
#define BCM2835_I2C_DIV
#define BCM2835_I2C_DEL
/*
 * 16-bit field for the number of SCL cycles to wait after rising SCL
 * before deciding the target is not responding. 0 disables the
 * timeout detection.
 */
#define BCM2835_I2C_CLKT

#define BCM2835_I2C_C_READ
#define BCM2835_I2C_C_CLEAR
#define BCM2835_I2C_C_ST
#define BCM2835_I2C_C_INTD
#define BCM2835_I2C_C_INTT
#define BCM2835_I2C_C_INTR
#define BCM2835_I2C_C_I2CEN

#define BCM2835_I2C_S_TA
#define BCM2835_I2C_S_DONE
#define BCM2835_I2C_S_TXW
#define BCM2835_I2C_S_RXR
#define BCM2835_I2C_S_TXD
#define BCM2835_I2C_S_RXD
#define BCM2835_I2C_S_TXE
#define BCM2835_I2C_S_RXF
#define BCM2835_I2C_S_ERR
#define BCM2835_I2C_S_CLKT
#define BCM2835_I2C_S_LEN

#define BCM2835_I2C_FEDL_SHIFT
#define BCM2835_I2C_REDL_SHIFT

#define BCM2835_I2C_CDIV_MIN
#define BCM2835_I2C_CDIV_MAX

struct bcm2835_i2c_dev {};

static inline void bcm2835_i2c_writel(struct bcm2835_i2c_dev *i2c_dev,
				      u32 reg, u32 val)
{}

static inline u32 bcm2835_i2c_readl(struct bcm2835_i2c_dev *i2c_dev, u32 reg)
{}

#define to_clk_bcm2835_i2c(_hw)
struct clk_bcm2835_i2c {};

static int clk_bcm2835_i2c_calc_divider(unsigned long rate,
				unsigned long parent_rate)
{}

static int clk_bcm2835_i2c_set_rate(struct clk_hw *hw, unsigned long rate,
				unsigned long parent_rate)
{}

static long clk_bcm2835_i2c_round_rate(struct clk_hw *hw, unsigned long rate,
				unsigned long *parent_rate)
{}

static unsigned long clk_bcm2835_i2c_recalc_rate(struct clk_hw *hw,
						unsigned long parent_rate)
{}

static const struct clk_ops clk_bcm2835_i2c_ops =;

static struct clk *bcm2835_i2c_register_div(struct device *dev,
					struct clk *mclk,
					struct bcm2835_i2c_dev *i2c_dev)
{}

static void bcm2835_fill_txfifo(struct bcm2835_i2c_dev *i2c_dev)
{}

static void bcm2835_drain_rxfifo(struct bcm2835_i2c_dev *i2c_dev)
{}

/*
 * Repeated Start Condition (Sr)
 * The BCM2835 ARM Peripherals datasheet mentions a way to trigger a Sr when it
 * talks about reading from a target with 10 bit address. This is achieved by
 * issuing a write, poll the I2CS.TA flag and wait for it to be set, and then
 * issue a read.
 * A comment in https://github.com/raspberrypi/linux/issues/254 shows how the
 * firmware actually does it using polling and says that it's a workaround for
 * a problem in the state machine.
 * It turns out that it is possible to use the TXW interrupt to know when the
 * transfer is active, provided the FIFO has not been prefilled.
 */

static void bcm2835_i2c_start_transfer(struct bcm2835_i2c_dev *i2c_dev)
{}

static void bcm2835_i2c_finish_transfer(struct bcm2835_i2c_dev *i2c_dev)
{}

/*
 * Note about I2C_C_CLEAR on error:
 * The I2C_C_CLEAR on errors will take some time to resolve -- if you were in
 * non-idle state and I2C_C_READ, it sets an abort_rx flag and runs through
 * the state machine to send a NACK and a STOP. Since we're setting CLEAR
 * without I2CEN, that NACK will be hanging around queued up for next time
 * we start the engine.
 */

static irqreturn_t bcm2835_i2c_isr(int this_irq, void *data)
{}

static int bcm2835_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
			    int num)
{}

static u32 bcm2835_i2c_func(struct i2c_adapter *adap)
{}

static const struct i2c_algorithm bcm2835_i2c_algo =;

/*
 * The BCM2835 was reported to have problems with clock stretching:
 * https://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html
 * https://www.raspberrypi.org/forums/viewtopic.php?p=146272
 */
static const struct i2c_adapter_quirks bcm2835_i2c_quirks =;

static int bcm2835_i2c_probe(struct platform_device *pdev)
{}

static void bcm2835_i2c_remove(struct platform_device *pdev)
{}

static const struct of_device_id bcm2835_i2c_of_match[] =;
MODULE_DEVICE_TABLE(of, bcm2835_i2c_of_match);

static struct platform_driver bcm2835_i2c_driver =;
module_platform_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_ALIAS();