summaryrefslogtreecommitdiff
path: root/src/soc/rockchip/rk3288/i2c.c
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2015-02-19 14:51:15 -0800
committerPatrick Georgi <pgeorgi@google.com>2015-04-21 08:22:28 +0200
commit2f37bd65518865688b9234afce0d467508d6f465 (patch)
treeeba5ed799de966299602b30c70d51dd40eaadd73 /src/soc/rockchip/rk3288/i2c.c
parent1f60f971fc89ef841e81b978964b38278d597b1d (diff)
downloadcoreboot-2f37bd65518865688b9234afce0d467508d6f465.tar.xz
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/: @@ expression A, V; @@ - writel(V, A) + write32(A, V) @@ expression A, V; @@ - writew(V, A) + write16(A, V) @@ expression A, V; @@ - writeb(V, A) + write8(A, V) @@ expression A; @@ - readl(A) + read32(A) @@ expression A; @@ - readb(A) + read8(A) BRANCH=none BUG=chromium:444723 TEST=None (depends on next patch) Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6 Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42 Original-Signed-off-by: Julius Werner <jwerner@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/254864 Reviewed-on: http://review.coreboot.org/9836 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/soc/rockchip/rk3288/i2c.c')
-rw-r--r--src/soc/rockchip/rk3288/i2c.c61
1 files changed, 31 insertions, 30 deletions
diff --git a/src/soc/rockchip/rk3288/i2c.c b/src/soc/rockchip/rk3288/i2c.c
index d69bb7cb78..6174aafd3c 100644
--- a/src/soc/rockchip/rk3288/i2c.c
+++ b/src/soc/rockchip/rk3288/i2c.c
@@ -97,10 +97,10 @@ static int i2c_send_start(struct rk3288_i2c_regs *reg_addr)
int timeout = I2C_TIMEOUT_US;
i2c_info("I2c Start::Send Start bit\n");
- writel(I2C_CLEANI, &reg_addr->i2c_ipd);
- writel(I2C_EN | I2C_START, &reg_addr->i2c_con);
+ write32(&reg_addr->i2c_ipd, I2C_CLEANI);
+ write32(&reg_addr->i2c_con, I2C_EN | I2C_START);
while (timeout--) {
- if (readl(&reg_addr->i2c_ipd) & I2C_STARTI)
+ if (read32(&reg_addr->i2c_ipd) & I2C_STARTI)
break;
udelay(1);
}
@@ -119,14 +119,14 @@ static int i2c_send_stop(struct rk3288_i2c_regs *reg_addr)
int timeout = I2C_TIMEOUT_US;
i2c_info("I2c Stop::Send Stop bit\n");
- writel(I2C_CLEANI, &reg_addr->i2c_ipd);
- writel(I2C_EN | I2C_STOP, &reg_addr->i2c_con);
+ write32(&reg_addr->i2c_ipd, I2C_CLEANI);
+ write32(&reg_addr->i2c_con, I2C_EN | I2C_STOP);
while (timeout--) {
- if (readl(&reg_addr->i2c_ipd) & I2C_STOPI)
+ if (read32(&reg_addr->i2c_ipd) & I2C_STOPI)
break;
udelay(1);
}
- writel(0, &reg_addr->i2c_con);
+ write32(&reg_addr->i2c_con, 0);
if (timeout <= 0) {
printk(BIOS_ERR, "I2C Stop::Send Stop Bit Timeout\n");
res = I2C_TIMEOUT;
@@ -147,8 +147,8 @@ static int i2c_read(struct rk3288_i2c_regs *reg_addr, struct i2c_seg segment)
unsigned int con = 0;
unsigned int i, j;
- writel(I2C_8BIT | segment.chip << 1 | 1, &reg_addr->i2c_mrxaddr);
- writel(0, &reg_addr->i2c_mrxraddr);
+ write32(&reg_addr->i2c_mrxaddr, I2C_8BIT | segment.chip << 1 | 1);
+ write32(&reg_addr->i2c_mrxraddr, 0);
con = I2C_MODE_TRX | I2C_EN | I2C_ACT2NAK;
while (bytes_remaining) {
bytes_transfered = MIN(bytes_remaining, 32);
@@ -157,30 +157,30 @@ static int i2c_read(struct rk3288_i2c_regs *reg_addr, struct i2c_seg segment)
con |= I2C_EN | I2C_NAK;
words_transfered = ALIGN_UP(bytes_transfered, 4) / 4;
- writel(I2C_CLEANI, &reg_addr->i2c_ipd);
- writel(con, &reg_addr->i2c_con);
- writel(bytes_transfered, &reg_addr->i2c_mrxcnt);
+ write32(&reg_addr->i2c_ipd, I2C_CLEANI);
+ write32(&reg_addr->i2c_con, con);
+ write32(&reg_addr->i2c_mrxcnt, bytes_transfered);
timeout = I2C_TIMEOUT_US;
while (timeout--) {
- if (readl(&reg_addr->i2c_ipd) & I2C_NAKRCVI) {
- writel(0, &reg_addr->i2c_mrxcnt);
- writel(0, &reg_addr->i2c_con);
+ if (read32(&reg_addr->i2c_ipd) & I2C_NAKRCVI) {
+ write32(&reg_addr->i2c_mrxcnt, 0);
+ write32(&reg_addr->i2c_con, 0);
return I2C_NOACK;
}
- if (readl(&reg_addr->i2c_ipd) & I2C_MBRFI)
+ if (read32(&reg_addr->i2c_ipd) & I2C_MBRFI)
break;
udelay(1);
}
if (timeout <= 0) {
printk(BIOS_ERR, "I2C Read::Recv Data Timeout\n");
- writel(0, &reg_addr->i2c_mrxcnt);
- writel(0, &reg_addr->i2c_con);
+ write32(&reg_addr->i2c_mrxcnt, 0);
+ write32(&reg_addr->i2c_con, 0);
return I2C_TIMEOUT;
}
for (i = 0; i < words_transfered; i++) {
- rxdata = readl(&reg_addr->rxdata[i]);
+ rxdata = read32(&reg_addr->rxdata[i]);
i2c_info("I2c Read::RXDATA[%d] = 0x%x\n", i, rxdata);
for (j = 0; j < 4; j++) {
if ((i * 4 + j) == bytes_transfered)
@@ -215,32 +215,33 @@ static int i2c_write(struct rk3288_i2c_regs *reg_addr, struct i2c_seg segment)
break;
txdata |= (*data++) << (j * 8);
} while (++j < 4);
- writel(txdata, &reg_addr->txdata[i]);
+ write32(&reg_addr->txdata[i], txdata);
j = 0;
i2c_info("I2c Write::TXDATA[%d] = 0x%x\n", i, txdata);
txdata = 0;
}
- writel(I2C_CLEANI, &reg_addr->i2c_ipd);
- writel(I2C_EN | I2C_MODE_TX | I2C_ACT2NAK, &reg_addr->i2c_con);
- writel(bytes_transfered, &reg_addr->i2c_mtxcnt);
+ write32(&reg_addr->i2c_ipd, I2C_CLEANI);
+ write32(&reg_addr->i2c_con,
+ I2C_EN | I2C_MODE_TX | I2C_ACT2NAK);
+ write32(&reg_addr->i2c_mtxcnt, bytes_transfered);
timeout = I2C_TIMEOUT_US;
while (timeout--) {
- if (readl(&reg_addr->i2c_ipd) & I2C_NAKRCVI) {
- writel(0, &reg_addr->i2c_mtxcnt);
- writel(0, &reg_addr->i2c_con);
+ if (read32(&reg_addr->i2c_ipd) & I2C_NAKRCVI) {
+ write32(&reg_addr->i2c_mtxcnt, 0);
+ write32(&reg_addr->i2c_con, 0);
return I2C_NOACK;
}
- if (readl(&reg_addr->i2c_ipd) & I2C_MBTFI)
+ if (read32(&reg_addr->i2c_ipd) & I2C_MBTFI)
break;
udelay(1);
}
if (timeout <= 0) {
printk(BIOS_ERR, "I2C Write::Send Data Timeout\n");
- writel(0, &reg_addr->i2c_mtxcnt);
- writel(0, &reg_addr->i2c_con);
+ write32(&reg_addr->i2c_mtxcnt, 0);
+ write32(&reg_addr->i2c_con, 0);
return I2C_TIMEOUT;
}
@@ -310,5 +311,5 @@ void i2c_init(unsigned int bus, unsigned int hz)
divh = clk_div * 3 / 7 - 1;
divl = clk_div - divh - 2;
assert((divh < 65536) && (divl < 65536));
- writel((divh << 16) | (divl << 0), &regs->i2c_clkdiv);
+ write32(&regs->i2c_clkdiv, (divh << 16) | (divl << 0));
}