d64f2e4f66f65103628c134f21ad830a14fb9e4a
[openwrt/svn-archive/archive.git] / utils / ucmb / driver / ucmb.h
1 #ifndef LINUX_UCMB_H_
2 #define LINUX_UCMB_H_
3
4 #include <linux/types.h>
5 #include <linux/ioctl.h>
6
7
8 /* IOCTLs */
9 #define __UCMB_IOCTL ('U'|'C'|'M'|'B')
10
11 /** UCMB_IOCTL_RESETUC - Reset the microcontroller. */
12 #define UCMB_IOCTL_RESETUC _IO(__UCMB_IOCTL, 0)
13 /** UCMB_IOCTL_GMSGDELAY - Get the delay to wait before fetching the status. */
14 #define UCMB_IOCTL_GMSGDELAY _IOR(__UCMB_IOCTL, 1, unsigned int)
15 /** UCMB_IOCTL_SMSGDELAY - Set the delay to wait before fetching the status. */
16 #define UCMB_IOCTL_SMSGDELAY _IOW(__UCMB_IOCTL, 2, unsigned int)
17
18
19 #ifdef __KERNEL__
20
21 #include <linux/device.h>
22 #include <linux/spi/spi.h>
23 #include <linux/spi/spi_gpio.h>
24
25 /**
26 * struct ucmb_platform_data - UCMB device descriptor
27 *
28 * @name: The name of the device. This will also be the name of
29 * the misc char device.
30 *
31 * @gpio_cs: The chipselect GPIO pin. Can be SPI_GPIO_NO_CHIPSELECT,
32 * if chipselect is not used.
33 * @gpio_sck: The clock GPIO pin.
34 * @gpio_miso: The master-in slave-out GPIO pin.
35 * @gpio_mosi: The master-out slave-in GPIO pin.
36 *
37 * @gpio_reset: The GPIO pin to the microcontroller reset line.
38 * Can be UCMB_NO_RESET, if reset GPIO is not used.
39 * @reset_activelow: If true, @gpio_reset is considered to be active
40 * on logical 0 (inverted).
41 *
42 * @mode: The SPI bus mode. SPI_MODE_*
43 * @max_speed_hz: The bus speed, in Hz. If zero the speed is not limited.
44 */
45 struct ucmb_platform_data {
46 const char *name;
47
48 unsigned long gpio_cs;
49 unsigned int gpio_sck;
50 unsigned int gpio_miso;
51 unsigned int gpio_mosi;
52
53 unsigned int gpio_reset;
54 bool reset_activelow;
55
56 u8 mode;
57 u32 max_speed_hz;
58
59 struct platform_device *pdev; /* internal */
60 };
61
62 #define UCMB_NO_RESET ((unsigned int)-1)
63
64 int ucmb_device_register(struct ucmb_platform_data *pdata);
65 void ucmb_device_unregister(struct ucmb_platform_data *pdata);
66
67
68 #endif /* __KERNEL__ */
69 #endif /* LINUX_UCMB_H_ */