Skip to content

Commit 48f151a

Browse files
EvenxfJiri Kosina
authored andcommitted
HID: Intel-thc-hid: Intel-quicki2c: Add driver data support
This patch defines driver data structure and adds it into QuickI2C device structure. Changes PCI ID table to use PCI_DEVICE_DATA() to pass platform specific driver data into driver, let driver has capability to enable different hardware features according to different platform driver data. Signed-off-by: Even Xu <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent bccbe21 commit 48f151a

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ static irqreturn_t quicki2c_irq_thread_handler(int irq, void *dev_id)
323323
* quicki2c_dev_init - Initialize QuickI2C device
324324
* @pdev: Pointer to the THC PCI device
325325
* @mem_addr: The Pointer of MMIO memory address
326+
* @ddata: Point to quicki2c_ddata structure
326327
*
327328
* Alloc quicki2c_device structure and initialized THC device,
328329
* then configure THC to HIDI2C mode.
@@ -332,7 +333,8 @@ static irqreturn_t quicki2c_irq_thread_handler(int irq, void *dev_id)
332333
* Return: Pointer to the quicki2c_device structure if success
333334
* or NULL on failure.
334335
*/
335-
static struct quicki2c_device *quicki2c_dev_init(struct pci_dev *pdev, void __iomem *mem_addr)
336+
static struct quicki2c_device *quicki2c_dev_init(struct pci_dev *pdev, void __iomem *mem_addr,
337+
const struct quicki2c_ddata *ddata)
336338
{
337339
struct device *dev = &pdev->dev;
338340
struct quicki2c_device *qcdev;
@@ -346,6 +348,7 @@ static struct quicki2c_device *quicki2c_dev_init(struct pci_dev *pdev, void __io
346348
qcdev->dev = dev;
347349
qcdev->mem_addr = mem_addr;
348350
qcdev->state = QUICKI2C_DISABLED;
351+
qcdev->ddata = ddata;
349352

350353
init_waitqueue_head(&qcdev->reset_ack_wq);
351354

@@ -529,9 +532,9 @@ static int quicki2c_alloc_report_buf(struct quicki2c_device *qcdev)
529532
*
530533
* Return 0 if success or error code on failure.
531534
*/
532-
static int quicki2c_probe(struct pci_dev *pdev,
533-
const struct pci_device_id *id)
535+
static int quicki2c_probe(struct pci_dev *pdev, const struct pci_device_id *id)
534536
{
537+
const struct quicki2c_ddata *ddata = (const struct quicki2c_ddata *)id->driver_data;
535538
struct quicki2c_device *qcdev;
536539
void __iomem *mem_addr;
537540
int ret;
@@ -569,7 +572,7 @@ static int quicki2c_probe(struct pci_dev *pdev,
569572

570573
pdev->irq = pci_irq_vector(pdev, 0);
571574

572-
qcdev = quicki2c_dev_init(pdev, mem_addr);
575+
qcdev = quicki2c_dev_init(pdev, mem_addr, ddata);
573576
if (IS_ERR(qcdev)) {
574577
dev_err_once(&pdev->dev, "QuickI2C device init failed\n");
575578
ret = PTR_ERR(qcdev);
@@ -919,13 +922,13 @@ static const struct dev_pm_ops quicki2c_pm_ops = {
919922
};
920923

921924
static const struct pci_device_id quicki2c_pci_tbl[] = {
922-
{PCI_VDEVICE(INTEL, THC_LNL_DEVICE_ID_I2C_PORT1), },
923-
{PCI_VDEVICE(INTEL, THC_LNL_DEVICE_ID_I2C_PORT2), },
924-
{PCI_VDEVICE(INTEL, THC_PTL_H_DEVICE_ID_I2C_PORT1), },
925-
{PCI_VDEVICE(INTEL, THC_PTL_H_DEVICE_ID_I2C_PORT2), },
926-
{PCI_VDEVICE(INTEL, THC_PTL_U_DEVICE_ID_I2C_PORT1), },
927-
{PCI_VDEVICE(INTEL, THC_PTL_U_DEVICE_ID_I2C_PORT2), },
928-
{}
925+
{ PCI_DEVICE_DATA(INTEL, THC_LNL_DEVICE_ID_I2C_PORT1, NULL) },
926+
{ PCI_DEVICE_DATA(INTEL, THC_LNL_DEVICE_ID_I2C_PORT2, NULL) },
927+
{ PCI_DEVICE_DATA(INTEL, THC_PTL_H_DEVICE_ID_I2C_PORT1, NULL) },
928+
{ PCI_DEVICE_DATA(INTEL, THC_PTL_H_DEVICE_ID_I2C_PORT2, NULL) },
929+
{ PCI_DEVICE_DATA(INTEL, THC_PTL_U_DEVICE_ID_I2C_PORT1, NULL) },
930+
{ PCI_DEVICE_DATA(INTEL, THC_PTL_U_DEVICE_ID_I2C_PORT2, NULL) },
931+
{ }
929932
};
930933
MODULE_DEVICE_TABLE(pci, quicki2c_pci_tbl);
931934

drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-dev.h

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
#include <linux/hid-over-i2c.h>
88
#include <linux/workqueue.h>
99

10-
#define THC_LNL_DEVICE_ID_I2C_PORT1 0xA848
11-
#define THC_LNL_DEVICE_ID_I2C_PORT2 0xA84A
12-
#define THC_PTL_H_DEVICE_ID_I2C_PORT1 0xE348
13-
#define THC_PTL_H_DEVICE_ID_I2C_PORT2 0xE34A
14-
#define THC_PTL_U_DEVICE_ID_I2C_PORT1 0xE448
15-
#define THC_PTL_U_DEVICE_ID_I2C_PORT2 0xE44A
10+
#define PCI_DEVICE_ID_INTEL_THC_LNL_DEVICE_ID_I2C_PORT1 0xA848
11+
#define PCI_DEVICE_ID_INTEL_THC_LNL_DEVICE_ID_I2C_PORT2 0xA84A
12+
#define PCI_DEVICE_ID_INTEL_THC_PTL_H_DEVICE_ID_I2C_PORT1 0xE348
13+
#define PCI_DEVICE_ID_INTEL_THC_PTL_H_DEVICE_ID_I2C_PORT2 0xE34A
14+
#define PCI_DEVICE_ID_INTEL_THC_PTL_U_DEVICE_ID_I2C_PORT1 0xE448
15+
#define PCI_DEVICE_ID_INTEL_THC_PTL_U_DEVICE_ID_I2C_PORT2 0xE44A
1616

1717
/* Packet size value, the unit is 16 bytes */
1818
#define MAX_PACKET_SIZE_VALUE_LNL 256
@@ -122,6 +122,16 @@ struct quicki2c_subip_acpi_config {
122122
u64 HMSL;
123123
};
124124

125+
/**
126+
* struct quicki2c_ddata - Driver specific data for quicki2c device
127+
* @max_detect_size: Identify max packet size detect for rx
128+
* @interrupt_delay: Identify interrupt detect delay for rx
129+
*/
130+
struct quicki2c_ddata {
131+
u32 max_detect_size;
132+
u32 interrupt_delay;
133+
};
134+
125135
struct device;
126136
struct pci_dev;
127137
struct thc_device;
@@ -135,6 +145,7 @@ struct acpi_device;
135145
* @thc_hw: Point to THC device
136146
* @hid_dev: Point to HID device
137147
* @acpi_dev: Point to ACPI device
148+
* @ddata: Point to QuickI2C platform specific driver data
138149
* @state: THC I2C device state
139150
* @mem_addr: MMIO memory address
140151
* @dev_desc: Device descriptor for HIDI2C protocol
@@ -158,6 +169,7 @@ struct quicki2c_device {
158169
struct thc_device *thc_hw;
159170
struct hid_device *hid_dev;
160171
struct acpi_device *acpi_dev;
172+
const struct quicki2c_ddata *ddata;
161173
enum quicki2c_dev_state state;
162174

163175
void __iomem *mem_addr;

0 commit comments

Comments
 (0)