1f5fbb83fSMauro Carvalho Chehab// SPDX-License-Identifier: GPL-2.0
2ad85094bSMauro Carvalho Chehab/*
3ad85094bSMauro Carvalho Chehab * Support for Intel Camera Imaging ISP subsystem.
43c0538fbSMauro Carvalho Chehab * Copyright (c) 2010 - 2015, Intel Corporation.
5ad85094bSMauro Carvalho Chehab *
6ad85094bSMauro Carvalho Chehab * This program is free software; you can redistribute it and/or modify it
7ad85094bSMauro Carvalho Chehab * under the terms and conditions of the GNU General Public License,
8ad85094bSMauro Carvalho Chehab * version 2, as published by the Free Software Foundation.
9ad85094bSMauro Carvalho Chehab *
10ad85094bSMauro Carvalho Chehab * This program is distributed in the hope it will be useful, but WITHOUT
11ad85094bSMauro Carvalho Chehab * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12ad85094bSMauro Carvalho Chehab * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13ad85094bSMauro Carvalho Chehab * more details.
14ad85094bSMauro Carvalho Chehab */
15ad85094bSMauro Carvalho Chehab
16ad85094bSMauro Carvalho Chehab#include "input_system.h"
17ad85094bSMauro Carvalho Chehab
18ad85094bSMauro Carvalho Chehab#include "ia_css_isys.h"
19ad85094bSMauro Carvalho Chehab#include "platform_support.h"
20ad85094bSMauro Carvalho Chehab
21641c2292SMauro Carvalho Chehab#ifdef ISP2401
22d71dc239SMauro Carvalho Chehab#include "isys_dma_public.h"	/* isys2401_dma_set_max_burst_size() */
23ad85094bSMauro Carvalho Chehab#include "isys_irq.h"
24ad85094bSMauro Carvalho Chehab#endif
25ad85094bSMauro Carvalho Chehab
26641c2292SMauro Carvalho Chehab#if !defined(ISP2401)
2739bc26e4SMauro Carvalho Chehabinput_system_err_t ia_css_isys_init(void)
28ad85094bSMauro Carvalho Chehab{
29ad85094bSMauro Carvalho Chehab	backend_channel_cfg_t backend_ch0;
30ad85094bSMauro Carvalho Chehab	backend_channel_cfg_t backend_ch1;
31ad85094bSMauro Carvalho Chehab	target_cfg2400_t targetB;
32ad85094bSMauro Carvalho Chehab	target_cfg2400_t targetC;
33bdfe0bebSMauro Carvalho Chehab	u32 acq_mem_region_size = 24;
34bdfe0bebSMauro Carvalho Chehab	u32 acq_nof_mem_regions = 2;
3539bc26e4SMauro Carvalho Chehab	input_system_err_t error = INPUT_SYSTEM_ERR_NO_ERROR;
36ad85094bSMauro Carvalho Chehab
37ad85094bSMauro Carvalho Chehab	memset(&backend_ch0, 0, sizeof(backend_channel_cfg_t));
38ad85094bSMauro Carvalho Chehab	memset(&backend_ch1, 0, sizeof(backend_channel_cfg_t));
39ad85094bSMauro Carvalho Chehab	memset(&targetB, 0, sizeof(targetB));
40ad85094bSMauro Carvalho Chehab	memset(&targetC, 0, sizeof(targetC));
41ad85094bSMauro Carvalho Chehab
42ad85094bSMauro Carvalho Chehab	error = input_system_configuration_reset();
43ad85094bSMauro Carvalho Chehab	if (error != INPUT_SYSTEM_ERR_NO_ERROR)
44ad85094bSMauro Carvalho Chehab		return error;
45ad85094bSMauro Carvalho Chehab
46ad85094bSMauro Carvalho Chehab	error = input_system_csi_xmem_channel_cfg(
47eaa399ebSMauro Carvalho Chehab		    0,			/*ch_id                 */
48eaa399ebSMauro Carvalho Chehab		    INPUT_SYSTEM_PORT_A,	/*port                  */
49eaa399ebSMauro Carvalho Chehab		    backend_ch0,		/*backend_ch            */
50eaa399ebSMauro Carvalho Chehab		    32,			/*mem_region_size       */
51eaa399ebSMauro Carvalho Chehab		    6,			/*nof_mem_regions       */
52eaa399ebSMauro Carvalho Chehab		    acq_mem_region_size,	/*acq_mem_region_size   */
53eaa399ebSMauro Carvalho Chehab		    acq_nof_mem_regions,	/*acq_nof_mem_regions   */
54eaa399ebSMauro Carvalho Chehab		    targetB,		/*target                */
55eaa399ebSMauro Carvalho Chehab		    3);			/*nof_xmem_buffers      */
56ad85094bSMauro Carvalho Chehab	if (error != INPUT_SYSTEM_ERR_NO_ERROR)
57ad85094bSMauro Carvalho Chehab		return error;
58ad85094bSMauro Carvalho Chehab
59ad85094bSMauro Carvalho Chehab	error = input_system_csi_xmem_channel_cfg(
60eaa399ebSMauro Carvalho Chehab		    1,			/*ch_id                 */
61eaa399ebSMauro Carvalho Chehab		    INPUT_SYSTEM_PORT_B,	/*port                  */
62eaa399ebSMauro Carvalho Chehab		    backend_ch0,		/*backend_ch            */
63eaa399ebSMauro Carvalho Chehab		    16,			/*mem_region_size       */
64eaa399ebSMauro Carvalho Chehab		    3,			/*nof_mem_regions       */
65eaa399ebSMauro Carvalho Chehab		    acq_mem_region_size,	/*acq_mem_region_size   */
66eaa399ebSMauro Carvalho Chehab		    acq_nof_mem_regions,	/*acq_nof_mem_regions   */
67eaa399ebSMauro Carvalho Chehab		    targetB,		/*target                */
68eaa399ebSMauro Carvalho Chehab		    3);			/*nof_xmem_buffers      */
69ad85094bSMauro Carvalho Chehab	if (error != INPUT_SYSTEM_ERR_NO_ERROR)
70ad85094bSMauro Carvalho Chehab		return error;
71ad85094bSMauro Carvalho Chehab
72ad85094bSMauro Carvalho Chehab	error = input_system_csi_xmem_channel_cfg(
73eaa399ebSMauro Carvalho Chehab		    2,			/*ch_id                 */
74eaa399ebSMauro Carvalho Chehab		    INPUT_SYSTEM_PORT_C,	/*port                  */
75eaa399ebSMauro Carvalho Chehab		    backend_ch1,		/*backend_ch            */
76eaa399ebSMauro Carvalho Chehab		    32,			/*mem_region_size       */
77eaa399ebSMauro Carvalho Chehab		    3,			/*nof_mem_regions       */
78eaa399ebSMauro Carvalho Chehab		    acq_mem_region_size,	/*acq_mem_region_size   */
79eaa399ebSMauro Carvalho Chehab		    acq_nof_mem_regions,	/*acq_nof_mem_regions   */
80eaa399ebSMauro Carvalho Chehab		    targetC,		/*target                */
81eaa399ebSMauro Carvalho Chehab		    2);			/*nof_xmem_buffers      */
82ad85094bSMauro Carvalho Chehab	if (error != INPUT_SYSTEM_ERR_NO_ERROR)
83ad85094bSMauro Carvalho Chehab		return error;
84ad85094bSMauro Carvalho Chehab
85ad85094bSMauro Carvalho Chehab	error = input_system_configuration_commit();
86ad85094bSMauro Carvalho Chehab
87ad85094bSMauro Carvalho Chehab	return error;
88ad85094bSMauro Carvalho Chehab}
89641c2292SMauro Carvalho Chehab#elif defined(ISP2401)
9039bc26e4SMauro Carvalho Chehabinput_system_err_t ia_css_isys_init(void)
91ad85094bSMauro Carvalho Chehab{
92ad85094bSMauro Carvalho Chehab	ia_css_isys_csi_rx_lut_rmgr_init();
93ad85094bSMauro Carvalho Chehab	ia_css_isys_ibuf_rmgr_init();
94ad85094bSMauro Carvalho Chehab	ia_css_isys_dma_channel_rmgr_init();
95ad85094bSMauro Carvalho Chehab	ia_css_isys_stream2mmio_sid_rmgr_init();
96ad85094bSMauro Carvalho Chehab
97ad85094bSMauro Carvalho Chehab	isys2401_dma_set_max_burst_size(ISYS2401_DMA0_ID,
98eaa399ebSMauro Carvalho Chehab					1 /* Non Burst DMA transactions */);
99ad85094bSMauro Carvalho Chehab
100ad85094bSMauro Carvalho Chehab	/* Enable 2401 input system IRQ status for driver to retrieve */
101ad85094bSMauro Carvalho Chehab	isys_irqc_status_enable(ISYS_IRQ0_ID);
102ad85094bSMauro Carvalho Chehab	isys_irqc_status_enable(ISYS_IRQ1_ID);
103ad85094bSMauro Carvalho Chehab	isys_irqc_status_enable(ISYS_IRQ2_ID);
104ad85094bSMauro Carvalho Chehab
105ad85094bSMauro Carvalho Chehab	return INPUT_SYSTEM_ERR_NO_ERROR;
106ad85094bSMauro Carvalho Chehab}
107ad85094bSMauro Carvalho Chehab#endif
108ad85094bSMauro Carvalho Chehab
109641c2292SMauro Carvalho Chehab#if !defined(ISP2401)
110ad85094bSMauro Carvalho Chehabvoid ia_css_isys_uninit(void)
111ad85094bSMauro Carvalho Chehab{
112ad85094bSMauro Carvalho Chehab}
113641c2292SMauro Carvalho Chehab#elif defined(ISP2401)
114ad85094bSMauro Carvalho Chehabvoid ia_css_isys_uninit(void)
115ad85094bSMauro Carvalho Chehab{
116ad85094bSMauro Carvalho Chehab	ia_css_isys_csi_rx_lut_rmgr_uninit();
117ad85094bSMauro Carvalho Chehab	ia_css_isys_ibuf_rmgr_uninit();
118ad85094bSMauro Carvalho Chehab	ia_css_isys_dma_channel_rmgr_uninit();
119ad85094bSMauro Carvalho Chehab	ia_css_isys_stream2mmio_sid_rmgr_uninit();
120ad85094bSMauro Carvalho Chehab}
121ad85094bSMauro Carvalho Chehab#endif
122ad85094bSMauro Carvalho Chehab
123