forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'i3c/for-6.14' of git://git.kernel.org/pub/scm/linux/kernel…
…/git/i3c/linux Pull i3c updates from Alexandre Belloni: "The main change is the addition of PCI bus support for mipi-i3c-hci. I'm also carrying an hwmon patch as it makes use of the bitops addition that is then mainly used by i3c drivers. Core: - Improve initialization of numbered I2C adapters Drivers: - use parity8 helper - dw: fix possible use-after-free - mipi-i3c-hci: add support for PCI bus host - svc: many fixes for IBI and hotjoin" * tag 'i3c/for-6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux: i3c: master: Improve initialization of numbered I2C adapters i3c: master: Fix missing 'ret' assignment in set_speed() i3c: cdns: use parity8 helper instead of open coding it i3c: mipi-i3c-hci: use parity8 helper instead of open coding it i3c: dw: use parity8 helper instead of open coding it hwmon: (spd5118) Use generic parity calculation bitops: add generic parity calculation for u8 i3c: mipi-i3c-hci: Add support for MIPI I3C HCI on PCI bus i3c: mipi-i3c-hci: Add Intel specific quirk to ring resuming i3c: fix kdoc parameter description for module_i3c_i2c_driver() i3c: dw: Fix use-after-free in dw_i3c_master driver due to race condition
- Loading branch information
Showing
11 changed files
with
227 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* PCI glue code for MIPI I3C HCI driver | ||
* | ||
* Copyright (C) 2024 Intel Corporation | ||
* | ||
* Author: Jarkko Nikula <[email protected]> | ||
*/ | ||
#include <linux/acpi.h> | ||
#include <linux/idr.h> | ||
#include <linux/kernel.h> | ||
#include <linux/module.h> | ||
#include <linux/pci.h> | ||
#include <linux/platform_device.h> | ||
|
||
struct mipi_i3c_hci_pci_info { | ||
int (*init)(struct pci_dev *pci); | ||
}; | ||
|
||
#define INTEL_PRIV_OFFSET 0x2b0 | ||
#define INTEL_PRIV_SIZE 0x28 | ||
#define INTEL_PRIV_RESETS 0x04 | ||
#define INTEL_PRIV_RESETS_RESET BIT(0) | ||
#define INTEL_PRIV_RESETS_RESET_DONE BIT(1) | ||
|
||
static DEFINE_IDA(mipi_i3c_hci_pci_ida); | ||
|
||
static int mipi_i3c_hci_pci_intel_init(struct pci_dev *pci) | ||
{ | ||
unsigned long timeout; | ||
void __iomem *priv; | ||
|
||
priv = devm_ioremap(&pci->dev, | ||
pci_resource_start(pci, 0) + INTEL_PRIV_OFFSET, | ||
INTEL_PRIV_SIZE); | ||
if (!priv) | ||
return -ENOMEM; | ||
|
||
/* Assert reset, wait for completion and release reset */ | ||
writel(0, priv + INTEL_PRIV_RESETS); | ||
timeout = jiffies + msecs_to_jiffies(10); | ||
while (!(readl(priv + INTEL_PRIV_RESETS) & | ||
INTEL_PRIV_RESETS_RESET_DONE)) { | ||
if (time_after(jiffies, timeout)) | ||
break; | ||
cpu_relax(); | ||
} | ||
writel(INTEL_PRIV_RESETS_RESET, priv + INTEL_PRIV_RESETS); | ||
|
||
return 0; | ||
} | ||
|
||
static struct mipi_i3c_hci_pci_info intel_info = { | ||
.init = mipi_i3c_hci_pci_intel_init, | ||
}; | ||
|
||
static int mipi_i3c_hci_pci_probe(struct pci_dev *pci, | ||
const struct pci_device_id *id) | ||
{ | ||
struct mipi_i3c_hci_pci_info *info; | ||
struct platform_device *pdev; | ||
struct resource res[2]; | ||
int dev_id, ret; | ||
|
||
ret = pcim_enable_device(pci); | ||
if (ret) | ||
return ret; | ||
|
||
pci_set_master(pci); | ||
|
||
memset(&res, 0, sizeof(res)); | ||
|
||
res[0].flags = IORESOURCE_MEM; | ||
res[0].start = pci_resource_start(pci, 0); | ||
res[0].end = pci_resource_end(pci, 0); | ||
|
||
res[1].flags = IORESOURCE_IRQ; | ||
res[1].start = pci->irq; | ||
res[1].end = pci->irq; | ||
|
||
dev_id = ida_alloc(&mipi_i3c_hci_pci_ida, GFP_KERNEL); | ||
if (dev_id < 0) | ||
return dev_id; | ||
|
||
pdev = platform_device_alloc("mipi-i3c-hci", dev_id); | ||
if (!pdev) | ||
return -ENOMEM; | ||
|
||
pdev->dev.parent = &pci->dev; | ||
device_set_node(&pdev->dev, dev_fwnode(&pci->dev)); | ||
|
||
ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res)); | ||
if (ret) | ||
goto err; | ||
|
||
info = (struct mipi_i3c_hci_pci_info *)id->driver_data; | ||
if (info && info->init) { | ||
ret = info->init(pci); | ||
if (ret) | ||
goto err; | ||
} | ||
|
||
ret = platform_device_add(pdev); | ||
if (ret) | ||
goto err; | ||
|
||
pci_set_drvdata(pci, pdev); | ||
|
||
return 0; | ||
|
||
err: | ||
platform_device_put(pdev); | ||
ida_free(&mipi_i3c_hci_pci_ida, dev_id); | ||
return ret; | ||
} | ||
|
||
static void mipi_i3c_hci_pci_remove(struct pci_dev *pci) | ||
{ | ||
struct platform_device *pdev = pci_get_drvdata(pci); | ||
int dev_id = pdev->id; | ||
|
||
platform_device_unregister(pdev); | ||
ida_free(&mipi_i3c_hci_pci_ida, dev_id); | ||
} | ||
|
||
static const struct pci_device_id mipi_i3c_hci_pci_devices[] = { | ||
/* Panther Lake-H */ | ||
{ PCI_VDEVICE(INTEL, 0xe37c), (kernel_ulong_t)&intel_info}, | ||
{ PCI_VDEVICE(INTEL, 0xe36f), (kernel_ulong_t)&intel_info}, | ||
/* Panther Lake-P */ | ||
{ PCI_VDEVICE(INTEL, 0xe47c), (kernel_ulong_t)&intel_info}, | ||
{ PCI_VDEVICE(INTEL, 0xe46f), (kernel_ulong_t)&intel_info}, | ||
{ }, | ||
}; | ||
MODULE_DEVICE_TABLE(pci, mipi_i3c_hci_pci_devices); | ||
|
||
static struct pci_driver mipi_i3c_hci_pci_driver = { | ||
.name = "mipi_i3c_hci_pci", | ||
.id_table = mipi_i3c_hci_pci_devices, | ||
.probe = mipi_i3c_hci_pci_probe, | ||
.remove = mipi_i3c_hci_pci_remove, | ||
}; | ||
|
||
module_pci_driver(mipi_i3c_hci_pci_driver); | ||
|
||
MODULE_AUTHOR("Jarkko Nikula <[email protected]>"); | ||
MODULE_LICENSE("GPL"); | ||
MODULE_DESCRIPTION("MIPI I3C HCI driver on PCI bus"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters