Skip to content
Permalink
Browse files

drivers: i2c_cc32xx: Get clock frequency from DTS

The i2c_cc32xx driver used system clock frequency
as a base for I2C clock frequency calculation.
This commit corrects that by obtaining the needed value from DTS.

Please note, that for I2C devices the clock-frequency property
specifies SCK frequency, instead of frequency of the clock driving
peripheral. To solve that problem, a new property was added.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
  • Loading branch information...
pizi-nordic authored and carlescufi committed Apr 11, 2019
1 parent 5f6cae3 commit 8f22b16b6c6eb6b6ec3602875156587b6093f2d1
Showing with 2 additions and 1 deletion.
  1. +1 −1 drivers/i2c/i2c_cc32xx.c
  2. +1 −0 soc/arm/ti_simplelink/cc32xx/dts_fixup.h
@@ -103,7 +103,7 @@ static int i2c_cc32xx_configure(struct device *dev, u32_t dev_config_raw)
return -EINVAL;
}

MAP_I2CMasterInitExpClk(base, CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC,
MAP_I2CMasterInitExpClk(base, DT_I2C_0_CLOCK_FREQUENCY,
bitrate_id);

return 0;
@@ -8,6 +8,7 @@
#define DT_I2C_0_LABEL DT_TI_CC32XX_I2C_40020000_LABEL
#define DT_I2C_0_BASE_ADDRESS DT_TI_CC32XX_I2C_40020000_BASE_ADDRESS
#define DT_I2C_0_BITRATE DT_TI_CC32XX_I2C_40020000_CLOCK_FREQUENCY
#define DT_I2C_0_CLOCK_FREQUENCY DT_TI_CC32XX_I2C_40020000_CLOCKS_CLOCK_FREQUENCY
#define DT_I2C_0_IRQ DT_TI_CC32XX_I2C_40020000_IRQ_0
#define DT_I2C_0_IRQ_PRIORITY DT_TI_CC32XX_I2C_40020000_IRQ_0_PRIORITY

0 comments on commit 8f22b16

Please sign in to comment.
You can’t perform that action at this time.