From fdd243d81bcf5e7fdc8cc7b5060c0c6ed60c5c81 Mon Sep 17 00:00:00 2001 From: Christophe Leroy Date: Wed, 3 May 2023 10:31:19 +0200 Subject: powerpc: mpc8xx: CPM parameter RAM can be anywhere With relocation, CPM parameter RAM can be anywhere in the dual port RAM, so don't split dual port RAM. Remove dparam and dparam16 members of struct comm_proc PROFF_XXX become offsets from the start of dual port RAM, then they are now consistant with the offsets in RPBASE registers. Signed-off-by: Christophe Leroy --- drivers/serial/serial_mpc8xx.c | 2 +- drivers/spi/mpc8xx_spi.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/serial/serial_mpc8xx.c b/drivers/serial/serial_mpc8xx.c index b8d6a81b650..beffc34d116 100644 --- a/drivers/serial/serial_mpc8xx.c +++ b/drivers/serial/serial_mpc8xx.c @@ -89,7 +89,7 @@ static int serial_mpc8xx_probe(struct udevice *dev) /* initialize pointers to SMC */ sp = cp->cp_smc + SMC_INDEX; - up = (smc_uart_t __iomem *)&cp->cp_dparam[PROFF_SMC]; + up = (smc_uart_t __iomem *)&cp->cp_dpmem[PROFF_SMC]; /* Disable relocation */ out_be16(&up->smc_rpbase, 0); diff --git a/drivers/spi/mpc8xx_spi.c b/drivers/spi/mpc8xx_spi.c index d84d7aea888..734b0751a90 100644 --- a/drivers/spi/mpc8xx_spi.c +++ b/drivers/spi/mpc8xx_spi.c @@ -51,7 +51,7 @@ static int mpc8xx_spi_probe(struct udevice *dev) { immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR; cpm8xx_t __iomem *cp = &immr->im_cpm; - spi_t __iomem *spi = (spi_t __iomem *)&cp->cp_dparam[PROFF_SPI]; + spi_t __iomem *spi = (spi_t __iomem *)&cp->cp_dpmem[PROFF_SPI]; cbd_t __iomem *tbdf, *rbdf; /* Disable relocation */ -- cgit v1.3.1 From 14e64c18019ea5361e260bec2a56620c4fe918a1 Mon Sep 17 00:00:00 2001 From: Christophe Leroy Date: Wed, 3 May 2023 09:05:33 +0200 Subject: spi, mpc8xx: Take parameter RAM relocation into account Instead of inhibiting parameter RAM relocation, take it into account. Signed-off-by: Christophe Leroy --- drivers/spi/mpc8xx_spi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/spi/mpc8xx_spi.c b/drivers/spi/mpc8xx_spi.c index 734b0751a90..5c8d7609351 100644 --- a/drivers/spi/mpc8xx_spi.c +++ b/drivers/spi/mpc8xx_spi.c @@ -52,10 +52,12 @@ static int mpc8xx_spi_probe(struct udevice *dev) immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR; cpm8xx_t __iomem *cp = &immr->im_cpm; spi_t __iomem *spi = (spi_t __iomem *)&cp->cp_dpmem[PROFF_SPI]; + u16 spi_rpbase; cbd_t __iomem *tbdf, *rbdf; - /* Disable relocation */ - out_be16(&spi->spi_rpbase, 0x1d80); + spi_rpbase = in_be16(&spi->spi_rpbase); + if (spi_rpbase) + spi = (spi_t __iomem *)&cp->cp_dpmem[spi_rpbase]; /* 1 */ /* Initialize the parameter ram. -- cgit v1.3.1 From 388cb1a10f091e494b837a8666d49866e9c7b1e2 Mon Sep 17 00:00:00 2001 From: Christophe Leroy Date: Wed, 3 May 2023 09:20:15 +0200 Subject: serial, mpc8xx: Take parameter RAM relocation into account Instead of inhibiting parameter RAM relacation, take into account the configured one. It means INIT_TRX command cannot be used and must be done manually as explained in the microcode patch application note. Signed-off-by: Christophe Leroy --- drivers/serial/serial_mpc8xx.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/serial/serial_mpc8xx.c b/drivers/serial/serial_mpc8xx.c index beffc34d116..d82760c7f10 100644 --- a/drivers/serial/serial_mpc8xx.c +++ b/drivers/serial/serial_mpc8xx.c @@ -83,6 +83,7 @@ static int serial_mpc8xx_probe(struct udevice *dev) immap_t __iomem *im = (immap_t __iomem *)CONFIG_SYS_IMMR; smc_t __iomem *sp; smc_uart_t __iomem *up; + u16 smc_rpbase; cpm8xx_t __iomem *cp = &(im->im_cpm); struct serialbuffer __iomem *rtx; @@ -90,8 +91,10 @@ static int serial_mpc8xx_probe(struct udevice *dev) sp = cp->cp_smc + SMC_INDEX; up = (smc_uart_t __iomem *)&cp->cp_dpmem[PROFF_SMC]; - /* Disable relocation */ - out_be16(&up->smc_rpbase, 0); + + smc_rpbase = in_be16(&up->smc_rpbase); + if (smc_rpbase) + up = (smc_uart_t __iomem *)&cp->cp_dpmem[smc_rpbase]; /* Disable transmitter/receiver. */ clrbits_be16(&sp->smc_smcmr, SMCMR_REN | SMCMR_TEN); @@ -154,15 +157,12 @@ static int serial_mpc8xx_probe(struct udevice *dev) out_be16(&up->smc_maxidl, CONFIG_SYS_MAXIDLE); out_be32(&rtx->rxindex, 0); - /* Initialize Tx/Rx parameters. */ - while (in_be16(&cp->cp_cpcr) & CPM_CR_FLG) /* wait if cp is busy */ - ; - - out_be16(&cp->cp_cpcr, - mk_cr_cmd(CPM_CR_CH_SMC, CPM_CR_INIT_TRX) | CPM_CR_FLG); - - while (in_be16(&cp->cp_cpcr) & CPM_CR_FLG) /* wait if cp is busy */ - ; + out_be32(&up->smc_rstate, 0); + out_be32(&up->smc_tstate, 0); + out_be16(&up->smc_rbptr, CPM_SERIAL_BASE); + out_be16(&up->smc_tbptr, CPM_SERIAL_BASE + sizeof(cbd_t)); + out_be16(&up->smc_brkcr, 1); + out_be16(&up->smc_brkec, 0); /* Enable transmitter/receiver. */ setbits_be16(&sp->smc_smcmr, SMCMR_REN | SMCMR_TEN); -- cgit v1.3.1