#define I2C_FREQUENCY 400000
#define ALT_CPU_FREQ 83333333
-static volatile struct cobalt_i2c_regs __iomem *
+static struct cobalt_i2c_regs __iomem *
cobalt_i2c_regs(struct cobalt *cobalt, unsigned idx)
{
switch (idx) {
case 0:
default:
- return (volatile struct cobalt_i2c_regs __iomem *)
+ return (struct cobalt_i2c_regs __iomem *)
(cobalt->bar1 + COBALT_I2C_0_BASE);
case 1:
- return (volatile struct cobalt_i2c_regs __iomem *)
+ return (struct cobalt_i2c_regs __iomem *)
(cobalt->bar1 + COBALT_I2C_1_BASE);
case 2:
- return (volatile struct cobalt_i2c_regs __iomem *)
+ return (struct cobalt_i2c_regs __iomem *)
(cobalt->bar1 + COBALT_I2C_2_BASE);
case 3:
- return (volatile struct cobalt_i2c_regs __iomem *)
+ return (struct cobalt_i2c_regs __iomem *)
(cobalt->bar1 + COBALT_I2C_3_BASE);
case 4:
- return (volatile struct cobalt_i2c_regs __iomem *)
+ return (struct cobalt_i2c_regs __iomem *)
(cobalt->bar1 + COBALT_I2C_HSMA_BASE);
}
}
/* Do low-level i2c byte transfer.
* Returns -1 in case of an error or 0 otherwise.
*/
-static int cobalt_tx_bytes(volatile struct cobalt_i2c_regs __iomem *regs,
+static int cobalt_tx_bytes(struct cobalt_i2c_regs __iomem *regs,
struct i2c_adapter *adap, bool start, bool stop,
u8 *data, u16 len)
{
for (i = 0; i < len; i++) {
/* Setup data */
- regs->txr_rxr = data[i];
+ iowrite8(data[i], ®s->txr_rxr);
/* Setup command */
if (i == 0 && start != 0) {
}
/* Execute command */
- regs->cr_sr = cmd;
+ iowrite8(cmd, ®s->cr_sr);
/* Wait for transfer to complete (TIP = 0) */
start_time = jiffies;
- status = regs->cr_sr;
+ status = ioread8(®s->cr_sr);
while (status & M00018_SR_BITMAP_TIP_MSK) {
if (time_after(jiffies, start_time + adap->timeout))
return -ETIMEDOUT;
cond_resched();
- status = regs->cr_sr;
+ status = ioread8(®s->cr_sr);
}
/* Verify ACK */
/* Do low-level i2c byte read.
* Returns -1 in case of an error or 0 otherwise.
*/
-static int cobalt_rx_bytes(volatile struct cobalt_i2c_regs __iomem *regs,
+static int cobalt_rx_bytes(struct cobalt_i2c_regs __iomem *regs,
struct i2c_adapter *adap, bool start, bool stop,
u8 *data, u16 len)
{
cmd |= M00018_CR_BITMAP_ACK_MSK;
/* Execute command */
- regs->cr_sr = cmd;
+ iowrite8(cmd, ®s->cr_sr);
/* Wait for transfer to complete (TIP = 0) */
start_time = jiffies;
- status = regs->cr_sr;
+ status = ioread8(®s->cr_sr);
while (status & M00018_SR_BITMAP_TIP_MSK) {
if (time_after(jiffies, start_time + adap->timeout))
return -ETIMEDOUT;
cond_resched();
- status = regs->cr_sr;
+ status = ioread8(®s->cr_sr);
}
/* Verify arbitration */
}
/* Store data */
- data[i] = regs->txr_rxr;
+ data[i] = ioread8(®s->txr_rxr);
}
return 0;
}
* The m00018 stop isn't doing the right thing (wrong timing).
* So instead send a start condition, 8 zeroes and a stop condition.
*/
-static int cobalt_stop(volatile struct cobalt_i2c_regs __iomem *regs,
+static int cobalt_stop(struct cobalt_i2c_regs __iomem *regs,
struct i2c_adapter *adap)
{
u8 data = 0;
struct i2c_msg msgs[], int num)
{
struct cobalt_i2c_data *data = adap->algo_data;
- volatile struct cobalt_i2c_regs __iomem *regs = data->regs;
+ struct cobalt_i2c_regs __iomem *regs = data->regs;
struct i2c_msg *pmsg;
unsigned short flags;
int ret = 0;
prescale = ((ALT_CPU_FREQ) / (5 * I2C_FREQUENCY)) - 1;
for (i = 0; i < COBALT_NUM_ADAPTERS; i++) {
- volatile struct cobalt_i2c_regs __iomem *regs =
+ struct cobalt_i2c_regs __iomem *regs =
cobalt_i2c_regs(cobalt, i);
struct i2c_adapter *adap = &cobalt->i2c_adap[i];
/* Disable I2C */
- regs->cr_sr = M00018_CTR_BITMAP_EN_MSK;
- regs->ctr = 0;
- regs->cr_sr = 0;
+ iowrite8(M00018_CTR_BITMAP_EN_MSK, ®s->cr_sr);
+ iowrite8(0, ®s->ctr);
+ iowrite8(0, ®s->cr_sr);
start_time = jiffies;
do {
}
return -ETIMEDOUT;
}
- status = regs->cr_sr;
+ status = ioread8(®s->cr_sr);
} while (status & M00018_SR_BITMAP_TIP_MSK);
/* Disable I2C */
- regs->ctr = 0;
- regs->cr_sr = 0;
+ iowrite8(0, ®s->ctr);
+ iowrite8(0, ®s->cr_sr);
/* Calculate i2c prescaler */
- regs->prerlo = prescale & 0xff;
- regs->prerhi = (prescale >> 8) & 0xff;
+ iowrite8(prescale & 0xff, ®s->prerlo);
+ iowrite8((prescale >> 8) & 0xff, ®s->prerhi);
/* Enable I2C, interrupts disabled */
- regs->ctr = M00018_CTR_BITMAP_EN_MSK;
+ iowrite8(M00018_CTR_BITMAP_EN_MSK, ®s->ctr);
/* Setup algorithm for adapter */
cobalt->i2c_data[i].cobalt = cobalt;
cobalt->i2c_data[i].regs = regs;