Jeremy Kerr | 09aecfa | 2017-06-06 16:08:36 -0500 | [diff] [blame] | 1 | /* |
| 2 | * FSI master definitions. These comprise the core <--> master interface, |
| 3 | * to allow the core to interact with the (hardware-specific) masters. |
| 4 | * |
| 5 | * Copyright (C) IBM Corporation 2016 |
| 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 version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | */ |
| 16 | |
| 17 | #ifndef DRIVERS_FSI_MASTER_H |
| 18 | #define DRIVERS_FSI_MASTER_H |
| 19 | |
| 20 | #include <linux/device.h> |
| 21 | |
Jeremy Kerr | 4af889b | 2017-06-06 16:08:58 -0500 | [diff] [blame] | 22 | #define FSI_MASTER_FLAG_SWCLOCK 0x1 |
| 23 | |
Jeremy Kerr | 09aecfa | 2017-06-06 16:08:36 -0500 | [diff] [blame] | 24 | struct fsi_master { |
| 25 | struct device dev; |
| 26 | int idx; |
| 27 | int n_links; |
| 28 | int flags; |
| 29 | int (*read)(struct fsi_master *, int link, uint8_t id, |
| 30 | uint32_t addr, void *val, size_t size); |
| 31 | int (*write)(struct fsi_master *, int link, uint8_t id, |
| 32 | uint32_t addr, const void *val, size_t size); |
| 33 | int (*term)(struct fsi_master *, int link, uint8_t id); |
| 34 | int (*send_break)(struct fsi_master *, int link); |
| 35 | int (*link_enable)(struct fsi_master *, int link); |
Benjamin Herrenschmidt | a2e7da8 | 2018-05-29 15:01:07 +1000 | [diff] [blame^] | 36 | int (*link_config)(struct fsi_master *, int link, |
| 37 | u8 t_send_delay, u8 t_echo_delay); |
Jeremy Kerr | 09aecfa | 2017-06-06 16:08:36 -0500 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | #define dev_to_fsi_master(d) container_of(d, struct fsi_master, dev) |
| 41 | |
Jeremy Kerr | e0c24bd | 2018-02-12 15:45:47 +1030 | [diff] [blame] | 42 | /** |
| 43 | * fsi_master registration & lifetime: the fsi_master_register() and |
| 44 | * fsi_master_unregister() functions will take ownership of the master, and |
| 45 | * ->dev in particular. The registration path performs a get_device(), which |
| 46 | * takes the first reference on the device. Similarly, the unregistration path |
| 47 | * performs a put_device(), which may well drop the last reference. |
| 48 | * |
| 49 | * This means that master implementations *may* need to hold their own |
| 50 | * reference (via get_device()) on master->dev. In particular, if the device's |
| 51 | * ->release callback frees the fsi_master, then fsi_master_unregister will |
| 52 | * invoke this free if no other reference is held. |
| 53 | * |
| 54 | * The same applies for the error path of fsi_master_register; if the call |
| 55 | * fails, dev->release will have been invoked. |
| 56 | */ |
Jeremy Kerr | 09aecfa | 2017-06-06 16:08:36 -0500 | [diff] [blame] | 57 | extern int fsi_master_register(struct fsi_master *master); |
| 58 | extern void fsi_master_unregister(struct fsi_master *master); |
| 59 | |
Jeremy Kerr | 15362d6 | 2018-02-12 15:45:40 +1030 | [diff] [blame] | 60 | extern int fsi_master_rescan(struct fsi_master *master); |
| 61 | |
Jeremy Kerr | 09aecfa | 2017-06-06 16:08:36 -0500 | [diff] [blame] | 62 | #endif /* DRIVERS_FSI_MASTER_H */ |