apm821xx: WNDR4700: enumerate PCIe in device-tree
authorChristian Lamparter <chunkeey@gmail.com>
Tue, 11 Aug 2020 23:21:13 +0000 (01:21 +0200)
committerChristian Lamparter <chunkeey@gmail.com>
Sat, 29 Aug 2020 15:14:27 +0000 (17:14 +0200)
This patch adds the pcie-switch and bridge configuration of the
WNDR4700.

This allows to get rid of the legacy firmware monikers and drop
the usbport LED declaration.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
target/linux/apm821xx/base-files/etc/board.d/01_leds
target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
target/linux/apm821xx/dts/netgear-wndr4700.dts
target/linux/apm821xx/files/arch/powerpc/platforms/44x/wndr4700.c

index dd529b528de9446efc6f176895f5bf47e1b0b75d..57598c0ca9363b7743690a81b781fad7f09800ed 100755 (executable)
@@ -42,9 +42,6 @@ netgear,wndap660)
 netgear,wndr4700)
        ucidef_set_led_switch "wan_green" "WAN (green)" "wndr4700:green:wan" "switch0" "0x20"
        ucidef_set_led_netdev "wan_yellow" "WAN (yellow)" "wndr4700:yellow:wan" "eth0.2" "tx rx"
-       ucidef_set_led_usbport "usb3" "USB3" "wndr4700:blue:usb" "usb2-port1" "usb2-port2" "usb3-port1" "usb3-port2"
-       ucidef_set_led_wlan "wlan2g" "WLAN2G" "wndr4700:blue:wlan" "phy0tpt"
-       ucidef_set_led_wlan "wlan5g" "WLAN5G" "wndr4700:blue:wlan" "phy1tpt"
        ;;
 
 *)
index ee58901d18e837ab615e81122e8b237e33cd8299..dcdcf4dc453f264f5f9182b3eaf4b3258bfca14a 100644 (file)
@@ -7,16 +7,16 @@
 board=$(board_name)
 
 case "$FIRMWARE" in
-"pci_wmac0.eeprom")
-       case $board in
-       netgear,wndr4700)
+"ath9k-eeprom-pci-0000:43:00.0.bin")
+        case $board in
+        netgear,wndr4700)
                . /lib/upgrade/nand.sh
 
                if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
-                       caldata_extract_ubi "caldata" 0x5000 0x1000
+                       caldata_extract_ubi "caldata" 0x1000 0x1000
                else
-                       caldata_extract "wifi_data" 0x5000 0x1000
-                       ath9k_patch_mac $(mtd_get_mac_binary wifi_data 0xc)
+                       caldata_extract "wifi_data" 0x1000 0x1000
+                       ath9k_patch_mac $(mtd_get_mac_binary wifi_data 0x0)
                fi
                ;;
        *)
@@ -25,16 +25,16 @@ case "$FIRMWARE" in
        esac
        ;;
 
-"pci_wmac1.eeprom")
-       case $board in
-       netgear,wndr4700)
+"ath9k-eeprom-pci-0000:44:00.0.bin")
+        case $board in
+        netgear,wndr4700)
                . /lib/upgrade/nand.sh
 
                if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
-                       caldata_extract_ubi "caldata" 0x1000 0x1000
+                       caldata_extract_ubi "caldata" 0x5000 0x1000
                else
-                       caldata_extract "wifi_data" 0x1000 0x1000
-                       ath9k_patch_mac $(mtd_get_mac_binary wifi_data 0x0)
+                       caldata_extract "wifi_data" 0x5000 0x1000
+                       ath9k_patch_mac $(mtd_get_mac_binary wifi_data 0xc)
                fi
                ;;
        *)
index 8972d2b030cf15c51b2065089b9267d6c62b7bd4..a1c23896a146196bd5f40cdc31e6b13b60782d73 100644 (file)
                usb-blue {
                        label = "wndr4700:blue:usb";
                        gpios = <&GPIO0 10 GPIO_ACTIVE_HIGH>;
+                       trigger-sources = <&usb2_port 1>, <&usb2_port 2>,
+                                         <&usb3_port 1>, <&usb3_port 2>;
+                       linux,default-trigger = "usbport";
                };
 
                logo-white {
                wlan-blue {
                        label = "wndr4700:blue:wlan";
                        gpios = <&GPIO0 18 GPIO_ACTIVE_HIGH>;
+                       linux,default-trigger = "phy0tpt";
                };
        };
 };
 
 &PCIE0 {
        status = "okay";
+
+       /*
+        * relevant lspci topology:
+        *
+        *      -+-[0000:40]---00.0-[41-7f]----00.0-[42-45]--+-02.0-[43]----00.0
+        *                                                   +-03.0-[44]----00.0
+        *                                                   \-04.0-[45]----00.0
+        *
+        */
+
+       bridge@64,0 {
+               reg = <0x00400000 0 0 0 0>;
+               #address-cells = <3>;
+               #size-cells = <2>;
+               ranges;
+
+               bridge@65,0 {
+                       /* IDT PES4T4 PCI Express Switch */
+                       compatible = "pci111d,803a";
+                       reg = <0x00410000 0 0 0 0>;
+                       #address-cells = <3>;
+                       #size-cells = <2>;
+                       ranges;
+
+                       bridge@66,2 {
+                               compatible = "pci111d,803a";
+                               reg = <0x00421000 0 0 0 0>;
+                               #address-cells = <3>;
+                               #size-cells = <2>;
+                               ranges;
+
+                               wifi0: wifi@67,0 {
+                                       /* Atheros AR9380 5GHz */
+                                       compatible = "pci168c,0030";
+                                       reg = <0x00430000 0 0 0 0>;
+                                       qca,no-eeprom;
+                                       /* wifi CAL & MAC is stored in nvram */
+
+                                       /*
+                                        * Because this was such a pain.
+                                        * Here's the full device path:
+                                        * pci0000:40/0000:40:00.0/0000:41:00.0/0000:42:02.0/0000:43:00.0
+                                        */
+                               };
+                       };
+
+                       bridge@66,3 {
+                               compatible = "pci111d,803a";
+                               reg = <0x00421800 0 0 0 0>;
+                               #address-cells = <3>;
+                               #size-cells = <2>;
+                               ranges;
+
+                               wifi1: wifi@68,0 {
+                                       /* Atheros AR9381 2.4GHz */
+                                       compatible = "pci168c,0033";
+                                       reg = <0x00440000 0 0 0 0>;
+                                       qca,no-eeprom;
+                                       /* wifi CAL & MAC is stored in nvram */
+                               };
+                       };
+
+                       bridge@66,4 {
+                               compatible = "pci111d,803a";
+                               reg = <0x00422000 0 0 0 0>;
+                               #address-cells = <3>;
+                               #size-cells = <2>;
+                               ranges;
+
+                               usb1: usb@69,0 {
+                                       /* Renesas uPD720202 */
+                                       compatible = "pci1912,0015";
+                                       reg = <0x00450000 0 0 0 0>;
+
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       usb2_port: port@1 {
+                                               reg = <1>;
+                                               #trigger-source-cells = <1>;
+                                       };
+
+                                       usb3_port: port@2 {
+                                               reg = <2>;
+                                               #trigger-source-cells = <1>;
+                                       };
+                               };
+                       };
+               };
+       };
 };
 
 &MSI {
index f50f43f3df939cdc3e792a152155e01a2bd36c9e..ff6137e2a4f2df549c5555a1771b2d9a2d866e0c 100644 (file)
@@ -73,27 +73,8 @@ define_machine(wndr4700) {
        .calibrate_decr = generic_calibrate_decr,
 };
 
-static struct ath9k_platform_data ar9380_wmac0_data = {
-       .led_pin = -1,
-       .eeprom_name = "pci_wmac1.eeprom",
-};
-static struct ath9k_platform_data ar9580_wmac1_data = {
-       .led_pin = -1,
-       .eeprom_name = "pci_wmac0.eeprom",
-};
-
 static int __init wndr4700_ath9k_eeprom_load(void)
 {
-       struct pci_dev *dev;
-
-       dev = pci_get_device(PCI_VENDOR_ID_ATHEROS, 0x0030, NULL);
-       if (dev)
-               dev->dev.platform_data = &ar9380_wmac0_data;
-
-       dev = pci_get_device(PCI_VENDOR_ID_ATHEROS, 0x0033, NULL);
-       if (dev)
-               dev->dev.platform_data = &ar9580_wmac1_data;
-
        return 0;
 }
 machine_device_initcall(wndr4700, wndr4700_ath9k_eeprom_load);