// SPDX-License-Identifier: GPL-2.0-only /* * i2c-xiic.c * Copyright (c) 2002-2007 Xilinx Inc. * Copyright (c) 2009-2010 Intel Corporation * * This code was implemented by Mocean Laboratories AB when porting linux * to the automotive development board Russellville. The copyright holder * as seen in the header is Intel corporation. * Mocean Laboratories forked off the GNU/Linux platform work into a * separate company called Pelagicore AB, which committed the code to the * kernel.
*/
/** * struct xiic_i2c - Internal representation of the XIIC I2C bus * @dev: Pointer to device structure * @base: Memory base of the HW registers * @completion: Completion for callers * @adap: Kernel adapter representation * @tx_msg: Messages from above to be sent * @lock: Mutual exclusion * @tx_pos: Current pos in TX message * @nmsgs: Number of messages in tx_msg * @rx_msg: Current RX message * @rx_pos: Position within current RX message * @endianness: big/little-endian byte order * @clk: Pointer to AXI4-lite input clock * @state: See STATE_ * @singlemaster: Indicates bus is single master * @dynamic: Mode of controller * @prev_msg_tx: Previous message is Tx * @quirks: To hold platform specific bug info * @smbus_block_read: Flag to handle block read * @input_clk: Input clock to I2C controller * @i2c_clk: I2C SCL frequency * @atomic: Mode of transfer * @atomic_lock: Lock for atomic transfer mode * @atomic_xfer_state: See STATE_
*/ struct xiic_i2c { struct device *dev; void __iomem *base; struct completion completion; struct i2c_adapter adap; struct i2c_msg *tx_msg; struct mutex lock; unsignedint tx_pos; unsignedint nmsgs; struct i2c_msg *rx_msg; int rx_pos; enum xiic_endian endianness; struct clk *clk; enum xilinx_i2c_state state; bool singlemaster; bool dynamic; bool prev_msg_tx;
u32 quirks; bool smbus_block_read; unsignedlong input_clk; unsignedint i2c_clk; bool atomic;
spinlock_t atomic_lock; /* Lock for atomic transfer mode */ enum xilinx_i2c_state atomic_xfer_state;
};
struct xiic_version_data {
u32 quirks;
};
/** * struct timing_regs - AXI I2C timing registers that depend on I2C spec * @tsusta: setup time for a repeated START condition * @tsusto: setup time for a STOP condition * @thdsta: hold time for a repeated START condition * @tsudat: setup time for data * @tbuf: bus free time between STOP and START
*/ struct timing_regs { unsignedint tsusta; unsignedint tsusto; unsignedint thdsta; unsignedint tsudat; unsignedint tbuf;
};
/* Reg values in ns derived from I2C spec and AXI I2C PG for different frequencies */ staticconststruct timing_regs timing_reg_values[] = {
{ 5700, 5000, 4300, 550, 5000 }, /* Reg values for 100KHz */
{ 900, 900, 900, 400, 1600 }, /* Reg values for 400KHz */
{ 380, 380, 380, 170, 620 }, /* Reg values for 1MHz */
};
/* The following constants specify the depth of the FIFOs */ #define IIC_RX_FIFO_DEPTH 16 /* Rx fifo capacity */ #define IIC_TX_FIFO_DEPTH 16 /* Tx fifo capacity */
/* The following constants specify groups of interrupts that are typically * enabled or disables at the same time
*/ #define XIIC_TX_INTERRUPTS \
(XIIC_INTR_TX_ERROR_MASK | XIIC_INTR_TX_EMPTY_MASK | XIIC_INTR_TX_HALF_MASK)
/* * Tx Fifo upper bit masks.
*/ #define XIIC_TX_DYN_START_MASK 0x0100 /* 1 = Set dynamic start */ #define XIIC_TX_DYN_STOP_MASK 0x0200 /* 1 = Set dynamic stop */
/* Dynamic mode constants */ #define MAX_READ_LENGTH_DYNAMIC 255 /* Max length for dynamic read */
/* * The following constants define the register offsets for the Interrupt * registers. There are some holes in the memory map for reserved addresses * to allow other registers to be added and still match the memory map of the * interrupt controller registers
*/ #define XIIC_DGIER_OFFSET 0x1C /* Device Global Interrupt Enable Register */ #define XIIC_IISR_OFFSET 0x20 /* Interrupt Status Register */ #define XIIC_IIER_OFFSET 0x28 /* Interrupt Enable Register */ #define XIIC_RESETR_OFFSET 0x40 /* Reset Register */
#define XIIC_RESET_MASK 0xAUL
#define XIIC_PM_TIMEOUT 1000 /* ms */ /* timeout waiting for the controller to respond */ #define XIIC_I2C_TIMEOUT (msecs_to_jiffies(1000)) /* timeout waiting for the controller finish transfers */ #define XIIC_XFER_TIMEOUT (msecs_to_jiffies(10000)) /* timeout waiting for the controller finish transfers in micro seconds */ #define XIIC_XFER_TIMEOUT_US 10000000
/* * The following constant is used for the device global interrupt enable * register, to enable all interrupts for the device, this is the only bit * in the register
*/ #define XIIC_GINTR_ENABLE_MASK 0x80000000UL
ret = clk_enable(i2c->clk); if (ret) {
dev_err(dev, "Cannot enable clock.\n"); return ret;
}
return 0;
}
/* * For the register read and write functions, a little-endian and big-endian * version are necessary. Endianness is detected during the probe function. * Only the least significant byte [doublet] of the register are ever * accessed. This requires an offset of 3 [2] from the base address for * big-endian systems.
*/
/** * xiic_setclk - Sets the configured clock rate * @i2c: Pointer to the xiic device structure * * The timing register values are calculated according to the input clock * frequency and configured scl frequency. For details, please refer the * AXI I2C PG and NXP I2C Spec. * Supported frequencies are 100KHz, 400KHz and 1MHz. * * Return: 0 on success (Supported frequency selected or not configurable in SW) * -EINVAL on failure (scl frequency not supported or THIGH is 0)
*/ staticint xiic_setclk(struct xiic_i2c *i2c)
{ unsignedint clk_in_mhz; unsignedint index = 0;
u32 reg_val;
switch (i2c->i2c_clk) { case I2C_MAX_FAST_MODE_PLUS_FREQ:
index = REG_VALUES_1MHZ; break; case I2C_MAX_FAST_MODE_FREQ:
index = REG_VALUES_400KHZ; break; case I2C_MAX_STANDARD_MODE_FREQ:
index = REG_VALUES_100KHZ; break; default:
dev_warn(i2c->adap.dev.parent, "Unsupported scl frequency\n"); return -EINVAL;
}
/* * Value to be stored in a register is the number of clock cycles required * for the time duration. So the time is divided by the input clock time * period to get the number of clock cycles required. Refer Xilinx AXI I2C * PG document and I2C specification for further details.
*/
/* THIGH - Depends on SCL clock frequency(i2c_clk) as below */
reg_val = (DIV_ROUND_UP(i2c->input_clk, 2 * i2c->i2c_clk)) - 7; if (reg_val == 0) return -EINVAL;
/* * Clear the I2C_M_RECV_LEN flag to avoid setting * message length again
*/
i2c->rx_msg->flags &= ~I2C_M_RECV_LEN;
/* Set smbus_block_read flag to identify in isr */
i2c->smbus_block_read = true;
/* Read byte from rx fifo and set message length */
rxmsg_len = xiic_getreg8(i2c, XIIC_DRR_REG_OFFSET);
i2c->rx_msg->buf[i2c->rx_pos++] = rxmsg_len;
/* Check if received length is valid */ if (rxmsg_len <= I2C_SMBUS_BLOCK_MAX) { /* Set Receive fifo depth */ if (rxmsg_len > IIC_RX_FIFO_DEPTH) { /* * When Rx msg len greater than or equal to Rx fifo capacity * Receive fifo depth should set to Rx fifo capacity minus 1
*/
rfd_set = IIC_RX_FIFO_DEPTH - 1;
i2c->rx_msg->len = rxmsg_len + 1;
} elseif ((rxmsg_len == 1) ||
(rxmsg_len == 0)) { /* * Minimum of 3 bytes required to exit cleanly. 1 byte * already received, Second byte is being received. Have * to set NACK in read_rx before receiving the last byte
*/
rfd_set = 0;
i2c->rx_msg->len = SMBUS_BLOCK_READ_MIN_LEN;
} else { /* * When Rx msg len less than Rx fifo capacity * Receive fifo depth should set to Rx msg len minus 2
*/
rfd_set = rxmsg_len - 2;
i2c->rx_msg->len = rxmsg_len + 1;
}
xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rfd_set);
/* Generate stop on the bus if it is last message */ if (i2c->nmsgs == 1) {
cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET);
xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr &
~XIIC_CR_MSMS_MASK);
}
/* Make TXACK=0, clean up for next transaction */
cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET);
xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr &
~XIIC_CR_NO_ACK_MASK);
}
}
/* Read the fifo */ for (i = 0; i < bytes_to_read; i++) {
i2c->rx_msg->buf[i2c->rx_pos++] =
xiic_getreg8(i2c, XIIC_DRR_REG_OFFSET);
}
if (i2c->dynamic) {
u8 bytes;
/* Receive remaining bytes if less than fifo depth */
bytes = min_t(u8, xiic_rx_space(i2c), IIC_RX_FIFO_DEPTH);
bytes--;
xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, bytes);
}
}
if ((pend & XIIC_INTR_ARB_LOST_MASK) ||
((pend & XIIC_INTR_TX_ERROR_MASK) &&
!(pend & XIIC_INTR_RX_FULL_MASK))) {
xiic_reinit(i2c);
status = true; if (i2c->tx_msg || i2c->rx_msg)
i2c->atomic_xfer_state = STATE_ERROR;
} return status;
}
staticint xiic_tx_fifo_space(struct xiic_i2c *i2c)
{ /* return the actual space left in the FIFO */ return IIC_TX_FIFO_DEPTH - xiic_getreg8(i2c, XIIC_TFO_REG_OFFSET) - 1;
}
staticvoid xiic_fill_tx_fifo(struct xiic_i2c *i2c)
{
u8 fifo_space = xiic_tx_fifo_space(i2c); int len = xiic_tx_space(i2c);
while (len--) {
u16 data = i2c->tx_msg->buf[i2c->tx_pos++];
if (!xiic_tx_space(i2c) && i2c->nmsgs == 1) { /* last message in transfer -> STOP */ if (i2c->dynamic) {
data |= XIIC_TX_DYN_STOP_MASK;
} else {
u8 cr; int status;
/* Wait till FIFO is empty so STOP is sent last */
status = xiic_wait_tx_empty(i2c); if (status) return;
/* Write to CR to stop */
cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET);
xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr &
~XIIC_CR_MSMS_MASK);
} if (!i2c->atomic)
dev_dbg(i2c->adap.dev.parent, "%s TX STOP\n", __func__);
}
xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, data);
if (i2c->atomic && xiic_error_check(i2c)) return;
}
}
/* Get the interrupt Status from the IPIF. There is no clearing of * interrupts in the IPIF. Interrupts must be cleared at the source. * To find which interrupts are pending; AND interrupts pending with * interrupts masked.
*/
mutex_lock(&i2c->lock);
isr = xiic_getreg32(i2c, XIIC_IISR_OFFSET);
ier = xiic_getreg32(i2c, XIIC_IIER_OFFSET);
pend = isr & ier;
/* Service requesting interrupt */ if ((pend & XIIC_INTR_ARB_LOST_MASK) ||
((pend & XIIC_INTR_TX_ERROR_MASK) &&
!(pend & XIIC_INTR_RX_FULL_MASK))) { /* bus arbritration lost, or... * Transmit error _OR_ RX completed * if this happens when RX_FULL is not set * this is probably a TX error
*/
/* dynamic mode seem to suffer from problems if we just flushes * fifos and the next message is a TX with len 0 (only addr) * reset the IP instead of just flush fifos
*/
ret = xiic_reinit(i2c); if (ret < 0)
dev_dbg(i2c->adap.dev.parent, "reinit failed\n");
if (i2c->rx_msg) {
wakeup_req = 1;
wakeup_code = STATE_ERROR;
} if (i2c->tx_msg) {
wakeup_req = 1;
wakeup_code = STATE_ERROR;
} /* don't try to handle other events */ goto out;
} if (pend & XIIC_INTR_RX_FULL_MASK) { /* Receive register/FIFO is full */
xiic_read_rx(i2c); if (xiic_rx_space(i2c) == 0) { /* this is the last part of the message */
i2c->rx_msg = NULL;
/* also clear TX error if there (RX complete) */
clr |= (isr & XIIC_INTR_TX_ERROR_MASK);
dev_dbg(i2c->adap.dev.parent, "%s end of message, nmsgs: %d\n",
__func__, i2c->nmsgs);
/* send next message if this wasn't the last, * otherwise the transfer will be finialise when * receiving the bus not busy interrupt
*/ if (i2c->nmsgs > 1) {
i2c->nmsgs--;
i2c->tx_msg++;
dev_dbg(i2c->adap.dev.parent, "%s will start next...\n", __func__);
xfer_more = 1;
}
}
} if (pend & (XIIC_INTR_TX_EMPTY_MASK | XIIC_INTR_TX_HALF_MASK)) { /* Transmit register/FIFO is empty or ½ empty */
if (xiic_tx_space(i2c)) {
xiic_fill_tx_fifo(i2c);
} else { /* current message fully written */
dev_dbg(i2c->adap.dev.parent, "%s end of message sent, nmsgs: %d\n",
__func__, i2c->nmsgs); /* Don't move onto the next message until the TX FIFO empties, * to ensure that a NAK is not missed.
*/ if (i2c->nmsgs > 1 && (pend & XIIC_INTR_TX_EMPTY_MASK)) {
i2c->nmsgs--;
i2c->tx_msg++;
xfer_more = 1;
} else {
xiic_irq_dis(i2c, XIIC_INTR_TX_HALF_MASK);
dev_dbg(i2c->adap.dev.parent, "%s Got TX IRQ but no more to do...\n",
__func__);
}
}
}
if (pend & XIIC_INTR_BNB_MASK) { /* IIC bus has transitioned to not busy */
clr |= XIIC_INTR_BNB_MASK;
/* The bus is not busy, disable BusNotBusy interrupt */
xiic_irq_dis(i2c, XIIC_INTR_BNB_MASK);
if (i2c->tx_msg && i2c->smbus_block_read) {
i2c->smbus_block_read = false; /* Set requested message len=1 to indicate STATE_DONE */
i2c->tx_msg->len = 1;
}
staticint xiic_wait_not_busy(struct xiic_i2c *i2c)
{ int tries = 3; int err;
/* for instance if previous transfer was terminated due to TX error * it might be that the bus is on it's way to become available * give it at most 3 ms to wake
*/
err = xiic_bus_busy(i2c); while (err && tries--) { if (i2c->atomic)
udelay(1000); else
usleep_range(1000, 1100);
err = xiic_bus_busy(i2c);
}
return err;
}
staticvoid xiic_recv_atomic(struct xiic_i2c *i2c)
{ while (xiic_rx_space(i2c)) { if (xiic_getreg32(i2c, XIIC_IISR_OFFSET) & XIIC_INTR_RX_FULL_MASK) {
xiic_read_rx(i2c);
/* Clear Rx full and Tx error interrupts. */
xiic_irq_clr_en(i2c, XIIC_INTR_RX_FULL_MASK |
XIIC_INTR_TX_ERROR_MASK);
} if (xiic_error_check(i2c)) return;
}
/* Clear and enable Rx full interrupt. */
xiic_irq_clr_en(i2c, XIIC_INTR_RX_FULL_MASK |
XIIC_INTR_TX_ERROR_MASK);
/* * We want to get all but last byte, because the TX_ERROR IRQ * is used to indicate error ACK on the address, and * negative ack on the last received byte, so to not mix * them receive all but last. * In the case where there is only one byte to receive * we can check if ERROR and RX full is set at the same time
*/
rx_watermark = msg->len;
bytes = min_t(u8, rx_watermark, IIC_RX_FIFO_DEPTH);
if (rx_watermark > 0)
bytes--;
xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, bytes);
/* write the address */
xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET,
i2c_8bit_addr_from_msg(msg) |
XIIC_TX_DYN_START_MASK);
/* If last message, include dynamic stop bit with length */
val = (i2c->nmsgs == 1) ? XIIC_TX_DYN_STOP_MASK : 0;
val |= msg->len;
xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, val);
xiic_irq_clr_en(i2c, XIIC_INTR_BNB_MASK);
} else { /* * If previous message is Tx, make sure that Tx FIFO is empty * before starting a new transfer as the repeated start in * standard mode can corrupt the transaction if there are * still bytes to be transmitted in FIFO
*/ if (i2c->prev_msg_tx) { int status;
status = xiic_wait_tx_empty(i2c); if (status) return;
}
staticvoid xiic_send_rem_atomic(struct xiic_i2c *i2c)
{ while (xiic_tx_space(i2c)) { if (xiic_tx_fifo_space(i2c)) {
u16 data;
data = i2c->tx_msg->buf[i2c->tx_pos];
i2c->tx_pos++; if (!xiic_tx_space(i2c) && i2c->nmsgs == 1) { /* last message in transfer -> STOP */ if (i2c->dynamic) {
data |= XIIC_TX_DYN_STOP_MASK;
} else {
u8 cr; int status;
/* Wait till FIFO is empty so STOP is sent last */
status = xiic_wait_tx_empty(i2c); if (status) return;
/* Write to CR to stop */
cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET);
xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr &
~XIIC_CR_MSMS_MASK);
}
}
xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, data);
} if (xiic_error_check(i2c)) return;
}
if (i2c->dynamic) { /* write the address */
data = i2c_8bit_addr_from_msg(msg) |
XIIC_TX_DYN_START_MASK;
if (i2c->nmsgs == 1 && msg->len == 0) /* no data and last message -> add STOP */
data |= XIIC_TX_DYN_STOP_MASK;
xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, data);
/* Clear any pending Tx empty, Tx Error and then enable them */
xiic_irq_clr_en(i2c, XIIC_INTR_TX_EMPTY_MASK |
XIIC_INTR_TX_ERROR_MASK |
XIIC_INTR_BNB_MASK |
((i2c->nmsgs > 1 || xiic_tx_space(i2c)) ?
XIIC_INTR_TX_HALF_MASK : 0));
xiic_fill_tx_fifo(i2c);
} else { /* * If previous message is Tx, make sure that Tx FIFO is empty * before starting a new transfer as the repeated start in * standard mode can corrupt the transaction if there are * still bytes to be transmitted in FIFO
*/ if (i2c->prev_msg_tx) { int status;
status = xiic_wait_tx_empty(i2c); if (status) return;
} /* Check if RSTA should be set */
cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); if (cr & XIIC_CR_MSMS_MASK) { /* Already a master, RSTA should be set */
xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, (cr |
XIIC_CR_REPEATED_START_MASK |
XIIC_CR_DIR_IS_TX_MASK) &
~(XIIC_CR_NO_ACK_MASK));
}
/* Write address to FIFO */
data = i2c_8bit_addr_from_msg(msg);
xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, data);
/* Fill fifo */
xiic_fill_tx_fifo(i2c);
if ((cr & XIIC_CR_MSMS_MASK) == 0) { /* Start Tx by writing to CR */
cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET);
xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr |
XIIC_CR_MSMS_MASK |
XIIC_CR_DIR_IS_TX_MASK);
}
/* Clear any pending Tx empty, Tx Error and then enable them */
xiic_irq_clr_en(i2c, XIIC_INTR_TX_EMPTY_MASK |
XIIC_INTR_TX_ERROR_MASK |
XIIC_INTR_BNB_MASK);
}
i2c->prev_msg_tx = true;
if (i2c->atomic && !i2c->atomic_xfer_state)
xiic_send_rem_atomic(i2c);
}
staticvoid __xiic_start_xfer(struct xiic_i2c *i2c)
{ int fifo_space = xiic_tx_fifo_space(i2c);
i2c->rx_pos = 0;
i2c->tx_pos = 0;
i2c->state = STATE_START; if (i2c->tx_msg->flags & I2C_M_RD) { /* we dont date putting several reads in the FIFO */
xiic_start_recv(i2c);
} else {
xiic_start_send(i2c);
}
}
staticint xiic_start_xfer(struct xiic_i2c *i2c, struct i2c_msg *msgs, int num)
{ bool broken_read, max_read_len, smbus_blk_read; int ret, count;
if (i2c->atomic)
spin_lock(&i2c->atomic_lock); else
mutex_lock(&i2c->lock);
if (i2c->tx_msg || i2c->rx_msg) {
dev_err(i2c->adap.dev.parent, "cannot start a transfer while busy\n");
ret = -EBUSY; goto out;
}
i2c->atomic_xfer_state = STATE_DONE;
/* In single master mode bus can only be busy, when in use by this * driver. If the register indicates bus being busy for some reason we * should ignore it, since bus will never be released and i2c will be * stuck forever.
*/ if (!i2c->singlemaster) {
ret = xiic_wait_not_busy(i2c); if (ret) { /* If the bus is stuck in a busy state, such as due to spurious low * pulses on the bus causing a false start condition to be detected, * then try to recover by re-initializing the controller and check * again if the bus is still busy.
*/
dev_warn(i2c->adap.dev.parent, "I2C bus busy timeout, reinitializing\n");
ret = xiic_reinit(i2c); if (ret) goto out;
ret = xiic_wait_not_busy(i2c); if (ret) goto out;
}
}
if (!i2c->atomic)
init_completion(&i2c->completion);
/* Decide standard mode or Dynamic mode */
i2c->dynamic = true;
/* Initialize prev message type */
i2c->prev_msg_tx = false;
/* * Scan through nmsgs, use dynamic mode when none of the below three * conditions occur. We need standard mode even if one condition holds * true in the entire array of messages in a single transfer. * If read transaction as dynamic mode is broken for delayed reads * in xlnx,axi-iic-2.0 / xlnx,xps-iic-2.00.a IP versions. * If read length is > 255 bytes. * If smbus_block_read transaction.
*/ for (count = 0; count < i2c->nmsgs; count++) {
broken_read = (i2c->quirks & DYNAMIC_MODE_READ_BROKEN_BIT) &&
(i2c->tx_msg[count].flags & I2C_M_RD);
max_read_len = (i2c->tx_msg[count].flags & I2C_M_RD) &&
(i2c->tx_msg[count].len > MAX_READ_LENGTH_DYNAMIC);
smbus_blk_read = (i2c->tx_msg[count].flags & I2C_M_RECV_LEN);
/* SCL frequency configuration */
i2c->input_clk = clk_get_rate(i2c->clk);
ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency",
&i2c->i2c_clk); /* If clock-frequency not specified in DT, do not configure in SW */ if (ret || i2c->i2c_clk > I2C_MAX_FAST_MODE_PLUS_FREQ)
i2c->i2c_clk = 0;
ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
xiic_process, IRQF_ONESHOT,
pdev->name, i2c);
/* * Detect endianness * Try to reset the TX FIFO. Then check the EMPTY flag. If it is not * set, assume that the endianness was wrong and swap.
*/
i2c->endianness = LITTLE;
xiic_setreg32(i2c, XIIC_CR_REG_OFFSET, XIIC_CR_TX_FIFO_RESET_MASK); /* Reset is cleared in xiic_reinit */
sr = xiic_getreg32(i2c, XIIC_SR_REG_OFFSET); if (!(sr & XIIC_SR_TX_FIFO_EMPTY_MASK))
i2c->endianness = BIG;
ret = xiic_reinit(i2c); if (ret < 0) {
dev_err_probe(&pdev->dev, ret, "Cannot xiic_reinit\n"); goto err_pm_disable;
}
/* add i2c adapter to i2c tree */
ret = i2c_add_adapter(&i2c->adap); if (ret) {
xiic_deinit(i2c); goto err_pm_disable;
}
if (pdata) { /* add in known devices to the bus */ for (i = 0; i < pdata->num_devices; i++)
i2c_new_client_device(&i2c->adap, pdata->devices + i);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.