-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i2s: phytium: Add Phytium i2s driver support #189
Merged
opsiff
merged 1 commit into
deepin-community:linux-6.6.y
from
tianwei08222:linux-6.6.y-i2s-only
Jul 1, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Phytium I2S LSD MFD driver over PCI bus | ||
* | ||
* Copyright (C) 2020-2023, Phytium Technology Co., Ltd. | ||
*/ | ||
|
||
#include <linux/kernel.h> | ||
#include <linux/module.h> | ||
#include <linux/pci.h> | ||
#include <linux/mfd/core.h> | ||
|
||
struct phytium_px210_mfd { | ||
struct device *dev; | ||
}; | ||
|
||
struct pdata_px210_mfd { | ||
struct device *dev; | ||
char *name; | ||
int clk_base; | ||
}; | ||
|
||
static struct resource phytium_px210_i2s_res0[] = { | ||
[0] = { | ||
.flags = IORESOURCE_MEM, | ||
}, | ||
[1] = { | ||
.flags = IORESOURCE_MEM, | ||
}, | ||
[2] = { | ||
.flags = IORESOURCE_IRQ, | ||
}, | ||
}; | ||
|
||
static struct mfd_cell phytium_px210_mfd_cells[] = { | ||
{ | ||
.id = 0, | ||
.name = "phytium-i2s", | ||
.of_compatible = "phytium,i2s", | ||
.resources = phytium_px210_i2s_res0, | ||
.num_resources = ARRAY_SIZE(phytium_px210_i2s_res0), | ||
.ignore_resource_conflicts = true, | ||
}, | ||
}; | ||
|
||
static void phytium_px210_i2s_setup(struct pci_dev *pdev) | ||
{ | ||
struct mfd_cell *cell = &phytium_px210_mfd_cells[0]; | ||
struct resource *res = (struct resource *)cell->resources; | ||
struct pdata_px210_mfd *pdata; | ||
|
||
res[0].start = pci_resource_start(pdev, 0); | ||
res[0].end = pci_resource_start(pdev, 0) + 0x0fff; | ||
|
||
res[1].start = pci_resource_start(pdev, 0) + 0x1000; | ||
res[1].end = pci_resource_start(pdev, 0) + 0x1fff; | ||
|
||
res[2].start = pdev->irq; | ||
res[2].end = pdev->irq; | ||
|
||
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
|
||
pdata->dev = &pdev->dev; | ||
pdata->name = "phytium-i2s-lsd"; | ||
pdata->clk_base = 480000000; | ||
|
||
cell->platform_data = pdata; | ||
cell->pdata_size = sizeof(*pdata); | ||
} | ||
|
||
static int phytium_px210_mfd_probe(struct pci_dev *pdev, | ||
const struct pci_device_id *id) | ||
{ | ||
struct phytium_px210_mfd *phytium_mfd; | ||
int ret; | ||
|
||
ret = pcim_enable_device(pdev); | ||
if (ret) | ||
return ret; | ||
|
||
pci_set_master(pdev); | ||
|
||
phytium_mfd = devm_kzalloc(&pdev->dev, sizeof(*phytium_mfd), GFP_KERNEL); | ||
if (!phytium_mfd) | ||
return -ENOMEM; | ||
|
||
phytium_mfd->dev = &pdev->dev; | ||
dev_set_drvdata(&pdev->dev, phytium_mfd); | ||
|
||
phytium_px210_i2s_setup(pdev); | ||
|
||
ret = mfd_add_devices(&pdev->dev, 0, phytium_px210_mfd_cells, | ||
ARRAY_SIZE(phytium_px210_mfd_cells), NULL, 0, | ||
NULL); | ||
if (ret) | ||
return 0; | ||
|
||
return 0; | ||
} | ||
|
||
|
||
static void phytium_px210_mfd_remove(struct pci_dev *pdev) | ||
{ | ||
mfd_remove_devices(&pdev->dev); | ||
} | ||
|
||
static const struct pci_device_id phytium_px210_mfd_ids[] = { | ||
{ | ||
.vendor = 0x1DB7, | ||
.device = 0xDC2B, | ||
.subvendor = PCI_ANY_ID, | ||
.subdevice = PCI_ANY_ID, | ||
.class = 0x3, | ||
.class_mask = 0, | ||
}, | ||
{}, | ||
}; | ||
MODULE_DEVICE_TABLE(pci, phytium_px210_mfd_ids); | ||
|
||
static struct pci_driver phytium_i2s_lsd_mfd_driver = { | ||
.name = "phytium_px210_mfd_i2s", | ||
.id_table = phytium_px210_mfd_ids, | ||
.probe = phytium_px210_mfd_probe, | ||
.remove = phytium_px210_mfd_remove, | ||
}; | ||
|
||
module_pci_driver(phytium_i2s_lsd_mfd_driver); | ||
|
||
MODULE_AUTHOR("Zhang Yiqun <[email protected]>"); | ||
MODULE_DESCRIPTION("Phytium Px210 MFD PCI driver for I2S-LSD"); | ||
MODULE_LICENSE("GPL"); |
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,185 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Phytium I2S MMD MFD driver over PCI bus | ||
* | ||
* Copyright (C) 2020-2023, Phytium Technology Co., Ltd. | ||
*/ | ||
|
||
#include <linux/kernel.h> | ||
#include <linux/module.h> | ||
#include <linux/pci.h> | ||
#include <linux/mfd/core.h> | ||
|
||
struct phytium_px210_mfd { | ||
struct device *dev; | ||
}; | ||
|
||
struct pdata_px210_mfd { | ||
struct device *dev; | ||
char *name; | ||
int clk_base; | ||
}; | ||
|
||
static struct resource phytium_px210_i2s_res0[] = { | ||
[0] = { | ||
.flags = IORESOURCE_MEM, | ||
}, | ||
[1] = { | ||
.flags = IORESOURCE_MEM, | ||
}, | ||
[2] = { | ||
.flags = IORESOURCE_IRQ, | ||
}, | ||
}; | ||
|
||
static struct resource phytium_px210_i2s_res1[] = { | ||
[0] = { | ||
.flags = IORESOURCE_MEM, | ||
}, | ||
[1] = { | ||
.flags = IORESOURCE_MEM, | ||
}, | ||
[2] = { | ||
.flags = IORESOURCE_IRQ, | ||
}, | ||
}; | ||
|
||
static struct resource phytium_px210_i2s_res2[] = { | ||
[0] = { | ||
.flags = IORESOURCE_MEM, | ||
}, | ||
[1] = { | ||
.flags = IORESOURCE_MEM, | ||
}, | ||
[2] = { | ||
.flags = IORESOURCE_IRQ, | ||
}, | ||
}; | ||
|
||
static struct mfd_cell phytium_px210_mfd_cells[] = { | ||
{ | ||
.id = 1, | ||
.name = "phytium-i2s", | ||
.of_compatible = "phytium,i2s", | ||
.resources = phytium_px210_i2s_res0, | ||
.num_resources = ARRAY_SIZE(phytium_px210_i2s_res0), | ||
.ignore_resource_conflicts = true, | ||
}, | ||
{ | ||
.id = 2, | ||
.name = "phytium-i2s", | ||
.of_compatible = "phytium,i2s", | ||
.resources = phytium_px210_i2s_res1, | ||
.num_resources = ARRAY_SIZE(phytium_px210_i2s_res1), | ||
.ignore_resource_conflicts = true, | ||
}, | ||
{ | ||
.id = 3, | ||
.name = "phytium-i2s", | ||
.of_compatible = "phytium,i2s", | ||
.resources = phytium_px210_i2s_res2, | ||
.num_resources = ARRAY_SIZE(phytium_px210_i2s_res2), | ||
.ignore_resource_conflicts = true, | ||
}, | ||
}; | ||
|
||
static void phytium_px210_i2s_setup(struct pci_dev *pdev, int i) | ||
{ | ||
struct mfd_cell *cell = &phytium_px210_mfd_cells[i]; | ||
struct resource *res = (struct resource *)cell->resources; | ||
struct pdata_px210_mfd *pdata; | ||
|
||
res[0].start = pci_resource_start(pdev, 0) + 0x2000 * i + 0x1000; | ||
res[0].end = pci_resource_start(pdev, 0) + 0x2000 * i + 0x1fff; | ||
|
||
res[1].start = pci_resource_start(pdev, 0) + 0x2000 * i; | ||
res[1].end = pci_resource_start(pdev, 0) + 0x2000 * i + 0x0fff; | ||
|
||
res[2].start = pdev->irq; | ||
res[2].end = pdev->irq; | ||
|
||
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
|
||
pdata->dev = &pdev->dev; | ||
pdata->clk_base = 600000000; | ||
switch (i) { | ||
case 0: | ||
pdata->name = "phytium-i2s-dp0"; | ||
break; | ||
case 1: | ||
pdata->name = "phytium-i2s-dp1"; | ||
break; | ||
case 2: | ||
pdata->name = "phytium-i2s-dp2"; | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
cell->platform_data = pdata; | ||
cell->pdata_size = sizeof(*pdata); | ||
} | ||
|
||
static int phytium_px210_mfd_probe(struct pci_dev *pdev, | ||
const struct pci_device_id *id) | ||
{ | ||
struct phytium_px210_mfd *phytium_mfd; | ||
int i; | ||
int ret; | ||
|
||
ret = pcim_enable_device(pdev); | ||
if (ret) | ||
return ret; | ||
|
||
pci_set_master(pdev); | ||
|
||
phytium_mfd = devm_kzalloc(&pdev->dev, sizeof(*phytium_mfd), GFP_KERNEL); | ||
if (!phytium_mfd) | ||
return -ENOMEM; | ||
|
||
phytium_mfd->dev = &pdev->dev; | ||
dev_set_drvdata(&pdev->dev, phytium_mfd); | ||
|
||
for (i = 0; i < 3; i++) | ||
phytium_px210_i2s_setup(pdev, i); | ||
|
||
ret = mfd_add_devices(&pdev->dev, 0, phytium_px210_mfd_cells, | ||
ARRAY_SIZE(phytium_px210_mfd_cells), NULL, 0, | ||
NULL); | ||
if (ret) | ||
return 0; | ||
|
||
return 0; | ||
} | ||
|
||
|
||
static void phytium_px210_mfd_remove(struct pci_dev *pdev) | ||
{ | ||
mfd_remove_devices(&pdev->dev); | ||
} | ||
|
||
static const struct pci_device_id phytium_px210_mfd_ids[] = { | ||
{ | ||
.vendor = 0x1DB7, | ||
.device = 0xDC23, | ||
.subvendor = PCI_ANY_ID, | ||
.subdevice = PCI_ANY_ID, | ||
.class = 0x3, | ||
.class_mask = 0, | ||
}, | ||
{}, | ||
}; | ||
MODULE_DEVICE_TABLE(pci, phytium_px210_mfd_ids); | ||
|
||
static struct pci_driver phytium_i2s_mmd_mfd_driver = { | ||
.name = "phytium_px210_mfd_mmd", | ||
.id_table = phytium_px210_mfd_ids, | ||
.probe = phytium_px210_mfd_probe, | ||
.remove = phytium_px210_mfd_remove, | ||
}; | ||
|
||
module_pci_driver(phytium_i2s_mmd_mfd_driver); | ||
|
||
MODULE_AUTHOR("Zhang Yiqun <[email protected]>"); | ||
MODULE_DESCRIPTION("Phytium Px210 MFD PCI driver for I2S-DP"); | ||
MODULE_LICENSE("GPL"); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个select是不是要去掉 ES8336 X86上也有用?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不能去掉,这是必要的依赖。ES8336 在X86上应该是能用的,但是我们在某一款arm芯片上I2S控制器适配的是ES8336codec芯片。