powerpc/85xx: Workaround MPC8536 GPIO 1 errata.
PATCH 1/1 powerpc/85xx: Workaround MPC8536 GPIO 1 errata.
On MPC8536 Rev 1.0 the status of GPIO pins configured as output cannot be determined by reading GPDAT register. Workaround by reading the status of input pins from GPDAT and the status of output pins from a shadow register.
--- arch/powerpc/sysdev/mpc8xxx_gpio.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
arch/powerpc/sysdev/mpc8xxx_gpio.c +5 -1
@@ -56,9 +56,13 @@ static void mpc8xxx_gpio_save_regs(struct of_mm_gpio_chip *mm)static int mpc8xxx_gpio_get (struct gpio_chip *gc,unsigned int gpio) { +u32 val;struct of_mm_gpio_chip *mm =to_of_mm_gpio_chip (gc); +struct mpc8xxx_gpio_chip *mpc8xxx_gc =to_mpc8xxx_gpio_chip (mm); + + val =in_be32 (mm->regs +GPIO_DAT ) && ~in_be32 (mm->regs +GPIO_DIR ); -return in_be32 (mm->regs +GPIO_DAT ) &mpc8xxx_gpio2mask (gpio); +return (val | mpc8xxx_gc->data) &mpc8xxx_gpio2mask (gpio); }static void mpc8xxx_gpio_set (struct gpio_chip *gc,unsigned int gpio,int val)
Signature · 1 line
1.5.4.3
Quoted 15 lines · Felix Radensky
On MPC8536 Rev 1.0 the status of GPIO pins configured as output cannot be determined by reading GPDAT register. Workaround by reading the status of input pins from GPDAT and the status of output pins from a shadow register.
Signed-off-by Felix Radensky <[email protected]>---
arch/powerpc/sysdev/mpc8xxx_gpio.c| 6 +++++-1 files changed, 5 insertions(+), 1 deletions(-)arch/powerpc/sysdev/mpc8xxx_gpio.c +0
-0
arch/powerpc/sysdev/mpc8xxx_gpio.c static void mpc8xxx_gpio_save_regs(struct · line 64
Quoted 9 lines
arch/powerpc/sysdev/mpc8xxx_gpio.c +4
-0@@ -56,9 +56,13 @@ static void mpc8xxx_gpio_save_regs(struct of_mm_gpio_chip *mm)static int mpc8xxx_gpio_get (struct gpio_chip *gc,unsigned int gpio) { +u32 val;struct of_mm_gpio_chip *mm =to_of_mm_gpio_chip (gc); +struct mpc8xxx_gpio_chip *mpc8xxx_gc =to_mpc8xxx_gpio_chip (mm); + + val =in_be32 (mm->regs +GPIO_DAT ) && ~in_be32 (mm->regs +GPIO_DIR );
it would be good to add a comment in the code about working around the errata.
Quoted 8 lines
arch/powerpc/sysdev/mpc8xxx_gpio.c +1
-1-return in_be32 (mm->regs +GPIO_DAT ) &mpc8xxx_gpio2mask (gpio); +return (val | mpc8xxx_gc->data) &mpc8xxx_gpio2mask (gpio); }static void mpc8xxx_gpio_set (struct gpio_chip *gc,unsigned int gpio,int val)Signature · 1 line
1.5.4.3
- k
Quoted 15 lines · Felix Radensky
On MPC8536 Rev 1.0 the status of GPIO pins configured as output cannot be determined by reading GPDAT register. Workaround by reading the status of input pins from GPDAT and the status of output pins from a shadow register.
Signed-off-by Felix Radensky <[email protected]>--- arch/powerpc/sysdev/mpc8xxx_gpio.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)arch/powerpc/sysdev/mpc8xxx_gpio.c +0
-0
arch/powerpc/sysdev/mpc8xxx_gpio.c static void mpc8xxx_gpio_save_regs(struct of_mm_gpio_chip *mm) · line 63
Quoted 8 lines
arch/powerpc/sysdev/mpc8xxx_gpio.c +4
-0@@ -56,9 +56,13 @@ static void mpc8xxx_gpio_save_regs(struct of_mm_gpio_chip *mm)static int mpc8xxx_gpio_get (struct gpio_chip *gc,unsigned int gpio) { +u32 val;struct of_mm_gpio_chip *mm =to_of_mm_gpio_chip (gc); +struct mpc8xxx_gpio_chip *mpc8xxx_gc =to_mpc8xxx_gpio_chip (mm); + + val =in_be32 (mm->regs +GPIO_DAT ) && ~in_be32 (mm->regs +GPIO_DIR );
Are you sure about &&?
Plus, this are two reads instead of just one. I think it'll be better to implement mpc8536_gpio_get(), and then do
if (of_device_is_compatible(np, ... 8536-gpio-bank ...))
gc->get = mpc8536_gpio_get; else gc->get = mpc8xxx_gpio_get;
arch/powerpc/sysdev/mpc8xxx_gpio.c static void mpc8xxx_gpio_save_regs(struct of_mm_gpio_chip *mm) · line 68
Quoted 5 lines
arch/powerpc/sysdev/mpc8xxx_gpio.c +1
-1-return in_be32 (mm->regs +GPIO_DAT ) &mpc8xxx_gpio2mask (gpio); +return (val | mpc8xxx_gc->data) &mpc8xxx_gpio2mask (gpio); }static void mpc8xxx_gpio_set (struct gpio_chip *gc,unsigned int gpio,int val)
Thanks,
Signature · 3 lines
Anton Vorontsov email: [email protected] irc://irc.freenode.net/bd2
Quoted 29 lines · Anton Vorontsov
Quoted 15 lines · Felix Radensky
On MPC8536 Rev 1.0 the status of GPIO pins configured as output cannot be determined by reading GPDAT register. Workaround by reading the status of input pins from GPDAT and the status of output pins from a shadow register.
Signed-off-by Felix Radensky <[email protected]>---
arch/powerpc/sysdev/mpc8xxx_gpio.c| 6 +++++-1 files changed, 5 insertions(+), 1 deletions(-)arch/powerpc/sysdev/mpc8xxx_gpio.c +0
-0arch/powerpc/sysdev/mpc8xxx_gpio.c static void mpc8xxx_gpio_save_regs(struct · line 65
Quoted 10 lines
arch/powerpc/sysdev/mpc8xxx_gpio.c +4
-0@@ -56,9 +56,13 @@ static void mpc8xxx_gpio_save_regs(struct of_mm_gpio_chip *mm)static int mpc8xxx_gpio_get (struct gpio_chip *gc,unsigned int gpio) { +u32 val;struct of_mm_gpio_chip *mm =to_of_mm_gpio_chip (gc); +struct mpc8xxx_gpio_chip *mpc8xxx_gc =to_mpc8xxx_gpio_chip (mm); + + val =in_be32 (mm->regs +GPIO_DAT ) && ~in_be32 (mm->regs +GPIO_DIR );Are you sure about &&?
Quoted 7 lines
Plus, this are two reads instead of just one. I think it'll be better to implement
mpc8536_gpio_get(), and then doif (of_device_is_compatible(np, ... 8536-gpio-bank ...))
gc->get = mpc8536_gpio_get; else gc->get = mpc8xxx_gpio_get;
I think 8572 has the same errata.
Quoted 17 lines
Quoted 6 lines
arch/powerpc/sysdev/mpc8xxx_gpio.c +1
-1-return in_be32 (mm->regs +GPIO_DAT ) &mpc8xxx_gpio2mask (gpio); +return (val | mpc8xxx_gc->data) &mpc8xxx_gpio2mask (gpio); }static void
mpc8xxx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)Thanks,
Signature · 7 lines
Anton Vorontsov email: [email protected] irc://irc.freenode.net/bd2 _______________________________________________ Linuxppc-dev mailing list [email protected] https://lists.ozlabs.org/listinfo/linuxppc-dev
Quoted 17 lines · Anton Vorontsov
Quoted 16 lines · Felix Radensky
On MPC8536 Rev 1.0 the status of GPIO pins configured as output cannot be determined by reading GPDAT register. Workaround by reading the status of input pins from GPDAT and the status of output pins from a shadow register.
Signed-off-by Felix Radensky <[email protected]>--- arch/powerpc/sysdev/mpc8xxx_gpio.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)arch/powerpc/sysdev/mpc8xxx_gpio.c +0
-0@@ -56,9 +56,13 @@ static void mpc8xxx_gpio_save_regs(struct of_mm_gpio_chip *mm)
Quoted 9 lines
arch/powerpc/sysdev/mpc8xxx_gpio.c static void mpc8xxx_gpio_save_regs(struct of_mm_gpio_chip *mm) · line 63
Quoted 7 lines
arch/powerpc/sysdev/mpc8xxx_gpio.c +4
-0static int mpc8xxx_gpio_get (struct gpio_chip *gc,unsigned int gpio) { +u32 val;struct of_mm_gpio_chip *mm =to_of_mm_gpio_chip (gc); +struct mpc8xxx_gpio_chip *mpc8xxx_gc =to_mpc8xxx_gpio_chip (mm); + + val =in_be32 (mm->regs +GPIO_DAT ) && ~in_be32 (mm->regs +GPIO_DIR );Are you sure about &&?
No, that's obviously a typo. Bitwise & intended.
Quoted 8 lines
Plus, this are two reads instead of just one. I think it'll be better to implement
mpc8536_gpio_get(), and then doif (of_device_is_compatible(np, ... 8536-gpio-bank ...))
gc->get = mpc8536_gpio_get; else gc->get = mpc8xxx_gpio_get;
The reads are from 2 different registers, how do you propose to replace them by a single read ?
I'll implement mpc8572_gpio_get(), suitable for both 8572 and 8536.
Quoted 9 lines
arch/powerpc/sysdev/mpc8xxx_gpio.c static void mpc8xxx_gpio_save_regs(struct of_mm_gpio_chip *mm) · line 68
Quoted 6 lines
arch/powerpc/sysdev/mpc8xxx_gpio.c +1
-1-return in_be32 (mm->regs +GPIO_DAT ) &mpc8xxx_gpio2mask (gpio); +return (val | mpc8xxx_gc->data) &mpc8xxx_gpio2mask (gpio); }static void mpc8xxx_gpio_set (struct gpio_chip *gc,unsigned int gpio,int val)Thanks,
On Tue, Aug 11, 2009 at 06:12:12PM +0300, Felix Radensky wrote:
[...]
Quoted 10 lines
Quoted 7 lines
Plus, this are two reads instead of just one. I think it'll be better to implement
mpc8536_gpio_get(), and then doif (of_device_is_compatible(np, ... 8536-gpio-bank ...))
gc->get = mpc8536_gpio_get; else gc->get = mpc8xxx_gpio_get;The reads are from 2 different registers, how do you propose to replace them by a single read ?
I didn't propose that, I proposed to not do 2 reads for CPUs that don't have the errata. ;-)
Quoted 1 line
I'll implement
mpc8572_gpio_get(), suitable for both 8572 and 8536.
Great, thanks!
Signature · 3 lines
Anton Vorontsov email: [email protected] irc://irc.freenode.net/bd2