]> CyberLeo.Net >> Repos - FreeBSD/releng/8.2.git/blob - sys/contrib/octeon-sdk/cvmx-ebt3000.c
Copy stable/8 to releng/8.2 in preparation for FreeBSD-8.2 release.
[FreeBSD/releng/8.2.git] / sys / contrib / octeon-sdk / cvmx-ebt3000.c
1 /***********************license start***************
2  *  Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
3  *  reserved.
4  *
5  *
6  *  Redistribution and use in source and binary forms, with or without
7  *  modification, are permitted provided that the following conditions are
8  *  met:
9  *
10  *      * Redistributions of source code must retain the above copyright
11  *        notice, this list of conditions and the following disclaimer.
12  *
13  *      * Redistributions in binary form must reproduce the above
14  *        copyright notice, this list of conditions and the following
15  *        disclaimer in the documentation and/or other materials provided
16  *        with the distribution.
17  *
18  *      * Neither the name of Cavium Networks nor the names of
19  *        its contributors may be used to endorse or promote products
20  *        derived from this software without specific prior written
21  *        permission.
22  *
23  *  TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
24  *  AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
25  *  OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
26  *  RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
27  *  REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
28  *  DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
29  *  OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
30  *  PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
31  *  POSSESSION OR CORRESPONDENCE TO DESCRIPTION.  THE ENTIRE RISK ARISING OUT
32  *  OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
33  *
34  *
35  *  For any questions regarding licensing please contact marketing@caviumnetworks.com
36  *
37  ***********************license end**************************************/
38
39
40
41
42
43
44 /**
45  * @file
46  *
47  * Interface to the EBT3000 specific devices
48  *
49  * <hr>$Revision: 41586 $<hr>
50  *
51  */
52
53 #include "cvmx-config.h"
54 #include "cvmx.h"
55 #include "cvmx-sysinfo.h"
56
57
58 void ebt3000_char_write(int char_position, char val)
59 {
60     /* Note: phys_to_ptr won't work here, as we are most likely going to access the boot bus. */
61     void *led_base = CASTPTR(void, CVMX_ADD_SEG32(CVMX_MIPS32_SPACE_KSEG0, cvmx_sysinfo_get()->led_display_base_addr));
62     if (!led_base)
63         return;
64     if (cvmx_sysinfo_get()->board_type == CVMX_BOARD_TYPE_EBT3000 && cvmx_sysinfo_get()->board_rev_major == 1)
65     {
66         /* Rev 1 board */
67         char *ptr = (char *)(led_base + 4);
68         char_position &= 0x3;  /* only 4 chars */
69         ptr[3 - char_position] = val;
70     }
71     else
72     {
73         /* rev 2 or later board */
74         char *ptr = (char *)(led_base);
75         char_position &= 0x7;  /* only 8 chars */
76         ptr[char_position] = val;
77     }
78 }
79
80 void ebt3000_str_write(const char *str)
81 {
82     /* Note: phys_to_ptr won't work here, as we are most likely going to access the boot bus. */
83     void *led_base;
84     if (!cvmx_sysinfo_get()->led_display_base_addr)
85         return;
86     led_base = CASTPTR(void, CVMX_ADD_SEG32(CVMX_MIPS32_SPACE_KSEG0, cvmx_sysinfo_get()->led_display_base_addr));
87     if (cvmx_sysinfo_get()->board_type == CVMX_BOARD_TYPE_EBT3000 && cvmx_sysinfo_get()->board_rev_major == 1)
88     {
89         char *ptr = (char *)(led_base + 4);
90         int i;
91         for (i=0; i<4; i++)
92         {
93             if (*str)
94                 ptr[3 - i] = *str++;
95             else
96                 ptr[3 - i] = ' ';
97         }
98     }
99     else
100     {
101         /* rev 2 board */
102         char *ptr = (char *)(led_base);
103         int i;
104         for (i=0; i<8; i++)
105         {
106             if (*str)
107                 ptr[i] = *str++;
108             else
109                 ptr[i] = ' ';
110         }
111     }
112 }