diff options
author | Neelesh Gupta <neelegup@linux.vnet.ibm.com> | 2014-12-18 15:44:45 +0530 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-01-21 14:52:16 +1100 |
commit | 162ec60743b66d15de281775176e8f051c4dfde5 (patch) | |
tree | 7f0ff7c5ae8ef3ab59c4591bc4306103379868f2 /hw/p8-i2c.c | |
parent | 2e4fc3a33dab3144b19b329df91ad66871cbe952 (diff) | |
download | skiboot-162ec60743b66d15de281775176e8f051c4dfde5.zip skiboot-162ec60743b66d15de281775176e8f051c4dfde5.tar.gz skiboot-162ec60743b66d15de281775176e8f051c4dfde5.tar.bz2 |
i2c: Unify the frequencies to calculate bit rate divisor
Provide the frequencies in same unit (HZ) for calculating the bit rate
divisor value.
Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw/p8-i2c.c')
-rw-r--r-- | hw/p8-i2c.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c index 5204cf8..3e5334c 100644 --- a/hw/p8-i2c.c +++ b/hw/p8-i2c.c @@ -998,11 +998,9 @@ static void p8_i2c_free_request(struct i2c_request *req) free(request); } -static inline uint32_t p8_i2c_get_bit_rate_divisor(uint32_t lb_freq_hz, +static inline uint32_t p8_i2c_get_bit_rate_divisor(uint32_t lb_freq, uint32_t bus_speed) { - uint64_t lb_freq = lb_freq_hz / 1000; - return (((lb_freq / bus_speed) - 1) / 4); } @@ -1011,7 +1009,7 @@ static inline uint64_t p8_i2c_get_poll_interval(uint32_t bus_speed) uint64_t usec; /* Polling Interval = 8 * (1/bus_speed) * (1/10) -> convert to uSec */ - usec = ((8 * USEC_PER_SEC) / (10 * bus_speed * 1000)); + usec = ((8 * USEC_PER_SEC) / (10 * bus_speed)); return usecs_to_tb(usec); } @@ -1194,7 +1192,6 @@ void p8_i2c_init(void) port->port_num = dt_prop_get_u32(i2cm_port, "reg"); port->master = master; speed = dt_prop_get_u32(i2cm_port, "bus-frequency"); - speed /= 1000; if (speed > max_bus_speed) max_bus_speed = speed; port->bit_rate_div = @@ -1207,7 +1204,7 @@ void p8_i2c_init(void) prlog(PR_INFO, " P%d: <%s> %d kHz\n", port->port_num, (char *)dt_prop_get(i2cm_port, "ibm,port-name"), - speed); + speed/1000); port++; } |