Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) ST-Ericsson SA 2007-2010
0004  * Author: Per Friden <per.friden@stericsson.com> for ST-Ericsson SA
0005  * Author: Jonas Aaberg <jonas.aberg@stericsson.com> for ST-Ericsson SA
0006  */
0007 #ifndef STE_DMA40_LL_H
0008 #define STE_DMA40_LL_H
0009 
0010 #define D40_DREG_PCBASE     0x400
0011 #define D40_DREG_PCDELTA    (8 * 4)
0012 #define D40_LLI_ALIGN       16 /* LLI alignment must be 16 bytes. */
0013 
0014 #define D40_LCPA_CHAN_SIZE 32
0015 #define D40_LCPA_CHAN_DST_DELTA 16
0016 
0017 #define D40_TYPE_TO_GROUP(type) (type / 16)
0018 #define D40_TYPE_TO_EVENT(type) (type % 16)
0019 #define D40_GROUP_SIZE 8
0020 #define D40_PHYS_TO_GROUP(phys) ((phys & (D40_GROUP_SIZE - 1)) / 2)
0021 
0022 /* Most bits of the CFG register are the same in log as in phy mode */
0023 #define D40_SREG_CFG_MST_POS        15
0024 #define D40_SREG_CFG_TIM_POS        14
0025 #define D40_SREG_CFG_EIM_POS        13
0026 #define D40_SREG_CFG_LOG_INCR_POS   12
0027 #define D40_SREG_CFG_PHY_PEN_POS    12
0028 #define D40_SREG_CFG_PSIZE_POS      10
0029 #define D40_SREG_CFG_ESIZE_POS       8
0030 #define D40_SREG_CFG_PRI_POS         7
0031 #define D40_SREG_CFG_LBE_POS         6
0032 #define D40_SREG_CFG_LOG_GIM_POS     5
0033 #define D40_SREG_CFG_LOG_MFU_POS     4
0034 #define D40_SREG_CFG_PHY_TM_POS      4
0035 #define D40_SREG_CFG_PHY_EVTL_POS    0
0036 
0037 
0038 /* Standard channel parameters - basic mode (element register) */
0039 #define D40_SREG_ELEM_PHY_ECNT_POS  16
0040 #define D40_SREG_ELEM_PHY_EIDX_POS   0
0041 
0042 #define D40_SREG_ELEM_PHY_ECNT_MASK (0xFFFF << D40_SREG_ELEM_PHY_ECNT_POS)
0043 
0044 /* Standard channel parameters - basic mode (Link register) */
0045 #define D40_SREG_LNK_PHY_TCP_POS    0
0046 #define D40_SREG_LNK_PHY_LMP_POS    1
0047 #define D40_SREG_LNK_PHY_PRE_POS    2
0048 /*
0049  * Source  destination link address. Contains the
0050  * 29-bit byte word aligned address of the reload area.
0051  */
0052 #define D40_SREG_LNK_PHYS_LNK_MASK  0xFFFFFFF8UL
0053 
0054 /* Standard basic channel logical mode */
0055 
0056 /* Element register */
0057 #define D40_SREG_ELEM_LOG_ECNT_POS  16
0058 #define D40_SREG_ELEM_LOG_LIDX_POS   8
0059 #define D40_SREG_ELEM_LOG_LOS_POS    1
0060 #define D40_SREG_ELEM_LOG_TCP_POS    0
0061 
0062 #define D40_SREG_ELEM_LOG_LIDX_MASK (0xFF << D40_SREG_ELEM_LOG_LIDX_POS)
0063 
0064 /* Link register */
0065 #define D40_EVENTLINE_POS(i)        (2 * i)
0066 #define D40_EVENTLINE_MASK(i)       (0x3 << D40_EVENTLINE_POS(i))
0067 
0068 /* Standard basic channel logical params in memory */
0069 
0070 /* LCSP0 */
0071 #define D40_MEM_LCSP0_ECNT_POS      16
0072 #define D40_MEM_LCSP0_SPTR_POS       0
0073 
0074 #define D40_MEM_LCSP0_ECNT_MASK     (0xFFFF << D40_MEM_LCSP0_ECNT_POS)
0075 #define D40_MEM_LCSP0_SPTR_MASK     (0xFFFF << D40_MEM_LCSP0_SPTR_POS)
0076 
0077 /* LCSP1 */
0078 #define D40_MEM_LCSP1_SPTR_POS      16
0079 #define D40_MEM_LCSP1_SCFG_MST_POS  15
0080 #define D40_MEM_LCSP1_SCFG_TIM_POS  14
0081 #define D40_MEM_LCSP1_SCFG_EIM_POS  13
0082 #define D40_MEM_LCSP1_SCFG_INCR_POS 12
0083 #define D40_MEM_LCSP1_SCFG_PSIZE_POS    10
0084 #define D40_MEM_LCSP1_SCFG_ESIZE_POS     8
0085 #define D40_MEM_LCSP1_SLOS_POS       1
0086 #define D40_MEM_LCSP1_STCP_POS       0
0087 
0088 #define D40_MEM_LCSP1_SPTR_MASK     (0xFFFF << D40_MEM_LCSP1_SPTR_POS)
0089 #define D40_MEM_LCSP1_SCFG_TIM_MASK (0x1 << D40_MEM_LCSP1_SCFG_TIM_POS)
0090 #define D40_MEM_LCSP1_SCFG_INCR_MASK    (0x1 << D40_MEM_LCSP1_SCFG_INCR_POS)
0091 #define D40_MEM_LCSP1_SCFG_PSIZE_MASK   (0x3 << D40_MEM_LCSP1_SCFG_PSIZE_POS)
0092 #define D40_MEM_LCSP1_SLOS_MASK     (0x7F << D40_MEM_LCSP1_SLOS_POS)
0093 #define D40_MEM_LCSP1_STCP_MASK     (0x1 << D40_MEM_LCSP1_STCP_POS)
0094 
0095 /* LCSP2 */
0096 #define D40_MEM_LCSP2_ECNT_POS      16
0097 
0098 #define D40_MEM_LCSP2_ECNT_MASK     (0xFFFF << D40_MEM_LCSP2_ECNT_POS)
0099 
0100 /* LCSP3 */
0101 #define D40_MEM_LCSP3_DCFG_MST_POS  15
0102 #define D40_MEM_LCSP3_DCFG_TIM_POS  14
0103 #define D40_MEM_LCSP3_DCFG_EIM_POS  13
0104 #define D40_MEM_LCSP3_DCFG_INCR_POS 12
0105 #define D40_MEM_LCSP3_DCFG_PSIZE_POS    10
0106 #define D40_MEM_LCSP3_DCFG_ESIZE_POS     8
0107 #define D40_MEM_LCSP3_DLOS_POS       1
0108 #define D40_MEM_LCSP3_DTCP_POS       0
0109 
0110 #define D40_MEM_LCSP3_DLOS_MASK     (0x7F << D40_MEM_LCSP3_DLOS_POS)
0111 #define D40_MEM_LCSP3_DTCP_MASK     (0x1 << D40_MEM_LCSP3_DTCP_POS)
0112 
0113 
0114 /* Standard channel parameter register offsets */
0115 #define D40_CHAN_REG_SSCFG  0x00
0116 #define D40_CHAN_REG_SSELT  0x04
0117 #define D40_CHAN_REG_SSPTR  0x08
0118 #define D40_CHAN_REG_SSLNK  0x0C
0119 #define D40_CHAN_REG_SDCFG  0x10
0120 #define D40_CHAN_REG_SDELT  0x14
0121 #define D40_CHAN_REG_SDPTR  0x18
0122 #define D40_CHAN_REG_SDLNK  0x1C
0123 
0124 /* DMA Register Offsets */
0125 #define D40_DREG_GCC        0x000
0126 #define D40_DREG_GCC_ENA    0x1
0127 /* This assumes that there are only 4 event groups */
0128 #define D40_DREG_GCC_ENABLE_ALL 0x3ff01
0129 #define D40_DREG_GCC_EVTGRP_POS 8
0130 #define D40_DREG_GCC_SRC 0
0131 #define D40_DREG_GCC_DST 1
0132 #define D40_DREG_GCC_EVTGRP_ENA(x, y) \
0133     (1 << (D40_DREG_GCC_EVTGRP_POS + 2 * x + y))
0134 
0135 #define D40_DREG_PRTYP      0x004
0136 #define D40_DREG_PRSME      0x008
0137 #define D40_DREG_PRSMO      0x00C
0138 #define D40_DREG_PRMSE      0x010
0139 #define D40_DREG_PRMSO      0x014
0140 #define D40_DREG_PRMOE      0x018
0141 #define D40_DREG_PRMOO      0x01C
0142 #define D40_DREG_PRMO_PCHAN_BASIC       0x1
0143 #define D40_DREG_PRMO_PCHAN_MODULO      0x2
0144 #define D40_DREG_PRMO_PCHAN_DOUBLE_DST      0x3
0145 #define D40_DREG_PRMO_LCHAN_SRC_PHY_DST_LOG 0x1
0146 #define D40_DREG_PRMO_LCHAN_SRC_LOG_DST_PHY 0x2
0147 #define D40_DREG_PRMO_LCHAN_SRC_LOG_DST_LOG 0x3
0148 
0149 #define D40_DREG_LCPA       0x020
0150 #define D40_DREG_LCLA       0x024
0151 
0152 #define D40_DREG_SSEG1      0x030
0153 #define D40_DREG_SSEG2      0x034
0154 #define D40_DREG_SSEG3      0x038
0155 #define D40_DREG_SSEG4      0x03C
0156 
0157 #define D40_DREG_SCEG1      0x040
0158 #define D40_DREG_SCEG2      0x044
0159 #define D40_DREG_SCEG3      0x048
0160 #define D40_DREG_SCEG4      0x04C
0161 
0162 #define D40_DREG_ACTIVE     0x050
0163 #define D40_DREG_ACTIVO     0x054
0164 #define D40_DREG_CIDMOD     0x058
0165 #define D40_DREG_TCIDV      0x05C
0166 #define D40_DREG_PCMIS      0x060
0167 #define D40_DREG_PCICR      0x064
0168 #define D40_DREG_PCTIS      0x068
0169 #define D40_DREG_PCEIS      0x06C
0170 
0171 #define D40_DREG_SPCMIS     0x070
0172 #define D40_DREG_SPCICR     0x074
0173 #define D40_DREG_SPCTIS     0x078
0174 #define D40_DREG_SPCEIS     0x07C
0175 
0176 #define D40_DREG_LCMIS0     0x080
0177 #define D40_DREG_LCMIS1     0x084
0178 #define D40_DREG_LCMIS2     0x088
0179 #define D40_DREG_LCMIS3     0x08C
0180 #define D40_DREG_LCICR0     0x090
0181 #define D40_DREG_LCICR1     0x094
0182 #define D40_DREG_LCICR2     0x098
0183 #define D40_DREG_LCICR3     0x09C
0184 #define D40_DREG_LCTIS0     0x0A0
0185 #define D40_DREG_LCTIS1     0x0A4
0186 #define D40_DREG_LCTIS2     0x0A8
0187 #define D40_DREG_LCTIS3     0x0AC
0188 #define D40_DREG_LCEIS0     0x0B0
0189 #define D40_DREG_LCEIS1     0x0B4
0190 #define D40_DREG_LCEIS2     0x0B8
0191 #define D40_DREG_LCEIS3     0x0BC
0192 
0193 #define D40_DREG_SLCMIS1    0x0C0
0194 #define D40_DREG_SLCMIS2    0x0C4
0195 #define D40_DREG_SLCMIS3    0x0C8
0196 #define D40_DREG_SLCMIS4    0x0CC
0197 
0198 #define D40_DREG_SLCICR1    0x0D0
0199 #define D40_DREG_SLCICR2    0x0D4
0200 #define D40_DREG_SLCICR3    0x0D8
0201 #define D40_DREG_SLCICR4    0x0DC
0202 
0203 #define D40_DREG_SLCTIS1    0x0E0
0204 #define D40_DREG_SLCTIS2    0x0E4
0205 #define D40_DREG_SLCTIS3    0x0E8
0206 #define D40_DREG_SLCTIS4    0x0EC
0207 
0208 #define D40_DREG_SLCEIS1    0x0F0
0209 #define D40_DREG_SLCEIS2    0x0F4
0210 #define D40_DREG_SLCEIS3    0x0F8
0211 #define D40_DREG_SLCEIS4    0x0FC
0212 
0213 #define D40_DREG_FSESS1     0x100
0214 #define D40_DREG_FSESS2     0x104
0215 
0216 #define D40_DREG_FSEBS1     0x108
0217 #define D40_DREG_FSEBS2     0x10C
0218 
0219 #define D40_DREG_PSEG1      0x110
0220 #define D40_DREG_PSEG2      0x114
0221 #define D40_DREG_PSEG3      0x118
0222 #define D40_DREG_PSEG4      0x11C
0223 #define D40_DREG_PCEG1      0x120
0224 #define D40_DREG_PCEG2      0x124
0225 #define D40_DREG_PCEG3      0x128
0226 #define D40_DREG_PCEG4      0x12C
0227 #define D40_DREG_RSEG1      0x130
0228 #define D40_DREG_RSEG2      0x134
0229 #define D40_DREG_RSEG3      0x138
0230 #define D40_DREG_RSEG4      0x13C
0231 #define D40_DREG_RCEG1      0x140
0232 #define D40_DREG_RCEG2      0x144
0233 #define D40_DREG_RCEG3      0x148
0234 #define D40_DREG_RCEG4      0x14C
0235 
0236 #define D40_DREG_PREFOT     0x15C
0237 #define D40_DREG_EXTCFG     0x160
0238 
0239 #define D40_DREG_CPSEG1     0x200
0240 #define D40_DREG_CPSEG2     0x204
0241 #define D40_DREG_CPSEG3     0x208
0242 #define D40_DREG_CPSEG4     0x20C
0243 #define D40_DREG_CPSEG5     0x210
0244 
0245 #define D40_DREG_CPCEG1     0x220
0246 #define D40_DREG_CPCEG2     0x224
0247 #define D40_DREG_CPCEG3     0x228
0248 #define D40_DREG_CPCEG4     0x22C
0249 #define D40_DREG_CPCEG5     0x230
0250 
0251 #define D40_DREG_CRSEG1     0x240
0252 #define D40_DREG_CRSEG2     0x244
0253 #define D40_DREG_CRSEG3     0x248
0254 #define D40_DREG_CRSEG4     0x24C
0255 #define D40_DREG_CRSEG5     0x250
0256 
0257 #define D40_DREG_CRCEG1     0x260
0258 #define D40_DREG_CRCEG2     0x264
0259 #define D40_DREG_CRCEG3     0x268
0260 #define D40_DREG_CRCEG4     0x26C
0261 #define D40_DREG_CRCEG5     0x270
0262 
0263 #define D40_DREG_CFSESS1    0x280
0264 #define D40_DREG_CFSESS2    0x284
0265 #define D40_DREG_CFSESS3    0x288
0266 
0267 #define D40_DREG_CFSEBS1    0x290
0268 #define D40_DREG_CFSEBS2    0x294
0269 #define D40_DREG_CFSEBS3    0x298
0270 
0271 #define D40_DREG_CLCMIS1    0x300
0272 #define D40_DREG_CLCMIS2    0x304
0273 #define D40_DREG_CLCMIS3    0x308
0274 #define D40_DREG_CLCMIS4    0x30C
0275 #define D40_DREG_CLCMIS5    0x310
0276 
0277 #define D40_DREG_CLCICR1    0x320
0278 #define D40_DREG_CLCICR2    0x324
0279 #define D40_DREG_CLCICR3    0x328
0280 #define D40_DREG_CLCICR4    0x32C
0281 #define D40_DREG_CLCICR5    0x330
0282 
0283 #define D40_DREG_CLCTIS1    0x340
0284 #define D40_DREG_CLCTIS2    0x344
0285 #define D40_DREG_CLCTIS3    0x348
0286 #define D40_DREG_CLCTIS4    0x34C
0287 #define D40_DREG_CLCTIS5    0x350
0288 
0289 #define D40_DREG_CLCEIS1    0x360
0290 #define D40_DREG_CLCEIS2    0x364
0291 #define D40_DREG_CLCEIS3    0x368
0292 #define D40_DREG_CLCEIS4    0x36C
0293 #define D40_DREG_CLCEIS5    0x370
0294 
0295 #define D40_DREG_CPCMIS     0x380
0296 #define D40_DREG_CPCICR     0x384
0297 #define D40_DREG_CPCTIS     0x388
0298 #define D40_DREG_CPCEIS     0x38C
0299 
0300 #define D40_DREG_SCCIDA1    0xE80
0301 #define D40_DREG_SCCIDA2    0xE90
0302 #define D40_DREG_SCCIDA3    0xEA0
0303 #define D40_DREG_SCCIDA4    0xEB0
0304 #define D40_DREG_SCCIDA5    0xEC0
0305 
0306 #define D40_DREG_SCCIDB1    0xE84
0307 #define D40_DREG_SCCIDB2    0xE94
0308 #define D40_DREG_SCCIDB3    0xEA4
0309 #define D40_DREG_SCCIDB4    0xEB4
0310 #define D40_DREG_SCCIDB5    0xEC4
0311 
0312 #define D40_DREG_PRSCCIDA   0xF80
0313 #define D40_DREG_PRSCCIDB   0xF84
0314 
0315 #define D40_DREG_STFU       0xFC8
0316 #define D40_DREG_ICFG       0xFCC
0317 #define D40_DREG_PERIPHID0  0xFE0
0318 #define D40_DREG_PERIPHID1  0xFE4
0319 #define D40_DREG_PERIPHID2  0xFE8
0320 #define D40_DREG_PERIPHID3  0xFEC
0321 #define D40_DREG_CELLID0    0xFF0
0322 #define D40_DREG_CELLID1    0xFF4
0323 #define D40_DREG_CELLID2    0xFF8
0324 #define D40_DREG_CELLID3    0xFFC
0325 
0326 /* LLI related structures */
0327 
0328 /**
0329  * struct d40_phy_lli - The basic configuration register for each physical
0330  * channel.
0331  *
0332  * @reg_cfg: The configuration register.
0333  * @reg_elt: The element register.
0334  * @reg_ptr: The pointer register.
0335  * @reg_lnk: The link register.
0336  *
0337  * These registers are set up for both physical and logical transfers
0338  * Note that the bit in each register means differently in logical and
0339  * physical(standard) mode.
0340  *
0341  * This struct must be 16 bytes aligned, and only contain physical registers
0342  * since it will be directly accessed by the DMA.
0343  */
0344 struct d40_phy_lli {
0345     u32 reg_cfg;
0346     u32 reg_elt;
0347     u32 reg_ptr;
0348     u32 reg_lnk;
0349 };
0350 
0351 /**
0352  * struct d40_phy_lli_bidir - struct for a transfer.
0353  *
0354  * @src: Register settings for src channel.
0355  * @dst: Register settings for dst channel.
0356  *
0357  * All DMA transfers have a source and a destination.
0358  */
0359 
0360 struct d40_phy_lli_bidir {
0361     struct d40_phy_lli  *src;
0362     struct d40_phy_lli  *dst;
0363 };
0364 
0365 
0366 /**
0367  * struct d40_log_lli - logical lli configuration
0368  *
0369  * @lcsp02: Either maps to register lcsp0 if src or lcsp2 if dst.
0370  * @lcsp13: Either maps to register lcsp1 if src or lcsp3 if dst.
0371  *
0372  * This struct must be 8 bytes aligned since it will be accessed directy by
0373  * the DMA. Never add any none hw mapped registers to this struct.
0374  */
0375 
0376 struct d40_log_lli {
0377     u32 lcsp02;
0378     u32 lcsp13;
0379 };
0380 
0381 /**
0382  * struct d40_log_lli_bidir - For both src and dst
0383  *
0384  * @src: pointer to src lli configuration.
0385  * @dst: pointer to dst lli configuration.
0386  *
0387  * You always have a src and a dst when doing DMA transfers.
0388  */
0389 
0390 struct d40_log_lli_bidir {
0391     struct d40_log_lli *src;
0392     struct d40_log_lli *dst;
0393 };
0394 
0395 /**
0396  * struct d40_log_lli_full - LCPA layout
0397  *
0398  * @lcsp0: Logical Channel Standard Param 0 - Src.
0399  * @lcsp1: Logical Channel Standard Param 1 - Src.
0400  * @lcsp2: Logical Channel Standard Param 2 - Dst.
0401  * @lcsp3: Logical Channel Standard Param 3 - Dst.
0402  *
0403  * This struct maps to LCPA physical memory layout. Must map to
0404  * the hw.
0405  */
0406 struct d40_log_lli_full {
0407     u32 lcsp0;
0408     u32 lcsp1;
0409     u32 lcsp2;
0410     u32 lcsp3;
0411 };
0412 
0413 /**
0414  * struct d40_def_lcsp - Default LCSP1 and LCSP3 settings
0415  *
0416  * @lcsp3: The default configuration for dst.
0417  * @lcsp1: The default configuration for src.
0418  */
0419 struct d40_def_lcsp {
0420     u32 lcsp3;
0421     u32 lcsp1;
0422 };
0423 
0424 /* Physical channels */
0425 
0426 enum d40_lli_flags {
0427     LLI_ADDR_INC    = 1 << 0,
0428     LLI_TERM_INT    = 1 << 1,
0429     LLI_CYCLIC  = 1 << 2,
0430     LLI_LAST_LINK   = 1 << 3,
0431 };
0432 
0433 void d40_phy_cfg(struct stedma40_chan_cfg *cfg,
0434          u32 *src_cfg,
0435          u32 *dst_cfg);
0436 
0437 void d40_log_cfg(struct stedma40_chan_cfg *cfg,
0438          u32 *lcsp1,
0439          u32 *lcsp2);
0440 
0441 int d40_phy_sg_to_lli(struct scatterlist *sg,
0442               int sg_len,
0443               dma_addr_t target,
0444               struct d40_phy_lli *lli,
0445               dma_addr_t lli_phys,
0446               u32 reg_cfg,
0447               struct stedma40_half_channel_info *info,
0448               struct stedma40_half_channel_info *otherinfo,
0449               unsigned long flags);
0450 
0451 /* Logical channels */
0452 
0453 int d40_log_sg_to_lli(struct scatterlist *sg,
0454               int sg_len,
0455               dma_addr_t dev_addr,
0456               struct d40_log_lli *lli_sg,
0457               u32 lcsp13, /* src or dst*/
0458               u32 data_width1, u32 data_width2);
0459 
0460 void d40_log_lli_lcpa_write(struct d40_log_lli_full *lcpa,
0461                 struct d40_log_lli *lli_dst,
0462                 struct d40_log_lli *lli_src,
0463                 int next, unsigned int flags);
0464 
0465 void d40_log_lli_lcla_write(struct d40_log_lli *lcla,
0466                 struct d40_log_lli *lli_dst,
0467                 struct d40_log_lli *lli_src,
0468                 int next, unsigned int flags);
0469 
0470 #endif /* STE_DMA40_LLI_H */