18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Definitions for using the Apple Descriptor-Based DMA controller 48c2ecf20Sopenharmony_ci * in Power Macintosh computers. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 1996 Paul Mackerras. 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 108c2ecf20Sopenharmony_ci#ifndef _ASM_DBDMA_H_ 118c2ecf20Sopenharmony_ci#define _ASM_DBDMA_H_ 128c2ecf20Sopenharmony_ci/* 138c2ecf20Sopenharmony_ci * DBDMA control/status registers. All little-endian. 148c2ecf20Sopenharmony_ci */ 158c2ecf20Sopenharmony_cistruct dbdma_regs { 168c2ecf20Sopenharmony_ci unsigned int control; /* lets you change bits in status */ 178c2ecf20Sopenharmony_ci unsigned int status; /* DMA and device status bits (see below) */ 188c2ecf20Sopenharmony_ci unsigned int cmdptr_hi; /* upper 32 bits of command address */ 198c2ecf20Sopenharmony_ci unsigned int cmdptr; /* (lower 32 bits of) command address (phys) */ 208c2ecf20Sopenharmony_ci unsigned int intr_sel; /* select interrupt condition bit */ 218c2ecf20Sopenharmony_ci unsigned int br_sel; /* select branch condition bit */ 228c2ecf20Sopenharmony_ci unsigned int wait_sel; /* select wait condition bit */ 238c2ecf20Sopenharmony_ci unsigned int xfer_mode; 248c2ecf20Sopenharmony_ci unsigned int data2ptr_hi; 258c2ecf20Sopenharmony_ci unsigned int data2ptr; 268c2ecf20Sopenharmony_ci unsigned int res1; 278c2ecf20Sopenharmony_ci unsigned int address_hi; 288c2ecf20Sopenharmony_ci unsigned int br_addr_hi; 298c2ecf20Sopenharmony_ci unsigned int res2[3]; 308c2ecf20Sopenharmony_ci}; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* Bits in control and status registers */ 338c2ecf20Sopenharmony_ci#define RUN 0x8000 348c2ecf20Sopenharmony_ci#define PAUSE 0x4000 358c2ecf20Sopenharmony_ci#define FLUSH 0x2000 368c2ecf20Sopenharmony_ci#define WAKE 0x1000 378c2ecf20Sopenharmony_ci#define DEAD 0x0800 388c2ecf20Sopenharmony_ci#define ACTIVE 0x0400 398c2ecf20Sopenharmony_ci#define BT 0x0100 408c2ecf20Sopenharmony_ci#define DEVSTAT 0x00ff 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci/* 438c2ecf20Sopenharmony_ci * DBDMA command structure. These fields are all little-endian! 448c2ecf20Sopenharmony_ci */ 458c2ecf20Sopenharmony_cistruct dbdma_cmd { 468c2ecf20Sopenharmony_ci __le16 req_count; /* requested byte transfer count */ 478c2ecf20Sopenharmony_ci __le16 command; /* command word (has bit-fields) */ 488c2ecf20Sopenharmony_ci __le32 phy_addr; /* physical data address */ 498c2ecf20Sopenharmony_ci __le32 cmd_dep; /* command-dependent field */ 508c2ecf20Sopenharmony_ci __le16 res_count; /* residual count after completion */ 518c2ecf20Sopenharmony_ci __le16 xfer_status; /* transfer status */ 528c2ecf20Sopenharmony_ci}; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* DBDMA command values in command field */ 558c2ecf20Sopenharmony_ci#define OUTPUT_MORE 0 /* transfer memory data to stream */ 568c2ecf20Sopenharmony_ci#define OUTPUT_LAST 0x1000 /* ditto followed by end marker */ 578c2ecf20Sopenharmony_ci#define INPUT_MORE 0x2000 /* transfer stream data to memory */ 588c2ecf20Sopenharmony_ci#define INPUT_LAST 0x3000 /* ditto, expect end marker */ 598c2ecf20Sopenharmony_ci#define STORE_WORD 0x4000 /* write word (4 bytes) to device reg */ 608c2ecf20Sopenharmony_ci#define LOAD_WORD 0x5000 /* read word (4 bytes) from device reg */ 618c2ecf20Sopenharmony_ci#define DBDMA_NOP 0x6000 /* do nothing */ 628c2ecf20Sopenharmony_ci#define DBDMA_STOP 0x7000 /* suspend processing */ 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* Key values in command field */ 658c2ecf20Sopenharmony_ci#define KEY_STREAM0 0 /* usual data stream */ 668c2ecf20Sopenharmony_ci#define KEY_STREAM1 0x100 /* control/status stream */ 678c2ecf20Sopenharmony_ci#define KEY_STREAM2 0x200 /* device-dependent stream */ 688c2ecf20Sopenharmony_ci#define KEY_STREAM3 0x300 /* device-dependent stream */ 698c2ecf20Sopenharmony_ci#define KEY_REGS 0x500 /* device register space */ 708c2ecf20Sopenharmony_ci#define KEY_SYSTEM 0x600 /* system memory-mapped space */ 718c2ecf20Sopenharmony_ci#define KEY_DEVICE 0x700 /* device memory-mapped space */ 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci/* Interrupt control values in command field */ 748c2ecf20Sopenharmony_ci#define INTR_NEVER 0 /* don't interrupt */ 758c2ecf20Sopenharmony_ci#define INTR_IFSET 0x10 /* intr if condition bit is 1 */ 768c2ecf20Sopenharmony_ci#define INTR_IFCLR 0x20 /* intr if condition bit is 0 */ 778c2ecf20Sopenharmony_ci#define INTR_ALWAYS 0x30 /* always interrupt */ 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* Branch control values in command field */ 808c2ecf20Sopenharmony_ci#define BR_NEVER 0 /* don't branch */ 818c2ecf20Sopenharmony_ci#define BR_IFSET 0x4 /* branch if condition bit is 1 */ 828c2ecf20Sopenharmony_ci#define BR_IFCLR 0x8 /* branch if condition bit is 0 */ 838c2ecf20Sopenharmony_ci#define BR_ALWAYS 0xc /* always branch */ 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci/* Wait control values in command field */ 868c2ecf20Sopenharmony_ci#define WAIT_NEVER 0 /* don't wait */ 878c2ecf20Sopenharmony_ci#define WAIT_IFSET 1 /* wait if condition bit is 1 */ 888c2ecf20Sopenharmony_ci#define WAIT_IFCLR 2 /* wait if condition bit is 0 */ 898c2ecf20Sopenharmony_ci#define WAIT_ALWAYS 3 /* always wait */ 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* Align an address for a DBDMA command structure */ 928c2ecf20Sopenharmony_ci#define DBDMA_ALIGN(x) (((unsigned long)(x) + sizeof(struct dbdma_cmd) - 1) \ 938c2ecf20Sopenharmony_ci & -sizeof(struct dbdma_cmd)) 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci/* Useful macros */ 968c2ecf20Sopenharmony_ci#define DBDMA_DO_STOP(regs) do { \ 978c2ecf20Sopenharmony_ci out_le32(&((regs)->control), (RUN|FLUSH)<<16); \ 988c2ecf20Sopenharmony_ci while(in_le32(&((regs)->status)) & (ACTIVE|FLUSH)) \ 998c2ecf20Sopenharmony_ci ; \ 1008c2ecf20Sopenharmony_ci} while(0) 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define DBDMA_DO_RESET(regs) do { \ 1038c2ecf20Sopenharmony_ci out_le32(&((regs)->control), (ACTIVE|DEAD|WAKE|FLUSH|PAUSE|RUN)<<16);\ 1048c2ecf20Sopenharmony_ci while(in_le32(&((regs)->status)) & (RUN)) \ 1058c2ecf20Sopenharmony_ci ; \ 1068c2ecf20Sopenharmony_ci} while(0) 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci#endif /* _ASM_DBDMA_H_ */ 1098c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 110