Maxim Polyakov has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/39845 )
Change subject: ec/kontron: add option to configure I2C frequency ......................................................................
ec/kontron: add option to configure I2C frequency
Allows to change the frequency for the I2C bus by overriding 2c_freq option from the devicetree of the board. For example, if the bus is not beyond the board, then we can increase the frequency in order to read DMI parameters from EEPROM faster.
Tested on kontron COMe module with T10-TNI carrierboard [1,2]
[1] https://review.coreboot.org/c/coreboot/+/39133 [2]
Change-Id: I36a7ae30f1197f77854634fac3a9e1911ce92093 Signed-off-by: Maxim Polyakov max.senia.poliak@gmail.com --- M src/ec/kontron/kempld/chip.h M src/ec/kontron/kempld/kempld_i2c.c 2 files changed, 20 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/45/39845/1
diff --git a/src/ec/kontron/kempld/chip.h b/src/ec/kontron/kempld/chip.h index 597f281..2b18faf 100644 --- a/src/ec/kontron/kempld/chip.h +++ b/src/ec/kontron/kempld/chip.h @@ -32,6 +32,7 @@
struct ec_kontron_kempld_config { struct kempld_uart uart[KEMPLD_NUM_UARTS]; + unsigned short i2c_freq; };
#endif /* EC_KONTRON_KEMPLD_CHIP_H */ diff --git a/src/ec/kontron/kempld/kempld_i2c.c b/src/ec/kontron/kempld/kempld_i2c.c index ab41097..24297f0c9 100644 --- a/src/ec/kontron/kempld/kempld_i2c.c +++ b/src/ec/kontron/kempld/kempld_i2c.c @@ -27,6 +27,7 @@ #include <timer.h> #include <delay.h>
+#include "chip.h" #include "kempld.h" #include "kempld_internal.h"
@@ -54,8 +55,8 @@ #define I2C_CMD_READ_NACK 0x29 #define I2C_CMD_IACK 0x01
-#define KEMPLD_I2C_FREQ_MAX 2700 /* 2.7 mHz */ -#define KEMPLD_I2C_FREQ_STD 100 /* 100 kHz */ +#define KEMPLD_I2C_FREQ_MAX 2700 /* 2.7 mHz */ +#define KEMPLD_I2C_FREQ_STD_DEFAULT 100 /* 100 kHz */
#define EIO 5 #define ENXIO 6 @@ -244,12 +245,17 @@
void kempld_i2c_device_init(struct device *const dev) { + const struct ec_kontron_kempld_config *const config = dev->chip_info; + unsigned short frequency; u16 prescale_corr; long prescale; u8 ctrl; u8 stat; u8 cfg;
+ if (!config) + return; + if (kempld_get_mutex(100) < 0) return;
@@ -258,11 +264,20 @@ ctrl &= ~(I2C_CTRL_EN | I2C_CTRL_IEN); kempld_write8(KEMPLD_I2C_CTRL, ctrl);
+ frequency = KEMPLD_I2C_FREQ_STD_DEFAULT; + if (config->i2c_freq) { + if (config->i2c_freq <= KEMPLD_I2C_FREQ_MAX) + frequency = config->i2c_freq + else + printk(BIOS_INFO, "kempld_i2c: %d kHz is an invalid frequency value. " + "Set default value %d kHz\n", config->i2c_freq, frequency); + } + const u8 spec_major = KEMPLD_SPEC_GET_MAJOR(kempld_read8(KEMPLD_SPEC)); if (spec_major == 1) - prescale = KEMPLD_CLK / (KEMPLD_I2C_FREQ_STD * 5) - 1000; + prescale = KEMPLD_CLK / (frequency * 5) - 1000; else - prescale = KEMPLD_CLK / (KEMPLD_I2C_FREQ_STD * 4) - 3000; + prescale = KEMPLD_CLK / (frequency * 4) - 3000;
if (prescale < 0) prescale = 0;
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39845 )
Change subject: ec/kontron: add option to configure I2C frequency ......................................................................
Patch Set 1:
(8 comments)
https://review.coreboot.org/c/coreboot/+/39845/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/39845/1//COMMIT_MSG@12 PS1, Line 12: DMI parameters from EEPROM faster. Please mention some numbers? 50 milliseconds? 100 ms?
https://review.coreboot.org/c/coreboot/+/39845/1//COMMIT_MSG@14 PS1, Line 14: kontron Kontron
https://review.coreboot.org/c/coreboot/+/39845/1//COMMIT_MSG@14 PS1, Line 14: Tested on kontron COMe module with T10-TNI carrierboard [1,2] With what frequency?
https://review.coreboot.org/c/coreboot/+/39845/1//COMMIT_MSG@17 PS1, Line 17: [2] Missing URL/reference?
https://review.coreboot.org/c/coreboot/+/39845/1/src/ec/kontron/kempld/chip.... File src/ec/kontron/kempld/chip.h:
https://review.coreboot.org/c/coreboot/+/39845/1/src/ec/kontron/kempld/chip.... PS1, Line 35: unsigned short i2c_freq; Just use one space as in the struct above.
https://review.coreboot.org/c/coreboot/+/39845/1/src/ec/kontron/kempld/kempl... File src/ec/kontron/kempld/kempld_i2c.c:
https://review.coreboot.org/c/coreboot/+/39845/1/src/ec/kontron/kempld/kempl... PS1, Line 272: BIOS_INFO BIOS_WARNING
https://review.coreboot.org/c/coreboot/+/39845/1/src/ec/kontron/kempld/kempl... PS1, Line 273: Set Use?
https://review.coreboot.org/c/coreboot/+/39845/1/src/ec/kontron/kempld/kempl... PS1, Line 275: Maybe print out the used frequency as BIOS_INFO every time.
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39845 )
Change subject: ec/kontron: add option to configure I2C frequency ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/39845/1/src/ec/kontron/kempld/chip.... File src/ec/kontron/kempld/chip.h:
https://review.coreboot.org/c/coreboot/+/39845/1/src/ec/kontron/kempld/chip.... PS1, Line 35: unsigned short i2c_freq; Also add the unit in the variable name: `i2c_freq_khz`.
Hello build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/39845
to look at the new patch set (#2).
Change subject: ec/kontron: add option to configure I2C frequency ......................................................................
ec/kontron: add option to configure I2C frequency
Allows to change the frequency for the I2C bus by overriding 2c_freq option from the devicetree of the board. For example, if the bus is not beyond the board, then we can increase the frequency in order to read DMI parameters from EEPROM faster.
Tested on kontron COMe module with T10-TNI carrierboard [1,2]
[1] https://review.coreboot.org/c/coreboot/+/39133 [2] https://review.coreboot.org/c/coreboot/+/39846
Change-Id: I36a7ae30f1197f77854634fac3a9e1911ce92093 Signed-off-by: Maxim Polyakov max.senia.poliak@gmail.com Signed-off-by: Nikolay Dementey n_dementey@eureca.ru --- M src/ec/kontron/kempld/chip.h M src/ec/kontron/kempld/kempld_i2c.c 2 files changed, 20 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/45/39845/2
Hello build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/39845
to look at the new patch set (#3).
Change subject: ec/kontron: add option to configure I2C frequency ......................................................................
ec/kontron: add option to configure I2C frequency
Allows to change the frequency for the I2C bus by overriding i2c_freq_khz option from the devicetree of the board. For example, if the bus is not beyond the board, then we can increase the frequency in order to read DMI parameters from EEPROM faster.
Tested on Kontron COMe module with T10-TNI carrierboard [1,2] with 400 kHz
[1] https://review.coreboot.org/c/coreboot/+/39133 [2] https://review.coreboot.org/c/coreboot/+/39846
Change-Id: I36a7ae30f1197f77854634fac3a9e1911ce92093 Signed-off-by: Maxim Polyakov max.senia.poliak@gmail.com Signed-off-by: Nikolay Dementey n_dementey@eureca.ru --- M src/ec/kontron/kempld/chip.h M src/ec/kontron/kempld/kempld_i2c.c 2 files changed, 22 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/45/39845/3
Maxim Polyakov has abandoned this change. ( https://review.coreboot.org/c/coreboot/+/39845 )
Change subject: ec/kontron: add option to configure I2C frequency ......................................................................
Abandoned