blob: 6b99f09b717d86b6c138e7e8962e12cff92065f3 [file] [log] [blame]
Stephen Streete0c99052006-03-07 23:53:24 -08001/*
2 * Copyright (C) 2005 Stephen Street / StreetFire Sound Labs
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
Sebastian Andrzej Siewior8348c252010-11-22 17:12:15 -080018#ifndef __linux_pxa2xx_spi_h
19#define __linux_pxa2xx_spi_h
Stephen Streete0c99052006-03-07 23:53:24 -080020
Sebastian Andrzej Siewior8348c252010-11-22 17:12:15 -080021#include <linux/pxa2xx_ssp.h>
Stephen Streete0c99052006-03-07 23:53:24 -080022
23#define PXA2XX_CS_ASSERT (0x01)
24#define PXA2XX_CS_DEASSERT (0x02)
25
Stephen Streete0c99052006-03-07 23:53:24 -080026/* device.platform_data for SSP controller devices */
27struct pxa2xx_spi_master {
Stephen Streete0c99052006-03-07 23:53:24 -080028 u32 clock_enable;
29 u16 num_chipselect;
30 u8 enable_dma;
Mika Westerberg851bacf2013-01-07 12:44:33 +020031
32 /* For non-PXA arches */
33 struct ssp_device ssp;
Stephen Streete0c99052006-03-07 23:53:24 -080034};
35
36/* spi_board_info.controller_data for SPI slave devices,
37 * copied to spi_device.platform_data ... mostly for dma tuning
38 */
39struct pxa2xx_spi_chip {
40 u8 tx_threshold;
41 u8 rx_threshold;
42 u8 dma_burst_size;
Stephen Street8d94cc52006-12-10 02:18:54 -080043 u32 timeout;
Stephen Streete0c99052006-03-07 23:53:24 -080044 u8 enable_loopback;
Eric Miaoa7bb3902009-04-06 19:00:54 -070045 int gpio_cs;
Stephen Streete0c99052006-03-07 23:53:24 -080046 void (*cs_control)(u32 command);
47};
48
Qiao Zhou60172212012-06-04 10:41:03 +080049#if defined(CONFIG_ARCH_PXA) || defined(CONFIG_ARCH_MMP)
Sebastian Andrzej Siewiord6ea3df2010-11-24 10:17:14 +010050
51#include <linux/clk.h>
52#include <mach/dma.h>
53
Guennadi Liakhovetskie1722742008-06-13 09:17:31 +010054extern void pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_master *info);
55
Sebastian Andrzej Siewiord6ea3df2010-11-24 10:17:14 +010056#else
57/*
58 * This is the implemtation for CE4100 on x86. ARM defines them in mach/ or
59 * plat/ include path.
60 * The CE4100 does not provide DMA support. This bits are here to let the driver
61 * compile and will never be used. Maybe we get DMA support at a later point in
62 * time.
63 */
64
65#define DCSR(n) (n)
66#define DSADR(n) (n)
67#define DTADR(n) (n)
68#define DCMD(n) (n)
69#define DRCMR(n) (n)
70
71#define DCSR_RUN (1 << 31) /* Run Bit */
72#define DCSR_NODESC (1 << 30) /* No-Descriptor Fetch */
73#define DCSR_STOPIRQEN (1 << 29) /* Stop Interrupt Enable */
74#define DCSR_REQPEND (1 << 8) /* Request Pending (read-only) */
75#define DCSR_STOPSTATE (1 << 3) /* Stop State (read-only) */
76#define DCSR_ENDINTR (1 << 2) /* End Interrupt */
77#define DCSR_STARTINTR (1 << 1) /* Start Interrupt */
78#define DCSR_BUSERR (1 << 0) /* Bus Error Interrupt */
79
80#define DCSR_EORIRQEN (1 << 28) /* End of Receive Interrupt Enable */
81#define DCSR_EORJMPEN (1 << 27) /* Jump to next descriptor on EOR */
82#define DCSR_EORSTOPEN (1 << 26) /* STOP on an EOR */
83#define DCSR_SETCMPST (1 << 25) /* Set Descriptor Compare Status */
84#define DCSR_CLRCMPST (1 << 24) /* Clear Descriptor Compare Status */
85#define DCSR_CMPST (1 << 10) /* The Descriptor Compare Status */
86#define DCSR_EORINTR (1 << 9) /* The end of Receive */
87
88#define DRCMR_MAPVLD (1 << 7) /* Map Valid */
89#define DRCMR_CHLNUM 0x1f /* mask for Channel Number */
90
91#define DDADR_DESCADDR 0xfffffff0 /* Address of next descriptor */
92#define DDADR_STOP (1 << 0) /* Stop */
93
94#define DCMD_INCSRCADDR (1 << 31) /* Source Address Increment Setting. */
95#define DCMD_INCTRGADDR (1 << 30) /* Target Address Increment Setting. */
96#define DCMD_FLOWSRC (1 << 29) /* Flow Control by the source. */
97#define DCMD_FLOWTRG (1 << 28) /* Flow Control by the target. */
98#define DCMD_STARTIRQEN (1 << 22) /* Start Interrupt Enable */
99#define DCMD_ENDIRQEN (1 << 21) /* End Interrupt Enable */
100#define DCMD_ENDIAN (1 << 18) /* Device Endian-ness. */
101#define DCMD_BURST8 (1 << 16) /* 8 byte burst */
102#define DCMD_BURST16 (2 << 16) /* 16 byte burst */
103#define DCMD_BURST32 (3 << 16) /* 32 byte burst */
104#define DCMD_WIDTH1 (1 << 14) /* 1 byte width */
105#define DCMD_WIDTH2 (2 << 14) /* 2 byte width (HalfWord) */
106#define DCMD_WIDTH4 (3 << 14) /* 4 byte width (Word) */
107#define DCMD_LENGTH 0x01fff /* length mask (max = 8K - 1) */
108
109/*
110 * Descriptor structure for PXA's DMA engine
111 * Note: this structure must always be aligned to a 16-byte boundary.
112 */
113
114typedef enum {
115 DMA_PRIO_HIGH = 0,
116 DMA_PRIO_MEDIUM = 1,
117 DMA_PRIO_LOW = 2
118} pxa_dma_prio;
119
120/*
121 * DMA registration
122 */
123
124static inline int pxa_request_dma(char *name,
125 pxa_dma_prio prio,
126 void (*irq_handler)(int, void *),
127 void *data)
128{
129 return -ENODEV;
130}
131
132static inline void pxa_free_dma(int dma_ch)
133{
134}
135
136/*
137 * The CE4100 does not have the clk framework implemented and SPI clock can
138 * not be switched on/off or the divider changed.
139 */
140static inline void clk_disable(struct clk *clk)
141{
142}
143
144static inline int clk_enable(struct clk *clk)
145{
146 return 0;
147}
148
149static inline unsigned long clk_get_rate(struct clk *clk)
150{
151 return 3686400;
152}
153
154#endif
Sebastian Andrzej Siewior8348c252010-11-22 17:12:15 -0800155#endif