Linux-libre 5.3.12-gnu
[librecmc/linux-libre.git] / arch / mips / emma / markeins / led.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *  Copyright (C) NEC Electronics Corporation 2004-2006
4  */
5 #include <linux/kernel.h>
6 #include <linux/types.h>
7 #include <linux/string.h>
8 #include <asm/emma/emma2rh.h>
9
10 const unsigned long clear = 0x20202020;
11
12 #define LED_BASE 0xb1400038
13
14 void markeins_led_clear(void)
15 {
16         emma2rh_out32(LED_BASE, clear);
17         emma2rh_out32(LED_BASE + 4, clear);
18 }
19
20 void markeins_led(const char *str)
21 {
22         int i;
23         int len = strlen(str);
24
25         markeins_led_clear();
26         if (len > 8)
27                 len = 8;
28
29         if (emma2rh_in32(0xb0000800) & (0x1 << 18))
30                 for (i = 0; i < len; i++)
31                         emma2rh_out8(LED_BASE + i, str[i]);
32         else
33                 for (i = 0; i < len; i++)
34                         emma2rh_out8(LED_BASE + (i & 4) + (3 - (i & 3)),
35                                      str[i]);
36 }
37
38 void markeins_led_hex(u32 val)
39 {
40         char str[10];
41
42         sprintf(str, "%08x", val);
43         markeins_led(str);
44 }