Blame view

arch/mips/jazz/reset.c 1009 Bytes
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
  /*
   * 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>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  
  #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();
49a89efbb   Ralf Baechle   [MIPS] Fix "no sp...
52
  		jazz_write_command(0xd1);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
53
  		kb_wait();
49a89efbb   Ralf Baechle   [MIPS] Fix "no sp...
54
  		jazz_write_output(0x00);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
55
56
  	}
  }