gpu: host1x-nvhost: Align syncpt interface APIs

The syncpt interface APIs in the host1x-nvhost driver slightly differ
from those in the legacy nvhost driver because instead of passing the
platform device structure for the host1x device, the platform device
structure for the host1x client device is passed.

By aligning the APIs so that we pass the platform device structure for
the host1x in all implementations, we can simplify the PVA driver and
directly use the APIs in the NVIDIA display driver.

The NVIDIA display driver requires some additional syncpt interface APIs
and so implement these as well.

Bug 3713048

Change-Id: I507e6fd066e6e22c0c47c20ba0dd3be5fa033c59
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2813827
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Mahesh Kumar
2022-11-21 20:18:36 +05:30
committed by Laxman Dewangan
parent 7d40c3953e
commit 88028eda4b
2 changed files with 48 additions and 22 deletions

View File

@@ -63,32 +63,43 @@ static const struct of_device_id host1x_match[] = {
{}, {},
}; };
static int nvhost_get_host1x_dev(struct platform_device *pdev) struct platform_device *nvhost_get_default_device(void)
{ {
struct nvhost_device_data *pdata = platform_get_drvdata(pdev);
struct platform_device *host1x_pdev; struct platform_device *host1x_pdev;
struct device_node *np; struct device_node *np;
np = of_find_matching_node(NULL, host1x_match); np = of_find_matching_node(NULL, host1x_match);
if (!np) { if (!np)
dev_err(&pdev->dev, "Failed to find host1x!\n"); return NULL;
return -ENODEV;
}
host1x_pdev = of_find_device_by_node(np); host1x_pdev = of_find_device_by_node(np);
if (!host1x_pdev)
return NULL;
return host1x_pdev;
}
EXPORT_SYMBOL(nvhost_get_default_device);
struct host1x *nvhost_get_host1x(struct platform_device *pdev)
{
struct platform_device *host1x_pdev;
struct host1x *host1x;
host1x_pdev = nvhost_get_default_device();
if (!host1x_pdev) { if (!host1x_pdev) {
dev_dbg(&pdev->dev, "host1x device not available\n"); dev_dbg(&pdev->dev, "host1x device not available\n");
return -EPROBE_DEFER; return NULL;
} }
pdata->host1x = platform_get_drvdata(host1x_pdev); host1x = platform_get_drvdata(host1x_pdev);
if (!pdata->host1x) { if (!host1x) {
dev_warn(&pdev->dev, "No platform data for host1x!\n"); dev_warn(&pdev->dev, "No platform data for host1x!\n");
return -ENODEV; return NULL;
} }
return 0; return host1x;
} }
EXPORT_SYMBOL(nvhost_get_host1x);
static struct device *nvhost_client_device_create(struct platform_device *pdev, static struct device *nvhost_client_device_create(struct platform_device *pdev,
struct cdev *cdev, struct cdev *cdev,
@@ -135,9 +146,11 @@ int nvhost_client_device_get_resources(struct platform_device *pdev)
int err; int err;
u32 i; u32 i;
err = nvhost_get_host1x_dev(pdev); pdata->host1x = nvhost_get_host1x(pdev);
if (err) if (!pdata->host1x) {
return err; dev_warn(&pdev->dev, "No platform data for host1x!\n");
return -ENODEV;
}
for (i = 0; i < pdev->num_resources; i++) { for (i = 0; i < pdev->num_resources; i++) {
void __iomem *regs = NULL; void __iomem *regs = NULL;
@@ -394,21 +407,34 @@ static int nvhost_syncpt_get_page_size(struct device_node *np, uint32_t *size)
u32 nvhost_syncpt_unit_interface_get_byte_offset_ext(struct platform_device *pdev, u32 nvhost_syncpt_unit_interface_get_byte_offset_ext(struct platform_device *pdev,
u32 syncpt_id) u32 syncpt_id)
{ {
struct nvhost_device_data *pdata = platform_get_drvdata(pdev); uint32_t size;
struct nvhost_syncpt_interface *syncpt_if = pdata->syncpt_unit_interface; int err;
if (WARN_ON(!syncpt_if)) err = nvhost_syncpt_get_page_size(pdev->dev.of_node, &size);
if (WARN_ON(err < 0))
return 0; return 0;
return syncpt_id * syncpt_if->page_size; return syncpt_id * size;
} }
EXPORT_SYMBOL(nvhost_syncpt_unit_interface_get_byte_offset_ext); EXPORT_SYMBOL(nvhost_syncpt_unit_interface_get_byte_offset_ext);
u32 nvhost_syncpt_unit_interface_get_byte_offset(u32 syncpt_id)
{
struct platform_device *host1x_pdev;
host1x_pdev = nvhost_get_default_device();
if (WARN_ON(!host1x_pdev))
return 0;
return nvhost_syncpt_unit_interface_get_byte_offset_ext(host1x_pdev,
syncpt_id);
}
EXPORT_SYMBOL(nvhost_syncpt_unit_interface_get_byte_offset);
int nvhost_syncpt_unit_interface_get_aperture(struct platform_device *pdev, int nvhost_syncpt_unit_interface_get_aperture(struct platform_device *pdev,
u64 *base, size_t *size) u64 *base, size_t *size)
{ {
return nvhost_syncpt_get_aperture(pdev->dev.parent->of_node, base, return nvhost_syncpt_get_aperture(pdev->dev.of_node, base, size);
size);
} }
EXPORT_SYMBOL(nvhost_syncpt_unit_interface_get_aperture); EXPORT_SYMBOL(nvhost_syncpt_unit_interface_get_aperture);

View File

@@ -24,13 +24,13 @@ int nvhost_syncpt_unit_interface_get_aperture(
phys_addr_t *base, phys_addr_t *base,
size_t *size); size_t *size);
u32 nvhost_syncpt_unit_interface_get_byte_offset(u32 syncpt_id);
#ifdef CONFIG_TEGRA_HOST1X #ifdef CONFIG_TEGRA_HOST1X
u32 nvhost_syncpt_unit_interface_get_byte_offset_ext( u32 nvhost_syncpt_unit_interface_get_byte_offset_ext(
struct platform_device *host_pdev, struct platform_device *host_pdev,
u32 syncpt_id); u32 syncpt_id);
#else #else
u32 nvhost_syncpt_unit_interface_get_byte_offset(u32 syncpt_id);
static inline u32 nvhost_syncpt_unit_interface_get_byte_offset_ext( static inline u32 nvhost_syncpt_unit_interface_get_byte_offset_ext(
struct platform_device *host_pdev, struct platform_device *host_pdev,
u32 syncpt_id) u32 syncpt_id)