]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/devs/spi/arm/at91/v2_0/include/spi_at91.h
unified MX27, MX25, MX37 trees
[karo-tx-redboot.git] / packages / devs / spi / arm / at91 / v2_0 / include / spi_at91.h
1 #ifndef CYGONCE_DEVS_SPI_ARM_AT91_H
2 #define CYGONCE_DEVS_SPI_ARM_AT91_H
3 //==========================================================================
4 //
5 //      spi_at91.h
6 //
7 //      Atmel AT91 (ARM) SPI driver defines
8 //
9 //==========================================================================
10 //####ECOSGPLCOPYRIGHTBEGIN####
11 // -------------------------------------------
12 // This file is part of eCos, the Embedded Configurable Operating System.
13 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
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 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39 // at http://sources.redhat.com/ecos/ecos-license/
40 // -------------------------------------------
41 //####ECOSGPLCOPYRIGHTEND####
42 //==========================================================================
43 //#####DESCRIPTIONBEGIN####
44 //
45 // Author(s):     Savin Zlobec <savin@elatec.si> 
46 // Date:          2004-08-25
47 //
48 //####DESCRIPTIONEND####
49 //
50 //==========================================================================
51
52 #include <pkgconf/hal.h>
53 #include <pkgconf/io_spi.h>
54
55 #include <cyg/infra/cyg_type.h>
56 #include <cyg/hal/drv_api.h>
57 #include <cyg/io/spi.h>
58
59 //-----------------------------------------------------------------------------
60 // AT91 SPI BUS
61
62 typedef struct cyg_spi_at91_bus_s
63 {
64     // ---- Upper layer data ----
65
66     cyg_spi_bus   spi_bus;                  // Upper layer SPI bus data
67
68     // ---- Lower layer data ----
69      
70     cyg_interrupt     spi_interrupt;        // SPI interrupt object
71     cyg_handle_t      spi_interrupt_handle; // SPI interrupt handle
72     cyg_drv_mutex_t   transfer_mx;          // Transfer mutex
73     cyg_drv_cond_t    transfer_cond;        // Transfer condition
74     cyg_bool          transfer_end;         // Transfer end flag
75     cyg_bool          cs_up;                // Chip Select up flag 
76     cyg_vector_t      interrupt_number;     // SPI Interrupt Number
77     cyg_addrword_t    base;                 // Base Address of the SPI peripheral
78     cyg_uint8         cs_en[4];             // The Configurations state for the CS
79     cyg_uint32        cs_gpio[4];           // The GPIO Configurations for the CS
80 } cyg_spi_at91_bus_t;
81
82 //-----------------------------------------------------------------------------
83 // AT91 SPI DEVICE
84
85 typedef struct cyg_spi_at91_device_s
86 {
87     // ---- Upper layer data ----
88
89     cyg_spi_device spi_device;  // Upper layer SPI device data
90
91     // ---- Lower layer data (configurable) ----
92
93     cyg_uint8  dev_num;         // Device number
94     cyg_uint8  cl_pol;          // Clock polarity (0 or 1)
95     cyg_uint8  cl_pha;          // Clock phase    (0 or 1)
96     cyg_uint32 cl_brate;        // Clock baud rate
97     cyg_uint16 cs_up_udly;      // Delay in us between CS up and transfer start
98     cyg_uint16 cs_dw_udly;      // Delay in us between transfer end and CS down
99     cyg_uint16 tr_bt_udly;      // Delay in us between two transfers
100
101     // ---- Lower layer data (internal) ----
102
103     cyg_bool   init;            // Is device initialized
104     cyg_uint8  cl_scbr;         // Value of SCBR (SPI clock) reg field
105     cyg_uint8  cl_div32;        // Divide SPI master clock by 32
106 } cyg_spi_at91_device_t;
107
108 //-----------------------------------------------------------------------------
109 // AT91 SPI exported busses
110
111 /* For backwards compatability  */
112 #define cyg_spi_at91_bus cyg_spi_at91_bus0
113
114 externC cyg_spi_at91_bus_t cyg_spi_at91_bus0;
115 externC cyg_spi_at91_bus_t cyg_spi_at91_bus1;
116
117 //-----------------------------------------------------------------------------
118
119 #endif // CYGONCE_DEVS_SPI_ARM_AT91_H 
120
121 //-----------------------------------------------------------------------------
122 // End of spi_at91.h