From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiko Schocher Date: Fri, 20 Mar 2015 11:10:28 +0100 Subject: [U-Boot] question about software i2c multi instance In-Reply-To: <550BEBEC.7060609@atmel.com> References: <550BEBEC.7060609@atmel.com> Message-ID: <550BF214.7060208@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello Bo, Am 20.03.2015 10:44, schrieb Bo Shen: > Hi Heiko, > After check the software i2c code, I found it can not support multi instances, although it has I2C_SOFT_DECLARATIONS2, I2C_SOFT_DECLARATIONS3, I2C_SOFT_DECLARATIONS4. > Because, when do GPIO operation, there is only one pair of CONFIG_SOFT_I2C_GPIO_SCL and CONFIG_SOFT_I2C_GPIO_SDA. > So, if want to support multi instances, it needs to extend the GPIO configuration for SCL/SDA, am I right? Prefered way should be to use DM, Przemyslaw posted patches for the soft-i2c driver, see http://lists.denx.de/pipermail/u-boot/2015-March/207641.html maybe you can try this? If not, you are right, you must define your own I2C_SCL/I2C_SDA/I2C_READ/I2C_INIT defines, for example: # define I2C_SCL(bit) \ do { \ switch(I2C_ADAP_HWNR) { case 0: gpio_direction_output(CONFIG_SOFT_I2C_GPIO_SCL_0, bit); \ break; case 1: gpio_direction_output(CONFIG_SOFT_I2C_GPIO_SCL_1, bit); \ break; [...] I2C_GPIO_SYNC; \ } while (0) bye, Heiko -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany