83xx: Add support for CFG_I2C_SPEED in fsl_i2c.c
PATCH 1/1 83xx: Add support for CFG_I2C_SPEED in fsl_i2c.c
Add support to fsl_i2c.c for setting and querying the I2C bus speed. Current 83xx boards define the CFG_I2C_SPEED, but fsl_i2c.c ignores the value and uses a conservative value of 0x3F when programming the I2C bus speed.
---
Unfortunately, only 83xx calculates and stores the I2C clock frequencies, so this code is compiled on 83xx only.
cpu/mpc83xx/cpu.c | 24 +++++++++++ drivers/i2c/fsl_i2c.c | 90 ++++++++++++++++++++++++++++++++++++++++- include/asm-ppc/fsl_i2c.h | 23 ++++++++++ include/configs/MPC832XEMDS.h | 1 + 4 files changed, 137 insertions(+), 1 deletions(-)
cpu/mpc83xx/cpu.c +24 -0
@@ -716,3 +716,27 @@ int dma_xfer(void *dest, u32 count, void *src)return ((int )dma_check ()); }#endif /*CONFIG_DDR_ECC*/ + +#ifdef CFG_I2C_SPEED +/* +* Map the frequency divider to the FDR. This data is taken from table 17-5 +* of the MPC8349EA reference manual, with duplicates removed. It also applies +* to the 8360. +*/ +struct fsl_i2c_speed_map fsl_i2c_speed_map[] = { + {256 ,0x20 }, {288 ,0x21 }, {320 ,0x22 }, {352 ,0x23 }, + {384 ,0x24 }, {416 ,0x01 }, {448 ,0x25 }, {480 ,0x02 }, + {512 ,0x26 }, {576 ,0x27 }, {640 ,0x28 }, {704 ,0x05 }, + {768 ,0x29 }, {832 ,0x06 }, {896 ,0x2A }, {1024 ,0x2B }, + {1152 ,0x08 }, {1280 ,0x2C }, {1536 ,0x2D }, {1792 ,0x2E }, + {1920 ,0x0B }, {2048 ,0x2F }, {2304 ,0x0C }, {2560 ,0x30 }, + {3072 ,0x31 }, {3584 ,0x32 }, {3840 ,0x0F }, {4096 ,0x33 }, + {4608 ,0x10 }, {5120 ,0x34 }, {6144 ,0x35 }, {7168 ,0x36 }, + {7680 ,0x13 }, {8192 ,0x37 }, {9216 ,0x14 }, {10240 ,0x38 }, + {12288 ,0x39 }, {14336 ,0x3A }, {15360 ,0x17 }, {16384 ,0x3B }, + {18432 ,0x18 }, {20480 ,0x3C }, {24576 ,0x3D }, {28672 ,0x3E }, + {30720 ,0x1B }, {32768 ,0x3F }, {36864 ,0x1C }, {40960 ,0x1D }, + {49152 ,0x1E }, {61440 ,0x1F }, + {-1 ,0x1F } +}; +#endif
drivers/i2c/fsl_i2c.c +89 -1
144 lines not on this page · raw message
include/asm-ppc/fsl_i2c.h +23 -0
@@ -83,4 +83,27 @@ typedef struct fsl_i2c { u8 res6[0xE8]; } fsl_i2c_t; +/* +* Map I2C frequency dividers to FDR values +* +* This structure is used to define the elements of a table that maps I2C +* frequency divider (I2C clock rate divided by I2C bus speed) to a value to be +* programmed into the Frequency Divider Ratio (FDR) register. +* +* The actual table should be defined in the board file, and it must be called +* fsl_i2c_speed_map[]. +* +* The first entry must be {0, X}, where X == fsl_i2c_speed_map[1].fdr. +* +* The last entry of the table must have a value of {-1,x}, where x is same +* FDR value as the second-to-last entry. +* +* The values of the divider must be in increasing numerical order, i.e. +* fsl_i2c_speed_map[x+1].divider > fsl_i2c_speed_map[x].divider. +*/ +typedef struct fsl_i2c_speed_map { +unsigned int divider; +u8 fdr; +}fsl_i2c_speed_map_t ; +#endif /* _ASM_I2C_H_ */
include/configs/MPC832XEMDS.h +1 -0
@@ -335,6 +335,7 @@#define CFG_I2C_SLAVE 0x7F#define CFG_I2C_NOPROBES {0x51}/* Don't probe these addrs */ #define CFG_I2C_OFFSET 0x3000 +#define CONFIG_I2C_CMD_TREE /* * Config on-board RTC
Signature · 1 line
1.5.2.4
PATCH 1/1 83xx: Add support for CFG_I2C_SPEED in fsl_i2c.c
Quoted 9 lines · Timur Tabi
Add support to
fsl_i2c.cfor setting and querying the I2C bus speed. Current 83xx boards define theCFG_I2C_SPEED, butfsl_i2c.cignores the value and uses a conservative value of0x3Fwhen programming the I2C bus speed.Signed-off-by Timur Tabi <[email protected]>---
Unfortunately, only 83xx calculates and stores the I2C clock frequencies, so this code is compiled on 83xx only.
I've got another patch that adds this feature to 85xx and 86xx, so if that patch is applied, then I will submit another version of *this* patch that extends the code to 85xx and 86xx.
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
PATCH 1/1 83xx: Add support for CFG_I2C_SPEED in fsl_i2c.c
Hi,
Quoted 8 lines · Timur Tabi
Quoted 7 lines · Timur Tabi
Add support to
fsl_i2c.cfor setting and querying the I2C bus speed. Current 83xx boards define theCFG_I2C_SPEED, butfsl_i2c.cignores the value and uses a conservative value of0x3Fwhen programming the I2C bus speed.Signed-off-by Timur Tabi <[email protected]>---
Quoted 7 lines
Quoted 2 lines
Unfortunately, only 83xx calculates and stores the I2C clock frequencies, so this code is compiled on 83xx only.
I've got another patch that adds this feature to 85xx and 86xx, so if that patch is applied, then I will submit another version of *this* patch that extends the code to 85xx and 86xx.
When is it planned to apply these patches (especially MPC85xx)?
Regards,
Jens
PATCH 1/1 83xx: Add support for CFG_I2C_SPEED in fsl_i2c.c
Quoted 1 line · Jens Gehrlein
When is it planned to apply these patches (especially MPC85xx)?
Well, it's on my to-do list, but I'm currently busy with something else. How important is this feature for you?
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
PATCH 1/1 83xx: Add support for CFG_I2C_SPEED in fsl_i2c.c
Hi Timur,
Quoted 7 lines · Timur Tabi
Quoted 1 line · Jens Gehrlein
When is it planned to apply these patches (especially MPC85xx)?
Well, it's on my to-do list, but I'm currently busy with something else. How important is this feature for you?
We started a hack on MPC8548 1.5 years before. Later we found your announcement on the mailing list. Your patches are the better solution. It's not urgent. But it's nice to know, how your "release plans" are.
Best regards
Jens
PATCH 1/1 83xx: Add support for CFG_I2C_SPEED in fsl_i2c.c
Quoted 3 lines · Jens Gehrlein
We started a hack on MPC8548 1.5 years before. Later we found your announcement on the mailing list. Your patches are the better solution. It's not urgent. But it's nice to know, how your "release plans" are.
Ok, I'll try to get it into 1.3.3
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale