cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

vme_vmivme7805.c (2504B)


      1// SPDX-License-Identifier: GPL-2.0-or-later
      2/*
      3 * Support for the VMIVME-7805 board access to the Universe II bridge.
      4 *
      5 * Author: Arthur Benilov <arthur.benilov@iba-group.com>
      6 * Copyright 2010 Ion Beam Application, Inc.
      7 */
      8
      9#include <linux/module.h>
     10#include <linux/types.h>
     11#include <linux/errno.h>
     12#include <linux/pci.h>
     13#include <linux/poll.h>
     14#include <linux/io.h>
     15
     16#include "vme_vmivme7805.h"
     17
     18static int vmic_probe(struct pci_dev *, const struct pci_device_id *);
     19static void vmic_remove(struct pci_dev *);
     20
     21/** Base address to access FPGA register */
     22static void __iomem *vmic_base;
     23
     24static const char driver_name[] = "vmivme_7805";
     25
     26static const struct pci_device_id vmic_ids[] = {
     27	{ PCI_DEVICE(PCI_VENDOR_ID_VMIC, PCI_DEVICE_ID_VTIMR) },
     28	{ },
     29};
     30
     31static struct pci_driver vmic_driver = {
     32	.name = driver_name,
     33	.id_table = vmic_ids,
     34	.probe = vmic_probe,
     35	.remove = vmic_remove,
     36};
     37
     38static int vmic_probe(struct pci_dev *pdev, const struct pci_device_id *id)
     39{
     40	int retval;
     41	u32 data;
     42
     43	/* Enable the device */
     44	retval = pci_enable_device(pdev);
     45	if (retval) {
     46		dev_err(&pdev->dev, "Unable to enable device\n");
     47		goto err;
     48	}
     49
     50	/* Map Registers */
     51	retval = pci_request_regions(pdev, driver_name);
     52	if (retval) {
     53		dev_err(&pdev->dev, "Unable to reserve resources\n");
     54		goto err_resource;
     55	}
     56
     57	/* Map registers in BAR 0 */
     58	vmic_base = ioremap(pci_resource_start(pdev, 0), 16);
     59	if (!vmic_base) {
     60		dev_err(&pdev->dev, "Unable to remap CRG region\n");
     61		retval = -EIO;
     62		goto err_remap;
     63	}
     64
     65	/* Clear the FPGA VME IF contents */
     66	iowrite32(0, vmic_base + VME_CONTROL);
     67
     68	/* Clear any initial BERR  */
     69	data = ioread32(vmic_base + VME_CONTROL) & 0x00000FFF;
     70	data |= BM_VME_CONTROL_BERRST;
     71	iowrite32(data, vmic_base + VME_CONTROL);
     72
     73	/* Enable the vme interface and byte swapping */
     74	data = ioread32(vmic_base + VME_CONTROL) & 0x00000FFF;
     75	data = data | BM_VME_CONTROL_MASTER_ENDIAN |
     76			BM_VME_CONTROL_SLAVE_ENDIAN |
     77			BM_VME_CONTROL_ABLE |
     78			BM_VME_CONTROL_BERRI |
     79			BM_VME_CONTROL_BPENA |
     80			BM_VME_CONTROL_VBENA;
     81	iowrite32(data, vmic_base + VME_CONTROL);
     82
     83	return 0;
     84
     85err_remap:
     86	pci_release_regions(pdev);
     87err_resource:
     88	pci_disable_device(pdev);
     89err:
     90	return retval;
     91}
     92
     93static void vmic_remove(struct pci_dev *pdev)
     94{
     95	iounmap(vmic_base);
     96	pci_release_regions(pdev);
     97	pci_disable_device(pdev);
     98
     99}
    100
    101module_pci_driver(vmic_driver);
    102
    103MODULE_DESCRIPTION("VMIVME-7805 board support driver");
    104MODULE_AUTHOR("Arthur Benilov <arthur.benilov@iba-group.com>");
    105MODULE_LICENSE("GPL");
    106