linux/drivers/misc/mic/card/mic_device.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0-only */
   2/*
   3 * Intel MIC Platform Software Stack (MPSS)
   4 *
   5 * Copyright(c) 2013 Intel Corporation.
   6 *
   7 * Disclaimer: The codes contained in these modules may be specific to
   8 * the Intel Software Development Platform codenamed: Knights Ferry, and
   9 * the Intel product codenamed: Knights Corner, and are not backward
  10 * compatible with other Intel products. Additionally, Intel will NOT
  11 * support the codes or instruction set in future products.
  12 *
  13 * Intel MIC Card driver.
  14 */
  15#ifndef _MIC_CARD_DEVICE_H_
  16#define _MIC_CARD_DEVICE_H_
  17
  18#include <linux/workqueue.h>
  19#include <linux/io.h>
  20#include <linux/interrupt.h>
  21#include <linux/mic_bus.h>
  22#include "../bus/scif_bus.h"
  23#include "../bus/vop_bus.h"
  24
  25/**
  26 * struct mic_intr_info - Contains h/w specific interrupt sources info
  27 *
  28 * @num_intr: The number of irqs available
  29 */
  30struct mic_intr_info {
  31        u32 num_intr;
  32};
  33
  34/**
  35 * struct mic_irq_info - OS specific irq information
  36 *
  37 * @irq_usage_count: usage count array tracking the number of sources
  38 * assigned for each irq.
  39 */
  40struct mic_irq_info {
  41        int *irq_usage_count;
  42};
  43
  44/**
  45 * struct mic_device -  MIC device information.
  46 *
  47 * @mmio: MMIO bar information.
  48 */
  49struct mic_device {
  50        struct mic_mw mmio;
  51};
  52
  53/**
  54 * struct mic_driver - MIC card driver information.
  55 *
  56 * @name: Name for MIC driver.
  57 * @dbg_dir: debugfs directory of this MIC device.
  58 * @dev: The device backing this MIC.
  59 * @dp: The pointer to the virtio device page.
  60 * @mdev: MIC device information for the host.
  61 * @hotplug_work: Hot plug work for adding/removing virtio devices.
  62 * @irq_info: The OS specific irq information
  63 * @intr_info: H/W specific interrupt information.
  64 * @dma_mbdev: dma device on the MIC virtual bus.
  65 * @dma_ch - Array of DMA channels
  66 * @num_dma_ch - Number of DMA channels available
  67 * @scdev: SCIF device on the SCIF virtual bus.
  68 * @vpdev: Virtio over PCIe device on the VOP virtual bus.
  69 */
  70struct mic_driver {
  71        char name[20];
  72        struct dentry *dbg_dir;
  73        struct device *dev;
  74        void __iomem *dp;
  75        struct mic_device mdev;
  76        struct work_struct hotplug_work;
  77        struct mic_irq_info irq_info;
  78        struct mic_intr_info intr_info;
  79        struct mbus_device *dma_mbdev;
  80        struct dma_chan *dma_ch[MIC_MAX_DMA_CHAN];
  81        int num_dma_ch;
  82        struct scif_hw_dev *scdev;
  83        struct vop_device *vpdev;
  84};
  85
  86/**
  87 * struct mic_irq - opaque pointer used as cookie
  88 */
  89struct mic_irq;
  90
  91/**
  92 * mic_mmio_read - read from an MMIO register.
  93 * @mw: MMIO register base virtual address.
  94 * @offset: register offset.
  95 *
  96 * RETURNS: register value.
  97 */
  98static inline u32 mic_mmio_read(struct mic_mw *mw, u32 offset)
  99{
 100        return ioread32(mw->va + offset);
 101}
 102
 103/**
 104 * mic_mmio_write - write to an MMIO register.
 105 * @mw: MMIO register base virtual address.
 106 * @val: the data value to put into the register
 107 * @offset: register offset.
 108 *
 109 * RETURNS: none.
 110 */
 111static inline void
 112mic_mmio_write(struct mic_mw *mw, u32 val, u32 offset)
 113{
 114        iowrite32(val, mw->va + offset);
 115}
 116
 117int mic_driver_init(struct mic_driver *mdrv);
 118void mic_driver_uninit(struct mic_driver *mdrv);
 119int mic_next_card_db(void);
 120struct mic_irq *
 121mic_request_card_irq(irq_handler_t handler, irq_handler_t thread_fn,
 122                     const char *name, void *data, int db);
 123void mic_free_card_irq(struct mic_irq *cookie, void *data);
 124u32 mic_read_spad(struct mic_device *mdev, unsigned int idx);
 125void mic_send_intr(struct mic_device *mdev, int doorbell);
 126void mic_send_p2p_intr(int doorbell, struct mic_mw *mw);
 127int mic_db_to_irq(struct mic_driver *mdrv, int db);
 128u32 mic_ack_interrupt(struct mic_device *mdev);
 129void mic_hw_intr_init(struct mic_driver *mdrv);
 130void __iomem *
 131mic_card_map(struct mic_device *mdev, dma_addr_t addr, size_t size);
 132void mic_card_unmap(struct mic_device *mdev, void __iomem *addr);
 133void __init mic_create_card_debug_dir(struct mic_driver *mdrv);
 134void mic_delete_card_debug_dir(struct mic_driver *mdrv);
 135void __init mic_init_card_debugfs(void);
 136void mic_exit_card_debugfs(void);
 137#endif
 138