Skip to content
Snippets Groups Projects
Commit 3438a96d authored by joachim.schmidt's avatar joachim.schmidt
Browse files

Transitional commitment for the management of the UBIFS file system.

parent 024e556b
No related branches found
No related tags found
No related merge requests found
Showing
with 1526 additions and 147 deletions
Howto.md 0 → 100644
```
$ source ${PETALINUXENV}
```
```
$ petalinux-create --type project --template zynq --name scalp_safe_petalinux
```
```
$ petalinux-config --get-hw-description=${HOME}/Documents/Projets/Hepia/scalp_project/scalp_firmware/designs/vivado/scalp_safe_firmware/2020.2/lin64/scalp_safe_firmware/scalp_safe_firmware.xsa --silentconfig
```
```
$ cd <PETALINUX_PROJECT_DIR>/project-spec/meta-user/recipes-bsp/
$ mkdir fsbl
```
```
$ cd fsbl
$ touch fsbl_%.bbappend
$ echo -e "XSCTH_BUILD_DEBUG = \"1\"\nYAML_COMPILER_FLAGS_append = \" -DFSBL_DEBUG_INFO\"" > fsbl_%.bbappend
```
```
$ emacs -nw <PETALINUX_PROJECT_DIR>/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
```
```
$ touch <PETALINUX_PROJECT_DIR>/project-spec/meta-user/recipes-bsp/u-boot/files/eeprom.cfg
$ $ echo -e "CONFIG_I2C_EEPROM=y\nCONFIG_SYS_I2C_EEPROM_ADDR=0x53\nCONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW=0x0\nCONFIG_SYS_TEXT_BASE=0x10080000\nCONFIG_ZYNQ_GEM_I2C_MAC_OFFSET=0xfa" > eeprom.cfg
$ cd <PETALINUX_PROJECT_DIR>/project-spec/meta-user/recipes-bsp/u-boot/
$ echo -e "\nSRC_URI += \"file://eeprom.cfg\"" >> u-boot-xlnx_%.bbappend
```
U-Boot SPI
petalinux-package --boot --fsbl <FSBL image> --fpga <FPGA bitstream> --u-boot --kernel
(0xD20000) Default DTB pickup address
Logging --->
[*] Enable logging support
API --->
[*] Enable U-Boot API
Boot media --->
[*] Support for booting from QSPI flash
[*] Support for booting from SPI flash
Device Drivers ---> ***********
MTD Support --->
SPI Flash Support --->
[*] SPI Flash MTD support
Device Drivers --->
-*- SPI Support --->
[*] Xilinx SPI driver
Device Drivers --->
[*] Network device support --->
[*] Enable RGMII
File systems --->
[*] Enable JFFS2 filesystem support
Device Drivers --->
MTD Support --->
UBI support --->
[*] Enable UBI - Unsorted block images
Command line interface --->
(ScalpZynq> ) Shell prompt
Info commands --->
[*] config
[*] license
Boot commands --->
[ ] Support booting Plan9 OS images
[ ] Support booting RTEMS OS images
[ ] Support booting VxWorks OS images
Environment commands --->
[*] search env
[*] eraseenv
[*] env flags -print variables that have non-default flags
[*] env info - print or evaluate environment information
Memory commands --->
[*] eeprom - EEPROM subsystem
[*] Enable layout-aware eeprom commands
[*] meminfo
[*] mdc, mwc *
Device access commands --->
[*] fpga loads - loads secure bitstreams (Xilinx only)
[*] mtd
Shell scripting commands --->
[*] setexpr
Command line interface --->
[*] Enable UBI - Unsorted block images commands
[*] Enable UBIFS - Unsorted block images filesystem commands (NEW)
Device Drivers --->
Multifunction device drivers --->
[*] Enable driver for generic I2C-attached EEPROMs
(0xfa) Set the I2C MAC offset
(0x53) Chip address of the EEPROM device
```
echo -e "\nSRC_URI += \"file://scalp_uboot.cfg\"" >> u-boot-xlnx_%.bbappend
```
In 2020.2 what ever changes done in 'petalinux-config -c kernel' those will store in <project-dir>/components/yocto/workspace/sources/linux-xlnx" directory. To add this configs into meta-user/recipies-kernel run the 'petalinux-devtool finish linux-xlnx <project-dir>/project-spec/meta-user -f' so that the version control will work on repo.
petalinux-devtool finish linux-xlnx ./project-spec/meta-user/ -f
petalinux-devtool finish linux-xlnx /home/jo/Documents/Projets/Hepia/scalp_project/scalp_petalinux/scalp_safe_petalinux/project-spec/meta-user/ -f
petalinux-devtool finish u-boot /home/jo/Documents/Projets/Hepia/scalp_project/scalp_petalinux/scalp_safe_petalinux/project-spec/meta-user/ -f
petalinux-package --boot --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system.bit --u-boot --kernel
program_flash -f images/linux/BOOT.BIN -offset 0 -flash_type qspi-x4-single -fsbl images/linux/zynq_fsbl.elf -cable type xilinx_tcf url TCP:127.0.0.1:3121
program_flash -jtagtargets
JTAG chain configuration
--------------------------------------------------
1 Digilent 210299AFC175
2 jsn-JTAG-HS3-210299AFC175-4ba00477-0 (name arm_dap idcode 4ba00477)
3 jsn-JTAG-HS3-210299AFC175-0373b093-0 (name xc7z015 idcode 0373b093)
4 Xilinx 00001a3719fe01
5 jsn-DLC10-00001a3719fe01-4ba00477-0 (name arm_dap idcode 4ba00477)
6 jsn-DLC10-00001a3719fe01-0373b093-0 (name xc7z015 idcode 0373b093)
program_flash -f images/linux/BOOT.BIN -offset 0 -flash_type qspi-x4-single -fsbl images/linux/zynq_fsbl.elf -target_id 2 -url TCP:127.0.0.1:3121
program_flash -f images/linux/BOOT.BIN -offset 0 -flash_type qspi-x4-single -fsbl images/linux/zynq_fsbl.elf -target_id 5 -url TCP:127.0.0.1:3121
petalinux-package --bsp -p /home/jo/Documents/Projets/Hepia/scalp_project/scalp_petalinux/scalp_safe_petalinux --hwsource=/home/jo/Documents/Projets/Hepia/scalp_project/scalp_firmware/designs/vivado/scalp_safe_firmware/2020.2/lin64/scalp_safe_firmware --output SCALP-SAFE-FIRMWARE-BSP-V0.01.BSP --force
petalinux-package –-bsp–p <petalinux-project-path>–-hwsource=<vivado-project-path> --outputCMS-ZCU102-v1.BSP--force
/tools/u-boot-tools/mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Scalp Board U-Boot script" -d uenv.scr uenv.scr.bin
bootgen -w -image bit.bif -arch zynq -process_bitstream bin
sf probe 0 0 0
sf read 0x2000000 0x520000 0xD6D934
sf read 0x2000000 0xC5540 0xD6D40C
petalinux-package --boot --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system.bit --u-boot --kernel --offset 0x520000
diff -u $(find -name .config.uboot.*) | grep "^\+" | cut -c2- | sed '1d' >> project-spec/meta-user/recipes-bsp/u-boot/files/scalp_uboot.cfg
...@@ -103,7 +103,7 @@ In my case **\<path-to-bsp\>** corresponds to /home/jo/Documents/Projets/Hepia/s ...@@ -103,7 +103,7 @@ In my case **\<path-to-bsp\>** corresponds to /home/jo/Documents/Projets/Hepia/s
``` ```
$ export SCALP_FIRMWARE_PATH="\<PATH_TO_SCALP_FIRMWARE_PROJECT\>" $ export SCALP_FIRMWARE_PATH="\<PATH_TO_SCALP_FIRMWARE_PROJECT\>"
$ petalinux-config --get-hw-description=$(find ${SCALP_FIRMWARE_PATH=} -name scalp_safe_firmware.xsa) --silentconfig $ petalinux-config --get-hw-description=$(find ${SCALP_FIRMWARE_PATH} -name scalp_safe_firmware.xsa) --silentconfig
``` ```
In my case **\<PATH_TO_SCALP_FIRMWARE_PROJECT\>** corresponds to /home/jo/Documents/Projets/Hepia/scalp_project/scalp_firmware/ In my case **\<PATH_TO_SCALP_FIRMWARE_PROJECT\>** corresponds to /home/jo/Documents/Projets/Hepia/scalp_project/scalp_firmware/
...@@ -184,7 +184,7 @@ In my case **\<PATH_TO_SCALP_FIRMWARE_PROJECT\>** corresponds to /home/jo/Docume ...@@ -184,7 +184,7 @@ In my case **\<PATH_TO_SCALP_FIRMWARE_PROJECT\>** corresponds to /home/jo/Docume
### Bug in the U-Boot config with the selection of the ZYNQ_SPI driver ### Bug in the U-Boot config with the selection of the ZYNQ_SPI driver
Despite the fact that the ZYNQ\_SPI driver is preselected in the U-Boot configuration specific to the SCALP board, this configuration is not automatically taken into account. Therefore, it is necessary to select the ZYNQ\_SPI driver manually. The same applies to commands related to the UBIFS file system (CMD\_UBI and CMD\_UBIFS). Despite the fact that some drivers and commands are preselected in the U-Boot configuration specific to the SCALP board, they are not automatically taken into account. It is therefore necessary to select the ZYNQ\_SPI driver manually. The same applies to the drivers relating to the Fixed-Link PHY (PHY\_FIXED) and Xilinx Ethernet PHYs support (PHY\_XILINX) and to the commands relating to the UBIFS file system (CMD\_UBI and CMD\_UBIFS).
First, you need to open the U-Boot configuration menu, after cleaning up the project. First, you need to open the U-Boot configuration menu, after cleaning up the project.
...@@ -204,18 +204,28 @@ U-Boot 2020.01 Configuration ...@@ -204,18 +204,28 @@ U-Boot 2020.01 Configuration
and... and...
```
U-Boot 2020.01 Configuration
Device Drivers --->
-*- Ethernet PHY (physical media interface) support --->
[*] Fixed-Link PHY (select with spacebar)
[*] Xilinx Ethernet PHYs support (select with spacebar)
```
and...
``` ```
U-Boot 2020.01 Configuration U-Boot 2020.01 Configuration
Command line interface ---> Command line interface --->
[*] Enable UBI - Unsorted block images commands [*] Enable UBI - Unsorted block images commands (select with spacebar)
[*] Enable UBIFS - Unsorted block images filesystem commands (NEW) [*] Enable UBIFS - Unsorted block images filesystem commands (NEW) (select with spacebar)
``` ```
Then select 2 times EXIT... Then select 2 times EXIT...
And save the configuration. And save the configuration.
**You can optionally return to the U-Boot configuration menu to check that the ZYNQ_SPI driver and the CMD_UBI and CMD_UBIFS commands have been taken into account.** **You can optionally return to the U-Boot configuration menu to check that the ZYNQ_SPI, PHY_FIXED and PHY_XILINX drivers and the CMD_UBI and CMD_UBIFS commands have been taken into account.**
### Build the PetaLinux project ### Build the PetaLinux project
...@@ -257,11 +267,128 @@ $ /tools/u-boot-tools/mkenvimage -s 0x20000 -o images/linux/scalp-u-boot.env.bin ...@@ -257,11 +267,128 @@ $ /tools/u-boot-tools/mkenvimage -s 0x20000 -o images/linux/scalp-u-boot.env.bin
In my case, I copied the tools produced by U-Boot into the **/tools/u-boot-tools/** folder. In my case, I copied the tools produced by U-Boot into the **/tools/u-boot-tools/** folder.
### Create UBIFS images
**First, check that the mtd-utils package (debian and ubuntu) is installed on your host machine.**
From the root directory of the PetaLinux project...
Extract the root file system to the previously created directory.
```
$ cd images/linux
$ mkdir rootfs
$ tar -xzvpf rootfs.tar.gz -C rootfs
```
**Do not go to the rootfs folder** and create a second folder named datafs.
```
$ mkdir datafs
```
Next, the two UBIFS images rootfs and datafs must be
**SF: Detected s25fl256s1 with page size 256 Bytes, erase size 64 KiB, total 32 MiB**
| QSPI Flash memory size | 33554432 Bytes |
|------------------------|----------------|
| Page size | 256 Bytes |
|------------------------|----------------|
| Erase block size | 65536 Bytes |
|------------------------|----------------|
| Max. erase blocks | 512 |
```
$ sudo mkfs.ubifs -r ./rootfs -m 1 -e 65408 -c 256 -o rootfs.img
$ sudo mkfs.ubifs -r ./datafs -m 1 -e 65408 -c 32 -o datafs.img
```
Next, a configuration file must be created to define the UBI volume.
```
$ echo \
"[datafs-volume]
mode=ubi
image=datafs.img
vol_id=0
vol_size=2MiB
vol_type=static
vol_name=datafs
[rootfs-volume]
mode=ubi
image=rootfs.img
vol_id=1
vol_size=16MiB
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize
" \
> ubiconf.ini
```
Next, the UBI volume must be created.
```
$ sudo ubinize -p 64KiB -m 1 -s 1 -O 64 -o ubifs.img ubiconf.ini
$ cd ../..
```
#### Howto obtain information about the organization of the SPI NOR memory.
**For information purposes only**
From U-Boot ...
```
ScalpZynq> ubi part ubifs
ubi0: attaching mtd5
ubi0: scanning is finished
ubi0: volume 1 ("rootfs") re-sized from 257 to 263 LEBs
ubi0: attached mtd5 (name "ubifs", size 18 MiB)
ubi0: PEB size: 65536 bytes (64 KiB), LEB size: 65408 bytes <----- -e 65408 / -p 65536
ubi0: min./max. I/O unit sizes: 1/256, sub-page size 1 <----- -m 1 / -s 1
ubi0: VID header offset: 64 (aligned 64), data offset: 128 <----- -O 64
ubi0: good PEBs: 300, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 2, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 1170760348
ubi0: available PEBs: 0, total reserved PEBs: 300, PEBs reserved for bad PEB handling: 0
```
```
ScalpZynq> ubi info
UBI: MTD device name: "ubifs"
UBI: MTD device size: 18 MiB
UBI: physical eraseblock size: 65536 bytes (64 KiB)
UBI: logical eraseblock size: 65408 bytes
UBI: number of good PEBs: 300
UBI: number of bad PEBs: 0
UBI: smallest flash I/O unit: 1
UBI: VID header offset: 64 (aligned 64)
UBI: data offset: 128
UBI: max. allowed volumes: 128
UBI: wear-leveling threshold: 4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 2
UBI: available PEBs: 0
UBI: total number of reserved PEBs: 300
UBI: number of PEBs reserved for bad PEB handling: 0
UBI: max/mean erase counter: 1/0
```
```
UBIFS error (ubi0:0 pid 0): validate_sb: LEB size mismatch: 65536 in superblock, 65408 real
```
### QSPI firmware packaging ### QSPI firmware packaging
``` ```
$ petalinux-package --boot --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system.bit --u-boot --kernel --offset 0x540000 --dtb images/linux/system.dtb --offset 0x520000 --force $ petalinux-package --boot --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system.bit --u-boot --kernel --offset 0x540000 --dtb images/linux/system.dtb --offset 0x520000 --force
petalinux-package --boot --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system.bit --u-boot --kernel --offset 0x540000 --dtb images/linux/system.dtb --offset 0x520000 --add images/linux/ubifs.img --offset 0xD40000 --force
Do not use this command : Do not use this command :
$ petalinux-package --boot --fsbl images/linux/zynq_fsbl.elf --offset 0x0 --fpga images/linux/system.bit --u-boot --add images/linux/scalp-u-boot.env.bin --offset 0x500000 --kernel --offset 0x540000 --dtb images/linux/system.dtb --offset 0x520000 --force $ petalinux-package --boot --fsbl images/linux/zynq_fsbl.elf --offset 0x0 --fpga images/linux/system.bit --u-boot --add images/linux/scalp-u-boot.env.bin --offset 0x500000 --kernel --offset 0x540000 --dtb images/linux/system.dtb --offset 0x520000 --force
...@@ -269,35 +396,78 @@ $ petalinux-package --boot --fsbl images/linux/zynq_fsbl.elf --offset 0x0 --fpga ...@@ -269,35 +396,78 @@ $ petalinux-package --boot --fsbl images/linux/zynq_fsbl.elf --offset 0x0 --fpga
The produced binary file can be found in the **./images/linux** folder. The **FIT image** of the Linux kernel is located at the address **0x540000**. The produced binary file can be found in the **./images/linux** folder. The **FIT image** of the Linux kernel is located at the address **0x540000**.
Below is the partitioning of the flash memory. **For information purposes only**, below is the partitioning of the flash memory.
```
{ INFO("s25fl256s0", 0x010219, 0x4d00, 256 * 1024, 128, USE_CLSR) },
{ INFO("s25fl256s1", 0x010219, 0x4d01, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) },
```
```
{
.idcode1 = 0x0219,
.idcode2 = 0x4d01,
.page_size = 256,
.pages_per_sector = 256,
.nr_sectors = 512,
.name = "S25FL256S1",
}
```
```
List of MTD devices:
* nor0
- type: NOR flash
- block size: 0x10000 bytes
- min I/O: 0x1 bytes
- 0x000000000000-0x000002000000 : "nor0"
- 0x000000000000-0x000000500000 : "boot"
- 0x000000500000-0x000000520000 : "bootenv"
- 0x000000520000-0x000000540000 : "dtb"
- 0x000000540000-0x000000d40000 : "fitimage"
- 0x000000d40000-0x000002000000 : "ubifs"
```
```
device nor0 <nor_flash>, # parts = 5
#: name size net size offset mask_flags
0: boot 0x00500000 0x00500000 0x00000000 1
1: bootenv 0x00020000 0x00020000 0x00500000 1
2: dtb 0x00020000 0x00020000 0x00520000 1
3: fitimage 0x00800000 0x00800000 0x00540000 1
4: ubifs 0x012c0000 0x012c0000 0x00d40000 0
active partition: nor0,0 - (boot) 0x00500000 @ 0x00000000
defaults:
mtdids : nor0=nor_flash
mtdparts: mtdparts=nor_flash:5m(boot)ro,128k(bootenv)ro,128k(dtb)ro,8m(fitimage)or,-(ubifs)
```
``` ```
/* FSBL + safe bitstream (design with only Zynq) + U-Boot */
/* Size : 5242880 Bytes */
partition@boot { partition@boot {
label = "boot"; label = "boot";
reg = <0x0 0x500000>; reg = <0x0 0x500000>;
}; };
/* Safe U-Boot Env. */
/* Size : 131072 Bytes */
partition@bootenv { partition@bootenv {
label = "bootenv"; label = "bootenv";
reg = <0x500000 0x20000>; reg = <0x500000 0x20000>;
}; };
/* Safe DTB */
/* Size : 131072 Bytes */
partition@dtb { partition@dtb {
label = "dtb"; label = "dtb";
reg = <0x520000 0x20000>; reg = <0x520000 0x20000>;
}; };
/* Safe Fit Image */
/* Size : 28049408 Bytes */
partition@fitimage { partition@fitimage {
label = "fitimage"; label = "fitimage";
reg = <0x540000 0x1ac0000>; reg = <0x540000 0x800000>;
};
partition@ubifs {
label = "ubifs";
reg = <0xD40000 0x12C0000>;
}; };
``` ```
...@@ -321,10 +491,10 @@ $ program_flash -jtagtarget ...@@ -321,10 +491,10 @@ $ program_flash -jtagtarget
> Available targets and devices: > Available targets and devices:
> JTAG chain configuration > JTAG chain configuration
> -------------------------------------------------- > --------------------------------------------------
> 1 Digilent 210299AFC175 > 1 Digilent 210299AFC175
> 2 jsn-JTAG-HS3-210299AFC175-4ba00477-0 (name arm_dap idcode 4ba00477) <-- target id 2 > 2 jsn-JTAG-HS3-210299AFC175-4ba00477-0 (name arm_dap idcode 4ba00477) <-- target id 2
> 3 jsn-JTAG-HS3-210299AFC175-0373b093-0 (name xc7z015 idcode 0373b093) > 3 jsn-JTAG-HS3-210299AFC175-0373b093-0 (name xc7z015 idcode 0373b093)
> 4 Digilent 210299AFB167 > 4 Digilent 210299AFB167
> 5 jsn-JTAG-HS3-210299AFB167-4ba00477-0 (name arm_dap idcode 4ba00477) <-- target id 5 > 5 jsn-JTAG-HS3-210299AFB167-4ba00477-0 (name arm_dap idcode 4ba00477) <-- target id 5
> 6 jsn-JTAG-HS3-210299AFB167-0373b093-0 (name xc7z015 idcode 0373b093) > 6 jsn-JTAG-HS3-210299AFB167-0373b093-0 (name xc7z015 idcode 0373b093)
...@@ -345,6 +515,11 @@ In my case, I copied the tools produced by U-Boot into the **/tools/u-boot-tools ...@@ -345,6 +515,11 @@ In my case, I copied the tools produced by U-Boot into the **/tools/u-boot-tools
## HOWTO ## HOWTO
### Howto access UBIFS partitions from U-Boot.
### Howto create a patch for U-Boot ### Howto create a patch for U-Boot
Retrieve the desired version of the U-Boot GIT deposit. Retrieve the desired version of the U-Boot GIT deposit.
...@@ -371,7 +546,7 @@ $ git diff -p xilinx-v2020.2 HEAD > my-u-boot.patch ...@@ -371,7 +546,7 @@ $ git diff -p xilinx-v2020.2 HEAD > my-u-boot.patch
Solution in case of problems with whitespaces. Solution in case of problems with whitespaces.
``` ```
$ emacs u-boot-scalp-sja1105.patch -f delete-trailing-whitespace -f save-buffer -f kill-emacs $ emacs my-u-boot.patch -f delete-trailing-whitespace -f save-buffer -f kill-emacs
``` ```
Apply the new patch to a clean version of the U-Boot GIT deposit. Apply the new patch to a clean version of the U-Boot GIT deposit.
...@@ -427,16 +602,16 @@ INITSCRIPT_NAME = "sja1105-init" ...@@ -427,16 +602,16 @@ INITSCRIPT_NAME = "sja1105-init"
INITSCRIPT_PARAMS = "start 02 S ." INITSCRIPT_PARAMS = "start 02 S ."
do_install() { do_install() {
install -d ${D}${sysconfdir}/init.d install -d ${D}${sysconfdir}/init.d
install -m 0755 ${S}/sja1105-init ${D}${sysconfdir}/init.d/sja1105-init install -m 0755 ${S}/sja1105-init ${D}${sysconfdir}/init.d/sja1105-init
install -d ${D}${sysconfdir}/rc2.d install -d ${D}${sysconfdir}/rc2.d
install -m 0755 ${S}/sja1105-init ${D}${sysconfdir}/rc2.d/S02sja1105-init install -m 0755 ${S}/sja1105-init ${D}${sysconfdir}/rc2.d/S02sja1105-init
install -d ${D}${sysconfdir}/rc3.d install -d ${D}${sysconfdir}/rc3.d
install -m 0755 ${S}/sja1105-init ${D}${sysconfdir}/rc3.d/S02sja1105-init install -m 0755 ${S}/sja1105-init ${D}${sysconfdir}/rc3.d/S02sja1105-init
install -d ${D}${sysconfdir}/rc4.d install -d ${D}${sysconfdir}/rc4.d
install -m 0755 ${S}/sja1105-init ${D}${sysconfdir}/rc4.d/S02sja1105-init install -m 0755 ${S}/sja1105-init ${D}${sysconfdir}/rc4.d/S02sja1105-init
install -d ${D}${sysconfdir}/rc5.d install -d ${D}${sysconfdir}/rc5.d
install -m 0755 ${S}/sja1105-init ${D}${sysconfdir}/rc5.d/S02sja1105-init install -m 0755 ${S}/sja1105-init ${D}${sysconfdir}/rc5.d/S02sja1105-init
} }
FILES_${PN} += "${sysconfdir}/*" FILES_${PN} += "${sysconfdir}/*"
...@@ -468,40 +643,42 @@ PIDFILE=/var/run/sja1105-init.pid ...@@ -468,40 +643,42 @@ PIDFILE=/var/run/sja1105-init.pid
LOGFILE=/var/log/sja1105-init.log LOGFILE=/var/log/sja1105-init.log
start() { start() {
if [ -f /var/run/$PIDNAME ] && kill -0 $(cat /var/run/$PIDNAME); then if [ -f /var/run/$PIDNAME ] && kill -0 $(cat /var/run/$PIDNAME); then
echo 'Service already running' >&2 echo 'Service already running' >&2
return 1 return 1
fi fi
echo 'Starting service…' >&2
local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!" echo 'Starting service…' >&2
su -c "$CMD" $RUNAS > "$PIDFILE" local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
echo 'Service started' >&2 su -c "$CMD" $RUNAS > "$PIDFILE"
echo 'Service started' >&2
} }
stop() { stop() {
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service not running' >&2 echo 'Service not running' >&2
return 1 return 1
fi fi
echo 'Stopping service…' >&2
echo 'Log files /var/log/sja1105-init.log and /var/log/sja1105-conf.log' >&2 echo 'Stopping service…' >&2
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE" echo 'Log files /var/log/sja1105-init.log and /var/log/sja1105-conf.log' >&2
echo 'Service stopped' >&2 kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Service stopped' >&2
} }
case "$1" in case "$1" in
start) start)
start start
;; ;;
stop) stop)
stop stop
;; ;;
retart) retart)
stop stop
start start
;; ;;
*) *)
echo "Usage: $0 {start|stop|restart|uninstall}" echo "Usage: $0 {start|stop|restart}"
esac esac
``` ```
...@@ -535,8 +712,8 @@ SRC_URI = "file://sja1105-conf \ ...@@ -535,8 +712,8 @@ SRC_URI = "file://sja1105-conf \
S = "${WORKDIR}" S = "${WORKDIR}"
do_install() { do_install() {
install -d ${D}/${bindir} install -d ${D}/${bindir}
install -m 0755 ${S}/sja1105-conf ${D}/${bindir} install -m 0755 ${S}/sja1105-conf ${D}/${bindir}
} }
``` ```
...@@ -556,7 +733,7 @@ sja1105_ports_link_up() ...@@ -556,7 +733,7 @@ sja1105_ports_link_up()
echo "[INFO] sja1105-conf : sja1105 ports linking up..." echo "[INFO] sja1105-conf : sja1105 ports linking up..."
ip link set swp0_east up ip link set swp0_east up
if [ "$?" -eq "0" ] ; then if [ "$?" -eq "0" ] ; then
echo "[INFO] sja1105-conf : swp0_east port is up." echo "[INFO] sja1105-conf : swp0_east port is up."
else else
...@@ -618,7 +795,7 @@ sja1105_link_ports_to_bridge() ...@@ -618,7 +795,7 @@ sja1105_link_ports_to_bridge()
echo "[INFO] sja1105-conf : sja1105 ports are being attached to the bridge..." echo "[INFO] sja1105-conf : sja1105 ports are being attached to the bridge..."
ip link set dev swp0_east master br0 ip link set dev swp0_east master br0
if [ "$?" -eq "0" ] ; then if [ "$?" -eq "0" ] ; then
echo "[INFO] sja1105-conf : Addition of the swp0_east interface to the bridge interface." echo "[INFO] sja1105-conf : Addition of the swp0_east interface to the bridge interface."
else else
...@@ -626,7 +803,7 @@ sja1105_link_ports_to_bridge() ...@@ -626,7 +803,7 @@ sja1105_link_ports_to_bridge()
fi fi
ip link set dev swp2_bottom master br0 ip link set dev swp2_bottom master br0
if [ "$?" -eq "0" ] ; then if [ "$?" -eq "0" ] ; then
echo "[INFO] sja1105-conf : Addition of the swp2_bottom interface to the bridge interface." echo "[INFO] sja1105-conf : Addition of the swp2_bottom interface to the bridge interface."
else else
...@@ -634,7 +811,7 @@ sja1105_link_ports_to_bridge() ...@@ -634,7 +811,7 @@ sja1105_link_ports_to_bridge()
fi fi
ip link set dev swp3_top master br0 ip link set dev swp3_top master br0
if [ "$?" -eq "0" ] ; then if [ "$?" -eq "0" ] ; then
echo "[INFO] sja1105-conf : Addition of the swp3_top interface to the bridge interface." echo "[INFO] sja1105-conf : Addition of the swp3_top interface to the bridge interface."
else else
...@@ -642,7 +819,7 @@ sja1105_link_ports_to_bridge() ...@@ -642,7 +819,7 @@ sja1105_link_ports_to_bridge()
fi fi
ip link set dev swp4_west master br0 ip link set dev swp4_west master br0
if [ "$?" -eq "0" ] ; then if [ "$?" -eq "0" ] ; then
echo "[INFO] sja1105-conf : Addition of the swp4_west interface to the bridge interface." echo "[INFO] sja1105-conf : Addition of the swp4_west interface to the bridge interface."
else else
...@@ -657,7 +834,7 @@ sja1105_ports_vlan_conf() ...@@ -657,7 +834,7 @@ sja1105_ports_vlan_conf()
echo "[INFO] sja1105-conf : sja1105 ports VLAN configuration in progress..." echo "[INFO] sja1105-conf : sja1105 ports VLAN configuration in progress..."
bridge vlan add dev swp0_east vid 1 pvid untagged bridge vlan add dev swp0_east vid 1 pvid untagged
if [ "$?" -eq "0" ] ; then if [ "$?" -eq "0" ] ; then
echo "[INFO] sja1105-conf : Configuration of the swp0_east interface in untagged VLAN mode." echo "[INFO] sja1105-conf : Configuration of the swp0_east interface in untagged VLAN mode."
else else
...@@ -665,7 +842,7 @@ sja1105_ports_vlan_conf() ...@@ -665,7 +842,7 @@ sja1105_ports_vlan_conf()
fi fi
bridge vlan add dev swp2_bottom vid 2 pvid untagged bridge vlan add dev swp2_bottom vid 2 pvid untagged
if [ "$?" -eq "0" ] ; then if [ "$?" -eq "0" ] ; then
echo "[INFO] sja1105-conf : Configuration of the swp2_bottom interface in untagged VLAN mode." echo "[INFO] sja1105-conf : Configuration of the swp2_bottom interface in untagged VLAN mode."
else else
...@@ -673,7 +850,7 @@ sja1105_ports_vlan_conf() ...@@ -673,7 +850,7 @@ sja1105_ports_vlan_conf()
fi fi
bridge vlan add dev swp3_top vid 3 pvid untagged bridge vlan add dev swp3_top vid 3 pvid untagged
if [ "$?" -eq "0" ] ; then if [ "$?" -eq "0" ] ; then
echo "[INFO] sja1105-conf : Configuration of the swp3_top interface in untagged VLAN mode." echo "[INFO] sja1105-conf : Configuration of the swp3_top interface in untagged VLAN mode."
else else
...@@ -681,7 +858,7 @@ sja1105_ports_vlan_conf() ...@@ -681,7 +858,7 @@ sja1105_ports_vlan_conf()
fi fi
bridge vlan add dev swp4_west vid 4 pvid untagged bridge vlan add dev swp4_west vid 4 pvid untagged
if [ "$?" -eq "0" ] ; then if [ "$?" -eq "0" ] ; then
echo "[INFO] sja1105-conf : Configuration of the swp4_west interface in untagged VLAN mode." echo "[INFO] sja1105-conf : Configuration of the swp4_west interface in untagged VLAN mode."
else else
...@@ -696,7 +873,7 @@ sja1105_bridge_link_up() ...@@ -696,7 +873,7 @@ sja1105_bridge_link_up()
echo "[INFO] sja1105-conf : sja1105 bridge linking up..." echo "[INFO] sja1105-conf : sja1105 bridge linking up..."
ip link set br0 up ip link set br0 up
if [ "$?" -eq "0" ] ; then if [ "$?" -eq "0" ] ; then
echo "[INFO] sja1105-conf : bridge-like interface is up." echo "[INFO] sja1105-conf : bridge-like interface is up."
else else
...@@ -736,3 +913,8 @@ $ petalinux-build ...@@ -736,3 +913,8 @@ $ petalinux-build
### Howto create a new BSP ### Howto create a new BSP
TODO TODO
...@@ -113,13 +113,20 @@ CONFIG_SUBSYSTEM_FLASH_PS7_QSPI_0_BANKLESS_PART2_FLAGS="dtb" ...@@ -113,13 +113,20 @@ CONFIG_SUBSYSTEM_FLASH_PS7_QSPI_0_BANKLESS_PART2_FLAGS="dtb"
# partition 3 # partition 3
# #
CONFIG_SUBSYSTEM_FLASH_PS7_QSPI_0_BANKLESS_PART3_NAME="fitimage" CONFIG_SUBSYSTEM_FLASH_PS7_QSPI_0_BANKLESS_PART3_NAME="fitimage"
CONFIG_SUBSYSTEM_FLASH_PS7_QSPI_0_BANKLESS_PART3_SIZE=0x1AC0000 CONFIG_SUBSYSTEM_FLASH_PS7_QSPI_0_BANKLESS_PART3_SIZE=0x800000
CONFIG_SUBSYSTEM_FLASH_PS7_QSPI_0_BANKLESS_PART3_FLAGS="fitimage" CONFIG_SUBSYSTEM_FLASH_PS7_QSPI_0_BANKLESS_PART3_FLAGS="fitimage"
# #
# partition 4 # partition 4
# #
CONFIG_SUBSYSTEM_FLASH_PS7_QSPI_0_BANKLESS_PART4_NAME="" CONFIG_SUBSYSTEM_FLASH_PS7_QSPI_0_BANKLESS_PART4_NAME="ubifs"
CONFIG_SUBSYSTEM_FLASH_PS7_QSPI_0_BANKLESS_PART4_SIZE=0x12C000
CONFIG_SUBSYSTEM_FLASH_PS7_QSPI_0_BANKLESS_PART4_FLAGS="ubifs"
#
# partition 5
#
CONFIG_SUBSYSTEM_FLASH_PS7_QSPI_0_BANKLESS_PART5_NAME=""
CONFIG_SUBSYSTEM_FLASH_IP_NAME="ps7_qspi_0" CONFIG_SUBSYSTEM_FLASH_IP_NAME="ps7_qspi_0"
# #
...@@ -167,10 +174,8 @@ CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_KERNEL_IMAGE_NAME="image.ub" ...@@ -167,10 +174,8 @@ CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_KERNEL_IMAGE_NAME="image.ub"
# #
# jffs2 rootfs image settings # jffs2 rootfs image settings
# #
CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_JFFS2_MEDIA_FLASH_SELECT=y # CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_JFFS2_MEDIA_FLASH_SELECT is not set
# CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_JFFS2_MEDIA_MANUAL_SELECT is not set CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_JFFS2_MEDIA_MANUAL_SELECT=y
CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_JFFS2_PART_NAME="jffs2"
CONFIG_SUBSYSTEM_IMAGES_ADVANCED_AUTOCONFIG_JFFS2_IMAGE_NAME="rootfs.jffs2"
# #
# dtb image settings # dtb image settings
...@@ -228,13 +233,12 @@ CONFIG_SUBSYSTEM_LINUX_CONFIG_TARGET="" ...@@ -228,13 +233,12 @@ CONFIG_SUBSYSTEM_LINUX_CONFIG_TARGET=""
# #
# Image Packaging Configuration # Image Packaging Configuration
# #
CONFIG_SUBSYSTEM_ROOTFS_INITRAMFS=y # CONFIG_SUBSYSTEM_ROOTFS_INITRAMFS is not set
# CONFIG_SUBSYSTEM_ROOTFS_INITRD is not set # CONFIG_SUBSYSTEM_ROOTFS_INITRD is not set
# CONFIG_SUBSYSTEM_ROOTFS_JFFS2 is not set # CONFIG_SUBSYSTEM_ROOTFS_JFFS2 is not set
# CONFIG_SUBSYSTEM_ROOTFS_NFS is not set # CONFIG_SUBSYSTEM_ROOTFS_NFS is not set
# CONFIG_SUBSYSTEM_ROOTFS_EXT4 is not set # CONFIG_SUBSYSTEM_ROOTFS_EXT4 is not set
# CONFIG_SUBSYSTEM_ROOTFS_OTHER is not set CONFIG_SUBSYSTEM_ROOTFS_OTHER=y
CONFIG_SUBSYSTEM_INITRAMFS_IMAGE_NAME="petalinux-image-minimal"
CONFIG_SUBSYSTEM_UIMAGE_NAME="image.ub" CONFIG_SUBSYSTEM_UIMAGE_NAME="image.ub"
CONFIG_SUBSYSTEM_RFS_FORMATS="cpio cpio.gz cpio.gz.u-boot tar.gz jffs2" CONFIG_SUBSYSTEM_RFS_FORMATS="cpio cpio.gz cpio.gz.u-boot tar.gz jffs2"
CONFIG_SUBSYSTEM_DTB_PADDING_SIZE=0x1000 CONFIG_SUBSYSTEM_DTB_PADDING_SIZE=0x1000
......
...@@ -165,7 +165,7 @@ ...@@ -165,7 +165,7 @@
//sja1105,role-phy; //sja1105,role-phy;
fixed-link { fixed-link {
speed = <1000>; speed = <10>;
full-duplex; full-duplex;
}; };
}; };
...@@ -177,7 +177,7 @@ ...@@ -177,7 +177,7 @@
//sja1105,role-phy; //sja1105,role-phy;
fixed-link { fixed-link {
speed = <1000>; speed = <10>;
full-duplex; full-duplex;
}; };
}; };
...@@ -189,7 +189,7 @@ ...@@ -189,7 +189,7 @@
//sja1105,role-mac; //sja1105,role-mac;
fixed-link { fixed-link {
speed = <1000>; speed = <10>;
full-duplex; full-duplex;
}; };
}; };
...@@ -201,7 +201,7 @@ ...@@ -201,7 +201,7 @@
//sja1105,role-phy; //sja1105,role-phy;
fixed-link { fixed-link {
speed = <1000>; speed = <10>;
full-duplex; full-duplex;
}; };
}; };
...@@ -213,7 +213,7 @@ ...@@ -213,7 +213,7 @@
//sja1105,role-mac; //sja1105,role-mac;
fixed-link { fixed-link {
speed = <1000>; speed = <10>;
full-duplex; full-duplex;
}; };
}; };
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
//local-mac-address = [00 0a 35 00 00 00]; //local-mac-address = [00 0a 35 00 00 00];
fixed-link { fixed-link {
speed = <1000>; speed = <10>;
full-duplex; full-duplex;
}; };
......
...@@ -2,9 +2,11 @@ CONFIG_API=y ...@@ -2,9 +2,11 @@ CONFIG_API=y
CONFIG_QSPI_BOOT=y CONFIG_QSPI_BOOT=y
CONFIG_SPI_BOOT=y CONFIG_SPI_BOOT=y
CONFIG_LOG=y CONFIG_LOG=y
CONFIG_LOG_MAX_LEVEL=6
CONFIG_LOG_DEFAULT_LEVEL=5
#CONFIG_LOG_ERROR_RETURN=y
# CONFIG_SPL_LOG is not set # CONFIG_SPL_LOG is not set
# CONFIG_TPL_LOG is not set # CONFIG_TPL_LOG is not set
CONFIG_LOG_MAX_LEVEL=5
CONFIG_LOG_CONSOLE=y CONFIG_LOG_CONSOLE=y
# CONFIG_LOG_TEST is not set # CONFIG_LOG_TEST is not set
# CONFIG_LOG_ERROR_RETURN is not set # CONFIG_LOG_ERROR_RETURN is not set
...@@ -26,6 +28,9 @@ CONFIG_CMD_MEMINFO=y ...@@ -26,6 +28,9 @@ CONFIG_CMD_MEMINFO=y
CONFIG_CMD_MX_CYCLIC=y CONFIG_CMD_MX_CYCLIC=y
CONFIG_CMD_FPGA_LOAD_SECURE=y CONFIG_CMD_FPGA_LOAD_SECURE=y
CONFIG_CMD_MTD=y CONFIG_CMD_MTD=y
CONFIG_CMD_MTDPARTS=y
CONFIG_CMD_MTDPARTS_SPREAD=y
CONFIG_CMD_MTDPARTS_SHOW_NET_SIZES=y
CONFIG_CMD_SETEXPR=y CONFIG_CMD_SETEXPR=y
CONFIG_CMD_UBI=y CONFIG_CMD_UBI=y
CONFIG_CMD_UBIFS=y CONFIG_CMD_UBIFS=y
...@@ -42,6 +47,7 @@ CONFIG_SPI=y ...@@ -42,6 +47,7 @@ CONFIG_SPI=y
CONFIG_DM_SPI=y CONFIG_DM_SPI=y
CONFIG_ZYNQ_SPI=y CONFIG_ZYNQ_SPI=y
CONFIG_ZYNQ_QSPI=y CONFIG_ZYNQ_QSPI=y
CONFIG_BITREVERSE=y
CONFIG_RGMII=y CONFIG_RGMII=y
CONFIG_FS_JFFS2=y CONFIG_FS_JFFS2=y
CONFIG_RBTREE=y CONFIG_RBTREE=y
...@@ -50,8 +56,6 @@ CONFIG_ENV_OFFSET=0x0 ...@@ -50,8 +56,6 @@ CONFIG_ENV_OFFSET=0x0
CONFIG_ENV_ADDR=0x500000 CONFIG_ENV_ADDR=0x500000
CONFIG_XILINX_OF_BOARD_DTB_ADDR=0x520000 CONFIG_XILINX_OF_BOARD_DTB_ADDR=0x520000
CONFIG_PACKING=y CONFIG_PACKING=y
CONFIG_CMD_SJA1105=y
CONFIG_SCALP_SJA1105=y
CONFIG_PINCTRL=y CONFIG_PINCTRL=y
CONFIG_PINCTRL_FULL=y CONFIG_PINCTRL_FULL=y
CONFIG_PINCTRL_GENERIC=y CONFIG_PINCTRL_GENERIC=y
...@@ -70,4 +74,13 @@ CONFIG_OF_EMBED=y ...@@ -70,4 +74,13 @@ CONFIG_OF_EMBED=y
CONFIG_DM_MDIO=y CONFIG_DM_MDIO=y
CONFIG_DM_MDIO_MUX=y CONFIG_DM_MDIO_MUX=y
# CONFIG_MDIO_MUX_I2CREG is not set # CONFIG_MDIO_MUX_I2CREG is not set
# CONFIG_MVMDIO is not set # CONFIG_MVMDIO is not set
\ No newline at end of file CONFIG_DM_DSA=y
CONFIG_SJA1105=y
CONFIG_SYS_MALLOC_F_LEN=0x800
CONFIG_PHY=y
CONFIG_NOP_PHY=y
#CONFIG_CMD_SJA1105=y
#CONFIG_SCALP_SJA1105=y
CONFIG_PHY_XILINX=y
CONFIG_PHY_FIXED=y
...@@ -11,11 +11,15 @@ ...@@ -11,11 +11,15 @@
"SCALP_BOOTENV_PARTITION_OFFSET=0x500000\0" \ "SCALP_BOOTENV_PARTITION_OFFSET=0x500000\0" \
"SCALP_BOOTENV_PARTITION_SIZE=0x20000\0" \ "SCALP_BOOTENV_PARTITION_SIZE=0x20000\0" \
"SCALP_FITIMAGE_PARTITION_OFFSET=0x540000\0" \ "SCALP_FITIMAGE_PARTITION_OFFSET=0x540000\0" \
"SCALP_FITIMAGE_PARTITION_SIZE=0x1AC0000\0" \ "SCALP_FITIMAGE_PARTITION_SIZE=0x7AD300\0" \
"SCALP_FITIMAGE_LOAD_OFFSET=0x2000000\0" \ "SCALP_FITIMAGE_LOAD_OFFSET=0x2000000\0" \
"SCALP_DTB_PARTITION_OFFSET=0x520000\0" \ "SCALP_DTB_PARTITION_OFFSET=0x520000\0" \
"SCALP_DTB_PARTITION_SIZE=0x20000\0" \ "SCALP_DTB_PARTITION_SIZE=0x20000\0" \
"SCALP_UBIFS_PARTITION_OFFSET=0xCED300\0" \
"SCALP_UBIFS_PARTITION_SIZE=0x1312D00\0" \
"SCALP_UBIFS_LOAD_OFFSET=0x3000000\0" \
"load_scalp_fitimage=sf probe 0 0 0 && sf read ${SCALP_FITIMAGE_LOAD_OFFSET} ${SCALP_FITIMAGE_PARTITION_OFFSET} ${SCALP_FITIMAGE_PARTITION_SIZE}\0" \ "load_scalp_fitimage=sf probe 0 0 0 && sf read ${SCALP_FITIMAGE_LOAD_OFFSET} ${SCALP_FITIMAGE_PARTITION_OFFSET} ${SCALP_FITIMAGE_PARTITION_SIZE}\0" \
"load_scalp_ubifs=sf probe 0 0 0 && sf read ${SCALP_UBIFS_LOAD_OFFSET} ${SCALP_UBIFS_PARTITION_OFFSET} ${SCALP_UBIFS_PARTITION_SIZE}\0" \
"macmemaddr=0x1000000\0" \ "macmemaddr=0x1000000\0" \
"readmac=i2c dev 0; i2c read 0x53 0xfa.1 6 ${macmemaddr}\0" \ "readmac=i2c dev 0; i2c read 0x53 0xfa.1 6 ${macmemaddr}\0" \
"buildmac=\n" \ "buildmac=\n" \
...@@ -45,3 +49,14 @@ ...@@ -45,3 +49,14 @@
"bootdelay=2\0" \ "bootdelay=2\0" \
"bootcmd=run custom_autoboot\0" \ "bootcmd=run custom_autoboot\0" \
"distro_bootcmd=run bootcmd\0" \ "distro_bootcmd=run bootcmd\0" \
"serverip=10.197.10.10\0" \
"netmask=255.0.0.0\0" \
"gatewayip=10.197.10.1\0" \
"ethact=eth0\0" \
"ethprime=eth0\0" \
// "mtdids=\"mtdids=nor0=nor_flash\"\0" \
// "mtdparts=\"mtdparts=nor_flash:5m(boot)ro,128k(bootenv)ro,128k(dtb)ro,8m(fitimage)or,-(ubifs)\"\0" \
#define MTDIDS_DEFAULT "nor0=nor_flash"
#define MTDPARTS_DEFAULT "mtdparts=nor_flash:5m(boot)ro,128k(bootenv)ro,128k(dtb)ro,8m(fitimage)ro,-(ubifs)"
...@@ -5,7 +5,7 @@ index 2d606b0dbb..b6f74f7320 100644 ...@@ -5,7 +5,7 @@ index 2d606b0dbb..b6f74f7320 100644
@@ -37,6 +37,19 @@ config DM_MDIO_MUX @@ -37,6 +37,19 @@ config DM_MDIO_MUX
This is currently implemented in net/mdio-mux-uclass.c This is currently implemented in net/mdio-mux-uclass.c
Look in include/miiphy.h for details. Look in include/miiphy.h for details.
+config DM_DSA +config DM_DSA
+ bool "Enable Driver Model for DSA switches" + bool "Enable Driver Model for DSA switches"
+ depends on DM_ETH && DM_MDIO + depends on DM_ETH && DM_MDIO
...@@ -23,9 +23,9 @@ index 2d606b0dbb..b6f74f7320 100644 ...@@ -23,9 +23,9 @@ index 2d606b0dbb..b6f74f7320 100644
depends on DM_MDIO && SANDBOX depends on DM_MDIO && SANDBOX
default y default y
@@ -57,6 +70,14 @@ config MDIO_MUX_SANDBOX @@ -57,6 +70,14 @@ config MDIO_MUX_SANDBOX
This driver is used for testing in test/dm/mdio.c This driver is used for testing in test/dm/mdio.c
+config DSA_SANDBOX +config DSA_SANDBOX
+ depends on DM_DSA && SANDBOX + depends on DM_DSA && SANDBOX
+ default y + default y
...@@ -40,7 +40,7 @@ index 2d606b0dbb..b6f74f7320 100644 ...@@ -40,7 +40,7 @@ index 2d606b0dbb..b6f74f7320 100644
@@ -360,6 +381,23 @@ config RTL8169 @@ -360,6 +381,23 @@ config RTL8169
This driver supports Realtek 8169 series gigabit ethernet family of This driver supports Realtek 8169 series gigabit ethernet family of
PCI/PCIe chipsets/adapters. PCI/PCIe chipsets/adapters.
+config SJA1105 +config SJA1105
+ bool "NXP SJA1105 Ethernet switch family driver" + bool "NXP SJA1105 Ethernet switch family driver"
+ depends on DM_DSA && DM_SPI + depends on DM_DSA && DM_SPI
...@@ -60,7 +60,7 @@ index 2d606b0dbb..b6f74f7320 100644 ...@@ -60,7 +60,7 @@ index 2d606b0dbb..b6f74f7320 100644
+ +
config SMC911X config SMC911X
bool "SMSC LAN911x and LAN921x controller driver" bool "SMSC LAN911x and LAN921x controller driver"
diff --git a/drivers/net/Makefile b/drivers/net/Makefile diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 30991834ec..67204ef3f4 100644 index 30991834ec..67204ef3f4 100644
--- a/drivers/net/Makefile --- a/drivers/net/Makefile
...@@ -3031,7 +3031,7 @@ index 965cf7bc03..a828b80a40 100644 ...@@ -3031,7 +3031,7 @@ index 965cf7bc03..a828b80a40 100644
@@ -33,6 +33,23 @@ config HAVE_PRIVATE_LIBGCC @@ -33,6 +33,23 @@ config HAVE_PRIVATE_LIBGCC
config LIB_UUID config LIB_UUID
bool bool
+config PACKING +config PACKING
+ bool "Generic bitfield packing and unpacking" + bool "Generic bitfield packing and unpacking"
+ default n + default n
...@@ -3062,7 +3062,7 @@ index 1fb650cd90..4f99bd47c2 100644 ...@@ -3062,7 +3062,7 @@ index 1fb650cd90..4f99bd47c2 100644
obj-$(CONFIG_LIB_RAND) += rand.o obj-$(CONFIG_LIB_RAND) += rand.o
+obj-$(CONFIG_PACKING) += packing.o +obj-$(CONFIG_PACKING) += packing.o
obj-y += panic.o obj-y += panic.o
ifeq ($(CONFIG_$(SPL_TPL_)BUILD),y) ifeq ($(CONFIG_$(SPL_TPL_)BUILD),y)
diff --git a/lib/packing.c b/lib/packing.c diff --git a/lib/packing.c b/lib/packing.c
new file mode 100644 new file mode 100644
...@@ -3278,3 +3278,480 @@ index 0000000000..21e0fab20d ...@@ -3278,3 +3278,480 @@ index 0000000000..21e0fab20d
+ } + }
+ return 0; + return 0;
+} +}
diff --git a/net/Makefile b/net/Makefile
index 2a700c8401..fac8c8beb9 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_CMD_SNTP) += sntp.o
obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o
obj-$(CONFIG_UDP_FUNCTION_FASTBOOT) += fastboot.o
obj-$(CONFIG_CMD_WOL) += wol.o
+obj-$(CONFIG_DM_DSA) += dsa-uclass.o
# Disable this warning as it is triggered by:
# sprintf(buf, index ? "foo%d" : "foo", index)
diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c
new file mode 100644
index 0000000000..7c17fd4d31
--- /dev/null
+++ b/net/dsa-uclass.c
@@ -0,0 +1,395 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2019 NXP
+ */
+
+#include <net/dsa.h>
+#include <dm/lists.h>
+#include <dm/device-internal.h>
+#include <dm/uclass-internal.h>
+#include <miiphy.h>
+
+#define DSA_PORT_CHILD_DRV_NAME "dsa-port"
+
+/* helper that returns the DSA master Ethernet device. */
+static struct udevice *dsa_port_get_master(struct udevice *pdev)
+{
+ struct udevice *dev = dev_get_parent(pdev);
+ struct dsa_perdev_platdata *platdata = dev_get_platdata(dev);
+
+ return platdata->master_dev;
+}
+
+/*
+ * Start the desired port, the CPU port and the master Eth interface.
+ * TODO: if cascaded we may need to _start ports in other switches too
+ */
+static int dsa_port_start(struct udevice *pdev)
+{
+ struct udevice *dev = dev_get_parent(pdev);
+ struct dsa_perdev_platdata *platdata = dev_get_platdata(dev);
+ struct udevice *master = dsa_port_get_master(pdev);
+ struct dsa_port_platdata *ppriv = dev_get_priv(pdev);
+ struct dsa_ops *ops = dsa_get_ops(dev);
+ int err;
+
+ if (!ppriv || !platdata)
+ return -EINVAL;
+
+ if (!master) {
+ dev_err(pdev, "DSA master Ethernet device not found!\n");
+ return -EINVAL;
+ }
+
+ if (ops->port_enable) {
+ err = ops->port_enable(dev, ppriv->index, ppriv->phy);
+ if (err)
+ return err;
+ err = ops->port_enable(dev, platdata->cpu_port,
+ platdata->port[platdata->cpu_port].phy);
+ if (err)
+ return err;
+ }
+
+ return eth_get_ops(master)->start(master);
+}
+
+/* Stop the desired port, the CPU port and the master Eth interface */
+static void dsa_port_stop(struct udevice *pdev)
+{
+ struct udevice *dev = dev_get_parent(pdev);
+ struct dsa_perdev_platdata *platdata = dev_get_platdata(dev);
+ struct udevice *master = dsa_port_get_master(pdev);
+ struct dsa_port_platdata *ppriv = dev_get_priv(pdev);
+ struct dsa_ops *ops = dsa_get_ops(dev);
+
+ if (!ppriv || !platdata)
+ return;
+
+ if (ops->port_disable) {
+ ops->port_disable(dev, ppriv->index, ppriv->phy);
+ ops->port_disable(dev, platdata->cpu_port,
+ platdata->port[platdata->cpu_port].phy);
+ }
+
+ /*
+ * stop master only if it's active, don't probe it otherwise.
+ * Under normal usage it would be active because we're using it, but
+ * during tear-down it may have been removed ahead of us.
+ */
+ if (master && device_active(master))
+ eth_get_ops(master)->stop(master);
+}
+
+/*
+ * Insert a DSA tag and call master Ethernet send on the resulting packet
+ * We copy the frame to a stack buffer where we have reserved headroom and
+ * tailroom space. Headroom and tailroom are set to 0.
+ */
+static int dsa_port_send(struct udevice *pdev, void *packet, int length)
+{
+ struct udevice *dev = dev_get_parent(pdev);
+ struct dsa_perdev_platdata *platdata = dev_get_platdata(dev);
+ struct udevice *master = dsa_port_get_master(pdev);
+ struct dsa_port_platdata *ppriv = dev_get_priv(pdev);
+ struct dsa_ops *ops = dsa_get_ops(dev);
+ uchar dsa_packet[DSA_MAX_FRAME_SIZE];
+ int head = platdata->headroom, tail = platdata->tailroom;
+ int err;
+
+ if (!master)
+ return -EINVAL;
+
+ if (length + head + tail > DSA_MAX_FRAME_SIZE)
+ return -EINVAL;
+
+ memset(dsa_packet, 0, head);
+ memset(dsa_packet + head + length, 0, tail);
+ memcpy(dsa_packet + head, packet, length);
+ length += head + tail;
+
+ err = ops->xmit(dev, ppriv->index, dsa_packet, length);
+ if (err)
+ return err;
+
+ return eth_get_ops(master)->send(master, dsa_packet, length);
+}
+
+/* Receive a frame from master Ethernet, process it and pass it on */
+static int dsa_port_recv(struct udevice *pdev, int flags, uchar **packetp)
+{
+ struct udevice *dev = dev_get_parent(pdev);
+ struct dsa_perdev_platdata *platdata = dev_get_platdata(dev);
+ struct udevice *master = dsa_port_get_master(pdev);
+ struct dsa_port_platdata *ppriv = dev_get_priv(pdev);
+ struct dsa_ops *ops = dsa_get_ops(dev);
+ int head = platdata->headroom, tail = platdata->tailroom;
+ int length, port_index, err;
+
+ if (!master)
+ return -EINVAL;
+
+ length = eth_get_ops(master)->recv(master, flags, packetp);
+ if (length <= 0)
+ return length;
+
+ /*
+ * if we receive frames from a different port or frames that DSA driver
+ * doesn't like we discard them here.
+ * In case of discard we return with no frame and expect to be called
+ * again instead of looping here, so upper layer can deal with timeouts
+ * and ctrl-c
+ */
+ err = ops->rcv(dev, &port_index, *packetp, length);
+ if (err || port_index != ppriv->index || (length <= head + tail)) {
+ if (eth_get_ops(master)->free_pkt)
+ eth_get_ops(master)->free_pkt(master, *packetp, length);
+ return -EAGAIN;
+ }
+
+ /*
+ * We move the pointer over headroom here to avoid a copy. If free_pkt
+ * gets called we move the pointer back before calling master free_pkt.
+ */
+ *packetp += head;
+
+ return length - head - tail;
+}
+
+static int dsa_port_free_pkt(struct udevice *pdev, uchar *packet, int length)
+{
+ struct udevice *dev = dev_get_parent(pdev);
+ struct dsa_perdev_platdata *platdata = dev_get_platdata(dev);
+ struct udevice *master = dsa_port_get_master(pdev);
+
+ if (!master)
+ return -EINVAL;
+
+ if (eth_get_ops(master)->free_pkt) {
+ /* return the original pointer and length to master Eth */
+ packet -= platdata->headroom;
+ length += platdata->headroom - platdata->tailroom;
+
+ return eth_get_ops(master)->free_pkt(master, packet, length);
+ }
+
+ return 0;
+}
+
+static int dsa_port_probe(struct udevice *pdev)
+{
+ struct udevice *master = dsa_port_get_master(pdev);
+ unsigned char env_enetaddr[ARP_HLEN];
+
+ /* If there is no MAC address in the environment, inherit it
+ * from the DSA master.
+ */
+ eth_env_get_enetaddr_by_index("eth", pdev->seq, env_enetaddr);
+ if (!is_zero_ethaddr(env_enetaddr))
+ return 0;
+
+ if (master) {
+ struct eth_pdata *slave_pdata, *master_pdata;
+
+ master_pdata = dev_get_platdata(master);
+ slave_pdata = dev_get_platdata(pdev);
+ memcpy(slave_pdata->enetaddr, master_pdata->enetaddr,
+ ARP_HLEN);
+ eth_env_set_enetaddr_by_index("eth", pdev->seq,
+ master_pdata->enetaddr);
+ }
+
+ return 0;
+}
+
+static const struct eth_ops dsa_port_ops = {
+ .start = dsa_port_start,
+ .send = dsa_port_send,
+ .recv = dsa_port_recv,
+ .stop = dsa_port_stop,
+ .free_pkt = dsa_port_free_pkt,
+};
+
+U_BOOT_DRIVER(dsa_port) = {
+ .name = DSA_PORT_CHILD_DRV_NAME,
+ .id = UCLASS_ETH,
+ .ops = &dsa_port_ops,
+ .probe = dsa_port_probe,
+ .platdata_auto_alloc_size = sizeof(struct eth_pdata),
+};
+
+/*
+ * reads the DT properties of the given DSA port.
+ * If the return value is != 0 then the port is skipped
+ */
+static int dsa_port_parse_dt(struct udevice *dev, int port_index,
+ ofnode ports_node, bool *is_cpu)
+{
+ struct dsa_perdev_platdata *platdata = dev_get_platdata(dev);
+ struct dsa_port_platdata *port = &platdata->port[port_index];
+ ofnode temp_node;
+ u32 ethernet;
+
+ /*
+ * if we don't have a DT we don't do anything here but the port is
+ * registered normally
+ */
+ if (!ofnode_valid(ports_node))
+ return 0;
+
+ ofnode_for_each_subnode(temp_node, ports_node) {
+ const char *port_label;
+ u32 reg;
+
+ if (ofnode_read_u32(temp_node, "reg", &reg) ||
+ reg != port_index)
+ continue;
+
+ port->node = temp_node;
+
+ /* if the port is explicitly disabled in DT skip it */
+ if (!ofnode_is_available(temp_node))
+ return -ENODEV;
+
+ dev_dbg(dev, "port %d node %s\n", port->index,
+ ofnode_get_name(port->node));
+
+ /* Use 'label' if present in DT */
+ port_label = ofnode_read_string(port->node, "label");
+ if (port_label)
+ strncpy(port->name, port_label, DSA_PORT_NAME_LENGTH);
+
+ *is_cpu = !ofnode_read_u32(port->node, "ethernet",
+ &ethernet);
+
+ if (*is_cpu) {
+ platdata->master_node =
+ ofnode_get_by_phandle(ethernet);
+ platdata->cpu_port = port_index;
+
+ dev_dbg(dev, "master node %s on port %d\n",
+ ofnode_get_name(platdata->master_node),
+ port_index);
+ }
+ break;
+ }
+
+ return 0;
+}
+
+/**
+ * This function mostly deals with pulling information out of the device tree
+ * into the platdata structure.
+ * It goes through the list of switch ports, registers an Eth device for each
+ * front panel port and identifies the cpu port connected to master Eth device.
+ * TODO: support cascaded switches
+ */
+static int dm_dsa_post_bind(struct udevice *dev)
+{
+ struct dsa_perdev_platdata *platdata = dev_get_platdata(dev);
+ ofnode ports_node = ofnode_null();
+ int first_err = 0, err = 0, i;
+
+ if (!platdata) {
+ dev_err(dev, "missing plaform data\n");
+ return -EINVAL;
+ }
+
+ if (platdata->num_ports <= 0 || platdata->num_ports > DSA_MAX_PORTS) {
+ dev_err(dev, "unexpected num_ports value (%d)\n",
+ platdata->num_ports);
+ return -EINVAL;
+ }
+
+ platdata->master_node = ofnode_null();
+
+ if (!ofnode_valid(dev->node)) {
+ dev_dbg(dev, "Device doesn't have a valid DT node!\n");
+ } else {
+ ports_node = ofnode_find_subnode(dev->node, "ports");
+ if (!ofnode_valid(ports_node))
+ dev_dbg(dev,
+ "ports node is missing under DSA device!\n");
+ }
+
+ for (i = 0; i < platdata->num_ports; i++) {
+ struct dsa_port_platdata *port = &platdata->port[i];
+ bool skip_port, is_cpu = false;
+
+ port->index = i;
+
+ /*
+ * If the driver set up port names in _bind use those, otherwise
+ * use default ones.
+ * If present, DT label is used as name and overrides anything
+ * we may have here.
+ */
+ if (!strlen(port->name))
+ snprintf(port->name, DSA_PORT_NAME_LENGTH, "%s@%d",
+ dev->name, i);
+
+ skip_port = !!dsa_port_parse_dt(dev, i, ports_node, &is_cpu);
+
+ /*
+ * if this is the CPU port don't register it as an ETH device,
+ * we skip it on purpose since I/O to/from it from the CPU
+ * isn't useful
+ * TODO: cpu port may have a PHY and we don't handle that yet.
+ */
+ if (is_cpu || skip_port)
+ continue;
+
+ err = device_bind_driver_to_node(dev, DSA_PORT_CHILD_DRV_NAME,
+ port->name, port->node,
+ &port->dev);
+
+ /* try to bind all ports but keep 1st error */
+ if (err && !first_err)
+ first_err = err;
+ }
+
+ if (!ofnode_valid(platdata->master_node))
+ dev_dbg(dev, "DSA master Eth device is missing!\n");
+
+ return first_err;
+}
+
+/**
+ * This function deals with additional devices around the switch as these should
+ * have been bound to drivers by now.
+ * TODO: pick up references to other switch devices here, if we're cascaded.
+ */
+static int dm_dsa_pre_probe(struct udevice *dev)
+{
+ struct dsa_perdev_platdata *platdata = dev_get_platdata(dev);
+ int i;
+
+ if (!platdata)
+ return -EINVAL;
+
+ if (ofnode_valid(platdata->master_node)) {
+ uclass_find_device_by_ofnode(UCLASS_ETH, platdata->master_node,
+ &platdata->master_dev);
+ device_probe(platdata->master_dev);
+ }
+
+ for (i = 0; i < platdata->num_ports; i++) {
+ struct dsa_port_platdata *port = &platdata->port[i];
+
+ if (port->dev) {
+ port->dev->priv = port;
+ port->phy = dm_eth_phy_connect(port->dev);
+ }
+ }
+
+ return 0;
+}
+
+UCLASS_DRIVER(dsa) = {
+ .id = UCLASS_DSA,
+ .name = "dsa",
+ .post_bind = dm_dsa_post_bind,
+ .pre_probe = dm_dsa_pre_probe,
+ .per_device_platdata_auto_alloc_size =
+ sizeof(struct dsa_perdev_platdata),
+};
diff --git a/test/dm/dsa.c b/test/dm/dsa.c
new file mode 100644
index 0000000000..b3ffed2f94
--- /dev/null
+++ b/test/dm/dsa.c
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2019 NXP
+ */
+
+#include <dsa.h>
+#include <dm/test.h>
+#include <test/ut.h>
+
+extern int dsa_sandbox_port_mask;
+
+/* this test sends ping requests with the local address through each DSA port
+ * via the dummy DSA master Eth.
+ * The dummy Eth filters traffic based on DSA port used to Tx and the port
+ * mask set here, so we can check that port information gets trough correctly.
+ */
+static int dm_test_dsa(struct unit_test_state *uts)
+{
+ dsa_sandbox_port_mask = 0x5;
+
+ env_set("ethrotate", "no");
+ net_ping_ip = string_to_ip("1.2.3.4");
+
+ env_set("ethact", "dsa-test-eth");
+ ut_assertok(net_loop(PING));
+
+ dsa_sandbox_port_mask = 0x7;
+ env_set("ethact", "lan0");
+ ut_assertok(net_loop(PING));
+ env_set("ethact", "lan1");
+ ut_assertok(net_loop(PING));
+ env_set("ethact", "lan2");
+ ut_assertok(net_loop(PING));
+
+ dsa_sandbox_port_mask = 0x1;
+ env_set("ethact", "lan0");
+ ut_assertok(net_loop(PING));
+ env_set("ethact", "lan1");
+ ut_assert(net_loop(PING) != 0);
+ env_set("ethact", "lan2");
+ ut_assert(net_loop(PING) != 0);
+
+ dsa_sandbox_port_mask = 0x6;
+ env_set("ethact", "lan0");
+ ut_assert(net_loop(PING) != 0);
+ env_set("ethact", "lan1");
+ ut_assertok(net_loop(PING));
+ env_set("ethact", "lan2");
+ ut_assertok(net_loop(PING));
+
+ dsa_sandbox_port_mask = 0;
+ env_set("ethact", "");
+ env_set("ethrotate", "yes");
+
+ return 0;
+}
+
+DM_TEST(dm_test_dsa, DM_TESTF_SCAN_FDT);
diff --git a/arch/arm/dts/zynq-scalp.dts b/arch/arm/dts/zynq-scalp.dts
new file mode 100644
index 0000000000..1de462dfcd
--- /dev/null
+++ b/arch/arm/dts/zynq-scalp.dts
@@ -0,0 +1,302 @@
+/*
+ * Scalp Board DTS
+ *
+ * Copyright (c) 2018-2021 Hepia
+ * Joachim Schmidt <joachim.schmidt@hesge.ch>
+ *
+ */
+
+/dts-v1/;
+#include "zynq-7000.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+ model = "Zynq Scalp Board";
+ compatible = "xlnx,zynq-scalp", "xlnx,zynq-7000";
+
+ aliases {
+ serial0 = &uart0; /* Bottom : MIO 46 - 47 (Switch on schematic) */
+ serial1 = &uart1; /* Top : MIO 48 - 49 */
+ ethernet0 = &gem5; /* MIO 16 - 27 */
+ /* Switch the name. QSPI first */
+ spi0 = &qspi; /* MIO 1 - 6 */
+ spi1 = &spi0; /* MIO 40 - 41, 45 */
+ spi2 = &spi1; /* EMIO */
+ mmc0 = &sdhci1; /* MIO 10 - 15, 9 (card detect) */
+ usb0 = &usb0; /* MIO 28 - 39 */
+ i2c0 = &i2c0; /* MIO 50 - 51 */
+ can0 = &can1; /* MIO 52 - 53 */
+ //gpio0 = &gpio0; /* MIO 0, 7, 8, 43, 44 */
+ };
+
+ /* 256 MB DDR3 */
+ memory@0 {
+ device_type = "memory";
+ reg = <0 0x10000000>;
+ };
+
+ chosen {
+ bootargs = "earlyprintk cpuidle.off=1 crashkernel=256M rw";
+ stdout-path = "serial0:115200n8";
+ xlnx,eeprom = &eeprom;
+ };
+};
+
+/* PS_Clk50M_i */
+&clkc {
+ fclk-enable = <0x1>;
+ ps-clk-frequency = <50000000>;
+};
+
+&intc {
+ num_cpus = <2>;
+ num_interrupts = <96>;
+};
+
+/* serial0 */
+&uart0 {
+ u-boot,dm-pre-reloc;
+ cts-override ;
+ device_type = "serial";
+ port-number = <0>;
+ status = "okay";
+};
+
+/* serial1 */
+&uart1 {
+ u-boot,dm-pre-reloc;
+ cts-override ;
+ device_type = "serial";
+ port-number = <1>;
+ status = "okay";
+};
+
+&qspi {
+ u-boot,dm-pre-reloc;
+ status = "okay";
+ is-dual = <0>;
+ num-cs = <1>;
+
+ /* Erase sector size of 64KB */
+ flash@0 {
+ /* compatible = "s25fl256s_64k"; drivers/mtd/spi/spi_flash_ids.c */
+ /* compatible = "spansion,s25fl256s1", "jedec,spi-nor"; */
+ /* compatible = "spansion,S25FL256S_64K", "spi-flash"; */
+ compatible = "spansion,s25fl256s", "jedec,spi-nor";
+ reg = <0x0>;
+ spi-tx-bus-width = <1>;
+ spi-rx-bus-width = <4>;
+ spi-max-frequency = <50000000>;
+ /* m25p,fast-read; */
+ #address-cells = <1>;
+ #size-cells = <1>;
+ };
+
+ // /* FSBL + safe bitstream (design with only Zynq) + U-Boot + (devicetree) => BOOT.BIN */
+ // /* Size : 5242880 Bytes */
+ // partition@boot {
+ // label = "boot";
+ // reg = <0x0 0x500000>;
+ // };
+
+ // /* Safe U-Boot Env. */
+ // /* Size : 131072 Bytes */
+ // partition@bootenv {
+ // label = "bootenv";
+ // reg = <0x500000 0x20000>;
+ // };
+
+ // /* Safe Fit Image */
+ // /* Size : 28049408 Bytes */
+ // partition@fitimage {
+ // label = "fitimage";
+ // reg = <0x520000 0x1ac0000>;
+ // };
+
+ // /* Safe DTB */
+ // /* Size : 131072 Bytes */
+ // partition@dtb {
+ // label = "dtb";
+ // reg = <0x1ac0000 0x20000>;
+ // };
+ // };
+};
+
+/* Switch Ethernet 5 ports - SPI0 - MIO 40, 41, 42, 45 */
+
+/*
+ * Port 0 => East
+ * Port 1 => Local
+ * Port 2 => Bottom
+ * Port 3 => Top
+ * Port 4 => West
+ */
+
+/* (PYH + Delay)
+ * Top 3
+ *
+ * 4 (MAC) West East (PHY + Delay) 0
+ *
+ * Bottom 2
+ * (MAC)
+ *
+ */
+
+&spi0 {
+ bus-num = <0>;
+ status = "okay";
+
+ sja1105@0 {
+ reg = <0>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "nxp,sja1105t";
+ reset-gpios = <&gpio0 44 GPIO_ACTIVE_LOW>;
+ spi-max-frequency = <12000000>;
+ spi-cpha;
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ swp0_east: port@0 {
+ label = "swp0_east";
+ phy-handle = <&rgmii_phy0>;
+ phy-mode = "rgmii-id";
+ reg = <0>;
+ //sja1105,role-phy;
+
+ // fixed-link {
+ // speed = <10>;
+ // full-duplex;
+ // };
+ };
+
+ port@1 {
+ ethernet = <&gem5>;
+ phy-mode = "rgmii";
+ reg = <1>;
+ //sja1105,role-phy;
+
+ fixed-link {
+ speed = <1000>;
+ full-duplex;
+ };
+ };
+
+ swp2_bottom: port@2 {
+ label = "swp2_bottom";
+ phy-handle = <&rgmii_phy1>;
+ phy-mode = "rgmii-id";
+ reg = <2>;
+ //sja1105,role-mac;
+
+ // fixed-link {
+ // speed = <10>;
+ // full-duplex;
+ // };
+ };
+
+ swp3_top: port@3 {
+ label = "swp3_top";
+ phy-handle = <&rgmii_phy2>;
+ phy-mode = "rgmii-id";
+ reg = <3>;
+ //sja1105,role-phy;
+
+ // fixed-link {
+ // speed = <10>;
+ // full-duplex;
+ // };
+ };
+
+ swp4_west: port@4 {
+ label = "swp4_west";
+ phy-handle = <&rgmii_phy3>;
+ phy-mode = "rgmii-id";
+ reg = <4>;
+ //sja1105,role-mac;
+
+ // fixed-link {
+ // speed = <10>;
+ // full-duplex;
+ // };
+ };
+ };
+ };
+};
+
+&mdio0 {
+ compatible = "sandbox,mdio"
+
+ rgmii_phy0: ethernet-phy@0 {
+ reg = <0x0>;
+ };
+ rgmii_phy1: ethernet-phy@1 {
+ reg = <0x1>;
+ };
+ rgmii_phy2: ethernet-phy@2 {
+ reg = <0x2>;
+ };
+ rgmii_phy3: ethernet-phy@3 {
+ reg = <0x3>;
+ };
+};
+
+/* ethernet0 */
+&gem5 {
+ status = "okay";
+ phy-mode = "rgmii";
+ xlnx,ptp-enet-clock = <0x7735940>;
+
+ fixed-link {
+ speed = <1000>;
+ full-duplex;
+ };
+};
+
+/* spi2 */
+&spi1 {
+ u-boot,dm-pre-reloc;
+ is-decoded-cs = <0>;
+ num-cs = <3>;
+ status = "okay";
+};
+
+&gpio0 {
+ emio-gpio-width = <64>;
+ gpio-mask-high = <0x0>;
+ gpio-mask-low = <0x5600>;
+};
+
+/* mmc0 */
+&sdhci1 {
+ u-boot,dm-pre-reloc;
+ xlnx,has-cd = <0x1>;
+ xlnx,has-power = <0x0>;
+ xlnx,has-wp = <0x0>;
+ status = "okay";
+};
+
+/* usb0 */
+/*&usb0 {
+ u-boot,dm-pre-reloc;
+ phy_type = "ulpi";
+ status = "okay";
+};*/
+
+/* i2c0 */
+&i2c0 {
+ status = "okay";
+
+ eeprom: eeprom@53 {
+ compatible = "microchip,24aa02e48";
+ reg = <0x53>;
+ };
+};
+
+/* can0 */
+&can1 {
+ u-boot,dm-pre-reloc;
+ status = "okay";
+};
diff --git a/arch/arm/dts/zynq-scalp.dts b/arch/arm/dts/zynq-scalp.dts diff --git a/arch/arm/dts/zynq-scalp.dts b/arch/arm/dts/zynq-scalp.dts
new file mode 100644 new file mode 100644
index 0000000000..fb7bebd40d index 0000000000..197e776b4b
--- /dev/null --- /dev/null
+++ b/arch/arm/dts/zynq-scalp.dts +++ b/arch/arm/dts/zynq-scalp.dts
@@ -0,0 +1,287 @@ @@ -0,0 +1,283 @@
+/* +/*
+ * Scalp Board DTS + * Scalp Board DTS
+ * + *
...@@ -96,36 +96,32 @@ index 0000000000..fb7bebd40d ...@@ -96,36 +96,32 @@ index 0000000000..fb7bebd40d
+ /* m25p,fast-read; */ + /* m25p,fast-read; */
+ #address-cells = <1>; + #address-cells = <1>;
+ #size-cells = <1>; + #size-cells = <1>;
+ };
+ +
+ // /* FSBL + safe bitstream (design with only Zynq) + U-Boot + (devicetree) => BOOT.BIN */ + partition@boot {
+ // /* Size : 5242880 Bytes */ + label = "boot";
+ // partition@boot { + reg = <0x0 0x500000>;
+ // label = "boot"; + };
+ // reg = <0x0 0x500000>; +
+ // }; + partition@bootenv {
+ + label = "bootenv";
+ // /* Safe U-Boot Env. */ + reg = <0x500000 0x20000>;
+ // /* Size : 131072 Bytes */ + };
+ // partition@bootenv { +
+ // label = "bootenv"; + partition@dtb {
+ // reg = <0x500000 0x20000>; + label = "dtb";
+ // }; + reg = <0x520000 0x20000>;
+ + };
+ // /* Safe Fit Image */ +
+ // /* Size : 28049408 Bytes */ + partition@fitimage {
+ // partition@fitimage { + label = "fitimage";
+ // label = "fitimage"; + reg = <0x540000 0x800000>;
+ // reg = <0x520000 0x1ac0000>; + };
+ // }; +
+ + partition@ubifs {
+ // /* Safe DTB */ + label = "ubifs";
+ // /* Size : 131072 Bytes */ + reg = <0xD40000 0x12C0000>;
+ // partition@dtb { + };
+ // label = "dtb"; + };
+ // reg = <0x1ac0000 0x20000>;
+ // };
+ // };
+}; +};
+ +
+/* Switch Ethernet 5 ports - SPI0 - MIO 40, 41, 42, 45 */ +/* Switch Ethernet 5 ports - SPI0 - MIO 40, 41, 42, 45 */
...@@ -171,10 +167,10 @@ index 0000000000..fb7bebd40d ...@@ -171,10 +167,10 @@ index 0000000000..fb7bebd40d
+ reg = <0>; + reg = <0>;
+ //sja1105,role-phy; + //sja1105,role-phy;
+ +
+ // fixed-link { + fixed-link {
+ // speed = <10>; + speed = <1000>;
+ // full-duplex; + full-duplex;
+ // }; + };
+ }; + };
+ +
+ port@1 { + port@1 {
...@@ -184,7 +180,7 @@ index 0000000000..fb7bebd40d ...@@ -184,7 +180,7 @@ index 0000000000..fb7bebd40d
+ //sja1105,role-phy; + //sja1105,role-phy;
+ +
+ fixed-link { + fixed-link {
+ speed = <10>; + speed = <1000>;
+ full-duplex; + full-duplex;
+ }; + };
+ }; + };
...@@ -195,10 +191,10 @@ index 0000000000..fb7bebd40d ...@@ -195,10 +191,10 @@ index 0000000000..fb7bebd40d
+ reg = <2>; + reg = <2>;
+ //sja1105,role-mac; + //sja1105,role-mac;
+ +
+ // fixed-link { + fixed-link {
+ // speed = <10>; + speed = <1000>;
+ // full-duplex; + full-duplex;
+ // }; + };
+ }; + };
+ +
+ swp3_top: port@3 { + swp3_top: port@3 {
...@@ -207,10 +203,10 @@ index 0000000000..fb7bebd40d ...@@ -207,10 +203,10 @@ index 0000000000..fb7bebd40d
+ reg = <3>; + reg = <3>;
+ //sja1105,role-phy; + //sja1105,role-phy;
+ +
+ // fixed-link { + fixed-link {
+ // speed = <10>; + speed = <1000>;
+ // full-duplex; + full-duplex;
+ // }; + };
+ }; + };
+ +
+ swp4_west: port@4 { + swp4_west: port@4 {
...@@ -219,10 +215,10 @@ index 0000000000..fb7bebd40d ...@@ -219,10 +215,10 @@ index 0000000000..fb7bebd40d
+ reg = <4>; + reg = <4>;
+ //sja1105,role-mac; + //sja1105,role-mac;
+ +
+ // fixed-link { + fixed-link {
+ // speed = <10>; + speed = <1000>;
+ // full-duplex; + full-duplex;
+ // }; + };
+ }; + };
+ }; + };
+ }; + };
......
diff --git a/arch/arm/dts/zynq-scalp.dts b/arch/arm/dts/zynq-scalp.dts
new file mode 100644
index 0000000000..15645d642d
--- /dev/null
+++ b/arch/arm/dts/zynq-scalp.dts
@@ -0,0 +1,204 @@
+/*
+ * Scalp Board DTS
+ *
+ * Copyright (c) 2018-2021 Hepia
+ * Joachim Schmidt <joachim.schmidt@hesge.ch>
+ *
+ */
+
+/dts-v1/;
+#include "zynq-7000.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+ model = "Zynq Scalp Board";
+ compatible = "xlnx,zynq-scalp", "xlnx,zynq-7000";
+
+ aliases {
+ serial0 = &uart0; /* Bottom : MIO 46 - 47 (Switch on schematic) */
+ serial1 = &uart1; /* Top : MIO 48 - 49 */
+ ethernet0 = &gem0; /* MIO 16 - 27 */
+ /* Switch the name. QSPI first */
+ spi0 = &qspi; /* MIO 1 - 6 */
+ spi1 = &spi0; /* MIO 40 - 41, 45 */
+ spi2 = &spi1; /* EMIO */
+ mmc0 = &sdhci1; /* MIO 10 - 15, 9 (card detect) */
+ usb0 = &usb0; /* MIO 28 - 39 */
+ i2c0 = &i2c0; /* MIO 50 - 51 */
+ can0 = &can1; /* MIO 52 - 53 */
+ //gpio0 = &gpio0; /* MIO 0, 7, 8, 43, 44 */
+ };
+
+ /* 256 MB DDR3 */
+ memory@0 {
+ device_type = "memory";
+ reg = <0 0x10000000>;
+ };
+
+ chosen {
+ bootargs = "earlyprintk cpuidle.off=1 crashkernel=256M rw";
+ stdout-path = "serial0:115200n8";
+ xlnx,eeprom = &eeprom;
+ };
+};
+
+/* PS_Clk50M_i */
+&clkc {
+ fclk-enable = <0x1>;
+ ps-clk-frequency = <50000000>;
+};
+
+&intc {
+ num_cpus = <2>;
+ num_interrupts = <96>;
+};
+
+/* serial0 */
+&uart0 {
+ u-boot,dm-pre-reloc;
+ cts-override ;
+ device_type = "serial";
+ port-number = <0>;
+ status = "okay";
+};
+
+/* serial1 */
+&uart1 {
+ u-boot,dm-pre-reloc;
+ cts-override ;
+ device_type = "serial";
+ port-number = <1>;
+ status = "okay";
+};
+
+&qspi {
+ u-boot,dm-pre-reloc;
+ status = "okay";
+ is-dual = <0>;
+ num-cs = <1>;
+
+ /* Erase sector size of 64KB */
+ flash@0 {
+ /* compatible = "s25fl256s_64k"; drivers/mtd/spi/spi_flash_ids.c */
+ /* compatible = "spansion,s25fl256s1", "jedec,spi-nor"; */
+ /* compatible = "spansion,S25FL256S_64K", "spi-flash"; */
+ compatible = "spansion,s25fl256s", "jedec,spi-nor";
+ reg = <0x0>;
+ spi-tx-bus-width = <1>;
+ spi-rx-bus-width = <4>;
+ spi-max-frequency = <50000000>;
+ /* m25p,fast-read; */
+ #address-cells = <1>;
+ #size-cells = <1>;
+ };
+
+ // /* FSBL + safe bitstream (design with only Zynq) + U-Boot + (devicetree) => BOOT.BIN */
+ // /* Size : 5242880 Bytes */
+ // partition@boot {
+ // label = "boot";
+ // reg = <0x0 0x500000>;
+ // };
+
+ // /* Safe U-Boot Env. */
+ // /* Size : 131072 Bytes */
+ // partition@bootenv {
+ // label = "bootenv";
+ // reg = <0x500000 0x20000>;
+ // };
+
+ // /* Safe Fit Image */
+ // /* Size : 28049408 Bytes */
+ // partition@fitimage {
+ // label = "fitimage";
+ // reg = <0x520000 0x1ac0000>;
+ // };
+
+ // /* Safe DTB */
+ // /* Size : 131072 Bytes */
+ // partition@dtb {
+ // label = "dtb";
+ // reg = <0x1ac0000 0x20000>;
+ // };
+ // };
+};
+
+&spi0 {
+ bus-num = <0>;
+ status = "okay";
+
+ /* SCALP specific SJA1105T driver */
+ sja1105@0 {
+ reg = <0>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "scalp,sja1105t";
+ reset-gpios = <&gpio0 44 GPIO_ACTIVE_LOW>;
+ spi-max-frequency = <12000000>;
+ spi-cpha;
+ };
+};
+
+/* ethernet0 */
+&gem0 {
+ status = "okay";
+ phy-mode = "moca";
+ //phy-mode = "rgmii"; /* "rgmii_id" */
+ //phy-handle = <&ethernet_phy>;
+ xlnx,ptp-enet-clock = <0x7735940>;
+ //local-mac-address = [00 0a 35 00 00 00];
+
+ fixed-link {
+ speed = <1000>;
+ full-duplex;
+ };
+
+ //ethernet_phy: ethernet-phy@0 {
+ // reg = <0>;
+ //};
+};
+
+/* spi2 */
+&spi1 {
+ u-boot,dm-pre-reloc;
+ is-decoded-cs = <0>;
+ num-cs = <3>;
+ status = "okay";
+};
+
+&gpio0 {
+ emio-gpio-width = <64>;
+ gpio-mask-high = <0x0>;
+ gpio-mask-low = <0x5600>;
+};
+
+/* mmc0 */
+&sdhci1 {
+ u-boot,dm-pre-reloc;
+ xlnx,has-cd = <0x1>;
+ xlnx,has-power = <0x0>;
+ xlnx,has-wp = <0x0>;
+ status = "okay";
+};
+
+/* usb0 */
+/*&usb0 {
+ u-boot,dm-pre-reloc;
+ phy_type = "ulpi";
+ status = "okay";
+};*/
+
+/* i2c0 */
+&i2c0 {
+ status = "okay";
+
+ eeprom: eeprom@53 {
+ compatible = "microchip,24aa02e48";
+ reg = <0x53>;
+ };
+};
+
+/* can0 */
+&can1 {
+ u-boot,dm-pre-reloc;
+ status = "okay";
+};
...@@ -4,8 +4,8 @@ SRC_URI += "file://platform-top.h \ ...@@ -4,8 +4,8 @@ SRC_URI += "file://platform-top.h \
file://devtool-fragment.cfg \ file://devtool-fragment.cfg \
" "
SRC_URI += "file://u-boot-setexpt.patch" SRC_URI += "file://u-boot-setexpt.patch"
SRC_URI += "file://u-boot-scalp-sja1105.patch" SRC_URI += "file://u-boot-scalp-sja1105-official.patch"
SRC_URI += "file://u-boot-zynq-scalp-dts.patch" SRC_URI += "file://u-boot-zynq-scalp-dts-sja1105-official.patch"
do_configure_append () { do_configure_append () {
if [ "${U_BOOT_AUTO_CONFIG}" = "1" ]; then if [ "${U_BOOT_AUTO_CONFIG}" = "1" ]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment