treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156
[linux-block.git] / arch / mips / emma / markeins / led.c
CommitLineData
1a59d1b8 1// SPDX-License-Identifier: GPL-2.0-or-later
355c471f 2/*
355c471f 3 * Copyright (C) NEC Electronics Corporation 2004-2006
355c471f 4 */
5#include <linux/kernel.h>
6#include <linux/types.h>
7#include <linux/string.h>
d91f2cbe 8#include <asm/emma/emma2rh.h>
355c471f 9
10const unsigned long clear = 0x20202020;
11
12#define LED_BASE 0xb1400038
13
14void markeins_led_clear(void)
15{
16 emma2rh_out32(LED_BASE, clear);
17 emma2rh_out32(LED_BASE + 4, clear);
18}
19
20void 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
38void markeins_led_hex(u32 val)
39{
40 char str[10];
41
42 sprintf(str, "%08x", val);
43 markeins_led(str);
44}