hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/video/fbdev/via/via-core.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved.
34 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
....@@ -220,49 +221,6 @@
220221 }
221222 EXPORT_SYMBOL_GPL(viafb_release_dma);
222223
223
-
224
-#if 0
225
-/*
226
- * Copy a single buffer from FB memory, synchronously. This code works
227
- * but is not currently used.
228
- */
229
-void viafb_dma_copy_out(unsigned int offset, dma_addr_t paddr, int len)
230
-{
231
- unsigned long flags;
232
- int csr;
233
-
234
- mutex_lock(&viafb_dma_lock);
235
- init_completion(&viafb_dma_completion);
236
- /*
237
- * Program the controller.
238
- */
239
- spin_lock_irqsave(&global_dev.reg_lock, flags);
240
- viafb_mmio_write(VDMA_CSR0, VDMA_C_ENABLE|VDMA_C_DONE);
241
- /* Enable ints; must happen after CSR0 write! */
242
- viafb_mmio_write(VDMA_MR0, VDMA_MR_TDIE);
243
- viafb_mmio_write(VDMA_MARL0, (int) (paddr & 0xfffffff0));
244
- viafb_mmio_write(VDMA_MARH0, (int) ((paddr >> 28) & 0xfff));
245
- /* Data sheet suggests DAR0 should be <<4, but it lies */
246
- viafb_mmio_write(VDMA_DAR0, offset);
247
- viafb_mmio_write(VDMA_DQWCR0, len >> 4);
248
- viafb_mmio_write(VDMA_TMR0, 0);
249
- viafb_mmio_write(VDMA_DPRL0, 0);
250
- viafb_mmio_write(VDMA_DPRH0, 0);
251
- viafb_mmio_write(VDMA_PMR0, 0);
252
- csr = viafb_mmio_read(VDMA_CSR0);
253
- viafb_mmio_write(VDMA_CSR0, VDMA_C_ENABLE|VDMA_C_START);
254
- spin_unlock_irqrestore(&global_dev.reg_lock, flags);
255
- /*
256
- * Now we just wait until the interrupt handler says
257
- * we're done.
258
- */
259
- wait_for_completion_interruptible(&viafb_dma_completion);
260
- viafb_mmio_write(VDMA_MR0, 0); /* Reset int enable */
261
- mutex_unlock(&viafb_dma_lock);
262
-}
263
-EXPORT_SYMBOL_GPL(viafb_dma_copy_out);
264
-#endif
265
-
266224 /*
267225 * Do a scatter/gather DMA copy from FB memory. You must have done
268226 * a successful call to viafb_request_dma() first.
....@@ -484,7 +442,7 @@
484442 */
485443 vdev->engine_start = pci_resource_start(vdev->pdev, 1);
486444 vdev->engine_len = pci_resource_len(vdev->pdev, 1);
487
- vdev->engine_mmio = ioremap_nocache(vdev->engine_start,
445
+ vdev->engine_mmio = ioremap(vdev->engine_start,
488446 vdev->engine_len);
489447 if (vdev->engine_mmio == NULL)
490448 dev_err(&vdev->pdev->dev,
....@@ -600,9 +558,8 @@
600558 /*
601559 * Power management functions
602560 */
603
-#ifdef CONFIG_PM
604
-static LIST_HEAD(viafb_pm_hooks);
605
-static DEFINE_MUTEX(viafb_pm_hooks_lock);
561
+static __maybe_unused LIST_HEAD(viafb_pm_hooks);
562
+static __maybe_unused DEFINE_MUTEX(viafb_pm_hooks_lock);
606563
607564 void viafb_pm_register(struct viafb_pm_hooks *hooks)
608565 {
....@@ -622,12 +579,10 @@
622579 }
623580 EXPORT_SYMBOL_GPL(viafb_pm_unregister);
624581
625
-static int via_suspend(struct pci_dev *pdev, pm_message_t state)
582
+static int __maybe_unused via_suspend(struct device *dev)
626583 {
627584 struct viafb_pm_hooks *hooks;
628585
629
- if (state.event != PM_EVENT_SUSPEND)
630
- return 0;
631586 /*
632587 * "I've occasionally hit a few drivers that caused suspend
633588 * failures, and each and every time it was a driver bug, and
....@@ -642,23 +597,12 @@
642597 hooks->suspend(hooks->private);
643598 mutex_unlock(&viafb_pm_hooks_lock);
644599
645
- pci_save_state(pdev);
646
- pci_disable_device(pdev);
647
- pci_set_power_state(pdev, pci_choose_state(pdev, state));
648600 return 0;
649601 }
650602
651
-static int via_resume(struct pci_dev *pdev)
603
+static int __maybe_unused via_resume(struct device *dev)
652604 {
653605 struct viafb_pm_hooks *hooks;
654
-
655
- /* Get the bus side powered up */
656
- pci_set_power_state(pdev, PCI_D0);
657
- pci_restore_state(pdev);
658
- if (pci_enable_device(pdev))
659
- return 0;
660
-
661
- pci_set_master(pdev);
662606
663607 /* Now bring back any subdevs */
664608 mutex_lock(&viafb_pm_hooks_lock);
....@@ -668,7 +612,6 @@
668612
669613 return 0;
670614 }
671
-#endif /* CONFIG_PM */
672615
673616 static int via_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
674617 {
....@@ -754,15 +697,23 @@
754697 };
755698 MODULE_DEVICE_TABLE(pci, via_pci_table);
756699
700
+static const struct dev_pm_ops via_pm_ops = {
701
+#ifdef CONFIG_PM_SLEEP
702
+ .suspend = via_suspend,
703
+ .resume = via_resume,
704
+ .freeze = NULL,
705
+ .thaw = via_resume,
706
+ .poweroff = NULL,
707
+ .restore = via_resume,
708
+#endif
709
+};
710
+
757711 static struct pci_driver via_driver = {
758712 .name = "viafb",
759713 .id_table = via_pci_table,
760714 .probe = via_pci_probe,
761715 .remove = via_pci_remove,
762
-#ifdef CONFIG_PM
763
- .suspend = via_suspend,
764
- .resume = via_resume,
765
-#endif
716
+ .driver.pm = &via_pm_ops,
766717 };
767718
768719 static int __init via_core_init(void)