Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
awilliam
GitHub Repository: awilliam/linux-vfio
Path: blob/master/arch/mips/emma/markeins/led.c
10818 views
1
/*
2
* Copyright (C) NEC Electronics Corporation 2004-2006
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
#include <linux/kernel.h>
19
#include <linux/types.h>
20
#include <linux/string.h>
21
#include <asm/emma/emma2rh.h>
22
23
const unsigned long clear = 0x20202020;
24
25
#define LED_BASE 0xb1400038
26
27
void markeins_led_clear(void)
28
{
29
emma2rh_out32(LED_BASE, clear);
30
emma2rh_out32(LED_BASE + 4, clear);
31
}
32
33
void markeins_led(const char *str)
34
{
35
int i;
36
int len = strlen(str);
37
38
markeins_led_clear();
39
if (len > 8)
40
len = 8;
41
42
if (emma2rh_in32(0xb0000800) & (0x1 << 18))
43
for (i = 0; i < len; i++)
44
emma2rh_out8(LED_BASE + i, str[i]);
45
else
46
for (i = 0; i < len; i++)
47
emma2rh_out8(LED_BASE + (i & 4) + (3 - (i & 3)),
48
str[i]);
49
}
50
51
void markeins_led_hex(u32 val)
52
{
53
char str[10];
54
55
sprintf(str, "%08x", val);
56
markeins_led(str);
57
}
58
59