]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/devs/spi/arm/mxc/v2_0/include/mxc_spi.h
Initial revision
[karo-tx-redboot.git] / packages / devs / spi / arm / mxc / v2_0 / include / mxc_spi.h
1 //==========================================================================
2 //
3 //      mxc_spi.h
4 //
5 //      SPI support on Freescale MXC platforms
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):    Kevin Zhang <k.zhang@freescale.com>
44 // Contributors:
45 // Date:         2006-08-24
46 // Purpose:
47 // Description:
48 //
49 //####DESCRIPTIONEND####
50 //
51 //==========================================================================
52
53 #ifndef __MXC_SPI_H__
54 #define __MXC_SPI_H__
55
56 #define SPI_RX_REG_OFF              0x0
57 #define SPI_TX_REG_OFF              0x4
58 #define SPI_CTRL_REG_OFF            0x8
59 #define SPI_INT_CTRL_REG_OFF        0xC
60
61 #if defined(MXC_SPI_VER_0_4)
62 #define SPI_DMA_REG_OFF             0x10
63 #define SPI_INT_STAT_REG_OFF        0x14
64 #define SPI_PERIOD_REG_OFF          0x18
65 #define SPI_TEST_REG_OFF            0x1C
66
67 #define SPI_INT_STAT_RR             (1 << 3)
68
69 #define SPI_CTRL_REG_XCH_BIT        (1 << 2)
70 #define SPI_CTRL_REG_RATE_SH        16  // start from bit 16
71 #define SPI_CTRL_REG_RATE_WD        3   // 3-bit width
72
73 #define SPI_CTRL_REG_BIT_COUNT32    (0x1F << 8)  // 32-bit xfer
74 #define SPI_CTRL_CS0                (0 << 24)
75 #define SPI_CTRL_CS1                (1 << 24)
76 #define SPI_CTRL_CS2                (2 << 24)
77 #define SPI_CTRL_CS3                (3 << 24)
78 #define SPI_CTRL_SSPOL_HIGH         (1 << 7)
79 #define SPI_CTRL_SSCTL_SET          (1 << 6)
80 #define SPI_CTRL_SCLK_POL_LOW       (1 << 4)
81 #define SPI_CTRL_MODE_MASTER        (1 << 1)
82 #define SPI_CTRL_EN                 (1 << 0)
83
84 #elif defined(MXC_SPI_VER_0_7)
85 #define SPI_DMA_REG_OFF             0x10
86 #define SPI_INT_STAT_REG_OFF        0x14
87 #define SPI_PERIOD_REG_OFF          0x18
88 #define SPI_TEST_REG_OFF            0x1C
89
90 #define SPI_INT_STAT_RR             (1 << 3)
91
92 #define SPI_CTRL_REG_XCH_BIT        (1 << 2)
93 #define SPI_CTRL_REG_RATE_SH        16  // start from bit 16
94 #define SPI_CTRL_REG_RATE_WD        3   // 3-bit width
95
96 #define SPI_CTRL_REG_BIT_COUNT32    (0x1F << 20)  // 32-bit xfer
97 #define SPI_CTRL_CS0                (0 << 12)
98 #define SPI_CTRL_CS1                (1 << 12)
99 #define SPI_CTRL_CS2                (2 << 12)
100 #define SPI_CTRL_CS3                (3 << 12)
101 #define SPI_CTRL_SSPOL_HIGH         (1 << 7)
102 #define SPI_CTRL_SSCTL_SET          (1 << 6)
103 #define SPI_CTRL_SCLK_POL_LOW       (1 << 4)
104 #define SPI_CTRL_MODE_MASTER        (1 << 1)
105 #define SPI_CTRL_EN                 (1 << 0)
106
107 #else
108 #define SPI_INT_STAT_REG_OFF        0xC
109 #define SPI_TEST_REG_OFF            0x10
110 #define SPI_PERIOD_REG_OFF          0x14
111 #define SPI_DMA_REG_OFF             0x18
112 #define SPI_RESET_REG_OFF           0x1C
113
114 #define SPI_INT_STAT_RR             (1 << 4)
115
116 #define SPI_CTRL_REG_XCH_BIT        (1 << 9)
117 #define SPI_CTRL_REG_RATE_SH        14  // start from bit 14
118 #define SPI_CTRL_REG_RATE_WD        5   // 5-bit width
119
120 #define SPI_CTRL_BURST_EN           (1 << 23)
121 #define SPI_CTRL_SDHC_SPI_EN        (1 << 22)
122 #define SPI_CTRL_SWAP_EN            (1 << 21)
123 #define SPI_CTRL_CS0                (0 << 19)
124 #define SPI_CTRL_CS1                (1 << 19)
125 #define SPI_CTRL_CS2                (2 << 19)
126 #define SPI_CTRL_SSPOL_HIGH         (1 << 8)
127 #define SPI_CTRL_SSCTL_SET          (1 << 7)
128 #define SPI_CTRL_SCLK_POL_LOW       (1 << 5)
129 #define SPI_CTRL_REG_BIT_COUNT32    0x1F   // 32-bit xfer
130 #define SPI_CTRL_MODE_MASTER        (1 << 11)
131 #define SPI_CTRL_EN                 (1 << 10)
132
133 #endif
134
135 int spi_init(unsigned int base, unsigned int baud, unsigned int ctrl_val);
136 unsigned int pmic_reg(unsigned int reg, unsigned int val, unsigned int write);
137 unsigned int spi_xchg_single(unsigned int data, unsigned int base);
138
139 #endif                          /* __MXC_SPI_H__ */