
Dear Marek,
In message 1352766871-892-4-git-send-email-marex@denx.de you wrote:
This patch pulls out the I2C speed setup from the i2c_init() call and implements the bus configuration lookup table with register values that needs to be programmed into the I2C IP to run at particular speed.
This patch is a first step towards implementing run-time I2C bus speed configuration for the MXS I2C IP.
Thanks.
+static struct mxs_i2c_speed_table {
- uint32_t speed;
- uint32_t timing0;
- uint32_t timing1;
+} mxs_i2c_tbl[] = {
- {
100000,
(0x0078 << I2C_TIMING0_HIGH_COUNT_OFFSET) |
(0x0030 << I2C_TIMING0_RCV_COUNT_OFFSET),
(0x0080 << I2C_TIMING1_LOW_COUNT_OFFSET) |
(0x0030 << I2C_TIMING1_XMIT_COUNT_OFFSET)
- },
- {
400000,
(0x000f << I2C_TIMING0_HIGH_COUNT_OFFSET) |
(0x0007 << I2C_TIMING0_RCV_COUNT_OFFSET),
(0x001f << I2C_TIMING1_LOW_COUNT_OFFSET) |
(0x000f << I2C_TIMING1_XMIT_COUNT_OFFSET),
- }
+};
Do we really need such a compile-time initialized table which will have to include all possible I2C speeds anybody is ever going to use on any board?
And if board XXX wants to use a funny I2C clock, we have to add yet another entry to this common file? Such a solution does not scale.
Can we not rather calculate these register values for any arbitrary I2C clock given?
Best regards,
Wolfgang Denk