Link: https://lore.kernel.org/r/20260217200002.683975158@linuxfoundation.org Tested-by: Florian Fainelli <florian.fainelli@broadcom.com> Tested-by: Takeshi Ogasawara <takeshi.ogasawara@futuring-girl.com> Tested-by: Peter Schneider <pschneider1968@googlemail.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Tested-by: Salvatore Bonaccorso <carnil@debian.org> Tested-by: Brett A C Sheffield <bacs@librecast.net> Tested-by: Mark Brown <broonie@kernel.org> Tested-by: Luna Jernberg <droidbittin@gmail.com> Tested-by: Ronald Warsow <rwarsow@gmx.de> Tested-by: Justin M. Forbes <jforbes@fedoraproject.org> Tested-by: Ron Economos <re@w6rz.net> Tested-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
58 lines
1.0 KiB
C
58 lines
1.0 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Reset a Jazz machine.
|
|
*
|
|
* We don't trust the firmware so we do it the classic way by poking and
|
|
* stabbing at the keyboard controller ...
|
|
*/
|
|
#include <linux/jiffies.h>
|
|
#include <asm/jazz.h>
|
|
|
|
#define KBD_STAT_IBF 0x02 /* Keyboard input buffer full */
|
|
|
|
static void jazz_write_output(unsigned char val)
|
|
{
|
|
int status;
|
|
|
|
do {
|
|
status = jazz_kh->command;
|
|
} while (status & KBD_STAT_IBF);
|
|
jazz_kh->data = val;
|
|
}
|
|
|
|
static void jazz_write_command(unsigned char val)
|
|
{
|
|
int status;
|
|
|
|
do {
|
|
status = jazz_kh->command;
|
|
} while (status & KBD_STAT_IBF);
|
|
jazz_kh->command = val;
|
|
}
|
|
|
|
static unsigned char jazz_read_status(void)
|
|
{
|
|
return jazz_kh->command;
|
|
}
|
|
|
|
static inline void kb_wait(void)
|
|
{
|
|
unsigned long start = jiffies;
|
|
unsigned long timeout = start + HZ/2;
|
|
|
|
do {
|
|
if (! (jazz_read_status() & 0x02))
|
|
return;
|
|
} while (time_before_eq(jiffies, timeout));
|
|
}
|
|
|
|
void jazz_machine_restart(char *command)
|
|
{
|
|
while(1) {
|
|
kb_wait();
|
|
jazz_write_command(0xd1);
|
|
kb_wait();
|
|
jazz_write_output(0x00);
|
|
}
|
|
}
|