1*9952f691SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2f64f8808SVince Bridgers /* Altera TSE SGDMA and MSGDMA Linux driver 3f64f8808SVince Bridgers * Copyright (C) 2014 Altera Corporation. All rights reserved 4f64f8808SVince Bridgers */ 5f64f8808SVince Bridgers 6f64f8808SVince Bridgers #ifndef __ALTERA_SGDMAHW_H__ 7f64f8808SVince Bridgers #define __ALTERA_SGDMAHW_H__ 8f64f8808SVince Bridgers 9f64f8808SVince Bridgers /* SGDMA descriptor structure */ 10f64f8808SVince Bridgers struct sgdma_descrip { 1189830580SVince Bridgers u32 raddr; /* address of data to be read */ 1289830580SVince Bridgers u32 pad1; 1389830580SVince Bridgers u32 waddr; 1489830580SVince Bridgers u32 pad2; 1589830580SVince Bridgers u32 next; 1689830580SVince Bridgers u32 pad3; 1789830580SVince Bridgers u16 bytes; 1889830580SVince Bridgers u8 rburst; 1989830580SVince Bridgers u8 wburst; 2089830580SVince Bridgers u16 bytes_xferred; /* 16 bits, bytes xferred */ 21f64f8808SVince Bridgers 22f64f8808SVince Bridgers /* bit 0: error 23f64f8808SVince Bridgers * bit 1: length error 24f64f8808SVince Bridgers * bit 2: crc error 25f64f8808SVince Bridgers * bit 3: truncated error 26f64f8808SVince Bridgers * bit 4: phy error 27f64f8808SVince Bridgers * bit 5: collision error 28f64f8808SVince Bridgers * bit 6: reserved 29f64f8808SVince Bridgers * bit 7: status eop for recv case 30f64f8808SVince Bridgers */ 3189830580SVince Bridgers u8 status; 32f64f8808SVince Bridgers 33f64f8808SVince Bridgers /* bit 0: eop 34f64f8808SVince Bridgers * bit 1: read_fixed 35f64f8808SVince Bridgers * bit 2: write fixed 36f64f8808SVince Bridgers * bits 3,4,5,6: Channel (always 0) 37f64f8808SVince Bridgers * bit 7: hardware owned 38f64f8808SVince Bridgers */ 3989830580SVince Bridgers u8 control; 40f64f8808SVince Bridgers } __packed; 41f64f8808SVince Bridgers 42c3ffe0caSTobias Klauser #define SGDMA_DESC_LEN sizeof(struct sgdma_descrip) 43f64f8808SVince Bridgers 44f64f8808SVince Bridgers #define SGDMA_STATUS_ERR BIT(0) 45f64f8808SVince Bridgers #define SGDMA_STATUS_LENGTH_ERR BIT(1) 46f64f8808SVince Bridgers #define SGDMA_STATUS_CRC_ERR BIT(2) 47f64f8808SVince Bridgers #define SGDMA_STATUS_TRUNC_ERR BIT(3) 48f64f8808SVince Bridgers #define SGDMA_STATUS_PHY_ERR BIT(4) 49f64f8808SVince Bridgers #define SGDMA_STATUS_COLL_ERR BIT(5) 50f64f8808SVince Bridgers #define SGDMA_STATUS_EOP BIT(7) 51f64f8808SVince Bridgers 52f64f8808SVince Bridgers #define SGDMA_CONTROL_EOP BIT(0) 53f64f8808SVince Bridgers #define SGDMA_CONTROL_RD_FIXED BIT(1) 54f64f8808SVince Bridgers #define SGDMA_CONTROL_WR_FIXED BIT(2) 55f64f8808SVince Bridgers 56f64f8808SVince Bridgers /* Channel is always 0, so just zero initialize it */ 57f64f8808SVince Bridgers 58f64f8808SVince Bridgers #define SGDMA_CONTROL_HW_OWNED BIT(7) 59f64f8808SVince Bridgers 60f64f8808SVince Bridgers /* SGDMA register space */ 61f64f8808SVince Bridgers struct sgdma_csr { 62f64f8808SVince Bridgers /* bit 0: error 63f64f8808SVince Bridgers * bit 1: eop 64f64f8808SVince Bridgers * bit 2: descriptor completed 65f64f8808SVince Bridgers * bit 3: chain completed 66f64f8808SVince Bridgers * bit 4: busy 67f64f8808SVince Bridgers * remainder reserved 68f64f8808SVince Bridgers */ 69f64f8808SVince Bridgers u32 status; 70f64f8808SVince Bridgers u32 pad1[3]; 71f64f8808SVince Bridgers 72f64f8808SVince Bridgers /* bit 0: interrupt on error 73f64f8808SVince Bridgers * bit 1: interrupt on eop 74f64f8808SVince Bridgers * bit 2: interrupt after every descriptor 75f64f8808SVince Bridgers * bit 3: interrupt after last descrip in a chain 76f64f8808SVince Bridgers * bit 4: global interrupt enable 77f64f8808SVince Bridgers * bit 5: starts descriptor processing 78f64f8808SVince Bridgers * bit 6: stop core on dma error 79f64f8808SVince Bridgers * bit 7: interrupt on max descriptors 80f64f8808SVince Bridgers * bits 8-15: max descriptors to generate interrupt 81f64f8808SVince Bridgers * bit 16: Software reset 82f64f8808SVince Bridgers * bit 17: clears owned by hardware if 0, does not clear otherwise 83f64f8808SVince Bridgers * bit 18: enables descriptor polling mode 84f64f8808SVince Bridgers * bit 19-26: clocks before polling again 85f64f8808SVince Bridgers * bit 27-30: reserved 86f64f8808SVince Bridgers * bit 31: clear interrupt 87f64f8808SVince Bridgers */ 88f64f8808SVince Bridgers u32 control; 89f64f8808SVince Bridgers u32 pad2[3]; 90f64f8808SVince Bridgers u32 next_descrip; 91f64f8808SVince Bridgers u32 pad3[3]; 92f64f8808SVince Bridgers }; 93f64f8808SVince Bridgers 9489830580SVince Bridgers #define sgdma_csroffs(a) (offsetof(struct sgdma_csr, a)) 9589830580SVince Bridgers #define sgdma_descroffs(a) (offsetof(struct sgdma_descrip, a)) 96f64f8808SVince Bridgers 97f64f8808SVince Bridgers #define SGDMA_STSREG_ERR BIT(0) /* Error */ 98f64f8808SVince Bridgers #define SGDMA_STSREG_EOP BIT(1) /* EOP */ 99f64f8808SVince Bridgers #define SGDMA_STSREG_DESCRIP BIT(2) /* Descriptor completed */ 100f64f8808SVince Bridgers #define SGDMA_STSREG_CHAIN BIT(3) /* Chain completed */ 101f64f8808SVince Bridgers #define SGDMA_STSREG_BUSY BIT(4) /* Controller busy */ 102f64f8808SVince Bridgers 103f64f8808SVince Bridgers #define SGDMA_CTRLREG_IOE BIT(0) /* Interrupt on error */ 104f64f8808SVince Bridgers #define SGDMA_CTRLREG_IOEOP BIT(1) /* Interrupt on EOP */ 105f64f8808SVince Bridgers #define SGDMA_CTRLREG_IDESCRIP BIT(2) /* Interrupt after every descriptor */ 106f64f8808SVince Bridgers #define SGDMA_CTRLREG_ILASTD BIT(3) /* Interrupt after last descriptor */ 107f64f8808SVince Bridgers #define SGDMA_CTRLREG_INTEN BIT(4) /* Global Interrupt enable */ 108f64f8808SVince Bridgers #define SGDMA_CTRLREG_START BIT(5) /* starts descriptor processing */ 109f64f8808SVince Bridgers #define SGDMA_CTRLREG_STOPERR BIT(6) /* stop on dma error */ 110f64f8808SVince Bridgers #define SGDMA_CTRLREG_INTMAX BIT(7) /* Interrupt on max descriptors */ 111f64f8808SVince Bridgers #define SGDMA_CTRLREG_RESET BIT(16)/* Software reset */ 112f64f8808SVince Bridgers #define SGDMA_CTRLREG_COBHW BIT(17)/* Clears owned by hardware */ 113f64f8808SVince Bridgers #define SGDMA_CTRLREG_POLL BIT(18)/* enables descriptor polling mode */ 114f64f8808SVince Bridgers #define SGDMA_CTRLREG_CLRINT BIT(31)/* Clears interrupt */ 115f64f8808SVince Bridgers 116f64f8808SVince Bridgers #endif /* __ALTERA_SGDMAHW_H__ */ 117