1 /******************************************************************************
4 Infineon Technologies AG
5 Am Campeon 1-12; 81726 Munich, Germany
7 For licensing information, see the file 'LICENSE' in the root folder of
10 ******************************************************************************/
13 \defgroup AMAZON_S_MEI Amazon-S MEI Driver Module
14 \brief Amazon-S MEI driver module
18 \defgroup Internal Compile Parametere
20 \brief exported functions for other driver use
24 \file amazon_s_mei_bsp.c
26 \brief Amazon-S MEI driver file
29 #include <linux/kernel.h>
30 #include <linux/module.h>
31 #include <linux/version.h>
32 #include <linux/utsrelease.h>
33 #include <linux/types.h>
36 #include <linux/errno.h>
37 #include <linux/interrupt.h>
38 #include <linux/netdevice.h>
39 #include <linux/etherdevice.h>
40 #include <linux/proc_fs.h>
41 #include <linux/init.h>
42 #include <linux/ioport.h>
43 #include <linux/delay.h>
44 #include <asm/uaccess.h>
45 #include <asm/hardirq.h>
46 #include <asm/ifx/ifx_regs.h>
47 #include <asm/ifx/irq.h>
48 #include <asm/ifx/ifx_gpio.h>
49 //#include <asm/ifx/ifx_led.h>
50 #include <asm/ifx/ifx_pmu.h>
51 #include <asm/ifx/ifx_atm.h>
53 #include "ifxmips_mei_interface.h"
55 #define IFXMIPS_RCU_RST IFX_RCU_RST_REQ
56 #define IFXMIPS_RCU_RST_REQ_ARC_JTAG IFX_RCU_RST_REQ_ARC_JTAG
57 #define IFXMIPS_RCU_RST_REQ_DFE IFX_RCU_RST_REQ_DFE
58 #define IFXMIPS_RCU_RST_REQ_AFE IFX_RCU_RST_REQ_AFE
59 #define IFXMIPS_FUSE_BASE_ADDR IFX_FUSE_BASE_ADDR
60 #define IFXMIPS_ICU_IM0_IER IFX_ICU_IM0_IER
61 #define IFXMIPS_ICU_IM2_IER IFX_ICU_IM2_IER
62 #define IFXMIPS_MEI_INT IFX_MEI_INT
63 #define IFXMIPS_MEI_DYING_GASP_INT IFX_MEI_DYING_GASP_INT
64 #define IFXMIPS_MEI_BASE_ADDR IFX_MEI_SPACE_ACCESS
65 #define IFXMIPS_PMU_PWDCR IFX_PMU_PWDCR
66 #define IFXMIPS_MPS_CHIPID IFX_MPS_CHIPID
68 #define ifxmips_port_reserve_pin ifx_gpio_pin_reserve
69 #define ifxmips_port_set_dir_in ifx_gpio_dir_in_set
70 #define ifxmips_port_clear_altsel0 ifx_gpio_altsel0_set
71 #define ifxmips_port_clear_altsel1 ifx_gpio_altsel1_clear
72 #define ifxmips_port_set_open_drain ifx_gpio_open_drain_clear
73 #define ifxmips_port_free_pin ifx_gpio_pin_free
74 #define ifxmips_mask_and_ack_irq bsp_mask_and_ack_irq
75 #define IFXMIPS_MPS_CHIPID_VERSION_GET IFX_MCD_CHIPID_VERSION_GET
76 #define ifxmips_r32(reg) __raw_readl(reg)
77 #define ifxmips_w32(val, reg) __raw_writel(val, reg)
78 #define ifxmips_w32_mask(clear, set, reg) ifxmips_w32((ifxmips_r32(reg) & ~clear) | set, reg)
80 #define IFX_MEI_EMSG(fmt, args...) printk(KERN_ERR "[%s %d]: " fmt,__FUNCTION__, __LINE__, ## args)
81 #define IFX_MEI_DMSG(fmt, args...) printk(KERN_INFO "[%s %d]: " fmt,__FUNCTION__, __LINE__, ## args)
83 #ifdef CONFIG_IFXMIPS_MEI_FW_LOOPBACK
84 //#define DFE_MEM_TEST
85 //#define DFE_PING_TEST
86 #define DFE_ATM_LOOPBACK
89 #include "dsp_xmem_arb_rand_em.h"
93 #include "aai_mem_test.h"
96 #ifdef DFE_ATM_LOOPBACK
97 #include <asm/ifxmips/ifxmips_mei_fw_loopback.h>
100 void dfe_loopback_irq_handler (DSL_DEV_Device_t
*pDev
);
102 #endif //CONFIG_AMAZON_S_MEI_FW_LOOPBACK
104 DSL_DEV_Version_t bsp_mei_version
= {
109 DSL_DEV_HwVersion_t bsp_chip_info
;
111 #define IFX_MEI_DEVNAME "ifx_mei"
112 #define BSP_MAX_DEVICES 1
114 DSL_DEV_MeiError_t
DSL_BSP_FWDownload (DSL_DEV_Device_t
*, const char *, unsigned long, long *, long *);
115 DSL_DEV_MeiError_t
DSL_BSP_Showtime (DSL_DEV_Device_t
*, DSL_uint32_t
, DSL_uint32_t
);
116 DSL_DEV_MeiError_t
DSL_BSP_AdslLedInit (DSL_DEV_Device_t
*, DSL_DEV_LedId_t
, DSL_DEV_LedType_t
, DSL_DEV_LedHandler_t
);
117 //DSL_DEV_MeiError_t DSL_BSP_AdslLedSet (DSL_DEV_Device_t *, DSL_DEV_LedId_t, DSL_DEV_LedMode_t);
118 DSL_DEV_MeiError_t
DSL_BSP_MemoryDebugAccess (DSL_DEV_Device_t
*, DSL_BSP_MemoryAccessType_t
, DSL_uint32_t
, DSL_uint32_t
*, DSL_uint32_t
);
119 DSL_DEV_MeiError_t
DSL_BSP_SendCMV (DSL_DEV_Device_t
*, u16
*, int, u16
*);
121 int DSL_BSP_KernelIoctls (DSL_DEV_Device_t
*, unsigned int, unsigned long);
123 static DSL_DEV_MeiError_t
IFX_MEI_RunAdslModem (DSL_DEV_Device_t
*);
124 static DSL_DEV_MeiError_t
IFX_MEI_CpuModeSet (DSL_DEV_Device_t
*, DSL_DEV_CpuMode_t
);
125 static DSL_DEV_MeiError_t
IFX_MEI_DownloadBootCode (DSL_DEV_Device_t
*);
126 static DSL_DEV_MeiError_t
IFX_MEI_ArcJtagEnable (DSL_DEV_Device_t
*, int);
127 static DSL_DEV_MeiError_t
IFX_MEI_AdslMailboxIRQEnable (DSL_DEV_Device_t
*, int);
129 static int IFX_MEI_GetPage (DSL_DEV_Device_t
*, u32
, u32
, u32
, u32
*, u32
*);
130 static int IFX_MEI_BarUpdate (DSL_DEV_Device_t
*, int);
132 static ssize_t
IFX_MEI_Write (DSL_DRV_file_t
*, const char *, size_t, loff_t
*);
133 static int IFX_MEI_UserIoctls (DSL_DRV_inode_t
*, DSL_DRV_file_t
*, unsigned int, unsigned long);
134 static int IFX_MEI_Open (DSL_DRV_inode_t
*, DSL_DRV_file_t
*);
135 static int IFX_MEI_Release (DSL_DRV_inode_t
*, DSL_DRV_file_t
*);
137 void AMAZON_SE_MEI_ARC_MUX_Test(void);
139 #ifdef CONFIG_PROC_FS
140 static int IFX_MEI_ProcRead (struct file
*, char *, size_t, loff_t
*);
141 static ssize_t
IFX_MEI_ProcWrite (struct file
*, const char *, size_t, loff_t
*);
143 #define PROC_ITEMS 11
144 #define MEI_DIRNAME "ifxmips_mei"
146 static struct proc_dir_entry
*meidir
;
147 static struct file_operations IFX_MEI_ProcOperations
= {
148 read
:IFX_MEI_ProcRead
,
149 write
:IFX_MEI_ProcWrite
,
151 static reg_entry_t regs
[BSP_MAX_DEVICES
][PROC_ITEMS
]; //total items to be monitored by /proc/mei
152 #define NUM_OF_REG_ENTRY (sizeof(regs[0])/sizeof(reg_entry_t))
153 #endif //CONFIG_PROC_FS
155 void IFX_MEI_ARC_MUX_Test(void);
157 static int adsl_dummy_ledcallback(void);
159 int (*ifx_mei_atm_showtime_enter
)(struct port_cell_info
*, void *) = NULL
;
160 EXPORT_SYMBOL(ifx_mei_atm_showtime_enter
);
162 int (*ifx_mei_atm_showtime_exit
)(void) = NULL
;
163 EXPORT_SYMBOL(ifx_mei_atm_showtime_exit
);
165 static int (*g_adsl_ledcallback
)(void) = adsl_dummy_ledcallback
;
167 static unsigned int g_tx_link_rate
[2] = {0};
169 static void *g_xdata_addr
= NULL
;
171 static u32
*mei_arc_swap_buff
= NULL
; // holding swap pages
173 extern void ifxmips_mask_and_ack_irq(unsigned int irq_nr
);
174 #define MEI_MASK_AND_ACK_IRQ ifxmips_mask_and_ack_irq
176 static int dev_major
= 105;
178 static struct file_operations bsp_mei_operations
= {
181 release
:IFX_MEI_Release
,
183 ioctl
:IFX_MEI_UserIoctls
,
186 static DSL_DEV_Device_t dsl_devices
[BSP_MAX_DEVICES
];
188 static ifx_mei_device_private_t
189 sDanube_Mei_Private
[BSP_MAX_DEVICES
];
191 static DSL_BSP_EventCallBack_t dsl_bsp_event_callback
[DSL_BSP_CB_LAST
+ 1];
194 * Write a value to register
195 * This function writes a value to danube register
197 * \param ul_address The address to write
198 * \param ul_data The value to write
202 IFX_MEI_LongWordWrite (u32 ul_address
, u32 ul_data
)
204 IFX_MEI_WRITE_REGISTER_L (ul_data
, ul_address
);
210 * Write a value to register
211 * This function writes a value to danube register
213 * \param pDev the device pointer
214 * \param ul_address The address to write
215 * \param ul_data The value to write
219 IFX_MEI_LongWordWriteOffset (DSL_DEV_Device_t
* pDev
, u32 ul_address
,
222 IFX_MEI_WRITE_REGISTER_L (ul_data
, pDev
->base_address
+ ul_address
);
228 * Read the danube register
229 * This function read the value from danube register
231 * \param ul_address The address to write
232 * \param pul_data Pointer to the data
236 IFX_MEI_LongWordRead (u32 ul_address
, u32
* pul_data
)
238 *pul_data
= IFX_MEI_READ_REGISTER_L (ul_address
);
244 * Read the danube register
245 * This function read the value from danube register
247 * \param pDev the device pointer
248 * \param ul_address The address to write
249 * \param pul_data Pointer to the data
253 IFX_MEI_LongWordReadOffset (DSL_DEV_Device_t
* pDev
, u32 ul_address
,
256 *pul_data
= IFX_MEI_READ_REGISTER_L (pDev
->base_address
+ ul_address
);
262 * Write several DWORD datas to ARC memory via ARC DMA interface
263 * This function writes several DWORD datas to ARC memory via DMA interface.
265 * \param pDev the device pointer
266 * \param destaddr The address to write
267 * \param databuff Pointer to the data buffer
268 * \param databuffsize Number of DWORDs to write
269 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
272 static DSL_DEV_MeiError_t
273 IFX_MEI_DMAWrite (DSL_DEV_Device_t
* pDev
, u32 destaddr
,
274 u32
* databuff
, u32 databuffsize
)
280 return DSL_DEV_MEI_ERR_FAILURE
;
282 // Set the write transfer address
283 IFX_MEI_LongWordWriteOffset (pDev
, ME_DX_AD
, destaddr
);
285 // Write the data pushed across DMA
286 while (databuffsize
--) {
288 if (destaddr
== MEI_TO_ARC_MAILBOX
)
289 MEI_HALF_WORD_SWAP (temp
);
290 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_DX_DATA
, temp
);
294 return DSL_DEV_MEI_ERR_SUCCESS
;
299 * Read several DWORD datas from ARC memory via ARC DMA interface
300 * This function reads several DWORD datas from ARC memory via DMA interface.
302 * \param pDev the device pointer
303 * \param srcaddr The address to read
304 * \param databuff Pointer to the data buffer
305 * \param databuffsize Number of DWORDs to read
306 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
309 static DSL_DEV_MeiError_t
310 IFX_MEI_DMARead (DSL_DEV_Device_t
* pDev
, u32 srcaddr
, u32
* databuff
,
317 return DSL_DEV_MEI_ERR_FAILURE
;
319 // Set the read transfer address
320 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_DX_AD
, srcaddr
);
322 // Read the data popped across DMA
323 while (databuffsize
--) {
324 IFX_MEI_LongWordReadOffset (pDev
, (u32
) ME_DX_DATA
, &temp
);
325 if (databuff
== (u32
*) DSL_DEV_PRIVATE(pDev
)->CMV_RxMsg
) // swap half word
326 MEI_HALF_WORD_SWAP (temp
);
331 return DSL_DEV_MEI_ERR_SUCCESS
;
336 * Switch the ARC control mode
337 * This function switchs the ARC control mode to JTAG mode or MEI mode
339 * \param pDev the device pointer
340 * \param mode The mode want to switch: JTAG_MASTER_MODE or MEI_MASTER_MODE.
344 IFX_MEI_ControlModeSet (DSL_DEV_Device_t
* pDev
, int mode
)
348 IFX_MEI_LongWordReadOffset (pDev
, (u32
) ME_DBG_MASTER
, &temp
);
350 case JTAG_MASTER_MODE
:
351 temp
&= ~(HOST_MSTR
);
353 case MEI_MASTER_MODE
:
357 IFX_MEI_EMSG ("IFX_MEI_ControlModeSet: unkonwn mode [%d]\n", mode
);
360 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_DBG_MASTER
, temp
);
364 * Disable ARC to MEI interrupt
366 * \param pDev the device pointer
370 IFX_MEI_IRQDisable (DSL_DEV_Device_t
* pDev
)
372 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_ARC2ME_MASK
, 0x0);
376 * Eable ARC to MEI interrupt
378 * \param pDev the device pointer
382 IFX_MEI_IRQEnable (DSL_DEV_Device_t
* pDev
)
384 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_ARC2ME_MASK
, MSGAV_EN
);
388 * Poll for transaction complete signal
389 * This function polls and waits for transaction complete signal.
391 * \param pDev the device pointer
395 meiPollForDbgDone (DSL_DEV_Device_t
* pDev
)
400 while (i
< WHILE_DELAY
) {
401 IFX_MEI_LongWordReadOffset (pDev
, (u32
) ME_ARC2ME_STAT
, &query
);
402 query
&= (ARC_TO_MEI_DBG_DONE
);
406 if (i
== WHILE_DELAY
) {
407 IFX_MEI_EMSG ("PollforDbg fail!\n");
410 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_ARC2ME_STAT
, ARC_TO_MEI_DBG_DONE
); // to clear this interrupt
414 * ARC Debug Memory Access for a single DWORD reading.
415 * This function used for direct, address-based access to ARC memory.
417 * \param pDev the device pointer
418 * \param DEC_mode ARC memory space to used
419 * \param address Address to read
420 * \param data Pointer to data
421 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
424 static DSL_DEV_MeiError_t
425 _IFX_MEI_DBGLongWordRead (DSL_DEV_Device_t
* pDev
, u32 DEC_mode
,
426 u32 address
, u32
* data
)
428 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_DBG_DECODE
, DEC_mode
);
429 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_DBG_RD_AD
, address
);
430 meiPollForDbgDone (pDev
);
431 IFX_MEI_LongWordReadOffset (pDev
, (u32
) ME_DBG_DATA
, data
);
432 return DSL_DEV_MEI_ERR_SUCCESS
;
436 * ARC Debug Memory Access for a single DWORD writing.
437 * This function used for direct, address-based access to ARC memory.
439 * \param pDev the device pointer
440 * \param DEC_mode ARC memory space to used
441 * \param address The address to write
442 * \param data The data to write
443 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
446 static DSL_DEV_MeiError_t
447 _IFX_MEI_DBGLongWordWrite (DSL_DEV_Device_t
* pDev
, u32 DEC_mode
,
448 u32 address
, u32 data
)
450 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_DBG_DECODE
, DEC_mode
);
451 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_DBG_WR_AD
, address
);
452 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_DBG_DATA
, data
);
453 meiPollForDbgDone (pDev
);
454 return DSL_DEV_MEI_ERR_SUCCESS
;
458 * ARC Debug Memory Access for writing.
459 * This function used for direct, address-based access to ARC memory.
461 * \param pDev the device pointer
462 * \param destaddr The address to read
463 * \param databuffer Pointer to data
464 * \param databuffsize The number of DWORDs to read
465 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
469 static DSL_DEV_MeiError_t
470 IFX_MEI_DebugWrite (DSL_DEV_Device_t
* pDev
, u32 destaddr
,
471 u32
* databuff
, u32 databuffsize
)
478 // Open the debug port before DMP memory write
479 IFX_MEI_ControlModeSet (pDev
, MEI_MASTER_MODE
);
481 // For the requested length, write the address and write the data
484 for (i
= 0; i
< databuffsize
; i
++) {
486 _IFX_MEI_DBGLongWordWrite (pDev
, ME_DBG_DECODE_DMP1_MASK
, address
, temp
);
491 // Close the debug port after DMP memory write
492 IFX_MEI_ControlModeSet (pDev
, JTAG_MASTER_MODE
);
494 return DSL_DEV_MEI_ERR_SUCCESS
;
498 * ARC Debug Memory Access for reading.
499 * This function used for direct, address-based access to ARC memory.
501 * \param pDev the device pointer
502 * \param srcaddr The address to read
503 * \param databuffer Pointer to data
504 * \param databuffsize The number of DWORDs to read
505 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
508 static DSL_DEV_MeiError_t
509 IFX_MEI_DebugRead (DSL_DEV_Device_t
* pDev
, u32 srcaddr
, u32
* databuff
, u32 databuffsize
)
516 // Open the debug port before DMP memory read
517 IFX_MEI_ControlModeSet (pDev
, MEI_MASTER_MODE
);
519 // For the requested length, write the address and read the data
522 for (i
= 0; i
< databuffsize
; i
++) {
523 _IFX_MEI_DBGLongWordRead (pDev
, ME_DBG_DECODE_DMP1_MASK
, address
, &temp
);
529 // Close the debug port after DMP memory read
530 IFX_MEI_ControlModeSet (pDev
, JTAG_MASTER_MODE
);
532 return DSL_DEV_MEI_ERR_SUCCESS
;
536 * Send a message to ARC MailBox.
537 * This function sends a message to ARC Mailbox via ARC DMA interface.
539 * \param pDev the device pointer
540 * \param msgsrcbuffer Pointer to message.
541 * \param msgsize The number of words to write.
542 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
545 static DSL_DEV_MeiError_t
546 IFX_MEI_MailboxWrite (DSL_DEV_Device_t
* pDev
, u16
* msgsrcbuffer
,
550 u32 arc_mailbox_status
= 0x0;
552 DSL_DEV_MeiError_t meiMailboxError
= DSL_DEV_MEI_ERR_SUCCESS
;
556 IFX_MEI_DMAWrite (pDev
, MEI_TO_ARC_MAILBOX
, (u32
*) msgsrcbuffer
, msgsize
/ 2);
558 IFX_MEI_DMAWrite (pDev
, MEI_TO_ARC_MAILBOXR
, (u32
*) (&temp
), 1);
560 // Notify arc that mailbox write completed
561 DSL_DEV_PRIVATE(pDev
)->cmv_waiting
= 1;
562 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_ME2ARC_INT
, MEI_TO_ARC_MSGAV
);
565 while (i
< WHILE_DELAY
) { // wait for ARC to clear the bit
566 IFX_MEI_LongWordReadOffset (pDev
, (u32
) ME_ME2ARC_INT
, &arc_mailbox_status
);
567 if ((arc_mailbox_status
& MEI_TO_ARC_MSGAV
) != MEI_TO_ARC_MSGAV
)
570 if (i
== WHILE_DELAY
) {
571 IFX_MEI_EMSG (">>> Timeout waiting for ARC to clear MEI_TO_ARC_MSGAV!!!"
572 " MEI_TO_ARC message size = %d DWORDs <<<\n", msgsize
/2);
573 meiMailboxError
= DSL_DEV_MEI_ERR_FAILURE
;
577 return meiMailboxError
;
581 * Read a message from ARC MailBox.
582 * This function reads a message from ARC Mailbox via ARC DMA interface.
584 * \param pDev the device pointer
585 * \param msgsrcbuffer Pointer to message.
586 * \param msgsize The number of words to read
587 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
590 static DSL_DEV_MeiError_t
591 IFX_MEI_MailboxRead (DSL_DEV_Device_t
* pDev
, u16
* msgdestbuffer
,
594 DSL_DEV_MeiError_t meiMailboxError
= DSL_DEV_MEI_ERR_SUCCESS
;
597 IFX_MEI_DMARead (pDev
, ARC_TO_MEI_MAILBOX
, (u32
*) msgdestbuffer
, msgsize
/ 2);
599 // Notify arc that mailbox read completed
600 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_ARC2ME_STAT
, ARC_TO_MEI_MSGAV
);
602 return meiMailboxError
;
606 * Download boot pages to ARC.
607 * This function downloads boot pages to ARC.
609 * \param pDev the device pointer
610 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
613 static DSL_DEV_MeiError_t
614 IFX_MEI_DownloadBootPages (DSL_DEV_Device_t
* pDev
)
621 ** DMA the boot code page(s)
626 (DSL_DEV_PRIVATE(pDev
)->img_hdr
-> count
); boot_loop
++) {
627 if ((DSL_DEV_PRIVATE(pDev
)-> img_hdr
->page
[boot_loop
].p_size
) & BOOT_FLAG
) {
628 page_size
= IFX_MEI_GetPage (pDev
, boot_loop
,
629 GET_PROG
, MAXSWAPSIZE
,
633 IFX_MEI_DMAWrite (pDev
, dest_addr
,
638 if ((DSL_DEV_PRIVATE(pDev
)-> img_hdr
->page
[boot_loop
].d_size
) & BOOT_FLAG
) {
639 page_size
= IFX_MEI_GetPage (pDev
, boot_loop
,
640 GET_DATA
, MAXSWAPSIZE
,
644 IFX_MEI_DMAWrite (pDev
, dest_addr
,
650 return DSL_DEV_MEI_ERR_SUCCESS
;
657 IFX_MEI_FuseInit (DSL_DEV_Device_t
* pDev
)
660 IFX_MEI_DMAWrite (pDev
, IRAM0_BASE
, &data
, 1);
661 IFX_MEI_DMAWrite (pDev
, IRAM0_BASE
+ 4, &data
, 1);
662 IFX_MEI_DMAWrite (pDev
, IRAM1_BASE
, &data
, 1);
663 IFX_MEI_DMAWrite (pDev
, IRAM1_BASE
+ 4, &data
, 1);
664 IFX_MEI_DMAWrite (pDev
, BRAM_BASE
, &data
, 1);
665 IFX_MEI_DMAWrite (pDev
, BRAM_BASE
+ 4, &data
, 1);
666 IFX_MEI_DMAWrite (pDev
, ADSL_DILV_BASE
, &data
, 1);
667 IFX_MEI_DMAWrite (pDev
, ADSL_DILV_BASE
+ 4, &data
, 1);
674 IFX_MEI_FuseProg (DSL_DEV_Device_t
* pDev
)
676 u32 reg_data
, fuse_value
;
679 IFX_MEI_LongWordRead ((u32
) IFXMIPS_RCU_RST
, ®_data
);
680 while ((reg_data
& 0x10000000) == 0) {
681 IFX_MEI_LongWordRead ((u32
) IFXMIPS_RCU_RST
, ®_data
);
683 /* 0x4000 translate to about 16 ms@111M, so should be enough */
687 // STEP a: Prepare memory for external accesses
688 // Write fuse_en bit24
689 IFX_MEI_LongWordRead ((u32
) IFXMIPS_RCU_RST
, ®_data
);
690 IFX_MEI_LongWordWrite ((u32
) IFXMIPS_RCU_RST
, reg_data
| (1 << 24));
692 IFX_MEI_FuseInit (pDev
);
693 for (i
= 0; i
< 4; i
++) {
694 IFX_MEI_LongWordRead ((u32
) (IFXMIPS_FUSE_BASE_ADDR
) + i
* 4, &fuse_value
);
695 switch (fuse_value
& 0xF0000) {
697 reg_data
= ((fuse_value
& RX_DILV_ADDR_BIT_MASK
) |
698 (RX_DILV_ADDR_BIT_MASK
+ 0x1));
699 IFX_MEI_DMAWrite (pDev
, ADSL_DILV_BASE
, ®_data
, 1);
702 reg_data
= ((fuse_value
& RX_DILV_ADDR_BIT_MASK
) |
703 (RX_DILV_ADDR_BIT_MASK
+ 0x1));
704 IFX_MEI_DMAWrite (pDev
, ADSL_DILV_BASE
+ 4, ®_data
, 1);
707 reg_data
= ((fuse_value
& IRAM0_ADDR_BIT_MASK
) |
708 (IRAM0_ADDR_BIT_MASK
+ 0x1));
709 IFX_MEI_DMAWrite (pDev
, IRAM0_BASE
, ®_data
, 1);
712 reg_data
= ((fuse_value
& IRAM0_ADDR_BIT_MASK
) |
713 (IRAM0_ADDR_BIT_MASK
+ 0x1));
714 IFX_MEI_DMAWrite (pDev
, IRAM0_BASE
+ 4, ®_data
, 1);
717 reg_data
= ((fuse_value
& IRAM1_ADDR_BIT_MASK
) |
718 (IRAM1_ADDR_BIT_MASK
+ 0x1));
719 IFX_MEI_DMAWrite (pDev
, IRAM1_BASE
, ®_data
, 1);
722 reg_data
= ((fuse_value
& IRAM1_ADDR_BIT_MASK
) |
723 (IRAM1_ADDR_BIT_MASK
+ 0x1));
724 IFX_MEI_DMAWrite (pDev
, IRAM1_BASE
+ 4, ®_data
, 1);
727 reg_data
= ((fuse_value
& BRAM_ADDR_BIT_MASK
) |
728 (BRAM_ADDR_BIT_MASK
+ 0x1));
729 IFX_MEI_DMAWrite (pDev
, BRAM_BASE
, ®_data
, 1);
732 reg_data
= ((fuse_value
& BRAM_ADDR_BIT_MASK
) |
733 (BRAM_ADDR_BIT_MASK
+ 0x1));
734 IFX_MEI_DMAWrite (pDev
, BRAM_BASE
+ 4, ®_data
, 1);
736 default: // PPE efuse
740 IFX_MEI_LongWordRead ((u32
) IFXMIPS_RCU_RST
, ®_data
);
741 IFX_MEI_LongWordWrite ((u32
) IFXMIPS_RCU_RST
, reg_data
& ~(1 << 24));
742 IFX_MEI_LongWordRead ((u32
) IFXMIPS_RCU_RST
, ®_data
);
747 * This function enables DFE Clock
749 * \param pDev the device pointer
750 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
753 static DSL_DEV_MeiError_t
754 IFX_MEI_EnableCLK (DSL_DEV_Device_t
* pDev
)
756 u32 arc_debug_data
= 0;
757 IFX_MEI_ControlModeSet (pDev
, MEI_MASTER_MODE
);
758 //enable ac_clk signal
759 _IFX_MEI_DBGLongWordRead (pDev
, ME_DBG_DECODE_DMP1_MASK
,
760 CRI_CCR0
, &arc_debug_data
);
761 arc_debug_data
|= ACL_CLK_MODE_ENABLE
;
762 _IFX_MEI_DBGLongWordWrite (pDev
, ME_DBG_DECODE_DMP1_MASK
,
763 CRI_CCR0
, arc_debug_data
);
764 IFX_MEI_ControlModeSet (pDev
, JTAG_MASTER_MODE
);
765 return DSL_DEV_MEI_ERR_SUCCESS
;
770 * This function halts the ARC.
772 * \param pDev the device pointer
773 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
776 static DSL_DEV_MeiError_t
777 IFX_MEI_HaltArc (DSL_DEV_Device_t
* pDev
)
779 u32 arc_debug_data
= 0x0;
781 // Switch arc control from JTAG mode to MEI mode
782 IFX_MEI_ControlModeSet (pDev
, MEI_MASTER_MODE
);
783 _IFX_MEI_DBGLongWordRead (pDev
, MEI_DEBUG_DEC_AUX_MASK
,
784 ARC_DEBUG
, &arc_debug_data
);
785 arc_debug_data
|= ARC_DEBUG_HALT
;
786 _IFX_MEI_DBGLongWordWrite (pDev
, MEI_DEBUG_DEC_AUX_MASK
,
787 ARC_DEBUG
, arc_debug_data
);
788 // Switch arc control from MEI mode to JTAG mode
789 IFX_MEI_ControlModeSet (pDev
, JTAG_MASTER_MODE
);
793 return DSL_DEV_MEI_ERR_SUCCESS
;
798 * This function runs the ARC.
800 * \param pDev the device pointer
801 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
804 static DSL_DEV_MeiError_t
805 IFX_MEI_RunArc (DSL_DEV_Device_t
* pDev
)
807 u32 arc_debug_data
= 0x0;
809 // Switch arc control from JTAG mode to MEI mode- write '1' to bit0
810 IFX_MEI_ControlModeSet (pDev
, MEI_MASTER_MODE
);
811 _IFX_MEI_DBGLongWordRead (pDev
, MEI_DEBUG_DEC_AUX_MASK
,
812 AUX_STATUS
, &arc_debug_data
);
814 // Write debug data reg with content ANDd with 0xFDFFFFFF (halt bit cleared)
815 arc_debug_data
&= ~ARC_AUX_HALT
;
816 _IFX_MEI_DBGLongWordWrite (pDev
, MEI_DEBUG_DEC_AUX_MASK
,
817 AUX_STATUS
, arc_debug_data
);
819 // Switch arc control from MEI mode to JTAG mode- write '0' to bit0
820 IFX_MEI_ControlModeSet (pDev
, JTAG_MASTER_MODE
);
821 // Enable mask for arc codeswap interrupts
822 IFX_MEI_IRQEnable (pDev
);
824 return DSL_DEV_MEI_ERR_SUCCESS
;
830 * This function resets the ARC.
832 * \param pDev the device pointer
833 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
836 static DSL_DEV_MeiError_t
837 IFX_MEI_ResetARC (DSL_DEV_Device_t
* pDev
)
839 u32 arc_debug_data
= 0;
841 IFX_MEI_HaltArc (pDev
);
843 IFX_MEI_LongWordRead ((u32
) IFXMIPS_RCU_RST
, &arc_debug_data
);
844 IFX_MEI_LongWordWrite ((u32
) IFXMIPS_RCU_RST
,
845 arc_debug_data
| IFXMIPS_RCU_RST_REQ_DFE
| IFXMIPS_RCU_RST_REQ_AFE
);
848 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_RST_CTRL
, MEI_SOFT_RESET
);
849 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_RST_CTRL
, 0);
851 IFX_MEI_IRQDisable (pDev
);
853 IFX_MEI_EnableCLK (pDev
);
857 *(unsigned long *) (BSP_PPE32_SRST
) = 0xC30;
858 *(unsigned long *) (BSP_PPE32_SRST
) = 0xFFF;
861 DSL_DEV_PRIVATE(pDev
)->modem_ready
= 0;
863 return DSL_DEV_MEI_ERR_SUCCESS
;
867 DSL_BSP_Showtime (DSL_DEV_Device_t
* dev
, DSL_uint32_t rate_fast
, DSL_uint32_t rate_intl
)
869 struct port_cell_info port_cell
= {0};
871 IFX_MEI_EMSG ("Datarate US intl = %d, fast = %d\n", (int)rate_intl
,
875 g_tx_link_rate
[0] = rate_fast
/ (53 * 8);
877 g_tx_link_rate
[1] = rate_intl
/ (53 * 8);
879 if ( g_tx_link_rate
[0] == 0 && g_tx_link_rate
[1] == 0 ) {
880 IFX_MEI_EMSG ("Got rate fail.\n");
883 if ( ifx_mei_atm_showtime_enter
)
885 port_cell
.port_num
= 2;
886 port_cell
.tx_link_rate
[0] = g_tx_link_rate
[0];
887 port_cell
.tx_link_rate
[1] = g_tx_link_rate
[1];
888 ifx_mei_atm_showtime_enter(&port_cell
, g_xdata_addr
);
892 IFX_MEI_EMSG("no hookup from ATM driver to set cell rate\n");
895 return DSL_DEV_MEI_ERR_SUCCESS
;
899 * Reset/halt/run the DFE.
900 * This function provide operations to reset/halt/run the DFE.
902 * \param pDev the device pointer
903 * \param mode which operation want to do
904 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
907 static DSL_DEV_MeiError_t
908 IFX_MEI_CpuModeSet (DSL_DEV_Device_t
*pDev
,
909 DSL_DEV_CpuMode_t mode
)
911 DSL_DEV_MeiError_t err_ret
= DSL_DEV_MEI_ERR_FAILURE
;
914 err_ret
= IFX_MEI_HaltArc (pDev
);
917 err_ret
= IFX_MEI_RunArc (pDev
);
920 err_ret
= IFX_MEI_ResetARC (pDev
);
929 * Accress DFE memory.
930 * This function provide a way to access DFE memory;
932 * \param pDev the device pointer
933 * \param type read or write
934 * \param destaddr destination address
935 * \param databuff pointer to hold data
936 * \param databuffsize size want to read/write
937 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
941 DSL_BSP_MemoryDebugAccess (DSL_DEV_Device_t
* pDev
,
942 DSL_BSP_MemoryAccessType_t type
,
943 DSL_uint32_t destaddr
, DSL_uint32_t
*databuff
,
944 DSL_uint32_t databuffsize
)
946 DSL_DEV_MeiError_t meierr
= DSL_DEV_MEI_ERR_SUCCESS
;
948 case DSL_BSP_MEMORY_READ
:
949 meierr
= IFX_MEI_DebugRead (pDev
, (u32
)destaddr
, (u32
*)databuff
, (u32
)databuffsize
);
951 case DSL_BSP_MEMORY_WRITE
:
952 meierr
= IFX_MEI_DebugWrite (pDev
, (u32
)destaddr
, (u32
*)databuff
, (u32
)databuffsize
);
955 return DSL_DEV_MEI_ERR_SUCCESS
;
959 * Download boot code to ARC.
960 * This function downloads boot code to ARC.
962 * \param pDev the device pointer
963 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
966 static DSL_DEV_MeiError_t
967 IFX_MEI_DownloadBootCode (DSL_DEV_Device_t
*pDev
)
969 IFX_MEI_IRQDisable (pDev
);
971 IFX_MEI_EnableCLK (pDev
);
973 IFX_MEI_FuseProg (pDev
); //program fuse rar
975 IFX_MEI_DownloadBootPages (pDev
);
977 return DSL_DEV_MEI_ERR_SUCCESS
;
981 * Enable Jtag debugger interface
982 * This function setups mips gpio to enable jtag debugger
984 * \param pDev the device pointer
985 * \param enable enable or disable
986 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
989 static DSL_DEV_MeiError_t
990 IFX_MEI_ArcJtagEnable (DSL_DEV_Device_t
*dev
, int enable
)
997 //reserve gpio 9, 10, 11, 14, 19 for ARC JTAG
998 ifxmips_port_reserve_pin (0, 9);
999 ifxmips_port_reserve_pin (0, 10);
1000 ifxmips_port_reserve_pin (0, 11);
1001 ifxmips_port_reserve_pin (0, 14);
1002 ifxmips_port_reserve_pin (1, 3);
1004 ifxmips_port_set_dir_in(0, 11);
1005 ifxmips_port_clear_altsel0(0, 11);
1006 ifxmips_port_clear_altsel1(0, 11);
1007 ifxmips_port_set_open_drain(0, 11);
1009 IFX_MEI_LongWordRead ((u32
) IFXMIPS_RCU_RST
, ®_data
);
1010 IFX_MEI_LongWordWrite ((u32
) IFXMIPS_RCU_RST
, reg_data
| IFXMIPS_RCU_RST_REQ_ARC_JTAG
);
1014 //reserve gpio 9, 10, 11, 14, 19 for ARC JTAG
1015 meierr
= ifxmips_port_free_pin (0, 9);
1017 IFX_MEI_EMSG ("Reserve GPIO 9 Fail.\n");
1020 meierr
= ifxmips_port_free_pin (0, 10);
1022 IFX_MEI_EMSG ("Reserve GPIO 10 Fail.\n");
1025 meierr
= ifxmips_port_free_pin (0, 11);
1027 IFX_MEI_EMSG ("Reserve GPIO 11 Fail.\n");
1030 meierr
= ifxmips_port_free_pin (0, 14);
1032 IFX_MEI_EMSG ("Reserve GPIO 14 Fail.\n");
1035 meierr
= ifxmips_port_free_pin (1, 3);
1037 IFX_MEI_EMSG ("Reserve GPIO 19 Fail.\n");
1044 return DSL_DEV_MEI_ERR_FAILURE
;
1046 return DSL_DEV_MEI_ERR_SUCCESS
;
1050 * Enable DFE to MIPS interrupt
1051 * This function enable DFE to MIPS interrupt
1053 * \param pDev the device pointer
1054 * \param enable enable or disable
1055 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
1058 static DSL_DEV_MeiError_t
1059 IFX_MEI_AdslMailboxIRQEnable (DSL_DEV_Device_t
*pDev
, int enable
)
1061 DSL_DEV_MeiError_t meierr
;
1064 meierr
= DSL_DEV_MEI_ERR_SUCCESS
;
1065 IFX_MEI_IRQDisable (pDev
);
1068 IFX_MEI_IRQEnable (pDev
);
1069 meierr
= DSL_DEV_MEI_ERR_SUCCESS
;
1072 meierr
= DSL_DEV_MEI_ERR_FAILURE
;
1080 * Get the modem status
1081 * This function return the modem status
1083 * \param pDev the device pointer
1084 * \return 1: modem ready 0: not ready
1088 IFX_MEI_IsModemReady (DSL_DEV_Device_t
* pDev
)
1090 return DSL_DEV_PRIVATE(pDev
)->modem_ready
;
1094 DSL_BSP_AdslLedInit (DSL_DEV_Device_t
* dev
,
1095 DSL_DEV_LedId_t led_number
,
1096 DSL_DEV_LedType_t type
,
1097 DSL_DEV_LedHandler_t handler
)
1100 struct led_config_param param
;
1101 if (led_number
== DSL_LED_LINK_ID
&& type
== DSL_LED_LINK_TYPE
&& handler
== /*DSL_LED_HD_CPU*/DSL_LED_HD_FW
) {
1102 param
.operation_mask
= CONFIG_OPERATION_UPDATE_SOURCE
;
1104 param
.source
= 0x01;
1105 // bsp_led_config (¶m);
1107 } else if (led_number
== DSL_LED_DATA_ID
&& type
== DSL_LED_DATA_TYPE
&& (handler
== DSL_LED_HD_FW
)) {
1108 param
.operation_mask
= CONFIG_OPERATION_UPDATE_SOURCE
;
1110 param
.source
= 0x02;
1111 // bsp_led_config (¶m);
1114 return DSL_DEV_MEI_ERR_SUCCESS
;
1118 DSL_BSP_AdslLedSet (DSL_DEV_Device_t
* dev
, DSL_DEV_LedId_t led_number
, DSL_DEV_LedMode_t mode
)
1120 printk(KERN_INFO
"[%s %d]: mode = %#x, led_number = %d\n", __func__
, __LINE__
, mode
, led_number
);
1123 switch (led_number
) {
1124 case DSL_LED_LINK_ID
:
1125 #ifdef CONFIG_BSP_LED
1126 bsp_led_set_blink (1, 0);
1127 bsp_led_set_data (1, 0);
1130 case DSL_LED_DATA_ID
:
1131 #ifdef CONFIG_BSP_LED
1132 bsp_led_set_blink (0, 0);
1133 bsp_led_set_data (0, 0);
1139 switch (led_number
) {
1140 case DSL_LED_LINK_ID
:
1141 #ifdef CONFIG_BSP_LED
1142 bsp_led_set_blink (1, 1); // data
1145 case DSL_LED_DATA_ID
:
1146 #ifdef CONFIG_BSP_LED
1147 bsp_led_set_blink (0, 1); // data
1153 switch (led_number
) {
1154 case DSL_LED_LINK_ID
:
1155 #ifdef CONFIG_BSP_LED
1156 bsp_led_set_blink (1, 0);
1157 bsp_led_set_data (1, 1);
1160 case DSL_LED_DATA_ID
:
1161 #ifdef CONFIG_BSP_LED
1162 bsp_led_set_blink (0, 0);
1163 bsp_led_set_data (0, 1);
1169 return DSL_DEV_MEI_ERR_SUCCESS
;
1175 * Compose a message.
1176 * This function compose a message from opcode, group, address, index, size, and data
1178 * \param opcode The message opcode
1179 * \param group The message group number
1180 * \param address The message address.
1181 * \param index The message index.
1182 * \param size The number of words to read/write.
1183 * \param data The pointer to data.
1184 * \param CMVMSG The pointer to message buffer.
1188 makeCMV (u8 opcode
, u8 group
, u16 address
, u16 index
, int size
, u16
* data
, u16
*CMVMSG
)
1190 memset (CMVMSG
, 0, MSG_LENGTH
* 2);
1191 CMVMSG
[0] = (opcode
<< 4) + (size
& 0xf);
1192 CMVMSG
[1] = (((index
== 0) ? 0 : 1) << 7) + (group
& 0x7f);
1193 CMVMSG
[2] = address
;
1195 if (opcode
== H2D_CMV_WRITE
)
1196 memcpy (CMVMSG
+ 4, data
, size
* 2);
1201 * Send a message to ARC and read the response
1202 * This function sends a message to arc, waits the response, and reads the responses.
1204 * \param pDev the device pointer
1205 * \param request Pointer to the request
1206 * \param reply Wait reply or not.
1207 * \param response Pointer to the response
1208 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
1212 DSL_BSP_SendCMV (DSL_DEV_Device_t
* pDev
, u16
* request
, int reply
, u16
* response
) // write cmv to arc, if reply needed, wait for reply
1214 DSL_DEV_MeiError_t meierror
;
1215 #if defined(BSP_PORT_RTEMS)
1216 int delay_counter
= 0;
1219 if (MEI_MUTEX_LOCK (DSL_DEV_PRIVATE(pDev
)->mei_cmv_sema
))
1220 return -ERESTARTSYS
;
1222 DSL_DEV_PRIVATE(pDev
)->cmv_reply
= reply
;
1223 memset (DSL_DEV_PRIVATE(pDev
)->CMV_RxMsg
, 0,
1224 sizeof (DSL_DEV_PRIVATE(pDev
)->
1226 DSL_DEV_PRIVATE(pDev
)->arcmsgav
= 0;
1228 meierror
= IFX_MEI_MailboxWrite (pDev
, request
, MSG_LENGTH
);
1230 if (meierror
!= DSL_DEV_MEI_ERR_SUCCESS
) {
1231 DSL_DEV_PRIVATE(pDev
)->cmv_waiting
= 0;
1232 DSL_DEV_PRIVATE(pDev
)->arcmsgav
= 0;
1233 IFX_MEI_EMSG ("MailboxWrite Fail!\n");
1234 IFX_MEI_EMSG ("Resetting ARC...\n");
1235 IFX_MEI_ResetARC(pDev
);
1236 MEI_MUTEX_UNLOCK (DSL_DEV_PRIVATE(pDev
)->mei_cmv_sema
);
1240 DSL_DEV_PRIVATE(pDev
)->cmv_count
++;
1243 if (DSL_DEV_PRIVATE(pDev
)->cmv_reply
==
1245 MEI_MUTEX_UNLOCK (DSL_DEV_PRIVATE(pDev
)->mei_cmv_sema
);
1246 return DSL_DEV_MEI_ERR_SUCCESS
;
1249 #if !defined(BSP_PORT_RTEMS)
1250 if (DSL_DEV_PRIVATE(pDev
)->arcmsgav
== 0)
1251 MEI_WAIT_EVENT_TIMEOUT (DSL_DEV_PRIVATE(pDev
)->wait_queue_arcmsgav
, CMV_TIMEOUT
);
1253 while (DSL_DEV_PRIVATE(pDev
)->arcmsgav
== 0 && delay_counter
< CMV_TIMEOUT
/ 5) {
1259 DSL_DEV_PRIVATE(pDev
)->cmv_waiting
= 0;
1260 if (DSL_DEV_PRIVATE(pDev
)->arcmsgav
== 0) { //CMV_timeout
1261 DSL_DEV_PRIVATE(pDev
)->arcmsgav
= 0;
1262 IFX_MEI_EMSG ("\%s: DSL_DEV_MEI_ERR_MAILBOX_TIMEOUT\n",
1264 MEI_MUTEX_UNLOCK (DSL_DEV_PRIVATE(pDev
)->mei_cmv_sema
);
1265 return DSL_DEV_MEI_ERR_MAILBOX_TIMEOUT
;
1268 DSL_DEV_PRIVATE(pDev
)->arcmsgav
= 0;
1269 DSL_DEV_PRIVATE(pDev
)->
1271 memcpy (response
, DSL_DEV_PRIVATE(pDev
)->CMV_RxMsg
, MSG_LENGTH
* 2);
1272 MEI_MUTEX_UNLOCK (DSL_DEV_PRIVATE(pDev
)->mei_cmv_sema
);
1273 return DSL_DEV_MEI_ERR_SUCCESS
;
1275 MEI_MUTEX_UNLOCK (DSL_DEV_PRIVATE(pDev
)->mei_cmv_sema
);
1276 return DSL_DEV_MEI_ERR_SUCCESS
;
1280 * Reset the ARC, download boot codes, and run the ARC.
1281 * This function resets the ARC, downloads boot codes to ARC, and runs the ARC.
1283 * \param pDev the device pointer
1284 * \return DSL_DEV_MEI_ERR_SUCCESS or DSL_DEV_MEI_ERR_FAILURE
1287 static DSL_DEV_MeiError_t
1288 IFX_MEI_RunAdslModem (DSL_DEV_Device_t
*pDev
)
1290 int nSize
= 0, idx
= 0;
1291 uint32_t im0_register
, im2_register
;
1292 // DSL_DEV_WinHost_Message_t m;
1294 if (mei_arc_swap_buff
== NULL
) {
1296 (u32
*) kmalloc (MAXSWAPSIZE
* 4, GFP_KERNEL
);
1297 if (mei_arc_swap_buff
== NULL
) {
1298 IFX_MEI_EMSG (">>> malloc fail for codeswap buff!!! <<<\n");
1299 return DSL_DEV_MEI_ERR_FAILURE
;
1301 printk("allocate %dKB swap buff memory at: 0x%p\n", ksize(mei_arc_swap_buff
)/1024, mei_arc_swap_buff
);
1304 DSL_DEV_PRIVATE(pDev
)->img_hdr
=
1305 (ARC_IMG_HDR
*) DSL_DEV_PRIVATE(pDev
)->adsl_mem_info
[0].address
;
1306 if ((DSL_DEV_PRIVATE(pDev
)->img_hdr
->
1307 count
) * sizeof (ARC_SWP_PAGE_HDR
) > SDRAM_SEGMENT_SIZE
) {
1308 IFX_MEI_EMSG ("firmware header size is bigger than 64K segment size\n");
1309 return DSL_DEV_MEI_ERR_FAILURE
;
1312 for (idx
= 0; idx
< MAX_BAR_REGISTERS
; idx
++) {
1313 nSize
+= DSL_DEV_PRIVATE(pDev
)->adsl_mem_info
[idx
].nCopy
;
1316 DSL_DEV_PRIVATE(pDev
)->image_size
) {
1317 IFX_MEI_EMSG ("Firmware download is not completed. Please download firmware again!\n");
1318 return DSL_DEV_MEI_ERR_FAILURE
;
1323 IFX_MEI_ResetARC (pDev
);
1324 IFX_MEI_HaltArc (pDev
);
1325 IFX_MEI_BarUpdate (pDev
, DSL_DEV_PRIVATE(pDev
)->nBar
);
1327 //IFX_MEI_DMSG("Starting to meiDownloadBootCode\n");
1329 IFX_MEI_DownloadBootCode (pDev
);
1331 im0_register
= (*IFXMIPS_ICU_IM0_IER
) & (1 << 20);
1332 im2_register
= (*IFXMIPS_ICU_IM2_IER
) & (1 << 20);
1334 #ifdef CONFIG_IFXMIPS_AMAZON_SE
1335 disable_irq (IFXMIPS_USB_OC_INT0
);
1336 disable_irq (IFXMIPS_USB_OC_INT2
);
1337 #elif defined(CONFIG_IFXMIPS_AR9)
1338 disable_irq (IFXMIPS_USB_OC_INT0
);
1339 disable_irq (IFXMIPS_USB_OC_INT2
);
1340 #elif defined(CONFIG_IFXMIPS_DANUBE)
1341 disable_irq (IFXMIPS_USB_OC_INT
);
1343 disable_irq (pDev
->nIrq
[IFX_DYING_GASP
]);
1345 IFX_MEI_RunArc (pDev
);
1347 MEI_WAIT_EVENT_TIMEOUT (DSL_DEV_PRIVATE(pDev
)->wait_queue_modemready
, 1000);
1349 #ifdef CONFIG_IFXMIPS_AMAZON_SE
1350 MEI_MASK_AND_ACK_IRQ (IFXMIPS_USB_OC_INT0
);
1351 MEI_MASK_AND_ACK_IRQ (IFXMIPS_USB_OC_INT2
);
1352 #elif defined(CONFIG_IFXMIPS_AMAZON_S)
1353 MEI_MASK_AND_ACK_IRQ (IFXMIPS_USB_OC_INT0
);
1354 MEI_MASK_AND_ACK_IRQ (IFXMIPS_USB_OC_INT2
);
1355 #elif defined(CONFIG_IFXMIPS_DANUBE)
1356 MEI_MASK_AND_ACK_IRQ (IFXMIPS_USB_OC_INT
);
1358 MEI_MASK_AND_ACK_IRQ (pDev
->nIrq
[IFX_DYING_GASP
]);
1361 enable_irq(pDev
->nIrq
[IFX_DYING_GASP
]);
1362 *IFXMIPS_ICU_IM0_IER
|= im0_register
;
1363 *IFXMIPS_ICU_IM2_IER
|= im2_register
;
1365 if (DSL_DEV_PRIVATE(pDev
)->modem_ready
!= 1) {
1366 IFX_MEI_EMSG ("Modem failed to be ready!\n");
1367 return DSL_DEV_MEI_ERR_FAILURE
;
1369 IFX_MEI_DMSG("Modem is ready.\n");
1370 return DSL_DEV_MEI_ERR_SUCCESS
;
1375 * Get the page's data pointer
1376 * This function caculats the data address from the firmware header.
1378 * \param pDev the device pointer
1379 * \param Page The page number.
1380 * \param data Data page or program page.
1381 * \param MaxSize The maximum size to read.
1382 * \param Buffer Pointer to data.
1383 * \param Dest Pointer to the destination address.
1384 * \return The number of bytes to read.
1388 IFX_MEI_GetPage (DSL_DEV_Device_t
* pDev
, u32 Page
, u32 data
,
1389 u32 MaxSize
, u32
* Buffer
, u32
* Dest
)
1394 u32 idx
, offset
, nBar
= 0;
1396 if (Page
> DSL_DEV_PRIVATE(pDev
)->img_hdr
->count
)
1399 ** Get program or data size, depending on "data" flag
1401 size
= (data
== GET_DATA
) ? (DSL_DEV_PRIVATE(pDev
)->img_hdr
->page
[Page
].d_size
) :
1402 (DSL_DEV_PRIVATE(pDev
)->img_hdr
->page
[Page
].p_size
);
1403 size
&= BOOT_FLAG_MASK
; // Clear boot bit!
1410 ** Get program or data offset, depending on "data" flag
1412 i
= data
? (DSL_DEV_PRIVATE(pDev
)->img_hdr
->page
[Page
].d_offset
) :
1413 (DSL_DEV_PRIVATE(pDev
)->img_hdr
->page
[Page
].p_offset
);
1416 ** Copy data/program to buffer
1419 idx
= i
/ SDRAM_SEGMENT_SIZE
;
1420 offset
= i
% SDRAM_SEGMENT_SIZE
;
1421 p
= (u32
*) ((u8
*) DSL_DEV_PRIVATE(pDev
)->adsl_mem_info
[idx
].address
+ offset
);
1423 for (i
= 0; i
< size
; i
++) {
1424 if (offset
+ i
* 4 - (nBar
* SDRAM_SEGMENT_SIZE
) >= SDRAM_SEGMENT_SIZE
) {
1427 p
= (u32
*) ((u8
*) KSEG1ADDR ((u32
)DSL_DEV_PRIVATE(pDev
)->adsl_mem_info
[idx
].address
));
1433 ** Pass back data/program destination address
1435 *Dest
= data
? (DSL_DEV_PRIVATE(pDev
)-> img_hdr
->page
[Page
].d_dest
) :
1436 (DSL_DEV_PRIVATE(pDev
)->img_hdr
->page
[Page
].p_dest
);
1442 * Free the memory for ARC firmware
1444 * \param pDev the device pointer
1445 * \param type Free all memory or free the unused memory after showtime
1448 const char *free_str
[4] = {"Invalid", "Free_Reload", "Free_Showtime", "Free_All"};
1450 IFX_MEI_DFEMemoryFree (DSL_DEV_Device_t
* pDev
, int type
)
1453 smmu_mem_info_t
*adsl_mem_info
=
1454 DSL_DEV_PRIVATE(pDev
)->adsl_mem_info
;
1456 for (idx
= 0; idx
< MAX_BAR_REGISTERS
; idx
++) {
1457 if (type
== FREE_ALL
||adsl_mem_info
[idx
].type
== type
) {
1458 if (adsl_mem_info
[idx
].size
> 0) {
1459 IFX_MEI_DMSG ("Freeing memory %p (%s)\n", adsl_mem_info
[idx
].org_address
, free_str
[adsl_mem_info
[idx
].type
]);
1460 if ( idx
== XDATA_REGISTER
) {
1461 g_xdata_addr
= NULL
;
1462 if ( ifx_mei_atm_showtime_exit
)
1463 ifx_mei_atm_showtime_exit();
1465 kfree (adsl_mem_info
[idx
].org_address
);
1466 adsl_mem_info
[idx
].org_address
= 0;
1467 adsl_mem_info
[idx
].address
= 0;
1468 adsl_mem_info
[idx
].size
= 0;
1469 adsl_mem_info
[idx
].type
= 0;
1470 adsl_mem_info
[idx
].nCopy
= 0;
1475 if(mei_arc_swap_buff
!= NULL
){
1476 printk("free %dKB swap buff memory at: 0x%p\n", ksize(mei_arc_swap_buff
)/1024, mei_arc_swap_buff
);
1477 kfree(mei_arc_swap_buff
);
1478 mei_arc_swap_buff
=NULL
;
1484 IFX_MEI_DFEMemoryAlloc (DSL_DEV_Device_t
* pDev
, long size
)
1486 unsigned long mem_ptr
;
1487 char *org_mem_ptr
= NULL
;
1489 long total_size
= 0;
1491 smmu_mem_info_t
*adsl_mem_info
=
1492 ((ifx_mei_device_private_t
*) pDev
->pPriv
)->adsl_mem_info
;
1493 // DSL_DEV_PRIVATE(pDev)->adsl_mem_info;
1494 int allocate_size
= SDRAM_SEGMENT_SIZE
;
1496 printk(KERN_INFO
"[%s %d]: image_size = %ld\n", __func__
, __LINE__
, size
);
1498 for (idx
= 0; size
> 0 && idx
< MAX_BAR_REGISTERS
; idx
++) {
1499 // skip bar15 for XDATA usage.
1500 #ifndef CONFIG_IFXMIPS_MEI_FW_LOOPBACK
1501 if (idx
== XDATA_REGISTER
)
1505 if (size
< SDRAM_SEGMENT_SIZE
) {
1506 allocate_size
= size
;
1507 if (allocate_size
< 1024)
1508 allocate_size
= 1024;
1511 if (idx
== (MAX_BAR_REGISTERS
- 1))
1512 allocate_size
= size
;
1514 allocate_size
= SDRAM_SEGMENT_SIZE
;
1515 org_mem_ptr
= kmalloc (allocate_size
+ 1024, GFP_KERNEL
);
1516 if (org_mem_ptr
== NULL
) {
1517 IFX_MEI_EMSG ("%d: kmalloc %d bytes memory fail!\n", idx
, allocate_size
);
1519 goto allocate_error
;
1521 mem_ptr
= (unsigned long) (org_mem_ptr
+ 1023) & ~(1024 -1);
1522 adsl_mem_info
[idx
].address
= (char *) mem_ptr
;
1523 adsl_mem_info
[idx
].org_address
= org_mem_ptr
;
1524 adsl_mem_info
[idx
].size
= allocate_size
;
1525 size
-= allocate_size
;
1526 total_size
+= allocate_size
;
1529 IFX_MEI_EMSG ("Image size is too large!\n");
1531 goto allocate_error
;
1537 IFX_MEI_DFEMemoryFree (pDev
, FREE_ALL
);
1542 * Program the BAR registers
1544 * \param pDev the device pointer
1545 * \param nTotalBar The number of bar to program.
1549 IFX_MEI_BarUpdate (DSL_DEV_Device_t
* pDev
, int nTotalBar
)
1552 smmu_mem_info_t
*adsl_mem_info
=
1553 DSL_DEV_PRIVATE(pDev
)->adsl_mem_info
;
1555 for (idx
= 0; idx
< nTotalBar
; idx
++) {
1556 //skip XDATA register
1557 if (idx
== XDATA_REGISTER
)
1559 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_XMEM_BAR_BASE
+ idx
* 4,
1560 (((uint32_t) adsl_mem_info
[idx
].address
) & 0x0FFFFFFF));
1562 for (idx
= nTotalBar
; idx
< MAX_BAR_REGISTERS
; idx
++) {
1563 if (idx
== XDATA_REGISTER
)
1565 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_XMEM_BAR_BASE
+ idx
* 4,
1566 (((uint32_t)adsl_mem_info
[nTotalBar
- 1].address
) & 0x0FFFFFFF));
1567 /* These are for /proc/danube_mei/meminfo purpose */
1568 adsl_mem_info
[idx
].address
= adsl_mem_info
[nTotalBar
- 1].address
;
1569 adsl_mem_info
[idx
].org_address
= adsl_mem_info
[nTotalBar
- 1].org_address
;
1570 adsl_mem_info
[idx
].size
= 0; /* Prevent it from being freed */
1573 g_xdata_addr
= adsl_mem_info
[XDATA_REGISTER
].address
;
1574 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_XMEM_BAR_BASE
+ XDATA_REGISTER
* 4,
1575 (((uint32_t) adsl_mem_info
[XDATA_REGISTER
].address
) & 0x0FFFFFFF));
1576 // update MEI_XDATA_BASE_SH
1577 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_XDATA_BASE_SH
,
1578 ((unsigned long)adsl_mem_info
[XDATA_REGISTER
].address
) & 0x0FFFFFFF);
1580 return DSL_DEV_MEI_ERR_SUCCESS
;
1583 /* This copies the firmware from secondary storage to 64k memory segment in SDRAM */
1585 DSL_BSP_FWDownload (DSL_DEV_Device_t
* pDev
, const char *buf
,
1586 unsigned long size
, long *loff
, long *current_offset
)
1588 ARC_IMG_HDR img_hdr_tmp
;
1589 smmu_mem_info_t
*adsl_mem_info
= DSL_DEV_PRIVATE(pDev
)->adsl_mem_info
;
1591 size_t nRead
= 0, nCopy
= 0;
1593 ssize_t retval
= -ENOMEM
;
1596 printk("\n%s\n", __func__
);
1599 if (size
< sizeof (img_hdr_tmp
)) {
1600 IFX_MEI_EMSG ("Firmware size is too small!\n");
1603 copy_from_user ((char *) &img_hdr_tmp
, buf
, sizeof (img_hdr_tmp
));
1604 // header of image_size and crc are not included.
1605 DSL_DEV_PRIVATE(pDev
)->image_size
= le32_to_cpu (img_hdr_tmp
.size
) + 8;
1607 if (DSL_DEV_PRIVATE(pDev
)->image_size
> 1024 * 1024) {
1608 IFX_MEI_EMSG ("Firmware size is too large!\n");
1611 // check if arc is halt
1612 IFX_MEI_ResetARC (pDev
);
1613 IFX_MEI_HaltArc (pDev
);
1615 IFX_MEI_DFEMemoryFree (pDev
, FREE_ALL
); //free all
1617 retval
= IFX_MEI_DFEMemoryAlloc (pDev
, DSL_DEV_PRIVATE(pDev
)->image_size
);
1619 IFX_MEI_EMSG ("Error: No memory space left.\n");
1622 for (idx
= 0; idx
< retval
; idx
++) {
1623 //skip XDATA register
1624 if (idx
== XDATA_REGISTER
)
1626 if (idx
* SDRAM_SEGMENT_SIZE
< le32_to_cpu (img_hdr_tmp
.page
[0].p_offset
))
1627 adsl_mem_info
[idx
].type
= FREE_RELOAD
;
1629 adsl_mem_info
[idx
].type
= FREE_SHOWTIME
;
1631 DSL_DEV_PRIVATE(pDev
)->nBar
= retval
;
1633 DSL_DEV_PRIVATE(pDev
)->img_hdr
=
1634 (ARC_IMG_HDR
*) adsl_mem_info
[0].address
;
1636 adsl_mem_info
[XDATA_REGISTER
].org_address
= kmalloc (SDRAM_SEGMENT_SIZE
+ 1024, GFP_KERNEL
);
1637 adsl_mem_info
[XDATA_REGISTER
].address
=
1638 (char *) ((unsigned long) (adsl_mem_info
[XDATA_REGISTER
].org_address
+ 1023) & 0xFFFFFC00);
1640 adsl_mem_info
[XDATA_REGISTER
].size
= SDRAM_SEGMENT_SIZE
;
1642 if (adsl_mem_info
[XDATA_REGISTER
].address
== NULL
) {
1643 IFX_MEI_EMSG ("kmalloc memory fail!\n");
1647 adsl_mem_info
[XDATA_REGISTER
].type
= FREE_RELOAD
;
1648 printk(KERN_INFO
"[%s %d] -> IFX_MEI_BarUpdate()\n", __func__
, __LINE__
);
1649 IFX_MEI_BarUpdate (pDev
, (DSL_DEV_PRIVATE(pDev
)->nBar
));
1651 else if (DSL_DEV_PRIVATE(pDev
)-> image_size
== 0) {
1652 IFX_MEI_EMSG ("Error: Firmware size=0! \n");
1657 while (nRead
< size
) {
1658 long offset
= ((long) (*loff
) + nRead
) % SDRAM_SEGMENT_SIZE
;
1659 idx
= (((long) (*loff
)) + nRead
) / SDRAM_SEGMENT_SIZE
;
1660 mem_ptr
= (char *) KSEG1ADDR ((unsigned long) (adsl_mem_info
[idx
].address
) + offset
);
1661 if ((size
- nRead
+ offset
) > SDRAM_SEGMENT_SIZE
)
1662 nCopy
= SDRAM_SEGMENT_SIZE
- offset
;
1664 nCopy
= size
- nRead
;
1665 copy_from_user (mem_ptr
, buf
+ nRead
, nCopy
);
1666 for (offset
= 0; offset
< (nCopy
/ 4); offset
++) {
1667 ((unsigned long *) mem_ptr
)[offset
] = le32_to_cpu (((unsigned long *) mem_ptr
)[offset
]);
1670 adsl_mem_info
[idx
].nCopy
+= nCopy
;
1674 *current_offset
= size
;
1675 return DSL_DEV_MEI_ERR_SUCCESS
;
1677 IFX_MEI_DFEMemoryFree (pDev
, FREE_ALL
);
1678 return DSL_DEV_MEI_ERR_FAILURE
;
1681 * Register a callback event.
1683 * -1 if the event already has a callback function registered.
1686 int DSL_BSP_EventCBRegister(DSL_BSP_EventCallBack_t
*p
)
1689 IFX_MEI_EMSG("Invalid parameter!\n");
1692 if (p
->event
> DSL_BSP_CB_LAST
|| p
->event
< DSL_BSP_CB_FIRST
) {
1693 IFX_MEI_EMSG("Invalid Event %d\n", p
->event
);
1696 if (dsl_bsp_event_callback
[p
->event
].function
) {
1697 IFX_MEI_EMSG("Event %d already has a callback function registered!\n", p
->event
);
1700 dsl_bsp_event_callback
[p
->event
].function
= p
->function
;
1701 dsl_bsp_event_callback
[p
->event
].event
= p
->event
;
1702 dsl_bsp_event_callback
[p
->event
].pData
= p
->pData
;
1706 int DSL_BSP_EventCBUnregister(DSL_BSP_EventCallBack_t
*p
)
1709 IFX_MEI_EMSG("Invalid parameter!\n");
1712 if (p
->event
> DSL_BSP_CB_LAST
|| p
->event
< DSL_BSP_CB_FIRST
) {
1713 IFX_MEI_EMSG("Invalid Event %d\n", p
->event
);
1716 if (dsl_bsp_event_callback
[p
->event
].function
) {
1717 IFX_MEI_EMSG("Unregistering Event %d...\n", p
->event
);
1718 dsl_bsp_event_callback
[p
->event
].function
= NULL
;
1719 dsl_bsp_event_callback
[p
->event
].pData
= NULL
;
1721 IFX_MEI_EMSG("Event %d is not registered!\n", p
->event
);
1728 * MEI Dying Gasp interrupt handler
1732 * \param regs Pointer to the structure of danube mips registers
1735 static irqreturn_t
IFX_MEI_Dying_Gasp_IrqHandle (int int1
, void *void0
)
1737 DSL_DEV_Device_t
*pDev
= (DSL_DEV_Device_t
*) void0
;
1738 DSL_BSP_CB_Type_t event
;
1741 IFX_MEI_EMSG("Error: Got Interrupt but pDev is NULL!!!!\n");
1744 disable_irq (pDev
->nIrq
[IFX_DYING_GASP
]);
1746 disable_irq_nosync(pDev
->nIrq
[IFX_DYING_GASP
]);
1748 event
= DSL_BSP_CB_DYING_GASP
;
1750 if (dsl_bsp_event_callback
[event
].function
)
1751 (*dsl_bsp_event_callback
[event
].function
)(pDev
, event
, dsl_bsp_event_callback
[event
].pData
);
1753 #ifdef CONFIG_USE_EMULATOR
1754 IFX_MEI_EMSG("Dying Gasp! Shutting Down... (Work around for Amazon-S Venus emulator)\n");
1756 IFX_MEI_EMSG("Dying Gasp! Shutting Down...\n");
1757 // kill_proc (1, SIGINT, 1); /* Ask init to reboot us */
1762 extern void ifx_usb_enable_afe_oc(void);
1765 * MEI interrupt handler
1769 * \param regs Pointer to the structure of danube mips registers
1772 static irqreturn_t
IFX_MEI_IrqHandle (int int1
, void *void0
)
1775 DSL_DEV_Device_t
*pDev
= (DSL_DEV_Device_t
*) void0
;
1776 #if defined(CONFIG_IFXMIPS_MEI_FW_LOOPBACK) && defined(DFE_PING_TEST)
1777 dfe_loopback_irq_handler (pDev
);
1779 #endif //CONFIG_AMAZON_S_MEI_FW_LOOPBACK
1780 DSL_BSP_CB_Type_t event
;
1783 IFX_MEI_EMSG("Error: Got Interrupt but pDev is NULL!!!!\n");
1785 IFX_MEI_DebugRead (pDev
, ARC_MEI_MAILBOXR
, &scratch
, 1);
1786 if (scratch
& OMB_CODESWAP_MESSAGE_MSG_TYPE_MASK
) {
1787 IFX_MEI_EMSG("Receive Code Swap Request interrupt!!!\n");
1790 else if (scratch
& OMB_CLEAREOC_INTERRUPT_CODE
) {
1791 // clear eoc message interrupt
1792 IFX_MEI_DMSG("OMB_CLEAREOC_INTERRUPT_CODE\n");
1793 event
= DSL_BSP_CB_CEOC_IRQ
;
1794 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_ARC2ME_STAT
, ARC_TO_MEI_MSGAV
);
1795 if (dsl_bsp_event_callback
[event
].function
)
1796 (*dsl_bsp_event_callback
[event
].function
)(pDev
, event
, dsl_bsp_event_callback
[event
].pData
);
1797 } else if (scratch
& OMB_REBOOT_INTERRUPT_CODE
) {
1799 IFX_MEI_DMSG("OMB_REBOOT_INTERRUPT_CODE\n");
1800 event
= DSL_BSP_CB_FIRMWARE_REBOOT
;
1802 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_ARC2ME_STAT
, ARC_TO_MEI_MSGAV
);
1804 if (dsl_bsp_event_callback
[event
].function
)
1805 (*dsl_bsp_event_callback
[event
].function
)(pDev
, event
, dsl_bsp_event_callback
[event
].pData
);
1806 } else { // normal message
1807 IFX_MEI_MailboxRead (pDev
, DSL_DEV_PRIVATE(pDev
)->CMV_RxMsg
, MSG_LENGTH
);
1808 if (DSL_DEV_PRIVATE(pDev
)-> cmv_waiting
== 1) {
1809 DSL_DEV_PRIVATE(pDev
)-> arcmsgav
= 1;
1810 DSL_DEV_PRIVATE(pDev
)-> cmv_waiting
= 0;
1811 #if !defined(BSP_PORT_RTEMS)
1812 MEI_WAKEUP_EVENT (DSL_DEV_PRIVATE(pDev
)->wait_queue_arcmsgav
);
1816 DSL_DEV_PRIVATE(pDev
)-> modem_ready_cnt
++;
1817 memcpy ((char *) DSL_DEV_PRIVATE(pDev
)->Recent_indicator
,
1818 (char *) DSL_DEV_PRIVATE(pDev
)->CMV_RxMsg
, MSG_LENGTH
* 2);
1819 if (((DSL_DEV_PRIVATE(pDev
)->CMV_RxMsg
[0] & 0xff0) >> 4) == D2H_AUTONOMOUS_MODEM_READY_MSG
) {
1820 //check ARC ready message
1821 IFX_MEI_DMSG ("Got MODEM_READY_MSG\n");
1822 DSL_DEV_PRIVATE(pDev
)->modem_ready
= 1;
1823 MEI_WAKEUP_EVENT (DSL_DEV_PRIVATE(pDev
)->wait_queue_modemready
);
1832 DSL_BSP_ATMLedCBRegister (int (*ifx_adsl_ledcallback
) (void))
1834 g_adsl_ledcallback
= ifx_adsl_ledcallback
;
1839 DSL_BSP_ATMLedCBUnregister (int (*ifx_adsl_ledcallback
) (void))
1841 g_adsl_ledcallback
= adsl_dummy_ledcallback
;
1847 DSL_BSP_EventCBRegister (int (*ifx_adsl_callback
)
1848 (DSL_BSP_CB_Event_t
* param
))
1852 if (DSL_EventCB
== NULL
) {
1853 DSL_EventCB
= ifx_adsl_callback
;
1862 DSL_BSP_EventCBUnregister (int (*ifx_adsl_callback
)
1863 (DSL_BSP_CB_Event_t
* param
))
1867 if (DSL_EventCB
== ifx_adsl_callback
) {
1877 DSL_BSP_GetEventCB (int (**ifx_adsl_callback
)
1878 (DSL_BSP_CB_Event_t
* param
))
1880 *ifx_adsl_callback
= DSL_EventCB
;
1885 #ifdef CONFIG_IFXMIPS_MEI_FW_LOOPBACK
1886 #define mte_reg_base (0x4800*4+0x20000)
1888 /* Iridia Registers Address Constants */
1889 #define MTE_Reg(r) (int)(mte_reg_base + (r*4))
1891 #define IT_AMODE MTE_Reg(0x0004)
1893 #define TIMER_DELAY (1024)
1894 #define BC0_BYTES (32)
1895 #define BC1_BYTES (30)
1897 #define TIMEOUT_VALUE 2000
1903 for (i
= 0; i
< cycle
; i
++);
1907 WriteRegLong (u32 addr
, u32 data
)
1909 //*((volatile u32 *)(addr)) = data;
1910 IFX_MEI_WRITE_REGISTER_L (data
, addr
);
1914 ReadRegLong (u32 addr
)
1917 //rd_val = *((volatile u32 *)(addr));
1919 return IFX_MEI_READ_REGISTER_L (addr
);
1922 /* This routine writes the mailbox with the data in an input array */
1924 WriteMbox (u32
* mboxarray
, u32 size
)
1926 IFX_MEI_DebugWrite (&dsl_devices
[0], IMBOX_BASE
, mboxarray
, size
);
1927 printk ("write to %X\n", IMBOX_BASE
);
1928 IFX_MEI_LongWordWriteOffset (&dsl_devices
[0], (u32
) ME_ME2ARC_INT
, MEI_TO_ARC_MSGAV
);
1931 /* This routine reads the output mailbox and places the results into an array */
1933 ReadMbox (u32
* mboxarray
, u32 size
)
1935 IFX_MEI_DebugRead (&dsl_devices
[0], OMBOX_BASE
, mboxarray
, size
);
1936 printk ("read from %X\n", OMBOX_BASE
);
1940 MEIWriteARCValue (u32 address
, u32 value
)
1944 /* Write address register */
1945 IFX_MEI_WRITE_REGISTER_L (address
, ME_DBG_WR_AD
+ IFXMIPS_MEI_BASE_ADDR
);
1947 /* Write data register */
1948 IFX_MEI_WRITE_REGISTER_L (value
, ME_DBG_DATA
+ IFXMIPS_MEI_BASE_ADDR
);
1950 /* wait until complete - timeout at 40 */
1951 for (i
= 0; i
< 40; i
++) {
1952 check
= IFX_MEI_READ_REGISTER_L (ME_ARC2ME_STAT
+ IFXMIPS_MEI_BASE_ADDR
);
1954 if ((check
& ARC_TO_MEI_DBG_DONE
))
1957 /* clear the flag */
1958 IFX_MEI_WRITE_REGISTER_L (ARC_TO_MEI_DBG_DONE
, ME_ARC2ME_STAT
+ IFXMIPS_MEI_BASE_ADDR
);
1962 arc_code_page_download (uint32_t arc_code_length
, uint32_t * start_address
)
1966 printk ("try to download pages,size=%d\n", arc_code_length
);
1967 IFX_MEI_ControlModeSet (&dsl_devices
[0], MEI_MASTER_MODE
);
1968 IFX_MEI_HaltArc (&dsl_devices
[0]);
1969 IFX_MEI_LongWordWriteOffset (&dsl_devices
[0], (u32
) ME_DX_AD
, 0);
1970 for (count
= 0; count
< arc_code_length
; count
++) {
1971 IFX_MEI_LongWordWriteOffset (&dsl_devices
[0], (u32
) ME_DX_DATA
,
1972 *(start_address
+ count
));
1974 IFX_MEI_ControlModeSet (&dsl_devices
[0], JTAG_MASTER_MODE
);
1977 load_jump_table (unsigned long addr
)
1980 uint32_t addr_le
, addr_be
;
1981 uint32_t jump_table
[32];
1983 for (i
= 0; i
< 16; i
++) {
1984 addr_le
= i
* 8 + addr
;
1985 addr_be
= ((addr_le
>> 16) & 0xffff);
1986 addr_be
|= ((addr_le
& 0xffff) << 16);
1987 jump_table
[i
* 2 + 0] = 0x0f802020;
1988 jump_table
[i
* 2 + 1] = addr_be
;
1989 //printk("jt %X %08X %08X\n",i,jump_table[i*2+0],jump_table[i*2+1]);
1991 arc_code_page_download (32, &jump_table
[0]);
1998 dfe_loopback_irq_handler (DSL_DEV_Device_t
*pDev
)
2000 uint32_t rd_mbox
[10];
2002 memset (&rd_mbox
[0], 0, 10 * 4);
2003 ReadMbox (&rd_mbox
[0], 6);
2004 if (rd_mbox
[0] == 0x0) {
2005 printk ("Get ARC_ACK\n");
2008 else if (rd_mbox
[0] == 0x5) {
2009 printk ("Get ARC_BUSY\n");
2012 else if (rd_mbox
[0] == 0x3) {
2013 printk ("Get ARC_EDONE\n");
2014 if (rd_mbox
[1] == 0x0) {
2016 printk ("Get E_MEMTEST\n");
2017 if (rd_mbox
[2] != 0x1) {
2019 printk ("Get Result %X\n", rd_mbox
[2]);
2023 IFX_MEI_LongWordWriteOffset (&dsl_devices
[0], (u32
) ME_ARC2ME_STAT
,
2024 ARC_TO_MEI_DBG_DONE
);
2025 MEI_MASK_AND_ACK_IRQ (pDev
->nIrq
[IFX_DFEIR
]);
2026 disable_irq (pDev
->nIrq
[IFX_DFEIR
]);
2032 wait_mem_test_result (void)
2037 printk ("Waiting Starting\n");
2038 while (mbox
[0] == 0) {
2039 ReadMbox (&mbox
[0], 5);
2041 printk ("Try to get mem test result.\n");
2042 ReadMbox (&mbox
[0], 5);
2043 if (mbox
[0] == 0xA) {
2044 printk ("Success.\n");
2046 else if (mbox
[0] == 0xA) {
2047 printk ("Fail,address %X,except data %X,receive data %X\n",
2048 mbox
[1], mbox
[2], mbox
[3]);
2056 arc_ping_testing (DSL_DEV_Device_t
*pDev
)
2058 #define MEI_PING 0x00000001
2059 uint32_t wr_mbox
[10], rd_mbox
[10];
2062 for (i
= 0; i
< 10; i
++) {
2067 printk ("send ping msg\n");
2068 wr_mbox
[0] = MEI_PING
;
2069 WriteMbox (&wr_mbox
[0], 10);
2071 while (got_int
== 0) {
2075 printk ("send start event\n");
2081 wr_mbox
[3] = (uint32_t) 0xf5acc307e;
2084 wr_mbox
[6] = 0x1c000;
2088 WriteMbox (&wr_mbox
[0], 10);
2089 DSL_ENABLE_IRQ (pDev
->nIrq
[IFX_DFEIR
]);
2090 //printk("IFX_MEI_MailboxWrite ret=%d\n",i);
2091 IFX_MEI_LongWordWriteOffset (&dsl_devices
[0],
2092 (u32
) ME_ME2ARC_INT
,
2094 printk ("sleeping\n");
2099 printk ("got_int >>>> 3\n");
2101 printk ("got int = %d\n", got_int
);
2104 DSL_ENABLE_IRQ (pDev
->nIrq
[IFX_DFEIR
]);
2106 //mbox_read(&rd_mbox[0],6);
2112 static DSL_DEV_MeiError_t
2113 DFE_Loopback_Test (void)
2116 u32 arc_debug_data
= 0, temp
;
2117 DSL_DEV_Device_t
*pDev
= &dsl_devices
[0];
2118 uint32_t wr_mbox
[10];
2120 IFX_MEI_ResetARC (pDev
);
2122 arc_debug_data
= ACL_CLK_MODE_ENABLE
;
2123 IFX_MEI_DebugWrite (pDev
, CRI_CCR0
, &arc_debug_data
, 1);
2125 #if defined( DFE_PING_TEST )|| defined( DFE_ATM_LOOPBACK)
2126 // WriteARCreg(AUX_XMEM_LTEST,0);
2127 IFX_MEI_ControlModeSet (pDev
, MEI_MASTER_MODE
);
2128 #define AUX_XMEM_LTEST 0x128
2129 _IFX_MEI_DBGLongWordWrite (pDev
, MEI_DEBUG_DEC_AUX_MASK
, AUX_XMEM_LTEST
, 0);
2130 IFX_MEI_ControlModeSet (pDev
, JTAG_MASTER_MODE
);
2132 // WriteARCreg(AUX_XDMA_GAP,0);
2133 IFX_MEI_ControlModeSet (pDev
, MEI_MASTER_MODE
);
2134 #define AUX_XDMA_GAP 0x114
2135 _IFX_MEI_DBGLongWordWrite (pDev
, MEI_DEBUG_DEC_AUX_MASK
, AUX_XDMA_GAP
, 0);
2136 IFX_MEI_ControlModeSet (pDev
, JTAG_MASTER_MODE
);
2138 IFX_MEI_ControlModeSet (pDev
, MEI_MASTER_MODE
);
2140 _IFX_MEI_DBGLongWordWrite (pDev
, MEI_DEBUG_DEC_AUX_MASK
,
2141 (u32
) ME_XDATA_BASE_SH
+ IFXMIPS_MEI_BASE_ADDR
, temp
);
2142 IFX_MEI_ControlModeSet (pDev
, JTAG_MASTER_MODE
);
2144 i
= IFX_MEI_DFEMemoryAlloc (pDev
, SDRAM_SEGMENT_SIZE
* 16);
2148 for (idx
= 0; idx
< i
; idx
++) {
2149 DSL_DEV_PRIVATE(pDev
)->adsl_mem_info
[idx
].type
= FREE_RELOAD
;
2150 IFX_MEI_WRITE_REGISTER_L ((((uint32_t) DSL_DEV_PRIVATE(pDev
)->adsl_mem_info
[idx
].address
) & 0x0fffffff),
2151 IFXMIPS_MEI_BASE_ADDR
+ ME_XMEM_BAR_BASE
+ idx
* 4);
2152 printk ("bar%d(%X)=%X\n", idx
,
2153 IFXMIPS_MEI_BASE_ADDR
+ ME_XMEM_BAR_BASE
+
2154 idx
* 4, (((uint32_t)
2155 ((ifx_mei_device_private_t
*)
2156 pDev
->pPriv
)->adsl_mem_info
[idx
].
2157 address
) & 0x0fffffff));
2158 memset ((u8
*) DSL_DEV_PRIVATE(pDev
)->adsl_mem_info
[idx
].address
, 0, SDRAM_SEGMENT_SIZE
);
2161 IFX_MEI_LongWordWriteOffset (pDev
, (u32
) ME_XDATA_BASE_SH
,
2162 ((unsigned long) DSL_DEV_PRIVATE(pDev
)->adsl_mem_info
[XDATA_REGISTER
].address
) & 0x0FFFFFFF);
2165 IFX_MEI_EMSG ("cannot load image: no memory\n");
2166 return DSL_DEV_MEI_ERR_FAILURE
;
2168 //WriteARCreg(AUX_IC_CTRL,2);
2169 printk(KERN_INFO
"[%s %s %d]: Setting MEI_MASTER_MODE..\n", __FILE__
, __func__
, __LINE__
);
2170 IFX_MEI_ControlModeSet (pDev
, MEI_MASTER_MODE
);
2171 #define AUX_IC_CTRL 0x11
2172 _IFX_MEI_DBGLongWordWrite (pDev
, MEI_DEBUG_DEC_AUX_MASK
,
2174 printk(KERN_INFO
"[%s %s %d]: Setting JTAG_MASTER_MODE..\n", __FILE__
, __func__
, __LINE__
);
2175 IFX_MEI_ControlModeSet (pDev
, JTAG_MASTER_MODE
);
2177 printk(KERN_INFO
"[%s %s %d]: Halting ARC...\n", __FILE__
, __func__
, __LINE__
);
2178 IFX_MEI_HaltArc (&dsl_devices
[0]);
2180 #ifdef DFE_PING_TEST
2182 printk ("ping test image size=%d\n", sizeof (arc_ahb_access_code
));
2183 memcpy ((u8
*) (DSL_DEV_PRIVATE(pDev
)->
2184 adsl_mem_info
[0].address
+ 0x1004),
2185 &arc_ahb_access_code
[0], sizeof (arc_ahb_access_code
));
2186 load_jump_table (0x80000 + 0x1004);
2188 #endif //DFE_PING_TEST
2190 printk ("ARC ping test code download complete\n");
2191 #endif //defined( DFE_PING_TEST )|| defined( DFE_ATM_LOOPBACK)
2193 IFX_MEI_LongWordWriteOffset (&dsl_devices
[0], (u32
) ME_ARC2ME_MASK
, MSGAV_EN
);
2195 arc_code_page_download (1537, &code_array
[0]);
2196 printk ("ARC mem test code download complete\n");
2197 #endif //DFE_MEM_TEST
2198 #ifdef DFE_ATM_LOOPBACK
2199 arc_debug_data
= 0xf;
2200 arc_code_page_download (sizeof(code_array
) / sizeof(*code_array
), &code_array
[0]);
2201 wr_mbox
[0] = 0; //TIMER_DELAY - org: 1024
2202 wr_mbox
[1] = 0; //TXFB_START0
2203 wr_mbox
[2] = 0x7f; //TXFB_END0 - org: 49
2204 wr_mbox
[3] = 0x80; //TXFB_START1 - org: 80
2205 wr_mbox
[4] = 0xff; //TXFB_END1 - org: 109
2206 wr_mbox
[5] = 0x100; //RXFB_START0 - org: 0
2207 wr_mbox
[6] = 0x17f; //RXFB_END0 - org: 49
2208 wr_mbox
[7] = 0x180; //RXFB_START1 - org: 256
2209 wr_mbox
[8] = 0x1ff; //RXFB_END1 - org: 315
2210 WriteMbox (&wr_mbox
[0], 9);
2211 // Start Iridia IT_AMODE (in dmp access) why is it required?
2212 IFX_MEI_DebugWrite (&dsl_devices
[0], 0x32010, &arc_debug_data
, 1);
2213 #endif //DFE_ATM_LOOPBACK
2214 IFX_MEI_IRQEnable (pDev
);
2215 printk(KERN_INFO
"[%s %s %d]: run ARC...\n", __FILE__
, __func__
, __LINE__
);
2216 IFX_MEI_RunArc (&dsl_devices
[0]);
2218 #ifdef DFE_PING_TEST
2219 arc_ping_testing (pDev
);
2220 #endif //DFE_PING_TEST
2222 wait_mem_test_result ();
2223 #endif //DFE_MEM_TEST
2225 IFX_MEI_DFEMemoryFree (pDev
, FREE_ALL
);
2226 return DSL_DEV_MEI_ERR_SUCCESS
;
2229 #endif //CONFIG_AMAZON_S_MEI_FW_LOOPBACK
2232 IFX_MEI_InitDevNode (int num
)
2235 if ((dev_major
= register_chrdev (dev_major
, IFX_MEI_DEVNAME
, &bsp_mei_operations
)) < 0) {
2236 IFX_MEI_EMSG ("register_chrdev(%d %s) failed!\n", dev_major
, IFX_MEI_DEVNAME
);
2244 IFX_MEI_CleanUpDevNode (int num
)
2247 unregister_chrdev (dev_major
, MEI_DIRNAME
);
2252 IFX_MEI_InitDevice (int num
)
2254 DSL_DEV_Device_t
*pDev
;
2256 pDev
= &dsl_devices
[num
];
2259 pDev
->pPriv
= &sDanube_Mei_Private
[num
];
2260 memset (pDev
->pPriv
, 0, sizeof (ifx_mei_device_private_t
));
2262 memset (&DSL_DEV_PRIVATE(pDev
)->
2263 adsl_mem_info
[0], 0,
2264 sizeof (smmu_mem_info_t
) * MAX_BAR_REGISTERS
);
2267 pDev
->nIrq
[IFX_DFEIR
] = IFXMIPS_MEI_INT
;
2268 pDev
->nIrq
[IFX_DYING_GASP
] = IFXMIPS_MEI_DYING_GASP_INT
;
2269 pDev
->base_address
= IFXMIPS_MEI_BASE_ADDR
;
2272 #ifdef CONFIG_IFXMIPS_AMAZON_SE
2273 *IFXMIPS_PMU_PWDCR
&= ~(1 << 9); // enable dsl
2274 *IFXMIPS_PMU_PWDCR
&= ~(1 << 15); // enable AHB base
2276 temp
= ifxmips_r32(IFXMIPS_PMU_PWDCR
);
2278 ifxmips_w32(temp
, IFXMIPS_PMU_PWDCR
);
2282 DSL_DEV_PRIVATE(pDev
)->modem_ready
= 0;
2283 DSL_DEV_PRIVATE(pDev
)->arcmsgav
= 0;
2285 MEI_INIT_WAKELIST ("arcq", DSL_DEV_PRIVATE(pDev
)->wait_queue_arcmsgav
); // for ARCMSGAV
2286 MEI_INIT_WAKELIST ("arcr", DSL_DEV_PRIVATE(pDev
)->wait_queue_modemready
); // for arc modem ready
2288 MEI_MUTEX_INIT (DSL_DEV_PRIVATE(pDev
)->mei_cmv_sema
, 1); // semaphore initialization, mutex
2290 MEI_MASK_AND_ACK_IRQ (pDev
->nIrq
[IFX_DFEIR
]);
2291 MEI_MASK_AND_ACK_IRQ (pDev
->nIrq
[IFX_DYING_GASP
]);
2293 if (request_irq (pDev
->nIrq
[IFX_DFEIR
], IFX_MEI_IrqHandle
, 0, "DFEIR", pDev
) != 0) {
2294 IFX_MEI_EMSG ("request_irq %d failed!\n", pDev
->nIrq
[IFX_DFEIR
]);
2297 if (request_irq (pDev
->nIrq
[IFX_DYING_GASP
], IFX_MEI_Dying_Gasp_IrqHandle
, 0, "DYING_GASP", pDev
) != 0) {
2298 IFX_MEI_EMSG ("request_irq %d failed!\n", pDev
->nIrq
[IFX_DYING_GASP
]);
2301 // IFX_MEI_DMSG("Device %d initialized. IER %#x\n", num, bsp_get_irq_ier(pDev->nIrq[IFX_DYING_GASP]));
2306 IFX_MEI_ExitDevice (int num
)
2308 DSL_DEV_Device_t
*pDev
;
2309 pDev
= &dsl_devices
[num
];
2314 disable_irq (pDev
->nIrq
[IFX_DFEIR
]);
2315 disable_irq (pDev
->nIrq
[IFX_DYING_GASP
]);
2317 free_irq(pDev
->nIrq
[IFX_DFEIR
], pDev
);
2318 free_irq(pDev
->nIrq
[IFX_DYING_GASP
], pDev
);
2323 static DSL_DEV_Device_t
*
2324 IFX_BSP_HandleGet (int maj
, int num
)
2326 if (num
> BSP_MAX_DEVICES
)
2328 return &dsl_devices
[num
];
2332 DSL_BSP_DriverHandleGet (int maj
, int num
)
2334 DSL_DEV_Device_t
*pDev
;
2336 if (num
> BSP_MAX_DEVICES
)
2339 pDev
= &dsl_devices
[num
];
2340 if (!try_module_get(pDev
->owner
))
2348 DSL_BSP_DriverHandleDelete (DSL_DEV_Device_t
* nHandle
)
2350 DSL_DEV_Device_t
*pDev
= (DSL_DEV_Device_t
*) nHandle
;
2353 module_put(pDev
->owner
);
2358 IFX_MEI_Open (DSL_DRV_inode_t
* ino
, DSL_DRV_file_t
* fil
)
2360 int maj
= MAJOR (ino
->i_rdev
);
2361 int num
= MINOR (ino
->i_rdev
);
2363 DSL_DEV_Device_t
*pDev
= NULL
;
2364 if ((pDev
= DSL_BSP_DriverHandleGet (maj
, num
)) == NULL
) {
2365 IFX_MEI_EMSG("open(%d:%d) fail!\n", maj
, num
);
2368 fil
->private_data
= pDev
;
2373 IFX_MEI_Release (DSL_DRV_inode_t
* ino
, DSL_DRV_file_t
* fil
)
2375 //int maj = MAJOR(ino->i_rdev);
2376 int num
= MINOR (ino
->i_rdev
);
2377 DSL_DEV_Device_t
*pDev
;
2379 pDev
= &dsl_devices
[num
];
2382 DSL_BSP_DriverHandleDelete (pDev
);
2387 * Callback function for linux userspace program writing
2390 IFX_MEI_Write (DSL_DRV_file_t
* filp
, const char *buf
, size_t size
, loff_t
* loff
)
2392 DSL_DEV_MeiError_t mei_error
= DSL_DEV_MEI_ERR_FAILURE
;
2394 DSL_DEV_Device_t
*pDev
= (DSL_DEV_Device_t
*) filp
->private_data
;
2400 DSL_BSP_FWDownload (pDev
, buf
, size
, (long *) loff
, &offset
);
2402 if (mei_error
== DSL_DEV_MEI_ERR_FAILURE
)
2404 return (ssize_t
) offset
;
2408 * Callback function for linux userspace program ioctling
2411 IFX_MEI_IoctlCopyFrom (int from_kernel
, char *dest
, char *from
, int size
)
2416 ret
= copy_from_user ((char *) dest
, (char *) from
, size
);
2418 ret
= (int)memcpy ((char *) dest
, (char *) from
, size
);
2423 IFX_MEI_IoctlCopyTo (int from_kernel
, char *dest
, char *from
, int size
)
2428 ret
= copy_to_user ((char *) dest
, (char *) from
, size
);
2430 ret
= (int)memcpy ((char *) dest
, (char *) from
, size
);
2435 IFX_MEI_Ioctls (DSL_DEV_Device_t
* pDev
, int from_kernel
, unsigned int command
, unsigned long lon
)
2438 int meierr
= DSL_DEV_MEI_ERR_SUCCESS
;
2439 u32 base_address
= IFXMIPS_MEI_BASE_ADDR
;
2440 DSL_DEV_WinHost_Message_t winhost_msg
, m
;
2441 DSL_DEV_MeiDebug_t debugrdwr
;
2442 DSL_DEV_MeiReg_t regrdwr
;
2446 case DSL_FIO_BSP_CMV_WINHOST
:
2447 IFX_MEI_IoctlCopyFrom (from_kernel
, (char *) winhost_msg
.msg
.TxMessage
,
2448 (char *) lon
, MSG_LENGTH
* 2);
2450 if ((meierr
= DSL_BSP_SendCMV (pDev
, winhost_msg
.msg
.TxMessage
, YES_REPLY
,
2451 winhost_msg
.msg
.RxMessage
)) != DSL_DEV_MEI_ERR_SUCCESS
) {
2452 IFX_MEI_EMSG ("WINHOST CMV fail :TxMessage:%X %X %X %X, RxMessage:%X %X %X %X %X\n",
2453 winhost_msg
.msg
.TxMessage
[0], winhost_msg
.msg
.TxMessage
[1], winhost_msg
.msg
.TxMessage
[2], winhost_msg
.msg
.TxMessage
[3],
2454 winhost_msg
.msg
.RxMessage
[0], winhost_msg
.msg
.RxMessage
[1], winhost_msg
.msg
.RxMessage
[2], winhost_msg
.msg
.RxMessage
[3],
2455 winhost_msg
.msg
.RxMessage
[4]);
2456 meierr
= DSL_DEV_MEI_ERR_FAILURE
;
2459 IFX_MEI_IoctlCopyTo (from_kernel
, (char *) lon
,
2460 (char *) winhost_msg
.msg
.RxMessage
,
2465 case DSL_FIO_BSP_CMV_READ
:
2466 IFX_MEI_IoctlCopyFrom (from_kernel
, (char *) (®rdwr
),
2467 (char *) lon
, sizeof (DSL_DEV_MeiReg_t
));
2469 IFX_MEI_LongWordRead ((u32
) regrdwr
.iAddress
,
2470 (u32
*) & (regrdwr
.iData
));
2472 IFX_MEI_IoctlCopyTo (from_kernel
, (char *) lon
,
2473 (char *) (®rdwr
),
2474 sizeof (DSL_DEV_MeiReg_t
));
2478 case DSL_FIO_BSP_CMV_WRITE
:
2479 IFX_MEI_IoctlCopyFrom (from_kernel
, (char *) (®rdwr
),
2480 (char *) lon
, sizeof (DSL_DEV_MeiReg_t
));
2482 IFX_MEI_LongWordWrite ((u32
) regrdwr
.iAddress
,
2486 case DSL_FIO_BSP_GET_BASE_ADDRESS
:
2487 IFX_MEI_IoctlCopyTo (from_kernel
, (char *) lon
,
2488 (char *) (&base_address
),
2489 sizeof (base_address
));
2492 case DSL_FIO_BSP_IS_MODEM_READY
:
2493 i
= IFX_MEI_IsModemReady (pDev
);
2494 IFX_MEI_IoctlCopyTo (from_kernel
, (char *) lon
,
2495 (char *) (&i
), sizeof (int));
2496 meierr
= DSL_DEV_MEI_ERR_SUCCESS
;
2498 case DSL_FIO_BSP_RESET
:
2499 case DSL_FIO_BSP_REBOOT
:
2500 meierr
= IFX_MEI_CpuModeSet (pDev
, DSL_CPU_RESET
);
2501 meierr
= IFX_MEI_CpuModeSet (pDev
, DSL_CPU_HALT
);
2504 case DSL_FIO_BSP_HALT
:
2505 meierr
= IFX_MEI_CpuModeSet (pDev
, DSL_CPU_HALT
);
2508 case DSL_FIO_BSP_RUN
:
2509 meierr
= IFX_MEI_CpuModeSet (pDev
, DSL_CPU_RUN
);
2511 case DSL_FIO_BSP_BOOTDOWNLOAD
:
2512 meierr
= IFX_MEI_DownloadBootCode (pDev
);
2514 case DSL_FIO_BSP_JTAG_ENABLE
:
2515 meierr
= IFX_MEI_ArcJtagEnable (pDev
, 1);
2518 case DSL_FIO_BSP_REMOTE
:
2519 IFX_MEI_IoctlCopyFrom (from_kernel
, (char *) (&i
),
2520 (char *) lon
, sizeof (int));
2522 meierr
= IFX_MEI_AdslMailboxIRQEnable (pDev
, i
);
2525 case DSL_FIO_BSP_DSL_START
:
2526 printk("\n%s: DSL_FIO_BSP_DSL_START\n",__func__
);
2527 if ((meierr
= IFX_MEI_RunAdslModem (pDev
)) != DSL_DEV_MEI_ERR_SUCCESS
) {
2528 IFX_MEI_EMSG ("IFX_MEI_RunAdslModem() error...");
2529 meierr
= DSL_DEV_MEI_ERR_FAILURE
;
2533 case DSL_FIO_BSP_DEBUG_READ
:
2534 case DSL_FIO_BSP_DEBUG_WRITE
:
2535 IFX_MEI_IoctlCopyFrom (from_kernel
,
2536 (char *) (&debugrdwr
),
2538 sizeof (debugrdwr
));
2540 if (command
== DSL_FIO_BSP_DEBUG_READ
)
2541 meierr
= DSL_BSP_MemoryDebugAccess (pDev
,
2542 DSL_BSP_MEMORY_READ
,
2550 meierr
= DSL_BSP_MemoryDebugAccess (pDev
,
2551 DSL_BSP_MEMORY_WRITE
,
2559 IFX_MEI_IoctlCopyTo (from_kernel
, (char *) lon
, (char *) (&debugrdwr
), sizeof (debugrdwr
));
2561 case DSL_FIO_BSP_GET_VERSION
:
2562 IFX_MEI_IoctlCopyTo (from_kernel
, (char *) lon
, (char *) (&bsp_mei_version
), sizeof (DSL_DEV_Version_t
));
2565 case DSL_FIO_BSP_GET_CHIP_INFO
:
2566 bsp_chip_info
.major
= 1;
2567 bsp_chip_info
.minor
= IFXMIPS_MPS_CHIPID_VERSION_GET(*IFXMIPS_MPS_CHIPID
);
2568 IFX_MEI_IoctlCopyTo (from_kernel
, (char *) lon
, (char *) (&bsp_chip_info
), sizeof (DSL_DEV_HwVersion_t
));
2569 meierr
= DSL_DEV_MEI_ERR_SUCCESS
;
2572 case DSL_FIO_BSP_FREE_RESOURCE
:
2573 makeCMV (H2D_CMV_READ
, DSL_CMV_GROUP_STAT
, 4, 0, 1, NULL
, m
.msg
.TxMessage
);
2574 if (DSL_BSP_SendCMV (pDev
, m
.msg
.TxMessage
, YES_REPLY
, m
.msg
.RxMessage
) != DSL_DEV_MEI_ERR_SUCCESS
) {
2575 meierr
= DSL_DEV_MEI_ERR_FAILURE
;
2578 IFX_MEI_DMSG("RxMessage[4] = %#x\n", m
.msg
.RxMessage
[4]);
2579 if (!(m
.msg
.RxMessage
[4] & DSL_DEV_STAT_CODESWAP_COMPLETE
)) {
2580 meierr
= DSL_DEV_MEI_ERR_FAILURE
;
2583 IFX_MEI_DMSG("Freeing all memories marked FREE_SHOWTIME\n");
2584 IFX_MEI_DFEMemoryFree (pDev
, FREE_SHOWTIME
);
2585 meierr
= DSL_DEV_MEI_ERR_SUCCESS
;
2587 #ifdef CONFIG_IFXMIPS_AMAZON_SE
2588 case DSL_FIO_ARC_MUX_TEST
:
2589 AMAZON_SE_MEI_ARC_MUX_Test();
2593 // IFX_MEI_EMSG("Invalid IOCTL command: %d\n");
2599 #ifdef CONFIG_IFXMIPS_AMAZON_SE
2600 void AMAZON_SE_MEI_ARC_MUX_Test(void)
2603 *IFXMIPS_RCU_RST
|= IFXMIPS_RCU_RST_REQ_MUX_ARC
;
2605 p
= (u32
*)(DFE_LDST_BASE_ADDR
+ IRAM0_BASE
);
2606 IFX_MEI_EMSG("Writing to IRAM0(%p)...\n", p
);
2607 for (i
= 0; i
< IRAM0_SIZE
/sizeof(u32
); i
++, p
++) {
2609 if (*p
!= 0xdeadbeef)
2610 IFX_MEI_EMSG("%p: %#x\n", p
, *p
);
2613 p
= (u32
*)(DFE_LDST_BASE_ADDR
+ IRAM1_BASE
);
2614 IFX_MEI_EMSG("Writing to IRAM1(%p)...\n", p
);
2615 for (i
= 0; i
< IRAM1_SIZE
/sizeof(u32
); i
++, p
++) {
2617 if (*p
!= 0xdeadbeef)
2618 IFX_MEI_EMSG("%p: %#x\n", p
, *p
);
2621 p
= (u32
*)(DFE_LDST_BASE_ADDR
+ BRAM_BASE
);
2622 IFX_MEI_EMSG("Writing to BRAM(%p)...\n", p
);
2623 for (i
= 0; i
< BRAM_SIZE
/sizeof(u32
); i
++, p
++) {
2625 if (*p
!= 0xdeadbeef)
2626 IFX_MEI_EMSG("%p: %#x\n", p
, *p
);
2629 p
= (u32
*)(DFE_LDST_BASE_ADDR
+ XRAM_BASE
);
2630 IFX_MEI_EMSG("Writing to XRAM(%p)...\n", p
);
2631 for (i
= 0; i
< XRAM_SIZE
/sizeof(u32
); i
++, p
++) {
2633 if (*p
!= 0xdeadbeef)
2634 IFX_MEI_EMSG("%p: %#x\n", p
, *p
);
2637 p
= (u32
*)(DFE_LDST_BASE_ADDR
+ YRAM_BASE
);
2638 IFX_MEI_EMSG("Writing to YRAM(%p)...\n", p
);
2639 for (i
= 0; i
< YRAM_SIZE
/sizeof(u32
); i
++, p
++) {
2641 if (*p
!= 0xdeadbeef)
2642 IFX_MEI_EMSG("%p: %#x\n", p
, *p
);
2645 p
= (u32
*)(DFE_LDST_BASE_ADDR
+ EXT_MEM_BASE
);
2646 IFX_MEI_EMSG("Writing to EXT_MEM(%p)...\n", p
);
2647 for (i
= 0; i
< EXT_MEM_SIZE
/sizeof(u32
); i
++, p
++) {
2649 if (*p
!= 0xdeadbeef)
2650 IFX_MEI_EMSG("%p: %#x\n", p
, *p
);
2652 *IFXMIPS_RCU_RST
&= ~IFXMIPS_RCU_RST_REQ_MUX_ARC
;
2656 DSL_BSP_KernelIoctls (DSL_DEV_Device_t
* pDev
, unsigned int command
,
2661 error
= IFX_MEI_Ioctls (pDev
, 1, command
, lon
);
2666 IFX_MEI_UserIoctls (DSL_DRV_inode_t
* ino
, DSL_DRV_file_t
* fil
,
2667 unsigned int command
, unsigned long lon
)
2670 int maj
= MAJOR (ino
->i_rdev
);
2671 int num
= MINOR (ino
->i_rdev
);
2672 DSL_DEV_Device_t
*pDev
;
2674 pDev
= IFX_BSP_HandleGet (maj
, num
);
2678 error
= IFX_MEI_Ioctls (pDev
, 0, command
, lon
);
2682 #ifdef CONFIG_PROC_FS
2684 * Register a callback function for linux proc filesystem
2687 IFX_MEI_InitProcFS (int num
)
2689 struct proc_dir_entry
*entry
;
2691 DSL_DEV_Device_t
*pDev
;
2692 reg_entry_t regs_temp
[PROC_ITEMS
] = {
2693 /* flag, name, description } */
2694 {NULL
, "arcmsgav", "arc to mei message ", 0},
2695 {NULL
, "cmv_reply", "cmv needs reply", 0},
2696 {NULL
, "cmv_waiting", "waiting for cmv reply from arc", 0},
2697 {NULL
, "modem_ready_cnt", "ARC to MEI indicator count", 0},
2698 {NULL
, "cmv_count", "MEI to ARC CMVs", 0},
2699 {NULL
, "reply_count", "ARC to MEI Reply", 0},
2700 {NULL
, "Recent_indicator", "most recent indicator", 0},
2701 {NULL
, "fw_version", "Firmware Version", 0},
2702 {NULL
, "fw_date", "Firmware Date", 0},
2703 {NULL
, "meminfo", "Memory Allocation Information", 0},
2704 {NULL
, "version", "MEI version information", 0},
2707 pDev
= &dsl_devices
[num
];
2711 regs_temp
[0].flag
= &(DSL_DEV_PRIVATE(pDev
)->arcmsgav
);
2712 regs_temp
[1].flag
= &(DSL_DEV_PRIVATE(pDev
)->cmv_reply
);
2713 regs_temp
[2].flag
= &(DSL_DEV_PRIVATE(pDev
)->cmv_waiting
);
2714 regs_temp
[3].flag
= &(DSL_DEV_PRIVATE(pDev
)->modem_ready_cnt
);
2715 regs_temp
[4].flag
= &(DSL_DEV_PRIVATE(pDev
)->cmv_count
);
2716 regs_temp
[5].flag
= &(DSL_DEV_PRIVATE(pDev
)->reply_count
);
2717 regs_temp
[6].flag
= (int *) &(DSL_DEV_PRIVATE(pDev
)->Recent_indicator
);
2719 memcpy ((char *) regs
[num
], (char *) regs_temp
, sizeof (regs_temp
));
2721 meidir
= proc_mkdir (MEI_DIRNAME
, NULL
);
2722 if (meidir
== NULL
) {
2723 IFX_MEI_EMSG ("Failed to create /proc/%s\n", MEI_DIRNAME
);
2727 for (i
= 0; i
< NUM_OF_REG_ENTRY
; i
++) {
2728 entry
= create_proc_entry (regs
[num
][i
].name
,
2729 S_IWUSR
| S_IRUSR
| S_IRGRP
|
2732 regs
[num
][i
].low_ino
= entry
->low_ino
;
2733 entry
->proc_fops
= &IFX_MEI_ProcOperations
;
2736 IFX_MEI_EMSG ("Failed to create /proc/%s/%s\n", MEI_DIRNAME
, regs
[num
][i
].name
);
2744 * Reading function for linux proc filesystem
2747 IFX_MEI_ProcRead (struct file
*file
, char *buf
, size_t nbytes
, loff_t
* ppos
)
2749 int i_ino
= (file
->f_dentry
->d_inode
)->i_ino
;
2753 reg_entry_t
*entry
= NULL
;
2754 DSL_DEV_Device_t
*pDev
= NULL
;
2755 DSL_DEV_WinHost_Message_t m
;
2757 for (num
= 0; num
< BSP_MAX_DEVICES
; num
++) {
2758 for (i
= 0; i
< NUM_OF_REG_ENTRY
; i
++) {
2759 if (regs
[num
][i
].low_ino
== (unsigned short)i_ino
) {
2760 entry
= ®s
[num
][i
];
2761 pDev
= &dsl_devices
[num
];
2768 else if (strcmp(entry
->name
, "meminfo") == 0) {
2769 if (*ppos
> 0) /* Assume reading completed in previous read */
2771 p
+= sprintf (p
, "No Address Size\n");
2772 for (i
= 0; i
< MAX_BAR_REGISTERS
; i
++) {
2773 p
+= sprintf (p
, "BAR[%02d] Addr:0x%08X Size:%lu\n",
2774 i
, (u32
) DSL_DEV_PRIVATE(pDev
)->adsl_mem_info
[i
].address
,
2775 DSL_DEV_PRIVATE(pDev
)-> adsl_mem_info
[i
].size
);
2776 //printk( "BAR[%02d] Addr:0x%08X Size:%d\n",i,adsl_mem_info[i].address,adsl_mem_info[i].size);
2779 } else if (strcmp(entry
->name
, "fw_version") == 0) {
2780 if (*ppos
> 0) /* Assume reading completed in previous read */
2782 if (DSL_DEV_PRIVATE(pDev
)->modem_ready_cnt
< 1)
2786 makeCMV (H2D_CMV_READ
, DSL_CMV_GROUP_INFO
, 54, 0, 1, NULL
, m
.msg
.TxMessage
);
2787 if (DSL_BSP_SendCMV (pDev
, m
.msg
.TxMessage
, YES_REPLY
, m
.msg
.RxMessage
) != DSL_DEV_MEI_ERR_SUCCESS
)
2789 p
+= sprintf(p
, "FW Version: %d.%d.", m
.msg
.RxMessage
[4] & 0xFF, (m
.msg
.RxMessage
[4] >> 8) & 0xFF);
2790 //sub_version:bits 4-7
2791 //int_version:bits 0-3
2792 //spl_appl:bits 8-13
2793 //rel_state:bits 14-15
2794 makeCMV (H2D_CMV_READ
, DSL_CMV_GROUP_INFO
, 54, 1, 1, NULL
, m
.msg
.TxMessage
);
2795 if (DSL_BSP_SendCMV (pDev
, m
.msg
.TxMessage
, YES_REPLY
, m
.msg
.RxMessage
) != DSL_DEV_MEI_ERR_SUCCESS
)
2797 p
+= sprintf(p
, "%d.%d.%d.%d\n",
2798 (m
.msg
.RxMessage
[4] >> 4) & 0xF, m
.msg
.RxMessage
[4] & 0xF,
2799 (m
.msg
.RxMessage
[4] >> 14) & 3, (m
.msg
.RxMessage
[4] >> 8) & 0x3F);
2801 } else if (strcmp(entry
->name
, "fw_date") == 0) {
2802 if (*ppos
> 0) /* Assume reading completed in previous read */
2804 if (DSL_DEV_PRIVATE(pDev
)->modem_ready_cnt
< 1)
2807 makeCMV (H2D_CMV_READ
, DSL_CMV_GROUP_INFO
, 55, 0, 1, NULL
, m
.msg
.TxMessage
);
2808 if (DSL_BSP_SendCMV (pDev
, m
.msg
.TxMessage
, YES_REPLY
, m
.msg
.RxMessage
) != DSL_DEV_MEI_ERR_SUCCESS
)
2811 p
+= sprintf(p
, "FW Date: %d.%d.", m
.msg
.RxMessage
[4] & 0xFF, (m
.msg
.RxMessage
[4] >> 8) & 0xFF);
2813 makeCMV (H2D_CMV_READ
, DSL_CMV_GROUP_INFO
, 55, 2, 1, NULL
, m
.msg
.TxMessage
);
2814 if (DSL_BSP_SendCMV (pDev
, m
.msg
.TxMessage
, YES_REPLY
, m
.msg
.RxMessage
) != DSL_DEV_MEI_ERR_SUCCESS
)
2817 p
+= sprintf(p
, "%d ", m
.msg
.RxMessage
[4]);
2819 makeCMV (H2D_CMV_READ
, DSL_CMV_GROUP_INFO
, 55, 1, 1, NULL
, m
.msg
.TxMessage
);
2820 if (DSL_BSP_SendCMV (pDev
, m
.msg
.TxMessage
, YES_REPLY
, m
.msg
.RxMessage
) != DSL_DEV_MEI_ERR_SUCCESS
)
2823 p
+= sprintf(p
, "%d:%d\n", (m
.msg
.RxMessage
[4] >> 8) & 0xFF, m
.msg
.RxMessage
[4] & 0xFF);
2826 } else if (strcmp(entry
->name
, "version") == 0) {
2827 if (*ppos
> 0) /* Assume reading completed in previous read */
2829 p
+= sprintf (p
, "IFX MEI V%ld.%ld.%ld\n", bsp_mei_version
.major
, bsp_mei_version
.minor
, bsp_mei_version
.revision
);
2832 } else if (entry
->flag
!= (int *) DSL_DEV_PRIVATE(pDev
)->Recent_indicator
) {
2833 if (*ppos
> 0) /* Assume reading completed in previous read */
2834 return 0; // indicates end of file
2835 p
+= sprintf (p
, "0x%08X\n\n", *(entry
->flag
));
2837 if ((p
- buf
) > nbytes
) /* Assume output can be read at one time */
2840 if ((int) (*ppos
) / ((int) 7) == 16)
2841 return 0; // indicate end of the message
2842 p
+= sprintf (p
, "0x%04X\n\n", *(((u16
*) (entry
->flag
)) + (int) (*ppos
) / ((int) 7)));
2849 * Writing function for linux proc filesystem
2852 IFX_MEI_ProcWrite (struct file
*file
, const char *buffer
, size_t count
, loff_t
* ppos
)
2854 int i_ino
= (file
->f_dentry
->d_inode
)->i_ino
;
2855 reg_entry_t
*current_reg
= NULL
;
2858 unsigned long newRegValue
= 0;
2860 DSL_DEV_Device_t
*pDev
= NULL
;
2862 for (num
= 0; num
< BSP_MAX_DEVICES
; num
++) {
2863 for (i
= 0; i
< NUM_OF_REG_ENTRY
; i
++) {
2864 if (regs
[num
][i
].low_ino
== i_ino
) {
2865 current_reg
= ®s
[num
][i
];
2866 pDev
= &dsl_devices
[num
];
2871 if ((current_reg
== NULL
)
2872 || (current_reg
->flag
==
2873 (int *) DSL_DEV_PRIVATE(pDev
)->
2877 newRegValue
= simple_strtoul (buffer
, &endp
, 0);
2878 *(current_reg
->flag
) = (int) newRegValue
;
2879 return (count
+ endp
- buffer
);
2881 #endif //CONFIG_PROC_FS
2883 static int adsl_dummy_ledcallback(void)
2888 int ifx_mei_atm_led_blink(void)
2890 return g_adsl_ledcallback();
2892 EXPORT_SYMBOL(ifx_mei_atm_led_blink
);
2894 int ifx_mei_atm_showtime_check(int *is_showtime
, struct port_cell_info
*port_cell
, void **xdata_addr
)
2898 if ( is_showtime
) {
2899 *is_showtime
= g_tx_link_rate
[0] == 0 && g_tx_link_rate
[1] == 0 ? 0 : 1;
2903 for ( i
= 0; i
< port_cell
->port_num
&& i
< 2; i
++ )
2904 port_cell
->tx_link_rate
[i
] = g_tx_link_rate
[i
];
2908 if ( g_tx_link_rate
[0] == 0 && g_tx_link_rate
[1] == 0 )
2911 *xdata_addr
= g_xdata_addr
;
2916 EXPORT_SYMBOL(ifx_mei_atm_showtime_check
);
2919 * Writing function for linux proc filesystem
2922 IFX_MEI_ModuleInit (void)
2926 printk ("IFX MEI Version %ld.%02ld.%02ld", bsp_mei_version
.major
, bsp_mei_version
.minor
, bsp_mei_version
.revision
);
2928 for (i
= 0; i
< BSP_MAX_DEVICES
; i
++) {
2929 if (IFX_MEI_InitDevice (i
) != 0) {
2930 printk ("%s: Init device fail!\n", __FUNCTION__
);
2933 IFX_MEI_InitDevNode (i
);
2934 #ifdef CONFIG_PROC_FS
2935 IFX_MEI_InitProcFS (i
);
2938 for (i
= 0; i
<= DSL_BSP_CB_LAST
; i
++)
2939 dsl_bsp_event_callback
[i
].function
= NULL
;
2941 #ifdef CONFIG_IFXMIPS_MEI_FW_LOOPBACK
2942 printk(KERN_INFO
"[%s %s %d]: Start loopback test...\n", __FILE__
, __func__
, __LINE__
);
2943 DFE_Loopback_Test ();
2950 IFX_MEI_ModuleExit (void)
2955 for (num
= 0; num
< BSP_MAX_DEVICES
; num
++) {
2956 IFX_MEI_CleanUpDevNode (num
);
2957 #ifdef CONFIG_PROC_FS
2958 for (i
= 0; i
< NUM_OF_REG_ENTRY
; i
++) {
2959 remove_proc_entry (regs
[num
][i
].name
, meidir
);
2964 remove_proc_entry (MEI_DIRNAME
, NULL
);
2965 for (i
= 0; i
< BSP_MAX_DEVICES
; i
++) {
2966 for (i
= 0; i
< BSP_MAX_DEVICES
; i
++) {
2967 IFX_MEI_ExitDevice (i
);
2972 /* export function for DSL Driver */
2974 /* The functions of MEI_DriverHandleGet and MEI_DriverHandleDelete are
2975 something like open/close in kernel space , where the open could be used
2976 to register a callback for autonomous messages and returns a mei driver context pointer (comparable to the file descriptor in user space)
2977 The context will be required for the multi line chips future! */
2979 EXPORT_SYMBOL (DSL_BSP_DriverHandleGet
);
2980 EXPORT_SYMBOL (DSL_BSP_DriverHandleDelete
);
2982 EXPORT_SYMBOL (DSL_BSP_ATMLedCBRegister
);
2983 EXPORT_SYMBOL (DSL_BSP_ATMLedCBUnregister
);
2984 EXPORT_SYMBOL (DSL_BSP_KernelIoctls
);
2985 EXPORT_SYMBOL (DSL_BSP_AdslLedInit
);
2986 //EXPORT_SYMBOL (DSL_BSP_AdslLedSet);
2987 EXPORT_SYMBOL (DSL_BSP_FWDownload
);
2988 EXPORT_SYMBOL (DSL_BSP_Showtime
);
2990 EXPORT_SYMBOL (DSL_BSP_MemoryDebugAccess
);
2991 EXPORT_SYMBOL (DSL_BSP_SendCMV
);
2993 // provide a register/unregister function for DSL driver to register a event callback function
2994 EXPORT_SYMBOL (DSL_BSP_EventCBRegister
);
2995 EXPORT_SYMBOL (DSL_BSP_EventCBUnregister
);
2997 module_init (IFX_MEI_ModuleInit
);
2998 module_exit (IFX_MEI_ModuleExit
);