linux/drivers/misc/mic/bus/scif_bus.h
<<
>>
Prefs
   1/*
   2 * Intel MIC Platform Software Stack (MPSS)
   3 *
   4 * Copyright(c) 2014 Intel Corporation.
   5 *
   6 * This program is free software; you can redistribute it and/or modify
   7 * it under the terms of the GNU General Public License, version 2, as
   8 * published by the Free Software Foundation.
   9 *
  10 * This program is distributed in the hope that it will be useful, but
  11 * WITHOUT ANY WARRANTY; without even the implied warranty of
  12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13 * General Public License for more details.
  14 *
  15 * Intel Symmetric Communications Interface Bus driver.
  16 */
  17#ifndef _SCIF_BUS_H_
  18#define _SCIF_BUS_H_
  19/*
  20 * Everything a scif driver needs to work with any particular scif
  21 * hardware abstraction layer.
  22 */
  23#include <linux/dma-mapping.h>
  24
  25#include <linux/mic_common.h>
  26#include "../common/mic_dev.h"
  27
  28struct scif_hw_dev_id {
  29        u32 device;
  30        u32 vendor;
  31};
  32
  33#define MIC_SCIF_DEV 1
  34#define SCIF_DEV_ANY_ID 0xffffffff
  35
  36/**
  37 * scif_hw_dev - representation of a hardware device abstracted for scif
  38 * @hw_ops: the hardware ops supported by this device
  39 * @id: the device type identification (used to match it with a driver)
  40 * @mmio: MMIO memory window
  41 * @aper: Aperture memory window
  42 * @dev: underlying device
  43 * @dnode - The destination node which this device will communicate with.
  44 * @snode - The source node for this device.
  45 * @dp - Self device page
  46 * @rdp - Remote device page
  47 * @dma_ch - Array of DMA channels
  48 * @num_dma_ch - Number of DMA channels available
  49 * @card_rel_da - Set to true if DMA addresses programmed in the DMA engine
  50 *              are relative to the card point of view
  51 */
  52struct scif_hw_dev {
  53        struct scif_hw_ops *hw_ops;
  54        struct scif_hw_dev_id id;
  55        struct mic_mw *mmio;
  56        struct mic_mw *aper;
  57        struct device dev;
  58        u8 dnode;
  59        u8 snode;
  60        void *dp;
  61        void __iomem *rdp;
  62        struct dma_chan **dma_ch;
  63        int num_dma_ch;
  64        bool card_rel_da;
  65};
  66
  67/**
  68 * scif_driver - operations for a scif I/O driver
  69 * @driver: underlying device driver (populate name and owner).
  70 * @id_table: the ids serviced by this driver.
  71 * @probe: the function to call when a device is found.  Returns 0 or -errno.
  72 * @remove: the function to call when a device is removed.
  73 */
  74struct scif_driver {
  75        struct device_driver driver;
  76        const struct scif_hw_dev_id *id_table;
  77        int (*probe)(struct scif_hw_dev *dev);
  78        void (*remove)(struct scif_hw_dev *dev);
  79};
  80
  81/**
  82 * scif_hw_ops - Hardware operations for accessing a SCIF device on the SCIF bus.
  83 *
  84 * @next_db: Obtain the next available doorbell.
  85 * @request_irq: Request an interrupt on a particular doorbell.
  86 * @free_irq: Free an interrupt requested previously.
  87 * @ack_interrupt: acknowledge an interrupt in the ISR.
  88 * @send_intr: Send an interrupt to the remote node on a specified doorbell.
  89 * @send_p2p_intr: Send an interrupt to the peer node on a specified doorbell
  90 * which is specifically targeted for a peer to peer node.
  91 * @ioremap: Map a buffer with the specified physical address and length.
  92 * @iounmap: Unmap a buffer previously mapped.
  93 */
  94struct scif_hw_ops {
  95        int (*next_db)(struct scif_hw_dev *sdev);
  96        struct mic_irq * (*request_irq)(struct scif_hw_dev *sdev,
  97                                        irqreturn_t (*func)(int irq,
  98                                                            void *data),
  99                                        const char *name, void *data,
 100                                        int db);
 101        void (*free_irq)(struct scif_hw_dev *sdev,
 102                         struct mic_irq *cookie, void *data);
 103        void (*ack_interrupt)(struct scif_hw_dev *sdev, int num);
 104        void (*send_intr)(struct scif_hw_dev *sdev, int db);
 105        void (*send_p2p_intr)(struct scif_hw_dev *sdev, int db,
 106                              struct mic_mw *mw);
 107        void __iomem * (*ioremap)(struct scif_hw_dev *sdev,
 108                                  phys_addr_t pa, size_t len);
 109        void (*iounmap)(struct scif_hw_dev *sdev, void __iomem *va);
 110};
 111
 112int scif_register_driver(struct scif_driver *driver);
 113void scif_unregister_driver(struct scif_driver *driver);
 114struct scif_hw_dev *
 115scif_register_device(struct device *pdev, int id,
 116                     const struct dma_map_ops *dma_ops,
 117                     struct scif_hw_ops *hw_ops, u8 dnode, u8 snode,
 118                     struct mic_mw *mmio, struct mic_mw *aper,
 119                     void *dp, void __iomem *rdp,
 120                     struct dma_chan **chan, int num_chan,
 121                     bool card_rel_da);
 122void scif_unregister_device(struct scif_hw_dev *sdev);
 123
 124static inline struct scif_hw_dev *dev_to_scif(struct device *dev)
 125{
 126        return container_of(dev, struct scif_hw_dev, dev);
 127}
 128
 129static inline struct scif_driver *drv_to_scif(struct device_driver *drv)
 130{
 131        return container_of(drv, struct scif_driver, driver);
 132}
 133#endif /* _SCIF_BUS_H */
 134