1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*
* ALSA SoC OMAP ABE driver
*
* Author: Laurent Le Faucheur <l-le-faucheur@ti.com>
* Liam Girdwood <lrg@slimlogic.co.uk>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include "abe_main.h"
/**
* abe_block_copy
* @direction: direction of the data move (Read/Write)
* @memory_bamk:memory bank among PMEM, DMEM, CMEM, SMEM, ATC/IO
* @address: address of the memory copy (byte addressing)
* @data: pointer to the data to transfer
* @nb_bytes: number of data to move
*
* Memory transfer to/from ABE to MPU
*/
void abe_block_copy(u32 direction, u32 memory_bank, u32 address,
u32 *data, u32 nb_bytes)
{
u32 i;
u32 base_address = 0, *src_ptr, *dst_ptr, n;
switch (memory_bank) {
case ABE_PMEM:
base_address = (u32) io_base + ABE_PMEM_BASE_OFFSET_MPU;
break;
case ABE_CMEM:
base_address = (u32) io_base + ABE_CMEM_BASE_OFFSET_MPU;
break;
case ABE_SMEM:
base_address = (u32) io_base + ABE_SMEM_BASE_OFFSET_MPU;
break;
case ABE_DMEM:
base_address = (u32) io_base + ABE_DMEM_BASE_OFFSET_MPU;
break;
case ABE_ATC:
base_address = (u32) io_base + ABE_ATC_BASE_OFFSET_MPU;
break;
default:
base_address = (u32) io_base + ABE_SMEM_BASE_OFFSET_MPU;
abe_dbg_param |= ERR_LIB;
abe_dbg_error_log(ABE_BLOCK_COPY_ERR);
break;
}
if (direction == COPY_FROM_HOST_TO_ABE) {
dst_ptr = (u32 *) (base_address + address);
src_ptr = (u32 *) data;
} else {
dst_ptr = (u32 *) data;
src_ptr = (u32 *) (base_address + address);
}
n = (nb_bytes / 4);
for (i = 0; i < n; i++)
*dst_ptr++ = *src_ptr++;
}
/**
* abe_reset_mem
*
* @memory_bank: memory bank among DMEM, SMEM
* @address: address of the memory copy (byte addressing)
* @nb_bytes: number of data to move
*
* Reset ABE memory
*/
void abe_reset_mem(u32 memory_bank, u32 address, u32 nb_bytes)
{
u32 i;
u32 *dst_ptr, n;
u32 base_address = 0;
switch (memory_bank) {
case ABE_SMEM:
base_address = (u32) io_base + ABE_SMEM_BASE_OFFSET_MPU;
break;
case ABE_DMEM:
base_address = (u32) io_base + ABE_DMEM_BASE_OFFSET_MPU;
break;
case ABE_CMEM:
base_address = (u32) io_base + ABE_CMEM_BASE_OFFSET_MPU;
break;
}
dst_ptr = (u32 *) (base_address + address);
n = (nb_bytes / 4);
for (i = 0; i < n; i++)
*dst_ptr++ = 0;
}
|