1 /******************************************************************************
3 ** FILE NAME : ifxmips_atm_vr9.c
9 ** DESCRIPTION : ATM driver common source file (core functions)
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 ** $Date $Author $Comment
21 ** 07 JUL 2009 Xu Liang Init Version
22 *******************************************************************************/
27 * ####################################
29 * ####################################
35 #include <linux/kernel.h>
36 #include <linux/module.h>
37 #include <linux/version.h>
38 #include <linux/types.h>
39 #include <linux/errno.h>
40 #include <linux/proc_fs.h>
41 #include <linux/init.h>
42 #include <linux/ioctl.h>
43 #include <linux/platform_device.h>
44 #include <linux/reset.h>
45 #include <asm/delay.h>
47 #include "ifxmips_atm_core.h"
48 #include "ifxmips_atm_fw_vr9.h"
52 #include <lantiq_soc.h>
54 #define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
55 #define IFX_PMU_MODULE_PPE_TC BIT(21)
56 #define IFX_PMU_MODULE_PPE_EMA BIT(22)
57 #define IFX_PMU_MODULE_PPE_QSB BIT(18)
58 #define IFX_PMU_MODULE_AHBS BIT(13)
59 #define IFX_PMU_MODULE_DSL_DFE BIT(9)
61 static inline void vr9_reset_ppe(struct platform_device
*pdev
)
63 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)
64 struct device
*dev
= &pdev
->dev
;
65 struct reset_control
*dsp
;
66 struct reset_control
*dfe
;
67 struct reset_control
*tc
;
69 dsp
= devm_reset_control_get(dev
, "dsp");
71 if (PTR_ERR(dsp
) != -EPROBE_DEFER
)
72 dev_err(dev
, "Failed to lookup dsp reset\n");
73 // return PTR_ERR(dsp);
76 dfe
= devm_reset_control_get(dev
, "dfe");
78 if (PTR_ERR(dfe
) != -EPROBE_DEFER
)
79 dev_err(dev
, "Failed to lookup dfe reset\n");
80 // return PTR_ERR(dfe);
83 tc
= devm_reset_control_get(dev
, "tc");
85 if (PTR_ERR(tc
) != -EPROBE_DEFER
)
86 dev_err(dev
, "Failed to lookup tc reset\n");
87 // return PTR_ERR(tc);
90 reset_control_assert(dsp
);
92 reset_control_assert(dfe
);
94 reset_control_assert(tc
);
96 *PP32_SRST
&= ~0x000303CF;
98 *PP32_SRST
|= 0x000303CF;
103 static inline int vr9_pp32_download_code(int pp32
, u32
*code_src
, unsigned int code_dword_len
, u32
*data_src
, unsigned int data_dword_len
)
105 unsigned int clr
, set
;
108 if ( code_src
== 0 || ((unsigned long)code_src
& 0x03) != 0
109 || data_src
== 0 || ((unsigned long)data_src
& 0x03) != 0 )
112 clr
= pp32
? 0xF0 : 0x0F;
113 if ( code_dword_len
<= CDM_CODE_MEMORYn_DWLEN(0) )
114 set
= pp32
? (3 << 6): (2 << 2);
117 IFX_REG_W32_MASK(clr
, set
, CDM_CFG
);
119 dest
= CDM_CODE_MEMORY(pp32
, 0);
120 while ( code_dword_len
-- > 0 )
121 IFX_REG_W32(*code_src
++, dest
++);
123 dest
= CDM_DATA_MEMORY(pp32
, 0);
124 while ( data_dword_len
-- > 0 )
125 IFX_REG_W32(*data_src
++, dest
++);
130 static void vr9_fw_ver(unsigned int *major
, unsigned int *minor
)
133 *major
= FW_VER_ID
->major
;
134 *minor
= FW_VER_ID
->minor
;
137 static void vr9_init(struct platform_device
*pdev
)
143 ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01
|
144 IFX_PMU_MODULE_PPE_TC
|
145 IFX_PMU_MODULE_PPE_EMA
|
146 IFX_PMU_MODULE_PPE_QSB
|
147 IFX_PMU_MODULE_AHBS
|
148 IFX_PMU_MODULE_DSL_DFE
);
153 IFX_REG_W32(0x08, PDMA_CFG
);
154 IFX_REG_W32(0x00203580, SAR_PDMA_RX_CMDBUF_CFG
);
155 IFX_REG_W32(0x004035A0, SAR_PDMA_RX_FW_CMDBUF_CFG
);
158 IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC
);
159 IFX_REG_W32(0x00000000, MBOX_IGU1_IER
);
160 IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC
);
161 IFX_REG_W32(0x00000000, MBOX_IGU3_IER
);
163 /* tc init - clear sync state */
167 /* init shared buffer */
169 for ( i
= 0; i
< SB_RAM0_DWLEN
+ SB_RAM1_DWLEN
+ SB_RAM2_DWLEN
+ SB_RAM3_DWLEN
; i
++ )
173 for ( i
= 0; i
< SB_RAM6_DWLEN
; i
++ )
177 static void vr9_shutdown(void)
181 static int vr9_start(int pp32
)
183 unsigned int mask
= 1 << (pp32
<< 4);
186 /* download firmware */
187 ret
= vr9_pp32_download_code(pp32
,
188 vr9_fw_bin
, sizeof(vr9_fw_bin
) / sizeof(*vr9_fw_bin
),
189 vr9_fw_data
, sizeof(vr9_fw_data
) / sizeof(*vr9_fw_data
));
194 IFX_REG_W32_MASK(mask
, 0, PP32_FREEZE
);
196 /* idle for a while to let PP32 init itself */
202 static void vr9_stop(int pp32
)
204 unsigned int mask
= 1 << (pp32
<< 4);
206 IFX_REG_W32_MASK(0, mask
, PP32_FREEZE
);
209 struct ltq_atm_ops vr9_ops
= {
211 .shutdown
= vr9_shutdown
,
214 .fw_ver
= vr9_fw_ver
,