add loongson mips ls1c300 initial support
A message that is not in the archive (sent off-list or not yet received): [email protected]
I'm not mips maintainer, so STOP sending me these emails, I'm not interested in them and I'm not going to read them.
Quoted 174 lines · On Wednesday 26 July 2023 00:46:10 Du Huanpeng wrote:
---
Changelog for v5:
- add detail commit message
- small fix in watchdog driverChangelog for v4:
- rebase to [247aa5a191159ea7e03bf1918e22fbbb784cd410]
- fix rebase issues
- use spl withoutSPL_DM
- fix some more codingstyle
- fix some more typo
- add comments about writing sdram controler
- keep .noreoder and do not use delay slotChangelog for v3:
- change cpu clock id fromCLK_CPUtoCLK_CPU_THROT
- migrate all APB dev's clock id toCLK_APB
- remove uarts' <reg-shift> property to use default value <0>
- move /clocks/acc node to /soc/acc
- callclk_request()before use a clk
- makeget_tbclk()return 1/2 clock of cpu
- disabledebug_uartby default
- add ops forcpu_throt_factorclk
- declareMSEC_PER_SECfor converting between sec and msec
- return a error code when the wdt clock is out of range
- minor format and codingstyle fixes
- rebase to [9859465bfe838bc8264d45e1a1bed847bba74bad]Changelog for v2:
1. dtsi:
add status disabled for uart0 ~ uart11
remove bootargs from chosen
make serial0 alias for uart2
oscillator remove @0 unit-address
change uart2 address to kuseg2. cleanup
Kconfigand update defconfig
- make these options configurable, disabled by default:
CMD_DM
DM_ETH
DM_GPIO
DM_SPI
DM_SPI_FLASH
DM_RESET
PINCONF
PINCTRL
PINMUX
RESET_LSMIPS
- make these options configurable, enabled by default:
CLK
DISPLAY_CPUINFO
SYSRESET
ROM_EXCEPTION_VECTORS
- disabled:
CONFIG_ENV_IS_IN_SPI_FLASH3. fix codingstyle
drivers/watchdog/lsmips-wdt.c
-priv->base+ offset
- add comment for default clock value4. remove address base definition header
- removearch/mips/mach-lsmips/ls1c300/ls1c300.h
- clean up files uses this header5. spl and debug uart
- add comment for spl & debug uart pinmuxing
- cleanup unused registers base header6. dtsi
- add "loongson,ls1c300-uart" to all uart node7. board dts
- add memory node to board dts, start at0x80000000, size 64MB8.
Kconfig
- makeROM_EXCEPTION_VECTORSuser configureable
- enableROM_EXCEPTION_VECTORSin defconfig9.
- seperatesdram_inittosdram_init.S
- add macro helpers to do sdram, pll lowlevel init10. dtsi
- move clock nodes to /clocks/xxx11.
- defineCONFIG_SKIP_LOWLEVEL_INITto 112.
- remove optionPINCTRL_LS1C300fromKconfig13.
-dram_init, useget_ram_size()to detect ram size.14. clk driver
- create custom clock ops for PLL
- remove debug code15.
- rebase to59bffec43a657598b194b9eb30dc01eec06078c7
- removeCONFIG_SYS_MONITOR_BASEfrominclude/configs/Du Huanpeng (6):
mips: initial build infrastructure for loongson SoCs
mips: ls1c300: add base support
mips: add a ls1c300 based board
mips: ls1c300: add clock driver
mips: ls1c300: add watchdog support
mips: ls1c300: add reset support based on watchdog driverMAINTAINERS | 15 ++ arch/mips/Kconfig | 11 ++ arch/mips/Makefile | 1 + arch/mips/dts/Makefile | 1 + arch/mips/dts/loongson32-ls1c300b.dtsi | 150 +++++++++++++++ arch/mips/dts/ls1c300-eval.dts | 30 +++ arch/mips/mach-lsmips/Kconfig | 76 ++++++++ arch/mips/mach-lsmips/Makefile | 6 + arch/mips/mach-lsmips/cpu.c | 19 ++ arch/mips/mach-lsmips/include/mach/serial.h | 16 ++ arch/mips/mach-lsmips/ls1c300/Makefile | 7 + arch/mips/mach-lsmips/ls1c300/gpio.c | 66 +++++++ arch/mips/mach-lsmips/ls1c300/init.c | 62 ++++++ arch/mips/mach-lsmips/ls1c300/lowlevel_init.S | 135 +++++++++++++ arch/mips/mach-lsmips/ls1c300/sdram.S | 96 ++++++++++ arch/mips/mach-lsmips/ls1c300/serial.c | 109 +++++++++++ arch/mips/mach-lsmips/spl.c | 47 +++++ board/loongson/ls1c300-eval/Kconfig | 12 ++ board/loongson/ls1c300-eval/MAINTAINERS | 7 + board/loongson/ls1c300-eval/Makefile | 3 + board/loongson/ls1c300-eval/board.c | 20 ++ configs/ls1c300_defconfig | 53 ++++++ drivers/clk/Makefile | 1 + drivers/clk/lsmips/Makefile | 3 + drivers/clk/lsmips/clk-ls1c300.c | 180 ++++++++++++++++++ drivers/reset/Kconfig | 7 + drivers/reset/Makefile | 1 + drivers/reset/reset-lsmips.c | 118 ++++++++++++ drivers/watchdog/Kconfig | 8 + drivers/watchdog/Makefile | 1 + drivers/watchdog/lsmips_wdt.c | 127 ++++++++++++ include/configs/ls1c300.h | 34 ++++ include/dt-bindings/clock/ls1c300-clk.h | 18 ++ include/dt-bindings/reset/ls1c300-reset.h | 36 ++++ 34 files changed, 1476 insertions(+) create mode 100644 arch/mips/dts/loongson32-ls1c300b.dtsi create mode 100644 arch/mips/dts/ls1c300-eval.dts create mode 100644 arch/mips/mach-lsmips/Kconfig create mode 100644 arch/mips/mach-lsmips/Makefile create mode 100644 arch/mips/mach-lsmips/cpu.c create mode 100644 arch/mips/mach-lsmips/include/mach/serial.h create mode 100644 arch/mips/mach-lsmips/ls1c300/Makefile create mode 100644 arch/mips/mach-lsmips/ls1c300/gpio.c create mode 100644 arch/mips/mach-lsmips/ls1c300/init.c create mode 100644 arch/mips/mach-lsmips/ls1c300/lowlevel_init.S create mode 100644 arch/mips/mach-lsmips/ls1c300/sdram.S create mode 100644 arch/mips/mach-lsmips/ls1c300/serial.c create mode 100644 arch/mips/mach-lsmips/spl.c create mode 100644 board/loongson/ls1c300-eval/Kconfig create mode 100644 board/loongson/ls1c300-eval/MAINTAINERS create mode 100644 board/loongson/ls1c300-eval/Makefile create mode 100644 board/loongson/ls1c300-eval/board.c create mode 100644 configs/ls1c300_defconfig create mode 100644 drivers/clk/lsmips/Makefile create mode 100644 drivers/clk/lsmips/clk-ls1c300.c create mode 100644 drivers/reset/reset-lsmips.c create mode 100644 drivers/watchdog/lsmips_wdt.c create mode 100644 include/configs/ls1c300.h create mode 100644 include/dt-bindings/clock/ls1c300-clk.h create mode 100644 include/dt-bindings/reset/ls1c300-reset.hSignature · 1 line
2.34.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Stefan Roese
Reviewed-byRe: [PATCH v5 5/6] mips: ls1c300: add watchdog support
Quoted 3 lines · Du Huanpeng
- watchdog driver for ls1c300 with devicetree support
Signed-off-by Du Huanpeng <[email protected]>
Thanks,
Stefan
Quoted 161 lines
--- drivers/watchdog/Kconfig | 8 +++ drivers/watchdog/Makefile | 1 + drivers/watchdog/lsmips_wdt.c | 127 ++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+)create mode 100644
drivers/watchdog/lsmips_wdt.cdrivers/watchdog/Kconfig +8
-0@@ -171,6 +171,14 @@ config WDT_GPIO doc/device-tree-bindings/watchdog/gpio-wdt.txt for information on how to describe the watchdog in device tree. +config WDT_LSMIPS + bool "Loongson MIPS watchdog timer support" + depends on WDT + help + Select this to enable watchdog timer for Loongson SoCs. + The watchdog timer is stopped when initialized. + It performs full SoC reset. + config WDT_MAX6370 bool "MAX6370 watchdog timer support" depends on WDTdrivers/watchdog/Makefile +1
-0@@ -30,6 +30,7 @@ obj-$(CONFIG_WDT_ORION) += orion_wdt.o obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o obj-$(CONFIG_WDT_FTWDT010) += ftwdt010_wdt.o obj-$(CONFIG_WDT_GPIO) += gpio_wdt.o +obj-$(CONFIG_WDT_LSMIPS) += lsmips_wdt.o obj-$(CONFIG_WDT_MAX6370) += max6370_wdt.o obj-$(CONFIG_WDT_MESON_GXBB) += meson_gxbb_wdt.o obj-$(CONFIG_WDT_MPC8xxx) += mpc8xxx_wdt.odrivers/watchdog/lsmips_wdt.c new file +117
-0@@ -0,0 +1,127 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Watchdog driver for MediaTek SoCs +* +* Copyright (C) 2018 MediaTek Inc. +* Author: Ryder Lee <[email protected]> +* +* based on: drivers/watchdog/mtk_wdt.c +* Copyright (C) 2020-2023 Du Huanpeng <[email protected]> +*/ + +#include <common.h> +#include <dm.h> +#include <hang.h> +#include <wdt.h> +#include <asm/io.h> +#include <clk.h> + + +struct lsmips_wdt_priv { +void __iomem *base; +#define WDT_EN 0 +#define WDT_TIMER 4 +#define WDT_SET 8 +ulong clock; +unsigned long timeout; +}; + +static int lsmips_wdt_reset (struct udevice *dev) +{ +struct lsmips_wdt_priv *priv =dev_get_priv (dev); + +writel (priv->timeout, priv->base +WDT_TIMER ); +writel (1 , priv->base +WDT_SET ); + +return 0 ; +} + +static int lsmips_wdt_stop (struct udevice *dev) +{ +struct lsmips_wdt_priv *priv =dev_get_priv (dev); + +writel (0 , priv->base +WDT_EN ); +return 0 ; +} + +static int lsmips_wdt_expire_now (struct udevice *dev,ulong flags) +{ +struct lsmips_wdt_priv *priv =dev_get_priv (dev); + +writel (1 , priv->base +WDT_EN ); +writel (1 , priv->base +WDT_TIMER ); +writel (1 , priv->base +WDT_SET ); + +hang (); +return 0 ; +} + +static int lsmips_wdt_start (struct udevice *dev,u64 timeout_ms,ulong flags) +{ +struct lsmips_wdt_priv *priv =dev_get_priv (dev); +unsigned int timeout; + + timeout =U32_MAX / (priv->clock /1000UL ); + +if (timeout < timeout_ms) + timeout =U32_MAX ; +else + timeout = timeout_ms * (priv->clock /MSEC_PER_SEC ); + +debug ("WDT: reload = %08x\n" , timeout); + +writel (1 , priv->base +WDT_EN ); +writel (timeout, priv->base +WDT_TIMER ); +writel (1 , priv->base +WDT_SET ); + + priv->timeout = timeout; + +return 0 ; +} + +static int lsmips_wdt_probe (struct udevice *dev) +{ +struct lsmips_wdt_priv *priv =dev_get_priv (dev); +struct clk cl; +ulong clock; + + priv->base =dev_remap_addr (dev); +if (!priv->base) +return -ENOENT ; + +if (clk_get_by_index (dev,0 , &cl) ==0 ) + clock =clk_get_rate (&cl); + +debug ("WDT: clock = %ld\n" , clock); + +if (IS_ERR_VALUE (clock)) { +dev_err (dev,"failed to get rate\n" ); +return clock; + } + + priv->clock = clock; +writel (0 , priv->base +WDT_EN ); +return 0 ; +} + +static const struct wdt_ops lsmips_wdt_ops = { + .start = lsmips_wdt_start, + .reset = lsmips_wdt_reset, + .stop = lsmips_wdt_stop, + .expire_now = lsmips_wdt_expire_now, +}; + +static const struct udevice_id lsmips_wdt_ids[] = { + { .compatible ="loongson,ls1c300-wdt" }, + {} +};
drivers/watchdog/lsmips_wdt.c line 127
Quoted 10 lines
drivers/watchdog/lsmips_wdt.c new file +10
-0+ +U_BOOT_DRIVER (lsmips_wdt) = { + .name ="lsmips_wdt" , + .id =UCLASS_WDT , + .of_match = lsmips_wdt_ids, + .priv_auto =sizeof (struct lsmips_wdt_priv ), + .probe = lsmips_wdt_probe, + .ops = &lsmips_wdt_ops, + .flags =DM_FLAG_PRE_RELOC , +};
Viele Grüße,
Stefan Roese
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]