diff mbox series

[v1,2/2] i2c: i2c-stm32f7: SYSCFG Fast Mode Plus support for I2C STM32F7

Message ID 1542370822-14721-3-git-send-email-pierre-yves.mordret@st.com
State Superseded
Headers show
Series SYSCFG Fast Mode Plus support for I2C STM32F7 | expand

Commit Message

Pierre Yves MORDRET Nov. 16, 2018, 12:20 p.m. UTC
Read SYSCFG bindings to set Fast Mode Plus bits if Fast Mode Plus
speed is selected.

Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.com>
---
  Version history:
    v1:
       * Initial
---
---
 drivers/i2c/busses/i2c-stm32f7.c | 37 ++++++++++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)

Comments

kernel test robot Nov. 18, 2018, 7:05 a.m. UTC | #1
Hi Pierre-Yves,

I love your patch! Yet something to improve:

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on v4.20-rc2 next-20181116]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Pierre-Yves-MORDRET/SYSCFG-Fast-Mode-Plus-support-for-I2C-STM32F7/20181118-135056
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
config: s390-allmodconfig (attached as .config)
compiler: s390x-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=s390 

All errors (new ones prefixed by >>):

   drivers/i2c/busses/i2c-stm32f7.c: In function 'stm32f7_i2c_setup_fm_plus_bits':
>> drivers/i2c/busses/i2c-stm32f7.c:1790:9: error: implicit declaration of function 'regmap_update_bits'; did you mean 'set_pgste_bits'? [-Werror=implicit-function-declaration]
     return regmap_update_bits(i2c_dev->regmap, reg, mask, mask);
            ^~~~~~~~~~~~~~~~~~
            set_pgste_bits
   cc1: some warnings being treated as errors

vim +1790 drivers/i2c/busses/i2c-stm32f7.c

  1768	
  1769	static int stm32f7_i2c_setup_fm_plus_bits(struct platform_device *pdev,
  1770						  struct stm32f7_i2c_dev *i2c_dev)
  1771	{
  1772		struct device_node *np = pdev->dev.of_node;
  1773		int ret;
  1774		u32 reg, mask;
  1775	
  1776		i2c_dev->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg-fmp");
  1777		if (IS_ERR(i2c_dev->regmap)) {
  1778			/* Optional */
  1779			return 0;
  1780		}
  1781	
  1782		ret = of_property_read_u32_index(np, "st,syscfg-fmp", 1, &reg);
  1783		if (ret)
  1784			return ret;
  1785	
  1786		ret = of_property_read_u32_index(np, "st,syscfg-fmp", 2, &mask);
  1787		if (ret)
  1788			return ret;
  1789	
> 1790		return regmap_update_bits(i2c_dev->regmap, reg, mask, mask);
  1791	}
  1792	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot Nov. 18, 2018, 7:08 a.m. UTC | #2
Hi Pierre-Yves,

I love your patch! Yet something to improve:

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on v4.20-rc2 next-20181116]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Pierre-Yves-MORDRET/SYSCFG-Fast-Mode-Plus-support-for-I2C-STM32F7/20181118-135056
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 8.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=8.1.0 make.cross ARCH=xtensa 

All errors (new ones prefixed by >>):

   drivers/i2c//busses/i2c-stm32f7.c: In function 'stm32f7_i2c_setup_fm_plus_bits':
>> drivers/i2c//busses/i2c-stm32f7.c:1790:9: error: implicit declaration of function 'regmap_update_bits'; did you mean 'file_update_time'? [-Werror=implicit-function-declaration]
     return regmap_update_bits(i2c_dev->regmap, reg, mask, mask);
            ^~~~~~~~~~~~~~~~~~
            file_update_time
   cc1: some warnings being treated as errors

vim +1790 drivers/i2c//busses/i2c-stm32f7.c

  1768	
  1769	static int stm32f7_i2c_setup_fm_plus_bits(struct platform_device *pdev,
  1770						  struct stm32f7_i2c_dev *i2c_dev)
  1771	{
  1772		struct device_node *np = pdev->dev.of_node;
  1773		int ret;
  1774		u32 reg, mask;
  1775	
  1776		i2c_dev->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg-fmp");
  1777		if (IS_ERR(i2c_dev->regmap)) {
  1778			/* Optional */
  1779			return 0;
  1780		}
  1781	
  1782		ret = of_property_read_u32_index(np, "st,syscfg-fmp", 1, &reg);
  1783		if (ret)
  1784			return ret;
  1785	
  1786		ret = of_property_read_u32_index(np, "st,syscfg-fmp", 2, &mask);
  1787		if (ret)
  1788			return ret;
  1789	
> 1790		return regmap_update_bits(i2c_dev->regmap, reg, mask, mask);
  1791	}
  1792	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
index 62d023e..8e381b7 100644
--- a/drivers/i2c/busses/i2c-stm32f7.c
+++ b/drivers/i2c/busses/i2c-stm32f7.c
@@ -21,6 +21,7 @@ 
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
+#include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
@@ -276,6 +277,7 @@  struct stm32f7_i2c_msg {
  * slave)
  * @dma: dma data
  * @use_dma: boolean to know if dma is used in the current transfer
+ * @regmap: holds SYSCFG phandle for Fast Mode Plus bits
  */
 struct stm32f7_i2c_dev {
 	struct i2c_adapter adap;
@@ -296,6 +298,7 @@  struct stm32f7_i2c_dev {
 	bool master_mode;
 	struct stm32_i2c_dma *dma;
 	bool use_dma;
+	struct regmap *regmap;
 };
 
 /**
@@ -1763,6 +1766,30 @@  static int stm32f7_i2c_unreg_slave(struct i2c_client *slave)
 	return 0;
 }
 
+static int stm32f7_i2c_setup_fm_plus_bits(struct platform_device *pdev,
+					  struct stm32f7_i2c_dev *i2c_dev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	int ret;
+	u32 reg, mask;
+
+	i2c_dev->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg-fmp");
+	if (IS_ERR(i2c_dev->regmap)) {
+		/* Optional */
+		return 0;
+	}
+
+	ret = of_property_read_u32_index(np, "st,syscfg-fmp", 1, &reg);
+	if (ret)
+		return ret;
+
+	ret = of_property_read_u32_index(np, "st,syscfg-fmp", 2, &mask);
+	if (ret)
+		return ret;
+
+	return regmap_update_bits(i2c_dev->regmap, reg, mask, mask);
+}
+
 static u32 stm32f7_i2c_func(struct i2c_adapter *adap)
 {
 	return I2C_FUNC_I2C | I2C_FUNC_10BIT_ADDR | I2C_FUNC_SLAVE |
@@ -1828,12 +1855,16 @@  static int stm32f7_i2c_probe(struct platform_device *pdev)
 	i2c_dev->speed = STM32_I2C_SPEED_STANDARD;
 	ret = device_property_read_u32(&pdev->dev, "clock-frequency",
 				       &clk_rate);
-	if (!ret && clk_rate >= 1000000)
+	if (!ret && clk_rate >= 1000000) {
 		i2c_dev->speed = STM32_I2C_SPEED_FAST_PLUS;
-	else if (!ret && clk_rate >= 400000)
+		ret = stm32f7_i2c_setup_fm_plus_bits(pdev, i2c_dev);
+		if (ret)
+			goto clk_free;
+	} else if (!ret && clk_rate >= 400000) {
 		i2c_dev->speed = STM32_I2C_SPEED_FAST;
-	else if (!ret && clk_rate >= 100000)
+	} else if (!ret && clk_rate >= 100000) {
 		i2c_dev->speed = STM32_I2C_SPEED_STANDARD;
+	}
 
 	rst = devm_reset_control_get(&pdev->dev, NULL);
 	if (IS_ERR(rst)) {