cvmx-ebt3000.c revision 210286
17494Sjkh/***********************license start***************
27494Sjkh *  Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
37494Sjkh *  reserved.
47494Sjkh *
57494Sjkh *
67494Sjkh *  Redistribution and use in source and binary forms, with or without
77494Sjkh *  modification, are permitted provided that the following conditions are
87494Sjkh *  met:
97494Sjkh *
107494Sjkh *      * Redistributions of source code must retain the above copyright
117494Sjkh *        notice, this list of conditions and the following disclaimer.
127494Sjkh *
137494Sjkh *      * Redistributions in binary form must reproduce the above
147494Sjkh *        copyright notice, this list of conditions and the following
157494Sjkh *        disclaimer in the documentation and/or other materials provided
167494Sjkh *        with the distribution.
177494Sjkh *
187494Sjkh *      * Neither the name of Cavium Networks nor the names of
197494Sjkh *        its contributors may be used to endorse or promote products
207494Sjkh *        derived from this software without specific prior written
217494Sjkh *        permission.
227494Sjkh *
237494Sjkh *  TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
247494Sjkh *  AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
257494Sjkh *  OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
267494Sjkh *  RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
277494Sjkh *  REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
287494Sjkh *  DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
2965437Sphantom *  OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
30142665Sphantom *  PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
317494Sjkh *  POSSESSION OR CORRESPONDENCE TO DESCRIPTION.  THE ENTIRE RISK ARISING OUT
327494Sjkh *  OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
337494Sjkh *
347494Sjkh *
3579754Sdd *  For any questions regarding licensing please contact marketing@caviumnetworks.com
3659460Sphantom *
3759460Sphantom ***********************license end**************************************/
387494Sjkh
3984306Sru
407494Sjkh
4135548Sache
427494Sjkh
4379754Sdd
4479754Sdd/**
457494Sjkh * @file
467494Sjkh *
477494Sjkh * Interface to the EBT3000 specific devices
487494Sjkh *
497494Sjkh * <hr>$Revision: 41586 $<hr>
507494Sjkh *
5179754Sdd */
527494Sjkh
537494Sjkh#include "cvmx-config.h"
547494Sjkh#include "cvmx.h"
5565437Sphantom#include "cvmx-sysinfo.h"
5679754Sdd
577494Sjkh
587494Sjkhvoid ebt3000_char_write(int char_position, char val)
597494Sjkh{
607494Sjkh    /* Note: phys_to_ptr won't work here, as we are most likely going to access the boot bus. */
61142665Sphantom    void *led_base = CASTPTR(void, CVMX_ADD_SEG32(CVMX_MIPS32_SPACE_KSEG0, cvmx_sysinfo_get()->led_display_base_addr));
62142665Sphantom    if (!led_base)
63142665Sphantom        return;
64142665Sphantom    if (cvmx_sysinfo_get()->board_type == CVMX_BOARD_TYPE_EBT3000 && cvmx_sysinfo_get()->board_rev_major == 1)
65142665Sphantom    {
66147402Sru        /* Rev 1 board */
67142665Sphantom        char *ptr = (char *)(led_base + 4);
68142665Sphantom        char_position &= 0x3;  /* only 4 chars */
69142665Sphantom        ptr[3 - char_position] = val;
70142665Sphantom    }
71142665Sphantom    else
72142665Sphantom    {
73142665Sphantom        /* rev 2 or later board */
747494Sjkh        char *ptr = (char *)(led_base);
7551577Sphantom        char_position &= 0x7;  /* only 8 chars */
767494Sjkh        ptr[char_position] = val;
777494Sjkh    }
787494Sjkh}
797494Sjkh
807494Sjkhvoid ebt3000_str_write(const char *str)
8135548Sache{
82142665Sphantom    /* 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}
113