1 /******************************************************************************
3 ** FILE NAME : ifxmips_mei_bsp.h
9 ** DESCRIPTION : MEI Driver
10 ** COPYRIGHT : Copyright (c) 2006
11 ** Infineon Technologies AG
12 ** Am Campeon 1-12, 85579 Neubiberg, Germany
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License as published by
16 ** the Free Software Foundation; either version 2 of the License, or
17 ** (at your option) any later version.
20 ** $Version $Date $Author $Comment
21 *******************************************************************************/
22 #ifndef _IFXMIPS_MEI_BSP_H_
23 #define _IFXMIPS_MEI_BSP_H_
25 /*** Register address offsets, relative to MEI_SPACE_ADDRESS ***/
26 #define MEI_DATA_XFR_OFFSET (0x0000)
27 #define MEI_VERSION_OFFSET (0x0004)
28 #define MEI_ARC_GP_STAT_OFFSET (0x0008)
29 #define MEI_DATA_XFR_STAT_OFFSET (0x000C)
30 #define MEI_XFR_ADDR_OFFSET (0x0010)
31 #define MEI_MAX_WAIT_OFFSET (0x0014)
32 #define MEI_TO_ARC_INT_OFFSET (0x0018)
33 #define ARC_TO_MEI_INT_OFFSET (0x001C)
34 #define ARC_TO_MEI_INT_MASK_OFFSET (0x0020)
35 #define MEI_DEBUG_WAD_OFFSET (0x0024)
36 #define MEI_DEBUG_RAD_OFFSET (0x0028)
37 #define MEI_DEBUG_DATA_OFFSET (0x002C)
38 #define MEI_DEBUG_DEC_OFFSET (0x0030)
39 #define MEI_CONFIG_OFFSET (0x0034)
40 #define MEI_RST_CONTROL_OFFSET (0x0038)
41 #define MEI_DBG_MASTER_OFFSET (0x003C)
42 #define MEI_CLK_CONTROL_OFFSET (0x0040)
43 #define MEI_BIST_CONTROL_OFFSET (0x0044)
44 #define MEI_BIST_STAT_OFFSET (0x0048)
45 #define MEI_XDATA_BASE_SH_OFFSET (0x004c)
46 #define MEI_XDATA_BASE_OFFSET (0x0050)
47 #define MEI_XMEM_BAR_BASE_OFFSET (0x0054)
48 #define MEI_XMEM_BAR0_OFFSET (0x0054)
49 #define MEI_XMEM_BAR1_OFFSET (0x0058)
50 #define MEI_XMEM_BAR2_OFFSET (0x005C)
51 #define MEI_XMEM_BAR3_OFFSET (0x0060)
52 #define MEI_XMEM_BAR4_OFFSET (0x0064)
53 #define MEI_XMEM_BAR5_OFFSET (0x0068)
54 #define MEI_XMEM_BAR6_OFFSET (0x006C))
55 #define MEI_XMEM_BAR7_OFFSET (0x0070)
56 #define MEI_XMEM_BAR8_OFFSET (0x0074)
57 #define MEI_XMEM_BAR9_OFFSET (0x0078)
58 #define MEI_XMEM_BAR10_OFFSET (0x007C)
59 #define MEI_XMEM_BAR11_OFFSET (0x0080)
60 #define MEI_XMEM_BAR12_OFFSET (0x0084)
61 #define MEI_XMEM_BAR13_OFFSET (0x0088)
62 #define MEI_XMEM_BAR14_OFFSET (0x008C)
63 #define MEI_XMEM_BAR15_OFFSET (0x0090)
64 #define MEI_XMEM_BAR16_OFFSET (0x0094)
66 #define WHILE_DELAY 20000
68 ** Define where in ME Processor's memory map the Stratify chip lives
71 #define MAXSWAPSIZE 8 * 1024 //8k *(32bits)
74 #define MSG_LENGTH 16 // x16 bits
78 #define CMV_TIMEOUT 1000 //jiffies
81 #define SDRAM_SEGMENT_SIZE (64*1024)
82 // Number of Bar registers
83 #define MAX_BAR_REGISTERS (17)
85 #define XDATA_REGISTER (15)
87 #define IFXMIPS_MEI_IOCTL_CMV_WINHOST IFX_ADSL_IOC_CMV_WINHOST
89 #define IFXMIPS_MEI_IOCTL_CMV_READ IFX_ADSL_IOC_CMV_READ
90 #define IFXMIPS_MEI_IOCTL_CMV_WRITE IFX_ADSL_IOC_CMV_WRITE
92 #define IFXMIPS_MEI_IOCTL_GET_BASE_ADDRESS IFX_ADSL_IOC_GET_BASE_ADDRESS
94 // ARC register addresss
95 #define ARC_STATUS 0x0
96 #define ARC_LP_START 0x2
97 #define ARC_LP_END 0x3
99 #define ARC_INT_MASK 0x10A
101 #define IRAM0_BASE (0x00000)
102 #define IRAM1_BASE (0x04000)
103 #define BRAM_BASE (0x0A000)
105 #define ADSL_BASE (0x20000)
106 #define CRI_BASE (ADSL_BASE + 0x11F00)
107 #define CRI_CCR0 (CRI_BASE + 0x00)
108 #define CRI_RST (CRI_BASE + 0x04*4)
109 #define ADSL_DILV_BASE (ADSL_BASE+0x20000)
112 #define IRAM0_ADDR_BIT_MASK 0xFFF
113 #define IRAM1_ADDR_BIT_MASK 0xFFF
114 #define BRAM_ADDR_BIT_MASK 0xFFF
115 #define RX_DILV_ADDR_BIT_MASK 0x1FFF
117 /*** Bit definitions ***/
154 // CRI_CCR0 Register definitions
155 #define CLK_2M_MODE_ENABLE BIT6
156 #define ACL_CLK_MODE_ENABLE BIT4
157 #define FDF_CLK_MODE_ENABLE BIT2
158 #define STM_CLK_MODE_ENABLE BIT0
160 // CRI_RST Register definitions
161 #define FDF_SRST BIT3
162 #define MTE_SRST BIT2
163 #define FCI_SRST BIT1
164 #define AAI_SRST BIT0
166 // MEI_TO_ARC_INTERRUPT Register definitions
167 #define MEI_TO_ARC_INT1 BIT3
168 #define MEI_TO_ARC_INT0 BIT2
169 #define MEI_TO_ARC_CS_DONE BIT1 //need to check
170 #define MEI_TO_ARC_MSGAV BIT0
172 // ARC_TO_MEI_INTERRUPT Register definitions
173 #define ARC_TO_MEI_INT1 BIT8
174 #define ARC_TO_MEI_INT0 BIT7
175 #define ARC_TO_MEI_CS_REQ BIT6
176 #define ARC_TO_MEI_DBG_DONE BIT5
177 #define ARC_TO_MEI_MSGACK BIT4
178 #define ARC_TO_MEI_NO_ACCESS BIT3
179 #define ARC_TO_MEI_CHECK_AAITX BIT2
180 #define ARC_TO_MEI_CHECK_AAIRX BIT1
181 #define ARC_TO_MEI_MSGAV BIT0
183 // ARC_TO_MEI_INTERRUPT_MASK Register definitions
184 #define GP_INT1_EN BIT8
185 #define GP_INT0_EN BIT7
186 #define CS_REQ_EN BIT6
187 #define DBG_DONE_EN BIT5
188 #define MSGACK_EN BIT4
189 #define NO_ACC_EN BIT3
190 #define AAITX_EN BIT2
191 #define AAIRX_EN BIT1
192 #define MSGAV_EN BIT0
194 #define MEI_SOFT_RESET BIT0
196 #define HOST_MSTR BIT0
198 #define JTAG_MASTER_MODE 0x0
199 #define MEI_MASTER_MODE HOST_MSTR
201 // MEI_DEBUG_DECODE Register definitions
202 #define MEI_DEBUG_DEC_MASK (0x3)
203 #define MEI_DEBUG_DEC_AUX_MASK (0x0)
204 #define MEI_DEBUG_DEC_DMP1_MASK (0x1)
205 #define MEI_DEBUG_DEC_DMP2_MASK (0x2)
206 #define MEI_DEBUG_DEC_CORE_MASK (0x3)
208 #define AUX_STATUS (0x0)
209 // ARC_TO_MEI_MAILBOX[11] is a special location used to indicate
210 // page swap requests.
211 #define MEI_TO_ARC_MAILBOX (0xDFD0)
212 #define MEI_TO_ARC_MAILBOXR (MEI_TO_ARC_MAILBOX + 0x2C)
214 #define ARC_TO_MEI_MAILBOX (0xDFA0)
215 #define ARC_MEI_MAILBOXR (ARC_TO_MEI_MAILBOX + 0x2C)
217 // Codeswap request messages are indicated by setting BIT31
218 #define OMB_CODESWAP_MESSAGE_MSG_TYPE_MASK (0x80000000)
220 // Clear Eoc messages received are indicated by setting BIT17
221 #define OMB_CLEAREOC_INTERRUPT_CODE (0x00020000)
226 // Page must be loaded at boot time if size field has BIT31 set
227 #define BOOT_FLAG (BIT31)
228 #define BOOT_FLAG_MASK ~BOOT_FLAG
230 #define FREE_RELOAD 1
231 #define FREE_SHOWTIME 2
235 #define IFXMIPS_WRITE_REGISTER_L(data,addr) do{ *((volatile u32*)(addr)) = (u32)(data);} while (0)
236 #define IFXMIPS_READ_REGISTER_L(addr) (*((volatile u32*)(addr)))
237 #define SET_BIT(reg, mask) reg |= (mask)
238 #define CLEAR_BIT(reg, mask) reg &= (~mask)
239 #define CLEAR_BITS(reg, mask) CLEAR_BIT(reg, mask)
240 #define SET_BITS(reg, mask) SET_BIT(reg, mask)
241 #define SET_BITFIELD(reg, mask, off, val) {reg &= (~mask); reg |= (val << off);}
243 #define ALIGN_SIZE ( 1L<<10 ) //1K size align
244 #define MEM_ALIGN(addr) (((addr) + ALIGN_SIZE - 1) & ~ (ALIGN_SIZE -1) )
247 #define MEI_HALF_WORD_SWAP(data) {data = ((data & 0xffff)<<16) + ((data & 0xffff0000)>>16);}
248 #define MEI_BYTE_SWAP(data) {data = ((data & 0xff)<<24) + ((data & 0xff00)<<8)+ ((data & 0xff0000)>>8)+ ((data & 0xff000000)>>24);}
250 // Swap page header describes size in 32-bit words, load location, and image offset
251 // for program and/or data segments
252 typedef struct _arc_swp_page_hdr
{
253 u32 p_offset
; //Offset bytes of progseg from beginning of image
254 u32 p_dest
; //Destination addr of progseg on processor
255 u32 p_size
; //Size in 32-bitwords of program segment
256 u32 d_offset
; //Offset bytes of dataseg from beginning of image
257 u32 d_dest
; //Destination addr of dataseg on processor
258 u32 d_size
; //Size in 32-bitwords of data segment
264 #define GET_PROG 0 // Flag used for program mem segment
265 #define GET_DATA 1 // Flag used for data mem segment
267 // Image header contains size of image, checksum for image, and count of
268 // page headers. Following that are 'count' page headers followed by
269 // the code and/or data segments to be loaded
270 typedef struct _arc_img_hdr
{
271 u32 size
; // Size of binary image in bytes
272 u32 checksum
; // Checksum for image
273 u32 count
; // Count of swp pages in image
274 ARC_SWP_PAGE_HDR page
[1]; // Should be "count" pages - '1' to make compiler happy
277 typedef struct smmu_mem_info
{
281 unsigned char *address
;
282 unsigned char *org_address
;
285 typedef struct ifxmips_mei_device_private
{
290 // Mei to ARC CMV count, reply count, ARC Indicator count
294 unsigned long image_size
;
296 u16 Recent_indicator
[MSG_LENGTH
];
298 u16 CMV_RxMsg
[MSG_LENGTH
] __attribute__ ((aligned (4)));
300 smmu_mem_info_t adsl_mem_info
[MAX_BAR_REGISTERS
];
301 ARC_IMG_HDR
*img_hdr
;
302 // to wait for arc cmv reply, sleep on wait_queue_arcmsgav;
303 wait_queue_head_t wait_queue_arcmsgav
;
304 wait_queue_head_t wait_queue_modemready
;
305 MEI_mutex_t mei_cmv_sema
;
306 } ifxmips_mei_device_private_t
;
308 #endif //_IFXMIPS_MEI_BSP_H_