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 struct device *dev = &pdev->dev;
64 struct reset_control *dsp;
65 struct reset_control *dfe;
66 struct reset_control *tc;
68 dsp = devm_reset_control_get(dev, "dsp");
70 if (PTR_ERR(dsp) != -EPROBE_DEFER)
71 dev_err(dev, "Failed to lookup dsp reset\n");
72 // return PTR_ERR(dsp);
75 dfe = devm_reset_control_get(dev, "dfe");
77 if (PTR_ERR(dfe) != -EPROBE_DEFER)
78 dev_err(dev, "Failed to lookup dfe reset\n");
79 // return PTR_ERR(dfe);
82 tc = devm_reset_control_get(dev, "tc");
84 if (PTR_ERR(tc) != -EPROBE_DEFER)
85 dev_err(dev, "Failed to lookup tc reset\n");
86 // return PTR_ERR(tc);
89 reset_control_assert(dsp);
91 reset_control_assert(dfe);
93 reset_control_assert(tc);
95 *PP32_SRST &= ~0x000303CF;
97 *PP32_SRST |= 0x000303CF;
101 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)
103 unsigned int clr, set;
106 if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
107 || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
110 clr = pp32 ? 0xF0 : 0x0F;
111 if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
112 set = pp32 ? (3 << 6): (2 << 2);
115 IFX_REG_W32_MASK(clr, set, CDM_CFG);
117 dest = CDM_CODE_MEMORY(pp32, 0);
118 while ( code_dword_len-- > 0 )
119 IFX_REG_W32(*code_src++, dest++);
121 dest = CDM_DATA_MEMORY(pp32, 0);
122 while ( data_dword_len-- > 0 )
123 IFX_REG_W32(*data_src++, dest++);
128 static void vr9_fw_ver(unsigned int *major, unsigned int *minor)
131 *major = FW_VER_ID->major;
132 *minor = FW_VER_ID->minor;
135 static void vr9_init(struct platform_device *pdev)
141 ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01 |
142 IFX_PMU_MODULE_PPE_TC |
143 IFX_PMU_MODULE_PPE_EMA |
144 IFX_PMU_MODULE_PPE_QSB |
145 IFX_PMU_MODULE_AHBS |
146 IFX_PMU_MODULE_DSL_DFE);
151 IFX_REG_W32(0x08, PDMA_CFG);
152 IFX_REG_W32(0x00203580, SAR_PDMA_RX_CMDBUF_CFG);
153 IFX_REG_W32(0x004035A0, SAR_PDMA_RX_FW_CMDBUF_CFG);
156 IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
157 IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
158 IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
159 IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
161 /* tc init - clear sync state */
165 /* init shared buffer */
167 for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN + SB_RAM2_DWLEN + SB_RAM3_DWLEN; i++ )
171 for ( i = 0; i < SB_RAM6_DWLEN; i++ )
175 static void vr9_shutdown(void)
179 static int vr9_start(int pp32)
181 unsigned int mask = 1 << (pp32 << 4);
184 /* download firmware */
185 ret = vr9_pp32_download_code(pp32,
186 vr9_fw_bin, sizeof(vr9_fw_bin) / sizeof(*vr9_fw_bin),
187 vr9_fw_data, sizeof(vr9_fw_data) / sizeof(*vr9_fw_data));
192 IFX_REG_W32_MASK(mask, 0, PP32_FREEZE);
194 /* idle for a while to let PP32 init itself */
200 static void vr9_stop(int pp32)
202 unsigned int mask = 1 << (pp32 << 4);
204 IFX_REG_W32_MASK(0, mask, PP32_FREEZE);
207 struct ltq_atm_ops vr9_ops = {
209 .shutdown = vr9_shutdown,
212 .fw_ver = vr9_fw_ver,