i2c: soft_i2c: add simple GPIO implementation
PATCH 1/2 i2c: soft_i2c: add simple GPIO implementation
Since the vast majority of GPIO I2C implementations behave the same way, support the common GPIO framework with default settings.
This adds two new defines CONFIG_SOFT_I2C_GPIO_{SCL,SDA} so that boards which want GPIO I2C support need only define these.
--- README | 10 ++++++++++ drivers/i2c/soft_i2c.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 0 deletions(-)
README +10 -0
@@ -1495,6 +1495,16 @@ The following options need to be configured: #define I2C_DELAY udelay(2) + CONFIG_SOFT_I2C_GPIO_SCL / CONFIG_SOFT_I2C_GPIO_SDA + + If your arch supports the generic GPIO framework (asm/gpio.h), + then you may alternatively define the two GPIOs that are to be + used as SCL / SDA. Any of the previous I2C_xxx macros will + have GPIO-based defaults assigned to them as appropriate. + + You should define these to the GPIO value as given directly to + the generic GPIO functions. + CONFIG_SYS_I2C_INIT_BOARD When a board is reset during an i2c bus transfer
drivers/i2c/soft_i2c.c +42 -0
48 lines not on this page · raw message
Signature · 1 line
1.7.1.1
PATCH 1/2 i2c: soft_i2c: add simple GPIO implementation
Quoted 5 lines · On Monday, July 05, 2010 04:50:08 Mike Frysinger wrote:
Since the vast majority of GPIO I2C implementations behave the same way, support the common GPIO framework with default settings.
This adds two new defines CONFIG_SOFT_I2C_GPIO_{SCL,SDA} so that boards which want GPIO I2C support need only define these.
i guess postpone this until we can get the tristate/sda issues sorted out -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100711/5b92dd92/attachment.pgp
PATCH 1/2 i2c: soft_i2c: add simple GPIO implementation
In reply to Mike FrysingerQuoted 7 lines · Mike Frysinger
Since the vast majority of GPIO I2C implementations behave the same way, support the common GPIO framework with default settings.
This adds two new defines CONFIG_SOFT_I2C_GPIO_{SCL,SDA} so that boards which want GPIO I2C support need only define these.
Signed-off-by Mike Frysinger<[email protected]>
Tested on my nios2 boards after additional patch "i2c: fix SDA contention in read_byte()".
Cheers,
Thomas
PATCH 2/2 Blackfin: bf533/bf561 boards: convert to new soft gpio i2c code
In reply to Mike FrysingerUse the new common gpio framework to simplify and unify the soft i2c configuration settings.
---
note: i can run this through the Blackfin tree if you want
include/configs/bf533-ezkit.h | 43 +--------------------------------------- include/configs/bf533-stamp.h | 43 +--------------------------------------- include/configs/bf561-ezkit.h | 42 +-------------------------------------- include/configs/blackstamp.h | 28 +------------------------ include/configs/ibf-dsp561.h | 29 +------------------------- 5 files changed, 10 insertions(+), 175 deletions(-)
include/configs/bf533-ezkit.h +2 -41
@@ -94,49 +94,10 @@/* * I2C Settings -* By default PF1 is used as SDA and PF0 as SCL on the Stamp board */ #define CONFIG_SOFT_I2C -#ifdef CONFIG_SOFT_I2C -#define PF_SCL PF0 -#define PF_SDA PF1 -#define I2C_INIT \ - do { \ - *pFIO_DIR |= PF_SCL; \ - SSYNC(); \ - } while (0) -#define I2C_ACTIVE \ - do { \ - *pFIO_DIR |= PF_SDA; \ - *pFIO_INEN &= ~PF_SDA; \ - SSYNC(); \ - } while (0) -#define I2C_TRISTATE \ - do { \ - *pFIO_DIR &= ~PF_SDA; \ - *pFIO_INEN |= PF_SDA; \ - SSYNC(); \ - } while (0) -#define I2C_READ ((*pFIO_FLAG_D & PF_SDA) != 0) -#define I2C_SDA (bit) \ - do { \ - if (bit) \ - *pFIO_FLAG_S = PF_SDA; \ - else \ - *pFIO_FLAG_C = PF_SDA; \ - SSYNC(); \ - } while (0) -#define I2C_SCL (bit) \ - do { \ - if (bit) \ - *pFIO_FLAG_S = PF_SCL; \ - else \ - *pFIO_FLAG_C = PF_SCL; \ - SSYNC(); \ - } while (0) -#define I2C_DELAY udelay(5)/* 1/4 I2C clock duration */ - -#endif +#define CONFIG_SOFT_I2C_GPIO_SCL GPIO_PF0 +#define CONFIG_SOFT_I2C_GPIO_SDA GPIO_PF1/*
include/configs/bf533-stamp.h +2 -41
51 lines not on this page · raw message
include/configs/bf561-ezkit.h +2 -40
48 lines not on this page · raw message
include/configs/blackstamp.h +2 -26
@@ -206,32 +206,8 @@* them yet. You can (and probably should) change these values! */ #ifdef CONFIG_SOFT_I2C - -#define PF_SCL PF9 -#define PF_SDA PF8 - -#define I2C_INIT do { *pFIO_DIR |= PF_SCL; SSYNC(); } while (0) -#define I2C_ACTIVE do { *pFIO_DIR |= PF_SDA; *pFIO_INEN &= ~PF_SDA; SSYNC(); } while (0) -#define I2C_TRISTATE do { *pFIO_DIR &= ~PF_SDA; *pFIO_INEN |= PF_SDA; SSYNC(); } while (0) -#define I2C_READ ((*pFIO_FLAG_D & PF_SDA) != 0) -#define I2C_SDA (bit) \ - do { \ - if (bit) \ - *pFIO_FLAG_S = PF_SDA; \ - else \ - *pFIO_FLAG_C = PF_SDA; \ - SSYNC(); \ - } while (0) -#define I2C_SCL (bit) \ - do { \ - if (bit) \ - *pFIO_FLAG_S = PF_SCL; \ - else \ - *pFIO_FLAG_C = PF_SCL; \ - SSYNC(); \ - } while (0) -#define I2C_DELAY udelay(5)/* 1/4 I2C clock duration */ - +#define CONFIG_SOFT_I2C_GPIO_SCL GPIO_PF9 +#define CONFIG_SOFT_I2C_GPIO_SDA GPIO_PF8#define CONFIG_SYS_I2C_SPEED 50000#define CONFIG_SYS_I2C_SLAVE 0xFE#endif
include/configs/ibf-dsp561.h +2 -27
@@ -112,33 +112,8 @@* I2C Settings */ #define CONFIG_SOFT_I2C 1 -#define PF_SCL 0x1/*PF0*/ -#define PF_SDA 0x2/*PF1*/ - -#ifdef CONFIG_SOFT_I2C -#define I2C_INIT do { *pFIO0_DIR |= PF_SCL; SSYNC(); } while (0) -#define I2C_ACTIVE do { *pFIO0_DIR |= PF_SDA; *pFIO0_INEN &= ~PF_SDA; SSYNC(); } while (0) -#define I2C_TRISTATE do { *pFIO0_DIR &= ~PF_SDA; *pFIO0_INEN |= PF_SDA; SSYNC(); } while (0) -#define I2C_READ ((*pFIO0_FLAG_D & PF_SDA) != 0) -#define I2C_SDA (bit) \ - do { \ - if (bit) \ - *pFIO0_FLAG_S = PF_SDA; \ - else \ - *pFIO0_FLAG_C = PF_SDA; \ - SSYNC(); \ - } while (0) -#define I2C_SCL (bit) \ - do { \ - if (bit) \ - *pFIO0_FLAG_S = PF_SCL; \ - else \ - *pFIO0_FLAG_C = PF_SCL; \ - SSYNC(); \ - } while (0) -#define I2C_DELAY udelay(5)/* 1/4 I2C clock duration */ - -#endif +#define CONFIG_SOFT_I2C_GPIO_SCL GPIO_PF0 +#define CONFIG_SOFT_I2C_GPIO_SDA GPIO_PF1/*
Signature · 1 line
1.7.1.1
PATCH 2/2 Blackfin: bf533/bf561 boards: convert to new soft gpio i2c code
Hello Mike,
Quoted 6 lines · Mike Frysinger
Use the new common gpio framework to simplify and unify the soft i2c configuration settings.
Signed-off-by Mike Frysinger <[email protected]>---
note: i can run this through the Blackfin tree if you want
I actually tried your 2 patches, but this patch doesn;t apply :-(
[hs at pollux u-boot-i2c]$ git am -i --whitespace=strip \[U-Boot\]\ \[PATCH\ 2_2\]\ Blackfin\:\ bf533_bf561\ boards\:\ convert\ to\ new\ soft\ gpio\ i2c\ code.eml
Commit Body is:
--------------------------
Blackfin: bf533/bf561 boards: convert to new soft gpio i2c code
Use the new common gpio framework to simplify and unify the soft i2c configuration settings.
--------------------------
Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all y
Applying: Blackfin: bf533/bf561 boards: convert to new soft gpio i2c code
error: patch failed: include/configs/bf533-ezkit.h:94
error: include/configs/bf533-ezkit.h: patch does not apply
error: patch failed: include/configs/bf533-stamp.h:138
error: include/configs/bf533-stamp.h: patch does not apply
error: patch failed: include/configs/bf561-ezkit.h:112
error: include/configs/bf561-ezkit.h: patch does not apply
error: patch failed: include/configs/ibf-dsp561.h:112
error: include/configs/ibf-dsp561.h: patch does not apply
Patch failed at 0001 Blackfin: bf533/bf561 boards: convert to new soft gpio i2c code When you have resolved this problem run "git am -i --resolved".
If you would prefer to skip this patch, instead run "git am -i --skip". To restore the original branch and stop patching run "git am -i --abort". [hs at pollux u-boot-i2c]$
Beside of this issue, your 2 patches are looking good!
So, if you want to pick up this patches in your blackfin tree, you can add my
bye
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH 2/2 Blackfin: bf533/bf561 boards: convert to new soft gpio i2c code
Quoted 9 lines · On Monday, July 05, 2010 07:14:16 Heiko Schocher wrote:
Quoted 6 lines · Mike Frysinger
Use the new common gpio framework to simplify and unify the soft i2c configuration settings.
Signed-off-by Mike Frysinger <[email protected]>---
note: i can run this through the Blackfin tree if you wantI actually tried your 2 patches, but this patch doesn;t apply :-(
it might depend on patches that are pending in my tree ...
Quoted 4 lines
So, if you want to pick up this patches in your blackfin tree, you can add my
Acked-by Heiko Schocher <[email protected]>
will do then, thanks
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100705/9d80141d/attachment.pgp
PATCH v2 1/2 i2c: soft_i2c: add simple GPIO implementation
In reply to Mike FrysingerSince the vast majority of GPIO I2C implementations behave the same way, support the common GPIO framework with default settings.
This adds two new defines CONFIG_SOFT_I2C_GPIO_{SCL,SDA} so that boards which want GPIO I2C support need only define these.
---
v2
- stub out tristate/active by default and let the gpios handle things in the sda/scl macros
README | 10 +++++++++ drivers/i2c/soft_i2c.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 0 deletions(-)
README +10 -0
@@ -1495,6 +1495,16 @@ The following options need to be configured: #define I2C_DELAY udelay(2) + CONFIG_SOFT_I2C_GPIO_SCL / CONFIG_SOFT_I2C_GPIO_SDA + + If your arch supports the generic GPIO framework (asm/gpio.h), + then you may alternatively define the two GPIOs that are to be + used as SCL / SDA. Any of the previous I2C_xxx macros will + have GPIO-based defaults assigned to them as appropriate. + + You should define these to the GPIO value as given directly to + the generic GPIO functions. + CONFIG_SYS_I2C_INIT_BOARD When a board is reset during an i2c bus transfer
drivers/i2c/soft_i2c.c +52 -0
58 lines not on this page · raw message
Signature · 1 line
1.7.1.1
PATCH v2 1/2 i2c: soft_i2c: add simple GPIO implementation
Quoted 6 lines · Mike Frysinger
Since the vast majority of GPIO I2C implementations behave the same way, support the common GPIO framework with default settings.
This adds two new defines CONFIG_SOFT_I2C_GPIO_{SCL,SDA} so that boards which want GPIO I2C support need only define these.
Quoted 7 lines
Signed-off-by Mike Frysinger <[email protected]>Tested-by Thomas Chou <[email protected]>---
v2
- stub out tristate/active by default and let the gpios handle things in the sda/scl macros
Tested v2 on nios2 boards.
PATCH v2 1/2 i2c: soft_i2c: add simple GPIO implementation
In reply to Mike FrysingerHello Mike,
Quoted 8 lines · Mike Frysinger
Since the vast majority of GPIO I2C implementations behave the same way, support the common GPIO framework with default settings.
This adds two new defines CONFIG_SOFT_I2C_GPIO_{SCL,SDA} so that boards which want GPIO I2C support need only define these.
Signed-off-by Mike Frysinger <[email protected]>Tested-by Thomas Chou <[email protected]>
Quoted 8 lines
---
v2
- stub out tristate/active by default and let the gpios handle things in the sda/scl macrosREADME | 10 +++++++++ drivers/i2c/soft_i2c.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 0 deletions(-)
Apllied to u-boot-i2c.git
Thanks.
bye
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany