1 /* SPDX-License-Identifier: GPL-2.0-only */ 1 2 /* 3 * Copyright (c) 2023, Intel Corporation. All 4 */ 5 #ifndef _LINUX_USB_LJCA_H_ 6 #define _LINUX_USB_LJCA_H_ 7 8 #include <linux/auxiliary_bus.h> 9 #include <linux/list.h> 10 #include <linux/spinlock.h> 11 #include <linux/types.h> 12 13 #define LJCA_MAX_GPIO_NUM 64 14 15 #define auxiliary_dev_to_ljca_client(auxiliary 16 container_of(auxiliary_dev, st 17 18 struct ljca_adapter; 19 20 /** 21 * typedef ljca_event_cb_t - event callback fu 22 * 23 * @context: the execution context of who regi 24 * @cmd: the command from device for this even 25 * @evt_data: the event data payload 26 * @len: the event data payload length 27 * 28 * The callback function is called in interrup 29 * only valid during the call. If the user nee 30 * must copy it. 31 */ 32 typedef void (*ljca_event_cb_t)(void *context, 33 34 /** 35 * struct ljca_client - represent a ljca clien 36 * 37 * @type: ljca client type 38 * @id: ljca client id within same client type 39 * @link: ljca client on the same ljca adapter 40 * @auxdev: auxiliary device object 41 * @adapter: ljca adapter the ljca client sit 42 * @context: the execution context of the even 43 * @event_cb: ljca client driver register this 44 * firmware asynchronous rx buffer pendin 45 * @event_cb_lock: spinlock to protect event c 46 */ 47 struct ljca_client { 48 u8 type; 49 u8 id; 50 struct list_head link; 51 struct auxiliary_device auxdev; 52 struct ljca_adapter *adapter; 53 54 void *context; 55 ljca_event_cb_t event_cb; 56 /* lock to protect event_cb */ 57 spinlock_t event_cb_lock; 58 }; 59 60 /** 61 * struct ljca_gpio_info - ljca gpio client de 62 * 63 * @num: ljca gpio client device pin number 64 * @valid_pin_map: ljca gpio client device val 65 */ 66 struct ljca_gpio_info { 67 unsigned int num; 68 DECLARE_BITMAP(valid_pin_map, LJCA_MAX 69 }; 70 71 /** 72 * struct ljca_i2c_info - ljca i2c client devi 73 * 74 * @id: ljca i2c client device identification 75 * @capacity: ljca i2c client device capacity 76 * @intr_pin: ljca i2c client device interrupt 77 */ 78 struct ljca_i2c_info { 79 u8 id; 80 u8 capacity; 81 u8 intr_pin; 82 }; 83 84 /** 85 * struct ljca_spi_info - ljca spi client devi 86 * 87 * @id: ljca spi client device identification 88 * @capacity: ljca spi client device capacity 89 */ 90 struct ljca_spi_info { 91 u8 id; 92 u8 capacity; 93 }; 94 95 /** 96 * ljca_register_event_cb - register a callbac 97 * 98 * @client: ljca client device 99 * @event_cb: callback function 100 * @context: execution context of event callba 101 * 102 * Return: 0 in case of success, negative valu 103 */ 104 int ljca_register_event_cb(struct ljca_client 105 106 /** 107 * ljca_unregister_event_cb - unregister the c 108 * 109 * @client: ljca client device 110 */ 111 void ljca_unregister_event_cb(struct ljca_clie 112 113 /** 114 * ljca_transfer - issue a LJCA command and wa 115 * 116 * @client: ljca client device 117 * @cmd: the command to be sent to the device 118 * @obuf: the buffer to be sent to the device; 119 * doesn't need to transmit data with thi 120 * @obuf_len: the size of the buffer to be sen 121 * be 0 when obuf is NULL 122 * @ibuf: any data associated with the respons 123 * NULL if the user doesn't need the resp 124 * @ibuf_len: must be initialized to the input 125 * 126 * Return: the actual length of response data 127 */ 128 int ljca_transfer(struct ljca_client *client, 129 u8 obuf_len, u8 *ibuf, u8 ib 130 131 /** 132 * ljca_transfer_noack - issue a LJCA command 133 * 134 * @client: ljca client device 135 * @cmd: the command to be sent to the device 136 * @obuf: the buffer to be sent to the device; 137 * doesn't need to transmit data with thi 138 * @obuf_len: the size of the buffer to be sen 139 * 140 * Return: 0 for success, negative value for e 141 */ 142 int ljca_transfer_noack(struct ljca_client *cl 143 u8 obuf_len); 144 145 #endif 146
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.