summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2018-06-10 09:25:51 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2018-06-10 09:25:51 +0000
commitb6e0d0b03279ca885ad6e2759078f12698a0778e (patch)
tree57130e34e53191d15bff9972531d76e13c5f696c /sys
parent553f236eb5289308ffde7e12e938136e489b896b (diff)
Extract the i2c bitrate from imxiic(4)'s clock-frequency attribute.
ok kettenis@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/fdt/imxiic.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/dev/fdt/imxiic.c b/sys/dev/fdt/imxiic.c
index ae9aa9f1700..930d6fb0ef9 100644
--- a/sys/dev/fdt/imxiic.c
+++ b/sys/dev/fdt/imxiic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxiic.c,v 1.3 2018/05/18 15:58:17 kettenis Exp $ */
+/* $OpenBSD: imxiic.c,v 1.4 2018/06/10 09:25:50 patrick Exp $ */
/*
* Copyright (c) 2013 Patrick Wildt <patrick@blueri.se>
*
@@ -54,6 +54,7 @@ struct imxiic_softc {
bus_size_t sc_ios;
void *sc_ih;
int sc_node;
+ int sc_bitrate;
struct rwlock sc_buslock;
struct i2c_controller i2c_tag;
@@ -133,8 +134,10 @@ imxiic_attach(struct device *parent, struct device *self, void *aux)
/* set iomux pins */
pinctrl_byname(faa->fa_node, "default");
- /* set speed to 100kHz */
- imxiic_setspeed(sc, 100);
+ /* set speed */
+ sc->sc_bitrate = OF_getpropint(sc->sc_node,
+ "clock-frequency", 100000) / 1000;
+ imxiic_setspeed(sc, sc->sc_bitrate);
/* reset */
HWRITE2(sc, I2C_I2CR, 0);
@@ -322,8 +325,8 @@ imxiic_i2c_acquire_bus(void *cookie, int flags)
/* clock gating */
clock_enable(sc->sc_node, NULL);
- /* set speed to 100kHz */
- imxiic_setspeed(sc, 100);
+ /* set speed */
+ imxiic_setspeed(sc, sc->sc_bitrate);
/* enable the controller */
HWRITE2(sc, I2C_I2SR, 0);