On Sun, 01 Jun 2025 13:23:06 -0400
"Ted Unangst" <[email protected]> wrote:
> I think maybe we could go in this direction. This starts adding support
> for the mux port to pckbc. It's missing the correct probe, but you can
> change the 0 to 1 and it should work.
>
> FreeBSD does something like this.
>
> Index: pckbc/pms.c
> ===================================================================
> RCS file: /home/cvs/src/sys/dev/pckbc/pms.c,v
> diff -u -p -r1.101 pms.c
> --- pckbc/pms.c 28 Apr 2025 13:35:39 -0000 1.101
> +++ pckbc/pms.c 1 Jun 2025 17:17:03 -0000
> @@ -717,6 +717,9 @@ pmsprobe(struct device *parent, void *ma
> if (pa->pa_slot != PCKBC_AUX_SLOT)
> return (0);
>
> + if (0)
> + pckbc_mux_enable(pa->pa_tag, 1);
> +
> /* Flush any garbage. */
> pckbc_flush(pa->pa_tag, pa->pa_slot);
>
> Index: ic/i8042reg.h
> ===================================================================
> RCS file: /home/cvs/src/sys/dev/ic/i8042reg.h,v
> diff -u -p -r1.9 i8042reg.h
> --- ic/i8042reg.h 5 May 2015 16:27:20 -0000 1.9
> +++ ic/i8042reg.h 1 Jun 2025 17:07:42 -0000
> @@ -21,6 +21,7 @@
> #define KBC_KBDECHO 0xd2 /* echo to keyboard port */
> #define KBC_AUXECHO 0xd3 /* echo to auxiliary port */
> #define KBC_AUXWRITE 0xd4 /* write to auxiliary port */
> +#define KBC_MUXWRITE 0x90 /* write to mux port */
> #define KBC_SELFTEST 0xaa /* start self-test */
> #define KBC_KBDTEST 0xab /* test keyboard port */
> #define KBC_KBDDISABLE 0xad /* disable keyboard port */
> Index: ic/pckbc.c
> ===================================================================
> RCS file: /home/cvs/src/sys/dev/ic/pckbc.c,v
> diff -u -p -r1.55 pckbc.c
> --- ic/pckbc.c 26 Aug 2023 15:01:00 -0000 1.55
> +++ ic/pckbc.c 1 Jun 2025 17:15:52 -0000
> @@ -220,7 +220,8 @@ pckbc_send_devcmd(struct pckbc_internal
> bus_space_handle_t ioh_c = t->t_ioh_c;
>
> if (slot == PCKBC_AUX_SLOT) {
> - if (!pckbc_send_cmd(iot, ioh_c, KBC_AUXWRITE))
> + int cmd = t->t_muxport ? KBC_MUXWRITE + t->t_muxport :
> KBC_AUXWRITE;
> + if (!pckbc_send_cmd(iot, ioh_c, cmd))
> return (0);
> }
> if (!pckbc_wait_output(iot, ioh_c))
> @@ -552,6 +553,13 @@ static struct pckbc_portcmd {
> KBC_AUXENABLE, KBC_AUXDISABLE,
> }
> };
> +
> +void
> +pckbc_mux_enable(pckbc_tag_t self, int port)
> +{
> + struct pckbc_internal *t = (struct pckbc_internal *)self;
> + t->t_muxport = port;
> +}
>
> void
> pckbc_slot_enable(pckbc_tag_t self, pckbc_slot_t slot, int on)
> Index: ic/pckbcvar.h
> ===================================================================
> RCS file: /home/cvs/src/sys/dev/ic/pckbcvar.h,v
> diff -u -p -r1.17 pckbcvar.h
> --- ic/pckbcvar.h 25 Jul 2023 10:00:44 -0000 1.17
> +++ ic/pckbcvar.h 1 Jun 2025 17:17:34 -0000
> @@ -60,6 +60,7 @@ struct pckbc_internal {
> #define PCKBC_FIXED_SET3 0x0004
> #define PCKBC_CANT_TRANSLATE (PCKBC_FIXED_SET2 | PCKBC_FIXED_SET3)
> int t_haveaux; /* controller has an aux port */
> + int t_muxport; /* use mux port for aux */
>
> struct pckbc_slotdata *t_slotdata[PCKBC_NSLOTS];
>
> @@ -107,6 +108,7 @@ int pckbc_poll_data1(bus_space_tag_t, bu
> void pckbc_set_poll(pckbc_tag_t, pckbc_slot_t, int);
> int pckbc_xt_translation(pckbc_tag_t, int *);
> void pckbc_slot_enable(pckbc_tag_t, pckbc_slot_t, int);
> +void pckbc_mux_enable(pckbc_tag_t, int);
>
> void pckbc_attach(struct pckbc_softc *, int);
> int pckbc_cnattach(bus_space_tag_t, bus_addr_t, bus_size_t, int);
Apologies for not noticing that the link I provided for the Aux Muxing spec
proposal (the best documentation I was able to find) had rotted. It isn't a
spec as such, more of an implementation proposal, but I couldn't find a formal
spec doc.
https://www.tonymacx86.com/attachments/ps2-mux-pdf.42272 has another copy.
According to Section 3.6 Recommended Post Assignments, usually port AUX#0
(routing byte 0x90) isn't used, and the first internal pointing device is on
AUX#1 (0x91). This seems to be the case on Let's Notes at least. So maybe
KBC_MUXWRITE 0x91 would be a better default?
I am wondering how Thinkpads with both a touchpad and trackpoint are handled by
the existing driver. By the "hidden multiplexing" described in Sec 2.2?
--
Chris