GNU Linux-libre 4.14.313-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / atomisp-regs.h
1 /*
2  * Support for Medifield PNW Camera Imaging ISP subsystem.
3  *
4  * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License version
8  * 2 as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  * 02110-1301, USA.
19  *
20  */
21
22 #ifndef ATOMISP_REGS_H
23 #define ATOMISP_REGS_H
24
25 /* common register definitions */
26 #define PUNIT_PORT              0x04
27 #define CCK_PORT                0x14
28
29 #define PCICMDSTS               0x01
30 #define INTR                    0x0f
31 #define MSI_CAPID               0x24
32 #define MSI_ADDRESS             0x25
33 #define MSI_DATA                0x26
34 #define INTR_CTL                0x27
35
36 #define PCI_MSI_CAPID           0x90
37 #define PCI_MSI_ADDR            0x94
38 #define PCI_MSI_DATA            0x98
39 #define PCI_INTERRUPT_CTRL      0x9C
40 #define PCI_I_CONTROL           0xfc
41
42 /* MRFLD specific register definitions */
43 #define MRFLD_CSI_AFE           0x39
44 #define MRFLD_CSI_CONTROL       0x3a
45 #define MRFLD_CSI_RCOMP         0x3d
46
47 #define MRFLD_PCI_PMCS          0x84
48 #define MRFLD_PCI_CSI_ACCESS_CTRL_VIOL  0xd4
49 #define MRFLD_PCI_CSI_AFE_HS_CONTROL    0xdc
50 #define MRFLD_PCI_CSI_AFE_RCOMP_CONTROL 0xe0
51 #define MRFLD_PCI_CSI_CONTROL           0xe8
52 #define MRFLD_PCI_CSI_AFE_TRIM_CONTROL  0xe4
53 #define MRFLD_PCI_CSI_DEADLINE_CONTROL  0xec
54 #define MRFLD_PCI_CSI_RCOMP_CONTROL     0xf4
55
56 /* Select Arasan (legacy)/Intel input system */
57 #define MRFLD_PCI_CSI_CONTROL_PARPATHEN BIT(24)
58 /* Enable CSI interface (ANN B0/K0) */
59 #define MRFLD_PCI_CSI_CONTROL_CSI_READY BIT(25)
60
61 /*
62  * Enables the combining of adjacent 32-byte read requests to the same
63  * cache line. When cleared, each 32-byte read request is sent as a
64  * separate request on the IB interface.
65  */
66 #define MRFLD_PCI_I_CONTROL_ENABLE_READ_COMBINING       0x1
67
68 /*
69  * Register: MRFLD_PCI_CSI_RCOMP_CONTROL
70  * If cleared, the high speed clock going to the digital logic is gated when
71  * RCOMP update is happening. The clock is gated for a minimum of 100 nsec.
72  * If this bit is set, then the high speed clock is not gated during the
73  * update cycle.
74  */
75 #define MRFLD_PCI_CSI_HS_OVR_CLK_GATE_ON_UPDATE         0x800000
76
77 /*
78  * Enables the combining of adjacent 32-byte write requests to the same
79  * cache line. When cleared, each 32-byte write request is sent as a
80  * separate request on the IB interface.
81  */
82 #define MRFLD_PCI_I_CONTROL_ENABLE_WRITE_COMBINING      0x2
83
84 #define MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK             0xc
85
86 #define MRFLD_PCI_CSI1_HSRXCLKTRIM              0x2
87 #define MRFLD_PCI_CSI1_HSRXCLKTRIM_SHIFT        16
88 #define MRFLD_PCI_CSI2_HSRXCLKTRIM              0x3
89 #define MRFLD_PCI_CSI2_HSRXCLKTRIM_SHIFT        24
90 #define MRFLD_PCI_CSI3_HSRXCLKTRIM              0x2
91 #define MRFLD_PCI_CSI3_HSRXCLKTRIM_SHIFT        28
92 #define MRFLD_PCI_CSI_HSRXCLKTRIM_MASK          0xf
93
94 /*
95  * This register is IUINT MMIO register, it is used to select the CSI
96  * receiver backend.
97  * 1: SH CSI backend
98  * 0: Arasan CSI backend
99  */
100 #define MRFLD_CSI_RECEIVER_SELECTION_REG       0x8081c
101
102 #define MRFLD_INTR_CLEAR_REG                   0x50c
103 #define MRFLD_INTR_STATUS_REG                  0x508
104 #define MRFLD_INTR_ENABLE_REG                  0x510
105
106 #define MRFLD_MAX_ZOOM_FACTOR   1024
107
108 /* MRFLD ISP POWER related */
109 #define MRFLD_ISPSSPM0         0x39
110 #define MRFLD_ISPSSPM0_ISPSSC_OFFSET   0
111 #define MRFLD_ISPSSPM0_ISPSSS_OFFSET   24
112 #define MRFLD_ISPSSPM0_ISPSSC_MASK     0x3
113 #define MRFLD_ISPSSPM0_IUNIT_POWER_ON  0
114 #define MRFLD_ISPSSPM0_IUNIT_POWER_OFF 0x3
115 #define MRFLD_ISPSSDVFS                 0x13F
116 #define MRFLD_BIT0                      0x0001
117 #define MRFLD_BIT1                      0x0002
118
119 /* MRFLD CSI lane configuration related */
120 #define MRFLD_PORT_CONFIG_NUM  8
121 #define MRFLD_PORT_NUM         3
122 #define MRFLD_PORT1_ENABLE_SHIFT       0
123 #define MRFLD_PORT2_ENABLE_SHIFT       1
124 #define MRFLD_PORT3_ENABLE_SHIFT       2
125 #define MRFLD_PORT1_LANES_SHIFT        3
126 #define MRFLD_PORT2_LANES_SHIFT        7
127 #define MRFLD_PORT3_LANES_SHIFT        8
128 #define MRFLD_PORT_CONFIG_MASK 0x000f03ff
129 #define MRFLD_PORT_CONFIGCODE_SHIFT    16
130 #define MRFLD_ALL_CSI_PORTS_OFF_MASK   0x7
131
132 #define CHV_PORT3_LANES_SHIFT           9
133 #define CHV_PORT_CONFIG_MASK            0x1f07ff
134
135 #define ISPSSPM1                                0x3a
136 #define ISP_FREQ_STAT_MASK                      (0x1f << ISP_FREQ_STAT_OFFSET)
137 #define ISP_REQ_FREQ_MASK                       0x1f
138 #define ISP_FREQ_VALID_MASK                     (0x1 << ISP_FREQ_VALID_OFFSET)
139 #define ISP_FREQ_STAT_OFFSET                    0x18
140 #define ISP_REQ_GUAR_FREQ_OFFSET                0x8
141 #define ISP_REQ_FREQ_OFFSET                     0x0
142 #define ISP_FREQ_VALID_OFFSET                   0x7
143 #define ISP_FREQ_RULE_ANY                       0x0
144
145 #define ISP_FREQ_457MHZ                         0x1C9
146 #define ISP_FREQ_400MHZ                         0x190
147 #define ISP_FREQ_356MHZ                         0x164
148 #define ISP_FREQ_320MHZ                         0x140
149 #define ISP_FREQ_266MHZ                         0x10a
150 #define ISP_FREQ_200MHZ                         0xc8
151 #define ISP_FREQ_100MHZ                         0x64
152
153 #define HPLL_FREQ_800MHZ                        0x320
154 #define HPLL_FREQ_1600MHZ                       0x640
155 #define HPLL_FREQ_2000MHZ                       0x7D0
156
157 #define CCK_FUSE_REG_0                  0x08
158 #define CCK_FUSE_HPLL_FREQ_MASK         0x03
159
160 #if defined(ISP2401)
161 #define ISP_FREQ_MAX    ISP_FREQ_320MHZ
162 #else
163 #define ISP_FREQ_MAX    ISP_FREQ_400MHZ
164 #endif
165
166 /* ISP2401 CSI2+ receiver delay settings */
167 #define CSI2_PORT_A_BASE                                        0xC0000
168 #define CSI2_PORT_B_BASE                                        0xC2000
169 #define CSI2_PORT_C_BASE                                        0xC4000
170
171 #define CSI2_LANE_CL_BASE                                       0x418
172 #define CSI2_LANE_D0_BASE                                       0x420
173 #define CSI2_LANE_D1_BASE                                       0x428
174 #define CSI2_LANE_D2_BASE                                       0x430
175 #define CSI2_LANE_D3_BASE                                       0x438
176
177 #define CSI2_REG_RX_CSI_DLY_CNT_TERMEN                          0
178 #define CSI2_REG_RX_CSI_DLY_CNT_SETTLE                          0x4
179
180 #define CSI2_PORT_A_RX_CSI_DLY_CNT_TERMEN_CLANE                 0xC0418
181 #define CSI2_PORT_A_RX_CSI_DLY_CNT_SETTLE_CLANE                 0xC041C
182 #define CSI2_PORT_A_RX_CSI_DLY_CNT_TERMEN_DLANE0                0xC0420
183 #define CSI2_PORT_A_RX_CSI_DLY_CNT_SETTLE_DLANE0                0xC0424
184 #define CSI2_PORT_A_RX_CSI_DLY_CNT_TERMEN_DLANE1                0xC0428
185 #define CSI2_PORT_A_RX_CSI_DLY_CNT_SETTLE_DLANE1                0xC042C
186 #define CSI2_PORT_A_RX_CSI_DLY_CNT_TERMEN_DLANE2                0xC0430
187 #define CSI2_PORT_A_RX_CSI_DLY_CNT_SETTLE_DLANE2                0xC0434
188 #define CSI2_PORT_A_RX_CSI_DLY_CNT_TERMEN_DLANE3                0xC0438
189 #define CSI2_PORT_A_RX_CSI_DLY_CNT_SETTLE_DLANE3                0xC043C
190
191 #define CSI2_PORT_B_RX_CSI_DLY_CNT_TERMEN_CLANE                 0xC2418
192 #define CSI2_PORT_B_RX_CSI_DLY_CNT_SETTLE_CLANE                 0xC241C
193 #define CSI2_PORT_B_RX_CSI_DLY_CNT_TERMEN_DLANE0                0xC2420
194 #define CSI2_PORT_B_RX_CSI_DLY_CNT_SETTLE_DLANE0                0xC2424
195 #define CSI2_PORT_B_RX_CSI_DLY_CNT_TERMEN_DLANE1                0xC2428
196 #define CSI2_PORT_B_RX_CSI_DLY_CNT_SETTLE_DLANE1                0xC242C
197
198 #define CSI2_PORT_C_RX_CSI_DLY_CNT_TERMEN_CLANE                 0xC4418
199 #define CSI2_PORT_C_RX_CSI_DLY_CNT_SETTLE_CLANE                 0xC441C
200 #define CSI2_PORT_C_RX_CSI_DLY_CNT_TERMEN_DLANE0                0xC4420
201 #define CSI2_PORT_C_RX_CSI_DLY_CNT_SETTLE_DLANE0                0xC4424
202 #define CSI2_PORT_C_RX_CSI_DLY_CNT_TERMEN_DLANE1                0xC4428
203 #define CSI2_PORT_C_RX_CSI_DLY_CNT_SETTLE_DLANE1                0xC442C
204
205 #define DMA_BURST_SIZE_REG                                      0xCD408
206
207 #define ISP_DFS_TRY_TIMES       2
208
209 #endif /* ATOMISP_REGS_H */