xref: /linux/drivers/staging/media/atomisp/pci/runtime/isys/src/isys_init.c (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2010 - 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 
16 #include "input_system.h"
17 
18 #include "ia_css_isys.h"
19 #include "platform_support.h"
20 
21 #include "isys_dma_public.h"	/* isys2401_dma_set_max_burst_size() */
22 #include "isys_irq.h"
23 
ia_css_isys_2400_init(void)24 static input_system_err_t ia_css_isys_2400_init(void)
25 {
26 	backend_channel_cfg_t backend_ch0;
27 	backend_channel_cfg_t backend_ch1;
28 	target_cfg2400_t targetB;
29 	target_cfg2400_t targetC;
30 	u32 acq_mem_region_size = 24;
31 	u32 acq_nof_mem_regions = 2;
32 	input_system_err_t error = INPUT_SYSTEM_ERR_NO_ERROR;
33 
34 	memset(&backend_ch0, 0, sizeof(backend_channel_cfg_t));
35 	memset(&backend_ch1, 0, sizeof(backend_channel_cfg_t));
36 	memset(&targetB, 0, sizeof(targetB));
37 	memset(&targetC, 0, sizeof(targetC));
38 
39 	error = input_system_configuration_reset();
40 	if (error != INPUT_SYSTEM_ERR_NO_ERROR)
41 		return error;
42 
43 	error = input_system_csi_xmem_channel_cfg(
44 		    0,			/*ch_id                 */
45 		    INPUT_SYSTEM_PORT_A,	/*port                  */
46 		    backend_ch0,		/*backend_ch            */
47 		    32,			/*mem_region_size       */
48 		    6,			/*nof_mem_regions       */
49 		    acq_mem_region_size,	/*acq_mem_region_size   */
50 		    acq_nof_mem_regions,	/*acq_nof_mem_regions   */
51 		    targetB,		/*target                */
52 		    3);			/*nof_xmem_buffers      */
53 	if (error != INPUT_SYSTEM_ERR_NO_ERROR)
54 		return error;
55 
56 	error = input_system_csi_xmem_channel_cfg(
57 		    1,			/*ch_id                 */
58 		    INPUT_SYSTEM_PORT_B,	/*port                  */
59 		    backend_ch0,		/*backend_ch            */
60 		    16,			/*mem_region_size       */
61 		    3,			/*nof_mem_regions       */
62 		    acq_mem_region_size,	/*acq_mem_region_size   */
63 		    acq_nof_mem_regions,	/*acq_nof_mem_regions   */
64 		    targetB,		/*target                */
65 		    3);			/*nof_xmem_buffers      */
66 	if (error != INPUT_SYSTEM_ERR_NO_ERROR)
67 		return error;
68 
69 	error = input_system_csi_xmem_channel_cfg(
70 		    2,			/*ch_id                 */
71 		    INPUT_SYSTEM_PORT_C,	/*port                  */
72 		    backend_ch1,		/*backend_ch            */
73 		    32,			/*mem_region_size       */
74 		    3,			/*nof_mem_regions       */
75 		    acq_mem_region_size,	/*acq_mem_region_size   */
76 		    acq_nof_mem_regions,	/*acq_nof_mem_regions   */
77 		    targetC,		/*target                */
78 		    2);			/*nof_xmem_buffers      */
79 	if (error != INPUT_SYSTEM_ERR_NO_ERROR)
80 		return error;
81 
82 	error = input_system_configuration_commit();
83 
84 	return error;
85 }
86 
ia_css_isys_2401_init(void)87 static input_system_err_t ia_css_isys_2401_init(void)
88 {
89 	ia_css_isys_csi_rx_lut_rmgr_init();
90 	ia_css_isys_ibuf_rmgr_init();
91 	ia_css_isys_dma_channel_rmgr_init();
92 	ia_css_isys_stream2mmio_sid_rmgr_init();
93 
94 	isys2401_dma_set_max_burst_size(ISYS2401_DMA0_ID,
95 					1 /* Non Burst DMA transactions */);
96 
97 	/* Enable 2401 input system IRQ status for driver to retrieve */
98 	isys_irqc_status_enable(ISYS_IRQ0_ID);
99 	isys_irqc_status_enable(ISYS_IRQ1_ID);
100 	isys_irqc_status_enable(ISYS_IRQ2_ID);
101 
102 	return INPUT_SYSTEM_ERR_NO_ERROR;
103 }
104 
ia_css_isys_init(void)105 input_system_err_t ia_css_isys_init(void)
106 {
107 	if (IS_ISP2401)
108 		return ia_css_isys_2401_init();
109 
110 	return ia_css_isys_2400_init();
111 }
112 
ia_css_isys_uninit(void)113 void ia_css_isys_uninit(void)
114 {
115 	if (IS_ISP2401) {
116 		ia_css_isys_csi_rx_lut_rmgr_uninit();
117 		ia_css_isys_ibuf_rmgr_uninit();
118 		ia_css_isys_dma_channel_rmgr_uninit();
119 		ia_css_isys_stream2mmio_sid_rmgr_uninit();
120 	}
121 }
122