| 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* |
| 3 | * Copyright (C) 2025 Nuvoton Technology Corp. |
| 4 | * |
| 5 | * Nuvoton NCT6694 USB transaction and data structure. |
| 6 | */ |
| 7 | |
| 8 | #ifndef __MFD_NCT6694_H |
| 9 | #define __MFD_NCT6694_H |
| 10 | |
| 11 | #define NCT6694_VENDOR_ID 0x0416 |
| 12 | #define NCT6694_PRODUCT_ID 0x200B |
| 13 | #define NCT6694_INT_IN_EP 0x81 |
| 14 | #define NCT6694_BULK_IN_EP 0x02 |
| 15 | #define NCT6694_BULK_OUT_EP 0x03 |
| 16 | |
| 17 | #define NCT6694_HCTRL_SET 0x40 |
| 18 | #define NCT6694_HCTRL_GET 0x80 |
| 19 | |
| 20 | #define NCT6694_URB_TIMEOUT 1000 |
| 21 | |
| 22 | enum nct6694_irq_id { |
| 23 | NCT6694_IRQ_GPIO0 = 0, |
| 24 | NCT6694_IRQ_GPIO1, |
| 25 | NCT6694_IRQ_GPIO2, |
| 26 | NCT6694_IRQ_GPIO3, |
| 27 | NCT6694_IRQ_GPIO4, |
| 28 | NCT6694_IRQ_GPIO5, |
| 29 | NCT6694_IRQ_GPIO6, |
| 30 | NCT6694_IRQ_GPIO7, |
| 31 | NCT6694_IRQ_GPIO8, |
| 32 | NCT6694_IRQ_GPIO9, |
| 33 | NCT6694_IRQ_GPIOA, |
| 34 | NCT6694_IRQ_GPIOB, |
| 35 | NCT6694_IRQ_GPIOC, |
| 36 | NCT6694_IRQ_GPIOD, |
| 37 | NCT6694_IRQ_GPIOE, |
| 38 | NCT6694_IRQ_GPIOF, |
| 39 | NCT6694_IRQ_CAN0, |
| 40 | NCT6694_IRQ_CAN1, |
| 41 | NCT6694_IRQ_RTC, |
| 42 | NCT6694_NR_IRQS, |
| 43 | }; |
| 44 | |
| 45 | enum nct6694_response_err_status { |
| 46 | NCT6694_NO_ERROR = 0, |
| 47 | NCT6694_FORMAT_ERROR, |
| 48 | NCT6694_RESERVED1, |
| 49 | NCT6694_RESERVED2, |
| 50 | NCT6694_NOT_SUPPORT_ERROR, |
| 51 | NCT6694_NO_RESPONSE_ERROR, |
| 52 | NCT6694_TIMEOUT_ERROR, |
| 53 | NCT6694_PENDING, |
| 54 | }; |
| 55 | |
| 56 | struct __packed { |
| 57 | u8 ; |
| 58 | u8 ; |
| 59 | union __packed { |
| 60 | __le16 ; |
| 61 | struct __packed { |
| 62 | u8 ; |
| 63 | u8 ; |
| 64 | }; |
| 65 | }; |
| 66 | u8 ; |
| 67 | u8 ; |
| 68 | __le16 ; |
| 69 | }; |
| 70 | |
| 71 | struct __packed { |
| 72 | u8 ; |
| 73 | u8 ; |
| 74 | u8 [4]; |
| 75 | __le16 ; |
| 76 | }; |
| 77 | |
| 78 | union __packed nct6694_usb_msg { |
| 79 | struct nct6694_cmd_header ; |
| 80 | struct nct6694_response_header ; |
| 81 | }; |
| 82 | |
| 83 | struct nct6694 { |
| 84 | struct device *dev; |
| 85 | struct ida gpio_ida; |
| 86 | struct ida i2c_ida; |
| 87 | struct ida canfd_ida; |
| 88 | struct ida wdt_ida; |
| 89 | struct irq_domain *domain; |
| 90 | struct mutex access_lock; |
| 91 | spinlock_t irq_lock; |
| 92 | struct urb *int_in_urb; |
| 93 | struct usb_device *udev; |
| 94 | union nct6694_usb_msg *usb_msg; |
| 95 | __le32 *int_buffer; |
| 96 | unsigned int irq_enable; |
| 97 | }; |
| 98 | |
| 99 | int nct6694_read_msg(struct nct6694 *nct6694, const struct nct6694_cmd_header *cmd_hd, void *buf); |
| 100 | int nct6694_write_msg(struct nct6694 *nct6694, const struct nct6694_cmd_header *cmd_hd, void *buf); |
| 101 | |
| 102 | #endif |
| 103 | |