Skip to content
Permalink
Browse files

ltq-atm/ltq-ptm: re-enable/fix reset_ppe() functionality for VR9

This patch re-enables the reset_ppe() functionality for VR9 targets by using
the new lantiq rcu subsystem. The reset sequence in the reset_ppe() function
was taken from the ppa datapath driver of lantiq UGW 7.4.1.

Additionally it adds the required reset definitions to the vr9 dtsi file.

It also prepares the reset_ppe() function calls for the other lantiq targets.

This feature is needed to be able to switch between ltq-atm/ltq-ptm driver
in ATM/PTM Auto-Mode at runtime.

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
  • Loading branch information...
sch-m authored and hauke committed Dec 5, 2018
1 parent eae6cac commit ff3cfe084885662843a6cc95a547eb9f8ef48fa5
@@ -40,6 +40,7 @@
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/ioctl.h>
#include <linux/platform_device.h>
#include <asm/delay.h>

/*
@@ -80,7 +81,7 @@
*/
static inline void init_pmu(void);
static inline void uninit_pmu(void);
static inline void reset_ppe(void);
static inline void reset_ppe(struct platform_device *pdev);
static inline void init_ema(void);
static inline void init_mailbox(void);
static inline void init_atm_tc(void);
@@ -136,7 +137,7 @@ static inline void uninit_pmu(void)
//PPE_TOP_PMU_SETUP(IFX_PMU_DISABLE);*/
}

static inline void reset_ppe(void)
static inline void reset_ppe(struct platform_device *pdev)
{
#if 0 //MODULE
unsigned int etop_cfg;
@@ -262,11 +263,11 @@ extern void ase_fw_ver(unsigned int *major, unsigned int *minor)
*minor = FW_VER_ID->minor;
}

void ase_init(void)
void ase_init(struct platform_device *pdev)
{
init_pmu();

reset_ppe();
reset_ppe(pdev);

init_ema();

@@ -40,6 +40,7 @@
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/ioctl.h>
#include <linux/platform_device.h>
#include <asm/delay.h>

/*
@@ -83,7 +84,7 @@
*/
static inline void init_pmu(void);
static inline void uninit_pmu(void);
static inline void reset_ppe(void);
static inline void reset_ppe(struct platform_device *pdev);
static inline void init_ema(void);
static inline void init_mailbox(void);
static inline void clear_share_buffer(void);
@@ -125,7 +126,7 @@ static inline void uninit_pmu(void)
{
}

static inline void reset_ppe(void)
static inline void reset_ppe(struct platform_device *pdev)
{
#ifdef MODULE
// reset PPE
@@ -193,10 +194,10 @@ void ar9_fw_ver(unsigned int *major, unsigned int *minor)
*minor = FW_VER_ID->minor;
}

void ar9_init(void)
void ar9_init(struct platform_device *pdev)
{
init_pmu();
reset_ppe();
reset_ppe(pdev);
init_ema();
init_mailbox();
clear_share_buffer();
@@ -34,7 +34,7 @@
#define SET_BITS(x, msb, lsb, value) (((x) & ~(((1 << ((msb) + 1)) - 1) ^ ((1 << (lsb)) - 1))) | (((value) & ((1 << (1 + (msb) - (lsb))) - 1)) << (lsb)))

struct ltq_atm_ops {
void (*init)(void);
void (*init)(struct platform_device *pdev);
void (*shutdown)(void);

int (*start)(int pp32);
@@ -40,6 +40,7 @@
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/ioctl.h>
#include <linux/platform_device.h>
#include <linux/delay.h>

/*
@@ -61,7 +62,7 @@
#define EMA_WRITE_BURST 0x2
#define EMA_READ_BURST 0x2

static inline void reset_ppe(void);
static inline void reset_ppe(struct platform_device *pdev);

#define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
#define IFX_PMU_MODULE_PPE_TC BIT(21)
@@ -70,7 +71,7 @@ static inline void reset_ppe(void);
#define IFX_PMU_MODULE_TPE BIT(13)
#define IFX_PMU_MODULE_DSL_DFE BIT(9)

static inline void reset_ppe(void)
static inline void reset_ppe(struct platform_device *pdev)
{
/*#ifdef MODULE
unsigned int etop_cfg;
@@ -140,7 +141,7 @@ static void danube_fw_ver(unsigned int *major, unsigned int *minor)
*minor = FW_VER_ID->minor;
}

static void danube_init(void)
static void danube_init(struct platform_device *pdev)
{
volatile u32 *p = SB_RAM0_ADDR(0);
unsigned int i;
@@ -152,7 +153,7 @@ static void danube_init(void)
IFX_PMU_MODULE_TPE |
IFX_PMU_MODULE_DSL_DFE);

reset_ppe();
reset_ppe(pdev);

/* init ema */
IFX_REG_W32((EMA_CMD_BUF_LEN << 16) | (EMA_CMD_BASE_ADDR >> 2), EMA_CMDCFG);
@@ -40,6 +40,8 @@
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/ioctl.h>
#include <linux/platform_device.h>
#include <linux/reset.h>
#include <asm/delay.h>

#include "ifxmips_atm_core.h"
@@ -56,21 +58,46 @@
#define IFX_PMU_MODULE_AHBS BIT(13)
#define IFX_PMU_MODULE_DSL_DFE BIT(9)

static inline void vr9_reset_ppe(void)
static inline void vr9_reset_ppe(struct platform_device *pdev)
{
/*#ifdef MODULE
// reset PPE
ifx_rcu_rst(IFX_RCU_DOMAIN_DSLDFE, IFX_RCU_MODULE_ATM);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)
struct device *dev = &pdev->dev;
struct reset_control *dsp;
struct reset_control *dfe;
struct reset_control *tc;

dsp = devm_reset_control_get(dev, "dsp");
if (IS_ERR(dsp)) {
if (PTR_ERR(dsp) != -EPROBE_DEFER)
dev_err(dev, "Failed to lookup dsp reset\n");
// return PTR_ERR(dsp);
}

dfe = devm_reset_control_get(dev, "dfe");
if (IS_ERR(dfe)) {
if (PTR_ERR(dfe) != -EPROBE_DEFER)
dev_err(dev, "Failed to lookup dfe reset\n");
// return PTR_ERR(dfe);
}

tc = devm_reset_control_get(dev, "tc");
if (IS_ERR(tc)) {
if (PTR_ERR(tc) != -EPROBE_DEFER)
dev_err(dev, "Failed to lookup tc reset\n");
// return PTR_ERR(tc);
}

reset_control_assert(dsp);
udelay(1000);
ifx_rcu_rst(IFX_RCU_DOMAIN_DSLTC, IFX_RCU_MODULE_ATM);
reset_control_assert(dfe);
udelay(1000);
ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_ATM);
reset_control_assert(tc);
udelay(1000);
*PP32_SRST &= ~0x000303CF;
udelay(1000);
*PP32_SRST |= 0x000303CF;
udelay(1000);
#endif*/
#endif
}

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)
@@ -107,7 +134,7 @@ static void vr9_fw_ver(unsigned int *major, unsigned int *minor)
*minor = FW_VER_ID->minor;
}

static void vr9_init(void)
static void vr9_init(struct platform_device *pdev)
{
volatile u32 *p;
unsigned int i;
@@ -120,7 +147,7 @@ static void vr9_init(void)
IFX_PMU_MODULE_AHBS |
IFX_PMU_MODULE_DSL_DFE);

vr9_reset_ppe();
vr9_reset_ppe(pdev);

/* pdma init */
IFX_REG_W32(0x08, PDMA_CFG);
@@ -1777,7 +1777,7 @@ static int ltq_atm_probe(struct platform_device *pdev)
goto INIT_PRIV_DATA_FAIL;
}

ops->init();
ops->init(pdev);
init_rx_tables();
init_tx_tables();

@@ -44,6 +44,8 @@
#include <linux/etherdevice.h>
#include <linux/interrupt.h>
#include <linux/netdevice.h>
#include <linux/platform_device.h>
#include <linux/of_device.h>
#include <asm/io.h>

/*
@@ -1448,6 +1450,19 @@ static int ptm_showtime_exit(void)
}


static const struct of_device_id ltq_ptm_match[] = {
#ifdef CONFIG_DANUBE
{ .compatible = "lantiq,ppe-danube", .data = NULL },
#elif defined CONFIG_AMAZON_SE
{ .compatible = "lantiq,ppe-ase", .data = NULL },
#elif defined CONFIG_AR9
{ .compatible = "lantiq,ppe-arx100", .data = NULL },
#elif defined CONFIG_VR9
{ .compatible = "lantiq,ppe-xrx200", .data = NULL },
#endif
{},
};
MODULE_DEVICE_TABLE(of, ltq_ptm_match);

/*
* ####################################
@@ -1465,7 +1480,7 @@ static int ptm_showtime_exit(void)
* 0 --- successful
* else --- failure, usually it is negative value of error code
*/
static int ifx_ptm_init(void)
static int ltq_ptm_probe(struct platform_device *pdev)
{
int ret;
struct port_cell_info port_cell = {0};
@@ -1481,7 +1496,7 @@ static int ifx_ptm_init(void)
goto INIT_PRIV_DATA_FAIL;
}

ifx_ptm_init_chip();
ifx_ptm_init_chip(pdev);
init_tables();

for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ ) {
@@ -1570,7 +1585,7 @@ static int ifx_ptm_init(void)
* Output:
* none
*/
static void __exit ifx_ptm_exit(void)
static int ltq_ptm_remove(struct platform_device *pdev)
{
int i;

@@ -1595,7 +1610,20 @@ static void __exit ifx_ptm_exit(void)
ifx_ptm_uninit_chip();

clear_priv_data();

return 0;
}

module_init(ifx_ptm_init);
module_exit(ifx_ptm_exit);
static struct platform_driver ltq_ptm_driver = {
.probe = ltq_ptm_probe,
.remove = ltq_ptm_remove,
.driver = {
.name = "ptm",
.owner = THIS_MODULE,
.of_match_table = ltq_ptm_match,
},
};

module_platform_driver(ltq_ptm_driver);

MODULE_LICENSE("GPL");
@@ -122,7 +122,7 @@ extern unsigned int ifx_ptm_dbg_enable;

extern void ifx_ptm_get_fw_ver(unsigned int *major, unsigned int *minor);

extern void ifx_ptm_init_chip(void);
extern void ifx_ptm_init_chip(struct platform_device *pdev);
extern void ifx_ptm_uninit_chip(void);

extern int ifx_pp32_start(int pp32);
@@ -40,6 +40,8 @@
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/ioctl.h>
#include <linux/platform_device.h>
#include <linux/reset.h>
#include <asm/delay.h>

/*
@@ -84,7 +86,7 @@
*/
static inline void init_pmu(void);
static inline void uninit_pmu(void);
static inline void reset_ppe(void);
static inline void reset_ppe(struct platform_device *pdev);
static inline void init_ema(void);
static inline void init_mailbox(void);
static inline void init_atm_tc(void);
@@ -129,7 +131,7 @@ static inline void uninit_pmu(void)
//PPE_TOP_PMU_SETUP(IFX_PMU_DISABLE);
}

static inline void reset_ppe(void)
static inline void reset_ppe(struct platform_device *pdev)
{
#ifdef MODULE
unsigned int etop_cfg;
@@ -260,11 +262,11 @@ extern void ifx_ptm_get_fw_ver(unsigned int *major, unsigned int *minor)
*minor = FW_VER_ID->minor;
}

void ifx_ptm_init_chip(void)
void ifx_ptm_init_chip(struct platform_device *pdev)
{
init_pmu();

reset_ppe();
reset_ppe(pdev);

init_ema();

@@ -40,6 +40,8 @@
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/ioctl.h>
#include <linux/platform_device.h>
#include <linux/reset.h>
#include <asm/delay.h>

/*
@@ -80,7 +82,7 @@
*/
static inline void init_pmu(void);
static inline void uninit_pmu(void);
static inline void reset_ppe(void);
static inline void reset_ppe(struct platform_device *pdev);
static inline void init_ema(void);
static inline void init_mailbox(void);
static inline void init_atm_tc(void);
@@ -130,7 +132,7 @@ static inline void uninit_pmu(void)

}

static inline void reset_ppe(void)
static inline void reset_ppe(struct platform_device *pdev)
{
#ifdef MODULE
// reset PPE
@@ -283,11 +285,11 @@ void ifx_ptm_get_fw_ver(unsigned int *major, unsigned int *minor)
*minor = FW_VER_ID->minor;
}

void ifx_ptm_init_chip(void)
void ifx_ptm_init_chip(struct platform_device *pdev)
{
init_pmu();

reset_ppe();
reset_ppe(pdev);

init_ema();

0 comments on commit ff3cfe0

Please sign in to comment.
You can’t perform that action at this time.