1 /* linux/include/asm/hardware/pl330.h
3 * Copyright (C) 2010 Samsung Electronics Co. Ltd.
4 * Jaswinder Singh <jassi.brar@samsung.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __PL330_CORE_H
22 #define __PL330_CORE_H
24 #define PL330_MAX_CHAN 8
25 #define PL330_MAX_IRQS 32
26 #define PL330_MAX_PERI 32
28 enum pl330_srccachectrl
{
29 SCCTRL0
= 0, /* Noncacheable and nonbufferable */
30 SCCTRL1
, /* Bufferable only */
31 SCCTRL2
, /* Cacheable, but do not allocate */
32 SCCTRL3
, /* Cacheable and bufferable, but do not allocate */
35 SCCTRL6
, /* Cacheable write-through, allocate on reads only */
36 SCCTRL7
, /* Cacheable write-back, allocate on reads only */
39 enum pl330_dstcachectrl
{
40 DCCTRL0
= 0, /* Noncacheable and nonbufferable */
41 DCCTRL1
, /* Bufferable only */
42 DCCTRL2
, /* Cacheable, but do not allocate */
43 DCCTRL3
, /* Cacheable and bufferable, but do not allocate */
46 DCCTRL6
, /* Cacheable write-through, allocate on writes only */
47 DCCTRL7
, /* Cacheable write-back, allocate on writes only */
50 /* Populated by the PL330 core driver for DMA API driver's info */
54 #define DMAC_MODE_NS (1 << 0)
56 unsigned int data_bus_width
:10; /* In number of bits */
57 unsigned int data_buf_dep
:10;
58 unsigned int num_chan
:4;
59 unsigned int num_peri
:6;
61 unsigned int num_events
:6;
65 /* Handle to the DMAC provided to the PL330 core */
69 /* Size of MicroCode buffers for each channel. */
71 /* ioremap'ed address of PL330 registers. */
73 /* Client can freely use it. */
75 /* PL330 core data, Client must not touch it. */
77 /* Populated by the PL330 core driver during pl330_add */
78 struct pl330_config pcfg
;
80 * If the DMAC has some reset mechanism, then the
81 * client may want to provide pointer to the method.
83 void (*dmac_reset
)(struct pl330_info
*pi
);
95 * Request Configuration.
96 * The PL330 core does not modify this and uses the last
97 * working configuration if the request doesn't provide any.
99 * The Client may want to provide this info only for the
100 * first request and a request with new settings.
102 struct pl330_reqcfg
{
103 /* Address Incrementing */
108 * For now, the SRC & DST protection levels
109 * and burst size/length are assumed same.
115 unsigned brst_size
:3; /* in power of 2 */
117 enum pl330_dstcachectrl dcctl
;
118 enum pl330_srccachectrl scctl
;
119 enum pl330_byteswap swap
;
123 * One cycle of DMAC operation.
124 * There may be more than one xfer in a request.
132 * Pointer to next xfer in the list.
133 * The last xfer in the req must point to NULL.
135 struct pl330_xfer
*next
;
138 /* The xfer callbacks are made with one of these arguments. */
140 /* The all xfers in the request were success. */
142 /* If req aborted due to global error. */
144 /* If req failed due to problem with Channel. */
155 /* A request defining Scatter-Gather List ending with NULL xfer. */
157 enum pl330_reqtype rqtype
;
158 /* Index of peripheral for the xfer. */
160 /* Unique token for this xfer, set by the client. */
162 /* Callback to be called after xfer. */
163 void (*xfer_cb
)(void *token
, enum pl330_op_err err
);
164 /* If NULL, req will be done at last set parameters. */
165 struct pl330_reqcfg
*cfg
;
166 /* Pointer to first xfer in the request. */
167 struct pl330_xfer
*x
;
171 * To know the status of the channel and DMAC, the client
172 * provides a pointer to this structure. The PL330 core
173 * fills it with current information.
175 struct pl330_chanstatus
{
177 * If the DMAC engine halted due to some error,
178 * the client should remove-add DMAC.
182 * If channel is halted due to some error,
183 * the client should ABORT/FLUSH and START the channel.
186 /* Location of last load */
188 /* Location of last store */
191 * Pointer to the currently active req, NULL if channel is
192 * inactive, even though the requests may be present.
194 struct pl330_req
*top_req
;
195 /* Pointer to req waiting second in the queue if any. */
196 struct pl330_req
*wait_req
;
200 /* Start the channel */
202 /* Abort the active xfer */
204 /* Stop xfer and flush queue */
208 extern int pl330_add(struct pl330_info
*);
209 extern void pl330_del(struct pl330_info
*pi
);
210 extern int pl330_update(const struct pl330_info
*pi
);
211 extern void pl330_release_channel(void *ch_id
);
212 extern void *pl330_request_channel(const struct pl330_info
*pi
);
213 extern int pl330_chan_status(void *ch_id
, struct pl330_chanstatus
*pstatus
);
214 extern int pl330_chan_ctrl(void *ch_id
, enum pl330_chan_op op
);
215 extern int pl330_submit_req(void *ch_id
, struct pl330_req
*r
);
217 #endif /* __PL330_CORE_H */