summaryrefslogtreecommitdiff
path: root/target/linux/brcm2708/patches-3.10/0143-i2c-bcm2708-fixed-baudrate.patch
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2014-02-28 20:30:08 +0000
committerFlorian Fainelli <florian@openwrt.org>2014-02-28 20:30:08 +0000
commitbb39b8d99aae1f7eb13a97bd874838da91080de6 (patch)
tree3046f53937c0bc5dc13e2b2ab7b688a1932199bf /target/linux/brcm2708/patches-3.10/0143-i2c-bcm2708-fixed-baudrate.patch
parentc6c0d09f85c211560a1405441925681cfa25e8b1 (diff)
downloadmtk-20170518-bb39b8d99aae1f7eb13a97bd874838da91080de6.zip
mtk-20170518-bb39b8d99aae1f7eb13a97bd874838da91080de6.tar.gz
mtk-20170518-bb39b8d99aae1f7eb13a97bd874838da91080de6.tar.bz2
brcm2708: update against latest rpi-3.10.y branch
Update our copies of the brcm2708 patches to the latest rpi-3.10-y rebased against linux-3.10.y stable (3.10.32). This should hopefully make it easier for us in the future to leverage the raspberry/rpi-* branches. Signed-off-by: Florian Fainelli <florian@openwrt.org> SVN-Revision: 39770
Diffstat (limited to 'target/linux/brcm2708/patches-3.10/0143-i2c-bcm2708-fixed-baudrate.patch')
-rw-r--r--target/linux/brcm2708/patches-3.10/0143-i2c-bcm2708-fixed-baudrate.patch51
1 files changed, 51 insertions, 0 deletions
diff --git a/target/linux/brcm2708/patches-3.10/0143-i2c-bcm2708-fixed-baudrate.patch b/target/linux/brcm2708/patches-3.10/0143-i2c-bcm2708-fixed-baudrate.patch
new file mode 100644
index 0000000..f805a89
--- /dev/null
+++ b/target/linux/brcm2708/patches-3.10/0143-i2c-bcm2708-fixed-baudrate.patch
@@ -0,0 +1,51 @@
+From fdd5f63fca69c692eaaac24b3a3d23e2cdf2fb4d Mon Sep 17 00:00:00 2001
+From: brabl2 <pavelvrbka@seznam.cz>
+Date: Sat, 21 Dec 2013 21:25:36 +0100
+Subject: [PATCH 143/174] i2c-bcm2708: fixed baudrate
+
+Fixed issue where the wrong CDIV value was set for baudrates below 3815 Hz (for 250MHz bus clock). In that case the computed CDIV value was more than 0xffff. However the CDIV register width is only 16 bits. This resulted in incorrect setting of CDIV and higher baudrate than intended.
+Example: 3500Hz -> CDIV=0x11704 -> CDIV(16bit)=0x1704 -> 42430Hz
+After correction: 3500Hz -> CDIV=0x11704 -> CDIV(16bit)=0xffff -> 3815Hz
+The correct baudrate is shown in the log after the cdiv > 0xffff correction.
+---
+ drivers/i2c/busses/i2c-bcm2708.c | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+--- a/drivers/i2c/busses/i2c-bcm2708.c
++++ b/drivers/i2c/busses/i2c-bcm2708.c
+@@ -155,6 +155,8 @@ static inline void bcm2708_bsc_setup(str
+
+ bus_hz = clk_get_rate(bi->clk);
+ cdiv = bus_hz / baudrate;
++ if (cdiv > 0xffff)
++ cdiv = 0xffff;
+
+ if (bi->msg->flags & I2C_M_RD)
+ c |= BSC_C_INTR | BSC_C_READ;
+@@ -268,6 +270,8 @@ static int bcm2708_i2c_probe(struct plat
+ struct clk *clk;
+ struct bcm2708_i2c *bi;
+ struct i2c_adapter *adap;
++ unsigned long bus_hz;
++ u32 cdiv;
+
+ regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!regs) {
+@@ -343,8 +347,15 @@ static int bcm2708_i2c_probe(struct plat
+ goto out_free_irq;
+ }
+
+- dev_info(&pdev->dev, "BSC%d Controller at 0x%08lx (irq %d) (baudrate %dk)\n",
+- pdev->id, (unsigned long)regs->start, irq, baudrate/1000);
++ bus_hz = clk_get_rate(bi->clk);
++ cdiv = bus_hz / baudrate;
++ if (cdiv > 0xffff) {
++ cdiv = 0xffff;
++ baudrate = bus_hz / cdiv;
++ }
++
++ dev_info(&pdev->dev, "BSC%d Controller at 0x%08lx (irq %d) (baudrate %d)\n",
++ pdev->id, (unsigned long)regs->start, irq, baudrate);
+
+ return 0;
+