1*b3a5c565Smatt /* $NetBSD: led.c,v 1.8 2015/06/09 22:47:12 matt Exp $ */
216b9c606Sthorpej
316b9c606Sthorpej /*-
416b9c606Sthorpej * Copyright (c) 2001 The NetBSD Foundation, Inc.
516b9c606Sthorpej * All rights reserved.
616b9c606Sthorpej *
716b9c606Sthorpej * This code is derived from software contributed to The NetBSD Foundation
816b9c606Sthorpej * by Jason R. Thorpe.
916b9c606Sthorpej *
1016b9c606Sthorpej * Redistribution and use in source and binary forms, with or without
1116b9c606Sthorpej * modification, are permitted provided that the following conditions
1216b9c606Sthorpej * are met:
1316b9c606Sthorpej * 1. Redistributions of source code must retain the above copyright
1416b9c606Sthorpej * notice, this list of conditions and the following disclaimer.
1516b9c606Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
1616b9c606Sthorpej * notice, this list of conditions and the following disclaimer in the
1716b9c606Sthorpej * documentation and/or other materials provided with the distribution.
1816b9c606Sthorpej *
1916b9c606Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2016b9c606Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2116b9c606Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2216b9c606Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2316b9c606Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2416b9c606Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2516b9c606Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2616b9c606Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2716b9c606Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2816b9c606Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2916b9c606Sthorpej * POSSIBILITY OF SUCH DAMAGE.
3016b9c606Sthorpej */
3116b9c606Sthorpej
326fdfc66cSlukem #include <sys/cdefs.h>
33*b3a5c565Smatt __KERNEL_RCSID(0, "$NetBSD: led.c,v 1.8 2015/06/09 22:47:12 matt Exp $");
346fdfc66cSlukem
3516b9c606Sthorpej #include "opt_algor_p4032.h"
3616b9c606Sthorpej #include "opt_algor_p5064.h"
3716b9c606Sthorpej #include "opt_algor_p6032.h"
3816b9c606Sthorpej
3916b9c606Sthorpej #include <sys/param.h>
4016b9c606Sthorpej
41*b3a5c565Smatt #include <mips/cpuregs.h>
42*b3a5c565Smatt
43f5439ed7Smatt #include <algor/autoconf.h>
4416b9c606Sthorpej
4516b9c606Sthorpej #ifdef ALGOR_P4032
4616b9c606Sthorpej #include <algor/algor/algor_p4032reg.h>
4716b9c606Sthorpej #endif
4816b9c606Sthorpej
4916b9c606Sthorpej #ifdef ALGOR_P5064
5016b9c606Sthorpej #include <algor/algor/algor_p5064reg.h>
5116b9c606Sthorpej #endif
5216b9c606Sthorpej
5316b9c606Sthorpej #ifdef ALGOR_P6032
5416b9c606Sthorpej #include <algor/algor/algor_p6032reg.h>
5516b9c606Sthorpej #endif
5616b9c606Sthorpej
5716b9c606Sthorpej #if defined(ALGOR_P4032)
5871cb790fSthorpej #define LEDBASE MIPS_PHYS_TO_KSEG1(P4032_LED)
5971cb790fSthorpej #define LED(x) ((3 - (x)) * 4)
6016b9c606Sthorpej #elif defined(ALGOR_P5064)
6116b9c606Sthorpej #define LEDBASE MIPS_PHYS_TO_KSEG1(P5064_LED1)
6216b9c606Sthorpej #define LED(x) ((3 - (x)) * 4)
6316b9c606Sthorpej #elif defined(ALGOR_P6032)
640c37c9e8Sthorpej #define HD2532_STRIDE 4
650c37c9e8Sthorpej #define HD2532_NFLASH_OFFSET 0x80
660c37c9e8Sthorpej #define HD2532_CRAM (HD2532_NFLASH_OFFSET + (0x18 * HD2532_STRIDE))
670c37c9e8Sthorpej #define LEDBASE MIPS_PHYS_TO_KSEG1(P6032_HDSP2532_BASE + HD2532_CRAM)
680c37c9e8Sthorpej #define LED(x) ((x) * HD2532_STRIDE)
6916b9c606Sthorpej #endif
7016b9c606Sthorpej
7116b9c606Sthorpej /*
7216b9c606Sthorpej * led_display:
7316b9c606Sthorpej *
7416b9c606Sthorpej * Set the LED display to the characters provided.
7516b9c606Sthorpej */
7616b9c606Sthorpej void
led_display(u_int8_t a,u_int8_t b,u_int8_t c,u_int8_t d)7716b9c606Sthorpej led_display(u_int8_t a, u_int8_t b, u_int8_t c, u_int8_t d)
7816b9c606Sthorpej {
7916b9c606Sthorpej u_int8_t *leds = (u_int8_t *) LEDBASE;
8016b9c606Sthorpej
8116b9c606Sthorpej leds[LED(0)] = a;
8216b9c606Sthorpej leds[LED(1)] = b;
8316b9c606Sthorpej leds[LED(2)] = c;
8416b9c606Sthorpej leds[LED(3)] = d;
850c37c9e8Sthorpej #if defined(ALGOR_P6032) /* XXX Should support these */
860c37c9e8Sthorpej leds[LED(4)] = ' ';
870c37c9e8Sthorpej leds[LED(5)] = ' ';
880c37c9e8Sthorpej leds[LED(6)] = ' ';
890c37c9e8Sthorpej leds[LED(7)] = ' ';
900c37c9e8Sthorpej #endif
9116b9c606Sthorpej }
92