mirror of
https://github.com/easytarget/MQ-Pro-IO.git
synced 2026-01-26 04:43:22 +00:00
refactor
This commit is contained in:
56
device-tree/README.md
Normal file
56
device-tree/README.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# Rebuild dts tree fo MQ pro..
|
||||
|
||||
see:
|
||||
https://manpages.ubuntu.com/manpages/focal/man1/dtc.1.html
|
||||
https://forum.armbian.com/topic/29626-mango-pi-mq-pro-d1-device-tree-try-to-okay-serial/
|
||||
https://github.com/torvalds/linux/tree/master/arch/riscv/boot/dts/allwinner
|
||||
|
||||
https://github.com/ners/MangoPi/tree/d2589d8211a2f9ae57d88f2e2c4d6a449d668f9e/MangoPi/linux/arch/riscv/boot/dts/allwinner
|
||||
|
||||
version from official armbian image?
|
||||
https://github.com/smaeul/u-boot/tree/329e94f16ff84f9cf9341f8dfdff7af1b1e6ee9a/arch/riscv/dts
|
||||
|
||||
## Notes for re-generating MQ PRO device tree (`.dtb`)
|
||||
My notes
|
||||
* By default the Device Tree compiler (`/usr/bin/dtc`) should already be installed, as should the linux-headers for the kernel.
|
||||
|
||||
### compile the mq-pro dts with the current kernel headers
|
||||
Example here is against the 'default' 6.8.0-31 linux kernel from the Ubuntu 24.04 release
|
||||
* clean the `dtspp` folder: `rm dtspp/*`
|
||||
* edit and run `bake.sh` to precompile the files against the latest linux-headers
|
||||
* cd into the `dtspp` folder and run:
|
||||
```dtc sun20i-d1-mangopi-mq-pro.dts > dtb-6.8.0-31-mqpro```
|
||||
modify the version to reflect the current headers
|
||||
* move the `.dtb` file into the `/boot` folder:
|
||||
`sudo mv dtb-6.8.0-31-mqpro /boot/dtbs`
|
||||
* make a link in `/boot` to this:
|
||||
`sudo ln -s dtbs/dtb-6.8.0-31-mqpro /boot/dtb-mqpro`
|
||||
|
||||
### Set up Grub to test boot the new DTB
|
||||
Initially we will test the new dtb:
|
||||
* backup the grub config: `sudo cp /etc/grub/grub.cfg /etc/grub/grub.cfg.generic-dtb`
|
||||
* `sudo vi /etc/grub/grub.cfg` (or use nano if you prefer)
|
||||
Find the 1st `menuentry` section (the default Ubuntu one) and edit the `devicetree` line to look like:
|
||||
`devicetree /boot/dtb-mqpro`
|
||||
* Reboot (`sudo reboot`) (remember the mq-pro is sloooow to reboot ;-) )
|
||||
* If the reboot fails you can either attach a serial adapter to the GPIO pins and select the fallback kernel from the advanced options menu, and then restore the grub config backup once logged in.
|
||||
Or (if no serial available) remove the SD card, mount it on another computer and restore the file there.
|
||||
|
||||
### Check that we have the correct device tree
|
||||
`dtc -I fs /sys/firmware/devicetree/base | grep 'model'`
|
||||
* ignore all the 'not a phandle reference' warnings
|
||||
* you should see `model = "MangoPi MQ Pro"` at the end
|
||||
|
||||
### Make this permanent in grub
|
||||
ToDo
|
||||
|
||||
## Issues
|
||||
**No HDMI output** - this is either a blocker.. or fine for a headless system
|
||||
|
||||
### Bonus
|
||||
The onboard (blue) status LED can be controlled via the sys tree:
|
||||
`sudo sh -c "echo 1 > /sys/devices/platform/leds/leds/blue\:status/brightness"` to turn on
|
||||
`sudo sh -c "echo 1 > /sys/devices/platform/leds/leds/blue\:status/brightness"` to turn off
|
||||
You can make it flash as wifi traffic is seen with:
|
||||
`sudo sh -c "echo phy0rx > /sys/devices/platform/leds/leds/blue\:status/trigger"`
|
||||
|
||||
5
device-tree/dtspp/preprocess.sh
Executable file
5
device-tree/dtspp/preprocess.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
rm -f dtbs/*
|
||||
for file in `ls ../{*.dts,*.dtsi}`; do
|
||||
echo "Processing $file to ${file##*/}"
|
||||
cpp -I/usr/src/linux-headers-6.8.0-31-generic/include/ -nostdinc -undef -x assembler-with-cpp $file > ${file##*/}
|
||||
done
|
||||
64
device-tree/sun20i-d1-common-regulators.dtsi
Normal file
64
device-tree/sun20i-d1-common-regulators.dtsi
Normal file
@@ -0,0 +1,64 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0+ or MIT)
|
||||
// Copyright (C) 2021-2022 Samuel Holland <samuel@sholland.org>
|
||||
|
||||
/ {
|
||||
reg_vcc: vcc {
|
||||
compatible = "regulator-fixed";
|
||||
regulator-name = "vcc";
|
||||
regulator-min-microvolt = <5000000>;
|
||||
regulator-max-microvolt = <5000000>;
|
||||
};
|
||||
|
||||
reg_vcc_3v3: vcc-3v3 {
|
||||
compatible = "regulator-fixed";
|
||||
regulator-name = "vcc-3v3";
|
||||
regulator-min-microvolt = <3300000>;
|
||||
regulator-max-microvolt = <3300000>;
|
||||
vin-supply = <®_vcc>;
|
||||
};
|
||||
};
|
||||
|
||||
&codec {
|
||||
avcc-supply = <®_aldo>;
|
||||
hpvcc-supply = <®_hpldo>;
|
||||
};
|
||||
|
||||
&hdmi {
|
||||
hvcc-supply = <®_ldoa>;
|
||||
};
|
||||
|
||||
&lradc {
|
||||
vref-supply = <®_aldo>;
|
||||
};
|
||||
|
||||
&pio {
|
||||
vcc-pb-supply = <®_vcc_3v3>;
|
||||
vcc-pc-supply = <®_vcc_3v3>;
|
||||
vcc-pd-supply = <®_vcc_3v3>;
|
||||
vcc-pe-supply = <®_vcc_3v3>;
|
||||
vcc-pf-supply = <®_vcc_3v3>;
|
||||
vcc-pg-supply = <®_vcc_3v3>;
|
||||
};
|
||||
|
||||
®_aldo {
|
||||
regulator-min-microvolt = <1800000>;
|
||||
regulator-max-microvolt = <1800000>;
|
||||
vdd33-supply = <®_vcc_3v3>;
|
||||
};
|
||||
|
||||
®_hpldo {
|
||||
regulator-min-microvolt = <1800000>;
|
||||
regulator-max-microvolt = <1800000>;
|
||||
hpldoin-supply = <®_vcc_3v3>;
|
||||
};
|
||||
|
||||
®_ldoa {
|
||||
regulator-always-on;
|
||||
regulator-min-microvolt = <1800000>;
|
||||
regulator-max-microvolt = <1800000>;
|
||||
ldo-in-supply = <®_vcc_3v3>;
|
||||
};
|
||||
|
||||
&ths {
|
||||
vref-supply = <®_aldo>;
|
||||
};
|
||||
169
device-tree/sun20i-d1-mangopi-mq-pro.dts
Normal file
169
device-tree/sun20i-d1-mangopi-mq-pro.dts
Normal file
@@ -0,0 +1,169 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0+ or MIT)
|
||||
// Copyright (C) 2022 Samuel Holland <samuel@sholland.org>
|
||||
|
||||
/dts-v1/;
|
||||
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
#include <dt-bindings/leds/common.h>
|
||||
|
||||
#include "sun20i-d1.dtsi"
|
||||
#include "sun20i-d1-common-regulators.dtsi"
|
||||
|
||||
/ {
|
||||
model = "MangoPi MQ Pro";
|
||||
compatible = "widora,mangopi-mq-pro", "allwinner,sun20i-d1";
|
||||
|
||||
aliases {
|
||||
ethernet0 = &rtl8723ds;
|
||||
mmc0 = &mmc0;
|
||||
serial0 = &uart0;
|
||||
};
|
||||
|
||||
chosen {
|
||||
stdout-path = "serial0:115200n8";
|
||||
};
|
||||
|
||||
hdmi_connector: connector {
|
||||
compatible = "hdmi-connector";
|
||||
type = "c";
|
||||
|
||||
port {
|
||||
hdmi_connector_in: endpoint {
|
||||
remote-endpoint = <&hdmi_out_connector>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
leds {
|
||||
compatible = "pwm-leds";
|
||||
|
||||
led {
|
||||
color = <LED_COLOR_ID_BLUE>;
|
||||
function = LED_FUNCTION_STATUS;
|
||||
max-brightness = <255>;
|
||||
pwms = <&pwm 2 50000 0>;
|
||||
};
|
||||
};
|
||||
|
||||
reg_avdd2v8: avdd2v8 {
|
||||
compatible = "regulator-fixed";
|
||||
regulator-name = "avdd2v8";
|
||||
regulator-min-microvolt = <2800000>;
|
||||
regulator-max-microvolt = <2800000>;
|
||||
vin-supply = <®_vcc_3v3>;
|
||||
};
|
||||
|
||||
reg_dvdd: dvdd {
|
||||
compatible = "regulator-fixed";
|
||||
regulator-name = "dvdd";
|
||||
regulator-min-microvolt = <1200000>;
|
||||
regulator-max-microvolt = <1200000>;
|
||||
vin-supply = <®_vcc_3v3>;
|
||||
};
|
||||
|
||||
reg_vdd_cpu: vdd-cpu {
|
||||
compatible = "regulator-fixed";
|
||||
regulator-name = "vdd-cpu";
|
||||
regulator-min-microvolt = <1100000>;
|
||||
regulator-max-microvolt = <1100000>;
|
||||
vin-supply = <®_vcc>;
|
||||
};
|
||||
|
||||
wifi_pwrseq: wifi-pwrseq {
|
||||
compatible = "mmc-pwrseq-simple";
|
||||
reset-gpios = <&pio 6 17 GPIO_ACTIVE_LOW>; /* PG17 */
|
||||
};
|
||||
};
|
||||
|
||||
&cpu0 {
|
||||
cpu-supply = <®_vdd_cpu>;
|
||||
};
|
||||
|
||||
&de {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&ehci1 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&hdmi {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&hdmi_out {
|
||||
hdmi_out_connector: endpoint {
|
||||
remote-endpoint = <&hdmi_connector_in>;
|
||||
};
|
||||
};
|
||||
|
||||
&hdmi_phy {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&mmc0 {
|
||||
bus-width = <4>;
|
||||
cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */
|
||||
disable-wp;
|
||||
vmmc-supply = <®_vcc_3v3>;
|
||||
vqmmc-supply = <®_vcc_3v3>;
|
||||
pinctrl-0 = <&mmc0_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&mmc1 {
|
||||
bus-width = <4>;
|
||||
mmc-pwrseq = <&wifi_pwrseq>;
|
||||
non-removable;
|
||||
vmmc-supply = <®_vcc_3v3>;
|
||||
vqmmc-supply = <®_vcc_3v3>;
|
||||
pinctrl-0 = <&mmc1_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
|
||||
rtl8723ds: wifi@1 {
|
||||
reg = <1>;
|
||||
interrupt-parent = <&pio>;
|
||||
interrupts = <6 10 IRQ_TYPE_LEVEL_LOW>; /* PG10 */
|
||||
interrupt-names = "host-wake";
|
||||
};
|
||||
};
|
||||
|
||||
&ohci1 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&pio {
|
||||
vcc-pe-supply = <®_avdd2v8>;
|
||||
};
|
||||
|
||||
&uart0 {
|
||||
pinctrl-0 = <&uart0_pb8_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&uart1 {
|
||||
uart-has-rtscts;
|
||||
pinctrl-0 = <&uart1_pg6_pins>, <&uart1_pg8_rts_cts_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
|
||||
bluetooth {
|
||||
compatible = "realtek,rtl8723ds-bt";
|
||||
device-wake-gpios = <&pio 6 18 GPIO_ACTIVE_HIGH>; /* PG18 */
|
||||
enable-gpios = <&pio 6 15 GPIO_ACTIVE_HIGH>; /* PG15 */
|
||||
host-wake-gpios = <&pio 6 14 GPIO_ACTIVE_HIGH>; /* PG14 */
|
||||
};
|
||||
};
|
||||
|
||||
&usb_otg {
|
||||
dr_mode = "peripheral";
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&usbphy {
|
||||
usb0_vbus-supply = <®_vcc>;
|
||||
status = "okay";
|
||||
};
|
||||
1212
device-tree/sun20i-d1.dtsi
Normal file
1212
device-tree/sun20i-d1.dtsi
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user