1 /* SPDX-License-Identifier: GPL-2.0 */ << 2 #ifndef __LINUX_USB_DLN2_H 1 #ifndef __LINUX_USB_DLN2_H 3 #define __LINUX_USB_DLN2_H 2 #define __LINUX_USB_DLN2_H 4 3 5 #define DLN2_CMD(cmd, id) ((cmd) 4 #define DLN2_CMD(cmd, id) ((cmd) | ((id) << 8)) 6 5 7 struct dln2_platform_data { 6 struct dln2_platform_data { 8 u16 handle; /* sub-driver 7 u16 handle; /* sub-driver handle (internally used only) */ 9 u8 port; /* I2C/SPI por 8 u8 port; /* I2C/SPI port */ 10 }; 9 }; 11 10 12 /** 11 /** 13 * dln2_event_cb_t - event callback function s 12 * dln2_event_cb_t - event callback function signature 14 * 13 * 15 * @pdev - the sub-device that registered this 14 * @pdev - the sub-device that registered this callback 16 * @echo - the echo header field received in t 15 * @echo - the echo header field received in the message 17 * @data - the data payload 16 * @data - the data payload 18 * @len - the data payload length 17 * @len - the data payload length 19 * 18 * 20 * The callback function is called in interrup 19 * The callback function is called in interrupt context and the data payload is 21 * only valid during the call. If the user nee 20 * only valid during the call. If the user needs later access of the data, it 22 * must copy it. 21 * must copy it. 23 */ 22 */ 24 23 25 typedef void (*dln2_event_cb_t)(struct platfor 24 typedef void (*dln2_event_cb_t)(struct platform_device *pdev, u16 echo, 26 const void *da 25 const void *data, int len); 27 26 28 /** 27 /** 29 * dl2n_register_event_cb - register a callbac 28 * dl2n_register_event_cb - register a callback function for an event 30 * 29 * 31 * @pdev - the sub-device that registers the c 30 * @pdev - the sub-device that registers the callback 32 * @event - the event for which to register a 31 * @event - the event for which to register a callback 33 * @event_cb - the callback function 32 * @event_cb - the callback function 34 * 33 * 35 * @return 0 in case of success, negative valu 34 * @return 0 in case of success, negative value in case of error 36 */ 35 */ 37 int dln2_register_event_cb(struct platform_dev 36 int dln2_register_event_cb(struct platform_device *pdev, u16 event, 38 dln2_event_cb_t eve 37 dln2_event_cb_t event_cb); 39 38 40 /** 39 /** 41 * dln2_unregister_event_cb - unregister the c 40 * dln2_unregister_event_cb - unregister the callback function for an event 42 * 41 * 43 * @pdev - the sub-device that registered the 42 * @pdev - the sub-device that registered the callback 44 * @event - the event for which to register a 43 * @event - the event for which to register a callback 45 */ 44 */ 46 void dln2_unregister_event_cb(struct platform_ 45 void dln2_unregister_event_cb(struct platform_device *pdev, u16 event); 47 46 48 /** 47 /** 49 * dln2_transfer - issue a DLN2 command and wa 48 * dln2_transfer - issue a DLN2 command and wait for a response and the 50 * associated data 49 * associated data 51 * 50 * 52 * @pdev - the sub-device which is issuing thi 51 * @pdev - the sub-device which is issuing this transfer 53 * @cmd - the command to be sent to the device 52 * @cmd - the command to be sent to the device 54 * @obuf - the buffer to be sent to the device 53 * @obuf - the buffer to be sent to the device; it can be NULL if the user 55 * doesn't need to transmit data with thi 54 * doesn't need to transmit data with this command 56 * @obuf_len - the size of the buffer to be se 55 * @obuf_len - the size of the buffer to be sent to the device 57 * @ibuf - any data associated with the respon 56 * @ibuf - any data associated with the response will be copied here; it can be 58 * NULL if the user doesn't need the resp 57 * NULL if the user doesn't need the response data 59 * @ibuf_len - must be initialized to the inpu 58 * @ibuf_len - must be initialized to the input buffer size; it will be modified 60 * to indicate the actual data transferre 59 * to indicate the actual data transferred; 61 * 60 * 62 * @return 0 for success, negative value for e 61 * @return 0 for success, negative value for errors 63 */ 62 */ 64 int dln2_transfer(struct platform_device *pdev 63 int dln2_transfer(struct platform_device *pdev, u16 cmd, 65 const void *obuf, unsigned o 64 const void *obuf, unsigned obuf_len, 66 void *ibuf, unsigned *ibuf_l 65 void *ibuf, unsigned *ibuf_len); 67 66 68 /** 67 /** 69 * dln2_transfer_rx - variant of @dln2_transfe 68 * dln2_transfer_rx - variant of @dln2_transfer() where TX buffer is not needed 70 * 69 * 71 * @pdev - the sub-device which is issuing thi 70 * @pdev - the sub-device which is issuing this transfer 72 * @cmd - the command to be sent to the device 71 * @cmd - the command to be sent to the device 73 * @ibuf - any data associated with the respon 72 * @ibuf - any data associated with the response will be copied here; it can be 74 * NULL if the user doesn't need the resp 73 * NULL if the user doesn't need the response data 75 * @ibuf_len - must be initialized to the inpu 74 * @ibuf_len - must be initialized to the input buffer size; it will be modified 76 * to indicate the actual data transferre 75 * to indicate the actual data transferred; 77 * 76 * 78 * @return 0 for success, negative value for e 77 * @return 0 for success, negative value for errors 79 */ 78 */ 80 79 81 static inline int dln2_transfer_rx(struct plat 80 static inline int dln2_transfer_rx(struct platform_device *pdev, u16 cmd, 82 void *ibuf, 81 void *ibuf, unsigned *ibuf_len) 83 { 82 { 84 return dln2_transfer(pdev, cmd, NULL, 83 return dln2_transfer(pdev, cmd, NULL, 0, ibuf, ibuf_len); 85 } 84 } 86 85 87 /** 86 /** 88 * dln2_transfer_tx - variant of @dln2_transfe 87 * dln2_transfer_tx - variant of @dln2_transfer() where RX buffer is not needed 89 * 88 * 90 * @pdev - the sub-device which is issuing thi 89 * @pdev - the sub-device which is issuing this transfer 91 * @cmd - the command to be sent to the device 90 * @cmd - the command to be sent to the device 92 * @obuf - the buffer to be sent to the device 91 * @obuf - the buffer to be sent to the device; it can be NULL if the 93 * user doesn't need to transmit data wit 92 * user doesn't need to transmit data with this command 94 * @obuf_len - the size of the buffer to be se 93 * @obuf_len - the size of the buffer to be sent to the device 95 * 94 * 96 * @return 0 for success, negative value for e 95 * @return 0 for success, negative value for errors 97 */ 96 */ 98 static inline int dln2_transfer_tx(struct plat 97 static inline int dln2_transfer_tx(struct platform_device *pdev, u16 cmd, 99 const void 98 const void *obuf, unsigned obuf_len) 100 { 99 { 101 return dln2_transfer(pdev, cmd, obuf, 100 return dln2_transfer(pdev, cmd, obuf, obuf_len, NULL, NULL); 102 } 101 } 103 102 104 #endif 103 #endif 105 104
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.