Fix the LPC47M192 SuperIO on the MPC8641 HPCN
Subsystems (2)
PATCH 1/1 Fix the LPC47M192 SuperIO on the MPC8641 HPCN
This is a fix for the LPC47M192 SuperIO on the MPC8641 HPCN. Specifically this fixes support for the I8042 Keyboard/Mouse and the GPIO on the chip.
Also, the mouse needs to use IRQ 12, which is currently in use by some PCI devices. Move those devices to IRQ 11, and reserve IRQ 12 for the mouse.
---
Note that I submitted this previously as part of a larger patchset. Most of the other patches in the set have been obsoleted, so I'm now submitting this as a standalone patch.
arch/powerpc/boot/dts/mpc8641_hpcn.dts | 4 - arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 43 +++++++++++++++---- 2 files changed, 38 insertions(+), 9 deletions(-)
arch/powerpc/boot/dts/mpc8641_hpcn.dts +2 -2
@@ -268,7 +268,7 @@ /* IDSEL 0x1c */ e000 0 0 1 &i8259 9 2 e000 0 0 2 &i8259 a 2 - e000 0 0 3 &i8259 c 2 + e000 0 0 3 &i8259 b 2 e000 0 0 4 &i8259 7 2 /* IDSEL 0x1d */
@@ -278,7 +278,7 @@ e800 0 0 4 &i8259 0 0 /* IDSEL 0x1e */ - f000 0 0 1 &i8259 c 2 + f000 0 0 1 &i8259 b 2 f000 0 0 2 &i8259 0 0 f000 0 0 3 &i8259 0 0 f000 0 0 4 &i8259 0 0
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c +36 -7
77 lines not on this page · raw message
Quoted 2 lines · Wade Farnsworth
+=A0=A0=A0=A0=A0=A0=A0/* LPC47M192 Super I/O configuration */ +=A0=A0=A0=A0=A0=A0=A0outb(0x55, 0x4e);=A0=A0=A0=A0=A0=A0=A0/* enter supe=
rio config mode */
Quoted 3 lines
+
+=A0=A0=A0=A0=A0=A0=A0/* Enable keyboard and mouse */ +=A0=A0=A0=A0=A0=A0=A0outb(0x07, 0x4e);=A0=A0=A0=A0=A0=A0=A0/* device sel=
ector register */
Quoted 1 line
+=A0=A0=A0=A0=A0=A0=A0outb(0x07, 0x4f);=A0=A0=A0=A0=A0=A0=A0/* select key=
board registers (device 7) */
Quoted 1 line
+=A0=A0=A0=A0=A0=A0=A0outb(0x30, 0x4e);=A0=A0=A0=A0=A0=A0=A0/* keyboard a=
ctivation register */
Quoted 1 line
+=A0=A0=A0=A0=A0=A0=A0outb(0x01, 0x4f);=A0=A0=A0=A0=A0=A0=A0/* activate k=
eyboard */
Hardcoded I/O port numbers always worry me a little. I know that this is supposed to work in general, but can't you read the I/O port range from a device tree property?
Arnd <><
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c static void __devinit quirk_uli1575(stru · line 298
Quoted 2 lines
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c +2
-0+/* enable superio @ 0x4e and keyboard/mouse address decoding */ +pci_write_config_byte (dev,0x63 ,0x90 );
I doubt that comment is accurate.
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c static void __devinit quirk_uli1575(stru · line 305
Quoted 2 lines
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c +2
-0+outb (0x07 ,0x4e );/* device selector register */ +outb (0x07 ,0x4f );/* select keyboard registers (device 7) */
Please abstract out the 4e,4f access sequence, so you can just say write_sio(0x30, 1); or similar.
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c static void __devinit quirk_uli1575(stru · line 314
Quoted 2 lines
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c +2
-0+/* Enable superio runtime registers for gpio in pci i/o space */ +outb (0x20 ,0x4e );/* device id register */
This write is superfluous as far as I can see.
Segher
Quoted 2 lines
Quoted 2 lines
+=A0=A0=A0=A0=A0=A0=A0/* LPC47M192 Super I/O configuration */ +=A0=A0=A0=A0=A0=A0=A0outb(0x55, 0x4e);=A0=A0=A0=A0=A0=A0=A0/* enter =
superio config mode */
Quoted 3 lines
Quoted 3 lines
+
+=A0=A0=A0=A0=A0=A0=A0/* Enable keyboard and mouse */ +=A0=A0=A0=A0=A0=A0=A0outb(0x07, 0x4e);=A0=A0=A0=A0=A0=A0=A0/* device =
selector register */
Quoted 1 line
Quoted 1 line
+=A0=A0=A0=A0=A0=A0=A0outb(0x07, 0x4f);=A0=A0=A0=A0=A0=A0=A0/* select =
keyboard registers (device=20
Quoted 2 lines
Quoted 2 lines
7) */
+=A0=A0=A0=A0=A0=A0=A0outb(0x30, 0x4e);=A0=A0=A0=A0=A0=A0=A0/* =
keyboard activation register */
Quoted 1 line
Quoted 1 line
+=A0=A0=A0=A0=A0=A0=A0outb(0x01, 0x4f);=A0=A0=A0=A0=A0=A0=A0/* =
activate keyboard */
Quoted 5 lines
Hardcoded I/O port numbers always worry me a little. I know that this=20=
is
supposed to work in general, but can't you read the I/O port range =
from
Quoted 1 line
a device tree property?
This code is writing hardcoded values into IRQ# and address window registers, the superio configuration address should be the least of your worries ;-)
Segher
Quoted 10 lines · Arnd Bergmann
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c static void __devinit quirk_uli1575(stru · line 307
Quoted 8 lines · Wade Farnsworth
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c +8
-0+/* LPC47M192 Super I/O configuration */ +outb (0x55 ,0x4e );/* enter superio config mode */ + +/* Enable keyboard and mouse */ +outb (0x07 ,0x4e );/* device selector register */ +outb (0x07 ,0x4f );/* select keyboard registers (device 7) */ +outb (0x30 ,0x4e );/* keyboard activation register */ +outb (0x01 ,0x4f );/* activate keyboard */
Quoted 3 lines
Hardcoded I/O port numbers always worry me a little. I know that this is supposed to work in general, but can't you read the I/O port range from a device tree property?
I suppose I could create a device node for the Super I/O config registers and use those instead of hardcoding it here.
Something to the effect of:
superio_cfg@4e {
reg = <1 4e 2>;
compatible = "smsc-lpc47m192-cfg";
};I'm not sure if the name and compatible properties are appropriate though. Any recommendations?
--Wade
Quoted 6 lines
Quoted 3 lines
Hardcoded I/O port numbers always worry me a little. I know that this is supposed to work in general, but can't you read the I/O port range from a device tree property?
I suppose I could create a device node for the Super I/O config registers and use those instead of hardcoding it here.
I'd just hide it all, do this setup in the firmware, where it belongs, and don't expose the superio config in the device tree.
Quoted 7 lines
superio_cfg@4e { reg = <1 4e 2>; compatible = "smsc-lpc47m192-cfg"; };I'm not sure if the name and compatible properties are appropriate though. Any recommendations?
"superio" and "smsc,lpc47m192" I'd say. You also then should link the logical devices on the superio to the device nodes that represent those. I'm not sure this is all worth it, this is low-level setup the firmware should do and everything else can treat it as a black box.
Segher
Quoted 4 lines · Segher Boessenkool
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c static void __devinit quirk_uli1575(stru · line 298
Quoted 2 lines
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c +2
-0+/* enable superio @ 0x4e and keyboard/mouse address decoding */ +pci_write_config_byte (dev,0x63 ,0x90 );I doubt that comment is accurate.
m1575 legacy interface device register 0x63 is the legacy I/O decoding control.
Writing 0x90 enables ports 0x4e and 0x4f for Super I/O configuration and ports 0x60 and 0x64 for keyboard/mouse.
Quoted 6 lines
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c static void __devinit quirk_uli1575(stru · line 305
Quoted 3 lines
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c +2
-0+outb (0x07 ,0x4e );/* device selector register */ +outb (0x07 ,0x4f );/* select keyboard registers (device 7) */ Please abstract out the 4e,4f access sequence, so you can just say
write_sio(0x30, 1); or similar.
Sure.
Quoted 5 lines
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c static void __devinit quirk_uli1575(stru · line 314
Quoted 3 lines
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c +2
-0+/* Enable superio runtime registers for gpio in pci i/o space */ +outb (0x20 ,0x4e );/* device id register */ This write is superfluous as far as I can see.
Yes, it appears so. I'll remove it.
--Wade
Quoted 6 lines · Segher Boessenkool
Quoted 6 lines
Quoted 5 lines
Hardcoded I/O port numbers always worry me a little. I know that this is
supposed to work in general, but can't you read the I/O port range from
a device tree property?
Quoted 6 lines
Quoted 2 lines
I suppose I could create a device node for the Super I/O config registers and use those instead of hardcoding it here.
I'd just hide it all, do this setup in the firmware, where it belongs, and don't expose the superio config in the device tree.
That's a valid point. This probably could (should?) be handled by U-boot.
Jon, or others do you have any opinions on this?
Quoted 9 lines
Quoted 8 lines
superio_cfg@4e { reg = <1 4e 2>; compatible = "smsc-lpc47m192-cfg"; };I'm not sure if the name and compatible properties are appropriate though. Any recommendations?
Quoted 6 lines
"superio" and "smsc,lpc47m192" I'd say. You also then should link the logical devices on the superio to the device nodes that represent those. I'm not sure this is all worth it, this is low-level setup the firmware should do and everything else can treat it as a black box.
OK, if we decide to keep this, I'll use those instead.
Thanks.
--Wade
Quoted 10 lines
Quoted 4 lines
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c static void __devinit quirk_uli1575(stru · line 298
Quoted 2 lines
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c +2
-0+/* enable superio @ 0x4e and keyboard/mouse address decoding */ +pci_write_config_byte (dev,0x63 ,0x90 );I doubt that comment is accurate.
m1575 legacy interface device register
0x63is the legacy I/O decoding control.Writing
0x90enables ports0x4eand0x4ffor Super I/O configuration and ports0x60and0x64for keyboard/mouse.
Ah I see. Copy this explanation into your next
version of the patch? :-)
Segher
Quoted 6 lines
Quoted 3 lines
I'd just hide it all, do this setup in the firmware, where it belongs, and don't expose the superio config in the device tree.
That's a valid point. This probably could (should?) be handled by U-boot.
Yeah. One more argument for this is that _every_
possible OS would need this code executed before
it runs.
Segher
Quoted 6 lines · Segher Boessenkool
Quoted 6 lines
Quoted 5 lines
Hardcoded I/O port numbers always worry me a little. I know that this is
supposed to work in general, but can't you read the I/O port range from
a device tree property?
Quoted 6 lines
Quoted 2 lines
I suppose I could create a device node for the Super I/O config registers and use those instead of hardcoding it here.
I'd just hide it all, do this setup in the firmware, where it belongs, and don't expose the superio config in the device tree.
No more. No more firmware-only initializations. It sounds great, in principle, until you actually have to figure out why someone's setup isn't working. I'm tired of having to see if the dts, u-boot, and Linux are in sync. If Linux wants to use a device, I think it's not unreasonable to have it setup the device itself. That way, Linux can do whatever it wants with the device, and not have to rely on U-Boot (or some other firmware) setting up the appropriate bits.
Quoted 9 lines
Quoted 8 lines
superio_cfg@4e { reg = <1 4e 2>; compatible = "smsc-lpc47m192-cfg"; };I'm not sure if the name and compatible properties are appropriate though. Any recommendations?
Quoted 6 lines
"superio" and "smsc,lpc47m192" I'd say. You also then should link the logical devices on the superio to the device nodes that represent those. I'm not sure this is all worth it, this is low-level setup the firmware should do and everything else can treat it as a black box.
Please...no. What happens next is that we find a small bug that requires we modify U-Boot to do the initialization slightly differently, and then requires Linux to act slightly differently. And then I get emails every day from people wondering why their boards don't work.
Andy
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
I suppose I could create a device node for the Super I/O config registers and use those instead of hardcoding it here.
I'd just hide it all, do this setup in the firmware, where it belongs, and don't expose the superio config in the device tree.
No more. No more firmware-only initializations.
This setup is very board specific, and the board cannot reasonably work without that setup being done right. You really want to push _that_ into Linux? Alternatively, you could put it into the device tree, but that doesn't help anything either.
Quoted 1 line
It sounds great, in principle, until you actually have to figure out why someone's setup isn't working. I'm tired of having to see if the dts, u-boot, and Linux are in sync. If Linux wants to use a device, I think it's not unreasonable to have it setup the device itself. That way, Linux can do whatever it wants with the device, and not have to rely on U-Boot (or some other firmware) setting up the appropriate bits.
There is one and only one way to set up the superio for a certain board (assuming the legacy I/O and IRQ values are considered fixed values).
Quoted 1 line
Please...no. What happens next is that we find a small bug that requires we modify U-Boot to do the initialization slightly differently, and then requires Linux to act slightly differently.
This is equivalent to needing a board-level fix really.
Segher