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

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2011 LAPIS Semiconductor Co., Ltd.
 */

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/i2c.h>
#include <linux/fs.h>
#include <linux/io.h>
#include <linux/types.h>
#include <linux/interrupt.h>
#include <linux/jiffies.h>
#include <linux/pci.h>
#include <linux/mutex.h>
#include <linux/ktime.h>
#include <linux/slab.h>

#define PCH_EVENT_SET
#define PCH_EVENT_NONE
#define PCH_MAX_CLK
#define PCH_BUFFER_MODE_ENABLE
#define PCH_EEPROM_SW_RST_MODE_ENABLE

#define PCH_I2CSADR
#define PCH_I2CCTL
#define PCH_I2CSR
#define PCH_I2CDR
#define PCH_I2CMON
#define PCH_I2CBC
#define PCH_I2CMOD
#define PCH_I2CBUFSLV
#define PCH_I2CBUFSUB
#define PCH_I2CBUFFOR
#define PCH_I2CBUFCTL
#define PCH_I2CBUFMSK
#define PCH_I2CBUFSTA
#define PCH_I2CBUFLEV
#define PCH_I2CESRFOR
#define PCH_I2CESRCTL
#define PCH_I2CESRMSK
#define PCH_I2CESRSTA
#define PCH_I2CTMR
#define PCH_I2CSRST
#define PCH_I2CNF

#define BUS_IDLE_TIMEOUT
#define PCH_I2CCTL_I2CMEN
#define TEN_BIT_ADDR_DEFAULT
#define TEN_BIT_ADDR_MASK
#define PCH_START
#define PCH_RESTART
#define PCH_ESR_START
#define PCH_BUFF_START
#define PCH_REPSTART
#define PCH_ACK
#define PCH_GETACK
#define CLR_REG
#define I2C_RD
#define I2CMCF_BIT
#define I2CMIF_BIT
#define I2CMAL_BIT
#define I2CBMFI_BIT
#define I2CBMAL_BIT
#define I2CBMNA_BIT
#define I2CBMTO_BIT
#define I2CBMIS_BIT
#define I2CESRFI_BIT
#define I2CESRTO_BIT
#define I2CESRFIIE_BIT
#define I2CESRTOIE_BIT
#define I2CBMDZ_BIT
#define I2CBMAG_BIT
#define I2CMBB_BIT
#define BUFFER_MODE_MASK
#define I2C_ADDR_MSK
#define I2C_MSB_2B_MSK
#define FAST_MODE_CLK
#define FAST_MODE_EN
#define SUB_ADDR_LEN_MAX
#define BUF_LEN_MAX
#define PCH_BUFFER_MODE
#define EEPROM_SW_RST_MODE
#define NORMAL_INTR_ENBL
#define EEPROM_RST_INTR_ENBL
#define EEPROM_RST_INTR_DISBL
#define BUFFER_MODE_INTR_ENBL
#define BUFFER_MODE_INTR_DISBL
#define NORMAL_MODE
#define BUFFER_MODE
#define EEPROM_SR_MODE
#define I2C_TX_MODE
#define PCH_BUF_TX
#define PCH_BUF_RD
#define I2C_ERROR_MASK
#define I2CMAL_EVENT
#define I2CMCF_EVENT
#define I2CBMFI_EVENT
#define I2CBMAL_EVENT
#define I2CBMNA_EVENT
#define I2CBMTO_EVENT
#define I2CBMIS_EVENT
#define I2CESRFI_EVENT
#define I2CESRTO_EVENT
#define PCI_DEVICE_ID_PCH_I2C

#define pch_dbg(adap, fmt, arg...)

#define pch_err(adap, fmt, arg...)

#define pch_pci_err(pdev, fmt, arg...)

#define pch_pci_dbg(pdev, fmt, arg...)

/*
Set the number of I2C instance max
Intel EG20T PCH :		1ch
LAPIS Semiconductor ML7213 IOH :	2ch
LAPIS Semiconductor ML7831 IOH :	1ch
*/
#define PCH_I2C_MAX_DEV

/**
 * struct i2c_algo_pch_data - for I2C driver functionalities
 * @pch_adapter:		stores the reference to i2c_adapter structure
 * @p_adapter_info:		stores the reference to adapter_info structure
 * @pch_base_address:		specifies the remapped base address
 * @pch_buff_mode_en:		specifies if buffer mode is enabled
 * @pch_event_flag:		specifies occurrence of interrupt events
 * @pch_i2c_xfer_in_progress:	specifies whether the transfer is completed
 */
struct i2c_algo_pch_data {};

/**
 * struct adapter_info - This structure holds the adapter information for the
 *			 PCH i2c controller
 * @pch_data:		stores a list of i2c_algo_pch_data
 * @pch_i2c_suspended:	specifies whether the system is suspended or not
 *			perhaps with more lines and words.
 * @ch_num:		specifies the number of i2c instance
 *
 * pch_data has as many elements as maximum I2C channels
 */
struct adapter_info {};


static int pch_i2c_speed =; /* I2C bus speed in Kbps */
static int pch_clk =;	/* specifies I2C clock speed in KHz */
static wait_queue_head_t pch_event;
static DEFINE_MUTEX(pch_mutex);

/* Definition for ML7213 by LAPIS Semiconductor */
#define PCI_DEVICE_ID_ML7213_I2C
#define PCI_DEVICE_ID_ML7223_I2C
#define PCI_DEVICE_ID_ML7831_I2C

static const struct pci_device_id pch_pcidev_id[] =;
MODULE_DEVICE_TABLE(pci, pch_pcidev_id);

static irqreturn_t pch_i2c_handler(int irq, void *pData);

static inline void pch_setbit(void __iomem *addr, u32 offset, u32 bitmask)
{}

static inline void pch_clrbit(void __iomem *addr, u32 offset, u32 bitmask)
{}

/**
 * pch_i2c_init() - hardware initialization of I2C module
 * @adap:	Pointer to struct i2c_algo_pch_data.
 */
static void pch_i2c_init(struct i2c_algo_pch_data *adap)
{}

/**
 * pch_i2c_wait_for_bus_idle() - check the status of bus.
 * @adap:	Pointer to struct i2c_algo_pch_data.
 * @timeout:	waiting time counter (ms).
 */
static s32 pch_i2c_wait_for_bus_idle(struct i2c_algo_pch_data *adap,
				     s32 timeout)
{}

/**
 * pch_i2c_start() - Generate I2C start condition in normal mode.
 * @adap:	Pointer to struct i2c_algo_pch_data.
 *
 * Generate I2C start condition in normal mode by setting I2CCTL.I2CMSTA to 1.
 */
static void pch_i2c_start(struct i2c_algo_pch_data *adap)
{}

/**
 * pch_i2c_stop() - generate stop condition in normal mode.
 * @adap:	Pointer to struct i2c_algo_pch_data.
 */
static void pch_i2c_stop(struct i2c_algo_pch_data *adap)
{}

static int pch_i2c_wait_for_check_xfer(struct i2c_algo_pch_data *adap)
{}

/**
 * pch_i2c_repstart() - generate repeated start condition in normal mode
 * @adap:	Pointer to struct i2c_algo_pch_data.
 */
static void pch_i2c_repstart(struct i2c_algo_pch_data *adap)
{}

/**
 * pch_i2c_writebytes() - write data to I2C bus in normal mode
 * @i2c_adap:	Pointer to the struct i2c_adapter.
 * @msgs:	Pointer to the i2c message structure.
 * @last:	specifies whether last message or not.
 *		In the case of compound mode it will be 1 for last message,
 *		otherwise 0.
 * @first:	specifies whether first message or not.
 *		1 for first message otherwise 0.
 */
static s32 pch_i2c_writebytes(struct i2c_adapter *i2c_adap,
			      struct i2c_msg *msgs, u32 last, u32 first)
{}

/**
 * pch_i2c_sendack() - send ACK
 * @adap:	Pointer to struct i2c_algo_pch_data.
 */
static void pch_i2c_sendack(struct i2c_algo_pch_data *adap)
{}

/**
 * pch_i2c_sendnack() - send NACK
 * @adap:	Pointer to struct i2c_algo_pch_data.
 */
static void pch_i2c_sendnack(struct i2c_algo_pch_data *adap)
{}

/**
 * pch_i2c_restart() - Generate I2C restart condition in normal mode.
 * @adap:	Pointer to struct i2c_algo_pch_data.
 *
 * Generate I2C restart condition in normal mode by setting I2CCTL.I2CRSTA.
 */
static void pch_i2c_restart(struct i2c_algo_pch_data *adap)
{}

/**
 * pch_i2c_readbytes() - read data  from I2C bus in normal mode.
 * @i2c_adap:	Pointer to the struct i2c_adapter.
 * @msgs:	Pointer to i2c_msg structure.
 * @last:	specifies whether last message or not.
 * @first:	specifies whether first message or not.
 */
static s32 pch_i2c_readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs,
			     u32 last, u32 first)
{}

/**
 * pch_i2c_cb() - Interrupt handler Call back function
 * @adap:	Pointer to struct i2c_algo_pch_data.
 */
static void pch_i2c_cb(struct i2c_algo_pch_data *adap)
{}

/**
 * pch_i2c_handler() - interrupt handler for the PCH I2C controller
 * @irq:	irq number.
 * @pData:	cookie passed back to the handler function.
 */
static irqreturn_t pch_i2c_handler(int irq, void *pData)
{}

/**
 * pch_i2c_xfer() - Reading adnd writing data through I2C bus
 * @i2c_adap:	Pointer to the struct i2c_adapter.
 * @msgs:	Pointer to i2c_msg structure.
 * @num:	number of messages.
 */
static s32 pch_i2c_xfer(struct i2c_adapter *i2c_adap,
			struct i2c_msg *msgs, s32 num)
{}

/**
 * pch_i2c_func() - return the functionality of the I2C driver
 * @adap:	Pointer to struct i2c_algo_pch_data.
 */
static u32 pch_i2c_func(struct i2c_adapter *adap)
{}

static const struct i2c_algorithm pch_algorithm =;

/**
 * pch_i2c_disbl_int() - Disable PCH I2C interrupts
 * @adap:	Pointer to struct i2c_algo_pch_data.
 */
static void pch_i2c_disbl_int(struct i2c_algo_pch_data *adap)
{}

static int pch_i2c_probe(struct pci_dev *pdev,
				   const struct pci_device_id *id)
{}

static void pch_i2c_remove(struct pci_dev *pdev)
{}

static int __maybe_unused pch_i2c_suspend(struct device *dev)
{}

static int __maybe_unused pch_i2c_resume(struct device *dev)
{}

static SIMPLE_DEV_PM_OPS(pch_i2c_pm_ops, pch_i2c_suspend, pch_i2c_resume);

static struct pci_driver pch_pcidriver =;

module_pci_driver();

MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_AUTHOR();
module_param(pch_i2c_speed, int, (S_IRUSR | S_IWUSR));
module_param(pch_clk, int, (S_IRUSR | S_IWUSR));