powerpc, mpc8xx: clear top of stack
Subsystems (3)
PATCH v2 1/9 powerpc, mpc8xx: clear top of stack
--- arch/powerpc/cpu/mpc8xx/start.S | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/cpu/mpc8xx/start.S +3 -1
@@ -144,9 +144,11 @@ in_flash: ori r2, r2, CONFIG_SYS_DER at l mtspr DER, r2 - /* set up the stack in internal DPRAM */ + /* set up the stack on top of internal DPRAM */ lis r3, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE)@h ori r3, r3, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE)@l + stw r0, -4(r3) + stw r0, -8(r3) addi r1, r3, -8 bl board_init_f_alloc_reserve
Signature · 1 line
2.13.3
PATCH v2 2/9 board: MCR3000: Activate CONFIG_DM and CONFIG_OF_CONTROL
Add mcr3000 device tree and activate CONFIG_DM and CONFIG_OF_CONTROL
--- arch/powerpc/dts/Makefile | 1 + arch/powerpc/dts/mcr3000.dts | 12 ++++++++++++ board/cssi/MCR3000/u-boot.lds | 6 ++++++ configs/MCR3000_defconfig | 3 +++ 4 files changed, 22 insertions(+) create mode 100644 arch/powerpc/dts/mcr3000.dts
arch/powerpc/dts/Makefile +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0+ dtb-$(CONFIG_TARGET_T2080QDS) += t2080qds.dtb +dtb-$(CONFIG_MCR3000) += mcr3000.dtb targets += $(dtb-y)
arch/powerpc/dts/mcr3000.dts new file +12 -0
@@ -0,0 +1,12 @@ +/* + * MCR3000 Device Tree Source + * + * Copyright 2017 CS Systemes d'Information + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +/dts-v1/; + +/ { +};
board/cssi/MCR3000/u-boot.lds +6 -0
@@ -69,6 +69,12 @@ SECTIONS __ex_table : { *(__ex_table) } __stop___ex_table = .; + /* + * _end - This is end of u-boot.bin image. + * dtb will be appended here to make u-boot-dtb.bin + */ + _end = .; + . = ALIGN(4096); __init_begin = .; .text.init : { *(.text.init) }
configs/MCR3000_defconfig +3 -0
@@ -73,3 +73,6 @@ CONFIG_MPC8XX_FEC=y CONFIG_SHA256=y CONFIG_LZMA=y CONFIG_OF_LIBFDT=y +CONFIG_DM=y +CONFIG_OF_CONTROL=y +CONFIG_DEFAULT_DEVICE_TREE="mcr3000"
Signature · 1 line
2.13.3
PATCH v2 2/9 board: MCR3000: Activate CONFIG_DM and CONFIG_OF_CONTROL
Quoted 3 lines · Christophe Leroy
Add mcr3000 device tree and activate
CONFIG_DMandCONFIG_OF_CONTROLSigned-off-by Christophe Leroy <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181203/f28901eb/attachment.sig>
PATCH v2 3/9 drivers: watchdog: add a DM driver for the MPC8xx watchdog
In reply to Christophe LeroyThis patch adds a DM driver for the MPC8xx watchdog. Basically, the watchdog is enabled by default from the start and SYPCR register has to be writen once to set the timeout and/or deactivate the watchdog. Once written, it cannot be written again.
It means that wdt_stop() can be called before wdt_start() to stop the watchdog, but cannot be called if wdt_start() has been called.
--- drivers/watchdog/Kconfig | 7 ++++++ drivers/watchdog/mpc8xx_wdt.c | 51 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+)
drivers/watchdog/Kconfig +7 -0
@@ -136,4 +136,11 @@ config WDT_MT7621 Select this to enable Ralink / Mediatek watchdog timer, which can be found on some MediaTek chips. +config WDT_MPC8xx + bool "MPC8xx watchdog timer support" + depends on WDT && MPC8xx + select CONFIG_MPC8xx_WATCHDOG + help + Select this to enable mpc8xx watchdog timer + endmenu
drivers/watchdog/mpc8xx_wdt.c +51 -0
60 lines not on this page · raw message
Signature · 1 line
2.13.3
PATCH v2 3/9 drivers: watchdog: add a DM driver for the MPC8xx watchdog
Quoted 9 lines · Christophe Leroy
This patch adds a DM driver for the MPC8xx watchdog. Basically, the watchdog is enabled by default from the start and SYPCR register has to be writen once to set the timeout and/or deactivate the watchdog. Once written, it cannot be written again.
It means that
wdt_stop()can be called beforewdt_start()to stop the watchdog, but cannot be called ifwdt_start()has been called.Signed-off-by Christophe Leroy <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181203/484fca90/attachment.sig>
PATCH v2 4/9 board: MCR3000: use new DM watchdog
In reply to Christophe LeroyThis patch switches MCR3000 board to the new DM watchdog.
The change in u-boot.lds is because MCR3000.o grows a bit with this patch and doesn't fit anymore below env_offset on some versions of GCC.
---
v2: fixed build failure for lack of space before env_offset in u-boot.lds
arch/powerpc/dts/mcr3000.dts | 3 +++ board/cssi/MCR3000/MCR3000.c | 16 ++++++++++++++++ board/cssi/MCR3000/u-boot.lds | 1 - configs/MCR3000_defconfig | 3 +++ 4 files changed, 22 insertions(+), 1 deletion(-)
arch/powerpc/dts/mcr3000.dts +3 -0
@@ -9,4 +9,7 @@ /dts-v1/; / { + WDT: watchdog at 0 { + compatible = "fsl,pq1-wdt"; + }; };
board/cssi/MCR3000/MCR3000.c +16 -0
@@ -12,6 +12,8 @@#include <mpc8xx.h> #include <fdt_support.h> #include <asm/io.h> +#include <dm/uclass.h> +#include <wdt.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -143,3 +145,17 @@ int board_early_init_f(void)return 0 ; } + +int board_early_init_r (void ) +{ +struct udevice *watchdog_dev =NULL ; + +if (uclass_get_device (UCLASS_WDT ,0 , &watchdog_dev)) { +puts ("Cannot find watchdog!\n" ); + }else { +puts ("Enabling watchdog.\n" ); +wdt_start (watchdog_dev,0xffff ,0 ); + } + +return 0 ; +}
board/cssi/MCR3000/u-boot.lds +0 -1
@@ -19,7 +19,6 @@ SECTIONS arch/powerpc/cpu/mpc8xx/start.o (.text) arch/powerpc/cpu/mpc8xx/traps.o (.text*) arch/powerpc/lib/built-in.o (.text*) - board/cssi/MCR3000/built-in.o (.text*) drivers/net/built-in.o (.text*) . = DEFINED(env_offset) ? env_offset : .;
configs/MCR3000_defconfig +3 -0
@@ -42,6 +42,7 @@ CONFIG_BOOTDELAY=5 CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="run flashboot" CONFIG_MISC_INIT_R=y +CONFIG_BOARD_EARLY_INIT_R=y CONFIG_HUSH_PARSER=y # CONFIG_AUTO_COMPLETE is not set CONFIG_SYS_PROMPT="S3K> "
@@ -76,3 +77,5 @@ CONFIG_OF_LIBFDT=y CONFIG_DM=y CONFIG_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="mcr3000" +CONFIG_WDT=y +CONFIG_WDT_MPC8xx=y
Signature · 1 line
2.13.3
PATCH v2 4/9 board: MCR3000: use new DM watchdog
Quoted 7 lines · Christophe Leroy
This patch switches MCR3000 board to the new DM watchdog.
The change in
u-boot.ldsis because MCR3000.o grows a bit with this patch and doesn't fit anymore belowenv_offseton some versions of GCC.Signed-off-by Christophe Leroy <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181203/b6b43d1d/attachment.sig>
PATCH v2 5/9 drivers: serial: migrate mpc8xx to DM
In reply to Christophe Leroy--- drivers/serial/serial_mpc8xx.c | 77 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 3 deletions(-)
drivers/serial/serial_mpc8xx.c +74 -3
@@ -6,6 +6,7 @@#include <common.h> #include <command.h> +#include <dm.h> #include <serial.h> #include <watchdog.h> #include <asm/cpm_8xx.h>
@@ -35,9 +36,9 @@ struct serialbuffer {uchar txbuf;/* tx buffers */ }; -static void serial_setdivisor (cpm8xx_t __iomem *cp) +static void serial_setdivisor (cpm8xx_t __iomem *cp,int baudrate) { -int divisor = (gd->cpu_clk +8 * gd->baudrate) /16 / gd->baudrate; +int divisor = (gd->cpu_clk +8 * baudrate) /16 / baudrate;if (divisor /16 >0x1000 ) {/* bad divisor, assume 50MHz clock and 9600 baud */
@@ -71,7 +72,7 @@ static void smc_setbrg(void)out_be32 (&cp->cp_simode,0 ); -serial_setdivisor (cp); +serial_setdivisor (cp, gd->baudrate); }static int smc_init (void )
@@ -186,11 +187,13 @@ static void smc_putc(const char c)WATCHDOG_RESET (); } +#ifndef CONFIG_DM_SERIAL static void smc_puts (const char *s) {while (*s)smc_putc (*s++); } +#endif static int smc_getc (void ) {
@@ -233,6 +236,7 @@ static int smc_tstc(void)return !(in_be16 (&rtx->rxbd.cbd_sc) &BD_SC_EMPTY ); } +#ifndef CONFIG_DM_SERIAL struct serial_device serial_smc_device = { .name ="serial_smc" , .start = smc_init,
@@ -253,3 +257,70 @@ void mpc8xx_serial_initialize(void) {serial_register (&serial_smc_device); } +#endif + +#ifdef CONFIG_DM_SERIAL +static int serial_mpc8xx_setbrg (struct udevice *dev,int baudrate) +{ +immap_t __iomem *im = (immap_t __iomem *)CONFIG_SYS_IMMR ; +cpm8xx_t __iomem *cp = &(im->im_cpm); + +/* Set up the baud rate generator. +* See 8xx_io/commproc.c for details. +* +* Wire BRG1 to SMCx +*/ + +out_be32 (&cp->cp_simode,0 ); + +serial_setdivisor (cp, baudrate); + +return 0 ; +} + +static int serial_mpc8xx_probe (struct udevice *dev) +{ +return smc_init (); +} + +static int serial_mpc8xx_putc (struct udevice *dev,const char ch) +{ +smc_putc (ch); + +return 0 ; +} + +static int serial_mpc8xx_getc (struct udevice *dev) +{ +return smc_getc (); +} + +static int serial_mpc8xx_pending (struct udevice *dev,bool input) +{ +if (input) +return smc_tstc (); + +return 0 ; +} + +static const struct dm_serial_ops serial_mpc8xx_ops = { + .putc = serial_mpc8xx_putc, + .pending = serial_mpc8xx_pending, + .getc = serial_mpc8xx_getc, + .setbrg = serial_mpc8xx_setbrg, +}; + +static const struct udevice_id serial_mpc8xx_ids[] = { + { .compatible ="fsl,pq1-smc" }, + { } +}; + +U_BOOT_DRIVER (serial_mpc8xx) = { + .name ="serial_mpc8xx" , + .id =UCLASS_SERIAL , + .of_match = serial_mpc8xx_ids, + .probe = serial_mpc8xx_probe, + .ops = &serial_mpc8xx_ops, + .flags =DM_FLAG_PRE_RELOC , +}; +#endif
Signature · 1 line
2.13.3
PATCH v2 5/9 drivers: serial: migrate mpc8xx to DM
Quoted 1 line · Christophe Leroy
Signed-off-by Christophe Leroy <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181203/44c2d3da/attachment.sig>
PATCH v2 6/9 board: MCR3000: migrate to DM_SERIAL
In reply to Christophe Leroy--- arch/powerpc/dts/mcr3000.dts | 7 +++++++ configs/MCR3000_defconfig | 1 + 2 files changed, 8 insertions(+)
arch/powerpc/dts/mcr3000.dts +7 -0
@@ -12,4 +12,11 @@ WDT: watchdog at 0 { compatible = "fsl,pq1-wdt"; }; + SERIAL: smc at 0 { + compatible = "fsl,pq1-smc"; + }; + + chosen { + stdout-path = &SERIAL; + }; };
configs/MCR3000_defconfig +1 -0
@@ -79,3 +79,4 @@ CONFIG_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="mcr3000" CONFIG_WDT=y CONFIG_WDT_MPC8xx=y +CONFIG_DM_SERIAL=y
Signature · 1 line
2.13.3
PATCH v2 6/9 board: MCR3000: migrate to DM_SERIAL
Quoted 1 line · Christophe Leroy
Signed-off-by Christophe Leroy <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181203/87fcd248/attachment.sig>
PATCH v2 7/9 drivers: serial: get rid of non DM mpc8xx driver
In reply to Christophe Leroy--- drivers/serial/serial.c | 2 - drivers/serial/serial_mpc8xx.c | 97 ++++++------------------------------------ include/serial.h | 1 - 3 files changed, 14 insertions(+), 86 deletions(-)
drivers/serial/serial.c +0 -2
@@ -119,7 +119,6 @@ U_BOOT_ENV_CALLBACK(baudrate, on_baudrate);serial_initfunc (atmel_serial_initialize);serial_initfunc (mcf_serial_initialize);serial_initfunc (mpc85xx_serial_initialize); -serial_initfunc (mpc8xx_serial_initialize);serial_initfunc (mxc_serial_initialize);serial_initfunc (ns16550_serial_initialize);serial_initfunc (pl01x_serial_initialize);
@@ -173,7 +172,6 @@ void serial_initialize(void)atmel_serial_initialize ();mcf_serial_initialize ();mpc85xx_serial_initialize (); -mpc8xx_serial_initialize ();mxc_serial_initialize ();ns16550_serial_initialize ();pl01x_serial_initialize ();
drivers/serial/serial_mpc8xx.c +14 -83
157 lines not on this page · raw message
include/serial.h +0 -1
@@ -224,7 +224,6 @@ struct serial_dev_priv {void atmel_serial_initialize (void );void mcf_serial_initialize (void );void mpc85xx_serial_initialize (void ); -void mpc8xx_serial_initialize (void );void mxc_serial_initialize (void );void ns16550_serial_initialize (void );void pl01x_serial_initialize (void );
Signature · 1 line
2.13.3
PATCH v2 7/9 drivers: serial: get rid of non DM mpc8xx driver
Quoted 1 line · Christophe Leroy
Signed-off-by Christophe Leroy <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181203/df243da8/attachment.sig>
PATCH v2 8/9 board_r: fix build with DM_SPI
In reply to Christophe Leroy CC common/board_r.ocommon/board_r.c:747:2: error: ‘initr_spi’ undeclared here (not in a function)
initr_spi,
^
make[1]: *** [common/board_r.o] Error 1
--- common/board_r.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/board_r.c +1 -1
@@ -743,7 +743,7 @@ static init_fnc_t init_sequence_r[] = {/* initialize higher level parts of CPU like time base and timers */ cpu_init_r,#endif -#ifdef CONFIG_PPC +#if defined(CONFIG_PPC ) && !defined(CONFIG_DM_SPI ) initr_spi,#endif #ifdef CONFIG_CMD_NAND
Signature · 1 line
2.13.3
PATCH v2 8/9 board_r: fix build with DM_SPI
Quoted 6 lines · Christophe Leroy
CC
common/board_r.ocommon/board_r.c:747:2: error: ‘initr_spi’ undeclared here (not in a function)
initr_spi,
^
make[1]: *** [common/board_r.o] Error 1
I have a patch to remove this code, which is not doing anything. will take care while applying your dm patch.
PATCH v2 8/9 board_r: fix build with DM_SPI
In reply to Christophe LeroyQuoted 8 lines · Christophe Leroy
CC
common/board_r.ocommon/board_r.c:747:2: error: ‘initr_spi’ undeclared here (not in a function)
initr_spi,
^
make[1]: *** [common/board_r.o] Error 1Fixes ebe76a2df9f6 ("dm: Remove spi_init() from board_r.c when using driver model")Signed-off-by Christophe Leroy <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181203/066c41a4/attachment.sig>
PATCH v2 9/9 spi, mpc8xx: migrate to DM_SPI
In reply to Christophe Leroy--- drivers/spi/mpc8xx_spi.c | 179 ++++++++--------------------------------------- 1 file changed, 30 insertions(+), 149 deletions(-)
drivers/spi/mpc8xx_spi.c +30 -149
@@ -17,64 +17,19 @@*/ #include <common.h> +#include <dm.h> #include <mpc8xx.h> +#include <spi.h> +#include <asm/cpm_8xx.h> -#include <linux/ctype.h> -#include <malloc.h> -#include <post.h> -#include <serial.h> - -#define SPI_EEPROM_WREN 0x06 -#define SPI_EEPROM_RDSR 0x05 -#define SPI_EEPROM_READ 0x03 -#define SPI_EEPROM_WRITE 0x02 - -/* --------------------------------------------------------------- -* Offset for initial SPI buffers in DPRAM: -* We need a 520 byte scratch DPRAM area to use at an early stage. -* It is used between the two initialization calls (spi_init_f() -* and spi_init_r()). -* The value 0xb00 makes it far enough from the start of the data -* area (as well as from the stack pointer). -* --------------------------------------------------------------- */ -#ifndef CONFIG_SYS_SPI_INIT_OFFSET -#define CONFIG_SYS_SPI_INIT_OFFSET 0xB00 -#endif +#include <asm/io.h> #define CPM_SPI_BASE_RX CPM_SPI_BASE#define CPM_SPI_BASE_TX (CPM_SPI_BASE + sizeof(cbd_t)) -/* ------------------- -* Function prototypes -* ------------------- */ -ssize_t spi_xfer (size_t ); - -/* ------------------- -* Variables -* ------------------- */ -#define MAX_BUFFER 0x104 -/* ---------------------------------------------------------------------- -* Initially we place the RX and TX buffers at a fixed location in DPRAM! -* ---------------------------------------------------------------------- */ -static uchar *rxbuf = - (uchar *)&((cpm8xx_t *)&((immap_t *)CONFIG_SYS_IMMR )->im_cpm)->cp_dpmem - [CONFIG_SYS_SPI_INIT_OFFSET ]; -static uchar *txbuf = - (uchar *)&((cpm8xx_t *)&((immap_t *)CONFIG_SYS_IMMR )->im_cpm)->cp_dpmem - [CONFIG_SYS_SPI_INIT_OFFSET +MAX_BUFFER ]; - -/* ************************************************************************** -* -* Function: spi_init_f -* -* Description: Init SPI-Controller (ROM part) -* -* return: --- -* -* *********************************************************************** */ -void spi_init_f (void ) +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;
@@ -180,117 +135,24 @@ void spi_init_f(void)clrbits_be16 (&tbdf->cbd_sc,BD_SC_READY );clrbits_be16 (&rbdf->cbd_sc,BD_SC_EMPTY ); -/* Set the bd's rx and tx buffer address pointers */ -out_be32 (&rbdf->cbd_bufaddr, (ulong )rxbuf); -out_be32 (&tbdf->cbd_bufaddr, (ulong )txbuf); -/* 10 + 11 */ out_8 (&cp->cp_spim,0 );/* Mask all SPI events */ out_8 (&cp->cp_spie,SPI_EMASK );/* Clear all SPI events */ -return ; +return 0 ; } -/* ************************************************************************** -* -* Function: spi_init_r -* -* Description: Init SPI-Controller (RAM part) - -* The malloc engine is ready and we can move our buffers to -* normal RAM -* -* return: --- -* -* *********************************************************************** */ -void spi_init_r (void ) +static int mpc8xx_spi_xfer (struct udevice *dev,unsigned int bitlen, +const void *dout,void *din,unsigned long flags) {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 ]; -cbd_t __iomem *tbdf, *rbdf; - -/* Disable relocation */ -out_be16 (&spi->spi_rpbase,0 ); - -/* tx and rx buffer descriptors */ - tbdf = (cbd_t __iomem *)&cp->cp_dpmem[CPM_SPI_BASE_TX ]; - rbdf = (cbd_t __iomem *)&cp->cp_dpmem[CPM_SPI_BASE_RX ]; - -/* Allocate memory for RX and TX buffers */ - rxbuf = (uchar *)malloc (MAX_BUFFER ); - txbuf = (uchar *)malloc (MAX_BUFFER ); - -out_be32 (&rbdf->cbd_bufaddr, (ulong )rxbuf); -out_be32 (&tbdf->cbd_bufaddr, (ulong )txbuf); - -return ; -} - -/**************************************************************************** -* Function: spi_write -**************************************************************************** */ -ssize_t spi_write (uchar *addr,int alen,uchar *buffer,int len) -{ -int i; - -memset (rxbuf,0 ,MAX_BUFFER ); -memset (txbuf,0 ,MAX_BUFFER ); - *txbuf =SPI_EEPROM_WREN ;/* write enable */ -spi_xfer (1 ); -memcpy (txbuf, addr, alen); - *txbuf =SPI_EEPROM_WRITE ;/* WRITE memory array */ -memcpy (alen + txbuf, buffer, len); -spi_xfer (alen + len); -/* ignore received data */ -for (i =0 ; i <1000 ; i++) { - *txbuf =SPI_EEPROM_RDSR ;/* read status */ - txbuf[1 ] =0 ; -spi_xfer (2 ); -if (!(rxbuf[1 ] &1 )) -break ; -udelay (1000 ); - } -if (i >=1000 ) -printf ("*** spi_write: Time out while writing!\n" ); - -return len; -} - -/**************************************************************************** -* Function: spi_read -**************************************************************************** */ -ssize_t spi_read (uchar *addr,int alen,uchar *buffer,int len) -{ -memset (rxbuf,0 ,MAX_BUFFER ); -memset (txbuf,0 ,MAX_BUFFER ); -memcpy (txbuf, addr, alen); - *txbuf =SPI_EEPROM_READ ;/* READ memory array */ - -/* -* There is a bug in 860T (?) that cuts the last byte of input -* if we're reading into DPRAM. The solution we choose here is -* to always read len+1 bytes (we have one extra byte at the -* end of the buffer). -*/ -spi_xfer (alen + len +1 ); -memcpy (buffer, alen + rxbuf, len); - -return len; -} - -/**************************************************************************** -* Function: spi_xfer -**************************************************************************** */ -ssize_t spi_xfer (size_t count) -{ -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 ];cbd_t __iomem *tbdf, *rbdf;int tm; +size_t count = (bitlen +7 ) /8 ; -/* Disable relocation */ -out_be16 (&spi->spi_rpbase,0 ); +if (count >MAX_BUFFER ) +return -EINVAL ; tbdf = (cbd_t __iomem *)&cp->cp_dpmem[CPM_SPI_BASE_TX ]; rbdf = (cbd_t __iomem *)&cp->cp_dpmem[CPM_SPI_BASE_RX ];
@@ -299,10 +161,12 @@ ssize_t spi_xfer(size_t count)clrbits_be32 (&cp->cp_pbdat,0x0001 );/* Setting tx bd status and data length */ +out_be32 (&tbdf->cbd_bufaddr, (ulong )dout);out_be16 (&tbdf->cbd_sc,BD_SC_READY |BD_SC_LAST |BD_SC_WRAP );out_be16 (&tbdf->cbd_datlen, count);/* Setting rx bd status and data length */ +out_be32 (&rbdf->cbd_bufaddr, (ulong )din);out_be16 (&rbdf->cbd_sc,BD_SC_EMPTY |BD_SC_WRAP );out_be16 (&rbdf->cbd_datlen,0 );/* rx length has no significance */
@@ -333,3 +197,20 @@ ssize_t spi_xfer(size_t count)return count; } + +static const struct dm_spi_ops mpc8xx_spi_ops = { + .xfer = mpc8xx_spi_xfer, +}; + +static const struct udevice_id mpc8xx_spi_ids[] = { + { .compatible ="fsl,mpc8xx-spi" }, + { } +}; + +U_BOOT_DRIVER (mpc8xx_spi) = { + .name ="mpc8xx_spi" , + .id =UCLASS_SPI , + .of_match = mpc8xx_spi_ids, + .ops = &mpc8xx_spi_ops, + .probe = mpc8xx_spi_probe, +};
Signature · 1 line
2.13.3
PATCH v2 9/9 spi, mpc8xx: migrate to DM_SPI
Quoted 4 lines · Christophe Leroy
Signed-off-by Christophe Leroy <[email protected]>--- drivers/spi/mpc8xx_spi.c | 179 ++++++++---------------------------------------
Update Kconfig to move the config definition in DM_SPI area.
Quoted 12 lines
/* Setting tx bd status and data length */drivers/spi/mpc8xx_spi.c +2
-0+out_be32 (&tbdf->cbd_bufaddr, (ulong )dout);out_be16 (&tbdf->cbd_sc,BD_SC_READY |BD_SC_LAST |BD_SC_WRAP );out_be16 (&tbdf->cbd_datlen, count);/* Setting rx bd status and data length */ +out_be32 (&rbdf->cbd_bufaddr, (ulong )din);out_be16 (&rbdf->cbd_sc,BD_SC_EMPTY |BD_SC_WRAP );out_be16 (&rbdf->cbd_datlen,0 );/* rx length has no significance */
drivers/spi/mpc8xx_spi.c ssize_t spi_xfer(size_t count) · line 206
Quoted 10 lines
drivers/spi/mpc8xx_spi.c +7
-0@@ -333,3 +197,20 @@ ssize_t spi_xfer(size_t count)return count; } + +static const struct dm_spi_ops mpc8xx_spi_ops = { + .xfer = mpc8xx_spi_xfer, +}; + +static const struct udevice_id mpc8xx_spi_ids[] = { + { .compatible ="fsl,mpc8xx-spi" },
Is this binding from Linux?
PATCH v2 9/9 spi, mpc8xx: migrate to DM_SPI
Quoted 7 lines · Jagan Teki
Quoted 4 lines · Christophe Leroy
Signed-off-by Christophe Leroy <[email protected]>--- drivers/spi/mpc8xx_spi.c | 179 ++++++++---------------------------------------
How did you handle this eeprom calls?
cmd/built-in.o: In function `eeprom_init':~/u-boot-dev/cmd/eeprom.c:71: undefined reference to spi_init_f' cmd/built-in.o: In function eeprom_rw_block':~/u-boot-dev/cmd/eeprom.c:135: undefined reference to spi_read' ~/u-boot-dev/cmd/eeprom.c:137: undefined reference to spi_write'
PATCH v2 9/9 spi, mpc8xx: migrate to DM_SPI
Le 21/11/2018 à 11:18, Jagan Teki a écrit :
Quoted 9 lines · Jagan Teki
Quoted 7 lines
Quoted 4 lines · Christophe Leroy
Signed-off-by Christophe Leroy <[email protected]>--- drivers/spi/mpc8xx_spi.c | 179 ++++++++---------------------------------------
Quoted 8 lines
How did you handle this eeprom calls?
cmd/built-in.o: In function `eeprom_init':~/u-boot-dev/cmd/eeprom.c:71: undefined reference tospi_init_f' cmd/built-in.o: In functioneeprom_rw_block':~/u-boot-dev/cmd/eeprom.c:135: undefined reference tospi_read' ~/u-boot-dev/cmd/eeprom.c:137: undefined reference tospi_write'
Oops, didn't see that. Indeed the HW I have doesn't have eeprom, I tested the SPI driver with thermal monitoring.
I see you sent a patch fixing it, thanks.
Christophe
PATCH v2 9/9 spi, mpc8xx: migrate to DM_SPI
In reply to Jagan TekiLe 21/11/2018 à 10:09, Jagan Teki a écrit :
Quoted 8 lines
Quoted 4 lines · Christophe Leroy
Signed-off-by Christophe Leroy <[email protected]>--- drivers/spi/mpc8xx_spi.c | 179 ++++++++---------------------------------------Update
Kconfigto move the config definition inDM_SPIarea.
You did it already it seems, thanks.
Quoted 14 lines
Quoted 14 lines
/* Setting tx bd status and data length */drivers/spi/mpc8xx_spi.c +2
-0+out_be32 (&tbdf->cbd_bufaddr, (ulong )dout);out_be16 (&tbdf->cbd_sc,BD_SC_READY |BD_SC_LAST |BD_SC_WRAP );out_be16 (&tbdf->cbd_datlen, count);/* Setting rx bd status and data length */ +out_be32 (&rbdf->cbd_bufaddr, (ulong )din);out_be16 (&rbdf->cbd_sc,BD_SC_EMPTY |BD_SC_WRAP );out_be16 (&rbdf->cbd_datlen,0 );/* rx length has no significance */ @@ -333,3 +197,20 @@ ssize_t spi_xfer(size_t count)
Quoted 12 lines
drivers/spi/mpc8xx_spi.c ssize_t spi_xfer(size_t count) · line 206
Quoted 9 lines
drivers/spi/mpc8xx_spi.c +7
-0return count; } + +static const struct dm_spi_ops mpc8xx_spi_ops = { + .xfer = mpc8xx_spi_xfer, +}; + +static const struct udevice_id mpc8xx_spi_ids[] = { + { .compatible ="fsl,mpc8xx-spi" },Is this binding from Linux?
No, on Linux we have a common driver for 8xx and most of 8xxx. But the Uboot 8xxx SPI driver is too light to easily include 8xx so it was easier to port the existing 8xx driver to DM at the moment.
When the 8xxx implements QE mode SPI for the 83xx, then I'll be able to amend it to also support 8xx.
Christophe
PATCH v2 9/9 spi, mpc8xx: migrate to DM_SPI
In reply to Christophe LeroyQuoted 1 line · Christophe Leroy
Signed-off-by Christophe Leroy <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181203/a4b9d319/attachment.sig>
PATCH v2 1/9 powerpc, mpc8xx: clear top of stack
In reply to Christophe LeroyQuoted 3 lines · Christophe Leroy
Reported-by Joakim Tjernlund <[email protected]>Signed-off-by Christophe Leroy <[email protected]>
Leroy, if you need space, you may want to revive:
https://github.com/u-boot/u-boot/commit/39768f7715ed637ef02f49fc7de664cc1aaf14b3#diff-e2f25eeee512eac55747ede53068dd1e
it got reverted as some odd 8xx boards broke. I think these are gone now.
Jocke
Quoted 28 lines
--- arch/powerpc/cpu/mpc8xx/start.S | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)arch/powerpc/cpu/mpc8xx/start.S +3
-2@@ -144,9 +144,11 @@ in_flash: ori r2, r2, CONFIG_SYS_DER at l mtspr DER, r2 - /* set up the stack in internal DPRAM */ + /* set up the stack on top of internal DPRAM */ lis r3, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE)@h ori r3, r3, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE)@l + stw r0, -4(r3) + stw r0, -8(r3) addi r1, r3, -8 bl board_init_f_alloc_reserve --2.13.3
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH v2 1/9 powerpc, mpc8xx: clear top of stack
In reply to Christophe LeroyQuoted 3 lines · Christophe Leroy
Reported-by Joakim Tjernlund <[email protected]>Signed-off-by Christophe Leroy <[email protected]>Reviewed-by Joakim Tjernlund <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181203/e9064f25/attachment.sig>