1 |
786 |
skrzyp |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// uE250_ide.c
|
4 |
|
|
//
|
5 |
|
|
// HAL support code for NMI uEngine uE250 IDE
|
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, 2003 Free Software Foundation, 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
|
16 |
|
|
// version.
|
17 |
|
|
//
|
18 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
19 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
20 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
21 |
|
|
// for more details.
|
22 |
|
|
//
|
23 |
|
|
// You should have received a copy of the GNU General Public License
|
24 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
25 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
26 |
|
|
//
|
27 |
|
|
// As a special exception, if other files instantiate templates or use
|
28 |
|
|
// macros or inline functions from this file, or you compile this file
|
29 |
|
|
// and link it with other works to produce a work based on this file,
|
30 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
31 |
|
|
// the GNU General Public License. However the source code for this file
|
32 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
33 |
|
|
// General Public License v2.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based
|
36 |
|
|
// on this file might be covered by the GNU General Public License.
|
37 |
|
|
// -------------------------------------------
|
38 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
39 |
|
|
//==========================================================================
|
40 |
|
|
//#####DESCRIPTIONBEGIN####
|
41 |
|
|
//
|
42 |
|
|
// Author(s): msalter
|
43 |
|
|
// Contributors: msalter, gthomas
|
44 |
|
|
// Date: 2002-01-04
|
45 |
|
|
// Purpose: PCI support
|
46 |
|
|
// Description: Implementations of HAL PCI interfaces
|
47 |
|
|
//
|
48 |
|
|
//####DESCRIPTIONEND####
|
49 |
|
|
//
|
50 |
|
|
//========================================================================*/
|
51 |
|
|
|
52 |
|
|
#include <pkgconf/hal.h>
|
53 |
|
|
#include <pkgconf/system.h>
|
54 |
|
|
#include CYGBLD_HAL_PLATFORM_H
|
55 |
|
|
#include CYGHWR_MEMORY_LAYOUT_H
|
56 |
|
|
|
57 |
|
|
#include <cyg/infra/cyg_type.h> // base types
|
58 |
|
|
#include <cyg/infra/cyg_trac.h> // tracing macros
|
59 |
|
|
#include <cyg/infra/cyg_ass.h> // assertion macros
|
60 |
|
|
#include <cyg/infra/diag.h> // diag_printf()
|
61 |
|
|
|
62 |
|
|
#include <cyg/hal/hal_io.h> // IO macros
|
63 |
|
|
#include <cyg/hal/hal_if.h> // calling interface API
|
64 |
|
|
#include <cyg/hal/hal_arch.h> // Register state info
|
65 |
|
|
#include <cyg/hal/hal_diag.h>
|
66 |
|
|
#include <cyg/hal/hal_intr.h> // Interrupt names
|
67 |
|
|
#include <cyg/hal/hal_cache.h>
|
68 |
|
|
#include <cyg/io/pci_hw.h>
|
69 |
|
|
#include <cyg/io/pci.h>
|
70 |
|
|
|
71 |
|
|
#ifdef CYGPKG_IO_PCI
|
72 |
|
|
|
73 |
|
|
#define MAX_IDE 2
|
74 |
|
|
static struct {
|
75 |
|
|
cyg_uint32 cmd_bar;
|
76 |
|
|
cyg_uint32 ctl_bar;
|
77 |
|
|
} ide_ctrl[MAX_IDE];
|
78 |
|
|
|
79 |
|
|
cyg_uint8
|
80 |
|
|
cyg_hal_plf_ide_read_uint8(int ctlr, cyg_uint32 reg)
|
81 |
|
|
{
|
82 |
|
|
return pci_io_read_8(ide_ctrl[ctlr].cmd_bar + reg);
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
void
|
86 |
|
|
cyg_hal_plf_ide_write_uint8(int ctlr, cyg_uint32 reg, cyg_uint8 val)
|
87 |
|
|
{
|
88 |
|
|
pci_io_write_8(ide_ctrl[ctlr].cmd_bar + reg, val);
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
cyg_uint16
|
92 |
|
|
cyg_hal_plf_ide_read_uint16(int ctlr, cyg_uint32 reg)
|
93 |
|
|
{
|
94 |
|
|
return pci_io_read_16(ide_ctrl[ctlr].cmd_bar + reg);
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
void
|
98 |
|
|
cyg_hal_plf_ide_write_uint16(int ctlr, cyg_uint32 reg, cyg_uint16 val)
|
99 |
|
|
{
|
100 |
|
|
pci_io_write_16(ide_ctrl[ctlr].cmd_bar + reg, val);
|
101 |
|
|
}
|
102 |
|
|
|
103 |
|
|
void
|
104 |
|
|
cyg_hal_plf_ide_write_control(int ctlr, cyg_uint32 reg, cyg_uint8 val)
|
105 |
|
|
{
|
106 |
|
|
pci_io_write_8(ide_ctrl[ctlr].ctl_bar + reg, val);
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
int
|
110 |
|
|
cyg_hal_plf_ide_init(void)
|
111 |
|
|
{
|
112 |
|
|
int i;
|
113 |
|
|
cyg_pci_device_id ide_dev = CYG_PCI_NULL_DEVID;
|
114 |
|
|
cyg_pci_device ide_info;
|
115 |
|
|
|
116 |
|
|
// diag_printf("Initializing IDE controller\n");
|
117 |
|
|
|
118 |
|
|
if (cyg_pci_find_device((cyg_uint16)0x1095, (cyg_uint16)0x0649, &ide_dev)) {
|
119 |
|
|
cyg_pci_get_device_info(ide_dev, &ide_info);
|
120 |
|
|
#ifdef DEBUG
|
121 |
|
|
for (i = 0; i < 6; i++) {
|
122 |
|
|
diag_printf("IDE - base[%d]: %08p, size: %08p, map: %08p\n",
|
123 |
|
|
i, ide_info.base_address[i], ide_info.base_size[i], ide_info.base_map[i]);
|
124 |
|
|
}
|
125 |
|
|
#endif
|
126 |
|
|
for (i = 0; i < MAX_IDE; i++) {
|
127 |
|
|
ide_ctrl[i].cmd_bar = ide_info.base_map[(2*i)+0] & 0xFFFFFFFE;
|
128 |
|
|
ide_ctrl[i].ctl_bar = ide_info.base_map[(2*i)+1] & 0xFFFFFFFE;
|
129 |
|
|
}
|
130 |
|
|
return HAL_IDE_NUM_CONTROLLERS;
|
131 |
|
|
} else {
|
132 |
|
|
diag_printf("Can't find IDE controller!\n");
|
133 |
|
|
return 0;
|
134 |
|
|
}
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
#endif // CYGPKG_IO_PCI
|