#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/mv643xx_i2c.h>
#include <linux/platform_device.h>
#include <linux/pinctrl/consumer.h>
#include <linux/pm_runtime.h>
#include <linux/property.h>
#include <linux/reset.h>
#include <linux/io.h>
#include <linux/of.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/delay.h>
#define MV64XXX_I2C_ADDR_ADDR(val) …
#define MV64XXX_I2C_BAUD_DIV_N(val) …
#define MV64XXX_I2C_BAUD_DIV_M(val) …
#define MV64XXX_I2C_REG_CONTROL_ACK …
#define MV64XXX_I2C_REG_CONTROL_IFLG …
#define MV64XXX_I2C_REG_CONTROL_STOP …
#define MV64XXX_I2C_REG_CONTROL_START …
#define MV64XXX_I2C_REG_CONTROL_TWSIEN …
#define MV64XXX_I2C_REG_CONTROL_INTEN …
#define MV64XXX_I2C_STATUS_BUS_ERR …
#define MV64XXX_I2C_STATUS_MAST_START …
#define MV64XXX_I2C_STATUS_MAST_REPEAT_START …
#define MV64XXX_I2C_STATUS_MAST_WR_ADDR_ACK …
#define MV64XXX_I2C_STATUS_MAST_WR_ADDR_NO_ACK …
#define MV64XXX_I2C_STATUS_MAST_WR_ACK …
#define MV64XXX_I2C_STATUS_MAST_WR_NO_ACK …
#define MV64XXX_I2C_STATUS_MAST_LOST_ARB …
#define MV64XXX_I2C_STATUS_MAST_RD_ADDR_ACK …
#define MV64XXX_I2C_STATUS_MAST_RD_ADDR_NO_ACK …
#define MV64XXX_I2C_STATUS_MAST_RD_DATA_ACK …
#define MV64XXX_I2C_STATUS_MAST_RD_DATA_NO_ACK …
#define MV64XXX_I2C_STATUS_MAST_WR_ADDR_2_ACK …
#define MV64XXX_I2C_STATUS_MAST_WR_ADDR_2_NO_ACK …
#define MV64XXX_I2C_STATUS_MAST_RD_ADDR_2_ACK …
#define MV64XXX_I2C_STATUS_MAST_RD_ADDR_2_NO_ACK …
#define MV64XXX_I2C_STATUS_NO_STATUS …
#define MV64XXX_I2C_REG_TX_DATA_LO …
#define MV64XXX_I2C_REG_TX_DATA_HI …
#define MV64XXX_I2C_REG_RX_DATA_LO …
#define MV64XXX_I2C_REG_RX_DATA_HI …
#define MV64XXX_I2C_REG_BRIDGE_CONTROL …
#define MV64XXX_I2C_REG_BRIDGE_STATUS …
#define MV64XXX_I2C_REG_BRIDGE_INTR_CAUSE …
#define MV64XXX_I2C_REG_BRIDGE_INTR_MASK …
#define MV64XXX_I2C_REG_BRIDGE_TIMING …
#define MV64XXX_I2C_BRIDGE_CONTROL_WR …
#define MV64XXX_I2C_BRIDGE_CONTROL_RD …
#define MV64XXX_I2C_BRIDGE_CONTROL_ADDR_SHIFT …
#define MV64XXX_I2C_BRIDGE_CONTROL_ADDR_EXT …
#define MV64XXX_I2C_BRIDGE_CONTROL_TX_SIZE_SHIFT …
#define MV64XXX_I2C_BRIDGE_CONTROL_RX_SIZE_SHIFT …
#define MV64XXX_I2C_BRIDGE_CONTROL_ENABLE …
#define MV64XXX_I2C_BRIDGE_CONTROL_REPEATED_START …
#define MV64XXX_I2C_BRIDGE_STATUS_ERROR …
enum { … };
enum { … };
struct mv64xxx_i2c_regs { … };
struct mv64xxx_i2c_data { … };
static struct mv64xxx_i2c_regs mv64xxx_i2c_regs_mv64xxx = …;
static struct mv64xxx_i2c_regs mv64xxx_i2c_regs_sun4i = …;
static void
mv64xxx_i2c_prepare_for_io(struct mv64xxx_i2c_data *drv_data,
struct i2c_msg *msg)
{ … }
static void
mv64xxx_i2c_hw_init(struct mv64xxx_i2c_data *drv_data)
{ … }
static void
mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status)
{ … }
static void mv64xxx_i2c_send_start(struct mv64xxx_i2c_data *drv_data)
{ … }
static void
mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data)
{ … }
static void
mv64xxx_i2c_read_offload_rx_data(struct mv64xxx_i2c_data *drv_data,
struct i2c_msg *msg)
{ … }
static int
mv64xxx_i2c_intr_offload(struct mv64xxx_i2c_data *drv_data)
{ … }
static irqreturn_t
mv64xxx_i2c_intr(int irq, void *dev_id)
{ … }
static void
mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
{ … }
static void mv64xxx_i2c_wait_polling(struct mv64xxx_i2c_data *drv_data)
{ … }
static int
mv64xxx_i2c_execute_msg(struct mv64xxx_i2c_data *drv_data, struct i2c_msg *msg,
int is_last)
{ … }
static void
mv64xxx_i2c_prepare_tx(struct mv64xxx_i2c_data *drv_data)
{ … }
static int
mv64xxx_i2c_offload_xfer(struct mv64xxx_i2c_data *drv_data)
{ … }
static bool
mv64xxx_i2c_valid_offload_sz(struct i2c_msg *msg)
{ … }
static bool
mv64xxx_i2c_can_offload(struct mv64xxx_i2c_data *drv_data)
{ … }
static u32
mv64xxx_i2c_functionality(struct i2c_adapter *adap)
{ … }
static int
mv64xxx_i2c_xfer_core(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
{ … }
static int
mv64xxx_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
{ … }
static int mv64xxx_i2c_xfer_atomic(struct i2c_adapter *adap,
struct i2c_msg msgs[], int num)
{ … }
static const struct i2c_algorithm mv64xxx_i2c_algo = …;
static const struct of_device_id mv64xxx_i2c_of_match_table[] = …;
MODULE_DEVICE_TABLE(of, mv64xxx_i2c_of_match_table);
#ifdef CONFIG_OF
static int
mv64xxx_calc_freq(struct mv64xxx_i2c_data *drv_data,
const int tclk, const int n, const int m)
{ … }
static bool
mv64xxx_find_baud_factors(struct mv64xxx_i2c_data *drv_data,
const u32 req_freq, const u32 tclk)
{ … }
static int
mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,
struct device *dev)
{ … }
#else
static int
mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,
struct device *dev)
{
return -ENODEV;
}
#endif
static int mv64xxx_i2c_init_recovery_info(struct mv64xxx_i2c_data *drv_data,
struct device *dev)
{ … }
static int
mv64xxx_i2c_runtime_suspend(struct device *dev)
{ … }
static int
mv64xxx_i2c_runtime_resume(struct device *dev)
{ … }
static int
mv64xxx_i2c_probe(struct platform_device *pd)
{ … }
static void
mv64xxx_i2c_remove(struct platform_device *pd)
{ … }
static const struct dev_pm_ops mv64xxx_i2c_pm_ops = …;
static struct platform_driver mv64xxx_i2c_driver = …;
module_platform_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;