OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [sh/] [hs7729pci/] [v2_0/] [src/] [smsc37c93x.c] - Blame information for rev 27

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//=============================================================================
2
//
3
//      smsc37c93x.c
4
//
5
//      Init code for SMSC 37C93x super IO controller
6
//
7
//=============================================================================
8
//####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under
14
// the terms of the GNU General Public License as published by the Free
15
// Software Foundation; either version 2 or (at your option) any later version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
// at http://sources.redhat.com/ecos/ecos-license/
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
//=============================================================================
41
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):   jskov
44
// Contributors:jskov
45
// Date:        2001-05-30
46
// Description: Init code for SMSC 37C93x super IO controller
47
//
48
//####DESCRIPTIONEND####
49
//
50
//=============================================================================
51
 
52
#include <pkgconf/hal.h>
53
#include CYGBLD_HAL_PLATFORM_H
54
 
55
#include <cyg/hal/hal_arch.h>           // SAVE/RESTORE GP macros
56
#include <cyg/hal/hal_io.h>             // IO macros
57
#include <cyg/hal/hal_intr.h>           // interrupt vectors
58
 
59
 
60
//-----------------------------------------------------------------------------
61
 
62
#define SMSC_READ_UINT8(_a_, _d_)               \
63
    CYG_MACRO_START                             \
64
    cyg_uint16 t;                               \
65
    HAL_READ_UINT16((_a_), t);                  \
66
    (_d_) = (t >> 8) & 0xff;                    \
67
    CYG_MACRO_END
68
 
69
#define SMSC_WRITE_UINT8(_a_, _d_)              \
70
    CYG_MACRO_START                             \
71
    HAL_WRITE_UINT16((_a_), (_d_)<<8);          \
72
    CYG_MACRO_END
73
 
74
//-----------------------------------------------------------------------------
75
 
76
// From page 137+ in SMSC-37C93x.pdf
77
#define SMSC_CONFIG             0xa80007e0
78
#define SMSC_CONFIG_DATA        0xa80007e2
79
 
80
#define SMSC_CONFIG_DEV         0x07
81
#define SMSC_CONFIG_POWER       0x22
82
#define SMSC_CONFIG_ACTIVATE    0x30
83
#define SMSC_CONFIG_ENTER       0x55
84
#define SMSC_CONFIG_BASE_HIGH   0x60
85
#define SMSC_CONFIG_BASE_LOW    0x61
86
#define SMSC_CONFIG_IRQ         0x70
87
#define SMSC_CONFIG_EXIT        0xaa
88
#define SMSC_CONFIG_MODE        0xf0
89
 
90
#define SMSC_CONFIG_DEV_COM1    0x04
91
#define SMSC_CONFIG_DEV_COM2    0x05
92
#define SMSC_CONFIG_DEV_RTC     0x06
93
 
94
#define SMSC_CONFIG_MODE_HIGH   0x02
95
 
96
#define SMSC_CONFIG_ACTIVATE_ENABLE 0x01
97
 
98
#define SMSC_CONFIG_POWER_COM1   0x10
99
#define SMSC_CONFIG_POWER_COM2   0x20
100
 
101
 
102
void
103
cyg_hal_init_superIO(void)
104
{
105
    // Note: two writes unlike the 37m81x!
106
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_ENTER);
107
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_ENTER);
108
 
109
    // Power ON COM1 and COM2
110
    SMSC_WRITE_UINT8(SMSC_CONFIG_POWER, SMSC_CONFIG_POWER_COM1|SMSC_CONFIG_POWER_COM2);
111
 
112
    // Configure and enable COM1
113
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_DEV);
114
    SMSC_WRITE_UINT8(SMSC_CONFIG_DATA, SMSC_CONFIG_DEV_COM1);
115
 
116
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_BASE_HIGH);
117
    SMSC_WRITE_UINT8(SMSC_CONFIG_DATA, 0x03);
118
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_BASE_LOW);
119
    SMSC_WRITE_UINT8(SMSC_CONFIG_DATA, 0xf8);
120
 
121
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_IRQ);
122
    SMSC_WRITE_UINT8(SMSC_CONFIG_DATA, 3); // UIO_IRQ3
123
 
124
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_MODE);
125
    SMSC_WRITE_UINT8(SMSC_CONFIG_DATA, SMSC_CONFIG_MODE_HIGH);
126
 
127
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_ACTIVATE);
128
    SMSC_WRITE_UINT8(SMSC_CONFIG_DATA, SMSC_CONFIG_ACTIVATE_ENABLE);
129
 
130
    // Configure and enable COM2
131
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_DEV);
132
    SMSC_WRITE_UINT8(SMSC_CONFIG_DATA, SMSC_CONFIG_DEV_COM2);
133
 
134
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_BASE_HIGH);
135
    SMSC_WRITE_UINT8(SMSC_CONFIG_DATA, 0x02);
136
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_BASE_LOW);
137
    SMSC_WRITE_UINT8(SMSC_CONFIG_DATA, 0xf8);
138
 
139
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_IRQ);
140
    SMSC_WRITE_UINT8(SMSC_CONFIG_DATA, 4); // UIO_IRQ4
141
 
142
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_MODE);
143
    SMSC_WRITE_UINT8(SMSC_CONFIG_DATA, SMSC_CONFIG_MODE_HIGH);
144
 
145
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_ACTIVATE);
146
    SMSC_WRITE_UINT8(SMSC_CONFIG_DATA, SMSC_CONFIG_ACTIVATE_ENABLE);
147
 
148
    // Configure and enable RTC
149
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_DEV);
150
    SMSC_WRITE_UINT8(SMSC_CONFIG_DATA, SMSC_CONFIG_DEV_RTC);
151
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_ACTIVATE);
152
    SMSC_WRITE_UINT8(SMSC_CONFIG_DATA, SMSC_CONFIG_ACTIVATE_ENABLE);
153
 
154
    SMSC_WRITE_UINT8(SMSC_CONFIG, SMSC_CONFIG_EXIT);
155
}
156
 
157
//-----------------------------------------------------------------------------
158
// end of smsc37c93x.c

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.