Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /* include/linux/amba/pl080.h
0003  *
0004  * Copyright 2008 Openmoko, Inc.
0005  * Copyright 2008 Simtec Electronics
0006  *      http://armlinux.simtec.co.uk/
0007  *      Ben Dooks <ben@simtec.co.uk>
0008  *
0009  * ARM PrimeCell PL080 DMA controller
0010 */
0011 
0012 /* Note, there are some Samsung updates to this controller block which
0013  * make it not entierly compatible with the PL080 specification from
0014  * ARM. When in doubt, check the Samsung documentation first.
0015  *
0016  * The Samsung defines are PL080S, and add an extra control register,
0017  * the ability to move more than 2^11 counts of data and some extra
0018  * OneNAND features.
0019 */
0020 
0021 #ifndef ASM_PL080_H
0022 #define ASM_PL080_H
0023 
0024 #define PL080_INT_STATUS            (0x00)
0025 #define PL080_TC_STATUS             (0x04)
0026 #define PL080_TC_CLEAR              (0x08)
0027 #define PL080_ERR_STATUS            (0x0C)
0028 #define PL080_ERR_CLEAR             (0x10)
0029 #define PL080_RAW_TC_STATUS         (0x14)
0030 #define PL080_RAW_ERR_STATUS            (0x18)
0031 #define PL080_EN_CHAN               (0x1c)
0032 #define PL080_SOFT_BREQ             (0x20)
0033 #define PL080_SOFT_SREQ             (0x24)
0034 #define PL080_SOFT_LBREQ            (0x28)
0035 #define PL080_SOFT_LSREQ            (0x2C)
0036 
0037 #define PL080_CONFIG                (0x30)
0038 #define PL080_CONFIG_M2_BE          BIT(2)
0039 #define PL080_CONFIG_M1_BE          BIT(1)
0040 #define PL080_CONFIG_ENABLE         BIT(0)
0041 
0042 #define PL080_SYNC              (0x34)
0043 
0044 /* The Faraday Technology FTDMAC020 variant registers */
0045 #define FTDMAC020_CH_BUSY           (0x20)
0046 /* Identical to PL080_CONFIG */
0047 #define FTDMAC020_CSR               (0x24)
0048 /* Identical to PL080_SYNC */
0049 #define FTDMAC020_SYNC              (0x2C)
0050 #define FTDMAC020_REVISION          (0x30)
0051 #define FTDMAC020_FEATURE           (0x34)
0052 
0053 /* Per channel configuration registers */
0054 #define PL080_Cx_BASE(x)            ((0x100 + (x * 0x20)))
0055 #define PL080_CH_SRC_ADDR           (0x00)
0056 #define PL080_CH_DST_ADDR           (0x04)
0057 #define PL080_CH_LLI                (0x08)
0058 #define PL080_CH_CONTROL            (0x0C)
0059 #define PL080_CH_CONFIG             (0x10)
0060 #define PL080S_CH_CONTROL2          (0x10)
0061 #define PL080S_CH_CONFIG            (0x14)
0062 /* The Faraday FTDMAC020 derivative shuffles the registers around */
0063 #define FTDMAC020_CH_CSR            (0x00)
0064 #define FTDMAC020_CH_CFG            (0x04)
0065 #define FTDMAC020_CH_SRC_ADDR           (0x08)
0066 #define FTDMAC020_CH_DST_ADDR           (0x0C)
0067 #define FTDMAC020_CH_LLP            (0x10)
0068 #define FTDMAC020_CH_SIZE           (0x14)
0069 
0070 #define PL080_LLI_ADDR_MASK         GENMASK(31, 2)
0071 #define PL080_LLI_ADDR_SHIFT            (2)
0072 #define PL080_LLI_LM_AHB2           BIT(0)
0073 
0074 #define PL080_CONTROL_TC_IRQ_EN         BIT(31)
0075 #define PL080_CONTROL_PROT_MASK         GENMASK(30, 28)
0076 #define PL080_CONTROL_PROT_SHIFT        (28)
0077 #define PL080_CONTROL_PROT_CACHE        BIT(30)
0078 #define PL080_CONTROL_PROT_BUFF         BIT(29)
0079 #define PL080_CONTROL_PROT_SYS          BIT(28)
0080 #define PL080_CONTROL_DST_INCR          BIT(27)
0081 #define PL080_CONTROL_SRC_INCR          BIT(26)
0082 #define PL080_CONTROL_DST_AHB2          BIT(25)
0083 #define PL080_CONTROL_SRC_AHB2          BIT(24)
0084 #define PL080_CONTROL_DWIDTH_MASK       GENMASK(23, 21)
0085 #define PL080_CONTROL_DWIDTH_SHIFT      (21)
0086 #define PL080_CONTROL_SWIDTH_MASK       GENMASK(20, 18)
0087 #define PL080_CONTROL_SWIDTH_SHIFT      (18)
0088 #define PL080_CONTROL_DB_SIZE_MASK      GENMASK(17, 15)
0089 #define PL080_CONTROL_DB_SIZE_SHIFT     (15)
0090 #define PL080_CONTROL_SB_SIZE_MASK      GENMASK(14, 12)
0091 #define PL080_CONTROL_SB_SIZE_SHIFT     (12)
0092 #define PL080_CONTROL_TRANSFER_SIZE_MASK    GENMASK(11, 0)
0093 #define PL080S_CONTROL_TRANSFER_SIZE_MASK   GENMASK(24, 0)
0094 #define PL080_CONTROL_TRANSFER_SIZE_SHIFT   (0)
0095 
0096 #define PL080_BSIZE_1               (0x0)
0097 #define PL080_BSIZE_4               (0x1)
0098 #define PL080_BSIZE_8               (0x2)
0099 #define PL080_BSIZE_16              (0x3)
0100 #define PL080_BSIZE_32              (0x4)
0101 #define PL080_BSIZE_64              (0x5)
0102 #define PL080_BSIZE_128             (0x6)
0103 #define PL080_BSIZE_256             (0x7)
0104 
0105 #define PL080_WIDTH_8BIT            (0x0)
0106 #define PL080_WIDTH_16BIT           (0x1)
0107 #define PL080_WIDTH_32BIT           (0x2)
0108 
0109 #define PL080N_CONFIG_ITPROT            BIT(20)
0110 #define PL080N_CONFIG_SECPROT           BIT(19)
0111 #define PL080_CONFIG_HALT           BIT(18)
0112 #define PL080_CONFIG_ACTIVE         BIT(17)  /* RO */
0113 #define PL080_CONFIG_LOCK           BIT(16)
0114 #define PL080_CONFIG_TC_IRQ_MASK        BIT(15)
0115 #define PL080_CONFIG_ERR_IRQ_MASK       BIT(14)
0116 #define PL080_CONFIG_FLOW_CONTROL_MASK      GENMASK(13, 11)
0117 #define PL080_CONFIG_FLOW_CONTROL_SHIFT     (11)
0118 #define PL080_CONFIG_DST_SEL_MASK       GENMASK(9, 6)
0119 #define PL080_CONFIG_DST_SEL_SHIFT      (6)
0120 #define PL080_CONFIG_SRC_SEL_MASK       GENMASK(4, 1)
0121 #define PL080_CONFIG_SRC_SEL_SHIFT      (1)
0122 #define PL080_CONFIG_ENABLE         BIT(0)
0123 
0124 #define PL080_FLOW_MEM2MEM          (0x0)
0125 #define PL080_FLOW_MEM2PER          (0x1)
0126 #define PL080_FLOW_PER2MEM          (0x2)
0127 #define PL080_FLOW_SRC2DST          (0x3)
0128 #define PL080_FLOW_SRC2DST_DST          (0x4)
0129 #define PL080_FLOW_MEM2PER_PER          (0x5)
0130 #define PL080_FLOW_PER2MEM_PER          (0x6)
0131 #define PL080_FLOW_SRC2DST_SRC          (0x7)
0132 
0133 #define FTDMAC020_CH_CSR_TC_MSK         BIT(31)
0134 /* Later versions have a threshold in bits 24..26,  */
0135 #define FTDMAC020_CH_CSR_FIFOTH_MSK     GENMASK(26, 24)
0136 #define FTDMAC020_CH_CSR_FIFOTH_SHIFT       (24)
0137 #define FTDMAC020_CH_CSR_CHPR1_MSK      GENMASK(23, 22)
0138 #define FTDMAC020_CH_CSR_PROT3          BIT(21)
0139 #define FTDMAC020_CH_CSR_PROT2          BIT(20)
0140 #define FTDMAC020_CH_CSR_PROT1          BIT(19)
0141 #define FTDMAC020_CH_CSR_SRC_SIZE_MSK       GENMASK(18, 16)
0142 #define FTDMAC020_CH_CSR_SRC_SIZE_SHIFT     (16)
0143 #define FTDMAC020_CH_CSR_ABT            BIT(15)
0144 #define FTDMAC020_CH_CSR_SRC_WIDTH_MSK      GENMASK(13, 11)
0145 #define FTDMAC020_CH_CSR_SRC_WIDTH_SHIFT    (11)
0146 #define FTDMAC020_CH_CSR_DST_WIDTH_MSK      GENMASK(10, 8)
0147 #define FTDMAC020_CH_CSR_DST_WIDTH_SHIFT    (8)
0148 #define FTDMAC020_CH_CSR_MODE           BIT(7)
0149 /* 00 = increase, 01 = decrease, 10 = fix */
0150 #define FTDMAC020_CH_CSR_SRCAD_CTL_MSK      GENMASK(6, 5)
0151 #define FTDMAC020_CH_CSR_SRCAD_CTL_SHIFT    (5)
0152 #define FTDMAC020_CH_CSR_DSTAD_CTL_MSK      GENMASK(4, 3)
0153 #define FTDMAC020_CH_CSR_DSTAD_CTL_SHIFT    (3)
0154 #define FTDMAC020_CH_CSR_SRC_SEL        BIT(2)
0155 #define FTDMAC020_CH_CSR_DST_SEL        BIT(1)
0156 #define FTDMAC020_CH_CSR_EN         BIT(0)
0157 
0158 /* FIFO threshold setting */
0159 #define FTDMAC020_CH_CSR_FIFOTH_1       (0x0)
0160 #define FTDMAC020_CH_CSR_FIFOTH_2       (0x1)
0161 #define FTDMAC020_CH_CSR_FIFOTH_4       (0x2)
0162 #define FTDMAC020_CH_CSR_FIFOTH_8       (0x3)
0163 #define FTDMAC020_CH_CSR_FIFOTH_16      (0x4)
0164 /* The FTDMAC020 supports 64bit wide transfers */
0165 #define FTDMAC020_WIDTH_64BIT           (0x3)
0166 /* Address can be increased, decreased or fixed */
0167 #define FTDMAC020_CH_CSR_SRCAD_CTL_INC      (0x0)
0168 #define FTDMAC020_CH_CSR_SRCAD_CTL_DEC      (0x1)
0169 #define FTDMAC020_CH_CSR_SRCAD_CTL_FIXED    (0x2)
0170 
0171 #define FTDMAC020_CH_CFG_LLP_CNT_MASK       GENMASK(19, 16)
0172 #define FTDMAC020_CH_CFG_LLP_CNT_SHIFT      (16)
0173 #define FTDMAC020_CH_CFG_BUSY           BIT(8)
0174 #define FTDMAC020_CH_CFG_INT_ABT_MASK       BIT(2)
0175 #define FTDMAC020_CH_CFG_INT_ERR_MASK       BIT(1)
0176 #define FTDMAC020_CH_CFG_INT_TC_MASK        BIT(0)
0177 
0178 /* Inside the LLIs, the applicable CSR fields are mapped differently */
0179 #define FTDMAC020_LLI_TC_MSK            BIT(28)
0180 #define FTDMAC020_LLI_SRC_WIDTH_MSK     GENMASK(27, 25)
0181 #define FTDMAC020_LLI_SRC_WIDTH_SHIFT       (25)
0182 #define FTDMAC020_LLI_DST_WIDTH_MSK     GENMASK(24, 22)
0183 #define FTDMAC020_LLI_DST_WIDTH_SHIFT       (22)
0184 #define FTDMAC020_LLI_SRCAD_CTL_MSK     GENMASK(21, 20)
0185 #define FTDMAC020_LLI_SRCAD_CTL_SHIFT       (20)
0186 #define FTDMAC020_LLI_DSTAD_CTL_MSK     GENMASK(19, 18)
0187 #define FTDMAC020_LLI_DSTAD_CTL_SHIFT       (18)
0188 #define FTDMAC020_LLI_SRC_SEL           BIT(17)
0189 #define FTDMAC020_LLI_DST_SEL           BIT(16)
0190 #define FTDMAC020_LLI_TRANSFER_SIZE_MASK    GENMASK(11, 0)
0191 #define FTDMAC020_LLI_TRANSFER_SIZE_SHIFT   (0)
0192 
0193 #define FTDMAC020_CFG_LLP_CNT_MASK      GENMASK(19, 16)
0194 #define FTDMAC020_CFG_LLP_CNT_SHIFT     (16)
0195 #define FTDMAC020_CFG_BUSY          BIT(8)
0196 #define FTDMAC020_CFG_INT_ABT_MSK       BIT(2)
0197 #define FTDMAC020_CFG_INT_ERR_MSK       BIT(1)
0198 #define FTDMAC020_CFG_INT_TC_MSK        BIT(0)
0199 
0200 /* DMA linked list chain structure */
0201 
0202 struct pl080_lli {
0203     u32 src_addr;
0204     u32 dst_addr;
0205     u32 next_lli;
0206     u32 control0;
0207 };
0208 
0209 struct pl080s_lli {
0210     u32 src_addr;
0211     u32 dst_addr;
0212     u32 next_lli;
0213     u32 control0;
0214     u32 control1;
0215 };
0216 
0217 #endif /* ASM_PL080_H */