aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sverdlin <alexander.sverdlin@nokia.com>2015-09-14 05:03:50 -0400
committerWolfram Sang <wsa@the-dreams.de>2015-10-20 11:05:16 -0400
commit35780e860f7d4a5f33f6ceadf09038ee26f1ef43 (patch)
tree341806deefeefb2ceafe960d7ca3880170baf3cf
parent064181b00e33c917145194247b4abcfa36ca06d7 (diff)
i2c: davinci: Optimize clock generation on Keystone SoC
According to "KeyStone Architecture Inter-IC Control Bus User Guide", fixed additive part of frequency divisors (referred as "d" in the code and datasheet) always equals to 6, independent of module clock prescaler. module clock frequency master clock frequency = ---------------------- (ICCL + 6) + (ICCH + 6) It was not the case with original Davinci IP. Introduce new compatible property "ti,keystone-i2c", which triggers special handling in the driver. Without this change Keystone-based systems (having 204.8MHz input clock) choose prescaler 29 (PSC=28). Using d=5 in this case leads to bus bitrate ~353kHz instead of requested 400kHz. After correction, assuming d=6 bus rate is ~392kHz. This gives ~11% transfer rate increase. Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com> Tested-by: Hemanth Guruva Reddy <hemanth.guruva_reddy@nokia.com> Tested-by: Lukasz Gemborowski <lukasz.gemborowski@nokia.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-davinci.txt6
-rw-r--r--drivers/i2c/busses/i2c-davinci.c8
2 files changed, 11 insertions, 3 deletions
diff --git a/Documentation/devicetree/bindings/i2c/i2c-davinci.txt b/Documentation/devicetree/bindings/i2c/i2c-davinci.txt
index a4e1cbc810c1..5b123e0e4cc2 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-davinci.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-davinci.txt
@@ -1,10 +1,10 @@
1* Texas Instruments Davinci I2C 1* Texas Instruments Davinci/Keystone I2C
2 2
3This file provides information, what the device node for the 3This file provides information, what the device node for the
4davinci i2c interface contain. 4davinci/keystone i2c interface contains.
5 5
6Required properties: 6Required properties:
7- compatible: "ti,davinci-i2c"; 7- compatible: "ti,davinci-i2c" or "ti,keystone-i2c";
8- reg : Offset and length of the register set for the device 8- reg : Offset and length of the register set for the device
9 9
10Recommended properties : 10Recommended properties :
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 3fbb9a035532..c5628a42170a 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -181,6 +181,7 @@ static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
181 u32 clkh; 181 u32 clkh;
182 u32 clkl; 182 u32 clkl;
183 u32 input_clock = clk_get_rate(dev->clk); 183 u32 input_clock = clk_get_rate(dev->clk);
184 struct device_node *of_node = dev->dev->of_node;
184 185
185 /* NOTE: I2C Clock divider programming info 186 /* NOTE: I2C Clock divider programming info
186 * As per I2C specs the following formulas provide prescaler 187 * As per I2C specs the following formulas provide prescaler
@@ -196,6 +197,9 @@ static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
196 * where if PSC == 0, d = 7, 197 * where if PSC == 0, d = 7,
197 * if PSC == 1, d = 6 198 * if PSC == 1, d = 6
198 * if PSC > 1 , d = 5 199 * if PSC > 1 , d = 5
200 *
201 * Note:
202 * d is always 6 on Keystone I2C controller
199 */ 203 */
200 204
201 /* get minimum of 7 MHz clock, but max of 12 MHz */ 205 /* get minimum of 7 MHz clock, but max of 12 MHz */
@@ -204,6 +208,9 @@ static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
204 psc++; /* better to run under spec than over */ 208 psc++; /* better to run under spec than over */
205 d = (psc >= 2) ? 5 : 7 - psc; 209 d = (psc >= 2) ? 5 : 7 - psc;
206 210
211 if (of_node && of_device_is_compatible(of_node, "ti,keystone-i2c"))
212 d = 6;
213
207 clk = ((input_clock / (psc + 1)) / (pdata->bus_freq * 1000)); 214 clk = ((input_clock / (psc + 1)) / (pdata->bus_freq * 1000));
208 /* Avoid driving the bus too fast because of rounding errors above */ 215 /* Avoid driving the bus too fast because of rounding errors above */
209 if (input_clock / (psc + 1) / clk > pdata->bus_freq * 1000) 216 if (input_clock / (psc + 1) / clk > pdata->bus_freq * 1000)
@@ -726,6 +733,7 @@ static struct i2c_algorithm i2c_davinci_algo = {
726 733
727static const struct of_device_id davinci_i2c_of_match[] = { 734static const struct of_device_id davinci_i2c_of_match[] = {
728 {.compatible = "ti,davinci-i2c", }, 735 {.compatible = "ti,davinci-i2c", },
736 {.compatible = "ti,keystone-i2c", },
729 {}, 737 {},
730}; 738};
731MODULE_DEVICE_TABLE(of, davinci_i2c_of_match); 739MODULE_DEVICE_TABLE(of, davinci_i2c_of_match);