diff options
Diffstat (limited to 'drivers/gpu/drm/sti/sti_vtg.c')
| -rw-r--r-- | drivers/gpu/drm/sti/sti_vtg.c | 64 |
1 files changed, 20 insertions, 44 deletions
diff --git a/drivers/gpu/drm/sti/sti_vtg.c b/drivers/gpu/drm/sti/sti_vtg.c index 2dcba1d3a122..ce6bc7e7b135 100644 --- a/drivers/gpu/drm/sti/sti_vtg.c +++ b/drivers/gpu/drm/sti/sti_vtg.c @@ -1,17 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) STMicroelectronics SA 2014 * Authors: Benjamin Gaignard <benjamin.gaignard@st.com> * Fabien Dessenne <fabien.dessenne@st.com> * Vincent Abriou <vincent.abriou@st.com> * for STMicroelectronics. - * License terms: GNU General Public License (GPL), version 2 */ #include <linux/module.h> +#include <linux/io.h> #include <linux/notifier.h> +#include <linux/of_platform.h> #include <linux/platform_device.h> -#include <drm/drmP.h> +#include <drm/drm_modes.h> +#include <drm/drm_print.h> #include "sti_drv.h" #include "sti_vtg.h" @@ -72,8 +75,6 @@ #define AWG_DELAY_ED (-8) #define AWG_DELAY_SD (-7) -static LIST_HEAD(vtg_lookup); - /* * STI VTG register offset structure * @@ -120,45 +121,39 @@ struct sti_vtg_sync_params { u32 vsync_off_bot; }; -/** +/* * STI VTG structure * - * @dev: pointer to device driver - * @np: device node * @regs: register mapping * @sync_params: synchronisation parameters used to generate timings * @irq: VTG irq * @irq_status: store the IRQ status value * @notifier_list: notifier callback * @crtc: the CRTC for vblank event - * @link: List node to link the structure in lookup list */ struct sti_vtg { - struct device *dev; - struct device_node *np; void __iomem *regs; struct sti_vtg_sync_params sync_params[VTG_MAX_SYNC_OUTPUT]; int irq; u32 irq_status; struct raw_notifier_head notifier_list; struct drm_crtc *crtc; - struct list_head link; }; -static void vtg_register(struct sti_vtg *vtg) -{ - list_add_tail(&vtg->link, &vtg_lookup); -} - struct sti_vtg *of_vtg_find(struct device_node *np) { + struct platform_device *pdev; struct sti_vtg *vtg; - list_for_each_entry(vtg, &vtg_lookup, link) { - if (vtg->np == np) - return vtg; - } - return NULL; + pdev = of_find_device_by_node(np); + if (!pdev) + return NULL; + + vtg = platform_get_drvdata(pdev); + + put_device(&pdev->dev); + + return vtg; } static void vtg_reset(struct sti_vtg *vtg) @@ -390,26 +385,15 @@ static int vtg_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct sti_vtg *vtg; - struct resource *res; int ret; vtg = devm_kzalloc(dev, sizeof(*vtg), GFP_KERNEL); if (!vtg) return -ENOMEM; - - vtg->dev = dev; - vtg->np = pdev->dev.of_node; - - /* Get Memory ressources */ - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - DRM_ERROR("Get memory resource failed\n"); - return -ENOMEM; - } - vtg->regs = devm_ioremap_nocache(dev, res->start, resource_size(res)); - if (!vtg->regs) { + vtg->regs = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(vtg->regs)) { DRM_ERROR("failed to remap I/O memory\n"); - return -ENOMEM; + return PTR_ERR(vtg->regs); } vtg->irq = platform_get_irq(pdev, 0); @@ -428,19 +412,13 @@ static int vtg_probe(struct platform_device *pdev) return ret; } - vtg_register(vtg); platform_set_drvdata(pdev, vtg); - DRM_INFO("%s %s\n", __func__, dev_name(vtg->dev)); + DRM_INFO("%s %s\n", __func__, dev_name(dev)); return 0; } -static int vtg_remove(struct platform_device *pdev) -{ - return 0; -} - static const struct of_device_id vtg_of_match[] = { { .compatible = "st,vtg", }, { /* sentinel */ } @@ -450,11 +428,9 @@ MODULE_DEVICE_TABLE(of, vtg_of_match); struct platform_driver sti_vtg_driver = { .driver = { .name = "sti-vtg", - .owner = THIS_MODULE, .of_match_table = vtg_of_match, }, .probe = vtg_probe, - .remove = vtg_remove, }; MODULE_AUTHOR("Benjamin Gaignard <benjamin.gaignard@st.com>"); |
