EzHID
Sun Keyboard Firmware
Introduction
sunkbd_hid is a firmware package for the EZ-USB chip that handles
all interfacing between the serial communication protocol of a Sun type
4 or 5 keyboard and the USB HID driver of any operating system. It
behaves
like a keyboard type interface device with boot protocol capabilities.
The firmware has been augmented by an additional interface that
collects
the serial input stream from a Sun mouse (mine says 'Type 5').
Most of the special function keys are reported through USB but many of
them show no reaction in the console or XFree86. To support the very
important ones, OPEN and FRONT, I have added special functionality in
the scancode converter. As a result the OPEN key is translated to
a simultaneous LALT+F11 and the FRONT key is translated to LALT+F12.
Swapping and hiding windows with these keys must then be configured in
the window manager.
Compilation
The source code is completely written in C. For compilation you need a
recent version of sdcc (any v2.2.2 or later).
Type either
make kbd
make mouse
make kbdmouse
to build the firmware with keyboard, mouse or combined keyboard and
mouse capabilities. The hex-file can be downloaded directly to the
EZ-USB using your preferred method.
The firmware supports both downloading into the device RAM or being
bootloaded from a programmed serial I2C EEPROM on the development
board. In the latter case small modifications have to be applied to the
code. See
the comments in Makefile for detailed instructions. After having
compiled the source code to suit the needs of the bootloading, run
create_ezhid_e2.pl on the compiled hex-file. The output of
create_ezhid_e2.pl has the correct format for the onbaord I2C EEPROM.
The benefit of having the firmware permanently in the EEPROM is that
most modern motherboards detect the USB keyboard boot protocol and
include the keyboard at system boot time. Moreover, you do not have to
set up
a firmware downloader for every operating system you happen to use on
your computer.
Converter
Depending on the type of prototype board you have for the EZ-USB chip,
you will need dedicated converteres.
Most important is the fact that Sun keyboards provide normal 5V level
signals at the PS/2 plug and talks RS232 serial protocol (but not
voltage level!).
The AN2131 device has 5V-TTL tolerant 3.3V I/O ports so it would be
save to
connect the keyboard without level shifters.
If you re-use a Keyspan PDA adapter like I did initially or similar
devices then you have to build some external hardware because
inverters and level shifters are needed to adapt to the standard serial
connector. Don't forget to tie all unused inputs to either GND or Vcc.
Otherwise the IC might not work properly!
The schematic was drawn by
Leonardo M. Teixiera <leonardoteixeira at inetone.com.br>.
If you use a prototype board like the I2CIO
prototype from DeVaSys then you can access the pins TxD0 and RxD0
(RxD1 for the mouse) of the AN2131 directly. Unfortunately, the AN2131
does not provide software switchable logic levels on the serial ports.
In order to connect the SUN keyboard to the AN2131 the signals have to
be inverted by an additional IC. The resulting is similar to the RS232
converter above but without the MAX232.
Especially in the latter case where the inverter IC connects
directly to the AN2131, you will encounter trouble when using a CD4069.
This IC needs proper CMOS logic levels at its inputs which cannot be
ensured by the AN2131. Replace the CD4049 with a TTL-compatible CMOS IC
like the 74HCT04 in this case.
Many thanks to Martin Pohlack for investigating these issues!
The mouse driver uses serial port 1. In this case pin 4 of the PS/2
connector should be wired to RxD1/2 at the EZ-USB chip. I have reused
pin 9 (RI) of the DB 9 serial connector at my Keyspan adapter and
connected pin 19 (PC5/T1) of the AN2131SC device internally to pin 26
(RB2/RxD2).
One last word about the power supply. I use an additional voltage
regulator to source the external glue logic and the keyboard itself. It
could be possible to draw the current directly from the USB supply. My
Sun type 5 keyboard declares to use max. 150 mA and the mouse needs 15
mA, so this combination is realistic from USB specification point of
view. To inform the hub and host about the current consumption you can
adjust the MaxPower value in
the configuration descriptor. It is currently set to 100 what means 200
mA. Be careful when you wire the USB supply to the outside! You could
easily
burn your host controller or hub when generating shorts!
Additional Resources
Back to main