]> git.karo-electronics.de Git - karo-tx-redboot.git/blob - packages/hal/arm/xscale/uE250/v2_0/src/uE250_ide.c
Initial revision
[karo-tx-redboot.git] / packages / hal / arm / xscale / uE250 / v2_0 / src / uE250_ide.c
1 //==========================================================================
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 Red Hat, Inc.
12 // Copyright (C) 2003 Gary Thomas <gary@mind.be>
13 //
14 // eCos is free software; you can redistribute it and/or modify it under
15 // the terms of the GNU General Public License as published by the Free
16 // Software Foundation; either version 2 or (at your option) any later version.
17 //
18 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19 // 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 along
24 // with eCos; if not, write to the Free Software Foundation, Inc.,
25 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 //
27 // As a special exception, if other files instantiate templates or use macros
28 // or inline functions from this file, or you compile this file and link it
29 // with other works to produce a work based on this file, this file does not
30 // by itself cause the resulting work to be covered by the GNU General Public
31 // License. However the source code for this file must still be made available
32 // in accordance with section (3) of the GNU General Public License.
33 //
34 // This exception does not invalidate any other reasons why a work based on
35 // this file might be covered by the GNU General Public License.
36 //
37 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38 // at http://sources.redhat.com/ecos/ecos-license/
39 // -------------------------------------------
40 //####ECOSGPLCOPYRIGHTEND####
41 //==========================================================================
42 //#####DESCRIPTIONBEGIN####
43 //
44 // Author(s):    msalter
45 // Contributors: msalter, gthomas
46 // Date:         2002-01-04
47 // Purpose:      PCI support
48 // Description:  Implementations of HAL PCI interfaces
49 //
50 //####DESCRIPTIONEND####
51 //
52 //========================================================================*/
53
54 #include <pkgconf/hal.h>
55 #include <pkgconf/system.h>
56 #include CYGBLD_HAL_PLATFORM_H
57 #include CYGHWR_MEMORY_LAYOUT_H
58
59 #include <cyg/infra/cyg_type.h>         // base types
60 #include <cyg/infra/cyg_trac.h>         // tracing macros
61 #include <cyg/infra/cyg_ass.h>          // assertion macros
62 #include <cyg/infra/diag.h>             // diag_printf()
63
64 #include <cyg/hal/hal_io.h>             // IO macros
65 #include <cyg/hal/hal_if.h>             // calling interface API
66 #include <cyg/hal/hal_arch.h>           // Register state info
67 #include <cyg/hal/hal_diag.h>
68 #include <cyg/hal/hal_intr.h>           // Interrupt names
69 #include <cyg/hal/hal_cache.h>
70 #include <cyg/io/pci_hw.h>
71 #include <cyg/io/pci.h>
72
73 #ifdef CYGPKG_IO_PCI
74
75 #define MAX_IDE 2
76 static struct {
77     cyg_uint32 cmd_bar;
78     cyg_uint32 ctl_bar;
79 } ide_ctrl[MAX_IDE];
80
81 cyg_uint8 
82 cyg_hal_plf_ide_read_uint8(int ctlr, cyg_uint32 reg)
83 {
84     return pci_io_read_8(ide_ctrl[ctlr].cmd_bar + reg);
85 }
86
87 void 
88 cyg_hal_plf_ide_write_uint8(int ctlr, cyg_uint32 reg, cyg_uint8 val)
89 {
90     pci_io_write_8(ide_ctrl[ctlr].cmd_bar + reg, val);
91 }
92
93 cyg_uint16 
94 cyg_hal_plf_ide_read_uint16(int ctlr, cyg_uint32 reg)
95 {
96     return pci_io_read_16(ide_ctrl[ctlr].cmd_bar + reg);
97 }
98
99 void 
100 cyg_hal_plf_ide_write_uint16(int ctlr, cyg_uint32 reg, cyg_uint16 val)
101 {
102     pci_io_write_16(ide_ctrl[ctlr].cmd_bar + reg, val);
103 }
104
105 void 
106 cyg_hal_plf_ide_write_control(int ctlr, cyg_uint32 reg, cyg_uint8 val)
107 {
108     pci_io_write_8(ide_ctrl[ctlr].ctl_bar + reg, val);
109 }
110
111 int
112 cyg_hal_plf_ide_init(void)
113 {
114     int i;
115     cyg_pci_device_id ide_dev = CYG_PCI_NULL_DEVID;
116     cyg_pci_device ide_info;
117
118 //    diag_printf("Initializing IDE controller\n");
119
120     if (cyg_pci_find_device((cyg_uint16)0x1095, (cyg_uint16)0x0649, &ide_dev)) {
121         cyg_pci_get_device_info(ide_dev, &ide_info);
122 #ifdef DEBUG
123         for (i = 0;  i < 6;  i++) {
124             diag_printf("IDE - base[%d]: %08p, size: %08p, map: %08p\n",
125                         i, ide_info.base_address[i], ide_info.base_size[i], ide_info.base_map[i]);
126         }
127 #endif
128         for (i = 0;  i < MAX_IDE;  i++) {
129             ide_ctrl[i].cmd_bar = ide_info.base_map[(2*i)+0] & 0xFFFFFFFE;
130             ide_ctrl[i].ctl_bar = ide_info.base_map[(2*i)+1] & 0xFFFFFFFE;
131         }
132         return HAL_IDE_NUM_CONTROLLERS;
133     } else {
134         diag_printf("Can't find IDE controller!\n");
135         return 0;
136     }
137 }
138
139 #endif // CYGPKG_IO_PCI