mirror of
https://gitee.com/open-loongarch/u-boot.git
synced 2026-10-25 12:57:10 +08:00
update to cadd162f
1. support update dtb 2. support install rootfs from ramdisk 3. other fixs
This commit is contained in:
@@ -618,6 +618,15 @@
|
||||
status = "disable"
|
||||
};
|
||||
|
||||
// 必须是 watchdog_d 意味着 detect 用于长时间的任务检测
|
||||
wdt:watchdog_d{
|
||||
compatible = "loongson,ls2x-wdt";
|
||||
reg = <0 0x1fe27030 0 0xC>;
|
||||
clocks = <&apb_clk>;
|
||||
clock-names = "clk";
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
pcie@0 {
|
||||
compatible = "loongson,ls2k1000-pci";
|
||||
#interrupt-cells = <1>;
|
||||
|
||||
@@ -52,30 +52,6 @@
|
||||
eio_en_off=<27>;
|
||||
};
|
||||
|
||||
chosen {
|
||||
stdout-path = "serial0:115200n8";
|
||||
bootargs = "earlycon";
|
||||
};
|
||||
|
||||
memory {
|
||||
name = "memory";
|
||||
device_type = "memory";
|
||||
reg = <0x90000000 0x00000000 0 0x10000000
|
||||
0x90000000 0x90000000 0 0x10000000>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
reserved-memory {
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
ranges;
|
||||
|
||||
bootparam: bootparam_region {
|
||||
reg = <0x90000000 0x0f000000 0x0 0x1000000>;
|
||||
no-map;
|
||||
};
|
||||
};
|
||||
|
||||
clocks {
|
||||
compatible = "simple-bus";
|
||||
#address-cells = <1>;
|
||||
@@ -231,7 +207,7 @@
|
||||
status = "disabled";
|
||||
|
||||
};
|
||||
#if 0
|
||||
|
||||
gmac1: ethernet@0x16030000 {
|
||||
compatible = "snps,dwmac-3.70a", "snps,arc-dwmac-3.70a";
|
||||
reg = <0 0x16030000 0 0x10000>;
|
||||
@@ -247,7 +223,7 @@
|
||||
dma-mask = <0xffffffff 0xffffffff>;
|
||||
status = "disabled";
|
||||
};
|
||||
#endif
|
||||
|
||||
gpio:gpio@0x16104000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
@@ -267,7 +243,6 @@
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
spi0: spi@0x16010000 {
|
||||
compatible = "loongson,ls-spi";
|
||||
reg = <0 0x16010000 0 0x40000>;
|
||||
@@ -279,7 +254,6 @@
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
#if 0
|
||||
spi1: spi@0x16018000 {
|
||||
compatible = "loongson,ls-spi";
|
||||
reg = <0 0x16018000 0 0x40000>;
|
||||
@@ -299,8 +273,6 @@
|
||||
interrupts = <14>;
|
||||
clock-frequency = <400000>;
|
||||
reg-shift = <0>;
|
||||
clocks = <&apb_clk>;
|
||||
clock-names = "scl";
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
@@ -336,7 +308,7 @@
|
||||
clock-frequency = <400000>;
|
||||
status = "disabled";
|
||||
};
|
||||
#endif
|
||||
|
||||
emmc0: emmc@0x16140000 {
|
||||
compatible = "loongson,ls-mmc";
|
||||
reg = <0 0x16140000 0 0x8000>;
|
||||
@@ -375,5 +347,14 @@
|
||||
dma-mask = <0x0 0xffffffff>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
// 必须是 watchdog_d 意味着 detect 用于长时间的任务检测
|
||||
wdt:watchdog_d{
|
||||
compatible = "loongson,ls2x-wdt";
|
||||
reg = <0 0x16124000 0 0xC>;
|
||||
clocks = <&apb_clk>;
|
||||
clock-names = "clk";
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/ {
|
||||
memory {
|
||||
name = "memory";
|
||||
device_type = "memory";
|
||||
reg = <0x90000000 0x00000000 0 0x10000000
|
||||
0x90000000 0x90000000 0 0x30000000>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
// MD4C1001G
|
||||
mc0: ram@0 {
|
||||
compatible = "loongson,ls2k0300-ddr";
|
||||
u-boot,dm-pre-reloc;
|
||||
|
||||
soc-config-reg = <0x1fe10100>;
|
||||
mc-disable-offs = <4>;
|
||||
mc-default-offs = <5>;
|
||||
|
||||
sdram-type = "ddr4"; // ddr4
|
||||
dimm-type = "udimm"; // rdimm/udimm/sodimm
|
||||
|
||||
cs-map = <0x1>; // bit map: bit0 -- cs0
|
||||
// bit1 -- cs1
|
||||
// bit2 -- cs2
|
||||
// bit3 -- cs3
|
||||
|
||||
data-width = <16>; // 8/16
|
||||
sdram-width = <16>; // 8/16
|
||||
sdram-banks = <4>; // 4/8
|
||||
sdram-bank-groups = <2>; // 0/2/4
|
||||
sdram-rows = <16>;
|
||||
sdram-cols = <10>;
|
||||
|
||||
// clk-latency = <0x30>; //
|
||||
// rd-latency = <0x9>; //
|
||||
// wr-latency = <0x4>; //
|
||||
mc-dqs-odt = <0x8>; //
|
||||
cmd-timing-mode = <1>; // 0: 1T mode; 1(default): 2T mode; 2: 3T mode.
|
||||
|
||||
// To enable the feature below, uncomment it.
|
||||
ddr-param-store;
|
||||
// early-printf;
|
||||
/* addr-mirror; */
|
||||
/* reset-revert; */
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
/ {
|
||||
memory {
|
||||
name = "memory";
|
||||
device_type = "memory";
|
||||
reg = <0x90000000 0x00000000 0 0x10000000
|
||||
0x90000000 0x90000000 0 0x70000000>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
// MD4C1002G
|
||||
mc0: ram@0 {
|
||||
compatible = "loongson,ls2k0300-ddr";
|
||||
u-boot,dm-pre-reloc;
|
||||
|
||||
soc-config-reg = <0x1fe10100>;
|
||||
mc-disable-offs = <4>;
|
||||
mc-default-offs = <5>;
|
||||
|
||||
sdram-type = "ddr4"; // ddr4
|
||||
dimm-type = "udimm"; // rdimm/udimm/sodimm
|
||||
|
||||
cs-map = <0x1>; // bit map: bit0 -- cs0
|
||||
// bit1 -- cs1
|
||||
// bit2 -- cs2
|
||||
// bit3 -- cs3
|
||||
|
||||
data-width = <16>; // 8/16
|
||||
sdram-width = <16>; // 8/16
|
||||
sdram-banks = <4>; // 4/8
|
||||
sdram-bank-groups = <2>; // 0/2/4
|
||||
sdram-rows = <17>;
|
||||
sdram-cols = <10>;
|
||||
|
||||
// clk-latency = <0x30>; //
|
||||
// rd-latency = <0x9>; //
|
||||
// wr-latency = <0x4>; //
|
||||
mc-dqs-odt = <0x8>; //
|
||||
cmd-timing-mode = <1>; // 0: 1T mode; 1(default): 2T mode; 2: 3T mode.
|
||||
|
||||
// To enable the feature below, uncomment it.
|
||||
ddr-param-store;
|
||||
// early-printf;
|
||||
/* addr-mirror; */
|
||||
/* reset-revert; */
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
/ {
|
||||
memory {
|
||||
name = "memory";
|
||||
device_type = "memory";
|
||||
reg = <0x90000000 0x00000000 0 0x10000000
|
||||
0x90000000 0x90000000 0 0x10000000>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
mc0: ram@0 {
|
||||
compatible = "loongson,ls2k0300-ddr";
|
||||
u-boot,dm-pre-reloc;
|
||||
|
||||
soc-config-reg = <0x1fe10100>;
|
||||
mc-disable-offs = <4>;
|
||||
mc-default-offs = <5>;
|
||||
|
||||
sdram-type = "ddr4"; // ddr4
|
||||
dimm-type = "udimm"; // rdimm/udimm/sodimm
|
||||
|
||||
cs-map = <0x1>; // bit map: bit0 -- cs0
|
||||
// bit1 -- cs1
|
||||
// bit2 -- cs2
|
||||
// bit3 -- cs3
|
||||
|
||||
data-width = <16>; // 8/16
|
||||
sdram-width = <16>; // 8/16
|
||||
sdram-banks = <4>; // 4/8
|
||||
sdram-bank-groups = <2>; // 0/2/4
|
||||
sdram-rows = <15>;
|
||||
sdram-cols = <10>;
|
||||
|
||||
// clk-latency = <0x30>; //
|
||||
// rd-latency = <0x9>; //
|
||||
// wr-latency = <0x4>; //
|
||||
mc-dqs-odt = <0x8>; //
|
||||
cmd-timing-mode = <1>; // 0: 1T mode; 1(default): 2T mode; 2: 3T mode.
|
||||
|
||||
// To enable the feature below, uncomment it.
|
||||
ddr-param-store;
|
||||
// early-printf;
|
||||
/* addr-mirror; */
|
||||
/* reset-revert; */
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
/ {
|
||||
memory {
|
||||
name = "memory";
|
||||
device_type = "memory";
|
||||
reg = <0x90000000 0x00000000 0 0x10000000
|
||||
0x90000000 0x90000000 0 0x30000000>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
// SNC1216S26SS12
|
||||
mc0: ram@0 {
|
||||
compatible = "loongson,ls2k0300-ddr";
|
||||
u-boot,dm-pre-reloc;
|
||||
|
||||
soc-config-reg = <0x1fe10100>;
|
||||
mc-disable-offs = <4>;
|
||||
mc-default-offs = <5>;
|
||||
|
||||
sdram-type = "ddr4"; // ddr4
|
||||
dimm-type = "udimm"; // rdimm/udimm/sodimm
|
||||
|
||||
cs-map = <0x1>; // bit map: bit0 -- cs0
|
||||
// bit1 -- cs1
|
||||
// bit2 -- cs2
|
||||
// bit3 -- cs3
|
||||
|
||||
data-width = <16>; // 8/16
|
||||
sdram-width = <16>; // 8/16
|
||||
sdram-banks = <4>; // 4/8
|
||||
sdram-bank-groups = <2>; // 0/2/4
|
||||
sdram-rows = <16>;
|
||||
sdram-cols = <10>;
|
||||
|
||||
// clk-latency = <0x30>; //
|
||||
// rd-latency = <0x9>; //
|
||||
// wr-latency = <0x4>; //
|
||||
mc-dqs-odt = <0x8>; //
|
||||
cmd-timing-mode = <1>; // 0: 1T mode; 1(default): 2T mode; 2: 3T mode.
|
||||
|
||||
// To enable the feature below, uncomment it.
|
||||
ddr-param-store;
|
||||
// early-printf;
|
||||
/* addr-mirror; */
|
||||
/* reset-revert; */
|
||||
};
|
||||
};
|
||||
@@ -1,42 +1,34 @@
|
||||
#include "ls2k300.dtsi"
|
||||
|
||||
#if defined(CONFIG_LOONGSON_DDR4_ISOCOM_2G)
|
||||
#include "ls2k300_ddr_isocom_2g.dtsi"
|
||||
#elif defined(CONFIG_LOONGSON_DDR4_ISOCOM_1G)
|
||||
#include "ls2k300_ddr_isocom_1g.dtsi"
|
||||
#elif defined(CONFIG_LOONGSON_DDR4_SINKER_1G)
|
||||
#include "ls2k300_ddr_sinker_1g.dtsi"
|
||||
#else
|
||||
#include "ls2k300_ddr_samsung_512m.dtsi"
|
||||
#endif
|
||||
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
|
||||
/ {
|
||||
mc0: ram@0 {
|
||||
compatible = "loongson,ls2k0300-ddr";
|
||||
u-boot,dm-pre-reloc;
|
||||
|
||||
soc-config-reg = <0x1fe10100>;
|
||||
mc-disable-offs = <4>;
|
||||
mc-default-offs = <5>;
|
||||
|
||||
sdram-type = "ddr4"; // ddr4
|
||||
dimm-type = "udimm"; // rdimm/udimm/sodimm
|
||||
|
||||
cs-map = <0x1>; // bit map: bit0 -- cs0
|
||||
// bit1 -- cs1
|
||||
// bit2 -- cs2
|
||||
// bit3 -- cs3
|
||||
|
||||
data-width = <16>; // 8/16
|
||||
sdram-width = <16>; // 8/16
|
||||
sdram-banks = <4>; // 4/8
|
||||
sdram-bank-groups = <2>; // 0/2/4
|
||||
sdram-rows = <15>;
|
||||
sdram-cols = <10>;
|
||||
|
||||
// clk-latency = <0x30>; //
|
||||
// rd-latency = <0x9>; //
|
||||
// wr-latency = <0x4>; //
|
||||
mc-dqs-odt = <0x8>; //
|
||||
cmd-timing-mode = <1>; // 0: 1T mode; 1(default): 2T mode; 2: 3T mode.
|
||||
|
||||
// To enable the feature below, uncomment it.
|
||||
ddr-param-store;
|
||||
// early-printf;
|
||||
/* addr-mirror; */
|
||||
/* reset-revert; */
|
||||
chosen {
|
||||
stdout-path = "serial0:115200n8";
|
||||
bootargs = "earlycon";
|
||||
};
|
||||
|
||||
reserved-memory {
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
ranges;
|
||||
|
||||
bootparam: bootparam_region {
|
||||
reg = <0x90000000 0x0f000000 0x0 0x1000000>;
|
||||
no-map;
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
&spi0 {
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
backlight = <&panel_bkl>;
|
||||
|
||||
display-timings {
|
||||
#if 1 // 4.3' LCD
|
||||
#if 0 // 4.3' LCD
|
||||
native-mode = <&atk_md0430r>;
|
||||
|
||||
atk_md0430r: 800x480 {
|
||||
|
||||
@@ -1,44 +1,25 @@
|
||||
#include "ls2k300.dtsi"
|
||||
#include "ls2k300_ddr_samsung_512m.dtsi"
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
#include <dt-bindings/power-domain/ls2k500-power-domain.h>
|
||||
|
||||
/ {
|
||||
model = "loongson-2k300";
|
||||
|
||||
mc0: ram@0 {
|
||||
compatible = "loongson,ls2k0300-ddr";
|
||||
u-boot,dm-pre-reloc;
|
||||
chosen {
|
||||
stdout-path = "serial0:115200n8";
|
||||
bootargs = "earlycon";
|
||||
};
|
||||
|
||||
soc-config-reg = <0x1fe10100>;
|
||||
mc-disable-offs = <4>;
|
||||
mc-default-offs = <5>;
|
||||
reserved-memory {
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
ranges;
|
||||
|
||||
sdram-type = "ddr4"; // ddr4
|
||||
dimm-type = "udimm"; // rdimm/udimm/sodimm
|
||||
|
||||
cs-map = <0x1>; // bit map: bit0 -- cs0
|
||||
// bit1 -- cs1
|
||||
// bit2 -- cs2
|
||||
// bit3 -- cs3
|
||||
|
||||
data-width = <16>; // 8/16
|
||||
sdram-width = <16>; // 8/16
|
||||
sdram-banks = <4>; // 4/8
|
||||
sdram-bank-groups = <2>; // 0/2/4
|
||||
sdram-rows = <15>;
|
||||
sdram-cols = <10>;
|
||||
|
||||
// clk-latency = <0x30>; //
|
||||
// rd-latency = <0x9>; //
|
||||
// wr-latency = <0x4>; //
|
||||
mc-dqs-odt = <0x8>; //
|
||||
cmd-timing-mode = <1>; // 0: 1T mode; 1(default): 2T mode; 2: 3T mode.
|
||||
|
||||
// To enable the feature below, uncomment it.
|
||||
// ddr-param-store;
|
||||
// early-printf;
|
||||
/* addr-mirror; */
|
||||
/* reset-revert; */
|
||||
bootparam: bootparam_region {
|
||||
reg = <0x90000000 0x0f000000 0x0 0x1000000>;
|
||||
no-map;
|
||||
};
|
||||
};
|
||||
|
||||
sysinfo-smbios {
|
||||
@@ -68,7 +49,7 @@
|
||||
backlight = <&panel_bkl>;
|
||||
|
||||
display-timings {
|
||||
#if 1 // 4.3' LCD
|
||||
#if 0 // 4.3' LCD
|
||||
native-mode = <&atk_md0430r>;
|
||||
|
||||
atk_md0430r: 800x480 {
|
||||
|
||||
@@ -35,24 +35,6 @@
|
||||
|
||||
};
|
||||
|
||||
cpuic: interrupt-controller {
|
||||
compatible = "loongson,cpu-interrupt-controller";
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <1>;
|
||||
};
|
||||
|
||||
extioiic: interrupt-controller@0x14001600 {
|
||||
compatible = "loongson,extioi-interrupt-controller";
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <1>;
|
||||
interrupt-parent = <&cpuic>;
|
||||
interrupts = <3>;
|
||||
interrupt-names = "cascade";
|
||||
vec_count=<128>;
|
||||
misc_func=<0x100>;
|
||||
eio_en_off=<15>;
|
||||
};
|
||||
|
||||
clocks {
|
||||
compatible = "simple-bus";
|
||||
#address-cells = <1>;
|
||||
@@ -138,7 +120,7 @@
|
||||
};
|
||||
|
||||
gmac1_pins: pinmux_gmac1_pins {
|
||||
pinctrl-single,bits = <0x8 0x00ffffff 0x00ffffff>;
|
||||
pinctrl-single,bits = <0x8 0x00aaaaaa 0x00ffffff>;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -207,8 +189,6 @@
|
||||
compatible = "ns16550a";
|
||||
reg = <0 0x14200000 0 0x10>;
|
||||
clocks = <&apb_clk>;
|
||||
interrupt-parent = <&extioiic>;
|
||||
interrupts = <0>;
|
||||
// pinctrl-0 = <&uart0>;
|
||||
// pinctrl-names = "default";
|
||||
no-loopback-test;
|
||||
@@ -240,29 +220,13 @@
|
||||
gmac0: ethernet@14140000 {
|
||||
compatible = "snps,dwmac-3.70a", "snps,arc-dwmac-3.70a";
|
||||
reg = <0 0x14140000 0 0x10000>;
|
||||
interrupt-parent = <&extioiic>;
|
||||
interrupts = <118>;
|
||||
interrupt-names = "macirq";
|
||||
// mac-address = [ 64 48 48 48 48 60 ];/* [>mac 64:48:48:48:48:60 <]*/
|
||||
phy-mode = "rgmii";
|
||||
bus_id = <0x0>;
|
||||
phy_addr = <0xffffffff>;
|
||||
phy-handle = <ð_phy0>;
|
||||
dma-mask = <0xffffffff 0xffffffff>;
|
||||
// snps,pbl = <2>;
|
||||
// snps,fixed-burst;
|
||||
// snps,force_sf_dma_mode;
|
||||
status = "disabled";
|
||||
|
||||
mdio0: mdio@0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "snps,dwmac-mdio";
|
||||
|
||||
eth_phy0: ethernet-phy@0 {
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
gmac1: ethernet@14020000 {
|
||||
@@ -270,26 +234,13 @@
|
||||
reg = <0 0x14020000 0 0x10000>;
|
||||
pinctrl-0 = <&gmac1_pins>;
|
||||
pinctrl-names = "default";
|
||||
interrupt-parent = <&extioiic>;
|
||||
interrupts = <119>;
|
||||
interrupt-names = "macirq";
|
||||
// mac-address = [ 64 48 48 48 48 61 ];/* [>mac 64:48:48:48:48:61 <]*/
|
||||
phy-mode = "rgmii-id";
|
||||
bus_id = <0x1>;
|
||||
phy_addr = <0xffffffff>;
|
||||
phy-handle = <ð_phy1>;
|
||||
dma-mask = <0xffffffff 0xffffffff>;
|
||||
// snps,pbl = <2>;
|
||||
// snps,fixed-burst;
|
||||
// snps,force_sf_dma_mode;
|
||||
status = "disabled";
|
||||
|
||||
mdio1: mdio@1 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "snps,dwmac-mdio";
|
||||
|
||||
eth_phy1: ethernet-phy@1 {
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
gpio@14202000 {
|
||||
@@ -399,8 +350,6 @@
|
||||
#size-cells = <0>;
|
||||
pinctrl-0 = <&i2c0_pins>;
|
||||
pinctrl-names = "default";
|
||||
interrupt-parent = <&extioiic>;
|
||||
interrupts = <14>;
|
||||
clock-frequency = <400000>;
|
||||
reg-shift = <0>;
|
||||
clocks = <&apb_clk>;
|
||||
@@ -413,8 +362,6 @@
|
||||
reg = <0 0x14201800 0 0x0800>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
interrupt-parent = <&extioiic>;
|
||||
interrupts = <15>;
|
||||
clock-frequency = <400000>;
|
||||
status = "disabled";
|
||||
};
|
||||
@@ -424,8 +371,6 @@
|
||||
reg = <0 0x15101000 0 0x0800>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
interrupt-parent = <&extioiic>;
|
||||
interrupts = <16>;
|
||||
clock-frequency = <400000>;
|
||||
status = "disabled";
|
||||
};
|
||||
@@ -435,8 +380,6 @@
|
||||
reg = <0 0x15101800 0 0x0800>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
interrupt-parent = <&extioiic>;
|
||||
interrupts = <17>;
|
||||
clock-frequency = <400000>;
|
||||
status = "disabled";
|
||||
};
|
||||
@@ -452,8 +395,8 @@
|
||||
};
|
||||
|
||||
sdio1: mmc@14218000 {
|
||||
compatible = "loongson,ls1x-mmc";
|
||||
reg = <0 0x14218000 0 0x2000>;
|
||||
compatible = "loongson,ls-mmc";
|
||||
reg = <0 0x14218000 0 0x8000>;
|
||||
pinctrl-0 = <&sdio1_pins>;
|
||||
pinctrl-names = "default";
|
||||
cap-sd-highspeed;
|
||||
@@ -473,6 +416,13 @@
|
||||
dma-mask = <0x0 0xffffffff>;
|
||||
};
|
||||
|
||||
otg: otg@0x14100000 {
|
||||
compatible = "snps,dwc2";
|
||||
reg = <0 0x14100000 0 0x40000>;
|
||||
dma-mask = <0x0 0xffffffff>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
usb2_phy: usb2phy@xhci {
|
||||
compatible = "usb-dummy-phy";
|
||||
};
|
||||
|
||||
@@ -109,12 +109,34 @@
|
||||
|
||||
&gmac0 {
|
||||
status = "okay";
|
||||
phy-mode = "rgmii-txid";
|
||||
phy-mode = "rgmii";
|
||||
phy-handle = <ð_phy0>;
|
||||
|
||||
mdio0: mdio@0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "snps,dwmac-mdio";
|
||||
|
||||
eth_phy0: ethernet-phy@0 {
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&gmac1 {
|
||||
status = "okay";
|
||||
phy-mode = "rgmii-txid";
|
||||
phy-mode = "rgmii";
|
||||
phy-handle = <ð_phy1>;
|
||||
|
||||
mdio1: mdio@1 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "snps,dwmac-mdio";
|
||||
|
||||
eth_phy1: ethernet-phy@0 {
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&emmc0 {
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
#include "ls2p500_g2p05z0_v10.dtsi"
|
||||
|
||||
/ {
|
||||
sysinfo-smbios {
|
||||
compatible = "u-boot,sysinfo-smbios";
|
||||
u-boot,dm-pre-reloc;
|
||||
|
||||
smbios {
|
||||
system {
|
||||
manufacturer = "Loongson";
|
||||
product = "LS2P500";
|
||||
};
|
||||
|
||||
baseboard {
|
||||
manufacturer = "Loongson";
|
||||
product = "LS2P500-GBKPJM0";
|
||||
};
|
||||
|
||||
chassis {
|
||||
manufacturer = "Loongson";
|
||||
product = "LS2P500-GBKPJM0";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&gmac0 {
|
||||
status = "okay";
|
||||
phy-mode = "rgmii";
|
||||
phy-handle = <ð_phy0>;
|
||||
|
||||
mdio0: mdio@0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "snps,dwmac-mdio";
|
||||
|
||||
eth_phy0: ethernet-phy@0 {
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&gmac1 {
|
||||
status = "okay";
|
||||
phy-mode = "rgmii";
|
||||
phy-handle = <ð_phy1>;
|
||||
|
||||
mdio1: mdio@1 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "snps,dwmac-mdio";
|
||||
|
||||
eth_phy1: ethernet-phy@0 {
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&sdio1 {
|
||||
status = "okay";
|
||||
use-sdcard;
|
||||
};
|
||||
|
||||
&otg {
|
||||
status = "okay";
|
||||
// force host mode
|
||||
hnp-srp-disable;
|
||||
};
|
||||
|
||||
&pwrc {
|
||||
domain-node {
|
||||
bit = <0>;
|
||||
clock-gate-la364 {
|
||||
bit = <0>;
|
||||
};
|
||||
clock-gate-iodma {
|
||||
bit = <1>;
|
||||
};
|
||||
};
|
||||
domain-ddr {
|
||||
bit = <2>;
|
||||
clock-gate-ddriso {
|
||||
bit = <20>;
|
||||
};
|
||||
clock-gate-ddrrst {
|
||||
bit = <21>;
|
||||
};
|
||||
clock-gate-ddr {
|
||||
bit = <22>;
|
||||
};
|
||||
};
|
||||
domain-print {
|
||||
bit = <4>;
|
||||
always-on;
|
||||
clock-gate-prtla132 {
|
||||
bit = <2>;
|
||||
clock-gate-off;
|
||||
};
|
||||
clock-gate-prtl1xbar {
|
||||
bit = <3>;
|
||||
};
|
||||
};
|
||||
domain-scan {
|
||||
bit = <6>;
|
||||
clock-gate-scala132 {
|
||||
bit = <4>;
|
||||
clock-gate-off;
|
||||
};
|
||||
clock-gate-scadev {
|
||||
bit = <5>;
|
||||
};
|
||||
};
|
||||
domain-sys {
|
||||
bit = <8>;
|
||||
clock-gate-boot {
|
||||
bit = <8>;
|
||||
};
|
||||
clock-gate-gmac1 {
|
||||
bit = <9>;
|
||||
};
|
||||
clock-gate-usb {
|
||||
bit = <10>;
|
||||
};
|
||||
clock-gate-sdio {
|
||||
bit = <11>;
|
||||
};
|
||||
clock-gate-apbdev {
|
||||
bit = <12>;
|
||||
};
|
||||
};
|
||||
domain-resume {
|
||||
bit = <10>;
|
||||
always-on;
|
||||
clock-gate-gmac0 {
|
||||
bit = <16>;
|
||||
};
|
||||
clock-gate-otg {
|
||||
bit = <17>;
|
||||
};
|
||||
};
|
||||
domain-image {
|
||||
bit = <12>;
|
||||
dpm-off;
|
||||
clock-gate-jbig {
|
||||
bit = <18>;
|
||||
};
|
||||
clock-gate-jpeg {
|
||||
bit = <19>;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -175,4 +175,23 @@ config CPU_FREQ
|
||||
|
||||
source "board/loongson/Kconfig"
|
||||
|
||||
choice
|
||||
prompt "DDR4 SDRAM Select"
|
||||
depends on TARGET_LS2K300_MINI_DP
|
||||
default LOONGSON_DDR4_DEFAULT
|
||||
|
||||
config LOONGSON_DDR4_DEFAULT
|
||||
bool "Samsung K4A4G165xx(Default)"
|
||||
|
||||
config LOONGSON_DDR4_SINKER_1G
|
||||
bool "Sinker SNC1216S26SS12"
|
||||
|
||||
config LOONGSON_DDR4_ISOCOM_1G
|
||||
bool "Isocom MD4C1001G"
|
||||
|
||||
config LOONGSON_DDR4_ISOCOM_2G
|
||||
bool "Isocom MD4C1002G"
|
||||
|
||||
endchoice
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -45,4 +45,14 @@ config LOONGSON_GENERAL_LOAD
|
||||
default n
|
||||
select CMD_UNZIP
|
||||
|
||||
config LOONGSON_BOARD_SATA_FS
|
||||
bool "board have sata fs"
|
||||
default n
|
||||
select CMD_UNZIP
|
||||
|
||||
config LOONGSON_BOARD_MMC_FS
|
||||
bool "board have mmc(such as emmc or SD card) fs"
|
||||
default n
|
||||
select CMD_UNZIP
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -18,7 +18,10 @@ obj-y += loongson_boot.o
|
||||
obj-y += loongson_env_trigger.o
|
||||
obj-y += loongson_init_env.o
|
||||
obj-y += loongson_stdout_operation.o
|
||||
obj-y += loongson_boot_syspart_manager.o
|
||||
obj-y += loongson_wdt_setup.o
|
||||
obj-$(CONFIG_LOONGSON_GENERAL_LOAD) += general_load/
|
||||
obj-$(CONFIG_LOONGSON_GENERAL_LOAD) += loongson_img_fdisk.o
|
||||
|
||||
ifeq ($(CONFIG_MENU), y)
|
||||
obj-$(CONFIG_MACH_LOONGSON) += loongson_update_menu.o
|
||||
|
||||
@@ -3,8 +3,32 @@
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <stdlib.h>
|
||||
#include <blk.h>
|
||||
#include "cmd_gl_arg.h"
|
||||
#include "general_load.h"
|
||||
#include "../loongson_boot_syspart_manager.h"
|
||||
#include "../loongson_img_fdisk.h"
|
||||
|
||||
static void try_to_read_fdisk(gl_target_t* src)
|
||||
{
|
||||
int type;
|
||||
struct blk_desc* desc;
|
||||
if (!src)
|
||||
return;
|
||||
|
||||
type = gl_target_get_type(src);
|
||||
if (type == GL_DEVICE_NET)
|
||||
loongson_try_read_img_fdisk("tftp");
|
||||
else if (type == GL_DEVICE_BLK) {
|
||||
desc = gl_target_get_desc(src);
|
||||
if (!desc)
|
||||
return;
|
||||
if (desc->if_type == IF_TYPE_MMC)
|
||||
loongson_try_read_img_fdisk("mmc");
|
||||
else if (desc->if_type == IF_TYPE_USB)
|
||||
loongson_try_read_img_fdisk("usb");
|
||||
}
|
||||
}
|
||||
|
||||
// [--from xxx [--fs xxx]] [--to xxx [--fs xxx]]
|
||||
static int do_general_load(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
|
||||
@@ -13,6 +37,7 @@ static int do_general_load(struct cmd_tbl *cmdtp, int flag, int argc, char * con
|
||||
gl_target_t* src;
|
||||
gl_target_t* dest;
|
||||
enum gl_extra_e extra = GL_EXTRA_NONE;
|
||||
int update_rootfs_target;
|
||||
|
||||
if(argc == 1)
|
||||
goto end;
|
||||
@@ -30,6 +55,21 @@ static int do_general_load(struct cmd_tbl *cmdtp, int flag, int argc, char * con
|
||||
|
||||
ret = general_load(src, dest, extra);
|
||||
|
||||
if (!ret) {
|
||||
update_rootfs_target = 0;
|
||||
if (!strncmp(src->get_symbol(src), "rootfs", strlen("rootfs")))
|
||||
update_rootfs_target = 1;
|
||||
if (!strncmp(src->get_symbol(src), "/update/rootfs", strlen("/update/rootfs")))
|
||||
update_rootfs_target = 1;
|
||||
|
||||
if (update_rootfs_target) {
|
||||
print_enable_setup(0);
|
||||
setup_cur_syspart(SYSPART_FIRST);
|
||||
print_enable_setup(1);
|
||||
try_to_read_fdisk(src);
|
||||
}
|
||||
}
|
||||
|
||||
free_targets:
|
||||
destroy_gl_target(dest);
|
||||
free_src:
|
||||
|
||||
@@ -18,7 +18,7 @@ const static struct cmd_gl_default_s __default =
|
||||
.blk_prefix = "/update/",
|
||||
.boot_device = "flash0:1",
|
||||
.root_device = "mmc0",
|
||||
.kernel_device = "mmc0",
|
||||
.kernel_device = "mmc0:1",
|
||||
.kernel_fstype = "ext4",
|
||||
.kernel_prefix = "/boot/",
|
||||
}
|
||||
@@ -28,7 +28,7 @@ const static struct cmd_gl_default_s __default =
|
||||
.blk_prefix = "/update/",
|
||||
.boot_device = "flash0:1",
|
||||
.root_device = "scsi0",
|
||||
.kernel_device = "scsi0",
|
||||
.kernel_device = "scsi0:1",
|
||||
.kernel_fstype = "ext4",
|
||||
.kernel_prefix = "/boot/",
|
||||
}
|
||||
|
||||
@@ -6,7 +6,18 @@ static int m__net_gl_read(struct net_gl_desc* self, int proto,
|
||||
{
|
||||
int ret;
|
||||
|
||||
// netretry yes 本身是做为双网口切换准备的,通常情况下没有问题
|
||||
// 因为操作者知道自已的网络设备上是否存在需要的文件或者能够检查网口情况
|
||||
// 然而在2K300上竟然有操作者不一定知道的文件需要存在
|
||||
// 就是 loongson_try_read_img_fdisk 中需要 fdisk.txt,这个过程是对操作者隐匿的
|
||||
// 好在目前只有2K300用 disk.img 模式,暂时需要这样规避
|
||||
// 对于其他所有使用 disk.img 的情况,务必、务必修改整体设计结构!
|
||||
// 禁止存在对操作者隐匿的条件
|
||||
#ifdef CONFIG_SOC_LS2K300
|
||||
env_set("netretry", "no");
|
||||
#else
|
||||
env_set("netretry", "yes");
|
||||
#endif
|
||||
env_set("ethrotate", "yes");
|
||||
|
||||
copy_filename(net_boot_file_name, filepath,
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
#include <stdio.h>
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <malloc.h>
|
||||
#include "bdinfo/bdinfo.h"
|
||||
#include "loongson_boot_syspart_manager.h"
|
||||
|
||||
static int setup_syspart_uboot_env(char* syspart)
|
||||
{
|
||||
if (!syspart)
|
||||
return -1;
|
||||
env_set(SYSPART_FIRST_UBOOT_ENV_NAME, syspart);
|
||||
|
||||
if (!strcmp(syspart, SYSPART_FIRST))
|
||||
env_set(SYSPART_SECOND_UBOOT_ENV_NAME, SYSPART_SECOND);
|
||||
else
|
||||
env_set(SYSPART_SECOND_UBOOT_ENV_NAME, SYSPART_FIRST);
|
||||
|
||||
env_set(SYSPART_USER_CH_UBOOT_ENV_NAME, "0");
|
||||
|
||||
env_save();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int setup_syspart_nvme_env(char* syspart)
|
||||
{
|
||||
if (!syspart)
|
||||
return -1;
|
||||
|
||||
bdinfo_set(BDI_ID_SYSPART, syspart);
|
||||
|
||||
#ifdef LS_DOUBLE_SYSTEM
|
||||
if (!strcmp(syspart, SYSPART_FIRST))
|
||||
bdinfo_set(BDI_ID_SYSPART_LAST, SYSPART_SECOND);
|
||||
else
|
||||
bdinfo_set(BDI_ID_SYSPART_LAST, SYSPART_FIRST);
|
||||
#endif
|
||||
|
||||
bdinfo_save();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int switch_syspart(void)
|
||||
{
|
||||
int ret = 0;
|
||||
char *env_val = NULL;
|
||||
|
||||
// from uboot env
|
||||
env_val = env_get(SYSPART_FIRST_UBOOT_ENV_NAME);
|
||||
if (!env_val)
|
||||
return -1;
|
||||
|
||||
if (!strcmp(env_val, SYSPART_FIRST))
|
||||
env_val = SYSPART_SECOND;
|
||||
else
|
||||
env_val = SYSPART_FIRST;
|
||||
|
||||
ret = setup_syspart_uboot_env(env_val);
|
||||
if (ret)
|
||||
printf("%s: setup uboot env failed! (target: %s)", __func__, env_val);
|
||||
ret = setup_syspart_nvme_env(env_val);
|
||||
if (ret)
|
||||
printf("%s: setup nvme env failed! (target: %s)", __func__, env_val);
|
||||
return ret ? -1 : 0;
|
||||
}
|
||||
|
||||
int setup_cur_syspart(char* syspart)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!syspart)
|
||||
return -1;
|
||||
|
||||
ret = setup_syspart_uboot_env(syspart);
|
||||
if (ret)
|
||||
printf("%s: setup uboot env failed! (target: %s)\n", __func__, syspart);
|
||||
ret = setup_syspart_nvme_env(syspart);
|
||||
if (ret)
|
||||
printf("%s: setup nvme env failed! (target: %s)\n", __func__, syspart);
|
||||
return ret ? -1 : 0;
|
||||
}
|
||||
|
||||
int detect_user_change_syspart(void)
|
||||
{
|
||||
int ret = 0;
|
||||
char *env_val = NULL;
|
||||
|
||||
env_val = env_get(SYSPART_USER_CH_UBOOT_ENV_NAME);
|
||||
if (!env_val)
|
||||
return -1;
|
||||
|
||||
if (!strcmp(env_val, SYSPART_USER_CH_DISABLE))
|
||||
return 0;
|
||||
|
||||
env_val = env_get(SYSPART_FIRST_UBOOT_ENV_NAME);
|
||||
if (!env_val)
|
||||
return -1;
|
||||
|
||||
ret = setup_syspart_nvme_env(env_val);
|
||||
if (ret)
|
||||
printf("%s: setup nvme env failed! (target: %s)", __func__, env_val);
|
||||
return ret ? -1 : 0;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef __LOONGSON_BOOT_SYSPART_MANAGER_H__
|
||||
#define __LOONGSON_BOOT_SYSPART_MANAGER_H__
|
||||
|
||||
#define SYSPART_FIRST "1"
|
||||
#define SYSPART_FIRST_UBOOT_ENV_NAME "syspart"
|
||||
#define SYSPART_SECOND "4"
|
||||
#define SYSPART_SECOND_UBOOT_ENV_NAME "syspart_last"
|
||||
|
||||
#define SYSPART_USER_CH_UBOOT_ENV_NAME "syspart_ch"
|
||||
#define SYSPART_USER_CH_DISABLE "0"
|
||||
#define SYSPART_USER_CH_ENABLE "1"
|
||||
|
||||
int switch_syspart(void);
|
||||
int setup_cur_syspart(char* syspart);
|
||||
int detect_user_change_syspart(void);
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <malloc.h>
|
||||
#include "loongson_boot_syspart_manager.h"
|
||||
#include "loongson_wdt_setup.h"
|
||||
|
||||
/*
|
||||
* 这是一个模拟uboot启动的时候的会自动复位的触发器逻辑
|
||||
@@ -36,11 +38,15 @@ static void loongson_tip_update_rootfs_change(void);
|
||||
static int loongson_handle_update_uboot_change(int index);
|
||||
static void loongson_tip_update_uboot_change(void);
|
||||
|
||||
static int loongson_handle_ab_sys_status_change(int index);
|
||||
static void loongson_tip_ab_sys_status_change(void);
|
||||
|
||||
static char* trigger_name_list[] = {
|
||||
"ls_trigger_boot",
|
||||
"ls_trigger_u_kernel",
|
||||
"ls_trigger_u_rootfs",
|
||||
"ls_trigger_u_uboot",
|
||||
"ls_trigger_ab_sys_status",
|
||||
NULL,
|
||||
};
|
||||
static loongson_trigger_handle_func trigger_handle_func_list[] = {
|
||||
@@ -48,6 +54,7 @@ static loongson_trigger_handle_func trigger_handle_func_list[] = {
|
||||
loongson_handle_update_kernel_change,
|
||||
loongson_handle_update_rootfs_change,
|
||||
loongson_handle_update_uboot_change,
|
||||
loongson_handle_ab_sys_status_change,
|
||||
NULL
|
||||
};
|
||||
static loongson_trigger_tip_func trigger_tip_func_list[] = {
|
||||
@@ -55,9 +62,10 @@ static loongson_trigger_tip_func trigger_tip_func_list[] = {
|
||||
loongson_tip_update_kernel_change,
|
||||
loongson_tip_update_rootfs_change,
|
||||
loongson_tip_update_uboot_change,
|
||||
loongson_tip_ab_sys_status_change,
|
||||
NULL
|
||||
};
|
||||
static char* trigger_default_value_list[] = {"0", "0", "0", "0", NULL};
|
||||
static char* trigger_default_value_list[] = {"0", "0", "0", "0", "0", NULL};
|
||||
|
||||
static int trigger_first_check(int index, char* env_value_bak, int buffer_len)
|
||||
{
|
||||
@@ -116,6 +124,27 @@ static int loongson_handle_boot_change(int index)
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
} else if (!strcmp(env_value, "mmc")) {
|
||||
#ifdef EMMC_BOOT_ENV
|
||||
printf("set boot system from mmc0 .....\r\n");
|
||||
ret = run_command(EMMC_BOOT_ENV, 0);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
} else if (!strcmp(env_value, "mmc0")) {
|
||||
#ifdef EMMC_BOOT_ENV
|
||||
printf("set boot system from mmc0 .....\r\n");
|
||||
ret = run_command(EMMC_BOOT_ENV, 0);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
} else if (!strcmp(env_value, "mmc1")) {
|
||||
#ifdef SDCARD_BOOT_ENV
|
||||
printf("set boot system from mmc1 .....\r\n");
|
||||
ret = run_command(SDCARD_BOOT_ENV, 0);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
} else
|
||||
return -1;
|
||||
|
||||
@@ -126,8 +155,11 @@ static void loongson_tip_boot_change(void)
|
||||
{
|
||||
printf("\tvalue:\n");
|
||||
printf("\t\t0 : no handle\n");
|
||||
printf("\t\tnand: set boot from nand default\n");
|
||||
printf("\t\tnand : set boot from nand default\n");
|
||||
printf("\t\tssd : set boot from ssd default\n");
|
||||
printf("\t\tmmc : set boot from mmc0 default\n");
|
||||
printf("\t\tmmc0 : set boot from mmc0 default\n");
|
||||
printf("\t\tmmc1 : set boot from mmc1 default\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
@@ -246,6 +278,53 @@ static void loongson_tip_update_uboot_change(void)
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static int loongson_handle_ab_sys_status_change(int index)
|
||||
{
|
||||
int ret;
|
||||
char env_value[32];
|
||||
|
||||
ret = trigger_first_check(index, env_value, 32);
|
||||
if (ret == -1)
|
||||
return -1;
|
||||
else if (ret == 1)
|
||||
return 0;
|
||||
|
||||
ret = 0;
|
||||
if (!strcmp(env_value, "boot1")) {
|
||||
printf("Detected new system ...\n");
|
||||
// setup env ls_trigger_ab_sys_status boot2
|
||||
ret = run_command("setenv ls_trigger_ab_sys_status boot2;saveenv", 0);
|
||||
} else if (!strcmp(env_value, "boot1_wdt")) {
|
||||
printf("Detected new system (with boot failed detect)...\n");
|
||||
// setup watchdog 34s 2k max is 34 s
|
||||
ls_wdt_start(LS_WDT_DEFAULT_TIMEOUT_MS);
|
||||
// setup env ls_trigger_ab_sys_status boot2
|
||||
ret = run_command("setenv ls_trigger_ab_sys_status boot2;saveenv", 0);
|
||||
} else if (!strcmp(env_value, "boot2")) {
|
||||
printf("Detected new system boot failed! run back to last system...\n");
|
||||
// switch last boot part
|
||||
switch_syspart();
|
||||
ret = run_command("setenv ls_trigger_ab_sys_status boot4;saveenv", 0);
|
||||
} else if (!strcmp(env_value, "boot4")) {
|
||||
// just wait last part start... and need set this value to be 0
|
||||
ret = 0;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void loongson_tip_ab_sys_status_change(void)
|
||||
{
|
||||
printf("\tvalue:\n");
|
||||
printf("\t\t0 : no handle\n");
|
||||
printf("\t\tboot1 : new system first boot(uboot will change it to be boot2)\n");
|
||||
printf("\t\boot1_wdt: new system first boot and use watchdog detect auto run back(uboot will change it to be boot2)\n");
|
||||
printf("\t\tboot2 : new system first boot failed(system need set this value to be 0, either uboot will boot last disk)\n");
|
||||
printf("\t\boot4 : to old system known install ab system failed\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////底层逻辑实现////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#define TARGET_FDISK_TXT_PATH "/usr/local/ls_resize/fdisk.txt"
|
||||
|
||||
static void try_read_block(char* block_type)
|
||||
{
|
||||
int ret;
|
||||
#if defined(CONFIG_SOC_LS2K300) || defined(CONFIG_SOC_LS2P500)
|
||||
char* target_block = "mmc0:1";
|
||||
#else
|
||||
char* target_block = "scsi0:1";
|
||||
#endif
|
||||
char cmd[256];
|
||||
|
||||
memset(cmd, 0 , 256);
|
||||
sprintf(cmd, "general_load --if %s%s --fmt fat32 --sym /update/fdisk.txt --of %s --fmt ext4 --sym %s --force", block_type, "0:1", target_block, TARGET_FDISK_TXT_PATH);
|
||||
ret = run_command(cmd, 0);
|
||||
|
||||
if (!ret)
|
||||
return;
|
||||
|
||||
memset(cmd, 0 , 256);
|
||||
sprintf(cmd, "general_load --if %s%s --fmt fat32 --sym /update/fdisk.txt --of %s --fmt ext4 --sym %s --force", block_type, "0", target_block, TARGET_FDISK_TXT_PATH);
|
||||
ret = run_command(cmd, 0);
|
||||
|
||||
if (!ret)
|
||||
return;
|
||||
|
||||
memset(cmd, 0 , 256);
|
||||
sprintf(cmd, "general_load --if %s%s --fmt ext4 --sym /update/fdisk.txt --of %s --fmt ext4 --sym %s --force", block_type, "0:1", target_block, TARGET_FDISK_TXT_PATH);
|
||||
ret = run_command(cmd, 0);
|
||||
|
||||
if (!ret)
|
||||
return;
|
||||
|
||||
memset(cmd, 0 , 256);
|
||||
sprintf(cmd, "general_load --if %s%s --fmt ext4 --sym /update/fdisk.txt --of %s --fmt ext4 --sym %s --force", block_type, "0", target_block, TARGET_FDISK_TXT_PATH);
|
||||
ret = run_command(cmd, 0);
|
||||
|
||||
if (!ret)
|
||||
return;
|
||||
}
|
||||
|
||||
static void try_read_tftp(void)
|
||||
{
|
||||
char* server_ip = NULL;
|
||||
#if defined(CONFIG_SOC_LS2K300) || defined(CONFIG_SOC_LS2P500)
|
||||
char* target_block = "mmc0:1";
|
||||
#else
|
||||
char* target_block = "scsi0:1";
|
||||
#endif
|
||||
char cmd[256];
|
||||
// general_load --if net:192.168.1.2 --fmt tftp --sym fdisk.txt --of mmc0:1 --fmt ext4 --sym /root/fdisk.txt --force
|
||||
|
||||
server_ip = env_get("serverip");
|
||||
|
||||
// fdisk.txt 是隐匿的,应快速超时
|
||||
env_set("tftptimeout", "1");
|
||||
env_set("tftptimeoutcountmax", "1");
|
||||
|
||||
memset(cmd, 0 , 256);
|
||||
sprintf(cmd, "general_load --if net:%s --fmt tftp --sym fdisk.txt --of %s --fmt ext4 --sym %s --force", server_ip, target_block, TARGET_FDISK_TXT_PATH);
|
||||
run_command(cmd, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int loongson_try_read_img_fdisk(char* read_way)
|
||||
{
|
||||
if (!read_way)
|
||||
return -1;
|
||||
|
||||
print_enable_setup(0);
|
||||
if (!strcmp(read_way, "usb")) {
|
||||
try_read_block(read_way);
|
||||
} else if (!strcmp(read_way, "mmc")) {
|
||||
try_read_block(read_way);
|
||||
} else if (!strcmp(read_way, "tftp")) {
|
||||
try_read_tftp();
|
||||
}
|
||||
print_enable_setup(1);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef __LOONGSON_IMG_FDISK_H__
|
||||
#define __LOONGSON_IMG_FDISK_H__
|
||||
|
||||
int loongson_try_read_img_fdisk(char* read_way);
|
||||
|
||||
#endif
|
||||
@@ -277,9 +277,17 @@ static int update_uboot(int dev)
|
||||
/*
|
||||
* erase uboot_env
|
||||
*/
|
||||
printf("Erase uboot_env partition ... ");
|
||||
sprintf(cmd, "mtd erase uboot_env");
|
||||
run_command(cmd, 0);
|
||||
|
||||
/*
|
||||
* erase u-boot ddr param
|
||||
*/
|
||||
printf("Erase ddr_context partition ... ");
|
||||
sprintf(cmd, "mtd erase ddr_context");
|
||||
run_command(cmd, 0);
|
||||
|
||||
user_env_save();
|
||||
|
||||
out:
|
||||
|
||||
@@ -61,11 +61,11 @@ static char *updatemenu_rootfs[] = {
|
||||
#endif
|
||||
#ifdef CONFIG_LOONGSON_GENERAL_LOAD
|
||||
#ifdef CONFIG_USB_STORAGE
|
||||
"Update rootfs (rootfs.img) (by usb)=general_load --if usb --sym rootfs.img --decompress\0",
|
||||
"Update rootfs (rootfs.img) (by usb)=general_load --if usb --sym rootfs.img --decompress;\0",
|
||||
#endif
|
||||
"Update rootfs (rootfs.img) (by tftp)=general_load --if net --sym rootfs.img --decompress\0",
|
||||
"Update rootfs (rootfs.img) (by tftp)=general_load --if net --sym rootfs.img --decompress;\0",
|
||||
#ifdef CONFIG_MMC
|
||||
"Update rootfs (rootfs.img) (by mmc)=general_load --if mmc1 --sym rootfs.img --decompress\0",
|
||||
"Update rootfs (rootfs.img) (by mmc)=general_load --if mmc1 --sym rootfs.img --decompress;\0",
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -103,7 +103,18 @@ static char *updatemenu_all[] = {
|
||||
};
|
||||
|
||||
static char *updatemenu_system[] = {
|
||||
#ifdef CONFIG_AHCI
|
||||
#ifdef CONFIG_LOONGSON_BOARD_MMC_FS
|
||||
"System install to mmc device (by usb)=recover_cmd usb 1 mmc\0",
|
||||
"System install to mmc device (by tftp)=recover_cmd tftp 1 mmc\0",
|
||||
#ifdef CONFIG_MMC
|
||||
"System install to mmc device (by mmc)=recover_cmd mmc 1 mmc\0",
|
||||
#endif
|
||||
"System recover from mmc disk=recover_cmd mmc_r\0",
|
||||
#ifdef LS_DOUBLE_SYSTEM
|
||||
"System recover last time boot=recover_cmd last\0",
|
||||
#endif
|
||||
#endif
|
||||
#ifdef CONFIG_LOONGSON_BOARD_SATA_FS
|
||||
"System install to sata disk (by usb)=recover_cmd usb\0",
|
||||
"System install to sata disk (by usb iso)=bootcfg usb\0",
|
||||
"System install to sata disk (by tftp)=recover_cmd tftp\0",
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <wdt.h>
|
||||
#include <stdio.h>
|
||||
#include "loongson_wdt_setup.h"
|
||||
|
||||
#ifdef CONFIG_WDT
|
||||
static struct udevice *currdev = NULL;
|
||||
|
||||
static int init_wdt_dev(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (currdev)
|
||||
return 0;
|
||||
|
||||
ret = uclass_get_device_by_name(UCLASS_WDT, LS_WDT_NODE_NAME, &currdev);
|
||||
if (ret) {
|
||||
printf("%s: Can't get the watchdog timer: %s\n", __func__, LS_WDT_NODE_NAME);
|
||||
currdev = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ls_wdt_start(int ms)
|
||||
{
|
||||
int ret;
|
||||
ret = init_wdt_dev();
|
||||
if (ret)
|
||||
return -1;
|
||||
|
||||
ret = wdt_start(currdev, ms, 0);
|
||||
if (ret == -ENOSYS) {
|
||||
printf("%s Starting watchdog timer not supported.\n", __func__);
|
||||
return -1;
|
||||
} else if (ret) {
|
||||
printf("%s Starting watchdog timer failed (%d)\n", __func__, ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ls_wdt_stop(void)
|
||||
{
|
||||
int ret;
|
||||
ret = init_wdt_dev();
|
||||
if (ret)
|
||||
return -1;
|
||||
|
||||
ret = wdt_stop(currdev);
|
||||
if (ret == -ENOSYS) {
|
||||
printf("%s Stopping watchdog timer not supported.\n", __func__);
|
||||
return -1;
|
||||
} else if (ret) {
|
||||
printf("%s Stopping watchdog timer failed (%d)\n", __func__, ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ls_wdt_restart(void)
|
||||
{
|
||||
int ret;
|
||||
ret = init_wdt_dev();
|
||||
if (ret)
|
||||
return -1;
|
||||
|
||||
ret = wdt_reset(currdev);
|
||||
if (ret == -ENOSYS) {
|
||||
printf("%s Resetting watchdog timer not supported.\n", __func__);
|
||||
return -1;
|
||||
} else if (ret) {
|
||||
printf("%s Resetting watchdog timer failed (%d)\n", __func__, ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
int ls_wdt_start(int ms) {return 0;}
|
||||
int ls_wdt_stop(void) {return 0;}
|
||||
int ls_wdt_restart(void) {return 0;}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef __LOONGSON_WDT_SETUP_H__
|
||||
#define __LOONGSON_WDT_SETUP_H__
|
||||
|
||||
#define LS_WDT_NODE_NAME "watchdog_d"
|
||||
#define LS_WDT_DEFAULT_TIMEOUT_MS 34000
|
||||
|
||||
int ls_wdt_start(int ms);
|
||||
int ls_wdt_stop(void);
|
||||
int ls_wdt_restart(void);
|
||||
|
||||
#endif
|
||||
@@ -306,6 +306,7 @@ static void loongson_env_trigger(void)
|
||||
run_command("loongson_env_trigger ls_trigger_u_rootfs", 0);
|
||||
run_command("loongson_env_trigger ls_trigger_u_uboot", 0);
|
||||
run_command("loongson_env_trigger ls_trigger_boot", 0);
|
||||
run_command("loongson_env_trigger ls_trigger_ab_sys_status", 0);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BOARD_EARLY_INIT_F
|
||||
|
||||
+129
-64
@@ -7,6 +7,17 @@
|
||||
#include <asm/gpio.h>
|
||||
#include "loongson_storage_read_file.h"
|
||||
#include "bdinfo/bdinfo.h"
|
||||
#include "loongson_boot_syspart_manager.h"
|
||||
|
||||
typedef enum recover_network {
|
||||
NETWORK_TFTP = 0,
|
||||
NETWORK_DHCP,
|
||||
NETWORK_UNKNOWN,
|
||||
} recover_network;
|
||||
|
||||
// 0 is scsi default
|
||||
// 1 is mmc
|
||||
static int install_target=0;
|
||||
|
||||
static int run_recover_cmd(char *cmd)
|
||||
{
|
||||
@@ -67,6 +78,7 @@ static int run_recover_cmd_for_storage(enum if_type if_type)
|
||||
char* type;
|
||||
enum if_type if_type_set[] = {IF_TYPE_USB, IF_TYPE_MMC};
|
||||
char* type_set[] = {"usb", "mmc", NULL};
|
||||
char* ins_target_set[] = {"scsi", "mmc", NULL};
|
||||
int status;
|
||||
|
||||
status = 0;
|
||||
@@ -111,7 +123,7 @@ static int run_recover_cmd_for_storage(enum if_type if_type)
|
||||
|
||||
// set bootargs env by loongson env
|
||||
memset(cmdbuf, 0, 256);
|
||||
sprintf(cmdbuf, "setenv bootargs ${bootargs} ins_way=%s;", type);
|
||||
sprintf(cmdbuf, "setenv bootargs ${bootargs} ins_way=%s ins_target=%s;", type, ins_target_set[install_target]);
|
||||
ret = run_command(cmdbuf, 0);
|
||||
if (ret) {
|
||||
status = 3;
|
||||
@@ -135,6 +147,65 @@ reset_start_failed:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* network_way
|
||||
* 0 tftp
|
||||
* 1 dhcp
|
||||
*/
|
||||
static int run_recover_cmd_for_network(recover_network network_way)
|
||||
{
|
||||
int ret = -1;
|
||||
char cmdbuf[256]; /* working copy of cmd */
|
||||
char* ins_target_set[] = {"scsi", "mmc", NULL};
|
||||
char* download_cmd[] = {RECOVER_TFTP_DOWNLOAD_CMD, RECOVER_DHCP_DOWNLOAD_CMD, NULL};
|
||||
int status;
|
||||
|
||||
status = 0;
|
||||
|
||||
if (network_way >= NETWORK_UNKNOWN) {
|
||||
status = 2;
|
||||
goto reset_failed;
|
||||
}
|
||||
|
||||
// read kernel and ramdisk
|
||||
ret = run_command(download_cmd[network_way], 0);
|
||||
if (ret) {
|
||||
status = 2;
|
||||
goto reset_failed;
|
||||
}
|
||||
|
||||
// set bootargs env
|
||||
ret = run_command(RECOVER_FRONT_BOOTARGS, 0);
|
||||
if (ret) {
|
||||
status = 3;
|
||||
goto reset_failed;
|
||||
};
|
||||
|
||||
// set bootargs env by loongson env
|
||||
memset(cmdbuf, 0, 256);
|
||||
sprintf(cmdbuf, "setenv bootargs ${bootargs} ins_way=tftp ins_target=%s u_ip=${ipaddr} u_sip=${serverip};", ins_target_set[install_target]);
|
||||
ret = run_command(cmdbuf, 0);
|
||||
if (ret) {
|
||||
status = 3;
|
||||
goto reset_failed;
|
||||
}
|
||||
|
||||
// boot kernel and ramdisk.gz
|
||||
ret = run_command(RECOVER_START, 0);
|
||||
if (ret) {
|
||||
status = 3;
|
||||
goto reset_failed;
|
||||
}
|
||||
return ret;
|
||||
|
||||
reset_failed:
|
||||
printf("##################################################################\n");
|
||||
if (status == 2)
|
||||
printf("### Error download kernel or ramdisk.gz\n");
|
||||
printf("##################################################################\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int do_recover_from_usb(void)
|
||||
{
|
||||
printf("Install System By USB .....\r\n");
|
||||
@@ -146,13 +217,13 @@ static int do_recover_from_tftp(void)
|
||||
{
|
||||
// char cmd[]= "tftpboot ${loadaddr} uImage;tftpboot ${rd_start} ramdisk.gz;"RECOVER_DEFAULT_ENV"";
|
||||
printf("Install System By tftp .....\r\n");
|
||||
return run_recover_cmd(RECOVER_TFTP_DEFAULT);
|
||||
return run_recover_cmd_for_network(NETWORK_TFTP);
|
||||
}
|
||||
|
||||
static int do_recover_from_dhcp(void)
|
||||
{
|
||||
printf("Install System By dhcp .....\r\n");
|
||||
return run_recover_cmd(RECOVER_DHCP_DEFAULT);
|
||||
return run_recover_cmd_for_network(NETWORK_DHCP);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MMC
|
||||
@@ -177,6 +248,19 @@ static int do_recover_from_sata(char *part_id)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int do_recover_from_mmc_r(char *part_id)
|
||||
{
|
||||
#ifdef RECOVER_SATA_DEFAULT
|
||||
printf("Recover System By SATA .....\r\n");
|
||||
return run_recover_cmd(RECOVER_SATA_DEFAULT);
|
||||
#else
|
||||
char cmd[CONFIG_SYS_CBSIZE] = {0};
|
||||
snprintf(cmd, sizeof(cmd), "ext4load mmc 0:%s ${loadaddr} uImage;ext4load mmc 0:%s ${rd_start} ramdisk.gz;%s setenv bootargs ${bootargs} rec_sys=1 rec_target=mmc; %s"
|
||||
, part_id, part_id, RECOVER_FRONT_BOOTARGS, RECOVER_START);
|
||||
return run_recover_cmd(cmd);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* 上电时长按按钮3秒进入recover功能, recover优先顺序usb>mmc>sata
|
||||
按键使用 LS_RECOVER_GPIO_BUTTON 定义的gpio */
|
||||
int recover(void)
|
||||
@@ -207,71 +291,18 @@ int recover(void)
|
||||
|
||||
#ifdef LS_DOUBLE_SYSTEM
|
||||
|
||||
static void do_recover_to_last_save_bdinfo(void)
|
||||
{
|
||||
char *env;
|
||||
char *env_buf;
|
||||
|
||||
env = env_get("syspart");
|
||||
env_buf = env_get("syspart_last");
|
||||
bdinfo_set(BDI_ID_SYSPART, env);
|
||||
bdinfo_set(BDI_ID_SYSPART_LAST, env_buf);
|
||||
bdinfo_save();
|
||||
}
|
||||
|
||||
static void do_recover_to_last_save_env_bdinfo(char* cur_syspart)
|
||||
{
|
||||
if (!cur_syspart)
|
||||
cur_syspart = "1";
|
||||
|
||||
if (!strcmp(cur_syspart, "1")) {
|
||||
env_set("syspart", "4");
|
||||
env_set("syspart_last", "1");
|
||||
} else {
|
||||
env_set("syspart", "1");
|
||||
env_set("syspart_last", "4");
|
||||
}
|
||||
env_save();
|
||||
do_recover_to_last_save_bdinfo();
|
||||
}
|
||||
|
||||
static int do_recover_to_last_handle_error(void)
|
||||
{
|
||||
char *env;
|
||||
char *env_last;
|
||||
|
||||
env = env_get("syspart");
|
||||
env_last = env_get("syspart_last");
|
||||
|
||||
// 不相等证明没问题
|
||||
if (strcmp(env, env_last))
|
||||
return 1;
|
||||
|
||||
do_recover_to_last_save_env_bdinfo(env);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_recover_to_last(void)
|
||||
{
|
||||
char *env;
|
||||
int ret;
|
||||
|
||||
env = env_get("bootcmd");
|
||||
if (strstr(env, "scsi") == NULL) {
|
||||
if (!strstr(env, "scsi") && !strstr(env, "mmc") ) {
|
||||
printf("current maybe is boot by nand\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 没有发现异常 (syspart != syspart_last)
|
||||
if (do_recover_to_last_handle_error()) {
|
||||
//两个启动盘的情况 是 两个盘符之间的转换
|
||||
env = env_get("syspart");
|
||||
do_recover_to_last_save_env_bdinfo(env);
|
||||
}
|
||||
|
||||
ret = run_command(BOOT_SATA_DEFAULT, 0);
|
||||
if (ret)
|
||||
printf("recover last time system failed!\n");
|
||||
ret = switch_syspart();
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -296,6 +327,16 @@ static int do_recover_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char * cons
|
||||
return ret;
|
||||
}
|
||||
|
||||
install_target = 0;
|
||||
if (!argv[3])
|
||||
install_target = 0;
|
||||
else {
|
||||
if (!strcmp(argv[3], "scsi"))
|
||||
install_target = 0;
|
||||
else if (!strcmp(argv[3], "mmc"))
|
||||
install_target = 1;
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "usb") == 0) {
|
||||
ret = do_recover_from_usb();
|
||||
}
|
||||
@@ -320,6 +361,16 @@ static int do_recover_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char * cons
|
||||
printf("part_id:%s\n", part_id);
|
||||
ret = do_recover_from_sata(part_id);
|
||||
}
|
||||
else if (strcmp(argv[1], "mmc_r") == 0) {
|
||||
char part_id[4] = "4";
|
||||
if (argc == 3) {
|
||||
memset(part_id, 0, sizeof(part_id));
|
||||
int len = strlen(argv[2]) > sizeof(part_id) ? sizeof(part_id) : strlen(argv[2]);
|
||||
strncpy(part_id, argv[2], len);
|
||||
}
|
||||
printf("part_id:%s\n", part_id);
|
||||
ret = do_recover_from_mmc_r(part_id);
|
||||
}
|
||||
#ifdef LS_DOUBLE_SYSTEM
|
||||
else if (strcmp(argv[1], "last") == 0) {
|
||||
ret = do_recover_to_last();
|
||||
@@ -330,9 +381,9 @@ static int do_recover_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char * cons
|
||||
}
|
||||
|
||||
#define RECOVER_CMD_TIP_HEAD "recover system by usb or backup partition.\n"\
|
||||
"recover_cmd <option> [part_id]\n"\
|
||||
"option: usb: recover from usb\n"\
|
||||
"option: tftp: recover from tftp\n"
|
||||
"recover_cmd <option> [part_id] [install_target]\n"\
|
||||
"option1: usb: recover from usb\n"\
|
||||
" tftp: recover from tftp\n"
|
||||
|
||||
#ifdef CONFIG_MMC
|
||||
#define RECOVER_CMD_TIP_MMC " mmc: recover from mmc\n"
|
||||
@@ -346,16 +397,30 @@ static int do_recover_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char * cons
|
||||
#define RECOVER_CMD_TIP_LAST ""
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LOONGSON_BOARD_SATA_FS
|
||||
#define INSTALL_TARGET_SCSI_TIP "option3: scsi: install system to sda"
|
||||
#else
|
||||
#define INSTALL_TARGET_SCSI_TIP ""
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LOONGSON_BOARD_MMC_FS
|
||||
#define INSTALL_TARGET_MMC_TIP "option3: mmc : install system to mmc"
|
||||
#else
|
||||
#define INSTALL_TARGET_MMC_TIP ""
|
||||
#endif
|
||||
|
||||
#define RECOVER_CMD_TIP RECOVER_CMD_TIP_HEAD \
|
||||
RECOVER_CMD_TIP_MMC \
|
||||
RECOVER_CMD_TIP_LAST \
|
||||
" sata: recover from sata\n"\
|
||||
" part_id: recover from part id of sata\n"
|
||||
" mmc_r: recover from mmc ext4 part\n"\
|
||||
"option2: part_id: recover from part id\n" \
|
||||
INSTALL_TARGET_SCSI_TIP \
|
||||
INSTALL_TARGET_MMC_TIP
|
||||
|
||||
U_BOOT_CMD(
|
||||
recover_cmd, 3, 1, do_recover_cmd,
|
||||
recover_cmd, 4, 1, do_recover_cmd,
|
||||
"recover the system",
|
||||
RECOVER_CMD_TIP
|
||||
);
|
||||
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ static void dev_fixup(void)
|
||||
|
||||
/* uart 0 and 1 be 2 line mode */
|
||||
val = readl(LS_GENERAL_CFG0);
|
||||
val |= 0xe000c000;
|
||||
val |= 0xe0008000;
|
||||
writel(val, LS_GENERAL_CFG0);
|
||||
|
||||
/*RTC toytrim rtctrim must init to 0, otherwise time can not update*/
|
||||
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
PS3="Please enter your choice:"
|
||||
|
||||
conf=""
|
||||
|
||||
function get_conf()
|
||||
{
|
||||
plat=loongson_${1}
|
||||
opts=(`cd configs && ls ${plat}*`)
|
||||
select opt in "${opts[@]}"
|
||||
do
|
||||
conf=$opt
|
||||
break
|
||||
done
|
||||
|
||||
echo
|
||||
echo "Your select is:${conf}"
|
||||
echo
|
||||
}
|
||||
|
||||
function usage()
|
||||
{
|
||||
echo "Usage:"
|
||||
echo "./buildenv.sh <chip> [options]"
|
||||
echo "chip: <2k300/2k500/2k1000/2p500/all>"
|
||||
echo "options: it's same as u-boot make defconfig"
|
||||
}
|
||||
|
||||
function main()
|
||||
{
|
||||
if [ $# -ge 1 ]; then
|
||||
param=${1}
|
||||
if [ ${param} = "all" ]; then
|
||||
get_conf
|
||||
else
|
||||
get_conf $param
|
||||
fi
|
||||
|
||||
shift
|
||||
make $conf $@
|
||||
else
|
||||
usage
|
||||
fi
|
||||
}
|
||||
|
||||
main $@
|
||||
@@ -24,6 +24,14 @@
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
static int __print_enable = 1;
|
||||
|
||||
int print_enable_setup(int enable)
|
||||
{
|
||||
__print_enable = enable ? 1 : 0;
|
||||
return __print_enable;
|
||||
}
|
||||
|
||||
static int on_console(const char *name, const char *value, enum env_op op,
|
||||
int flags)
|
||||
{
|
||||
@@ -515,12 +523,18 @@ int ftstc(int file)
|
||||
|
||||
void fputc(int file, const char c)
|
||||
{
|
||||
if (!__print_enable)
|
||||
return;
|
||||
|
||||
if (file < MAX_FILES)
|
||||
console_putc(file, c);
|
||||
}
|
||||
|
||||
void fputs(int file, const char *s)
|
||||
{
|
||||
if (!__print_enable)
|
||||
return;
|
||||
|
||||
if (file < MAX_FILES)
|
||||
console_puts(file, s);
|
||||
}
|
||||
@@ -651,6 +665,9 @@ void putc(const char c)
|
||||
if (!gd)
|
||||
return;
|
||||
|
||||
if (!__print_enable)
|
||||
return;
|
||||
|
||||
console_record_putc(c);
|
||||
|
||||
/* sandbox can send characters to stdout before it has a console */
|
||||
@@ -692,6 +709,9 @@ void puts(const char *s)
|
||||
if (!gd)
|
||||
return;
|
||||
|
||||
if (!__print_enable)
|
||||
return;
|
||||
|
||||
console_record_puts(s);
|
||||
|
||||
/* sandbox can send characters to stdout before it has a console */
|
||||
|
||||
@@ -23,7 +23,9 @@ CONFIG_ARCH_LA_LOONGSON=y
|
||||
CONFIG_SOC_LS2K1000=y
|
||||
CONFIG_CPU_900MHZ=y
|
||||
CONFIG_TARGET_LS2K1000_DP=y
|
||||
CONFIG_LOONGSON_RECOVER=y
|
||||
CONFIG_LOONGSON_GENERAL_LOAD=y
|
||||
CONFIG_LOONGSON_BOARD_SATA_FS=y
|
||||
CONFIG_SPL_PAYLOAD="u-boot.img.lzo"
|
||||
CONFIG_AHCI=y
|
||||
CONFIG_PHYS_64BIT=y
|
||||
@@ -34,9 +36,9 @@ CONFIG_AUTOBOOT_KEYED=y
|
||||
CONFIG_AUTOBOOT_DELAY_STR="m"
|
||||
CONFIG_AUTOBOOT_STOP_STR="c"
|
||||
CONFIG_USE_BOOTARGS=y
|
||||
CONFIG_BOOTARGS="root=/dev/sda console=ttyS0,115200 rootfstype=ext4 rw rootwait"
|
||||
CONFIG_BOOTARGS="console=ttyS0,115200 rootfstype=ext4 rw rootwait"
|
||||
CONFIG_USE_BOOTCOMMAND=y
|
||||
CONFIG_BOOTCOMMAND="setenv bootargs ${bootargs} mtdparts=${mtdparts} fbcon=rotate:${rotate} panel=${panel}; sf probe;sf read ${fdt_addr} dtb; general_load --sym uImage; bootm "
|
||||
CONFIG_BOOTCOMMAND="setenv bootargs ${bootargs} root=/dev/mmcblk0p${syspart} mtdparts=${mtdparts} fbcon=rotate:${rotate} panel=${panel};ext4load scsi 0:${syspart} ${loadaddr} /boot/uImage;bootm"
|
||||
CONFIG_LOGLEVEL=7
|
||||
CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
|
||||
# CONFIG_SYS_DEVICE_NULLDEV is not set
|
||||
@@ -80,7 +82,7 @@ CONFIG_CMD_ISOFS=y
|
||||
CONFIG_CMD_FS_GENERIC=y
|
||||
CONFIG_CMD_MTDPARTS=y
|
||||
CONFIG_MTDIDS_DEFAULT="nor0=spi0.0"
|
||||
CONFIG_MTDPARTS_DEFAULT="spi0.0:924k(uboot),32k(uboot_env),4k(bdinfo),64k(dtb)"
|
||||
CONFIG_MTDPARTS_DEFAULT="spi0.0:924k(uboot),32k(uboot_env),4k(bdinfo),56k(dtb),8k(ddr_context)"
|
||||
CONFIG_ISO_PARTITION=y
|
||||
# CONFIG_SPL_EFI_PARTITION is not set
|
||||
CONFIG_OF_LIVE=y
|
||||
@@ -169,6 +171,10 @@ CONFIG_SPLASH_SCREEN_ALIGN=y
|
||||
CONFIG_BMP_16BPP=y
|
||||
CONFIG_BMP_24BPP=y
|
||||
CONFIG_BMP_32BPP=y
|
||||
# CONFIG_WATCHDOG is not set
|
||||
# CONFIG_WATCHDOG_AUTOSTART is not set
|
||||
CONFIG_WDT=y
|
||||
CONFIG_WDT_LS2X=y
|
||||
CONFIG_FAT_WRITE=y
|
||||
CONFIG_BCH=y
|
||||
CONFIG_PANIC_HANG=y
|
||||
|
||||
@@ -23,7 +23,9 @@ CONFIG_SPL_SPI=y
|
||||
CONFIG_ARCH_LA_LOONGSON=y
|
||||
CONFIG_SOC_LS2K300=y
|
||||
CONFIG_CPU_1000MHZ=y
|
||||
CONFIG_LOONGSON_RECOVER=y
|
||||
CONFIG_LOONGSON_GENERAL_LOAD=y
|
||||
CONFIG_LOONGSON_BOARD_MMC_FS=y
|
||||
CONFIG_SPL_PAYLOAD="u-boot.img"
|
||||
CONFIG_PHYS_64BIT=y
|
||||
CONFIG_SYS_LOAD_ADDR=0x9000000003000000
|
||||
@@ -33,9 +35,9 @@ CONFIG_AUTOBOOT_KEYED=y
|
||||
CONFIG_AUTOBOOT_DELAY_STR="m"
|
||||
CONFIG_AUTOBOOT_STOP_STR="c"
|
||||
CONFIG_USE_BOOTARGS=y
|
||||
CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/mmcblk0 rw noinitrd init=/linuxrc rootfstype=ext4 rootwait"
|
||||
CONFIG_BOOTARGS="console=ttyS0,115200 rw noinitrd init=/sbin/init rootfstype=ext4 rootwait"
|
||||
CONFIG_USE_BOOTCOMMAND=y
|
||||
CONFIG_BOOTCOMMAND="setenv bootargs ${bootargs} mtdparts=${mtdparts} fbcon=rotate:${rotate} panel=${panel};general_load --sym uImage;bootm"
|
||||
CONFIG_BOOTCOMMAND="setenv bootargs ${bootargs} root=/dev/mmcblk0p${syspart} mtdparts=${mtdparts} fbcon=rotate:${rotate} panel=${panel};ext4load mmc 0:${syspart} ${loadaddr} /boot/uImage;bootm"
|
||||
CONFIG_LOGLEVEL=7
|
||||
CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
|
||||
# CONFIG_SYS_DEVICE_NULLDEV is not set
|
||||
@@ -55,13 +57,21 @@ CONFIG_SPL_MTD_SUPPORT=y
|
||||
CONFIG_SPL_DM_SPI_FLASH=y
|
||||
CONFIG_SPL_SPI_FLASH_MTD=y
|
||||
CONFIG_SPL_SPI_LOAD=y
|
||||
# CONFIG_BOOTM_PLAN9 is not set
|
||||
CONFIG_CMD_BOOTMENU=y
|
||||
CONFIG_CMD_MD5SUM=y
|
||||
# CONFIG_CMD_XIMG is not set
|
||||
# CONFIG_CMD_RANDOM is not set
|
||||
CONFIG_CMD_MEMTEST=y
|
||||
CONFIG_CMD_GPT=y
|
||||
# CONFIG_RANDOM_UUID is not set
|
||||
CONFIG_CMD_GPT_RENAME=y
|
||||
CONFIG_CMD_MMC=y
|
||||
CONFIG_CMD_MTD=y
|
||||
CONFIG_CMD_POWEROFF=y
|
||||
CONFIG_CMD_SF_TEST=y
|
||||
CONFIG_CMD_USB=y
|
||||
# CONFIG_CMD_ITEST is not set
|
||||
CONFIG_CMD_DHCP=y
|
||||
CONFIG_CMD_MII=y
|
||||
CONFIG_CMD_PING=y
|
||||
CONFIG_CMD_BMP=y
|
||||
@@ -73,9 +83,9 @@ CONFIG_CMD_FAT=y
|
||||
CONFIG_CMD_FS_GENERIC=y
|
||||
CONFIG_CMD_MTDPARTS=y
|
||||
CONFIG_MTDIDS_DEFAULT="nor0=spi0.0"
|
||||
CONFIG_MTDPARTS_DEFAULT="spi0.0:924k(uboot),32k(uboot_env),4k(bdinfo),64k(dtb)"
|
||||
CONFIG_MTDPARTS_DEFAULT="spi0.0:924k(uboot),32k(uboot_env),4k(bdinfo),56k(dtb),8k(ddr_context)"
|
||||
CONFIG_ISO_PARTITION=y
|
||||
CONFIG_PARTITION_UUIDS=y
|
||||
# CONFIG_SPL_EFI_PARTITION is not set
|
||||
CONFIG_OF_LIVE=y
|
||||
CONFIG_OF_BOARD=y
|
||||
CONFIG_OF_SPL_REMOVE_PROPS="interrupt-parent interrupts"
|
||||
@@ -145,6 +155,10 @@ CONFIG_SPLASH_SCREEN_ALIGN=y
|
||||
CONFIG_BMP_16BPP=y
|
||||
CONFIG_BMP_24BPP=y
|
||||
CONFIG_BMP_32BPP=y
|
||||
# CONFIG_WATCHDOG is not set
|
||||
# CONFIG_WATCHDOG_AUTOSTART is not set
|
||||
CONFIG_WDT=y
|
||||
CONFIG_WDT_LS2X=y
|
||||
CONFIG_FAT_WRITE=y
|
||||
CONFIG_BCH=y
|
||||
CONFIG_PANIC_HANG=y
|
||||
|
||||
@@ -23,7 +23,9 @@ CONFIG_SPL_SPI=y
|
||||
CONFIG_ARCH_LA_LOONGSON=y
|
||||
CONFIG_SOC_LS2K300=y
|
||||
CONFIG_CPU_1000MHZ=y
|
||||
CONFIG_LOONGSON_RECOVER=y
|
||||
CONFIG_LOONGSON_GENERAL_LOAD=y
|
||||
CONFIG_LOONGSON_BOARD_MMC_FS=y
|
||||
CONFIG_SPL_PAYLOAD="u-boot.img"
|
||||
CONFIG_PHYS_64BIT=y
|
||||
CONFIG_SYS_LOAD_ADDR=0x9000000003000000
|
||||
@@ -33,9 +35,9 @@ CONFIG_AUTOBOOT_KEYED=y
|
||||
CONFIG_AUTOBOOT_DELAY_STR="m"
|
||||
CONFIG_AUTOBOOT_STOP_STR="c"
|
||||
CONFIG_USE_BOOTARGS=y
|
||||
CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/mmcblk0 rw noinitrd init=/linuxrc rootfstype=ext4 rootwait"
|
||||
CONFIG_BOOTARGS="console=ttyS0,115200 rw noinitrd init=/sbin/init rootfstype=ext4 rootwait"
|
||||
CONFIG_USE_BOOTCOMMAND=y
|
||||
CONFIG_BOOTCOMMAND="setenv bootargs ${bootargs} mtdparts=${mtdparts} fbcon=rotate:${rotate} panel=${panel};general_load --sym uImage;bootm"
|
||||
CONFIG_BOOTCOMMAND="setenv bootargs ${bootargs} root=/dev/mmcblk0p${syspart} mtdparts=${mtdparts} fbcon=rotate:${rotate} panel=${panel};ext4load mmc 0:${syspart} ${loadaddr} /boot/uImage;bootm"
|
||||
# CONFIG_INIT_USB_INPUT_DEV_BOOT is not set
|
||||
CONFIG_LOGLEVEL=7
|
||||
CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
|
||||
@@ -56,13 +58,24 @@ CONFIG_SPL_MTD_SUPPORT=y
|
||||
CONFIG_SPL_DM_SPI_FLASH=y
|
||||
CONFIG_SPL_SPI_FLASH_MTD=y
|
||||
CONFIG_SPL_SPI_LOAD=y
|
||||
# CONFIG_BOOTM_NETBSD is not set
|
||||
# CONFIG_BOOTM_PLAN9 is not set
|
||||
CONFIG_CMD_BOOTMENU=y
|
||||
CONFIG_CMD_MD5SUM=y
|
||||
# CONFIG_CMD_RUN is not set
|
||||
# CONFIG_CMD_XIMG is not set
|
||||
# CONFIG_CMD_EXPORTENV is not set
|
||||
# CONFIG_CMD_IMPORTENV is not set
|
||||
# CONFIG_CMD_ENV_EXISTS is not set
|
||||
# CONFIG_CMD_RANDOM is not set
|
||||
CONFIG_CMD_GPT=y
|
||||
# CONFIG_RANDOM_UUID is not set
|
||||
CONFIG_CMD_GPT_RENAME=y
|
||||
CONFIG_CMD_MMC=y
|
||||
CONFIG_CMD_MTD=y
|
||||
CONFIG_CMD_POWEROFF=y
|
||||
CONFIG_CMD_SF_TEST=y
|
||||
CONFIG_CMD_USB=y
|
||||
CONFIG_CMD_DHCP=y
|
||||
CONFIG_CMD_MII=y
|
||||
CONFIG_CMD_PING=y
|
||||
CONFIG_CMD_BMP=y
|
||||
@@ -74,9 +87,9 @@ CONFIG_CMD_FAT=y
|
||||
CONFIG_CMD_FS_GENERIC=y
|
||||
CONFIG_CMD_MTDPARTS=y
|
||||
CONFIG_MTDIDS_DEFAULT="nor0=spi0.0"
|
||||
CONFIG_MTDPARTS_DEFAULT="spi0.0:924k(uboot),32k(uboot_env),4k(bdinfo),64k(dtb)"
|
||||
CONFIG_MTDPARTS_DEFAULT="spi0.0:924k(uboot),32k(uboot_env),4k(bdinfo),56k(dtb),8k(ddr_context)"
|
||||
CONFIG_ISO_PARTITION=y
|
||||
CONFIG_PARTITION_UUIDS=y
|
||||
# CONFIG_SPL_EFI_PARTITION is not set
|
||||
CONFIG_OF_LIVE=y
|
||||
CONFIG_OF_BOARD=y
|
||||
CONFIG_OF_SPL_REMOVE_PROPS="interrupt-parent interrupts"
|
||||
@@ -146,6 +159,10 @@ CONFIG_SPLASH_SCREEN_ALIGN=y
|
||||
CONFIG_BMP_16BPP=y
|
||||
CONFIG_BMP_24BPP=y
|
||||
CONFIG_BMP_32BPP=y
|
||||
# CONFIG_WATCHDOG is not set
|
||||
# CONFIG_WATCHDOG_AUTOSTART is not set
|
||||
CONFIG_WDT=y
|
||||
CONFIG_WDT_LS2X=y
|
||||
CONFIG_FAT_WRITE=y
|
||||
CONFIG_BCH=y
|
||||
CONFIG_PANIC_HANG=y
|
||||
|
||||
@@ -73,7 +73,7 @@ CONFIG_CMD_FAT=y
|
||||
CONFIG_CMD_FS_GENERIC=y
|
||||
CONFIG_CMD_MTDPARTS=y
|
||||
CONFIG_MTDIDS_DEFAULT="nand0=ls-nand,nor0=spi0.0"
|
||||
CONFIG_MTDPARTS_DEFAULT="ls-nand:14m(kernel),-(root);spi0.0:924k(uboot),32k(uboot_env),4k(bdinfo),64k(dtb)"
|
||||
CONFIG_MTDPARTS_DEFAULT="ls-nand:14m(kernel),-(root);spi0.0:924k(uboot),32k(uboot_env),4k(bdinfo),56k(dtb),8k(ddr_context)"
|
||||
CONFIG_ISO_PARTITION=y
|
||||
CONFIG_PARTITION_UUIDS=y
|
||||
CONFIG_OF_LIVE=y
|
||||
|
||||
@@ -59,6 +59,9 @@ CONFIG_SYS_EEPROM_SIZE=4096
|
||||
CONFIG_SYS_EEPROM_PAGE_WRITE_BITS=4
|
||||
CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=3
|
||||
CONFIG_CMD_MD5SUM=y
|
||||
CONFIG_CMD_GPT=y
|
||||
# CONFIG_RANDOM_UUID is not set
|
||||
CONFIG_CMD_GPT_RENAME=y
|
||||
CONFIG_CMD_MBR=y
|
||||
CONFIG_CMD_MMC=y
|
||||
CONFIG_CMD_MTD=y
|
||||
@@ -74,9 +77,9 @@ CONFIG_CMD_FAT=y
|
||||
CONFIG_CMD_FS_GENERIC=y
|
||||
CONFIG_CMD_MTDPARTS=y
|
||||
CONFIG_MTDIDS_DEFAULT="nand0=ls-nand,nor0=spi0.0"
|
||||
CONFIG_MTDPARTS_DEFAULT="ls-nand:14m(kernel),-(root);spi0.0:924k(uboot),32k(uboot_env),4k(bdinfo),64k(dtb)"
|
||||
CONFIG_MTDPARTS_DEFAULT="ls-nand:14m(kernel),-(root);spi0.0:924k(uboot),32k(uboot_env),4k(bdinfo),56k(dtb),8k(ddr_context)"
|
||||
CONFIG_ISO_PARTITION=y
|
||||
CONFIG_PARTITION_UUIDS=y
|
||||
# CONFIG_SPL_EFI_PARTITION is not set
|
||||
CONFIG_OF_BOARD=y
|
||||
CONFIG_OF_SPL_REMOVE_PROPS="interrupt-parent interrupts"
|
||||
CONFIG_ENV_OVERWRITE=y
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
CONFIG_LOONGARCH=y
|
||||
CONFIG_SYS_TEXT_BASE=0x900000000ec00000
|
||||
CONFIG_SYS_MALLOC_LEN=0x1000000
|
||||
CONFIG_SYS_MALLOC_F_LEN=0x4000
|
||||
CONFIG_SPL_LIBCOMMON_SUPPORT=y
|
||||
CONFIG_SPL_LIBGENERIC_SUPPORT=y
|
||||
CONFIG_NR_DRAM_BANKS=2
|
||||
CONFIG_ENV_SIZE=0x4000
|
||||
CONFIG_ENV_OFFSET=0xe7000
|
||||
CONFIG_ENV_SECT_SIZE=0x1000
|
||||
CONFIG_DM_GPIO=y
|
||||
CONFIG_SPL_DM_SPI=y
|
||||
CONFIG_DEFAULT_DEVICE_TREE="ls2p500_gbkpjm0_v10"
|
||||
CONFIG_SPL_TEXT_BASE=0x9000000090000000
|
||||
CONFIG_SPL_SERIAL=y
|
||||
CONFIG_SPL_STACK_R_ADDR=0x9000000002000000
|
||||
CONFIG_SPL_SIZE_LIMIT=0x40000
|
||||
CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x100
|
||||
CONFIG_SPL=y
|
||||
CONFIG_SPL_SPI_FLASH_SUPPORT=y
|
||||
CONFIG_SPL_SPI=y
|
||||
CONFIG_ARCH_LA_LOONGSON=y
|
||||
CONFIG_SOC_LS2P500=y
|
||||
CONFIG_CPU_800MHZ=y
|
||||
CONFIG_TARGET_LS2P500_RSJ=y
|
||||
CONFIG_LOONGSON_GENERAL_LOAD=y
|
||||
CONFIG_SPL_PAYLOAD="u-boot.img"
|
||||
CONFIG_PHYS_64BIT=y
|
||||
CONFIG_SYS_LOAD_ADDR=0x9000000098000000
|
||||
CONFIG_STACK_SIZE=0x200000
|
||||
CONFIG_BOOTDELAY=0
|
||||
CONFIG_AUTOBOOT_KEYED=y
|
||||
CONFIG_AUTOBOOT_DELAY_STR="m"
|
||||
CONFIG_AUTOBOOT_STOP_STR="c"
|
||||
CONFIG_USE_BOOTARGS=y
|
||||
CONFIG_BOOTARGS="console=ttyS0,115200 rw noinitrd init=/linuxrc rootfstype=ext4 rootwait"
|
||||
CONFIG_USE_BOOTCOMMAND=y
|
||||
CONFIG_BOOTCOMMAND="setenv bootargs ${bootargs} root=/dev/mmcblk0p${syspart} mtdparts=${mtdparts};ext4load mmc 0 ${loadaddr} /boot/uImage;bootm"
|
||||
CONFIG_LOGLEVEL=7
|
||||
CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
|
||||
# CONFIG_SYS_DEVICE_NULLDEV is not set
|
||||
CONFIG_DISPLAY_BOARDINFO=y
|
||||
CONFIG_BOARD_EARLY_INIT_F=y
|
||||
CONFIG_BOARD_EARLY_INIT_R=y
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_MISC_INIT_R=y
|
||||
CONFIG_SPL_SIZE_LIMIT_SUBTRACT_GD=y
|
||||
CONFIG_SPL_SIZE_LIMIT_SUBTRACT_MALLOC=y
|
||||
CONFIG_SPL_SHOW_ERRORS=y
|
||||
CONFIG_SPL_SYS_MALLOC_SIMPLE=y
|
||||
CONFIG_SPL_STACK_R=y
|
||||
# CONFIG_SPL_BANNER_PRINT is not set
|
||||
CONFIG_SPL_DISPLAY_PRINT=y
|
||||
CONFIG_SPL_MTD_SUPPORT=y
|
||||
CONFIG_SPL_DM_SPI_FLASH=y
|
||||
CONFIG_SPL_POWER=y
|
||||
CONFIG_SPL_SPI_FLASH_MTD=y
|
||||
CONFIG_SPL_SPI_LOAD=y
|
||||
CONFIG_CMD_BOOTMENU=y
|
||||
CONFIG_CMD_EEPROM=y
|
||||
CONFIG_SYS_I2C_EEPROM_ADDR_LEN=2
|
||||
CONFIG_SYS_EEPROM_SIZE=4096
|
||||
CONFIG_SYS_EEPROM_PAGE_WRITE_BITS=4
|
||||
CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=3
|
||||
CONFIG_CMD_MD5SUM=y
|
||||
CONFIG_CMD_GPT=y
|
||||
# CONFIG_RANDOM_UUID is not set
|
||||
CONFIG_CMD_GPT_RENAME=y
|
||||
CONFIG_CMD_MBR=y
|
||||
CONFIG_CMD_MMC=y
|
||||
CONFIG_CMD_MTD=y
|
||||
CONFIG_CMD_POWEROFF=y
|
||||
CONFIG_CMD_SF_TEST=y
|
||||
CONFIG_CMD_USB=y
|
||||
CONFIG_CMD_PING=y
|
||||
CONFIG_CMD_BMP=y
|
||||
CONFIG_CMD_EXT2=y
|
||||
CONFIG_CMD_EXT4=y
|
||||
CONFIG_CMD_EXT4_WRITE=y
|
||||
CONFIG_CMD_FAT=y
|
||||
CONFIG_CMD_FS_GENERIC=y
|
||||
CONFIG_CMD_MTDPARTS=y
|
||||
CONFIG_MTDIDS_DEFAULT="nor0=spi0.0"
|
||||
CONFIG_MTDPARTS_DEFAULT="spi0.0:924k(uboot),32k(uboot_env),4k(bdinfo),56k(dtb),8k(ddr_context)"
|
||||
CONFIG_ISO_PARTITION=y
|
||||
# CONFIG_SPL_EFI_PARTITION is not set
|
||||
CONFIG_OF_LIVE=y
|
||||
CONFIG_OF_BOARD=y
|
||||
CONFIG_OF_SPL_REMOVE_PROPS="interrupt-parent interrupts"
|
||||
CONFIG_ENV_OVERWRITE=y
|
||||
CONFIG_ENV_IS_IN_SPI_FLASH=y
|
||||
CONFIG_ENV_SECT_SIZE_AUTO=y
|
||||
CONFIG_ENV_SPI_MAX_HZ=30000000
|
||||
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
|
||||
CONFIG_VERSION_VARIABLE=y
|
||||
CONFIG_NET_RANDOM_ETHADDR=y
|
||||
CONFIG_BOOTP_SERVERIP=y
|
||||
CONFIG_SPL_DM=y
|
||||
CONFIG_SPL_OF_TRANSLATE=y
|
||||
CONFIG_BUTTON=y
|
||||
CONFIG_BUTTON_GPIO=y
|
||||
CONFIG_DMA=y
|
||||
CONFIG_LOONGSON_DMA=y
|
||||
CONFIG_DM_PCA953X=y
|
||||
CONFIG_LOONGSON_GPIO=y
|
||||
CONFIG_DM_I2C=y
|
||||
CONFIG_SYS_I2C_OCORES=y
|
||||
CONFIG_LED=y
|
||||
CONFIG_LED_BLINK=y
|
||||
CONFIG_LED_GPIO=y
|
||||
CONFIG_MISC=y
|
||||
CONFIG_I2C_EEPROM=y
|
||||
CONFIG_SYS_I2C_EEPROM_ADDR=0x57
|
||||
CONFIG_MMC=y
|
||||
CONFIG_MMC_IO_VOLTAGE=y
|
||||
CONFIG_MMC_UHS_SUPPORT=y
|
||||
CONFIG_MMC_LOONGSON=y
|
||||
CONFIG_MTD=y
|
||||
CONFIG_DM_MTD=y
|
||||
CONFIG_DM_SPI_FLASH=y
|
||||
CONFIG_SF_DEFAULT_SPEED=25000000
|
||||
CONFIG_SPI_FLASH_EON=y
|
||||
CONFIG_SPI_FLASH_GIGADEVICE=y
|
||||
CONFIG_SPI_FLASH_WINBOND=y
|
||||
CONFIG_SPI_FLASH_MTD=y
|
||||
CONFIG_PHY_MARVELL=y
|
||||
CONFIG_PHY_REALTEK=y
|
||||
CONFIG_DM_ETH=y
|
||||
CONFIG_DM_MDIO=y
|
||||
CONFIG_DM_ETH_PHY=y
|
||||
CONFIG_ETH_DESIGNWARE=y
|
||||
CONFIG_RGMII=y
|
||||
CONFIG_MII=y
|
||||
CONFIG_PINCTRL=y
|
||||
CONFIG_PINCTRL_SINGLE=y
|
||||
CONFIG_POWER_DOMAIN=y
|
||||
CONFIG_LOONGSON_POWER_DOMAIN=y
|
||||
CONFIG_DM_REGULATOR=y
|
||||
CONFIG_DM_REGULATOR_GPIO=y
|
||||
CONFIG_RAM=y
|
||||
CONFIG_SPL_RAM=y
|
||||
CONFIG_LOONGSON_DDR=y
|
||||
CONFIG_SERIAL_RX_BUFFER=y
|
||||
CONFIG_SYS_NS16550=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_DM_SPI=y
|
||||
CONFIG_LOONGSON_SPI=y
|
||||
CONFIG_SYSINFO=y
|
||||
CONFIG_SYSINFO_SMBIOS=y
|
||||
CONFIG_USB=y
|
||||
CONFIG_USB_EHCI_HCD=y
|
||||
CONFIG_USB_EHCI_GENERIC=y
|
||||
CONFIG_USB_OHCI_HCD=y
|
||||
CONFIG_USB_OHCI_GENERIC=y
|
||||
CONFIG_USB_DWC2=y
|
||||
CONFIG_USB_STORAGE=y
|
||||
CONFIG_USB_KEYBOARD=y
|
||||
CONFIG_USB_KEYBOARD_FN_KEYS=y
|
||||
CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
CONFIG_VIDEO_LOGO=y
|
||||
CONFIG_BACKLIGHT_GPIO=y
|
||||
CONFIG_SYS_WHITE_ON_BLACK=y
|
||||
CONFIG_VIDCONSOLE_AS_LCD=y
|
||||
CONFIG_VIDEO_LOONGSON=y
|
||||
CONFIG_SPLASH_SCREEN=y
|
||||
CONFIG_SPLASHIMAGE_GUARD=y
|
||||
CONFIG_SPLASH_SCREEN_ALIGN=y
|
||||
CONFIG_BMP_16BPP=y
|
||||
CONFIG_BMP_24BPP=y
|
||||
CONFIG_BMP_32BPP=y
|
||||
CONFIG_FAT_WRITE=y
|
||||
CONFIG_BCH=y
|
||||
CONFIG_PANIC_HANG=y
|
||||
CONFIG_LMB=y
|
||||
@@ -477,6 +477,23 @@ config SYS_I2C_SANDBOX
|
||||
Enable I2C support for sandbox. This is an emulation of a real I2C
|
||||
bus. Devices can be attached to the bus using the device tree
|
||||
which specifies the driver to use. See sandbox.dts as an example.
|
||||
config SYS_I2C_LOONGSON
|
||||
bool "LoongSon I2C driver"
|
||||
depends on DM_I2C
|
||||
default y
|
||||
help
|
||||
Enable I2C support for sandbox. This is an emulation of a real I2C
|
||||
bus. Devices can be attached to the bus using the device tree
|
||||
which specifies the driver to use. See sandbox.dts as an example.
|
||||
|
||||
config SPL_SYS_I2C_LOONGSON
|
||||
bool "LoongSon I2C driver (SPL)"
|
||||
depends on SPL && DM_I2C
|
||||
default y
|
||||
help
|
||||
Enable I2C support for sandbox. This is an emulation of a real I2C
|
||||
bus. Devices can be attached to the bus using the device tree
|
||||
which specifies the driver to use. See sandbox.dts as an example.
|
||||
|
||||
config SYS_I2C_SH
|
||||
bool "Legacy SuperH I2C interface"
|
||||
|
||||
@@ -52,6 +52,7 @@ obj-$(CONFIG_SYS_I2C_UNIPHIER) += i2c-uniphier.o
|
||||
obj-$(CONFIG_SYS_I2C_UNIPHIER_F) += i2c-uniphier-f.o
|
||||
obj-$(CONFIG_SYS_I2C_VERSATILE) += i2c-versatile.o
|
||||
obj-$(CONFIG_SYS_I2C_XILINX_XIIC) += xilinx_xiic.o
|
||||
obj-$(CONFIG_SYS_I2C_LOONGSON) += lsfs_i2c.o
|
||||
obj-$(CONFIG_TEGRA186_BPMP_I2C) += tegra186_bpmp_i2c.o
|
||||
|
||||
obj-$(CONFIG_$(SPL_)I2C_MUX) += muxes/
|
||||
|
||||
@@ -0,0 +1,406 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Simulate an I2C port
|
||||
*
|
||||
* Copyright (c) 2014 Google, Inc
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <errno.h>
|
||||
#include <i2c.h>
|
||||
#include <log.h>
|
||||
#include <linux/iopoll.h>
|
||||
#include <linux/delay.h>
|
||||
#include <asm/io.h>
|
||||
#include <dm/acpi.h>
|
||||
#include <dm/lists.h>
|
||||
#include <dm/device-internal.h>
|
||||
|
||||
/* Loongson I2C offset registers */
|
||||
#define I2C_CR1 0x00
|
||||
#define I2C_CR2 0x04
|
||||
#define I2C_DR 0x10
|
||||
#define I2C_SR1 0x14
|
||||
#define I2C_SR2 0x18
|
||||
#define I2C_CCR 0x1C
|
||||
#define I2C_TRISE 0x20
|
||||
#define I2C_FLTR 0x24
|
||||
|
||||
/* Loongson I2C control 1*/
|
||||
#define I2C_CR1_POS BIT(11)
|
||||
#define I2C_CR1_ACK BIT(10)
|
||||
#define I2C_CR1_STOP BIT(9)
|
||||
#define I2C_CR1_START BIT(8)
|
||||
#define I2C_CR1_PE BIT(0)
|
||||
|
||||
/* Loongson I2C control 2 */
|
||||
#define I2C_CR2_FREQ_MASK GENMASK(5, 0)
|
||||
#define I2C_CR2_FREQ(n) ((n) & I2C_CR2_FREQ_MASK)
|
||||
#define I2C_CR2_ITBUFEN BIT(10)
|
||||
#define I2C_CR2_ITEVTEN BIT(9)
|
||||
#define I2C_CR2_ITERREN BIT(8)
|
||||
#define I2C_CR2_IRQ_MASK (I2C_CR2_ITBUFEN | \
|
||||
I2C_CR2_ITEVTEN | \
|
||||
I2C_CR2_ITERREN)
|
||||
|
||||
/* Loongson I2C Status 1 */
|
||||
#define I2C_SR1_AF BIT(10)
|
||||
#define I2C_SR1_ARLO BIT(9)
|
||||
#define I2C_SR1_BERR BIT(8)
|
||||
#define I2C_SR1_TXE BIT(7)
|
||||
#define I2C_SR1_RXNE BIT(6)
|
||||
#define I2C_SR1_BTF BIT(2)
|
||||
#define I2C_SR1_ADDR BIT(1)
|
||||
#define I2C_SR1_SB BIT(0)
|
||||
#define I2C_SR1_ITEVTEN_MASK (I2C_SR1_BTF | \
|
||||
I2C_SR1_ADDR | \
|
||||
I2C_SR1_SB)
|
||||
#define I2C_SR1_ITBUFEN_MASK (I2C_SR1_TXE | \
|
||||
I2C_SR1_RXNE)
|
||||
#define I2C_SR1_ITERREN_MASK (I2C_SR1_AF | \
|
||||
I2C_SR1_ARLO | \
|
||||
I2C_SR1_BERR)
|
||||
|
||||
/* Loongson I2C Status 2 */
|
||||
#define I2C_SR2_BUSY BIT(1)
|
||||
|
||||
/* Loongson I2C Control Clock */
|
||||
#define I2C_CCR_FS BIT(15)
|
||||
#define I2C_CCR_DUTY BIT(14)
|
||||
|
||||
enum ls_i2c_speed {
|
||||
LS_I2C_SPEED_STANDARD, /* 100 kHz */
|
||||
LS_I2C_SPEED_FAST, /* 400 kHz */
|
||||
};
|
||||
|
||||
/**
|
||||
* struct priv_msg - client specific data
|
||||
* @addr: 8-bit slave addr, including r/w bit
|
||||
* @count: number of bytes to be transferred
|
||||
* @buf: data buffer
|
||||
* @stop: last I2C msg to be sent, i.e. STOP to be generated
|
||||
* @result: result of the transfer
|
||||
*/
|
||||
struct priv_msg {
|
||||
u8 addr;
|
||||
u32 count;
|
||||
u8 *buf;
|
||||
bool stop;
|
||||
int result;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ls_i2c_dev - private data of the controller
|
||||
* @adap: I2C adapter for this controller
|
||||
* @dev: device for this controller
|
||||
* @base: virtual memory area
|
||||
* @complete: completion of I2C message
|
||||
* @speed: Standard or Fast are supported
|
||||
* @msg: I2C transfer information
|
||||
*/
|
||||
struct ls_i2c_dev {
|
||||
struct device *dev;
|
||||
void __iomem *base;
|
||||
int speed;
|
||||
struct priv_msg msg;
|
||||
};
|
||||
static inline void i2c_set_bits(void __iomem *reg, u32 mask)
|
||||
{
|
||||
writel(readl(reg) | mask, reg);
|
||||
}
|
||||
|
||||
static inline void i2c_clr_bits(void __iomem *reg, u32 mask)
|
||||
{
|
||||
writel(readl(reg) & ~mask, reg);
|
||||
}
|
||||
static void ls_i2c_write_byte(struct ls_i2c_dev *i2c_dev, u8 byte)
|
||||
{
|
||||
writel(byte, i2c_dev->base + I2C_DR);
|
||||
}
|
||||
|
||||
static void ls_i2c_read_msg(struct ls_i2c_dev *i2c_dev)
|
||||
{
|
||||
struct priv_msg *msg = &i2c_dev->msg;
|
||||
|
||||
*msg->buf++ = readl(i2c_dev->base + I2C_DR);
|
||||
msg->count--;
|
||||
}
|
||||
|
||||
static void ls_i2c_terminate_xfer(struct ls_i2c_dev *i2c_dev)
|
||||
{
|
||||
struct priv_msg *msg = &i2c_dev->msg;
|
||||
|
||||
i2c_set_bits(i2c_dev->base + I2C_CR1, (1 << (8 + msg->stop)));
|
||||
}
|
||||
|
||||
static void ls_i2c_handle_write(struct ls_i2c_dev *i2c_dev)
|
||||
{
|
||||
struct priv_msg *msg = &i2c_dev->msg;
|
||||
|
||||
udelay(150);
|
||||
|
||||
if (msg->count) {
|
||||
ls_i2c_write_byte(i2c_dev, *msg->buf++);
|
||||
msg->count--;
|
||||
if (!msg->count) {
|
||||
ls_i2c_terminate_xfer(i2c_dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ls_i2c_handle_read(struct ls_i2c_dev *i2c_dev, int flag)
|
||||
{
|
||||
struct priv_msg *msg = &i2c_dev->msg;
|
||||
void __iomem *reg = i2c_dev->base + I2C_CR1;
|
||||
int i;
|
||||
|
||||
udelay(150); //When SR1 is set up, the data is not immediately ready
|
||||
|
||||
switch (msg->count) {
|
||||
case 1:
|
||||
/* only transmit 1 bytes condition */
|
||||
ls_i2c_read_msg(i2c_dev);
|
||||
break;
|
||||
case 2:
|
||||
if (flag != 1) {
|
||||
/* ensure only transmit 2 bytes condition */
|
||||
break;
|
||||
}
|
||||
i2c_set_bits(i2c_dev->base + I2C_CR1, (1 << (8 + msg->stop)));
|
||||
|
||||
|
||||
for (i = 2; i > 0; i--)
|
||||
ls_i2c_read_msg(i2c_dev);
|
||||
|
||||
i2c_clr_bits(i2c_dev->base + I2C_CR1, I2C_CR1_POS);
|
||||
break;
|
||||
case 3:
|
||||
if (readl(i2c_dev->base + I2C_CR2) & I2C_CR2_ITBUFEN) {
|
||||
break;
|
||||
}
|
||||
i2c_clr_bits(reg, I2C_CR1_ACK);
|
||||
default:
|
||||
ls_i2c_read_msg(i2c_dev);
|
||||
}
|
||||
}
|
||||
|
||||
static inline u8 i2c_8bit_addr_from_msg(const struct i2c_msg *msg)
|
||||
{
|
||||
return (msg->addr << 1) | (msg->flags & I2C_M_RD ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
#define INPUT_REF_CLK (REF_FREQ * 1000000)
|
||||
|
||||
static int ls_i2c_hw_config(struct ls_i2c_dev *i2c_dev)
|
||||
{
|
||||
u32 val;
|
||||
u32 ccr = 0;
|
||||
|
||||
/* reference clock determination the cnfigure val(0x3f) */
|
||||
i2c_set_bits(i2c_dev->base + I2C_CR2, 0x3f);
|
||||
i2c_set_bits(i2c_dev->base + I2C_TRISE, 0x3f);
|
||||
|
||||
if (i2c_dev->speed == LS_I2C_SPEED_STANDARD) {
|
||||
val = DIV_ROUND_UP(INPUT_REF_CLK, 100000 * 2);
|
||||
} else {
|
||||
val = DIV_ROUND_UP(INPUT_REF_CLK, 400000 * 3);
|
||||
|
||||
/* Select Fast mode */
|
||||
ccr |= I2C_CCR_FS;
|
||||
}
|
||||
ccr |= val & 0xfff;
|
||||
writel(ccr, i2c_dev->base + I2C_CCR);
|
||||
|
||||
/* Enable I2C */
|
||||
writel(I2C_CR1_PE, i2c_dev->base + I2C_CR1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int ls_i2c_wait_free_bus(struct ls_i2c_dev *i2c_dev)
|
||||
{
|
||||
u32 status;
|
||||
int ret;
|
||||
ret = readl_poll_timeout(i2c_dev->base + I2C_SR2, status, !(status & I2C_SR2_BUSY), 1000);
|
||||
if (ret) {
|
||||
ret = -EBUSY;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* ls_i2c_handle_rx_addr()
|
||||
* master receiver
|
||||
* @i2c_dev: Controller's private data
|
||||
*/
|
||||
static void ls_i2c_handle_rx_addr(struct ls_i2c_dev *i2c_dev)
|
||||
{
|
||||
struct priv_msg *msg = &i2c_dev->msg;
|
||||
|
||||
switch (msg->count) {
|
||||
case 0:
|
||||
ls_i2c_terminate_xfer(i2c_dev);
|
||||
break;
|
||||
case 1:
|
||||
i2c_clr_bits(i2c_dev->base + I2C_CR1,
|
||||
(I2C_CR1_ACK | I2C_CR1_POS));
|
||||
/* start or stop */
|
||||
i2c_set_bits(i2c_dev->base + I2C_CR1, (1 << (8 + msg->stop)));
|
||||
break;
|
||||
case 2:
|
||||
i2c_clr_bits(i2c_dev->base + I2C_CR1, I2C_CR1_ACK);
|
||||
i2c_set_bits(i2c_dev->base + I2C_CR1, I2C_CR1_POS);
|
||||
break;
|
||||
|
||||
default:
|
||||
i2c_set_bits(i2c_dev->base + I2C_CR1, I2C_CR1_ACK);
|
||||
i2c_clr_bits(i2c_dev->base + I2C_CR1, I2C_CR1_POS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static u32 ls_i2c_isr_error(u32 status, void *data)
|
||||
{
|
||||
struct ls_i2c_dev *i2c_dev = data;
|
||||
struct priv_msg *msg = &i2c_dev->msg;
|
||||
|
||||
/* Arbitration lost */
|
||||
if (status & I2C_SR1_ARLO) {
|
||||
i2c_clr_bits(i2c_dev->base + I2C_SR1, I2C_SR1_ARLO);
|
||||
msg->result = -EAGAIN;
|
||||
}
|
||||
|
||||
/*
|
||||
* Acknowledge failure:
|
||||
* In master transmitter mode a Stop must be generated by software
|
||||
*/
|
||||
if (status & I2C_SR1_AF) {
|
||||
i2c_set_bits(i2c_dev->base + I2C_CR1, I2C_CR1_STOP);
|
||||
i2c_clr_bits(i2c_dev->base + I2C_SR1, I2C_SR1_AF);
|
||||
msg->result = -ENODEV;
|
||||
}
|
||||
|
||||
/* Bus error */
|
||||
if (status & I2C_SR1_BERR) {
|
||||
i2c_clr_bits(i2c_dev->base + I2C_SR1, I2C_SR1_BERR);
|
||||
msg->result = -EIO;
|
||||
}
|
||||
|
||||
|
||||
return msg->result;
|
||||
}
|
||||
static int ls_i2c_wait_flags(struct ls_i2c_dev *i2c_dev,u32 flags, u32 *status)
|
||||
{
|
||||
static volatile u32 timeout = 1000000;
|
||||
*status = readl(i2c_dev->base + I2C_SR1);
|
||||
while(!(*status & flags)) {
|
||||
if(!timeout)
|
||||
return -ETIMEDOUT;
|
||||
*status = readl(i2c_dev->base + I2C_SR1);
|
||||
timeout--;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int ls_i2c_xfer_msg(struct ls_i2c_dev *i2c_dev,struct i2c_msg *msg, bool is_stop)
|
||||
{
|
||||
struct priv_msg *priv_msg = &i2c_dev->msg;
|
||||
int ret, i;
|
||||
u32 status, event, mask;
|
||||
priv_msg->addr = i2c_8bit_addr_from_msg(msg);
|
||||
priv_msg->buf = msg->buf;
|
||||
priv_msg->count = msg->len;
|
||||
priv_msg->stop = is_stop;
|
||||
priv_msg->result = 0;
|
||||
mask = I2C_SR1_SB;
|
||||
ls_i2c_wait_flags(i2c_dev, mask, &status);
|
||||
|
||||
ls_i2c_write_byte(i2c_dev, priv_msg->addr);
|
||||
mask = I2C_SR1_TXE | I2C_SR1_RXNE | I2C_SR1_BTF | I2C_SR1_ADDR | I2C_SR1_ITERREN_MASK;
|
||||
/*start*/
|
||||
do {
|
||||
ret = ls_i2c_wait_flags(i2c_dev, mask, &status);
|
||||
if (ret)
|
||||
printf("wait timeout\n:");
|
||||
if(status & (I2C_SR1_ARLO | I2C_SR1_AF | I2C_SR1_BERR)) {
|
||||
return ls_i2c_isr_error(status, i2c_dev);
|
||||
}
|
||||
event = status;
|
||||
|
||||
/* I2C Address sent */
|
||||
if (event & I2C_SR1_ADDR) {
|
||||
if (priv_msg->addr & I2C_M_RD)
|
||||
ls_i2c_handle_rx_addr(i2c_dev);
|
||||
if (priv_msg->count == 0)
|
||||
ls_i2c_terminate_xfer(i2c_dev);
|
||||
|
||||
/* Clear ADDR flag */
|
||||
readl(i2c_dev->base + I2C_SR2);
|
||||
}
|
||||
|
||||
if (priv_msg->addr & I2C_M_RD) {
|
||||
/* RX */
|
||||
if (event & 0x40)
|
||||
ls_i2c_handle_read(i2c_dev, 0);
|
||||
if (event & 0x4)
|
||||
ls_i2c_handle_read(i2c_dev, 1);
|
||||
} else {
|
||||
/* TX */
|
||||
if (event & 0x84)
|
||||
for (i = 0; i < 1 + !!((event & 0x84) == 0x84); i++)
|
||||
ls_i2c_handle_write(i2c_dev);
|
||||
}
|
||||
|
||||
} while (priv_msg->count);
|
||||
|
||||
ret = priv_msg->result;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lsfs_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, int num)
|
||||
{
|
||||
struct ls_i2c_dev *i2c_dev = dev_get_priv(bus);
|
||||
int ret, i;
|
||||
ret = ls_i2c_wait_free_bus(i2c_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* START generation */
|
||||
i2c_set_bits(i2c_dev->base + I2C_CR1, I2C_CR1_START);
|
||||
|
||||
for (i = 0; i < num && !ret; i++)
|
||||
ret = ls_i2c_xfer_msg(i2c_dev, &msg[i], i == num - 1);
|
||||
|
||||
return (ret < 0) ? ret : 0;
|
||||
}
|
||||
|
||||
static int lsfs_i2c_probe(struct udevice *bus)
|
||||
{
|
||||
struct ls_i2c_dev *i2c_dev = dev_get_priv(bus);
|
||||
|
||||
i2c_dev->base = PHYS_TO_UNCACHED(dev_read_addr_ptr(bus));
|
||||
i2c_dev->speed = LS_I2C_SPEED_STANDARD;
|
||||
ls_i2c_hw_config(i2c_dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct dm_i2c_ops lsfs_i2c_ops = {
|
||||
.xfer = lsfs_i2c_xfer,
|
||||
};
|
||||
|
||||
static const struct udevice_id lsfs_i2c_ids[] = {
|
||||
{ .compatible = "loongson,lsfs-i2c" },
|
||||
{ }
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(lsfs_i2c) = {
|
||||
.name = "lsfs_i2c",
|
||||
.id = UCLASS_I2C,
|
||||
.of_match = lsfs_i2c_ids,
|
||||
.probe = lsfs_i2c_probe,
|
||||
.ops = &lsfs_i2c_ops,
|
||||
.priv_auto = sizeof(struct ls_i2c_dev),
|
||||
};
|
||||
@@ -14,9 +14,8 @@
|
||||
#define mem_debug(s...)
|
||||
#endif
|
||||
|
||||
#define DTB_OFFSET 0xF0000 /* (1024K - 64K) dtb start offset*/
|
||||
#define DTB_DIMM_INFO_OFFS 0xF000 // start from DTB 60K
|
||||
#define DIMM_INFO_IN_FLASH_OFFS (PHYS_TO_UNCACHED(0x1c000000) + DTB_OFFSET + DTB_DIMM_INFO_OFFS)
|
||||
#define DDR_CONTEXT_OFF 0xFE000 // (1024k - 8k) ddr_context
|
||||
#define DIMM_INFO_IN_FLASH_OFFS (PHYS_TO_UNCACHED(0x1c000000) + DDR_CONTEXT_OFF)
|
||||
|
||||
#define USE_DDR_1TMODE
|
||||
#define MC_PER_NODE 1
|
||||
|
||||
@@ -81,6 +81,12 @@ config WDT
|
||||
What exactly happens when the timer expires is up to a particular
|
||||
device/driver.
|
||||
|
||||
config WDT_LS2X
|
||||
bool "loongson 2x soc watchdog timer support"
|
||||
depends on WDT
|
||||
help
|
||||
Enable support for the watchdog timer on loongson 2x SoCs.
|
||||
|
||||
config WDT_APPLE
|
||||
bool "Apple watchdog timer support"
|
||||
depends on WDT
|
||||
|
||||
@@ -41,3 +41,4 @@ obj-$(CONFIG_WDT_STM32MP) += stm32mp_wdt.o
|
||||
obj-$(CONFIG_WDT_SUNXI) += sunxi_wdt.o
|
||||
obj-$(CONFIG_WDT_TANGIER) += tangier_wdt.o
|
||||
obj-$(CONFIG_WDT_XILINX) += xilinx_wwdt.o
|
||||
obj-$(CONFIG_WDT_LS2X) += ls2x_wdt.o
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* loongson 2x soc built-in hardware watchdog timer
|
||||
*
|
||||
* Copyright (C) 2024 qujintao <qujintao@loongson.cn>
|
||||
*
|
||||
* Based on the Linux driver version which is:
|
||||
* mt7621_wdt.c
|
||||
*/
|
||||
|
||||
#include <clk.h>
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <wdt.h>
|
||||
#include <asm/global_data.h>
|
||||
#include <linux/io.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
struct ls2x_wdt {
|
||||
void __iomem *regs;
|
||||
unsigned int clk_rate;
|
||||
};
|
||||
|
||||
#define LS2X_WDT_RESET_REG 0x0
|
||||
#define LS2X_WDT_SET_REG 0x4
|
||||
#define LS2X_WDT_TIMER_REG 0x8
|
||||
|
||||
#define LS2X_WDT_ENABLE (0x1 << 1)
|
||||
#define LS2X_WDT_RESTART 0x1
|
||||
|
||||
static int ls2x_wdt_stop(struct udevice *dev);
|
||||
|
||||
static int ls2x_wdt_ping(struct ls2x_wdt *priv)
|
||||
{
|
||||
writel(LS2X_WDT_RESTART, priv->regs + LS2X_WDT_SET_REG);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ls2x_wdt_start(struct udevice *dev, u64 ms, ulong flags)
|
||||
{
|
||||
unsigned int temp;
|
||||
unsigned int value;
|
||||
u64 max_ms;
|
||||
u64 real_ms;
|
||||
struct ls2x_wdt *priv = dev_get_priv(dev);
|
||||
|
||||
if (!ms)
|
||||
return 0;
|
||||
|
||||
ls2x_wdt_stop(dev);
|
||||
|
||||
max_ms = (unsigned int)(0xffffffff) / priv->clk_rate;
|
||||
max_ms *= 1000;
|
||||
|
||||
real_ms = (max_ms <= ms) ? max_ms : ms;
|
||||
|
||||
value = (real_ms) * (priv->clk_rate / 1000);
|
||||
/* set the prescaler to 1ms == 1000us */
|
||||
writel(value, priv->regs + LS2X_WDT_TIMER_REG);
|
||||
|
||||
temp = readl(priv->regs + LS2X_WDT_RESET_REG);
|
||||
temp |= LS2X_WDT_ENABLE;
|
||||
writel(temp, priv->regs + LS2X_WDT_RESET_REG);
|
||||
|
||||
ls2x_wdt_ping(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ls2x_wdt_stop(struct udevice *dev)
|
||||
{
|
||||
unsigned int temp;
|
||||
struct ls2x_wdt *priv = dev_get_priv(dev);
|
||||
|
||||
ls2x_wdt_ping(priv);
|
||||
|
||||
temp = readl(priv->regs + LS2X_WDT_RESET_REG);
|
||||
temp |= LS2X_WDT_ENABLE;
|
||||
temp ^= LS2X_WDT_ENABLE;
|
||||
writel(temp, priv->regs + LS2X_WDT_RESET_REG);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ls2x_wdt_reset(struct udevice *dev)
|
||||
{
|
||||
struct ls2x_wdt *priv = dev_get_priv(dev);
|
||||
|
||||
ls2x_wdt_ping(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ls2x_wdt_probe(struct udevice *dev)
|
||||
{
|
||||
struct clk clk;
|
||||
struct ls2x_wdt *priv = dev_get_priv(dev);
|
||||
int ret;
|
||||
|
||||
priv->regs = dev_remap_addr(dev);
|
||||
if (!priv->regs)
|
||||
return -EINVAL;
|
||||
|
||||
ret = clk_get_by_index(dev, 0, &clk);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = clk_enable(&clk);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
priv->clk_rate = clk_get_rate(&clk);
|
||||
|
||||
ls2x_wdt_stop(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct wdt_ops ls2x_wdt_ops = {
|
||||
.start = ls2x_wdt_start,
|
||||
.reset = ls2x_wdt_reset,
|
||||
.stop = ls2x_wdt_stop,
|
||||
};
|
||||
|
||||
static const struct udevice_id ls2x_wdt_ids[] = {
|
||||
{ .compatible = "loongson,ls2x-wdt" },
|
||||
{}
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(ls2x_wdt) = {
|
||||
.name = "ls2x_wdt",
|
||||
.id = UCLASS_WDT,
|
||||
.of_match = ls2x_wdt_ids,
|
||||
.probe = ls2x_wdt_probe,
|
||||
.priv_auto = sizeof(struct ls2x_wdt),
|
||||
.ops = &ls2x_wdt_ops,
|
||||
};
|
||||
@@ -54,8 +54,10 @@
|
||||
|
||||
/* LS SATA configuration */
|
||||
#if defined(CONFIG_LOONGSON_AHCI)
|
||||
#ifndef CONFIG_LOONGSON_RECOVER
|
||||
#define CONFIG_LOONGSON_RECOVER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Miscellaneous configuration options */
|
||||
#define CONFIG_SYS_BOOTM_LEN (64 << 20)
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#define RD_ADDR 0x9000000007000000
|
||||
#elif defined(CONFIG_SOC_LS2K1000)
|
||||
#define RD_ADDR 0x9000000090040000
|
||||
#elif defined(CONFIG_SOC_LS2K300)
|
||||
#define RD_ADDR 0x9000000007000000
|
||||
#endif
|
||||
|
||||
#if RD_ADDR >= LOCK_CACHE_BASE && RD_ADDR < (LOCK_CACHE_BASE + LOCK_CACHE_SIZE)
|
||||
@@ -39,9 +41,10 @@
|
||||
"bootmenu_1=Update kernel=updatemenu kernel 1\0" \
|
||||
"bootmenu_2=Update rootfs=updatemenu rootfs 1\0" \
|
||||
"bootmenu_3=Update u-boot=updatemenu uboot 1\0" \
|
||||
"bootmenu_4=Update ALL=updatemenu all 1\0" \
|
||||
"bootmenu_5=System install or recover=updatemenu system 1\0" \
|
||||
"bootmenu_6=Board product=updatemenu product 1\0"
|
||||
"bootmenu_4=Update dtb=updatemenu dtb 1\0" \
|
||||
"bootmenu_5=Update ALL=updatemenu all 1\0" \
|
||||
"bootmenu_6=System install or recover=updatemenu system 1\0" \
|
||||
"bootmenu_7=Board product=updatemenu product 1\0"
|
||||
|
||||
#if !defined(CONFIG_DM_VIDEO) || !defined(CONFIG_VIDEO)
|
||||
#define LOONGSON_BOOTMENU_VIDEO \
|
||||
@@ -90,11 +93,15 @@ RECOVER_FRONT_BOOTARGS "setenv bootargs ${bootargs} ins_way=usb;" RECOVER_START
|
||||
#define RECOVER_MMC_DEFAULT "mmc rescan;fatload mmc 0:1 ${loadaddr} /install/uImage;fatload mmc 0:1 ${rd_start} /install/ramdisk.gz;"\
|
||||
RECOVER_FRONT_BOOTARGS "setenv bootargs ${bootargs} ins_way=mmc;" RECOVER_START
|
||||
|
||||
#define RECOVER_TFTP_DOWNLOAD_CMD "tftpboot ${loadaddr} uImage;tftpboot ${rd_start} ramdisk.gz;"
|
||||
|
||||
#define RECOVER_TFTP_DEFAULT "tftpboot ${loadaddr} uImage;tftpboot ${rd_start} ramdisk.gz;"\
|
||||
RECOVER_FRONT_BOOTARGS "setenv bootargs ${bootargs} ins_way=tftp u_ip=${ipaddr} u_sip=${serverip};" RECOVER_START
|
||||
RECOVER_FRONT_BOOTARGS "setenv bootargs ${bootargs} ins_way=tftp ins_target=mmc u_ip=${ipaddr} u_sip=${serverip};" RECOVER_START
|
||||
|
||||
#define RECOVER_DHCP_DOWNLOAD_CMD "dhcp ${loadaddr} uImage;dhcp ${rd_start} ramdisk.gz;"
|
||||
|
||||
#define RECOVER_DHCP_DEFAULT "dhcp ${loadaddr} uImage;dhcp ${rd_start} ramdisk.gz;"\
|
||||
RECOVER_FRONT_BOOTARGS "setenv bootargs ${bootargs} ins_way=tftp u_ip=${ipaddr} u_sip=${serverip};" RECOVER_START
|
||||
RECOVER_FRONT_BOOTARGS "setenv bootargs ${bootargs} ins_way=tftp ins_target=mmc u_ip=${ipaddr} u_sip=${serverip};" RECOVER_START
|
||||
|
||||
#ifdef CONFIG_LINUX_KERNEL_LOG_CLOSE
|
||||
#define LINUX_KERNEL_LOG_LEVEL_SETUP " loglevel=0"
|
||||
@@ -116,16 +123,16 @@ saveenv;"
|
||||
|
||||
#define BOOT_NAND_DEFAULT NAND_BOOT_ENV"boot"
|
||||
|
||||
#define EMMC_BOOT_ENV "setenv bootargs " CMDLINE_CONSOLE LINUX_KERNEL_LOG_LEVEL_SETUP " root=/dev/mmcblk0 noinitrd init=/linuxrc rootfstype=ext4 rw rootwait; \
|
||||
setenv bootcmd ' setenv bootargs ${bootargs} mtdparts=${mtdparts} fbcon=rotate:${rotate} panel=${panel}; \
|
||||
ext4load mmc 0 ${loadaddr} /boot/uImage;bootm ';\
|
||||
#define EMMC_BOOT_ENV "setenv bootargs " CMDLINE_CONSOLE LINUX_KERNEL_LOG_LEVEL_SETUP " noinitrd init=/sbin/init rootfstype=ext4 rw rootwait; \
|
||||
setenv bootcmd ' setenv bootargs ${bootargs} root=/dev/mmcblk0p${syspart} mtdparts=${mtdparts} fbcon=rotate:${rotate} panel=${panel}; \
|
||||
ext4load mmc 0:1 ${loadaddr} /boot/uImage;bootm ';\
|
||||
saveenv;"
|
||||
|
||||
#define BOOT_EMMC_DEFAULT EMMC_BOOT_ENV"boot"
|
||||
|
||||
#define SDCARD_BOOT_ENV "setenv bootargs " CMDLINE_CONSOLE LINUX_KERNEL_LOG_LEVEL_SETUP " root=/dev/mmcblk1 noinitrd init=/linuxrc rootfstype=ext4 rw rootwait; \
|
||||
setenv bootcmd ' setenv bootargs ${bootargs} mtdparts=${mtdparts} fbcon=rotate:${rotate} panel=${panel}; \
|
||||
ext4load mmc 1 ${loadaddr} /boot/uImage;bootm ';\
|
||||
#define SDCARD_BOOT_ENV "setenv bootargs " CMDLINE_CONSOLE LINUX_KERNEL_LOG_LEVEL_SETUP " noinitrd init=/sbin/init rootfstype=ext4 rw rootwait; \
|
||||
setenv bootcmd ' setenv bootargs ${bootargs} root=/dev/mmcblk1p${syspart} mtdparts=${mtdparts} fbcon=rotate:${rotate} panel=${panel}; \
|
||||
ext4load mmc 1:1 ${loadaddr} /boot/uImage;bootm ';\
|
||||
saveenv;"
|
||||
|
||||
#define BOOT_SDCARD_DEFAULT SDCARD_BOOT_ENV"boot"
|
||||
@@ -138,9 +145,8 @@ boot"
|
||||
saveenv;\
|
||||
boot"
|
||||
|
||||
#ifdef CONFIG_AHCI
|
||||
/* use ab system mode */
|
||||
#define LS_DOUBLE_SYSTEM
|
||||
#endif
|
||||
|
||||
#define CONFIG_EXTRA_ENV_SETTINGS \
|
||||
CONSOLE_STDOUT_SETTINGS \
|
||||
|
||||
@@ -56,4 +56,6 @@ void fputc(int file, const char c);
|
||||
int ftstc(int file);
|
||||
int fgetc(int file);
|
||||
|
||||
int print_enable_setup(int enable);
|
||||
|
||||
#endif /* __STDIO_H */
|
||||
|
||||
Reference in New Issue
Block a user