From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161257AbcFBPfQ (ORCPT ); Thu, 2 Jun 2016 11:35:16 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33412 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161101AbcFBPfO (ORCPT ); Thu, 2 Jun 2016 11:35:14 -0400 MIME-Version: 1.0 In-Reply-To: References: <1462980974-22091-1-git-send-email-cedric.madianga@gmail.com> <1462980974-22091-3-git-send-email-cedric.madianga@gmail.com> Date: Thu, 2 Jun 2016 17:35:12 +0200 Message-ID: Subject: Re: [PATCH 2/5] i2c: Add STM32F4 I2C driver From: "M'boumba Cedric Madianga" To: Maxime Coquelin Cc: Patrice Chotard , Wolfram Sang , Rob Herring , Russell King , "linux-arm-kernel@lists.infradead.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , linux-i2c@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, >> + >> +/** >> + * stm32f4_i2c_xfer() - Transfer combined I2C message >> + * @i2c_adap: Adapter pointer to the controller >> + * @msgs: Pointer to data to be written. >> + * @num: Number of messages to be executed >> + */ >> +static int stm32f4_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], >> + int num) >> +{ >> + struct stm32f4_i2c_dev *i2c_dev = i2c_get_adapdata(i2c_adap); >> + int ret, i; >> + >> + i2c_dev->busy = true; >> + >> + ret = clk_prepare_enable(i2c_dev->clk); >> + if (ret) { >> + dev_err(i2c_dev->dev, "Failed to prepare_enable clock\n"); >> + return ret; >> + } >> + >> + stm32f4_i2c_hw_config(i2c_dev); > Maybe you could call this only at probe and resume time? > You would save some register accesses. Some clarification about this point. We need to call stm32f4_i2c_hw_config before each I2C transfer as at the end of I2C communication the peripheral is automatically disabled and configuration registers are reset. BR, Cedric From mboxrd@z Thu Jan 1 00:00:00 1970 From: "M'boumba Cedric Madianga" Subject: Re: [PATCH 2/5] i2c: Add STM32F4 I2C driver Date: Thu, 2 Jun 2016 17:35:12 +0200 Message-ID: References: <1462980974-22091-1-git-send-email-cedric.madianga@gmail.com> <1462980974-22091-3-git-send-email-cedric.madianga@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: In-Reply-To: Sender: linux-i2c-owner@vger.kernel.org To: Maxime Coquelin Cc: Patrice Chotard , Wolfram Sang , Rob Herring , Russell King , "linux-arm-kernel@lists.infradead.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , linux-i2c@vger.kernel.org List-Id: devicetree@vger.kernel.org Hi, >> + >> +/** >> + * stm32f4_i2c_xfer() - Transfer combined I2C message >> + * @i2c_adap: Adapter pointer to the controller >> + * @msgs: Pointer to data to be written. >> + * @num: Number of messages to be executed >> + */ >> +static int stm32f4_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], >> + int num) >> +{ >> + struct stm32f4_i2c_dev *i2c_dev = i2c_get_adapdata(i2c_adap); >> + int ret, i; >> + >> + i2c_dev->busy = true; >> + >> + ret = clk_prepare_enable(i2c_dev->clk); >> + if (ret) { >> + dev_err(i2c_dev->dev, "Failed to prepare_enable clock\n"); >> + return ret; >> + } >> + >> + stm32f4_i2c_hw_config(i2c_dev); > Maybe you could call this only at probe and resume time? > You would save some register accesses. Some clarification about this point. We need to call stm32f4_i2c_hw_config before each I2C transfer as at the end of I2C communication the peripheral is automatically disabled and configuration registers are reset. BR, Cedric From mboxrd@z Thu Jan 1 00:00:00 1970 From: cedric.madianga@gmail.com (M'boumba Cedric Madianga) Date: Thu, 2 Jun 2016 17:35:12 +0200 Subject: [PATCH 2/5] i2c: Add STM32F4 I2C driver In-Reply-To: References: <1462980974-22091-1-git-send-email-cedric.madianga@gmail.com> <1462980974-22091-3-git-send-email-cedric.madianga@gmail.com> Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi, >> + >> +/** >> + * stm32f4_i2c_xfer() - Transfer combined I2C message >> + * @i2c_adap: Adapter pointer to the controller >> + * @msgs: Pointer to data to be written. >> + * @num: Number of messages to be executed >> + */ >> +static int stm32f4_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], >> + int num) >> +{ >> + struct stm32f4_i2c_dev *i2c_dev = i2c_get_adapdata(i2c_adap); >> + int ret, i; >> + >> + i2c_dev->busy = true; >> + >> + ret = clk_prepare_enable(i2c_dev->clk); >> + if (ret) { >> + dev_err(i2c_dev->dev, "Failed to prepare_enable clock\n"); >> + return ret; >> + } >> + >> + stm32f4_i2c_hw_config(i2c_dev); > Maybe you could call this only at probe and resume time? > You would save some register accesses. Some clarification about this point. We need to call stm32f4_i2c_hw_config before each I2C transfer as at the end of I2C communication the peripheral is automatically disabled and configuration registers are reset. BR, Cedric