Add latest U-boot support for BPI R2 & BPI R64 (not yet)

https://github.com/frank-w/u-boot/commits/2019-07-bpi-r2-sata_new

ready for submission :slight_smile: anything i should write in coverletter else why we want to add this and that it depends on ryders-patches for hifsys?

Subject: [PATCH 0/4] add pcie/ahci for mt7623/bpi-r2

with this Patchseries i want to add ahci-support (sata) for bananapi-r2

pci-driver may support other devices too using mt2701 for pcie, but in first step pcie is only activated for mt7623 (dts)

Patches depend on hifsys-patches from ryder.lee:

https://patchwork.ozlabs.org/project/uboot/list/?series=121987

also applies cleanly on 2019-10-rc1 (with ryders Patches first)

just a detail…shouldn’t i remove the commented lines in dts?

Yup, remove them.

Anyway them useless, until we replace to original DTS.

all ok, including cover-letter? then i send it out…

Nobody punish us for that :slight_smile:

we will see :stuck_out_tongue: sent it out…

1 Like

@ray: @Ryder.Lee posted some comments :wink: can you try to change it according to it?

first one is easy…replace defines directly by the readX/writeX…but the others (remove magic numbers or put something from code to dts is imho bit tricky)

i try to fix what i can…but i cannot decode magic-numbers, move things from code to dts or rewrite driver to match other devices based on linux-driver/tphy

Looks funny. :slight_smile:

Man who working in Mediatek asking you to replace reverse engineered numbers to names that know Mediatek :slight_smile:

i think we will need his help for changing this, we cannot rewrite the driver to state of linux’ one

but i made a basic change to access the dts :slight_smile:

now we can access the dts by functions defined in ofnode.h

cute

Extract “ranges” and use them instead of defines @Ryder.Lee said.

But I like to left defines, and use them if you have problem extracting FDT data.

is there any example/description how to decode the ranges the right way? There seem to be a helper function:

https://elixir.bootlin.com/u-boot/latest/source/common/fdt_support.c#L1591

But the address-params are still unclear to me and how to get the right index

board/freescale/qemu-ppce500/qemu-ppce500.c should help

Basicly use fdt_getprop…but how to the right index? The file seems to decode to physical adresses, but i need the values like they are listed…

Btw. Ryder posted some code for pcie driver,but i’ve not found access to dts yet :frowning:

Seems to be this:

pcie->base = dev_remap_addr_name(dev, "subsys");

similar call for Ports (snprintf(…“port%d”, slot) as second param).

have added the Patch in my repo

compiles without warnings, but hangs on pci enum till watchdog resets the board…

at a first check it seems that this is not successful:

266     dev_for_each_subnode(subnode, dev) {
267         struct fdt_pci_addr addr;
268         u32 slot = 0;
269 printk(KERN_ALERT "DEBUG: Passed %s %d \n",__FUNCTION__,__LINE__); //this is printed 3 times (for each pci-port)
270         if (!ofnode_is_available(subnode))
271             continue;
272
273 printk(KERN_ALERT "DEBUG: Passed %s %d \n",__FUNCTION__,__LINE__); //this printk isn't called => !ofnode_is_available(subnode)
274
275         err = ofnode_read_pci_addr(subnode, 0, "reg", &addr);

as far as i see, each port needs to have status-field with “okay”…and i see that is disabled in my dts :smiley:

after fixed this (should not reset the board…only print nothing found or similar) i hang here:

221 printk(KERN_ALERT "DEBUG: Passed %s %d \n",__FUNCTION__,__LINE__); //gets printed
222     err = reset_get_by_index(dev, slot, &port->reset);
223     if (err)
224         return err;
225 printk(KERN_ALERT "DEBUG: Passed %s %d \n",__FUNCTION__,__LINE__); //gets not printed
226     err = generic_phy_get_by_index(dev, slot, &port->phy);

after getting the reset-values printed, i see that is not set (0,0,0), seems we need to get reset-values first

should be

reset-names = "pcie-rst0", "pcie-rst1", "pcie-rst2";

in pci-controller-root-node. do we need ./drivers/reset/reset-mediatek.c here or only read the dts-property into the reset-struct?

seems there is something missing in dts…i see reset-names but no “resets”, this property was disabled by // in old dtsi :slight_smile: i try to add it back…strange after i added them back i got no message on pci enum…only a watchdog-reset after some time

Oh, look at that driver: https://elixir.bootlin.com/u-boot/latest/source/drivers/pci/pci-rcar-gen3.c

Looks like regions automatically parsed. So you need just:

struct pci_controller *hose = dev_get_uclass_priv(dev);
hose->regions[0].phys_start - as MEM region base
hose->regions[1].phys_start - as IO region base

You digging too deep to tell me your current position by few words :slight_smile:

resets are not found by ryders code…because they are deleted…i added them this way:

281         resets = <&hifsys HIFSYS_PCIE0_RST>,
282              <&hifsys HIFSYS_PCIE1_RST>,
283              <&hifsys HIFSYS_PCIE2_RST>;

but now nothing is printed on pci-enum (not the debug-messages i see before)

https://github.com/frank-w/u-boot/commits/sata_test_ryder

accidentaly removed my debug-messages by “git reset”

now i see much more, but resets still 0

DEBUG: Passed mtk_pcie_probe 247                                                                                                     
DEBUG: Passed mtk_pcie_probe 252                                                                                                     
DEBUG: Passed mtk_pcie_probe 258                                                                                                     
DEBUG: Passed mtk_pcie_probe 264                                                                                                     
DEBUG: Passed mtk_pcie_probe 269                                                                                                     
DEBUG: Passed mtk_pcie_probe 273                                                                                                     
DEBUG: Passed mtk_pcie_probe 278                                                                                                     
DEBUG: Passed mtk_pcie_parse_port 207                                                                                                
DEBUG: Passed mtk_pcie_parse_port 211                                                                                                
DEBUG: Passed mtk_pcie_parse_port 216                                                                                                
DEBUG: Passed mtk_pcie_parse_port 221 0,0,0                                                                                          
DEBUG: Passed mtk_pcie_parse_port 225                                                                                                
DEBUG: Passed mtk_pcie_parse_port 229                                                                                                
DEBUG: Passed mtk_pcie_parse_port 232                                                                                                
DEBUG: Passed mtk_pcie_parse_port 235                                                                                                
DEBUG: Passed mtk_pcie_probe 269                                                                                                     
DEBUG: Passed mtk_pcie_probe 273                                                                                                     
DEBUG: Passed mtk_pcie_probe 278                                                                                                     
DEBUG: Passed mtk_pcie_parse_port 207                                                                                                
DEBUG: Passed mtk_pcie_parse_port 211                                                                                                
DEBUG: Passed mtk_pcie_parse_port 216                                                                                                
DEBUG: Passed mtk_pcie_parse_port 221 0,0,0                                                                                          
DEBUG: Passed mtk_pcie_parse_port 225                                                                                                
DEBUG: Passed mtk_pcie_parse_port 229                                                                                                
DEBUG: Passed mtk_pcie_parse_port 232                                                                                                
DEBUG: Passed mtk_pcie_parse_port 235                                                                                                
DEBUG: Passed mtk_pcie_probe 269                                                                                                     
DEBUG: Passed mtk_pcie_probe 273                                                                                                     
DEBUG: Passed mtk_pcie_probe 278                                                                                                     
DEBUG: Passed mtk_pcie_parse_port 207                                                                                                
DEBUG: Passed mtk_pcie_parse_port 211                                                                                                
DEBUG: Passed mtk_pcie_parse_port 216                                                                                                
DEBUG: Passed mtk_pcie_parse_port 221 0,0,0                                                                                          
DEBUG: Passed mtk_pcie_parse_port 225                                                                                                
DEBUG: Passed mtk_pcie_parse_port 229                                                                                                
DEBUG: Passed mtk_pcie_parse_port 232                                                                                                
DEBUG: Passed mtk_pcie_parse_port 235                                                                                                
DEBUG: Passed mtk_pcie_probe 285                                                                                                     
DEBUG: Passed mtk_pcie_enable_port 172                                                                                               
DEBUG: Passed mtk_pcie_enable_port 184                                                                                               
DEBUG: Passed mtk_pcie_enable_port 192                                                                                               
DEBUG: Passed mtk_pcie_enable_port 172                                                                                               
DEBUG: Passed mtk_pcie_enable_port 184                                                                                               
DEBUG: Passed mtk_pcie_enable_port 192                                                                                               
DEBUG: Passed mtk_pcie_enable_port 172                                                                                               
DEBUG: Passed mtk_pcie_enable_port 184                                                                                               
DEBUG: Passed mtk_pcie_enable_port 192

ok let’s look at pinmux in dts…

should be this: https://github.com/frank-w/BPI-R2-4.14/blob/6a8cd4974ab40922aa8320f7eee1c8cc26b084de/arch/arm/boot/dts/mt7623.dtsi#L1469

seems dt-bindings for pinctrl are not there…

dt-bindings/pinctrl/mt7623-pinfunc.h

$ ls -1 ./arch/arm/dts/include/dt-bindings/pinctrl/
am33xx.h
am43xx.h
at91.h
bcm2835.h
dra.h
hisi.h
k3.h
omap.h
pads-imx8qm.h
pads-imx8qxp.h
pinctrl-snapdragon.h
pinctrl-tegra.h
pinctrl-tegra-xusb.h
pins-imx8mq.h
r7s72100-pinctrl.h
rockchip.h
stm32-pinfunc.h
sun4i-a10.h

because you lack of pinmux setting in dts and phy driver

and if i read the PCI core correctly - pci_uclass_pre_probe() in pci-uclass.c will parse range automatically.

--- a/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
+++ b/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
@@ -172,6 +172,13 @@
                };
        };

+       pcie_default: pcie-default {
+               mux {
+                       function = "pcie";
+                       groups =  "pcie0_0_perst", "pcie1_0_perst";
+               };
+       };
+
        uart0_pins_a: uart0-default {
                mux {
                        function = "uart";
@@ -201,6 +208,28 @@
        };
 };

+&pcie {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pcie_default>;
+       status = "okay";
+
+       pcie@0,0 {
+               status = "okay";
+       };
+
+       pcie@1,0 {
+               status = "okay";
+       };
+};
+
+&pcie0_phy {
+       status = "okay";
+};
+
+&pcie1_phy {
+       status = "okay";
+};

Just note that the form of uboot pinmux is different than linux mt7623 dts since we wrote a new pinctrl core after 4.19, and this new format is adopted by uboot 7623 at that time.

2 Likes

it’s time to copy complete DTS with all dependencies :slight_smile:

that brings nothing… i tried to copy relavant parts an hung on dt-bindings…

that was the point i hung :wink: maybe we should make a separate thread for pcie/ahci?

that was the point i hung :wink: maybe we should make a separate thread for pcie/ahci?

use the version i posted and add a phy driver

i have started new thread to outsource discussion about this

http://forum.banana-pi.org/t/bpi-r2-uboot-pcie-sata-ahaci/9613