blob: 25a1835ccfd4cd80f60425a979acee21ecf8fcf9 [file] [log] [blame]
Nicholas Flintham1e3d3112013-04-10 10:48:38 +01001/*
2 * include/linux/spi/spidev.h
3 *
4 * Copyright (C) 2006 SWAPP
5 * Andrea Paterniani <a.paterniani@swapp-eng.it>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#ifndef SPIDEV_H
23#define SPIDEV_H
24
25#include <linux/types.h>
26
27
28#define SPI_CPHA 0x01
29#define SPI_CPOL 0x02
30
31#define SPI_MODE_0 (0|0)
32#define SPI_MODE_1 (0|SPI_CPHA)
33#define SPI_MODE_2 (SPI_CPOL|0)
34#define SPI_MODE_3 (SPI_CPOL|SPI_CPHA)
35
36#define SPI_CS_HIGH 0x04
37#define SPI_LSB_FIRST 0x08
38#define SPI_3WIRE 0x10
39#define SPI_LOOP 0x20
40#define SPI_NO_CS 0x40
41#define SPI_READY 0x80
42
43
44
45#define SPI_IOC_MAGIC 'k'
46
47struct spi_ioc_transfer {
48 __u64 tx_buf;
49 __u64 rx_buf;
50
51 __u32 len;
52 __u32 speed_hz;
53
54 __u16 delay_usecs;
55 __u8 bits_per_word;
56 __u8 cs_change;
57 __u32 pad;
58
59};
60
61#define SPI_MSGSIZE(N) \
62 ((((N)*(sizeof (struct spi_ioc_transfer))) < (1 << _IOC_SIZEBITS)) \
63 ? ((N)*(sizeof (struct spi_ioc_transfer))) : 0)
64#define SPI_IOC_MESSAGE(N) _IOW(SPI_IOC_MAGIC, 0, char[SPI_MSGSIZE(N)])
65
66
67#define SPI_IOC_RD_MODE _IOR(SPI_IOC_MAGIC, 1, __u8)
68#define SPI_IOC_WR_MODE _IOW(SPI_IOC_MAGIC, 1, __u8)
69
70#define SPI_IOC_RD_LSB_FIRST _IOR(SPI_IOC_MAGIC, 2, __u8)
71#define SPI_IOC_WR_LSB_FIRST _IOW(SPI_IOC_MAGIC, 2, __u8)
72
73#define SPI_IOC_RD_BITS_PER_WORD _IOR(SPI_IOC_MAGIC, 3, __u8)
74#define SPI_IOC_WR_BITS_PER_WORD _IOW(SPI_IOC_MAGIC, 3, __u8)
75
76#define SPI_IOC_RD_MAX_SPEED_HZ _IOR(SPI_IOC_MAGIC, 4, __u32)
77#define SPI_IOC_WR_MAX_SPEED_HZ _IOW(SPI_IOC_MAGIC, 4, __u32)
78
79
80
81#endif