Xenomai  3.0.8
spi-master.h
1 
18 #ifndef _RTDM_SPI_MASTER_H
19 #define _RTDM_SPI_MASTER_H
20 
21 #include <rtdm/driver.h>
22 #include <rtdm/uapi/spi.h>
23 #include "spi-device.h"
24 
25 struct class;
26 struct device_node;
27 struct rtdm_spi_master;
28 struct spi_master;
29 
30 struct rtdm_spi_master_ops {
31  int (*open)(struct rtdm_spi_remote_slave *slave);
32  void (*close)(struct rtdm_spi_remote_slave *slave);
33  int (*configure)(struct rtdm_spi_remote_slave *slave);
34  void (*chip_select)(struct rtdm_spi_remote_slave *slave,
35  bool active);
36  int (*set_iobufs)(struct rtdm_spi_remote_slave *slave,
37  struct rtdm_spi_iobufs *p);
38  int (*mmap_iobufs)(struct rtdm_spi_remote_slave *slave,
39  struct vm_area_struct *vma);
40  void (*mmap_release)(struct rtdm_spi_remote_slave *slave);
41  int (*transfer_iobufs)(struct rtdm_spi_remote_slave *slave);
42  ssize_t (*write)(struct rtdm_spi_remote_slave *slave,
43  const void *tx, size_t len);
44  ssize_t (*read)(struct rtdm_spi_remote_slave *slave,
45  void *rx, size_t len);
46  struct rtdm_spi_remote_slave *(*attach_slave)
47  (struct rtdm_spi_master *master,
48  struct spi_device *spi);
49  void (*detach_slave)(struct rtdm_spi_remote_slave *slave);
50 };
51 
52 struct rtdm_spi_master {
53  int subclass;
54  const struct rtdm_spi_master_ops *ops;
55  struct spi_master *kmaster;
56  struct { /* Internal */
57  struct rtdm_driver driver;
58  struct class *devclass;
59  char *classname;
60  struct list_head slaves;
61  struct list_head next;
62  rtdm_lock_t lock;
63  rtdm_mutex_t bus_lock;
64  struct rtdm_spi_remote_slave *cs;
65  };
66 };
67 
68 #define rtdm_spi_alloc_master(__dev, __type, __mptr) \
69  __rtdm_spi_alloc_master(__dev, sizeof(__type), \
70  offsetof(__type, __mptr)) \
71 
72 struct rtdm_spi_master *
73 __rtdm_spi_alloc_master(struct device *dev, size_t size, int off);
74 
75 int __rtdm_spi_setup_driver(struct rtdm_spi_master *master);
76 
77 int rtdm_spi_add_master(struct rtdm_spi_master *master);
78 
79 void rtdm_spi_remove_master(struct rtdm_spi_master *master);
80 
81 #endif /* !_RTDM_SPI_MASTER_H */
ipipe_spinlock_t rtdm_lock_t
Lock variable.
Definition: driver.h:551
Real-Time Driver Model for Xenomai, driver API header.
RTDM driver.
Definition: driver.h:249