1 /*
2  * Support for Intel Camera Imaging ISP subsystem.
3  * Copyright (c) 2010-2016, Intel Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  */
14 
15 #include "debug.h"
16 
17 #include "hmm.h"
18 
19 #ifndef __INLINE_DEBUG__
20 #include "debug_private.h"
21 #endif /* __INLINE_DEBUG__ */
22 
23 
24 #define __INLINE_SP__
25 #include "sp.h"
26 
27 #include "assert_support.h"
28 
29 /* The address of the remote copy */
30 hrt_address	debug_buffer_address = (hrt_address) - 1;
31 ia_css_ptr	debug_buffer_ddr_address = (ia_css_ptr)-1;
32 /* The local copy */
33 static debug_data_t		debug_data;
34 debug_data_t		*debug_data_ptr = &debug_data;
35 
36 void debug_buffer_init(const hrt_address addr)
37 {
38 	debug_buffer_address = addr;
39 
40 	debug_data.head = 0;
41 	debug_data.tail = 0;
42 }
43 
44 void debug_buffer_ddr_init(const ia_css_ptr addr)
45 {
46 	debug_buf_mode_t mode = DEBUG_BUFFER_MODE_LINEAR;
47 	u32 enable = 1;
48 	u32 head = 0;
49 	u32 tail = 0;
50 	/* set the ddr queue */
51 	debug_buffer_ddr_address = addr;
52 	hmm_store(addr + DEBUG_DATA_BUF_MODE_DDR_ADDR,
53 		   &mode, sizeof(debug_buf_mode_t));
54 	hmm_store(addr + DEBUG_DATA_HEAD_DDR_ADDR,
55 		   &head, sizeof(uint32_t));
56 	hmm_store(addr + DEBUG_DATA_TAIL_DDR_ADDR,
57 		   &tail, sizeof(uint32_t));
58 	hmm_store(addr + DEBUG_DATA_ENABLE_DDR_ADDR,
59 		   &enable, sizeof(uint32_t));
60 
61 	/* set the local copy */
62 	debug_data.head = 0;
63 	debug_data.tail = 0;
64 }
65 
66 void debug_buffer_setmode(const debug_buf_mode_t mode)
67 {
68 	assert(debug_buffer_address != ((hrt_address)-1));
69 
70 	sp_dmem_store_uint32(SP0_ID,
71 			     debug_buffer_address + DEBUG_DATA_BUF_MODE_ADDR, mode);
72 }
73