Reset interrupted i2c slaves (galaxy5200)
PATCH 2/3 Reset interrupted i2c slaves (galaxy5200)
Reset any i2c devices that may have been interrupted by a system reset. Normally this would be accomplished by clocking the line until SCL and SDA are released and then sending a start condtiion (From an Atmel datasheet). But since there is only write access to these lines on the MPC5200 we can only attempt to reset any slave devices by sending more start commands than bits the slave is attempting to transmit.
---
Some whitespace cleanup and typos are included in this patch
board/galaxy5200/galaxy5200.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/configs/galaxy5200.h | 9 +++++---- 2 files changed, 46 insertions(+), 4 deletions(-)
board/galaxy5200/galaxy5200.c +41 -0
@@ -155,6 +155,47 @@ phys_size_t initdram(int board_type)return dramsize + dramsize2; } +/* +* Reset any i2c devices that may have been interrupted by a system reset. +* Normally this would be accomplished by clocking the line until SCL and SDA +* are released and then sending a start condtiion (From an Atmel datasheet). +* But since there is only write access to these lines on the MPC5200 we can +* only attempt to reset any slave devices by sending more start commands than +* bits the slave is attempting to transmit. +*/ +int misc_init_f (void ) +{ +volatile struct mpc5xxx_gpio *gpio = + (struct mpc5xxx_gpio *)MPC5XXX_GPIO ; +int i; +u16 state; + + state = gpio->outo_gpioe; + +/* Enable gpio on i2c1 and i2c2 */ + gpio->outo_gpioe |=0xf ; + +/* +* Send an i2c start command 16 times to reset the state machines on +* any slave devices transmitting on the bus. +*/ +for (i =0 ; i <16 ; i++) { + gpio->outo_dvo =0x5 ; +udelay (5 ); + gpio->outo_dvo |=0xa ; +udelay (5 ); + gpio->outo_dvo &=0xa ; +udelay (5 ); + gpio->outo_dvo =0x0 ; +udelay (5 ); + } + +/* Return control of i2c1 and i2c2 */ + gpio->outo_gpioe = state; + +return 0 ; +} +int checkboard (void ) {puts ("Board: galaxy5200\n" );
include/configs/galaxy5200.h +5 -4
@@ -81,8 +81,8 @@#endif /* RAMBOOT will be defined automatically in memory section */ -#define MTDIDS_DEFAULT "nor0=physmap-flash.0" -#define MTDPARTS_DEFAULT "mtdparts=physmap-flash.0:256k(ubootl)," \ +#define MTDIDS_DEFAULT "nor0=physmap-flash.0" +#define MTDPARTS_DEFAULT "mtdparts=physmap-flash.0:256k(ubootl)," \ "1792k(kernel),13312k(jffs2),256k(uboot)ro,256k(oftree),-(space)"/*
@@ -94,7 +94,7 @@#undef CONFIG_BOOTARGS#define CONFIG_PREBOOT "echo;" \ - "echo Welcome to U-Boot"\ + "echo Welcome to U-Boot;"\ "echo"/*
@@ -110,6 +110,7 @@#define CONFIG_SYS_I2C_MODULE 2/* Select I2C module #1 or #2 */ #define CONFIG_SYS_I2C_SPEED 100000/* 100 kHz */ #define CONFIG_SYS_I2C_SLAVE 0x7F +#define CONFIG_MISC_INIT_F 1/* Reset i2c busses */ /* * EEPROM CAT24WC32 configuration
@@ -376,7 +377,7 @@#define CONFIG_SYS_BOOTCS_START CONFIG_SYS_FLASH_BASE#define CONFIG_SYS_BOOTCS_SIZE CONFIG_SYS_FLASH_SIZE -#define CONFIG_SYS_RESET_ADDRESS 0xff000000 +#define CONFIG_SYS_RESET_ADDRESS 0xff000000/* * USB settings
Signature · 1 line
1.6.3.1
PATCH 2/3 Reset interrupted i2c slaves (galaxy5200)
Hi Eric,
Quoted 6 lines · Eric Millbrandt
Reset any i2c devices that may have been interrupted by a system reset. Normally this would be accomplished by clocking the line until SCL and SDA are released and then sending a start condtiion (From an Atmel datasheet). But since there is only write access to these lines on the MPC5200 we can only attempt to reset any slave devices by sending more start commands than bits the slave is attempting to transmit.
<snip>
Quoted 33 lines
include/configs/galaxy5200.h +4
-3@@ -81,8 +81,8 @@#endif /* RAMBOOT will be defined automatically in memory section */ -#define MTDIDS_DEFAULT "nor0=physmap-flash.0" -#define MTDPARTS_DEFAULT "mtdparts=physmap-flash.0:256k(ubootl)," \ +#define MTDIDS_DEFAULT "nor0=physmap-flash.0" +#define MTDPARTS_DEFAULT "mtdparts=physmap-flash.0:256k(ubootl)," \ "1792k(kernel),13312k(jffs2),256k(uboot)ro,256k(oftree),-(space)"/* @@ -94,7 +94,7 @@#undef CONFIG_BOOTARGS#define CONFIG_PREBOOT "echo;" \ - "echo Welcome to U-Boot"\ + "echo Welcome to U-Boot;"\ "echo"/* @@ -110,6 +110,7 @@#define CONFIG_SYS_I2C_MODULE 2/* Select I2C module #1 or #2 */ #define CONFIG_SYS_I2C_SPEED 100000/* 100 kHz */ #define CONFIG_SYS_I2C_SLAVE 0x7F +#define CONFIG_MISC_INIT_F 1/* Reset i2c busses */ /* * EEPROM CAT24WC32 configuration
include/configs/galaxy5200.h line 380
Quoted 5 lines
include/configs/galaxy5200.h +1
-1@@ -376,7 +377,7 @@#define CONFIG_SYS_BOOTCS_START CONFIG_SYS_FLASH_BASE#define CONFIG_SYS_BOOTCS_SIZE CONFIG_SYS_FLASH_SIZE -#define CONFIG_SYS_RESET_ADDRESS 0xff000000 +#define CONFIG_SYS_RESET_ADDRESS 0xff000000
Other than the "#define CONFIG_MISC_INIT_F 1" change, the modifications to include/configs/galaxy5200.h should be separated out into a different patch (if you want to have them committed) as they don't have anything to do with the patch's title and description.
Best,
Peter
PATCH 2/3 Reset interrupted i2c slaves (galaxy5200)
In reply to Eric MillbrandtHi Eric,
Quoted 6 lines
Reset any i2c devices that may have been interrupted by a system reset. Normally this would be accomplished by clocking the line until SCL and SDA are released and then sending a start condtiion (From an Atmel datasheet). But since there is only write access to these lines on the MPC5200 we can only attempt to reset any slave devices by sending more start commands than bits the slave is attempting to transmit.
You may want to talk to Heiko (on CC) about this deblocking stuff. Heiko implemented an algorithm which seems to work very good for a lot of different cpu types.
I think it may be worth to reuse what's available there. And much more, the algorithm Heiko has implemented has been thoroughly tested on actual hardware whereas from your commit-msg it seems that your implementation is more a theoretical one at the moment.
Cheers
Detlev
Signature · 7 lines
You cannot teach what you do not know
You cannot lead where you will not go.
-- Anonymous
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.dePATCH 2/3 Reset interrupted i2c slaves (galaxy5200)
Hi Eric,
Quoted 3 lines
You may want to talk to Heiko (on CC) about this deblocking stuff. Heiko implemented an algorithm which seems to work very good for a lot of different cpu types.
Ah, I was late in catching up, so I see Heiko has already commented on your patches.
Heiko, is the algorithm identical to your implementation?
Cheers
Detlev
Signature · 7 lines
I have always observed that the pretensions of all people are in exact inverse ratio to their merits; this is one of the axioms of morals. -- Joseph Lagrange -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
PATCH 2/3 Reset interrupted i2c slaves (galaxy5200)
In reply to Detlev ZundelHello Detlev,
Quoted 10 lines · Detlev Zundel
Quoted 6 lines
Reset any i2c devices that may have been interrupted by a system reset. Normally this would be accomplished by clocking the line until SCL and SDA are released and then sending a start condtiion (From an Atmel datasheet). But since there is only write access to these lines on the MPC5200 we can only attempt to reset any slave devices by sending more start commands than bits the slave is attempting to transmit.
You may want to talk to Heiko (on CC) about this deblocking stuff. Heiko implemented an algorithm which seems to work very good for a lot of different cpu types.
But this is realized for the bitbang driver, and actual only manufacturer (keymile) specific. So, if we can use the I2C pins as GPIO, it is maybe an option, but a fast look in the mpc5200 users manual, didn;t show me a way for using the I2C pins as GPIO, so, we must implement a CPU specific (as we did it for the 83xx) way.
Quoted 4 lines
I think it may be worth to reuse what's available there. And much more, the algorithm Heiko has implemented has been thoroughly tested on actual hardware whereas from your commit-msg it seems that your implementation is more a theoretical one at the moment.
As I understood Eric, there is only write access to the I2C pins, so we couldn;t use "my" deblocking mechanism. As Erics way is as the standard deblocking mechanism in the bitbang driver, I think, it is okay.
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/3 Reset interrupted i2c slaves (galaxy5200)
Hello Heiko,
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Reset any i2c devices that may have been interrupted by a system reset. Normally this would be accomplished by clocking the line until SCL and SDA are released and then sending a start condtiion (From an Atmel datasheet). But since there is only write access to these lines on the MPC5200 we can only attempt to reset any slave devices by sending more start commands than bits the slave is attempting to transmit.
Quoted 6 lines
Quoted 3 lines
You may want to talk to Heiko (on CC) about this deblocking stuff. Heiko implemented an algorithm which seems to work very good for a lot of different cpu types.
But this is realized for the bitbang driver, and actual only manufacturer (keymile) specific.
I don't see a reason, why deblockiung an I2C bus should be manufacturer specific...
Quoted 10 lines
So, if we can use the I2C pins as GPIO, it is maybe
an option, but a fast look in the mpc5200 users manual, didn;t show me a way for using the I2C pins as GPIO, so, we must implement a CPU specific (as we did it for the 83xx) way.Quoted 4 lines
I think it may be worth to reuse what's available there. And much more, the algorithm Heiko has implemented has been thoroughly tested on actual hardware whereas from your commit-msg it seems that your implementation is more a theoretical one at the moment.
Quoted 4 lines
As I understood Eric, there is only write access to the I2C pins, so we couldn;t use "my" deblocking mechanism. As Erics way is as the standard deblocking mechanism in the bitbang driver, I think, it is okay.
Ok, thanks for validating though! Maybe we should add some documentation notes about the various places where such things are done?
Cheers
Detlev
Signature · 7 lines
The Speedo3 is very similar to other Intel network chips, that is to say
"apparently designed on a different planet".
-- drivers/net/eepro100.c in Linux source
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de