From 949e1a0856c4a04ac4a3fee1bd4a0cc69ac187c5 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 19 Aug 2024 15:08:55 -0700 Subject: [PATCH] mpc85xx: tl-wdr4900: move platform code to dts No benefit in doing so in platform file. Code for dts has already been written. Might as well use it. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/16125 Signed-off-by: Robert Marko --- .../arch/powerpc/boot/dts/tl-wdr4900-v1.dts | 19 ++++++- .../powerpc/platforms/85xx/tl_wdr4900_v1.c | 52 ------------------- 2 files changed, 18 insertions(+), 53 deletions(-) diff --git a/target/linux/mpc85xx/files/arch/powerpc/boot/dts/tl-wdr4900-v1.dts b/target/linux/mpc85xx/files/arch/powerpc/boot/dts/tl-wdr4900-v1.dts index d8162f0dff5..91baba0cd77 100644 --- a/target/linux/mpc85xx/files/arch/powerpc/boot/dts/tl-wdr4900-v1.dts +++ b/target/linux/mpc85xx/files/arch/powerpc/boot/dts/tl-wdr4900-v1.dts @@ -266,9 +266,12 @@ 0x1000000 0x0 0x0 0x0 0x100000>; - wifi@0,0 { + ath9k: wifi@0,0 { compatible = "pci168c,0033"; reg = <0x0000 0 0 0 0>; + #gpio-cells = <2>; + gpio-controller; + qca,led-pin = /bits/ 8 <0>; nvmem-cells = <&cal_caldata_1000>, <&macaddr_uboot_4fc00 0>; nvmem-cell-names = "calibration", "mac-address"; }; @@ -291,6 +294,15 @@ wifi@0,0 { compatible = "pci168c,0030"; reg = <0x0000 0 0 0 0>; + /* + * The PCI header of the AR9381 chip is not programmed + * correctly by the bootloader and the device uses wrong + * data due to that. Replace the broken values with the + * correct ones. + */ + device-id = <0x0030>; + class-code = <0x028000>; + qca,led-pin = /bits/ 8 <0>; nvmem-cells = <&cal_caldata_5000>, <&macaddr_uboot_4fc00 (-1)>; nvmem-cell-names = "calibration", "mac-address"; }; @@ -304,6 +316,11 @@ leds { compatible = "gpio-leds"; + wps { + gpios = <&ath9k 1 GPIO_ACTIVE_LOW>; + label = "tp-link:green:wps"; + }; + system_green: system { gpios = <&gpio0 2 GPIO_ACTIVE_LOW>; label = "tp-link:blue:system"; diff --git a/target/linux/mpc85xx/files/arch/powerpc/platforms/85xx/tl_wdr4900_v1.c b/target/linux/mpc85xx/files/arch/powerpc/platforms/85xx/tl_wdr4900_v1.c index 095f1fb77d5..22c4ad3fc4c 100644 --- a/target/linux/mpc85xx/files/arch/powerpc/platforms/85xx/tl_wdr4900_v1.c +++ b/target/linux/mpc85xx/files/arch/powerpc/platforms/85xx/tl_wdr4900_v1.c @@ -47,58 +47,6 @@ void __init tl_wdr4900_v1_pic_init(void) mpic_init(mpic); } -#ifdef CONFIG_PCI -static struct gpio_led tl_wdr4900_v1_wmac_leds_gpio[] = { - { - .name = "tp-link:blue:wps", - .gpio = 1, - .active_low = 1, - }, -}; - -static struct ath9k_platform_data tl_wdr4900_v1_wmac0_data = { - .led_pin = 0, - .leds = tl_wdr4900_v1_wmac_leds_gpio, - .num_leds = ARRAY_SIZE(tl_wdr4900_v1_wmac_leds_gpio), -}; - -static struct ath9k_platform_data tl_wdr4900_v1_wmac1_data = { - .led_pin = 0, -}; - -static void tl_wdr4900_v1_pci_wmac_fixup(struct pci_dev *dev) -{ - if (!machine_is(tl_wdr4900_v1)) - return; - - if (dev->bus->number == 1 && - PCI_SLOT(dev->devfn) == 0) { - dev->dev.platform_data = &tl_wdr4900_v1_wmac0_data; - return; - } - - if (dev->bus->number == 3 && - PCI_SLOT(dev->devfn) == 0 && - dev->device == 0xabcd) { - dev->dev.platform_data = &tl_wdr4900_v1_wmac1_data; - - /* - * The PCI header of the AR9381 chip is not programmed - * correctly by the bootloader and the device uses wrong - * data due to that. Replace the broken values with the - * correct ones. - */ - dev->device = 0x30; - dev->class = 0x028000; - - pr_info("pci %s: AR9381 fixup applied\n", pci_name(dev)); - } -} - -DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATHEROS, PCI_ANY_ID, - tl_wdr4900_v1_pci_wmac_fixup); -#endif /* CONFIG_PCI */ - /* * Setup the architecture */