]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/devs/usb/i386/SoRoD12/v2_0/include/usbs_i386_sorod12.inl
Initial revision
[karo-tx-redboot.git] / packages / devs / usb / i386 / SoRoD12 / v2_0 / include / usbs_i386_sorod12.inl
1 #ifndef USBS_I386_SORO12_INL
2 #define USBS_I386_SORO12_INL
3 //==========================================================================
4 //
5 //      usbS_i386_sorod12.inl
6 //
7 //      Hardware specific parts for the SoRo D12 PC 104 USB card.
8 //
9 //==========================================================================
10 //####ECOSGPLCOPYRIGHTBEGIN####
11 // -------------------------------------------
12 // This file is part of eCos, the Embedded Configurable Operating System.
13 // Copyright (C) 2006, eCosCentric
14 //
15 // eCos is free software; you can redistribute it and/or modify it under
16 // the terms of the GNU General Public License as published by the Free
17 // Software Foundation; either version 2 or (at your option) any later version.
18 //
19 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22 // for more details.
23 //
24 // You should have received a copy of the GNU General Public License along
25 // with eCos; if not, write to the Free Software Foundation, Inc.,
26 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27 //
28 // As a special exception, if other files instantiate templates or use macros
29 // or inline functions from this file, or you compile this file and link it
30 // with other works to produce a work based on this file, this file does not
31 // by itself cause the resulting work to be covered by the GNU General Public
32 // License. However the source code for this file must still be made available
33 // in accordance with section (3) of the GNU General Public License.
34 //
35 // This exception does not invalidate any other reasons why a work based on
36 // this file might be covered by the GNU General Public License.
37 // -------------------------------------------
38 //####ECOSGPLCOPYRIGHTEND####
39 //==========================================================================
40 //#####DESCRIPTIONBEGIN####
41 //
42 // Author(s):    Frank M. Pagliughi (fmp), ASL
43 // Date:         2004-05-22
44 //
45 // This code is a hardware specific device driver for the SoRo Systems
46 // USB-D12-104, a PC/104 (ISA) Full-Speed USB slave board, which turns
47 // a PC/104 stack into a USB slave device. The board contains a
48 // Philips PDIUSBD12 Peripheral Controller Chip mapped into the PC's
49 // I/O space, with jumper-selectable I/O base address, IRQ, and DMA
50 // settings. The eCos config tool is used to adjust settings for this
51 // driver to match the physical jumper settings. The chip could run in
52 // polled mode without an IRQ, but this wouldn't be a great idea other
53 // than maybe a debug environment.
54
55 // ------------------------------------------------------------------------
56 //                                                              Data-Only I/O                              
57 // ------------------------------------------------------------------------
58 //
59
60 #include <pkgconf/devs_usb_i386_sorod12.h>
61
62 // These routines read or write 8 bit values to the data area.
63
64 static inline byte d12_read_data_byte(d12_addr_type base_addr)
65 {
66         #if defined(CYGSEM_DEVS_USB_I386_SOROD12_IO_MAPPED)
67                 byte val;
68                 HAL_READ_UINT8((unsigned) base_addr, val);
69                 return val;
70         #else
71                 return *base_addr;
72         #endif
73 }
74
75 static inline void d12_write_data_byte(d12_addr_type base_addr, byte val)
76 {
77         #if defined(CYGSEM_DEVS_USB_I386_SOROD12_IO_MAPPED)
78                 HAL_WRITE_UINT8((unsigned) base_addr, val);
79         #else
80                 *base_addr = val;
81         #endif
82 }
83
84 // This routine writes a command to the device.
85
86 static inline void d12_write_cmd(d12_addr_type base_addr, byte cmd)
87 {
88         #if defined(CYGSEM_DEVS_USB_I386_SOROD12_IO_MAPPED)
89                 HAL_WRITE_UINT8((unsigned) base_addr+1, cmd);
90         #else
91                 *(base_addr+1) = cmd;
92         #endif
93 }
94
95 // ------------------------------------------------------------------------
96 //      Reads 'n' bytes from the data address of the D12 and places them into
97 //      the buf[] array. Buf can be NULL, in which case the specified number of
98 //      bytes are read and discarded.
99
100 static uint8 d12_read_data(d12_addr_type base_addr, byte *buf, uint8 n)
101 {
102         uint8 i;
103
104         if (buf) {
105                 for (i=0; i<n; ++i)
106                         buf[i] = d12_read_data_byte(base_addr);
107         }
108         else {
109                 for (i=0; i<n; ++i)
110                         d12_read_data_byte(base_addr);
111                 n = 0;
112         }
113
114         return n;
115 }
116
117 // ------------------------------------------------------------------------
118 // Writes 'n' bytes out the data reg of the chip
119
120 static void d12_write_data(d12_addr_type base_addr, const byte *buf, uint8 n)
121 {
122         uint8 i;
123
124         for (i=0; i<n; ++i)
125                 d12_write_data_byte(base_addr, buf[i]);
126 }
127
128 #endif // USBS_I386_SORO12_INL