blob: 3df8c54868df59d9f6b2c19cd7be3c1c166a3f59 [file] [log] [blame]
Thomas Gleixner1802d0b2019-05-27 08:55:21 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Jeremy Kerr0508ad12017-02-01 10:53:41 -06002/* FSI device & driver interfaces
3 *
4 * Copyright (C) IBM Corporation 2016
Jeremy Kerr0508ad12017-02-01 10:53:41 -06005 */
6
7#ifndef LINUX_FSI_H
8#define LINUX_FSI_H
9
10#include <linux/device.h>
11
Jeremy Kerrfda07a62017-02-01 10:53:42 -060012struct fsi_device {
Jeremy Kerrdd37eed2017-02-01 10:53:43 -060013 struct device dev;
14 u8 engine_type;
15 u8 version;
Jeremy Kerrf7ade2a2017-06-06 16:08:44 -050016 u8 unit;
17 struct fsi_slave *slave;
18 uint32_t addr;
19 uint32_t size;
Jeremy Kerrfda07a62017-02-01 10:53:42 -060020};
21
Jeremy Kerr4efe37f2017-06-06 16:08:45 -050022extern int fsi_device_read(struct fsi_device *dev, uint32_t addr,
23 void *val, size_t size);
24extern int fsi_device_write(struct fsi_device *dev, uint32_t addr,
25 const void *val, size_t size);
26extern int fsi_device_peek(struct fsi_device *dev, void *val);
27
Jeremy Kerrdd37eed2017-02-01 10:53:43 -060028struct fsi_device_id {
29 u8 engine_type;
30 u8 version;
31};
32
33#define FSI_VERSION_ANY 0
34
35#define FSI_DEVICE(t) \
36 .engine_type = (t), .version = FSI_VERSION_ANY,
37
38#define FSI_DEVICE_VERSIONED(t, v) \
39 .engine_type = (t), .version = (v),
40
Jeremy Kerrfda07a62017-02-01 10:53:42 -060041struct fsi_driver {
Jeremy Kerrdd37eed2017-02-01 10:53:43 -060042 struct device_driver drv;
43 const struct fsi_device_id *id_table;
Jeremy Kerrfda07a62017-02-01 10:53:42 -060044};
45
46#define to_fsi_dev(devp) container_of(devp, struct fsi_device, dev)
47#define to_fsi_drv(drvp) container_of(drvp, struct fsi_driver, drv)
48
Christopher Bostic356d8002017-06-06 16:08:48 -050049extern int fsi_driver_register(struct fsi_driver *fsi_drv);
50extern void fsi_driver_unregister(struct fsi_driver *fsi_drv);
51
52/* module_fsi_driver() - Helper macro for drivers that don't do
53 * anything special in module init/exit. This eliminates a lot of
54 * boilerplate. Each module may only use this macro once, and
55 * calling it replaces module_init() and module_exit()
56 */
57#define module_fsi_driver(__fsi_driver) \
58 module_driver(__fsi_driver, fsi_driver_register, \
59 fsi_driver_unregister)
60
Jeremy Kerrda36cad2017-06-06 16:08:50 -050061/* direct slave API */
62extern int fsi_slave_claim_range(struct fsi_slave *slave,
63 uint32_t addr, uint32_t size);
64extern void fsi_slave_release_range(struct fsi_slave *slave,
65 uint32_t addr, uint32_t size);
66extern int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
67 void *val, size_t size);
68extern int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
69 const void *val, size_t size);
70
Jeremy Kerr0508ad12017-02-01 10:53:41 -060071extern struct bus_type fsi_bus_type;
Benjamin Herrenschmidt0ab5fe52018-06-20 15:22:52 +100072extern const struct device_type fsi_cdev_type;
73
74enum fsi_dev_type {
75 fsi_dev_cfam,
76 fsi_dev_sbefifo,
77 fsi_dev_scom,
78 fsi_dev_occ
79};
80
81extern int fsi_get_new_minor(struct fsi_device *fdev, enum fsi_dev_type type,
82 dev_t *out_dev, int *out_index);
83extern void fsi_free_minor(dev_t dev);
Jeremy Kerr0508ad12017-02-01 10:53:41 -060084
85#endif /* LINUX_FSI_H */