Merge tag 'drm-misc-fixes-2017-12-14' of git://anongit.freedesktop.org/drm/drm-misc
[sfrench/cifs-2.6.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / runtime / isys / src / isys_init.c
1 #ifndef ISP2401
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2015, Intel Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  */
15 #else
16 /*
17 Support for Intel Camera Imaging ISP subsystem.
18 Copyright (c) 2010 - 2015, Intel Corporation.
19
20 This program is free software; you can redistribute it and/or modify it
21 under the terms and conditions of the GNU General Public License,
22 version 2, as published by the Free Software Foundation.
23
24 This program is distributed in the hope it will be useful, but WITHOUT
25 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
26 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
27 more details.
28 */
29 #endif
30
31 #include "input_system.h"
32
33 #ifdef HAS_INPUT_SYSTEM_VERSION_2
34 #include "ia_css_isys.h"
35 #include "platform_support.h"
36
37 #ifdef USE_INPUT_SYSTEM_VERSION_2401
38 #include "isys_dma.h"           /* isys2401_dma_set_max_burst_size() */
39 #include "isys_irq.h"
40 #endif
41
42 #if defined(USE_INPUT_SYSTEM_VERSION_2)
43 input_system_error_t ia_css_isys_init(void)
44 {
45         backend_channel_cfg_t backend_ch0;
46         backend_channel_cfg_t backend_ch1;
47         target_cfg2400_t targetB;
48         target_cfg2400_t targetC;
49         uint32_t acq_mem_region_size = 24;
50         uint32_t acq_nof_mem_regions = 2;
51         input_system_error_t error = INPUT_SYSTEM_ERR_NO_ERROR;
52
53         memset(&backend_ch0, 0, sizeof(backend_channel_cfg_t));
54         memset(&backend_ch1, 0, sizeof(backend_channel_cfg_t));
55         memset(&targetB, 0, sizeof(targetB));
56         memset(&targetC, 0, sizeof(targetC));
57
58         error = input_system_configuration_reset();
59         if (error != INPUT_SYSTEM_ERR_NO_ERROR)
60                 return error;
61
62         error = input_system_csi_xmem_channel_cfg(
63                         0,                      /*ch_id                 */
64                         INPUT_SYSTEM_PORT_A,    /*port                  */
65                         backend_ch0,            /*backend_ch            */
66                         32,                     /*mem_region_size       */
67                         6,                      /*nof_mem_regions       */
68                         acq_mem_region_size,    /*acq_mem_region_size   */
69                         acq_nof_mem_regions,    /*acq_nof_mem_regions   */
70                         targetB,                /*target                */
71                         3);                     /*nof_xmem_buffers      */
72         if (error != INPUT_SYSTEM_ERR_NO_ERROR)
73                 return error;
74
75         error = input_system_csi_xmem_channel_cfg(
76                         1,                      /*ch_id                 */
77                         INPUT_SYSTEM_PORT_B,    /*port                  */
78                         backend_ch0,            /*backend_ch            */
79                         16,                     /*mem_region_size       */
80                         3,                      /*nof_mem_regions       */
81                         acq_mem_region_size,    /*acq_mem_region_size   */
82                         acq_nof_mem_regions,    /*acq_nof_mem_regions   */
83                         targetB,                /*target                */
84                         3);                     /*nof_xmem_buffers      */
85         if (error != INPUT_SYSTEM_ERR_NO_ERROR)
86                 return error;
87
88         error = input_system_csi_xmem_channel_cfg(
89                         2,                      /*ch_id                 */
90                         INPUT_SYSTEM_PORT_C,    /*port                  */
91                         backend_ch1,            /*backend_ch            */
92                         32,                     /*mem_region_size       */
93                         3,                      /*nof_mem_regions       */
94                         acq_mem_region_size,    /*acq_mem_region_size   */
95                         acq_nof_mem_regions,    /*acq_nof_mem_regions   */
96                         targetC,                /*target                */
97                         2);                     /*nof_xmem_buffers      */
98         if (error != INPUT_SYSTEM_ERR_NO_ERROR)
99                 return error;
100
101         error = input_system_configuration_commit();
102
103         return error;
104 }
105 #elif defined(USE_INPUT_SYSTEM_VERSION_2401)
106 input_system_error_t ia_css_isys_init(void)
107 {
108         input_system_error_t error = INPUT_SYSTEM_ERR_NO_ERROR;
109
110         ia_css_isys_csi_rx_lut_rmgr_init();
111         ia_css_isys_ibuf_rmgr_init();
112         ia_css_isys_dma_channel_rmgr_init();
113         ia_css_isys_stream2mmio_sid_rmgr_init();
114
115         isys2401_dma_set_max_burst_size(ISYS2401_DMA0_ID,
116                 1 /* Non Burst DMA transactions */);
117
118         /* Enable 2401 input system IRQ status for driver to retrieve */
119         isys_irqc_status_enable(ISYS_IRQ0_ID);
120         isys_irqc_status_enable(ISYS_IRQ1_ID);
121         isys_irqc_status_enable(ISYS_IRQ2_ID);
122
123         return error;
124 }
125 #endif
126
127 #if defined(USE_INPUT_SYSTEM_VERSION_2)
128 void ia_css_isys_uninit(void)
129 {
130 }
131 #elif defined(USE_INPUT_SYSTEM_VERSION_2401)
132 void ia_css_isys_uninit(void)
133 {
134         ia_css_isys_csi_rx_lut_rmgr_uninit();
135         ia_css_isys_ibuf_rmgr_uninit();
136         ia_css_isys_dma_channel_rmgr_uninit();
137         ia_css_isys_stream2mmio_sid_rmgr_uninit();
138 }
139 #endif
140
141 #endif