Add new CS GROUP CPU board CMPCPRO (v1)
Subsystems (5)
PATCH 1/14 powerpc: mpc8xx: Migrate to CONFIG_SYS_CLK_FREQ
In reply to Christophe Leroy8xx has CONFIG_8xx_GCLK_FREQ which is similar to CONFIG_SYS_CLK_FREQ, and doesn't set CONFIG_SYS_CLK_FREQ.
Due to that, get_board_sys_clk() returns 0.
Remove CONFIG_8xx_GCLK_FREQ and use CONFIG_SYS_CLK_FREQ instead.
--- arch/powerpc/cpu/mpc8xx/Kconfig | 3 --- arch/powerpc/cpu/mpc8xx/speed.c | 4 ++-- configs/CMPC885_defconfig | 2 +- configs/MCR3000_defconfig | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-)
arch/powerpc/cpu/mpc8xx/Kconfig +0 -3
@@ -30,9 +30,6 @@ config MPC885 endchoice -config 8xx_GCLK_FREQ - int "CPU GCLK Frequency" - comment "Specific commands" config CMD_IMMAP
arch/powerpc/cpu/mpc8xx/speed.c +2 -2
@@ -14,7 +14,7 @@DECLARE_GLOBAL_DATA_PTR ;/* -* get_clocks() fills in gd->cpu_clock depending on CONFIG_8xx_GCLK_FREQ +* get_clocks() fills in gd->cpu_clk depending on CONFIG_SYS_CLK_FREQ */ int get_clocks (void ) {
@@ -28,7 +28,7 @@ int get_clocks(void)* (For example, the cogent CMA286-60 CPU module has no * separate oscillator for PITRTCLK) */ - gd->cpu_clk = CONFIG_8xx_GCLK_FREQ; + gd->cpu_clk =CONFIG_SYS_CLK_FREQ ;if ((sccr &SCCR_EBDF11 ) ==0 ) {/* No Bus Divider active */
configs/CMPC885_defconfig +1 -1
@@ -4,11 +4,11 @@ CONFIG_ENV_SECT_SIZE=0x2000 CONFIG_DM_GPIO=y CONFIG_DEFAULT_DEVICE_TREE="cmpc885" CONFIG_SYS_PROMPT="S3K> " +CONFIG_SYS_CLK_FREQ=132000000 CONFIG_ENV_ADDR=0x40004000 CONFIG_MPC8xx=y CONFIG_TARGET_CMPC885=y CONFIG_MPC885=y -CONFIG_8xx_GCLK_FREQ=132000000 CONFIG_CMD_IMMAP=y CONFIG_SYS_SIUMCR=0x00620000 CONFIG_SYS_SYPCR=0xFFFFFF8F
configs/MCR3000_defconfig +1 -1
@@ -4,11 +4,11 @@ CONFIG_ENV_SIZE=0x2000 CONFIG_ENV_SECT_SIZE=0x2000 CONFIG_DEFAULT_DEVICE_TREE="mcr3000" CONFIG_SYS_PROMPT="S3K> " +CONFIG_SYS_CLK_FREQ=132000000 CONFIG_SYS_LOAD_ADDR=0x200000 CONFIG_ENV_ADDR=0x4004000 CONFIG_MPC8xx=y CONFIG_TARGET_MCR3000=y -CONFIG_8xx_GCLK_FREQ=132000000 CONFIG_CMD_IMMAP=y CONFIG_SYS_SIUMCR=0x00600400 CONFIG_SYS_SYPCR=0xFFFFFF8F
Signature · 1 line
2.39.2
cover Add new CS GROUP CPU board CMPCPRO (v1)
This series adds support for the last CPU board from CS GROUP France (previously CSSI).
That CPU board called CMPCPRO has a mpc8321E CPU (Family PQII PRO hence its name) and can be plugged in place of the CMPC885 board.
In order to support that new board, the following changes are included in this series:
- Make the mpc8xx watchdog driver more generic for reusing it with mpc83xx
- Fix various small problems on mpc83xx platform
- Add a GPIO Driver for QE GPIOs
- Add support for mpc832x into mpc83xx SPI driver
- Refactor existing board code that will be shared with new board
- Add the new board
This series is based on today's next tree and has passed CI tests at
https://source.denx.de/u-boot/custodians/u-boot-mpc8xx/-/pipelines/15928
Christophe Leroy (14):
powerpc: mpc8xx: Migrate to CONFIG_SYS_CLK_FREQ
watchdog: mpc8xx: Rename it mpc8xxx
watchdog: mpc8xxx: Make it generic
watchdog: mpc8xxx: Add support for mpc83xx
powerpc: mpc832x: Fix reset word
powerpc: mpc83xx: Fix soc.h
powerpc: mpc83xx: Don't activate MMU when not necessary
clk: mpc83xx: Fix clocks for mpc832x
gpio: Add QUICC Engine GPIOs driver
spi: mpc8xxx: Add support for SPI on mpc832x
board: cssi: Create dedicated file for common sources
board: cssi: Refactor EEPROM read
board: cssi: Move all mother board code into common.c
board: cssi: Add CPU board CMPCPRO
arch/powerpc/Kconfig | 2 +- arch/powerpc/cpu/mpc83xx/Kconfig | 5 + arch/powerpc/cpu/mpc83xx/cpu.c | 2 +- arch/powerpc/cpu/mpc83xx/hrcw/Kconfig | 3 +- arch/powerpc/cpu/mpc83xx/start.S | 4 +- arch/powerpc/cpu/mpc8xx/Kconfig | 6 +- arch/powerpc/cpu/mpc8xx/cpu_init.c | 5 +- arch/powerpc/cpu/mpc8xx/speed.c | 4 +- arch/powerpc/dts/Makefile | 1 + arch/powerpc/dts/cmpc885.dts | 12 +- arch/powerpc/dts/cmpcpro.dts | 189 +++++++++ arch/powerpc/dts/mcr3000.dts | 20 +- arch/powerpc/include/asm/arch-mpc83xx/gpio.h | 5 + arch/powerpc/include/asm/arch-mpc83xx/soc.h | 16 +- arch/powerpc/include/asm/mpc8xxx_spi.h | 1 + board/cssi/MAINTAINERS | 2 + board/cssi/cmpc885/Makefile | 2 +- board/cssi/cmpc885/cmpc885.c | 241 ++--------- board/cssi/cmpcpro/Kconfig | 26 ++ board/cssi/cmpcpro/Makefile | 8 + board/cssi/cmpcpro/cmpcpro.c | 404 +++++++++++++++++++ board/cssi/cmpcpro/cmpcpro.env | 8 + board/cssi/cmpcpro/nand.c | 43 ++ board/cssi/common/common.c | 219 ++++++++++ board/cssi/common/common.h | 15 + board/cssi/mcr3000/mcr3000.c | 14 - configs/CMPC885_defconfig | 4 +- configs/CMPCPRO_defconfig | 209 ++++++++++ configs/MCR3000_defconfig | 5 +- drivers/clk/mpc83xx_clk.c | 7 + drivers/gpio/Kconfig | 18 + drivers/gpio/Makefile | 1 + drivers/gpio/qe_gpio.c | 170 ++++++++ drivers/spi/mpc8xxx_spi.c | 13 + drivers/watchdog/Kconfig | 26 +- drivers/watchdog/Makefile | 2 +- drivers/watchdog/mpc8xx_wdt.c | 75 ---- drivers/watchdog/mpc8xxx_wdt.c | 112 +++++ include/configs/cmpc885.h | 6 + include/configs/cmpcpro.h | 99 +++++ 40 files changed, 1660 insertions(+), 344 deletions(-) create mode 100644 arch/powerpc/dts/cmpcpro.dts create mode 100644 board/cssi/cmpcpro/Kconfig create mode 100644 board/cssi/cmpcpro/Makefile create mode 100644 board/cssi/cmpcpro/cmpcpro.c create mode 100644 board/cssi/cmpcpro/cmpcpro.env create mode 100644 board/cssi/cmpcpro/nand.c create mode 100644 board/cssi/common/common.c create mode 100644 board/cssi/common/common.h create mode 100644 configs/CMPCPRO_defconfig create mode 100644 drivers/gpio/qe_gpio.c delete mode 100644 drivers/watchdog/mpc8xx_wdt.c create mode 100644 drivers/watchdog/mpc8xxx_wdt.c create mode 100644 include/configs/cmpcpro.h
Signature · 1 line
2.39.2
PATCH 7/14 powerpc: mpc83xx: Don't activate MMU when not necessary
At startup, some RAM is needed (for instance for stack) before DRAM is initialised.
One way to offer such RAM, used by mpc83xx, is to lock some entries in the cache. To do that, MMU needs to be activated.
On mpc83xx having a QUICC Engine an alternative is to user some part of from the Multi User RAM, like done on mpc8xx for instance. For that, the MMU is not needed.
Activating the MMU is problematic because exception vectors are not setup yet so in case of ISI or DSI that CPU will crash and reboot.
At the time being, MMU is activated regardless.
Only activate it when locking cache entries to provide initial RAM.
--- arch/powerpc/cpu/mpc83xx/start.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/cpu/mpc83xx/start.S +1 -1
@@ -215,6 +215,7 @@ in_flash: * gt-regs BAT can be reused after board_init_f calls * board_early_init_f (EVB only). */ +#ifdef CONFIG_SYS_INIT_RAM_LOCK /* enable address translation */ bl enable_addr_trans sync
@@ -222,7 +223,6 @@ in_flash: /* enable the data cache */ bl dcache_enable sync -#ifdef CONFIG_SYS_INIT_RAM_LOCK bl lock_ram_in_cache sync #endif
Signature · 1 line
2.39.2
PATCH 5/14 powerpc: mpc832x: Fix reset word
In reply to Christophe LeroyAccording to the reference manual, the Reset Configuration Word Low Register bits 2-3 must be set to 0b10.
--- arch/powerpc/cpu/mpc83xx/hrcw/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/powerpc/cpu/mpc83xx/hrcw/Kconfig +1 -2
@@ -539,8 +539,7 @@ config DDR_MC_CLOCK_MODE config SYSTEM_PLL_VCO_DIV int - default 0 if ARCH_MPC832X - default 2 if ARCH_MPC8313 + default 2 if ARCH_MPC8313 || ARCH_MPC832X default 0 if SYSTEM_PLL_VCO_DIV_2 && !ARCH_MPC8360 && !ARCH_MPC837X default 1 if SYSTEM_PLL_VCO_DIV_4 && !ARCH_MPC8360 && !ARCH_MPC837X default 2 if SYSTEM_PLL_VCO_DIV_8 && !ARCH_MPC8360 && !ARCH_MPC837X
Signature · 1 line
2.39.2
PATCH 3/14 watchdog: mpc8xxx: Make it generic
In reply to Christophe Leroympc8xx, mpc83xx and mpc86xx have similar watchdog with almost same memory registers.
Refactor the driver to get the register addresses from the device tree and use the compatible to know the prescale factor.
Calculate the watchdog setup value from the provided timeout.
Don't declare it anymore as an HW_WATCHDOG, u-boot will start servicing the watchdog early enough.
On mpc8xx the watchdog configuration register is also used for configuring the bus monitor. So add it as an option to the watchdog when it is mpc8xx. When watchdog is not selected, leave the configuration of the initial SYPCR from Kconfig.
--- arch/powerpc/cpu/mpc8xx/Kconfig | 3 +- arch/powerpc/cpu/mpc8xx/cpu_init.c | 5 +-- arch/powerpc/dts/cmpc885.dts | 12 ++--- arch/powerpc/dts/mcr3000.dts | 20 ++++++++- board/cssi/mcr3000/mcr3000.c | 14 ------ configs/CMPC885_defconfig | 2 +- configs/MCR3000_defconfig | 3 +- drivers/watchdog/Kconfig | 18 +++++++- drivers/watchdog/mpc8xxx_wdt.c | 72 ++++++++++++++++++++++-------- 9 files changed, 102 insertions(+), 47 deletions(-)
arch/powerpc/cpu/mpc8xx/Kconfig +2 -1
@@ -48,7 +48,8 @@ config SYS_SIUMCR SIU Module Configuration (11-6) config SYS_SYPCR - hex "SYPCR register" + hex "SYPCR register" if !WDT_MPC8xxx + default 0 help System Protection Control (11-9)
arch/powerpc/cpu/mpc8xx/cpu_init.c +2 -3
@@ -26,10 +26,9 @@ void cpu_init_f(immap_t __iomem *immr)/* SYPCR - contains watchdog control (11-9) */ -#ifndef CONFIG_HW_WATCHDOG /* deactivate watchdog if not enabled in config */ -out_be32 (&immr->im_siu_conf.sc_sypcr,CONFIG_SYS_SYPCR & ~SYPCR_SWE ); -#endif +if (!IS_ENABLED (CONFIG_WDT_MPC8xxx)) +out_be32 (&immr->im_siu_conf.sc_sypcr,CONFIG_SYS_SYPCR & ~SYPCR_SWE );schedule ();
arch/powerpc/dts/cmpc885.dts +7 -5
@@ -18,11 +18,6 @@ stdout-path = &SERIAL; }; - WDT: watchdog@0 { - device_type = "watchdog"; - compatible = "fsl,pq1-wdt"; - }; - SERIAL: serial { compatible = "fsl,pq1-smc"; };
@@ -43,6 +38,13 @@ ranges = <0 0xff000000 0x4000>; reg = <0xff000000 0x00000200>; + WDT: watchdog@0 { + compatible = "fsl,pq1-wdt"; + reg = <0x0 0x10>; + timeout-sec = <2>; + hw_margin_ms = <1000>; + }; + CPM1_PIO_B: gpio-controller@ab8 { #gpio-cells = <2>; compatible = "fsl,cpm1-pario-bank-b";
arch/powerpc/dts/mcr3000.dts +18 -2
@@ -9,9 +9,25 @@ /dts-v1/; / { - WDT: watchdog@0 { - compatible = "fsl,pq1-wdt"; + #address-cells = <1>; + #size-cells = <1>; + + soc: immr@ff000000 { + #address-cells = <1>; + #size-cells = <1>; + device-type = "soc"; + compatible = "simple-bus"; + ranges = <0 0xff000000 0x4000>; + reg = <0xff000000 0x00000200>; + + WDT: watchdog@0 { + compatible = "fsl,pq1-wdt"; + reg = <0x0 0x10>; + timeout-sec = <2>; + hw_margin_ms = <1000>; + }; }; + SERIAL: smc@0 { compatible = "fsl,pq1-smc"; };
board/cssi/mcr3000/mcr3000.c +0 -14
@@ -138,17 +138,3 @@ 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 ; -}
configs/CMPC885_defconfig +1 -1
@@ -11,7 +11,6 @@ CONFIG_TARGET_CMPC885=y CONFIG_MPC885=y CONFIG_CMD_IMMAP=y CONFIG_SYS_SIUMCR=0x00620000 -CONFIG_SYS_SYPCR=0xFFFFFF8F CONFIG_SYS_TBSCR=0x00C3 CONFIG_SYS_PISCR=0x0000 CONFIG_SYS_PLPRCR_BOOL=y
@@ -106,5 +105,6 @@ CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_MPC8XX_SPI=y CONFIG_WDT=y +CONFIG_WDT_MPC8xxx_BME=y # CONFIG_REGEX is not set CONFIG_LZMA=y
configs/MCR3000_defconfig +1 -2
@@ -11,7 +11,6 @@ CONFIG_MPC8xx=y CONFIG_TARGET_MCR3000=y CONFIG_CMD_IMMAP=y CONFIG_SYS_SIUMCR=0x00600400 -CONFIG_SYS_SYPCR=0xFFFFFF8F CONFIG_SYS_TBSCR=0x00C3 CONFIG_SYS_PISCR=0x0000 CONFIG_SYS_PLPRCR_BOOL=y
@@ -29,7 +28,6 @@ CONFIG_AUTOBOOT_PROMPT="\nEnter password - autoboot in %d sec...\n" CONFIG_AUTOBOOT_DELAY_STR="root" CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="run flashboot" -CONFIG_BOARD_EARLY_INIT_R=y # CONFIG_HWCONFIG is not set CONFIG_MISC_INIT_R=y CONFIG_HUSH_PARSER=y
@@ -102,4 +100,5 @@ CONFIG_MPC8XX_FEC=y # CONFIG_PCI is not set CONFIG_DM_SERIAL=y CONFIG_WDT=y +CONFIG_WDT_MPC8xxx_BME=y CONFIG_LZMA=y
drivers/watchdog/Kconfig +17 -1
@@ -187,10 +187,26 @@ config WDT_MESON_GXBB config WDT_MPC8xxx bool "MPC8xxx watchdog timer support" depends on WDT && MPC8xx - select HW_WATCHDOG help Select this to enable mpc8xxx watchdog timer +config WDT_MPC8xxx_BME + bool "Enable MPC8xx Bus Monitoring" + depends on WDT_MPC8xxx && MPC8xx + help + Select this to enable mpc8xx Bus Monitor. + +config WDT_MPC8xxx_BMT + int "MPC8xx Bus Monitor Timing" if WDT_MPC8xxx_BME + range 0 255 + default 255 + depends on WDT_MPC8xxx + help + Bus monitor timing. Defines the timeout period, in 8 system clock + resolution, for the bus monitor. + + Maximum timeout is 2,040 clocks (255 x 8). + config WDT_MT7620 bool "MediaTek MT7620 watchdog timer support" depends on WDT && SOC_MT7620
drivers/watchdog/mpc8xxx_wdt.c +54 -18
115 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH 6/14 powerpc: mpc83xx: Fix soc.h
In reply to Christophe LeroyThere are helpers included in soc.h
Declare them static inline so that soc.h can be
included in several places.
--- arch/powerpc/include/asm/arch-mpc83xx/soc.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/arch-mpc83xx/soc.h +8 -8
@@ -18,14 +18,14 @@ enum soc_type { SOC_MPC8379, }; -bool mpc83xx_has_sdhc (int type) +static inline bool mpc83xx_has_sdhc (int type) {return (type ==SOC_MPC8308 ) || (type ==SOC_MPC8309 ) || (type ==SOC_MPC8379 ); } -bool mpc83xx_has_tsec (int type) +static inline bool mpc83xx_has_tsec (int type) {return (type ==SOC_MPC8308 ) || (type == SOC_MPC8313) ||
@@ -34,37 +34,37 @@ bool mpc83xx_has_tsec(int type) (type ==SOC_MPC8379 ); } -bool mpc83xx_has_pcie1 (int type) +static inline bool mpc83xx_has_pcie1 (int type) {return (type ==SOC_MPC8308 ) || (type ==SOC_MPC8315 ) || (type ==SOC_MPC8379 ); } -bool mpc83xx_has_pcie2 (int type) +static inline bool mpc83xx_has_pcie2 (int type) {return (type ==SOC_MPC8315 ) || (type ==SOC_MPC8379 ); } -bool mpc83xx_has_sata (int type) +static inline bool mpc83xx_has_sata (int type) {return (type ==SOC_MPC8315 ) || (type ==SOC_MPC8379 ); } -bool mpc83xx_has_pci (int type) +static inline bool mpc83xx_has_pci (int type) {return type !=SOC_MPC8308 ; } -bool mpc83xx_has_second_i2c (int type) +static inline bool mpc83xx_has_second_i2c (int type) {return (type !=SOC_MPC8315 ) && (type !=SOC_MPC832X ); } -bool mpc83xx_has_quicc_engine (int type) +static inline bool mpc83xx_has_quicc_engine (int type) {return (type ==SOC_MPC8309 ) || (type == SOC_MPC832X) ||
Signature · 1 line
2.39.2
PATCH 8/14 clk: mpc83xx: Fix clocks for mpc832x
In reply to Christophe Leroygd->arch.sdhc_clk only exists when CONFIG_FSL_ESDHC is set, so enclose it inside ifdefs.
gd->arch.qe_clk and gd->arch.brg_clk must be populated when CONFIG_QE is set.
--- drivers/clk/mpc83xx_clk.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/clk/mpc83xx_clk.c +7 -0
@@ -346,8 +346,10 @@ static int mpc83xx_clk_probe(struct udevice *dev) type =dev_get_driver_data (dev); +#ifdef CONFIG_FSL_ESDHC if (mpc83xx_has_sdhc (type)) gd->arch.sdhc_clk = priv->speed[MPC83XX_CLK_SDHC ]; +#endif gd->arch.core_clk = priv->speed[MPC83XX_CLK_CORE ]; gd->arch.i2c1_clk = priv->speed[MPC83XX_CLK_I2C1 ];
@@ -362,6 +364,11 @@ static int mpc83xx_clk_probe(struct udevice *dev) gd->cpu_clk = priv->speed[MPC83XX_CLK_CORE ]; gd->bus_clk = priv->speed[MPC83XX_CLK_CSB ]; +#ifdef CONFIG_QE + gd->arch.qe_clk = priv->speed[MPC83XX_CLK_QE ]; + gd->arch.brg_clk = priv->speed[MPC83XX_CLK_BRG ]; +#endif +return 0 ; }
Signature · 1 line
2.39.2
PATCH 4/14 watchdog: mpc8xxx: Add support for mpc83xx
In reply to Christophe LeroyIntroduce a new compatible "fsl,pq2pro-wdt"
On mpc83xx, the prescaling factor is 0x10000.
Don't write the watchdog configuration register in start.S as it can be written only once.
--- arch/powerpc/cpu/mpc83xx/cpu.c | 2 +- arch/powerpc/cpu/mpc83xx/start.S | 2 ++ drivers/watchdog/Kconfig | 2 +- drivers/watchdog/mpc8xxx_wdt.c | 1 + 4 files changed, 5 insertions(+), 2 deletions(-)
arch/powerpc/cpu/mpc83xx/cpu.c +1 -1
@@ -165,7 +165,7 @@ unsigned long get_tbclk(void) }#endif -#if defined(CONFIG_WATCHDOG ) +#if defined(CONFIG_WATCHDOG ) && !defined(CONFIG_WDT )void watchdog_reset (void ) {int re_enable =disable_interrupts ();
arch/powerpc/cpu/mpc83xx/start.S +2 -0
@@ -483,6 +483,7 @@ init_e300_core: /* time t 10 */ lis r3, CONFIG_SYS_IMMR@h +#ifndef CONFIG_WDT_MPC8xxx #if defined(CONFIG_WATCHDOG) /* Initialise the Watchdog values and reset it (if req) */ /*------------------------------------------------------*/
@@ -508,6 +509,7 @@ init_e300_core: /* time t 10 */ stw r4, SWCRR(r3) 1: #endif /* CONFIG_WATCHDOG */ +#endif #if defined(CONFIG_MASK_AER_AO) /* Write the Arbiter Event Enable to mask Address Only traps. */
drivers/watchdog/Kconfig +1 -1
@@ -186,7 +186,7 @@ config WDT_MESON_GXBB config WDT_MPC8xxx bool "MPC8xxx watchdog timer support" - depends on WDT && MPC8xx + depends on WDT && (MPC8xx || MPC83xx) help Select this to enable mpc8xxx watchdog timer
drivers/watchdog/mpc8xxx_wdt.c +1 -0
@@ -98,6 +98,7 @@ static const struct wdt_ops mpc8xxx_wdt_ops = {static const struct udevice_id mpc8xxx_wdt_ids[] = { { .compatible ="fsl,pq1-wdt" , .data =0x800 }, + { .compatible ="fsl,pq2pro-wdt" , .data =0x10000 }, {} };
Signature · 1 line
2.39.2
PATCH 2/14 watchdog: mpc8xx: Rename it mpc8xxx
In reply to Christophe Leroympc8xx, mpc83xx and mpc86xx have similar watchdog with almost same memory registers.
Rename it mpc8xxx which is the generic name used for drivers supporting several mpc families.
The driver will be made more generic in following patch.
---
arch/powerpc/Kconfig | 2 +-
drivers/watchdog/Kconfig | 6 ++---
drivers/watchdog/Makefile | 2 +-
.../watchdog/{mpc8xx_wdt.c => mpc8xxx_wdt.c} | 24 +++++++++----------
4 files changed, 17 insertions(+), 17 deletions(-)
rename drivers/watchdog/{mpc8xx_wdt.c => mpc8xxx_wdt.c} (72%)arch/powerpc/Kconfig +1 -1
@@ -31,7 +31,7 @@ config MPC8xx select CREATE_ARCH_SYMLINK select BOARD_EARLY_INIT_F imply CMD_REGINFO - imply WDT_MPC8xx + imply WDT_MPC8xxx endchoice
drivers/watchdog/Kconfig +3 -3
@@ -184,12 +184,12 @@ config WDT_MESON_GXBB Select this to enable Meson watchdog timer, which can be found on some Amlogic platforms. -config WDT_MPC8xx - bool "MPC8xx watchdog timer support" +config WDT_MPC8xxx + bool "MPC8xxx watchdog timer support" depends on WDT && MPC8xx select HW_WATCHDOG help - Select this to enable mpc8xx watchdog timer + Select this to enable mpc8xxx watchdog timer config WDT_MT7620 bool "MediaTek MT7620 watchdog timer support"
drivers/watchdog/Makefile +1 -1
@@ -29,7 +29,7 @@ obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o obj-$(CONFIG_WDT_GPIO) += gpio_wdt.o obj-$(CONFIG_WDT_MAX6370) += max6370_wdt.o obj-$(CONFIG_WDT_MESON_GXBB) += meson_gxbb_wdt.o -obj-$(CONFIG_WDT_MPC8xx) += mpc8xx_wdt.o +obj-$(CONFIG_WDT_MPC8xxx) += mpc8xxx_wdt.o obj-$(CONFIG_WDT_MT7620) += mt7620_wdt.o obj-$(CONFIG_WDT_MT7621) += mt7621_wdt.o obj-$(CONFIG_WDT_MTK) += mtk_wdt.o
drivers/watchdog/mpc8xxx_wdt.c renamed from drivers/watchdog/mpc8xx_wdt.c +12 -12
@@ -19,7 +19,7 @@ void hw_watchdog_reset(void)out_be16 (&immap->im_siu_conf.sc_swsr,0xaa39 );/* write magic2 */ } -static int mpc8xx_wdt_start (struct udevice *dev,u64 timeout,ulong flags) +static int mpc8xxx_wdt_start (struct udevice *dev,u64 timeout,ulong flags) {immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR ;u32 val =CONFIG_SYS_SYPCR ;
@@ -38,7 +38,7 @@ static int mpc8xx_wdt_start(struct udevice *dev, u64 timeout, ulong flags) } -static int mpc8xx_wdt_stop (struct udevice *dev) +static int mpc8xxx_wdt_stop (struct udevice *dev) {immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR ;
@@ -49,27 +49,27 @@ static int mpc8xx_wdt_stop(struct udevice *dev)return 0 ; } -static int mpc8xx_wdt_reset (struct udevice *dev) +static int mpc8xxx_wdt_reset (struct udevice *dev) {hw_watchdog_reset ();return 0 ; } -static const struct wdt_ops mpc8xx_wdt_ops = { - .start = mpc8xx_wdt_start, - .reset = mpc8xx_wdt_reset, - .stop = mpc8xx_wdt_stop, +static const struct wdt_ops mpc8xxx_wdt_ops = { + .start = mpc8xxx_wdt_start, + .reset = mpc8xxx_wdt_reset, + .stop = mpc8xxx_wdt_stop, }; -static const struct udevice_id mpc8xx_wdt_ids[] = { +static const struct udevice_id mpc8xxx_wdt_ids[] = { { .compatible ="fsl,pq1-wdt" }, {} }; -U_BOOT_DRIVER (wdt_mpc8xx) = { - .name ="wdt_mpc8xx" , +U_BOOT_DRIVER (wdt_mpc8xxx) = { + .name ="wdt_mpc8xxx" , .id =UCLASS_WDT , - .of_match = mpc8xx_wdt_ids, - .ops = &mpc8xx_wdt_ops, + .of_match = mpc8xxx_wdt_ids, + .ops = &mpc8xxx_wdt_ops, };
Signature · 1 line
2.39.2
PATCH 13/14 board: cssi: Move all mother board code into common.c
In reply to Christophe LeroyAll the code used to manage the mother boards will be common to soon to come CPU board.
Move all that code into common.c
--- board/cssi/cmpc885/cmpc885.c | 152 +++++------------------------------ board/cssi/common/common.c | 124 +++++++++++++++++++++++++++- board/cssi/common/common.h | 8 +- include/configs/cmpc885.h | 6 ++ 4 files changed, 157 insertions(+), 133 deletions(-)
board/cssi/cmpc885/cmpc885.c +21 -131
@@ -28,33 +28,15 @@DECLARE_GLOBAL_DATA_PTR ; -#define BOARD_CMPC885 "cmpc885" -#define BOARD_MCR3000_2G "mcr3k_2g" -#define BOARD_VGOIP "vgoip" -#define BOARD_MIAE "miae" - -#define TYPE_MCR 0x22 -#define TYPE_MIAE 0x23 - -#define FAR_CASRSA 2 -#define FAR_VGOIP 4 -#define FAV_CLA 7 -#define FAV_SRSA 8 -#define ADDR_CPLD_R_RESET ((unsigned short __iomem *)CONFIG_CPLD_BASE)#define ADDR_CPLD_R_ETAT ((unsigned short __iomem *)(CONFIG_CPLD_BASE + 2))#define ADDR_CPLD_R_TYPE ((unsigned char __iomem *)(CONFIG_CPLD_BASE + 3)) -#define ADDR_FPGA_R_BASE ((unsigned char __iomem *)CONFIG_FPGA_BASE) -#define ADDR_FPGA_R_ALARMES_IN ((unsigned char __iomem *)CONFIG_FPGA_BASE + 0x31) -#define ADDR_FPGA_R_FAV ((unsigned char __iomem *)CONFIG_FPGA_BASE + 0x44) -#define PATH_PHY2 "/soc@ff000000/mdio@e00/ethernet-phy@2"#define PATH_PHY3 "/soc@ff000000/mdio@e00/ethernet-phy@3"#define PATH_ETH1 "/soc@ff000000/ethernet@1e00"#define FIBER_PHY PATH_PHY2 -#define FPGA_R_ACQ_AL_FAV 0x04#define R_ETAT_PRES_BASE 0x0040#define R_RESET_STATUS 0x0400
@@ -62,8 +44,6 @@ DECLARE_GLOBAL_DATA_PTR;int ft_board_setup (void *blob,struct bd_info *bd) { -u8 fav_id, far_id; -const char *sync ="receive" ;ft_cpu_setup (blob, bd);
@@ -87,32 +67,19 @@ int ft_board_setup(void *blob, struct bd_info *bd)do_fixup_by_path (blob,"/localbus/e1" ,"rising-edge-sync-pulse" , sync,strlen (sync),1 );/* MIAE only */ -if (!(in_be16 (ADDR_CPLD_R_ETAT ) &R_ETAT_PRES_BASE ) ||in_8 (ADDR_FPGA_R_BASE ) !=TYPE_MIAE ) +if (!(in_be16 (ADDR_CPLD_R_ETAT ) &R_ETAT_PRES_BASE ))return 0 ; - far_id =in_8 (ADDR_FPGA_R_BASE +0x43 ) >>5 ; -ft_cleanup (blob, (u32 )far_id,"far-id" ,"cs,mia-far" ); - -/* -* special case, with CASRSA (far_id: 2) -* FAV-SRSA register itself as FAV-CLA -*/ - fav_id =in_8 (ADDR_FPGA_R_BASE +0x44 ) >>5 ; - -if (far_id ==FAR_CASRSA && fav_id ==FAV_CLA ) - fav_id =FAV_SRSA ; - -ft_cleanup (blob, (u32 )fav_id,"fav-id" ,"cs,mia-fav" ); - -if (far_id ==FAR_CASRSA ) { -/* switch to phy3 with gpio, we'll only use phy3 */ -immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR ; -cpm8xx_t __iomem *cp = (cpm8xx_t __iomem *)&immr->im_cpm; +return ft_board_setup_common (blob); +} -setbits_be32 (&cp->cp_pedat,0x00002000 ); - } +void ft_board_setup_phy3 (void ) +{ +/* switch to phy3 with gpio, we'll only use phy3 */ +immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR ; +cpm8xx_t __iomem *cp = (cpm8xx_t __iomem *)&immr->im_cpm; -return 0 ; +setbits_be32 (&cp->cp_pedat,0x00002000 ); }int checkboard (void )
@@ -120,30 +87,11 @@ int checkboard(void)serial_puts ("Board: " );/* Is a motherboard present ? */ -if (in_be16 (ADDR_CPLD_R_ETAT ) &R_ETAT_PRES_BASE ) { -switch (in_8 (ADDR_FPGA_R_BASE )) { -int far_id; -case TYPE_MCR : -printf ("MCR3000_2G (CS GROUP)\n" ); -break ; -case TYPE_MIAE : - far_id =in_8 (ADDR_FPGA_R_BASE +0x43 ) >>5 ; - -if (far_id ==FAR_VGOIP ) -printf ("VGoIP (CS GROUP)\n" ); -else -printf ("MIAE (CS GROUP)\n" ); - -break ; -default : -printf ("Unknown\n" ); -for (;;) - ; -break ; - } - }else { -printf ("CMPC885 (CS GROUP)\n" ); - } +if (in_be16 (ADDR_CPLD_R_ETAT ) &R_ETAT_PRES_BASE ) +return checkboard_common (); + +printf ("CMPC885 (CS GROUP)\n" ); +return 0 ; }
@@ -174,57 +122,12 @@ static int setup_mac(void)int misc_init_r (void ) { -u8 val, tmp, far_id; -int count =3 ; - - val =in_8 (ADDR_FPGA_R_BASE ); -/* Verify mother board presence */ if (in_be16 (ADDR_CPLD_R_ETAT ) &R_ETAT_PRES_BASE ) { -/* identify the type of mother board */ -switch (val) { -case TYPE_MCR : -/* if at boot alarm button is pressed, delay boot */ -if ((in_8 (ADDR_FPGA_R_ALARMES_IN ) &FPGA_R_ACQ_AL_FAV ) ==0 ) -env_set ("bootdelay" ,"60" ); - -env_set ("config" ,BOARD_MCR3000_2G ); -env_set ("hostname" ,BOARD_MCR3000_2G ); -break ; - -case TYPE_MIAE : -do { - tmp =in_8 (ADDR_FPGA_R_BASE +0x41 ); - count--; -mdelay (10 );/* 10msec wait */ - }while (count && tmp !=in_8 (ADDR_FPGA_R_BASE +0x41 )); - -if (!count) { -printf ("Cannot read the reset factory switch position\n" ); -hang (); - } - -if (tmp &0x1 ) -env_set_default ("Factory settings switch ON" ,0 ); - -env_set ("config" ,BOARD_MIAE ); - far_id =in_8 (ADDR_FPGA_R_BASE +0x43 ) >>5 ; - -if (far_id ==FAR_VGOIP ) -env_set ("hostname" ,BOARD_VGOIP ); -else -env_set ("hostname" ,BOARD_MIAE ); -break ; - -default : -env_set ("config" ,BOARD_CMPC885 ); -env_set ("hostname" ,BOARD_CMPC885 ); -break ; - } +misc_init_r_common (); }else { -printf ("no mother board detected" ); -env_set ("config" ,BOARD_CMPC885 ); -env_set ("hostname" ,BOARD_CMPC885 ); +env_set ("config" ,CFG_BOARD_CMPCXXX ); +env_set ("hostname" ,CFG_BOARD_CMPCXXX ); }if (setup_mac ())
@@ -236,7 +139,7 @@ int misc_init_r(void)return 0 ; } -static void iop_setup_mcr (void ) +void iop_setup_mcr (void ) {immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR ;iop8xx_t __iomem *iop = &immr->im_ioport;
@@ -539,7 +442,7 @@ static void iop_setup_cmpc885(void)clrbits_be32 (&cp->cp_peso,0x00031980 ); } -static void iop_setup_miae (void ) +void iop_setup_miae (void ) {immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR ;iop8xx_t __iomem *iop = &immr->im_ioport;
@@ -549,7 +452,7 @@ static void iop_setup_miae(void)udelay (100 );/* Set the front panel LED color to red */ -clrbits_8 (ADDR_FPGA_R_FAV ,0x02 ); +clrbits_8 ((unsigned char __iomem *)CONFIG_FPGA_BASE +0x44 ,0x02 );/* We must initialize data before changing direction */ setbits_be16 (&iop->iop_pcdat,0x0888 );
@@ -1007,20 +910,7 @@ int board_early_init_r(void)mdelay (200 ); } -/* Identify the type of mother board */ -switch (in_8 (ADDR_FPGA_R_BASE )) { -case TYPE_MCR : -iop_setup_mcr (); -break ; - -case TYPE_MIAE : -iop_setup_miae (); -break ; - -default : -break ; - } -/* CMPC885 board alone */ +iop_setup_common (); }else {iop_setup_cmpc885 (); }
board/cssi/common/common.c +123 -1
141 lines not on this page · raw message
board/cssi/common/common.h +7 -1
@@ -3,7 +3,13 @@#ifndef _BOARD_CSSI_COMMON_H#define _BOARD_CSSI_COMMON_H -void ft_cleanup (void *blob,unsigned long id,const char *prop,const char *compatible);int read_eeprom (u8 *din,int len); +int ft_board_setup_common (void *blob); +void ft_board_setup_phy3 (void ); +int checkboard_common (void ); +void misc_init_r_common (void ); +void iop_setup_common (void ); +void iop_setup_mcr (void ); +void iop_setup_miae (void );#endif /* _BOARD_CSSI_COMMON_H */
include/configs/cmpc885.h +6 -0
@@ -26,4 +26,10 @@/* NAND configuration part */ #define CFG_SYS_NAND_BASE 0xC0000000 +/* Board names */ +#define CFG_BOARD_CMPCXXX "cmpc885" +#define CFG_BOARD_MCR3000_2G "mcr3k_2g" +#define CFG_BOARD_VGOIP "vgoip" +#define CFG_BOARD_MIAE "miae" +#endif /* __CONFIG_H */
Signature · 1 line
2.39.2
PATCH 9/14 gpio: Add QUICC Engine GPIOs driver
In reply to Christophe LeroyThe mpc832x has GPIOs handled by the QUICC Engine. The registers are different from the one for the non QE mpc83xx GPIOs.
Implement a GPIO driver for those.
--- arch/powerpc/include/asm/arch-mpc83xx/gpio.h | 5 + drivers/gpio/Kconfig | 18 ++ drivers/gpio/Makefile | 1 + drivers/gpio/qe_gpio.c | 170 +++++++++++++++++++ 4 files changed, 194 insertions(+) create mode 100644 drivers/gpio/qe_gpio.c
arch/powerpc/include/asm/arch-mpc83xx/gpio.h +5 -0
@@ -22,6 +22,11 @@ struct mpc8xxx_gpio_plat {uint ngpios; }; +struct qe_gpio_plat { +ulong addr; +unsigned long size; +}; +#ifndef DM_GPIO void mpc83xx_gpio_init_f (void );void mpc83xx_gpio_init_r (void );
drivers/gpio/Kconfig +18 -0
@@ -547,6 +547,24 @@ config MPC8XXX_GPIO value setting, the open-drain feature, which can configure individual GPIOs to work as open-drain outputs, is supported. +config QE_GPIO + bool "Freescale QUICC ENGINE GPIO driver" + depends on DM_GPIO + depends on QE + help + This driver supports the QUICC Engine GPIOs of MPC83XX CPUs. + Each GPIO bank is identified by its own entry in the device tree, + i.e. + + qe_pio_a: gpio-controller@1400 { + compatible = "fsl,mpc8323-qe-pario-bank"; + reg = <0x1400 0x18>; + gpio-controller; + #gpio-cells = <2>; + }; + + Each bank has 32 GPIOs. + config MPC8XX_GPIO bool "Freescale MPC8XX GPIO driver" depends on DM_GPIO
drivers/gpio/Makefile +1 -0
@@ -38,6 +38,7 @@ obj-$(CONFIG_TEGRA186_GPIO) += tegra186_gpio.o obj-$(CONFIG_DA8XX_GPIO) += da8xx_gpio.o obj-$(CONFIG_ALTERA_PIO) += altera_pio.o obj-$(CONFIG_MPC8XXX_GPIO) += mpc8xxx_gpio.o +obj-$(CONFIG_QE_GPIO) += qe_gpio.o obj-$(CONFIG_MPC8XX_GPIO) += mpc8xx_gpio.o obj-$(CONFIG_MPC83XX_SPISEL_BOOT) += mpc83xx_spisel_boot.o obj-$(CONFIG_SH_GPIO_PFC) += sh_pfc.o
drivers/gpio/qe_gpio.c new file +170 -0
170 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH 11/14 board: cssi: Create dedicated file for common sources
In reply to Christophe LeroyIn preparation of the new cssi board called cmpcpro which we be introduce in a future patch, move common functions into a dedicated file in a common directory.
--- board/cssi/cmpc885/Makefile | 2 +- board/cssi/cmpc885/cmpc885.c | 54 ++----------------------------- board/cssi/common/common.c | 62 ++++++++++++++++++++++++++++++++++++ board/cssi/common/common.h | 8 +++++ 4 files changed, 73 insertions(+), 53 deletions(-) create mode 100644 board/cssi/common/common.c create mode 100644 board/cssi/common/common.h
board/cssi/cmpc885/Makefile +1 -1
@@ -5,6 +5,6 @@ # Christophe Leroy <[email protected]> # -obj-y += cmpc885.o +obj-y += cmpc885.o ../common/common.o obj-y += sdram.o obj-$(CONFIG_CMD_NAND) += nand.o
board/cssi/cmpc885/cmpc885.c +2 -52
68 lines not on this page · raw message
board/cssi/common/common.c new file +62 -0
62 lines not on this page · raw message
board/cssi/common/common.h new file +8 -0
@@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _BOARD_CSSI_COMMON_H +#define _BOARD_CSSI_COMMON_H + +void ft_cleanup (void *blob,unsigned long id,const char *prop,const char *compatible); + +#endif /* _BOARD_CSSI_COMMON_H */
Signature · 1 line
2.39.2
PATCH 14/14 board: cssi: Add CPU board CMPCPRO
In reply to Christophe LeroyCSSI has another CPU board, similar to the CMPC885 board that get plugged on the two base boards MCR3000_2G and MIAE.
That CPU board is called CMPCPRO because it has a MPC8321E CPU, also known as Power QUICC II PRO.
--- arch/powerpc/cpu/mpc83xx/Kconfig | 5 + arch/powerpc/dts/Makefile | 1 + arch/powerpc/dts/cmpcpro.dts | 189 +++++++++++++++ board/cssi/MAINTAINERS | 2 + board/cssi/cmpcpro/Kconfig | 26 ++ board/cssi/cmpcpro/Makefile | 8 + board/cssi/cmpcpro/cmpcpro.c | 404 +++++++++++++++++++++++++++++++ board/cssi/cmpcpro/cmpcpro.env | 8 + board/cssi/cmpcpro/nand.c | 43 ++++ configs/CMPCPRO_defconfig | 209 ++++++++++++++++ include/configs/cmpcpro.h | 99 ++++++++ 11 files changed, 994 insertions(+) create mode 100644 arch/powerpc/dts/cmpcpro.dts create mode 100644 board/cssi/cmpcpro/Kconfig create mode 100644 board/cssi/cmpcpro/Makefile create mode 100644 board/cssi/cmpcpro/cmpcpro.c create mode 100644 board/cssi/cmpcpro/cmpcpro.env create mode 100644 board/cssi/cmpcpro/nand.c create mode 100644 configs/CMPCPRO_defconfig create mode 100644 include/configs/cmpcpro.h
arch/powerpc/cpu/mpc83xx/Kconfig +5 -0
@@ -20,6 +20,10 @@ choice prompt "Target select" optional +config TARGET_CMPCPRO + bool "Support CMPCPRO board from CSSI" + select ARCH_MPC832X + config TARGET_MPC837XERDB bool "Support MPC837XERDB" select ARCH_MPC837X
@@ -205,5 +209,6 @@ config NEVER_ASSERT_ODT_TO_CPU source "board/freescale/mpc837xerdb/Kconfig" source "board/gdsys/mpc8308/Kconfig" +source "board/cssi/cmpcpro/Kconfig" endmenu
arch/powerpc/dts/Makefile +1 -0
@@ -30,6 +30,7 @@ dtb-$(CONFIG_TARGET_TUXX1) += kmtuxa1.dtb dtb-$(CONFIG_TARGET_MCR3000) += mcr3000.dtb dtb-$(CONFIG_TARGET_GAZERBEAM) += gazerbeam.dtb dtb-$(CONFIG_TARGET_CMPC885) += cmpc885.dtb +dtb-$(CONFIG_TARGET_CMPCPRO) += cmpcpro.dtb include $(srctree)/scripts/Makefile.dts
arch/powerpc/dts/cmpcpro.dts new file +189 -0
189 lines not on this page · raw message
board/cssi/MAINTAINERS +2 -0
@@ -6,3 +6,5 @@ F: include/configs/mcr3000.h F: configs/MCR3000_defconfig F: include/configs/cmpc885.h F: configs/CMPC885_defconfig +F: include/configs/cmpcpro.h +F: configs/CMPCPRO_defconfig
board/cssi/cmpcpro/Kconfig new file +26 -0
@@ -0,0 +1,26 @@ +if TARGET_CMPCPRO + +config SYS_BOARD + default "cmpcpro" + +config SYS_VENDOR + default "cssi" + +config SYS_CONFIG_NAME + default "cmpcpro" + +config TEXT_BASE + default 0x40000000 + +config CPLD_BASE + hex + default 0x90000000 + +config FPGA_BASE + hex + default 0x80000000 + +config PCI + default no + +endif
board/cssi/cmpcpro/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# (C) Copyright 2006 +# Wolfgang Denk, DENX Software Engineering, [email protected]. +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += cmpcpro.o nand.o ../common/common.o
board/cssi/cmpcpro/cmpcpro.c new file +404 -0
404 lines not on this page · raw message
board/cssi/cmpcpro/cmpcpro.env new file +8 -0
@@ -0,0 +1,8 @@ +loadaddr=0x1a00000 +filename=cmpcpro.itb +netdev=eth0 +console_args=console=ttyS0,115200N8 +loadkernel=ubi part nand0;ubifsmount ubi0; ubifsload ${loadaddr} /boot/${filename}; ubifsumount; ubi detach +flashboot=mw.w 90000040 0x000E 1; setenv bootargs ${console_args} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:eth0:off ${ofl_args}; run loadkernel; bootm $loadaddr#$config +tftpboot=mw.w 90000040 0x000E 1; setenv bootargs ${console_args} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:eth0:off ${ofl_args}; tftp ${loadaddr} ${filename}; bootm $loadaddr#$config +update=echo 'Updating ubi image'; mw.w 90000040 0x000E 1; if tftp $loadaddr $ubifile; then nand erase.chip; nand write $loadaddr 0x00 $filesize; fi;
board/cssi/cmpcpro/nand.c new file +43 -0
43 lines not on this page · raw message
configs/CMPCPRO_defconfig new file +209 -0
209 lines not on this page · raw message
include/configs/cmpcpro.h new file +99 -0
99 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH 12/14 board: cssi: Refactor EEPROM read
In reply to Christophe LeroyOn cmpc885 board, the ethernet addresses are stored in an EEPROM that is accessed through SPI.
A 3 bytes command is sent to the chip then the content gets read. At the time being a single block access is performed, ignoring the first 3 bytes read.
Reword the SPI transfer to first send 3 bytes then receive the content of the EEPROM so that there don't be 3 dummy bytes at the beginning of the buffer.
And move the function into common.c so that it can be reused by the board that will be added in a future patch.
--- board/cssi/cmpc885/cmpc885.c | 35 ++++------------------------------- board/cssi/common/common.c | 35 +++++++++++++++++++++++++++++++++++ board/cssi/common/common.h | 1 + 3 files changed, 40 insertions(+), 31 deletions(-)
board/cssi/cmpc885/cmpc885.c +4 -31
@@ -147,55 +147,28 @@ int checkboard(void)return 0 ; } -#define SPI_EEPROM_READ 0x03#define MAX_SPI_BYTES 0x20 -#define EE_OFF_MAC1 0x13 -#define EE_OFF_MAC2 0x19 +#define EE_OFF_MAC1 0x10 +#define EE_OFF_MAC2 0x16/* Reads MAC addresses from SPI EEPROM */ static int setup_mac (void ) { -struct udevice *eeprom; -struct spi_slave *slave; -char name[30 ], *str;uchar din[MAX_SPI_BYTES ]; -uchar dout[MAX_SPI_BYTES ] = {SPI_EEPROM_READ ,0 ,0 }; -int bitlen =256 , cs =0 , mode =0 , bus =0 , ret; +int ret;unsigned long ident =0x08005120 ; -snprintf (name,sizeof (name),"generic_%d:%d" , bus, cs); - - str =strdup (name); -if (!str) -return -1 ; - - ret =uclass_get_device (UCLASS_SPI ,0 , &eeprom); -if (ret) { -printf ("Could not enable Serial Peripheral Interface (SPI).\n" ); -return -1 ; - } - - ret =_spi_get_bus_and_cs (bus, cs,1000000 , mode,"spi_generic_drv" , str, &eeprom, &slave); + ret =read_eeprom (din,sizeof (din));if (ret)return ret; - ret =spi_claim_bus (slave); - - ret =spi_xfer (slave, bitlen, dout, din,SPI_XFER_BEGIN |SPI_XFER_END ); -if (ret) { -printf ("Error %d during SPI transaction\n" , ret); -return ret; - } -if (memcmp (din +EE_OFF_MAC1 , &ident,sizeof (ident)) ==0 )eth_env_set_enetaddr ("ethaddr" , din +EE_OFF_MAC1 );if (memcmp (din +EE_OFF_MAC2 , &ident,sizeof (ident)) ==0 )eth_env_set_enetaddr ("eth1addr" , din +EE_OFF_MAC2 ); -spi_release_bus (slave); -return 0 ; }
board/cssi/common/common.c +35 -0
@@ -8,7 +8,11 @@* Common specific routines for the CS Group boards */ +#include <dm.h> #include <fdt_support.h> +#include <spi.h> + +#define SPI_EEPROM_READ 0x03static int fdt_set_node_and_value (void *blob,char *node,const char *prop,void *var,int size)
@@ -60,3 +64,34 @@ void ft_cleanup(void *blob, unsigned long id, const char *prop, const char *compfdt_set_node_and_value (blob,"/" , prop, &id,sizeof (uint32_t )); } + +int read_eeprom (u8 *din,int len) +{ +struct udevice *eeprom; +struct spi_slave *slave; +uchar dout[3 ] = {SPI_EEPROM_READ ,0 ,0 }; +int ret; + + ret =uclass_get_device (UCLASS_SPI ,0 , &eeprom); +if (ret) +return ret; + + ret =_spi_get_bus_and_cs (0 ,0 ,1000000 ,0 ,"spi_generic_drv" , +"generic_0:0" , &eeprom, &slave); +if (ret) +return ret; + + ret =spi_claim_bus (slave); + + ret =spi_xfer (slave,sizeof (dout) <<3 , dout,NULL ,SPI_XFER_BEGIN ); +if (ret) +return ret; + + ret =spi_xfer (slave, len <<3 ,NULL , din,SPI_XFER_END ); +if (ret) +return ret; + +spi_release_bus (slave); + +return 0 ; +}
board/cssi/common/common.h +1 -0
@@ -4,5 +4,6 @@#define _BOARD_CSSI_COMMON_Hvoid ft_cleanup (void *blob,unsigned long id,const char *prop,const char *compatible); +int read_eeprom (u8 *din,int len);#endif /* _BOARD_CSSI_COMMON_H */
Signature · 1 line
2.39.2
PATCH 10/14 spi: mpc8xxx: Add support for SPI on mpc832x
In reply to Christophe LeroyOn mpc832x, SPI can be either handled by CPU or QE. In order to work in CPU mode, bit 17 of SPMODE has to be set to 1, that bit is called OP.
Also, data is located at a different place than the one expected by the driver today. In 8 bits mode with REV set, data to be transmitted is located in the most significant byte while received data is located in second byte. So perform the necessary shifts.
In order to differentiate with other CPUs, a new compatible is added for mpc832x: fsl,mpc832x-spi
--- arch/powerpc/include/asm/mpc8xxx_spi.h | 1 + drivers/spi/mpc8xxx_spi.c | 13 +++++++++++++ 2 files changed, 14 insertions(+)
arch/powerpc/include/asm/mpc8xxx_spi.h +1 -0
@@ -12,6 +12,7 @@#if defined(CONFIG_ARCH_MPC8308 ) || \ defined(CONFIG_ARCH_MPC8313 ) || \ + defined(CONFIG_ARCH_MPC832X ) || \ defined(CONFIG_ARCH_MPC834X ) || \ defined(CONFIG_ARCH_MPC837X )
drivers/spi/mpc8xxx_spi.c +13 -0
@@ -16,6 +16,7 @@#include <dm/device_compat.h> #include <linux/bitops.h> #include <linux/delay.h> +#include <asm/arch/soc.h> enum {SPI_EV_NE =BIT (31 -22 ),/* Receiver Not Empty */
@@ -30,6 +31,7 @@ enum {SPI_MODE_REV =BIT (31 -5 ),/* Reverse mode - MSB first */ SPI_MODE_MS =BIT (31 -6 ),/* Always master */ SPI_MODE_EN =BIT (31 -7 ),/* Enable interface */ +SPI_MODE_OP =BIT (31 -17 ),/* CPU Mode, QE otherwise */ SPI_MODE_LEN_MASK =0xf00000 , SPI_MODE_LEN_SHIFT = 20,
@@ -89,6 +91,9 @@ static int mpc8xxx_spi_probe(struct udevice *dev)*/ out_be32 (&priv->spi->mode,SPI_MODE_REV |SPI_MODE_MS ); +if (dev_get_driver_data (dev) ==SOC_MPC832X ) +setbits_be32 (&priv->spi->mode,SPI_MODE_OP ); +/* set len to 8 bits */ setbits_be32 (&spi->mode, (8 -1 ) <<SPI_MODE_LEN_SHIFT );
@@ -130,6 +135,7 @@ static int mpc8xxx_spi_xfer(struct udevice *dev, uint bitlen,u32 tmpdin =0 , tmpdout =0 , n;const u8 *cout = dout;u8 *cin = din; +ulong type =dev_get_driver_data (bus);debug ("%s: slave %s:%u dout %08X din %08X bitlen %u\n" , __func__, bus->name, plat->cs, (uint )dout, (uint )din, bitlen);
@@ -157,6 +163,9 @@ static int mpc8xxx_spi_xfer(struct udevice *dev, uint bitlen,if (cout) tmpdout = *cout++; +if (type ==SOC_MPC832X ) + tmpdout <<=24 ; +/* Write the data out */ out_be32 (&spi->tx, tmpdout);
@@ -179,6 +188,9 @@ static int mpc8xxx_spi_xfer(struct udevice *dev, uint bitlen, tmpdin =in_be32 (&spi->rx);setbits_be32 (&spi->event,SPI_EV_NE ); +if (type ==SOC_MPC832X ) + tmpdin >>=16 ; +if (cin) *cin++ = tmpdin;
@@ -271,6 +283,7 @@ static const struct dm_spi_ops mpc8xxx_spi_ops = {static const struct udevice_id mpc8xxx_spi_ids[] = { { .compatible ="fsl,spi" }, + { .compatible ="fsl,mpc832x-spi" , .data =SOC_MPC832X }, { } };
Signature · 1 line
2.39.2