Home | History | Annotate | Line # | Download | only in via
      1  1.5  riastrad /*	$NetBSD: via_dmablit.h,v 1.5 2021/12/19 12:30:23 riastradh Exp $	*/
      2  1.3  riastrad 
      3  1.1  riastrad /* via_dmablit.h -- PCI DMA BitBlt support for the VIA Unichrome/Pro
      4  1.1  riastrad  *
      5  1.1  riastrad  * Copyright 2005 Thomas Hellstrom.
      6  1.1  riastrad  * All Rights Reserved.
      7  1.1  riastrad  *
      8  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
      9  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
     10  1.1  riastrad  * to deal in the Software without restriction, including without limitation
     11  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sub license,
     12  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     13  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     14  1.1  riastrad  *
     15  1.1  riastrad  * The above copyright notice and this permission notice (including the
     16  1.1  riastrad  * next paragraph) shall be included in all copies or substantial portions
     17  1.1  riastrad  * of the Software.
     18  1.1  riastrad  *
     19  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     20  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     21  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
     22  1.1  riastrad  * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
     23  1.1  riastrad  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
     24  1.1  riastrad  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
     25  1.1  riastrad  * USE OR OTHER DEALINGS IN THE SOFTWARE.
     26  1.1  riastrad  *
     27  1.1  riastrad  * Authors:
     28  1.1  riastrad  *    Thomas Hellstrom.
     29  1.1  riastrad  *    Register info from Digeo Inc.
     30  1.1  riastrad  */
     31  1.1  riastrad 
     32  1.1  riastrad #ifndef _VIA_DMABLIT_H
     33  1.1  riastrad #define _VIA_DMABLIT_H
     34  1.1  riastrad 
     35  1.1  riastrad #include <linux/dma-mapping.h>
     36  1.5  riastrad #include <linux/workqueue.h>
     37  1.5  riastrad 
     38  1.5  riastrad #include <drm/drm_wait_netbsd.h>
     39  1.1  riastrad 
     40  1.1  riastrad #define VIA_NUM_BLIT_ENGINES 2
     41  1.1  riastrad #define VIA_NUM_BLIT_SLOTS 8
     42  1.1  riastrad 
     43  1.1  riastrad struct _drm_via_descriptor;
     44  1.1  riastrad 
     45  1.1  riastrad typedef struct _drm_via_sg_info {
     46  1.2  riastrad #ifdef __NetBSD__
     47  1.2  riastrad 	bus_dmamap_t dmamap;
     48  1.2  riastrad #else
     49  1.1  riastrad 	struct page **pages;
     50  1.2  riastrad #endif
     51  1.1  riastrad 	unsigned long num_pages;
     52  1.2  riastrad #ifdef __NetBSD__
     53  1.2  riastrad 	bus_dma_segment_t *desc_segs;
     54  1.2  riastrad 	int num_desc_segs;
     55  1.2  riastrad 	void *desc_kva;
     56  1.2  riastrad 	bus_dmamap_t desc_dmamap;
     57  1.2  riastrad #endif
     58  1.1  riastrad 	struct _drm_via_descriptor **desc_pages;
     59  1.1  riastrad 	int num_desc_pages;
     60  1.1  riastrad 	int num_desc;
     61  1.1  riastrad 	enum dma_data_direction direction;
     62  1.1  riastrad 	dma_addr_t chain_start;
     63  1.1  riastrad 	uint32_t free_on_sequence;
     64  1.1  riastrad 	unsigned int descriptors_per_page;
     65  1.1  riastrad 	int aborted;
     66  1.1  riastrad 	enum {
     67  1.1  riastrad 		dr_via_device_mapped,
     68  1.1  riastrad 		dr_via_desc_pages_alloc,
     69  1.1  riastrad 		dr_via_pages_locked,
     70  1.1  riastrad 		dr_via_pages_alloc,
     71  1.1  riastrad 		dr_via_sg_init
     72  1.1  riastrad 	} state;
     73  1.1  riastrad } drm_via_sg_info_t;
     74  1.1  riastrad 
     75  1.1  riastrad typedef struct _drm_via_blitq {
     76  1.1  riastrad 	struct drm_device *dev;
     77  1.1  riastrad 	uint32_t cur_blit_handle;
     78  1.1  riastrad 	uint32_t done_blit_handle;
     79  1.1  riastrad 	unsigned serviced;
     80  1.1  riastrad 	unsigned head;
     81  1.1  riastrad 	unsigned cur;
     82  1.1  riastrad 	unsigned num_free;
     83  1.1  riastrad 	unsigned num_outstanding;
     84  1.1  riastrad 	unsigned long end;
     85  1.1  riastrad 	int aborting;
     86  1.1  riastrad 	int is_active;
     87  1.1  riastrad 	drm_via_sg_info_t *blits[VIA_NUM_BLIT_SLOTS];
     88  1.1  riastrad 	spinlock_t blit_lock;
     89  1.2  riastrad #ifdef __NetBSD__
     90  1.2  riastrad 	drm_waitqueue_t blit_queue[VIA_NUM_BLIT_SLOTS];
     91  1.2  riastrad 	drm_waitqueue_t busy_queue;
     92  1.2  riastrad #else
     93  1.1  riastrad 	wait_queue_head_t blit_queue[VIA_NUM_BLIT_SLOTS];
     94  1.1  riastrad 	wait_queue_head_t busy_queue;
     95  1.2  riastrad #endif
     96  1.1  riastrad 	struct work_struct wq;
     97  1.1  riastrad 	struct timer_list poll_timer;
     98  1.1  riastrad } drm_via_blitq_t;
     99  1.1  riastrad 
    100  1.1  riastrad 
    101  1.1  riastrad /*
    102  1.1  riastrad  *  PCI DMA Registers
    103  1.1  riastrad  *  Channels 2 & 3 don't seem to be implemented in hardware.
    104  1.1  riastrad  */
    105  1.1  riastrad 
    106  1.1  riastrad #define VIA_PCI_DMA_MAR0            0xE40   /* Memory Address Register of Channel 0 */
    107  1.1  riastrad #define VIA_PCI_DMA_DAR0            0xE44   /* Device Address Register of Channel 0 */
    108  1.1  riastrad #define VIA_PCI_DMA_BCR0            0xE48   /* Byte Count Register of Channel 0 */
    109  1.1  riastrad #define VIA_PCI_DMA_DPR0            0xE4C   /* Descriptor Pointer Register of Channel 0 */
    110  1.1  riastrad 
    111  1.1  riastrad #define VIA_PCI_DMA_MAR1            0xE50   /* Memory Address Register of Channel 1 */
    112  1.1  riastrad #define VIA_PCI_DMA_DAR1            0xE54   /* Device Address Register of Channel 1 */
    113  1.1  riastrad #define VIA_PCI_DMA_BCR1            0xE58   /* Byte Count Register of Channel 1 */
    114  1.1  riastrad #define VIA_PCI_DMA_DPR1            0xE5C   /* Descriptor Pointer Register of Channel 1 */
    115  1.1  riastrad 
    116  1.1  riastrad #define VIA_PCI_DMA_MAR2            0xE60   /* Memory Address Register of Channel 2 */
    117  1.1  riastrad #define VIA_PCI_DMA_DAR2            0xE64   /* Device Address Register of Channel 2 */
    118  1.1  riastrad #define VIA_PCI_DMA_BCR2            0xE68   /* Byte Count Register of Channel 2 */
    119  1.1  riastrad #define VIA_PCI_DMA_DPR2            0xE6C   /* Descriptor Pointer Register of Channel 2 */
    120  1.1  riastrad 
    121  1.1  riastrad #define VIA_PCI_DMA_MAR3            0xE70   /* Memory Address Register of Channel 3 */
    122  1.1  riastrad #define VIA_PCI_DMA_DAR3            0xE74   /* Device Address Register of Channel 3 */
    123  1.1  riastrad #define VIA_PCI_DMA_BCR3            0xE78   /* Byte Count Register of Channel 3 */
    124  1.1  riastrad #define VIA_PCI_DMA_DPR3            0xE7C   /* Descriptor Pointer Register of Channel 3 */
    125  1.1  riastrad 
    126  1.1  riastrad #define VIA_PCI_DMA_MR0             0xE80   /* Mode Register of Channel 0 */
    127  1.1  riastrad #define VIA_PCI_DMA_MR1             0xE84   /* Mode Register of Channel 1 */
    128  1.1  riastrad #define VIA_PCI_DMA_MR2             0xE88   /* Mode Register of Channel 2 */
    129  1.1  riastrad #define VIA_PCI_DMA_MR3             0xE8C   /* Mode Register of Channel 3 */
    130  1.1  riastrad 
    131  1.1  riastrad #define VIA_PCI_DMA_CSR0            0xE90   /* Command/Status Register of Channel 0 */
    132  1.1  riastrad #define VIA_PCI_DMA_CSR1            0xE94   /* Command/Status Register of Channel 1 */
    133  1.1  riastrad #define VIA_PCI_DMA_CSR2            0xE98   /* Command/Status Register of Channel 2 */
    134  1.1  riastrad #define VIA_PCI_DMA_CSR3            0xE9C   /* Command/Status Register of Channel 3 */
    135  1.1  riastrad 
    136  1.1  riastrad #define VIA_PCI_DMA_PTR             0xEA0   /* Priority Type Register */
    137  1.1  riastrad 
    138  1.1  riastrad /* Define for DMA engine */
    139  1.1  riastrad /* DPR */
    140  1.1  riastrad #define VIA_DMA_DPR_EC		(1<<1)	/* end of chain */
    141  1.1  riastrad #define VIA_DMA_DPR_DDIE	(1<<2)	/* descriptor done interrupt enable */
    142  1.1  riastrad #define VIA_DMA_DPR_DT		(1<<3)	/* direction of transfer (RO) */
    143  1.1  riastrad 
    144  1.1  riastrad /* MR */
    145  1.1  riastrad #define VIA_DMA_MR_CM		(1<<0)	/* chaining mode */
    146  1.1  riastrad #define VIA_DMA_MR_TDIE		(1<<1)	/* transfer done interrupt enable */
    147  1.1  riastrad #define VIA_DMA_MR_HENDMACMD		(1<<7) /* ? */
    148  1.1  riastrad 
    149  1.1  riastrad /* CSR */
    150  1.1  riastrad #define VIA_DMA_CSR_DE		(1<<0)	/* DMA enable */
    151  1.1  riastrad #define VIA_DMA_CSR_TS		(1<<1)	/* transfer start */
    152  1.1  riastrad #define VIA_DMA_CSR_TA		(1<<2)	/* transfer abort */
    153  1.1  riastrad #define VIA_DMA_CSR_TD		(1<<3)	/* transfer done */
    154  1.1  riastrad #define VIA_DMA_CSR_DD		(1<<4)	/* descriptor done */
    155  1.1  riastrad #define VIA_DMA_DPR_EC          (1<<1)  /* end of chain */
    156  1.1  riastrad 
    157  1.1  riastrad 
    158  1.1  riastrad 
    159  1.1  riastrad #endif
    160