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

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * TI DAVINCI I2C adapter driver.
 *
 * Copyright (C) 2006 Texas Instruments.
 * Copyright (C) 2007 MontaVista Software Inc.
 *
 * Updated by Vinod & Sudhakar Feb 2005
 *
 * ----------------------------------------------------------------------------
 *
 * ----------------------------------------------------------------------------
 */
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/clk.h>
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/err.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/cpufreq.h>
#include <linux/gpio/consumer.h>
#include <linux/of.h>
#include <linux/platform_data/i2c-davinci.h>
#include <linux/pm_runtime.h>

/* ----- global defines ----------------------------------------------- */

#define DAVINCI_I2C_TIMEOUT
#define DAVINCI_I2C_MAX_TRIES
#define DAVINCI_I2C_OWN_ADDRESS
#define I2C_DAVINCI_INTR_ALL

#define DAVINCI_I2C_OAR_REG
#define DAVINCI_I2C_IMR_REG
#define DAVINCI_I2C_STR_REG
#define DAVINCI_I2C_CLKL_REG
#define DAVINCI_I2C_CLKH_REG
#define DAVINCI_I2C_CNT_REG
#define DAVINCI_I2C_DRR_REG
#define DAVINCI_I2C_SAR_REG
#define DAVINCI_I2C_DXR_REG
#define DAVINCI_I2C_MDR_REG
#define DAVINCI_I2C_IVR_REG
#define DAVINCI_I2C_EMDR_REG
#define DAVINCI_I2C_PSC_REG
#define DAVINCI_I2C_FUNC_REG
#define DAVINCI_I2C_DIR_REG
#define DAVINCI_I2C_DIN_REG
#define DAVINCI_I2C_DOUT_REG
#define DAVINCI_I2C_DSET_REG
#define DAVINCI_I2C_DCLR_REG

#define DAVINCI_I2C_IVR_AAS
#define DAVINCI_I2C_IVR_SCD
#define DAVINCI_I2C_IVR_XRDY
#define DAVINCI_I2C_IVR_RDR
#define DAVINCI_I2C_IVR_ARDY
#define DAVINCI_I2C_IVR_NACK
#define DAVINCI_I2C_IVR_AL

#define DAVINCI_I2C_STR_BB
#define DAVINCI_I2C_STR_RSFULL
#define DAVINCI_I2C_STR_SCD
#define DAVINCI_I2C_STR_ARDY
#define DAVINCI_I2C_STR_NACK
#define DAVINCI_I2C_STR_AL

#define DAVINCI_I2C_MDR_NACK
#define DAVINCI_I2C_MDR_STT
#define DAVINCI_I2C_MDR_STP
#define DAVINCI_I2C_MDR_MST
#define DAVINCI_I2C_MDR_TRX
#define DAVINCI_I2C_MDR_XA
#define DAVINCI_I2C_MDR_RM
#define DAVINCI_I2C_MDR_IRS

#define DAVINCI_I2C_IMR_AAS
#define DAVINCI_I2C_IMR_SCD
#define DAVINCI_I2C_IMR_XRDY
#define DAVINCI_I2C_IMR_RRDY
#define DAVINCI_I2C_IMR_ARDY
#define DAVINCI_I2C_IMR_NACK
#define DAVINCI_I2C_IMR_AL

/* set SDA and SCL as GPIO */
#define DAVINCI_I2C_FUNC_PFUNC0

/* set SCL as output when used as GPIO*/
#define DAVINCI_I2C_DIR_PDIR0
/* set SDA as output when used as GPIO*/
#define DAVINCI_I2C_DIR_PDIR1

/* read SCL GPIO level */
#define DAVINCI_I2C_DIN_PDIN0
/* read SDA GPIO level */
#define DAVINCI_I2C_DIN_PDIN1

/*set the SCL GPIO high */
#define DAVINCI_I2C_DSET_PDSET0
/*set the SDA GPIO high */
#define DAVINCI_I2C_DSET_PDSET1

/* set the SCL GPIO low */
#define DAVINCI_I2C_DCLR_PDCLR0
/* set the SDA GPIO low */
#define DAVINCI_I2C_DCLR_PDCLR1

/* timeout for pm runtime autosuspend */
#define DAVINCI_I2C_PM_TIMEOUT

struct davinci_i2c_dev {};

/* default platform data to use if not supplied in the platform_device */
static struct davinci_i2c_platform_data davinci_i2c_platform_data_default =;

static inline void davinci_i2c_write_reg(struct davinci_i2c_dev *i2c_dev,
					 int reg, u16 val)
{}

static inline u16 davinci_i2c_read_reg(struct davinci_i2c_dev *i2c_dev, int reg)
{}

static inline void davinci_i2c_reset_ctrl(struct davinci_i2c_dev *i2c_dev,
								int val)
{}

static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
{}

/*
 * This function configures I2C and brings I2C out of reset.
 * This function is called during I2C init function. This function
 * also gets called if I2C encounters any errors.
 */
static int i2c_davinci_init(struct davinci_i2c_dev *dev)
{}

/*
 * This routine does i2c bus recovery by using i2c_generic_scl_recovery
 * which is provided by I2C Bus recovery infrastructure.
 */
static void davinci_i2c_prepare_recovery(struct i2c_adapter *adap)
{}

static void davinci_i2c_unprepare_recovery(struct i2c_adapter *adap)
{}

static struct i2c_bus_recovery_info davinci_i2c_gpio_recovery_info =;

static void davinci_i2c_set_scl(struct i2c_adapter *adap, int val)
{}

static int davinci_i2c_get_scl(struct i2c_adapter *adap)
{}

static int davinci_i2c_get_sda(struct i2c_adapter *adap)
{}

static void davinci_i2c_scl_prepare_recovery(struct i2c_adapter *adap)
{}

static void davinci_i2c_scl_unprepare_recovery(struct i2c_adapter *adap)
{}

static struct i2c_bus_recovery_info davinci_i2c_scl_recovery_info =;

/*
 * Waiting for bus not busy
 */
static int i2c_davinci_wait_bus_not_busy(struct davinci_i2c_dev *dev)
{}

/*
 * Low level read/write transaction. This function is called from
 * i2c_davinci_xfer.
 */
static int
i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
{}

/*
 * Prepare controller for a transaction and call i2c_davinci_xfer_msg
 */
static int
i2c_davinci_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
{}

static u32 i2c_davinci_func(struct i2c_adapter *adap)
{}

static void terminate_read(struct davinci_i2c_dev *dev)
{}
static void terminate_write(struct davinci_i2c_dev *dev)
{}

/*
 * Interrupt service routine. This gets called whenever an I2C interrupt
 * occurs.
 */
static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)
{}

#ifdef CONFIG_CPU_FREQ
static int i2c_davinci_cpufreq_transition(struct notifier_block *nb,
				     unsigned long val, void *data)
{}

static inline int i2c_davinci_cpufreq_register(struct davinci_i2c_dev *dev)
{}

static inline void i2c_davinci_cpufreq_deregister(struct davinci_i2c_dev *dev)
{}
#else
static inline int i2c_davinci_cpufreq_register(struct davinci_i2c_dev *dev)
{
	return 0;
}

static inline void i2c_davinci_cpufreq_deregister(struct davinci_i2c_dev *dev)
{
}
#endif

static const struct i2c_algorithm i2c_davinci_algo =;

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

static int davinci_i2c_probe(struct platform_device *pdev)
{}

static void davinci_i2c_remove(struct platform_device *pdev)
{}

static int davinci_i2c_suspend(struct device *dev)
{}

static int davinci_i2c_resume(struct device *dev)
{}

static const struct dev_pm_ops davinci_i2c_pm =;

static const struct platform_device_id davinci_i2c_driver_ids[] =;
MODULE_DEVICE_TABLE(platform, davinci_i2c_driver_ids);

static struct platform_driver davinci_i2c_driver =;

/* I2C may be needed to bring up other drivers */
static int __init davinci_i2c_init_driver(void)
{}
subsys_initcall(davinci_i2c_init_driver);

static void __exit davinci_i2c_exit_driver(void)
{}
module_exit(davinci_i2c_exit_driver);

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