summaryrefslogtreecommitdiffstats
path: root/hdata
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2017-04-24 14:45:40 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-04-28 15:11:15 +1000
commit0ccb51dcda80a9c7fded7ca45cd0ba97f81401c7 (patch)
tree70890872f3e493514b0512a9ca9dc212bef74140 /hdata
parent06117d0c466461458039d54e9cabcd706e4d8516 (diff)
downloadblackbird-skiboot-0ccb51dcda80a9c7fded7ca45cd0ba97f81401c7.tar.gz
blackbird-skiboot-0ccb51dcda80a9c7fded7ca45cd0ba97f81401c7.zip
hdata/i2c: Fix bus and clock frequencies
The clock-frequency of the i2c master should be derived from the xscom bus frequency (itself derived from the nest frequency). The bus-frequency of the i2c bus should be in Hz so convert the HDAT value from kHz to Hz. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Reviewed-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hdata')
-rw-r--r--hdata/i2c.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/hdata/i2c.c b/hdata/i2c.c
index 5a74a7f0..24e92573 100644
--- a/hdata/i2c.c
+++ b/hdata/i2c.c
@@ -31,6 +31,7 @@ static struct dt_node *get_i2cm_node(struct dt_node *xscom, int engine)
{
uint64_t xscom_base = P9_I2CM_XSCOM_BASE + P9_I2CM_XSCOM_SIZE * engine;
struct dt_node *i2cm;
+ uint64_t freq, clock;
i2cm = dt_find_by_name_addr(xscom, "i2cm", xscom_base);
if (!i2cm) {
@@ -45,8 +46,12 @@ static struct dt_node *get_i2cm_node(struct dt_node *xscom, int engine)
dt_add_property_cells(i2cm, "#address-cells", 1);
dt_add_property_cells(i2cm, "chip-engine#", engine);
- /* XXX: verify this */
- dt_add_property_cells(i2cm, "clock-frequency", 150000000);
+ freq = dt_prop_get_u64_def(xscom, "bus-frequency", 0);
+ clock = (u32)(freq / 4);
+ if (clock)
+ dt_add_property_cells(i2cm, "clock-frequency", clock);
+ else
+ dt_add_property_cells(i2cm, "clock-frequency", 150000000);
}
return i2cm;
@@ -73,7 +78,7 @@ static struct dt_node *get_bus_node(struct dt_node *i2cm, int port, int freq)
* reduce the frequency to something that all devices
* can tolerate.
*/
- dt_add_property_cells(bus, "bus-frequency", freq);
+ dt_add_property_cells(bus, "bus-frequency", freq * 1000);
}
return bus;
OpenPOWER on IntegriCloud