blob: ab036b6b1804fc667b1b5b9ed5e36abb7059ac0f [file] [log] [blame]
Alessandro Rubini3a95b9f2012-11-24 00:22:56 +00001/* include/linux/amba/pl080.h
Ben Dooksfa7a7882009-03-10 23:57:26 +00002 *
3 * Copyright 2008 Openmoko, Inc.
4 * Copyright 2008 Simtec Electronics
5 * http://armlinux.simtec.co.uk/
6 * Ben Dooks <ben@simtec.co.uk>
7 *
8 * ARM PrimeCell PL080 DMA controller
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13*/
14
15/* Note, there are some Samsung updates to this controller block which
16 * make it not entierly compatible with the PL080 specification from
17 * ARM. When in doubt, check the Samsung documentation first.
18 *
Lucas De Marchi25985ed2011-03-30 22:57:33 -030019 * The Samsung defines are PL080S, and add an extra control register,
Ben Dooksfa7a7882009-03-10 23:57:26 +000020 * the ability to move more than 2^11 counts of data and some extra
21 * OneNAND features.
22*/
23
Viresh Kumar47850a22011-08-05 15:32:26 +053024#ifndef ASM_PL080_H
25#define ASM_PL080_H
26
Ben Dooksfa7a7882009-03-10 23:57:26 +000027#define PL080_INT_STATUS (0x00)
28#define PL080_TC_STATUS (0x04)
29#define PL080_TC_CLEAR (0x08)
30#define PL080_ERR_STATUS (0x0C)
31#define PL080_ERR_CLEAR (0x10)
32#define PL080_RAW_TC_STATUS (0x14)
33#define PL080_RAW_ERR_STATUS (0x18)
34#define PL080_EN_CHAN (0x1c)
35#define PL080_SOFT_BREQ (0x20)
36#define PL080_SOFT_SREQ (0x24)
37#define PL080_SOFT_LBREQ (0x28)
38#define PL080_SOFT_LSREQ (0x2C)
39
40#define PL080_CONFIG (0x30)
Linus Walleijded091f2017-04-02 16:50:53 +020041#define PL080_CONFIG_M2_BE BIT(2)
42#define PL080_CONFIG_M1_BE BIT(1)
43#define PL080_CONFIG_ENABLE BIT(0)
Ben Dooksfa7a7882009-03-10 23:57:26 +000044
45#define PL080_SYNC (0x34)
46
Linus Walleij1e1cfc72017-05-20 23:42:53 +020047/* The Faraday Technology FTDMAC020 variant registers */
48#define FTDMAC020_CH_BUSY (0x20)
49/* Identical to PL080_CONFIG */
50#define FTDMAC020_CSR (0x24)
51/* Identical to PL080_SYNC */
52#define FTDMAC020_SYNC (0x2C)
53#define FTDMAC020_REVISION (0x30)
54#define FTDMAC020_FEATURE (0x34)
Ben Dooksfa7a7882009-03-10 23:57:26 +000055
Linus Walleij44f0aee2017-04-02 16:50:33 +020056/* Per channel configuration registers */
Ben Dooksfa7a7882009-03-10 23:57:26 +000057#define PL080_Cx_BASE(x) ((0x100 + (x * 0x20)))
Ben Dooksfa7a7882009-03-10 23:57:26 +000058#define PL080_CH_SRC_ADDR (0x00)
59#define PL080_CH_DST_ADDR (0x04)
60#define PL080_CH_LLI (0x08)
61#define PL080_CH_CONTROL (0x0C)
62#define PL080_CH_CONFIG (0x10)
63#define PL080S_CH_CONTROL2 (0x10)
64#define PL080S_CH_CONFIG (0x14)
Linus Walleij1e1cfc72017-05-20 23:42:53 +020065/* The Faraday FTDMAC020 derivative shuffles the registers around */
66#define FTDMAC020_CH_CSR (0x00)
67#define FTDMAC020_CH_CFG (0x04)
68#define FTDMAC020_CH_SRC_ADDR (0x08)
69#define FTDMAC020_CH_DST_ADDR (0x0C)
70#define FTDMAC020_CH_LLP (0x10)
71#define FTDMAC020_CH_SIZE (0x14)
Ben Dooksfa7a7882009-03-10 23:57:26 +000072
Linus Walleijfcc78542017-05-20 23:42:54 +020073#define PL080_LLI_ADDR_MASK GENMASK(31, 2)
Ben Dooksfa7a7882009-03-10 23:57:26 +000074#define PL080_LLI_ADDR_SHIFT (2)
Linus Walleijded091f2017-04-02 16:50:53 +020075#define PL080_LLI_LM_AHB2 BIT(0)
Ben Dooksfa7a7882009-03-10 23:57:26 +000076
Linus Walleijded091f2017-04-02 16:50:53 +020077#define PL080_CONTROL_TC_IRQ_EN BIT(31)
Linus Walleijfcc78542017-05-20 23:42:54 +020078#define PL080_CONTROL_PROT_MASK GENMASK(30, 28)
Ben Dooksfa7a7882009-03-10 23:57:26 +000079#define PL080_CONTROL_PROT_SHIFT (28)
Linus Walleijded091f2017-04-02 16:50:53 +020080#define PL080_CONTROL_PROT_CACHE BIT(30)
81#define PL080_CONTROL_PROT_BUFF BIT(29)
82#define PL080_CONTROL_PROT_SYS BIT(28)
83#define PL080_CONTROL_DST_INCR BIT(27)
84#define PL080_CONTROL_SRC_INCR BIT(26)
85#define PL080_CONTROL_DST_AHB2 BIT(25)
86#define PL080_CONTROL_SRC_AHB2 BIT(24)
Linus Walleijfcc78542017-05-20 23:42:54 +020087#define PL080_CONTROL_DWIDTH_MASK GENMASK(23, 21)
Ben Dooksfa7a7882009-03-10 23:57:26 +000088#define PL080_CONTROL_DWIDTH_SHIFT (21)
Linus Walleijfcc78542017-05-20 23:42:54 +020089#define PL080_CONTROL_SWIDTH_MASK GENMASK(20, 18)
Ben Dooksfa7a7882009-03-10 23:57:26 +000090#define PL080_CONTROL_SWIDTH_SHIFT (18)
Linus Walleijfcc78542017-05-20 23:42:54 +020091#define PL080_CONTROL_DB_SIZE_MASK GENMASK(17, 15)
Ben Dooksfa7a7882009-03-10 23:57:26 +000092#define PL080_CONTROL_DB_SIZE_SHIFT (15)
Linus Walleijfcc78542017-05-20 23:42:54 +020093#define PL080_CONTROL_SB_SIZE_MASK GENMASK(14, 12)
Ben Dooksfa7a7882009-03-10 23:57:26 +000094#define PL080_CONTROL_SB_SIZE_SHIFT (12)
Linus Walleijfcc78542017-05-20 23:42:54 +020095#define PL080_CONTROL_TRANSFER_SIZE_MASK GENMASK(11, 0)
96#define PL080S_CONTROL_TRANSFER_SIZE_MASK GENMASK(24, 0)
Ben Dooksfa7a7882009-03-10 23:57:26 +000097#define PL080_CONTROL_TRANSFER_SIZE_SHIFT (0)
98
99#define PL080_BSIZE_1 (0x0)
100#define PL080_BSIZE_4 (0x1)
101#define PL080_BSIZE_8 (0x2)
102#define PL080_BSIZE_16 (0x3)
103#define PL080_BSIZE_32 (0x4)
104#define PL080_BSIZE_64 (0x5)
105#define PL080_BSIZE_128 (0x6)
106#define PL080_BSIZE_256 (0x7)
107
108#define PL080_WIDTH_8BIT (0x0)
109#define PL080_WIDTH_16BIT (0x1)
110#define PL080_WIDTH_32BIT (0x2)
111
Linus Walleijded091f2017-04-02 16:50:53 +0200112#define PL080N_CONFIG_ITPROT BIT(20)
113#define PL080N_CONFIG_SECPROT BIT(19)
114#define PL080_CONFIG_HALT BIT(18)
115#define PL080_CONFIG_ACTIVE BIT(17) /* RO */
116#define PL080_CONFIG_LOCK BIT(16)
117#define PL080_CONFIG_TC_IRQ_MASK BIT(15)
118#define PL080_CONFIG_ERR_IRQ_MASK BIT(14)
Linus Walleijfcc78542017-05-20 23:42:54 +0200119#define PL080_CONFIG_FLOW_CONTROL_MASK GENMASK(13, 11)
Ben Dooksfa7a7882009-03-10 23:57:26 +0000120#define PL080_CONFIG_FLOW_CONTROL_SHIFT (11)
Linus Walleijfcc78542017-05-20 23:42:54 +0200121#define PL080_CONFIG_DST_SEL_MASK GENMASK(9, 6)
Ben Dooksfa7a7882009-03-10 23:57:26 +0000122#define PL080_CONFIG_DST_SEL_SHIFT (6)
Linus Walleijfcc78542017-05-20 23:42:54 +0200123#define PL080_CONFIG_SRC_SEL_MASK GENMASK(4, 1)
Ben Dooksfa7a7882009-03-10 23:57:26 +0000124#define PL080_CONFIG_SRC_SEL_SHIFT (1)
Linus Walleijded091f2017-04-02 16:50:53 +0200125#define PL080_CONFIG_ENABLE BIT(0)
Ben Dooksfa7a7882009-03-10 23:57:26 +0000126
127#define PL080_FLOW_MEM2MEM (0x0)
128#define PL080_FLOW_MEM2PER (0x1)
129#define PL080_FLOW_PER2MEM (0x2)
130#define PL080_FLOW_SRC2DST (0x3)
131#define PL080_FLOW_SRC2DST_DST (0x4)
132#define PL080_FLOW_MEM2PER_PER (0x5)
133#define PL080_FLOW_PER2MEM_PER (0x6)
134#define PL080_FLOW_SRC2DST_SRC (0x7)
135
Linus Walleij1e1cfc72017-05-20 23:42:53 +0200136#define FTDMAC020_CH_CSR_TC_MSK BIT(31)
137/* Later versions have a threshold in bits 24..26, */
Linus Walleijfcc78542017-05-20 23:42:54 +0200138#define FTDMAC020_CH_CSR_FIFOTH_MSK GENMASK(26, 24)
Linus Walleij1e1cfc72017-05-20 23:42:53 +0200139#define FTDMAC020_CH_CSR_FIFOTH_SHIFT (24)
Linus Walleijfcc78542017-05-20 23:42:54 +0200140#define FTDMAC020_CH_CSR_CHPR1_MSK GENMASK(23, 22)
Linus Walleij1e1cfc72017-05-20 23:42:53 +0200141#define FTDMAC020_CH_CSR_PROT3 BIT(21)
142#define FTDMAC020_CH_CSR_PROT2 BIT(20)
143#define FTDMAC020_CH_CSR_PROT1 BIT(19)
Linus Walleijfcc78542017-05-20 23:42:54 +0200144#define FTDMAC020_CH_CSR_SRC_SIZE_MSK GENMASK(18, 16)
Linus Walleij1e1cfc72017-05-20 23:42:53 +0200145#define FTDMAC020_CH_CSR_SRC_SIZE_SHIFT (16)
146#define FTDMAC020_CH_CSR_ABT BIT(15)
Linus Walleijfcc78542017-05-20 23:42:54 +0200147#define FTDMAC020_CH_CSR_SRC_WIDTH_MSK GENMASK(13, 11)
Linus Walleij1e1cfc72017-05-20 23:42:53 +0200148#define FTDMAC020_CH_CSR_SRC_WIDTH_SHIFT (11)
Linus Walleijfcc78542017-05-20 23:42:54 +0200149#define FTDMAC020_CH_CSR_DST_WIDTH_MSK GENMASK(10, 8)
Linus Walleij1e1cfc72017-05-20 23:42:53 +0200150#define FTDMAC020_CH_CSR_DST_WIDTH_SHIFT (8)
151#define FTDMAC020_CH_CSR_MODE BIT(7)
152/* 00 = increase, 01 = decrease, 10 = fix */
Linus Walleijfcc78542017-05-20 23:42:54 +0200153#define FTDMAC020_CH_CSR_SRCAD_CTL_MSK GENMASK(6, 5)
Linus Walleij1e1cfc72017-05-20 23:42:53 +0200154#define FTDMAC020_CH_CSR_SRCAD_CTL_SHIFT (5)
Linus Walleijfcc78542017-05-20 23:42:54 +0200155#define FTDMAC020_CH_CSR_DSTAD_CTL_MSK GENMASK(4, 3)
Linus Walleij1e1cfc72017-05-20 23:42:53 +0200156#define FTDMAC020_CH_CSR_DSTAD_CTL_SHIFT (3)
157#define FTDMAC020_CH_CSR_SRC_SEL BIT(2)
158#define FTDMAC020_CH_CSR_DST_SEL BIT(1)
159#define FTDMAC020_CH_CSR_EN BIT(0)
160
161/* FIFO threshold setting */
162#define FTDMAC020_CH_CSR_FIFOTH_1 (0x0)
163#define FTDMAC020_CH_CSR_FIFOTH_2 (0x1)
164#define FTDMAC020_CH_CSR_FIFOTH_4 (0x2)
165#define FTDMAC020_CH_CSR_FIFOTH_8 (0x3)
166#define FTDMAC020_CH_CSR_FIFOTH_16 (0x4)
167/* The FTDMAC020 supports 64bit wide transfers */
168#define FTDMAC020_WIDTH_64BIT (0x3)
169/* Address can be increased, decreased or fixed */
170#define FTDMAC020_CH_CSR_SRCAD_CTL_INC (0x0)
171#define FTDMAC020_CH_CSR_SRCAD_CTL_DEC (0x1)
172#define FTDMAC020_CH_CSR_SRCAD_CTL_FIXED (0x2)
173
Linus Walleijfcc78542017-05-20 23:42:54 +0200174#define FTDMAC020_CH_CFG_LLP_CNT_MASK GENMASK(19, 16)
Linus Walleij1e1cfc72017-05-20 23:42:53 +0200175#define FTDMAC020_CH_CFG_LLP_CNT_SHIFT (16)
176#define FTDMAC020_CH_CFG_BUSY BIT(8)
177#define FTDMAC020_CH_CFG_INT_ABT_MASK BIT(2)
178#define FTDMAC020_CH_CFG_INT_ERR_MASK BIT(1)
179#define FTDMAC020_CH_CFG_INT_TC_MASK BIT(0)
180
181/* Inside the LLIs, the applicable CSR fields are mapped differently */
182#define FTDMAC020_LLI_TC_MSK BIT(28)
Linus Walleijfcc78542017-05-20 23:42:54 +0200183#define FTDMAC020_LLI_SRC_WIDTH_MSK GENMASK(27, 25)
Linus Walleij1e1cfc72017-05-20 23:42:53 +0200184#define FTDMAC020_LLI_SRC_WIDTH_SHIFT (25)
Linus Walleijfcc78542017-05-20 23:42:54 +0200185#define FTDMAC020_LLI_DST_WIDTH_MSK GENMASK(24, 22)
Linus Walleij1e1cfc72017-05-20 23:42:53 +0200186#define FTDMAC020_LLI_DST_WIDTH_SHIFT (22)
Linus Walleijfcc78542017-05-20 23:42:54 +0200187#define FTDMAC020_LLI_SRCAD_CTL_MSK GENMASK(21, 20)
Linus Walleij1e1cfc72017-05-20 23:42:53 +0200188#define FTDMAC020_LLI_SRCAD_CTL_SHIFT (20)
Linus Walleijfcc78542017-05-20 23:42:54 +0200189#define FTDMAC020_LLI_DSTAD_CTL_MSK GENMASK(19, 18)
Linus Walleij1e1cfc72017-05-20 23:42:53 +0200190#define FTDMAC020_LLI_DSTAD_CTL_SHIFT (18)
191#define FTDMAC020_LLI_SRC_SEL BIT(17)
192#define FTDMAC020_LLI_DST_SEL BIT(16)
Linus Walleijfcc78542017-05-20 23:42:54 +0200193#define FTDMAC020_LLI_TRANSFER_SIZE_MASK GENMASK(11, 0)
Linus Walleij1e1cfc72017-05-20 23:42:53 +0200194#define FTDMAC020_LLI_TRANSFER_SIZE_SHIFT (0)
195
Linus Walleijfcc78542017-05-20 23:42:54 +0200196#define FTDMAC020_CFG_LLP_CNT_MASK GENMASK(19, 16)
Linus Walleij1e1cfc72017-05-20 23:42:53 +0200197#define FTDMAC020_CFG_LLP_CNT_SHIFT (16)
198#define FTDMAC020_CFG_BUSY BIT(8)
199#define FTDMAC020_CFG_INT_ABT_MSK BIT(2)
200#define FTDMAC020_CFG_INT_ERR_MSK BIT(1)
201#define FTDMAC020_CFG_INT_TC_MSK BIT(0)
202
Ben Dooksfa7a7882009-03-10 23:57:26 +0000203/* DMA linked list chain structure */
204
205struct pl080_lli {
206 u32 src_addr;
207 u32 dst_addr;
208 u32 next_lli;
209 u32 control0;
210};
211
212struct pl080s_lli {
213 u32 src_addr;
214 u32 dst_addr;
215 u32 next_lli;
216 u32 control0;
217 u32 control1;
218};
219
Viresh Kumar47850a22011-08-05 15:32:26 +0530220#endif /* ASM_PL080_H */