| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include <armada_common.h> |
| 10 |
#include <common/debug.h> |
| 11 |
#include <drivers/delay_timer.h> |
| 12 |
#include <drivers/ti/uart/uart_16550.h> |
| 13 |
#include <drivers/console.h> |
| 14 |
#include <plat_marvell.h> |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
unsigned char add_xor_checksum(unsigned char *buf, unsigned char xor_len) |
| 23 |
{ |
| 24 |
unsigned char xor_sum = 0; |
| 25 |
unsigned int i; |
| 26 |
|
| 27 |
for (i = 0; i < xor_len; i++) |
| 28 |
xor_sum ^= buf[i]; |
| 29 |
|
| 30 |
return xor_sum; |
| 31 |
} |
| 32 |
|
| 33 |
int system_power_off(void) |
| 34 |
{ |
| 35 |
static console_t console; |
| 36 |
|
| 37 |
|
| 38 |
unsigned char system_off_now[4] = { '@', 'C', '0' }; |
| 39 |
int i, len; |
| 40 |
|
| 41 |
len = sizeof(system_off_now); |
| 42 |
system_off_now[len - 1] = add_xor_checksum(system_off_now, len); |
| 43 |
|
| 44 |
console_16550_register(PLAT_MARVELL_UART_BASE + 0x100, |
| 45 |
PLAT_MARVELL_UART_CLK_IN_HZ, 115200, &console); |
| 46 |
|
| 47 |
|
| 48 |
for (i = 0; i < len; i++) { |
| 49 |
console.putc(system_off_now[i], &console); |
| 50 |
udelay(1000); |
| 51 |
} |
| 52 |
|
| 53 |
console.flush(&console); |
| 54 |
(void)console_unregister(&console); |
| 55 |
|
| 56 |
mdelay(100); |
| 57 |
|
| 58 |
return 0; |
| 59 |
} |