GNU Linux-libre 4.14.328-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / hive_isp_css_common / host / debug.c
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 #ifndef __INLINE_DEBUG__
18 #include "debug_private.h"
19 #endif /* __INLINE_DEBUG__ */
20
21 #include "memory_access.h"
22
23 #define __INLINE_SP__
24 #include "sp.h"
25
26 #include "assert_support.h"
27
28 /* The address of the remote copy */
29 hrt_address     debug_buffer_address = (hrt_address)-1;
30 hrt_vaddress    debug_buffer_ddr_address = (hrt_vaddress)-1;
31 /* The local copy */
32 debug_data_t            debug_data;
33 debug_data_t            *debug_data_ptr = &debug_data;
34
35 void debug_buffer_init(const hrt_address addr)
36 {
37         debug_buffer_address = addr;
38
39         debug_data.head = 0;
40         debug_data.tail = 0;
41 }
42
43 void debug_buffer_ddr_init(const hrt_vaddress addr)
44 {
45         debug_buf_mode_t mode = DEBUG_BUFFER_MODE_LINEAR;
46         uint32_t enable = 1;
47         uint32_t head = 0;
48         uint32_t tail = 0;
49         /* set the ddr queue */
50         debug_buffer_ddr_address = addr;
51         mmgr_store(addr + DEBUG_DATA_BUF_MODE_DDR_ADDR,
52                                 &mode, sizeof(debug_buf_mode_t));
53         mmgr_store(addr + DEBUG_DATA_HEAD_DDR_ADDR,
54                                 &head, sizeof(uint32_t));
55         mmgr_store(addr + DEBUG_DATA_TAIL_DDR_ADDR,
56                                 &tail, sizeof(uint32_t));
57         mmgr_store(addr + DEBUG_DATA_ENABLE_DDR_ADDR,
58                                 &enable, sizeof(uint32_t));
59
60         /* set the local copy */
61         debug_data.head = 0;
62         debug_data.tail = 0;
63 }
64
65 void debug_buffer_setmode(const debug_buf_mode_t mode)
66 {
67         assert(debug_buffer_address != ((hrt_address)-1));
68
69         sp_dmem_store_uint32(SP0_ID,
70                 debug_buffer_address + DEBUG_DATA_BUF_MODE_ADDR, mode);
71 }
72