#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#define I2C_CTL …
#define I2C_ADDR_CFG …
#define I2C_COUNT …
#define I2C_RX …
#define I2C_TX …
#define I2C_STATUS …
#define I2C_HSMODE_CFG …
#define I2C_VERSION …
#define ADDR_DVD0 …
#define ADDR_DVD1 …
#define ADDR_STA0_DVD …
#define ADDR_RST …
#define STP_EN …
#define FIFO_AF_LVL_MASK …
#define FIFO_AF_LVL …
#define FIFO_AE_LVL_MASK …
#define FIFO_AE_LVL …
#define I2C_DMA_EN …
#define FULL_INTEN …
#define EMPTY_INTEN …
#define I2C_DVD_OPT …
#define I2C_OUT_OPT …
#define I2C_TRIM_OPT …
#define I2C_HS_MODE …
#define I2C_MODE …
#define I2C_EN …
#define I2C_INT_EN …
#define I2C_START …
#define SDA_IN …
#define SCL_IN …
#define FIFO_FULL …
#define FIFO_EMPTY …
#define I2C_INT …
#define I2C_RX_ACK …
#define I2C_BUSY …
#define I2C_RST …
#define I2C_FIFO_DEEP …
#define I2C_FIFO_FULL_THLD …
#define I2C_FIFO_EMPTY_THLD …
#define I2C_DATA_STEP …
#define I2C_ADDR_DVD0_CALC(high, low) …
#define I2C_ADDR_DVD1_CALC(high, low) …
#define SPRD_I2C_PM_TIMEOUT …
#define I2C_XFER_TIMEOUT …
struct sprd_i2c { … };
static void sprd_i2c_set_count(struct sprd_i2c *i2c_dev, u32 count)
{ … }
static void sprd_i2c_send_stop(struct sprd_i2c *i2c_dev, int stop)
{ … }
static void sprd_i2c_clear_start(struct sprd_i2c *i2c_dev)
{ … }
static void sprd_i2c_clear_ack(struct sprd_i2c *i2c_dev)
{ … }
static void sprd_i2c_clear_irq(struct sprd_i2c *i2c_dev)
{ … }
static void sprd_i2c_reset_fifo(struct sprd_i2c *i2c_dev)
{ … }
static void sprd_i2c_set_devaddr(struct sprd_i2c *i2c_dev, struct i2c_msg *m)
{ … }
static void sprd_i2c_write_bytes(struct sprd_i2c *i2c_dev, u8 *buf, u32 len)
{ … }
static void sprd_i2c_read_bytes(struct sprd_i2c *i2c_dev, u8 *buf, u32 len)
{ … }
static void sprd_i2c_set_full_thld(struct sprd_i2c *i2c_dev, u32 full_thld)
{
u32 tmp = readl(i2c_dev->base + I2C_CTL);
tmp &= ~FIFO_AF_LVL_MASK;
tmp |= full_thld << FIFO_AF_LVL;
writel(tmp, i2c_dev->base + I2C_CTL);
};
static void sprd_i2c_set_empty_thld(struct sprd_i2c *i2c_dev, u32 empty_thld)
{
u32 tmp = readl(i2c_dev->base + I2C_CTL);
tmp &= ~FIFO_AE_LVL_MASK;
tmp |= empty_thld << FIFO_AE_LVL;
writel(tmp, i2c_dev->base + I2C_CTL);
};
static void sprd_i2c_set_fifo_full_int(struct sprd_i2c *i2c_dev, int enable)
{
u32 tmp = readl(i2c_dev->base + I2C_CTL);
if (enable)
tmp |= FULL_INTEN;
else
tmp &= ~FULL_INTEN;
writel(tmp, i2c_dev->base + I2C_CTL);
};
static void sprd_i2c_set_fifo_empty_int(struct sprd_i2c *i2c_dev, int enable)
{
u32 tmp = readl(i2c_dev->base + I2C_CTL);
if (enable)
tmp |= EMPTY_INTEN;
else
tmp &= ~EMPTY_INTEN;
writel(tmp, i2c_dev->base + I2C_CTL);
};
static void sprd_i2c_opt_start(struct sprd_i2c *i2c_dev)
{ … }
static void sprd_i2c_opt_mode(struct sprd_i2c *i2c_dev, int rw)
{ … }
static void sprd_i2c_data_transfer(struct sprd_i2c *i2c_dev)
{ … }
static int sprd_i2c_handle_msg(struct i2c_adapter *i2c_adap,
struct i2c_msg *msg, bool is_last_msg)
{ … }
static int sprd_i2c_xfer(struct i2c_adapter *i2c_adap,
struct i2c_msg *msgs, int num)
{ … }
static u32 sprd_i2c_func(struct i2c_adapter *adap)
{ … }
static const struct i2c_algorithm sprd_i2c_algo = …;
static void sprd_i2c_set_clk(struct sprd_i2c *i2c_dev, u32 freq)
{ … }
static void sprd_i2c_enable(struct sprd_i2c *i2c_dev)
{ … }
static irqreturn_t sprd_i2c_isr_thread(int irq, void *dev_id)
{ … }
static irqreturn_t sprd_i2c_isr(int irq, void *dev_id)
{ … }
static int sprd_i2c_clk_init(struct sprd_i2c *i2c_dev)
{ … }
static int sprd_i2c_probe(struct platform_device *pdev)
{ … }
static void sprd_i2c_remove(struct platform_device *pdev)
{ … }
static int __maybe_unused sprd_i2c_suspend_noirq(struct device *dev)
{ … }
static int __maybe_unused sprd_i2c_resume_noirq(struct device *dev)
{ … }
static int __maybe_unused sprd_i2c_runtime_suspend(struct device *dev)
{ … }
static int __maybe_unused sprd_i2c_runtime_resume(struct device *dev)
{ … }
static const struct dev_pm_ops sprd_i2c_pm_ops = …;
static const struct of_device_id sprd_i2c_of_match[] = …;
MODULE_DEVICE_TABLE(of, sprd_i2c_of_match);
static struct platform_driver sprd_i2c_driver = …;
module_platform_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;