i2c: ihs_i2c: Use new fpgamap interface
PATCH 1/3 i2c: ihs_i2c: Use new fpgamap interface
The fpgamap interface has been switched to a "single function + data size" interface. Reflect this change in the IHS I2C driver.
--- drivers/i2c/ihs_i2c.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-)
drivers/i2c/ihs_i2c.c +24 -21
@@ -99,7 +99,8 @@ static int wait_for_int(bool read)#endif #ifdef CONFIG_DM_I2C -fpgamap_read16 (fpga, priv->addr +REG_INTERRUPT_STATUS , &val); +fpgamap_read (fpga, priv->addr +REG_INTERRUPT_STATUS , &val, +FPGAMAP_SIZE_16 );#else I2C_GET_REG (interrupt_status, &val);#endif
@@ -110,7 +111,8 @@ static int wait_for_int(bool read)if (ctr++ >5000 )return 1 ;#ifdef CONFIG_DM_I2C -fpgamap_read16 (fpga, priv->addr +REG_INTERRUPT_STATUS , &val); +fpgamap_read (fpga, priv->addr +REG_INTERRUPT_STATUS , &val, +FPGAMAP_SIZE_16 );#else I2C_GET_REG (interrupt_status, &val);#endif
@@ -128,6 +130,7 @@ static int ihs_i2c_transfer(uchar chip, uchar *buffer, int len, bool read,#endif {u16 val; +u16 data;#ifdef CONFIG_DM_I2C struct ihs_i2c_priv *priv =dev_get_priv (dev);struct udevice *fpga;
@@ -136,13 +139,14 @@ static int ihs_i2c_transfer(uchar chip, uchar *buffer, int len, bool read,#endif /* Clear interrupt status */ + data =I2CINT_ERROR_EV |I2CINT_RECEIVE_EV |I2CINT_TRANSMIT_EV ;#ifdef CONFIG_DM_I2C -fpgamap_write16 (fpga, priv->addr +REG_INTERRUPT_STATUS , -I2CINT_ERROR_EV |I2CINT_RECEIVE_EV |I2CINT_TRANSMIT_EV ); -fpgamap_read16 (fpga, priv->addr +REG_INTERRUPT_STATUS , &val); +fpgamap_write (fpga, priv->addr +REG_INTERRUPT_STATUS , &data, +FPGAMAP_SIZE_16 ); +fpgamap_read (fpga, priv->addr +REG_INTERRUPT_STATUS , &val, +FPGAMAP_SIZE_16 );#else -I2C_SET_REG (interrupt_status,I2CINT_ERROR_EV - |I2CINT_RECEIVE_EV |I2CINT_TRANSMIT_EV ); +I2C_SET_REG (interrupt_status, data);I2C_GET_REG (interrupt_status, &val);#endif
@@ -153,26 +157,24 @@ static int ihs_i2c_transfer(uchar chip, uchar *buffer, int len, bool read,if (len >1 ) val |= buffer[1 ] <<8 ;#ifdef CONFIG_DM_I2C -fpgamap_write16 (fpga, priv->addr +REG_WRITE_MAILBOX_EXT , val); +fpgamap_write (fpga, priv->addr +REG_WRITE_MAILBOX_EXT , &val, +FPGAMAP_SIZE_16 );#else I2C_SET_REG (write_mailbox_ext, val);#endif } + data =I2CMB_NATIVE + | (read ?0 :I2CMB_WRITE ) + | (chip <<1 ) + | ((len >1 ) ?I2CMB_2BYTE :0 ) + | (is_last ?0 :I2CMB_HOLD_BUS ); +#ifdef CONFIG_DM_I2C -fpgamap_write16 (fpga, priv->addr +REG_WRITE_MAILBOX , -I2CMB_NATIVE - | (read ?I2CMB_READ :I2CMB_WRITE ) - | (chip <<1 ) - | ((len >1 ) ?I2CMB_2BYTE :I2CMB_1BYTE ) - | (!is_last ?I2CMB_HOLD_BUS :I2CMB_DONT_HOLD_BUS )); +fpgamap_write (fpga, priv->addr +REG_WRITE_MAILBOX , &data, +FPGAMAP_SIZE_16 );#else -I2C_SET_REG (write_mailbox, -I2CMB_NATIVE - | (read ?0 :I2CMB_WRITE ) - | (chip <<1 ) - | ((len >1 ) ?I2CMB_2BYTE :0 ) - | (is_last ?0 :I2CMB_HOLD_BUS )); +I2C_SET_REG (write_mailbox, data);#endif #ifdef CONFIG_DM_I2C
@@ -185,7 +187,8 @@ static int ihs_i2c_transfer(uchar chip, uchar *buffer, int len, bool read,/* If we want to read, get the bytes from the mailbox */ if (read) {#ifdef CONFIG_DM_I2C -fpgamap_read16 (fpga, priv->addr +REG_READ_MAILBOX_EXT , &val); +fpgamap_read (fpga, priv->addr +REG_READ_MAILBOX_EXT , &val, +FPGAMAP_SIZE_16 );#else I2C_GET_REG (read_mailbox_ext, &val);#endif
--
2.16.1
PATCH 2/3 i2c: fsl: Use dev_read_addr
Since bus translations are now fully supported, use a plain "dev_read_addr" to get the device address from the device tree.
--- drivers/i2c/fsl_i2c.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/i2c/fsl_i2c.c +1 -4
@@ -573,11 +573,8 @@ static int fsl_i2c_set_bus_speed(struct udevice *bus, uint speed)static int fsl_i2c_ofdata_to_platdata (struct udevice *bus) {struct fsl_i2c_dev *dev =dev_get_priv (bus); -fdt_addr_t addr; - addr =dev_read_u32_default (bus,"reg" ,-1 ); - - dev->base =map_sysmem (CONFIG_SYS_IMMR + addr,sizeof (struct fsl_i2c_base )); + dev->base =map_sysmem (dev_read_addr (bus),sizeof (struct fsl_i2c_base ));if (!dev->base)return -ENOMEM ;
Signature · 1 line
2.16.1
PATCH 2/3 i2c: fsl: Use dev_read_addr
Hello Mario,
Am 28.03.2018 um 14:37 schrieb Mario Six:
Quoted 7 lines
Since bus translations are now fully supported, use a plain "
dev_read_addr" to get the device address from the device tree.Signed-off-by Mario Six <[email protected]>--- drivers/i2c/fsl_i2c.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Applied to u-boot-i2c master
Thanks!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 3/3 i2c: fsl: Add option to get clock from DT
In reply to Mario SixAdd an option to get the clock speed from the device tree, hence adding compatibility with DM clock drivers.
--- drivers/i2c/fsl_i2c.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/i2c/fsl_i2c.c +7 -1
@@ -12,6 +12,7 @@#include <i2c.h> /* Functional interface */ #include <asm/io.h> #include <asm/fsl_i2c.h> /* HW definitions */ +#include <clk.h> #include <dm.h> #include <mapmem.h>
@@ -573,6 +574,7 @@ static int fsl_i2c_set_bus_speed(struct udevice *bus, uint speed)static int fsl_i2c_ofdata_to_platdata (struct udevice *bus) {struct fsl_i2c_dev *dev =dev_get_priv (bus); +struct clk clock; dev->base =map_sysmem (dev_read_addr (bus),sizeof (struct fsl_i2c_base ));
@@ -584,7 +586,11 @@ static int fsl_i2c_ofdata_to_platdata(struct udevice *bus) 0x7f); dev->speed =dev_read_u32_default (bus,"clock-frequency" ,400000 ); - dev->i2c_clk = dev->index ? gd->arch.i2c2_clk : gd->arch.i2c1_clk; +if (!clk_get_by_index (bus,0 , &clock)) + dev->i2c_clk =clk_get_rate (&clock); +else + dev->i2c_clk = dev->index ? gd->arch.i2c2_clk : + gd->arch.i2c1_clk;return 0 ; }
Signature · 1 line
2.16.1
PATCH 3/3 i2c: fsl: Add option to get clock from DT
Hello Mario,
Am 28.03.2018 um 14:37 schrieb Mario Six:
Quoted 7 lines
Add an option to get the clock speed from the device tree, hence adding compatibility with DM clock drivers.
Signed-off-by Mario Six <[email protected]>--- drivers/i2c/fsl_i2c.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Applied to u-boot-i2c master
Thanks!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 1/3 i2c: ihs_i2c: Use new fpgamap interface
In reply to Mario SixHello Mario,
Am 28.03.2018 um 14:37 schrieb Mario Six:
Quoted 7 lines
The fpgamap interface has been switched to a "single function + data size" interface. Reflect this change in the IHS I2C driver.
Signed-off-by Mario Six <[email protected]>--- drivers/i2c/ihs_i2c.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-)
Applied to u-boot-i2c master
Thanks!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de