162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* Altera TSE SGDMA and MSGDMA Linux driver 362306a36Sopenharmony_ci * Copyright (C) 2014 Altera Corporation. All rights reserved 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#ifndef __ALTERA_SGDMAHW_H__ 762306a36Sopenharmony_ci#define __ALTERA_SGDMAHW_H__ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci/* SGDMA descriptor structure */ 1062306a36Sopenharmony_cistruct sgdma_descrip { 1162306a36Sopenharmony_ci u32 raddr; /* address of data to be read */ 1262306a36Sopenharmony_ci u32 pad1; 1362306a36Sopenharmony_ci u32 waddr; 1462306a36Sopenharmony_ci u32 pad2; 1562306a36Sopenharmony_ci u32 next; 1662306a36Sopenharmony_ci u32 pad3; 1762306a36Sopenharmony_ci u16 bytes; 1862306a36Sopenharmony_ci u8 rburst; 1962306a36Sopenharmony_ci u8 wburst; 2062306a36Sopenharmony_ci u16 bytes_xferred; /* 16 bits, bytes xferred */ 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci /* bit 0: error 2362306a36Sopenharmony_ci * bit 1: length error 2462306a36Sopenharmony_ci * bit 2: crc error 2562306a36Sopenharmony_ci * bit 3: truncated error 2662306a36Sopenharmony_ci * bit 4: phy error 2762306a36Sopenharmony_ci * bit 5: collision error 2862306a36Sopenharmony_ci * bit 6: reserved 2962306a36Sopenharmony_ci * bit 7: status eop for recv case 3062306a36Sopenharmony_ci */ 3162306a36Sopenharmony_ci u8 status; 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci /* bit 0: eop 3462306a36Sopenharmony_ci * bit 1: read_fixed 3562306a36Sopenharmony_ci * bit 2: write fixed 3662306a36Sopenharmony_ci * bits 3,4,5,6: Channel (always 0) 3762306a36Sopenharmony_ci * bit 7: hardware owned 3862306a36Sopenharmony_ci */ 3962306a36Sopenharmony_ci u8 control; 4062306a36Sopenharmony_ci} __packed; 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci#define SGDMA_DESC_LEN sizeof(struct sgdma_descrip) 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci#define SGDMA_STATUS_ERR BIT(0) 4562306a36Sopenharmony_ci#define SGDMA_STATUS_LENGTH_ERR BIT(1) 4662306a36Sopenharmony_ci#define SGDMA_STATUS_CRC_ERR BIT(2) 4762306a36Sopenharmony_ci#define SGDMA_STATUS_TRUNC_ERR BIT(3) 4862306a36Sopenharmony_ci#define SGDMA_STATUS_PHY_ERR BIT(4) 4962306a36Sopenharmony_ci#define SGDMA_STATUS_COLL_ERR BIT(5) 5062306a36Sopenharmony_ci#define SGDMA_STATUS_EOP BIT(7) 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci#define SGDMA_CONTROL_EOP BIT(0) 5362306a36Sopenharmony_ci#define SGDMA_CONTROL_RD_FIXED BIT(1) 5462306a36Sopenharmony_ci#define SGDMA_CONTROL_WR_FIXED BIT(2) 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci/* Channel is always 0, so just zero initialize it */ 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci#define SGDMA_CONTROL_HW_OWNED BIT(7) 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci/* SGDMA register space */ 6162306a36Sopenharmony_cistruct sgdma_csr { 6262306a36Sopenharmony_ci /* bit 0: error 6362306a36Sopenharmony_ci * bit 1: eop 6462306a36Sopenharmony_ci * bit 2: descriptor completed 6562306a36Sopenharmony_ci * bit 3: chain completed 6662306a36Sopenharmony_ci * bit 4: busy 6762306a36Sopenharmony_ci * remainder reserved 6862306a36Sopenharmony_ci */ 6962306a36Sopenharmony_ci u32 status; 7062306a36Sopenharmony_ci u32 pad1[3]; 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci /* bit 0: interrupt on error 7362306a36Sopenharmony_ci * bit 1: interrupt on eop 7462306a36Sopenharmony_ci * bit 2: interrupt after every descriptor 7562306a36Sopenharmony_ci * bit 3: interrupt after last descrip in a chain 7662306a36Sopenharmony_ci * bit 4: global interrupt enable 7762306a36Sopenharmony_ci * bit 5: starts descriptor processing 7862306a36Sopenharmony_ci * bit 6: stop core on dma error 7962306a36Sopenharmony_ci * bit 7: interrupt on max descriptors 8062306a36Sopenharmony_ci * bits 8-15: max descriptors to generate interrupt 8162306a36Sopenharmony_ci * bit 16: Software reset 8262306a36Sopenharmony_ci * bit 17: clears owned by hardware if 0, does not clear otherwise 8362306a36Sopenharmony_ci * bit 18: enables descriptor polling mode 8462306a36Sopenharmony_ci * bit 19-26: clocks before polling again 8562306a36Sopenharmony_ci * bit 27-30: reserved 8662306a36Sopenharmony_ci * bit 31: clear interrupt 8762306a36Sopenharmony_ci */ 8862306a36Sopenharmony_ci u32 control; 8962306a36Sopenharmony_ci u32 pad2[3]; 9062306a36Sopenharmony_ci u32 next_descrip; 9162306a36Sopenharmony_ci u32 pad3[3]; 9262306a36Sopenharmony_ci}; 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci#define sgdma_csroffs(a) (offsetof(struct sgdma_csr, a)) 9562306a36Sopenharmony_ci#define sgdma_descroffs(a) (offsetof(struct sgdma_descrip, a)) 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci#define SGDMA_STSREG_ERR BIT(0) /* Error */ 9862306a36Sopenharmony_ci#define SGDMA_STSREG_EOP BIT(1) /* EOP */ 9962306a36Sopenharmony_ci#define SGDMA_STSREG_DESCRIP BIT(2) /* Descriptor completed */ 10062306a36Sopenharmony_ci#define SGDMA_STSREG_CHAIN BIT(3) /* Chain completed */ 10162306a36Sopenharmony_ci#define SGDMA_STSREG_BUSY BIT(4) /* Controller busy */ 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci#define SGDMA_CTRLREG_IOE BIT(0) /* Interrupt on error */ 10462306a36Sopenharmony_ci#define SGDMA_CTRLREG_IOEOP BIT(1) /* Interrupt on EOP */ 10562306a36Sopenharmony_ci#define SGDMA_CTRLREG_IDESCRIP BIT(2) /* Interrupt after every descriptor */ 10662306a36Sopenharmony_ci#define SGDMA_CTRLREG_ILASTD BIT(3) /* Interrupt after last descriptor */ 10762306a36Sopenharmony_ci#define SGDMA_CTRLREG_INTEN BIT(4) /* Global Interrupt enable */ 10862306a36Sopenharmony_ci#define SGDMA_CTRLREG_START BIT(5) /* starts descriptor processing */ 10962306a36Sopenharmony_ci#define SGDMA_CTRLREG_STOPERR BIT(6) /* stop on dma error */ 11062306a36Sopenharmony_ci#define SGDMA_CTRLREG_INTMAX BIT(7) /* Interrupt on max descriptors */ 11162306a36Sopenharmony_ci#define SGDMA_CTRLREG_RESET BIT(16)/* Software reset */ 11262306a36Sopenharmony_ci#define SGDMA_CTRLREG_COBHW BIT(17)/* Clears owned by hardware */ 11362306a36Sopenharmony_ci#define SGDMA_CTRLREG_POLL BIT(18)/* enables descriptor polling mode */ 11462306a36Sopenharmony_ci#define SGDMA_CTRLREG_CLRINT BIT(31)/* Clears interrupt */ 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci#endif /* __ALTERA_SGDMAHW_H__ */ 117