Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipq40xx: add support for OpenMesh A62 #884

Closed
wants to merge 7 commits into from
Closed

Conversation

ecsv
Copy link
Contributor

@ecsv ecsv commented Apr 20, 2018

  • QCA IPQ4019
  • 256 MB of RAM
  • 32 MB of SPI NOR flash (s25fl256s1)
    • 2x 15 MB available; but one of the 15 MB regions is the recovery image
  • 2T2R 2.4 GHz
    • QCA4019 hw1.0 (SoC)
    • requires special BDF in QCA4019/hw1.0/board-2.bin with
      bus=ahb,bmi-chip-id=0,bmi-board-id=20,variant=OM-A62
  • 2T2R 5 GHz (channel 36-64)
    • QCA9888 hw2.0 (PCI)
    • requires special BDF in QCA9888/hw2.0/board-2.bin
      bus=pci,bmi-chip-id=0,bmi-board-id=16,variant=OM-A62
  • 2T2R 5 GHz (channel 100-165)
    • QCA4019 hw1.0 (SoC)
    • requires special BDF in QCA4019/hw1.0/board-2.bin with
      bus=ahb,bmi-chip-id=0,bmi-board-id=21,variant=OM-A62
  • multi-color LED (controlled via red/green/blue GPIOs)
  • 1x button (reset; kmod-input-gpio-keys compatible)
  • external watchdog
    • triggered GPIO
  • 1x USB 2.0
  • TTL pins are on board (arrow points to VCC, then follows: GND, TX, RX)
  • 2x gigabit ethernet
    • phy@mdio3:
      • Label: Ethernet 1
      • gmac0 (ethaddr) in original firmware
      • 802.3at POE+
    • phy@mdio4:
      • Label: Ethernet 2
      • gmac1 (eth1addr) in original firmware
      • 18-24V passive POE (mode B)
  • powered only via POE

The tool ap51-flash (https://github.com/ap51-flash/ap51-flash) should be used to transfer the factory image to the u-boot when the device boots up.

The initramfs image can be started using

setenv bootargs 'loglevel=8 earlycon=msm_serial_dm,0x78af000 console=ttyMSM0,115200 mtdparts=spi0.0:256k(0:SBL1),128k(0:MIBIB),384k(0:QSEE),64k(0:CDT),64k(0:DDRPARAMS),64k(0:APPSBLENV),512k(0:APPSBL),64k(0:ART),64k(0:custom),64k(0:KEYS),15552k(inactive),15552k(inactive2)'
tftpboot 0x84000000 openwrt-ipq40xx-openmesh_a62-initramfs-fit-uImage.itb
set fdt_high 0x85000000
bootm 0x84000000

As you can see, this PR currently contains some changes from #881 and #879. It doesn't seem to be a good idea to build the support without the other PRs in mind. So you can basically ignore following changes when the other PRs are accepted:

  • firmware: ath10k-firmware: update to 2018-04-19
  • ipq40xx: Remove unused reserved-memory nodes
  • ipq40xx: Move reserved-memory DT to qcom-ipq4019.dtsi

I would like to thank @chunkeey here because he investigated the gpio-hog problem with the pinctrl-msm and prepared several patches for upstream.


There are not many informations about this device but OpenMesh just added it to their shop https://store.openmesh.com/products/a62-universal-tri-band-802-11ac-wave-2-cloud-managed-wifi-access-point.html

The u-boot source code can currently only be downloaded from https://drive.google.com/drive/folders/1bBOQH5RCpwi0acJlLd0xs2OComopO5tn?usp=sharing

* introduces the BDFs in /lib/firmware/ath10k/QCA4019/hw1.0/board-2.bin
  for:
  - 8devices Jalapeno
  - Asus RT-AC58U
  - AVM FRITZ!Box 4040
  - GL.iNet GL-B1300
  - Meraki MR33
  - Netgear EX6100v2
  - Netgear EX6150v2
  - OpenMesh A62
* introduces the BDFs in /lib/firmware/ath10k/QCA9888/hw2.0/board-2.bin
  - OpenMesh A62
* adds new firmware for QCA6174 hw3.0
  - firmware-6.bin_RM.4.4.1.c1-00038-QCARMSWP-1
  - firmware-6.bin_RM.4.4.1.c1-00041-QCARMSWP-1
* various undocumented BDF updates to:
  - QCA4019 hw1.0:
    + bus=ahb,bmi-chip-id=0,bmi-board-id=16
    + bus=ahb,bmi-chip-id=0,bmi-board-id=17
    + bus=ahb,bmi-chip-id=0,bmi-board-id=19
    + bus=ahb,bmi-chip-id=0,bmi-board-id=20
    + bus=ahb,bmi-chip-id=0,bmi-board-id=21
    + bus=ahb,bmi-chip-id=0,bmi-board-id=29
    + bus=ahb,bmi-chip-id=0,bmi-board-id=30
  - QCA9888 hw2.0:
    + bus=pci,bmi-chip-id=0,bmi-board-id=16
    + bus=pci,bmi-chip-id=0,bmi-board-id=17
    + bus=pci,bmi-chip-id=0,bmi-board-id=18
    + bus=pci,bmi-chip-id=0,bmi-board-id=23
    + bus=pci,bmi-chip-id=0,bmi-board-id=24
    + bus=pci,bmi-chip-id=0,bmi-board-id=25
  - QCA9984 hw1.0:
    + bus=pci,bmi-chip-id=0,bmi-board-id=1
    + bus=pci,bmi-chip-id=0,bmi-board-id=3
    + bus=pci,bmi-chip-id=0,bmi-board-id=5
    + bus=pci,bmi-chip-id=0,bmi-board-id=6
    + bus=pci,bmi-chip-id=0,bmi-board-id=7
    + bus=pci,bmi-chip-id=0,bmi-board-id=8

Signed-off-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
The reserved-memory regions are mostly undocumented by QCA and are named
very unspecific in the QSDK device trees. It was tried to clean them up by
commit 71ed9f1 ("ipq40xx: Use detailed reserved memory for A42") and
similar changes.

The features which require these regions were mostly unknown but
Senthilkumar N L <snlakshm@qti.qualcomm.com> and Sricharan Ramabadhran
<srichara@qti.qualcomm.com> provided some more insight in some of them:

* crash dump feature
  - a couple of regions used when 'qca,scm_restart_reason' dt node has the
    value 'dload_status' not set to 1
    + apps_bl <0x87000000 0x400000>
    + sbl <0x87400000 0x100000>
    + cnss_debug <0x87400000 0x100000>
    + cpu_context_dump <0x87b00000 0x080000>
  - required driver not available in Linux
  - safe to remove
* QSEE app execution
  - region tz_apps <0x87b80000 0x280000>
  - required driver not available in Linux
  - safe to remove
* communication with TZ/QSEE
  - region smem <0x87b80000 0x280000>
  - driver changes not yet upstreamed
  - must not be removed because any access can crash kernel/program
* trustzone (QSEE) private memory
  - region tz <0x87e80000 0x180000>
  - must not be removed because any access can crash kernel/program

Removing the unnecessary regions saves some kilobyte of reserved-memory and
cleans up the device tree:

* 2560 KiB
  - 8devices Jalapeno
  - AVM FRITZ!Box 4040
  - Compex WPJ428
  - Meraki MR33 Access Point
  - OpenMesh A42
* 14336 KiB
  - GL.iNet GL-B1300
  - Qualcomm Technologies, Inc. IPQ40xx/AP-DK01.1-C1

Signed-off-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
The tz and smem reserved-memory information handled in the upstream Linux
sources by the SoC specific dtsi and not by the the boards dts. Using the
same approach in OpenWrt avoids unneccessary duplication.

Signed-off-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
The pinctrl initialization fails with the MSM pinctrl code and gpio-hogs
because either the gpio ranges are not yet initialized (missing gpio-range
in DT) or that the msm driver unconditionally tries to re-initializes the
ranges (gpio-range in DT).

To allow gpio-hogs and similar early-boot gpio code, the gpio-ranges must
be in the device tree and the pinctrl-msm code must check whether the range
was already initialized by the DT.

Signed-off-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
Signed-off-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
Signed-off-by: Sven Eckelmann <sven.eckelmann@open-mesh.com>
* QCA IPQ4019
* 256 MB of RAM
* 32 MB of SPI NOR flash (s25fl256s1)
  - 2x 15 MB available; but one of the 15 MB regions is the recovery image
* 2T2R 2.4 GHz
  - QCA4019 hw1.0 (SoC)
  - requires special BDF in QCA4019/hw1.0/board-2.bin with
    bus=ahb,bmi-chip-id=0,bmi-board-id=20,variant=OM-A62
* 2T2R 5 GHz (channel 36-64)
  - QCA9888 hw2.0 (PCI)
  - requires special BDF in QCA9888/hw2.0/board-2.bin
    bus=pci,bmi-chip-id=0,bmi-board-id=16,variant=OM-A62
* 2T2R 5 GHz (channel 100-165)
  - QCA4019 hw1.0 (SoC)
  - requires special BDF in QCA4019/hw1.0/board-2.bin with
    bus=ahb,bmi-chip-id=0,bmi-board-id=21,variant=OM-A62
* multi-color LED (controlled via red/green/blue GPIOs)
* 1x button (reset; kmod-input-gpio-keys compatible)
* external watchdog
  - triggered GPIO
* 1x USB (xHCI)
* TTL pins are on board (arrow points to VCC, then follows: GND, TX, RX)
* 2x gigabit ethernet
  - phy@mdio3:
    + Label: Ethernet 1
    + gmac0 (ethaddr) in original firmware
    + 802.3at POE+
  - phy@mdio4:
    + Label: Ethernet 2
    + gmac1 (eth1addr) in original firmware
    + 18-24V passive POE (mode B)
* powered only via POE

The tool ap51-flash (https://github.com/ap51-flash/ap51-flash) should be
used to transfer the factory image to the u-boot when the device boots up.

The initramfs image can be started using

  setenv bootargs 'loglevel=8 earlycon=msm_serial_dm,0x78af000 console=ttyMSM0,115200 mtdparts=spi0.0:256k(0:SBL1),128k(0:MIBIB),384k(0:QSEE),64k(0:CDT),64k(0:DDRPARAMS),64k(0:APPSBLENV),512k(0:APPSBL),64k(0:ART),64k(0:custom),64k(0:KEYS),15552k(inactive),15552k(inactive2)'
  tftpboot 0x84000000 openwrt-ipq40xx-openmesh_a62-initramfs-fit-uImage.itb
  set fdt_high 0x85000000
  bootm 0x84000000

Signed-off-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
@mkresin
Copy link
Member

mkresin commented Apr 20, 2018

I haven't had a look at the driver nor do I have access to a board at the moment, but can't we use the phy-supply from the phy framework as we are doing with lantiq/xrx200 on kernel 4.14 a vbus-supply similar to the lantiq commits in my staging tree?

I mean, the hogged GPIO is a similar workaround as gpio-export and the phyvbus-supply seem to me the "correct" solution for the problem.

One benefit of using phyvbus-supply is that the usb power is disabled if the usb driver is unloaded/not enabled. Furthermroe, this way the usb power can be disabled if the usb port should be used in peripheral mode.

It might that the following works out of the box (update: no it doesn't, neither the dwc3 core nor dwc3-of-simple.c have vbus supply support yet):

soc {
	usb_vbus: regulator-usb-vbus {
		compatible = "regulator-fixed";

		regulator-name = "USB_VBUS";

		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;

		gpio = <&tlmm 58 GPIO_ACTIVE_HIGH>;
		enable-active-high;
	};

	usb2: usb2@60f8800 {
		vbus-supply = <&usb_vbus>;
		status = "okay";
	};
};

Options are already enabled target/linux/ipq40xx/config-4.14 needs the following additional config options:

CONFIG_REGULATOR=y
CONFIG_REGULATOR_FIXED_VOLTAGE=y

I remember that we had a similar issue with ipq806x back in the days and we went with setting the pin output-high/output-low in the pinmux. It is neither a proper solution and just another workaround instead of using the phyvbus-supply.

@mkresin mkresin added the target/ipq40xx pull request/issue for ipq40xx target label Apr 20, 2018
@ecsv
Copy link
Contributor Author

ecsv commented Apr 23, 2018

As you mentioned in your mail (and also updated your ticket), external vbus-supply is currently not supported by dcw3.

And yes, in theory this might be a good idea to switch to - but it is a rather bad timing the dcw3-qcom is currently upstreamed https://lkml.org/lkml/2018/4/13/508. Not sure what must be done to this driver to correctly enable/disable vbus-supply for peripheral/host mode. At least dwc3-omap.c integrated it very tight to their mailbox system.

@mkresin mkresin self-assigned this Apr 23, 2018
@mkresin
Copy link
Member

mkresin commented Apr 23, 2018

Merged, thanks!

I cherry picked the related commits and removed the patching of the unrelated dtsi from the gpio hog patch.

@mkresin mkresin closed this Apr 23, 2018
@ecsv ecsv deleted the a62 branch April 24, 2018 06:51
@ecsv
Copy link
Contributor Author

ecsv commented Apr 30, 2018

Here some additional information about the VBUS: An OC protection circuit was added between powerrail and VBUS pin of the USB connector. The gpio58 is used to control this circuit and allows to disable the power (set it to high - which it is by default). There is a capacitor and thus voltage will not drop directly when setting GPIO58 to high.

@ecsv
Copy link
Contributor Author

ecsv commented Nov 5, 2018

I was just asked in private about following situation:

  • device checked in cloudtrax from China (and downloaded new configuration)
  • SSH is accessible (User: root + Password configured in cloudtrax, IP taken from cloudtrax AP overview page)
  • u-boot is not accessible (just reboots when trying to open the u-boot shell)
  • u-boot asks for fwupgrade.cfg.sig when trying to upload factory image using ap51-flash

This means that the device is unlocked but still has the signature check key for installed. I don't know whether this was intended by Datto/OpenMesh or not. But you just have to disable the key in this case to make u-boot accessible again:

if grep KEYS /proc/mtd > /dev/null; then
  dd if=/dev/zero of=/dev/mtdblock9 conv=notrunc bs=1 seek=0 count=8
else
  dd if=/dev/zero of=/dev/mtdblock7 conv=notrunc bs=1 seek=32768 count=8
fi

A new OpenWrt image should be installed immediately to avoid that firmware-ng reinstalls the key again. I don't actually know whether it would do that in this situation but the disabling of the key works (see Datto's u-boot GPL source code for more details).

@pepe2k
Copy link
Member

pepe2k commented Nov 5, 2018

@ecsv here is also related OpenWrt forum topic: https://forum.openwrt.org/t/openwrt-installation-on-openmesh-a62-router/23986

Cheers,
Piotr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
target/ipq40xx pull request/issue for ipq40xx target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants