aboutsummaryrefslogtreecommitdiff
path: root/sys/arm64/rockchip/rk_i2c.c
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-12-09 11:39:45 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-12-09 11:39:45 +0000
commit67350cb56a69468c118bd4ccf6e361b7ebfa9eb4 (patch)
tree093815c5d75ba2f601c6ba4d487fff29ab62f3ad /sys/arm64/rockchip/rk_i2c.c
parent0b9890fcbf4bd3cb118afc215675503889b63fb9 (diff)
parent25b4f9ad69e65a688f77df35062c81ac65a71f8d (diff)
downloadsrc-67350cb56a69468c118bd4ccf6e361b7ebfa9eb4.tar.gz
src-67350cb56a69468c118bd4ccf6e361b7ebfa9eb4.zip
Merge ^/head r340918 through r341763.
Notes
Notes: svn path=/projects/clang700-import/; revision=341764
Diffstat (limited to 'sys/arm64/rockchip/rk_i2c.c')
-rw-r--r--sys/arm64/rockchip/rk_i2c.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/arm64/rockchip/rk_i2c.c b/sys/arm64/rockchip/rk_i2c.c
index 26053b07ce24..7773a07ecd33 100644
--- a/sys/arm64/rockchip/rk_i2c.c
+++ b/sys/arm64/rockchip/rk_i2c.c
@@ -146,6 +146,9 @@ static struct ofw_compat_data compat_data[] = {
#ifdef SOC_ROCKCHIP_RK3328
{"rockchip,rk3328-i2c", 1},
#endif
+#ifdef SOC_ROCKCHIP_RK3399
+ {"rockchip,rk3399-i2c", 1},
+#endif
{NULL, 0}
};
@@ -168,15 +171,15 @@ static int rk_i2c_detach(device_t dev);
static uint32_t
rk_i2c_get_clkdiv(struct rk_i2c_softc *sc, uint64_t speed)
{
- uint64_t pclk_freq;
+ uint64_t sclk_freq;
uint32_t clkdiv;
int err;
- err = clk_get_freq(sc->pclk, &pclk_freq);
+ err = clk_get_freq(sc->sclk, &sclk_freq);
if (err != 0)
return (err);
- clkdiv = (pclk_freq / speed / RK_I2C_CLKDIV_MUL / 2) - 1;
+ clkdiv = (sclk_freq / speed / RK_I2C_CLKDIV_MUL / 2) - 1;
clkdiv &= RK_I2C_CLKDIVL_MASK;
clkdiv = clkdiv << RK_I2C_CLKDIVH_SHIFT | clkdiv;
@@ -417,7 +420,6 @@ rk_i2c_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs)
/* Write slave address */
reg = msgs[i].slave | RK_I2C_MRXADDR_VALID(0);
RK_I2C_WRITE(sc, RK_I2C_MRXADDR, reg);
-
/* Write slave register address */
for (j = 0, reg = 0; j < msgs[i].len; j++) {
reg |= (msgs[i].buf[j] & 0xff) << (j * 8);
@@ -509,6 +511,8 @@ rk_i2c_attach(device_t dev)
return (ENXIO);
}
+ clk_set_assigned(dev, ofw_bus_get_node(dev));
+
/* Activate the module clocks. */
error = clk_get_by_ofw_name(dev, 0, "i2c", &sc->sclk);
if (error != 0) {