rockchip-linux / kernel

BSP kernel source
Other
947 stars 1.1k forks source link

Building a device tree to run a Linux kernel on a Rockchip rk3288 board #130

Open aicastell opened 6 years ago

aicastell commented 6 years ago

I am trying to run a Linux kernel on a Rockchip rk3288 board.

This boards runs a native Android kernel. I extracted the Device Tree Source (DTS) from Android to use it as reference to build a custom DTS for the Linux kernel, following this steps:

$ mkdir /tmp/dtb
$ adb pull /proc/device-tree/ /tmp/dtb
$ dtc -I fs -O dts /tmp/dtb/ > /tmp/android.dts

Using android.dts as a basis I am trying to write a custom linux.dts to run Linux kernel 4.4.103 on my board. Linux kernel sources can be downloaded from this repo:

$ git clone git://github.com/rockchip-linux/kernel.git

Using my custom linux.dts the Linux kernel boots, it mounts a root filesystem fine, the login (serial) console appears, and even the ethernet device works as expected.

But I have power problems with the USB-OTG and with the mini-pci-e. Using a multimeter checked the USB-OTG connector receives 0V when running my Linux kernel, but it receives 4.8V when running the Android kernel. Also, the mini-pci-e receives 0V when running the Linux kernel, but it received 3.75V when running the Android kernel.

I don't know what GPIO lines should be managed to enable power on these two devices. My experience working device trees is quite limited, so any advice with this could be really helpful. Thanks a lot in advance! :)

This is the current linux.dts version:

/dts-v1/;
#include <dt-bindings/clock/rockchip,rk808.h>
#include "rk3288.dtsi"
/ {
    model = "Linux RK3288";
    compatible = "rockchip,rk3288-merrii-k2", "rockchip,rk3288";
    memory {
        reg = <0x0 0x0 0x0 0x80000000>;
        device_type = "memory";
    };
    ext_gmac: external-gmac-clock {
        compatible = "fixed-clock";
        #clock-cells = <0>;
        clock-frequency = <125000000>;
        clock-output-names = "ext_gmac";
    };
    sdio_pwrseq: sdio-pwrseq {
        compatible = "mmc-pwrseq-simple";
        clocks = <&rk808 RK808_CLKOUT1>;
        clock-names = "ext_clock";
        pinctrl-names = "default";
        pinctrl-0 = <&wifi_enable_h>;
        reset-gpios = <&gpio4 28 GPIO_ACTIVE_LOW>;
    };
    vcc_5v: usb-regulator {
        compatible = "regulator-fixed";
        regulator-name = "vcc_5v";
        regulator-min-microvolt = <5000000>;
        regulator-max-microvolt = <5000000>;
        regulator-always-on;
        regulator-boot-on;
        vin-supply = <&vcc_sys>;
    };
    vcc_host_5v: usb-host-regulator {
        compatible = "regulator-fixed";
        enable-active-high;
        gpio = <&gpio0 14 GPIO_ACTIVE_HIGH>;
        pinctrl-names = "default";
        pinctrl-0 = <&host_vbus_drv>;
        regulator-name = "vcc_host_5v";
        regulator-min-microvolt = <5000000>;
        regulator-max-microvolt = <5000000>;
        regulator-always-on;
        vin-supply = <&vcc_5v>;
    };
    vcc_otg_5v: usb-otg-regulator {
        compatible = "regulator-fixed";
        enable-active-high;
        gpio = <&gpio0 12 GPIO_ACTIVE_HIGH>;
        pinctrl-names = "default";
        pinctrl-0 = <&otg_vbus_drv>;
        regulator-name = "vcc_otg_5v";
        regulator-min-microvolt = <5000000>;
        regulator-max-microvolt = <5000000>;
        regulator-always-on;
        vin-supply = <&vcc_5v>;
    };
    vcc_sys: vsys-regulator {
        compatible = "regulator-fixed";
        regulator-name = "vcc_sys";
        regulator-min-microvolt = <5000000>;
        regulator-max-microvolt = <5000000>;
        regulator-always-on;
        regulator-boot-on;
    };
    usb_control {
        compatible = "rockchip,rk3288-usb-control";
        host_drv_gpio = <&gpio0 14 GPIO_ACTIVE_LOW>;
        otg_drv_gpio = <&gpio0 12 GPIO_ACTIVE_LOW>;
        rockchip,remote_wakeup;
        rockchip,usb_irq_wakeup;
    };
};
&hdmi {
    status = "okay";
    rockchip,cec_enable = <0>;
    rockchip,hdcp_enable = <0>;
    rockchip,defaultmode = <16>;
};
&dmc {
    status = "okay";
};
&cpu0 {
    cpu0-supply = <&vdd_cpu>;
    enable-method = "psci";
};
&cpu1 {
    enable-method = "psci";
};
&cpu2 {
    enable-method = "psci";
};
&cpu3 {
    enable-method = "psci";
};
&pwm0 {
    status = "okay";
};
&pwm1 {
    status = "okay";
};
&emmc {
    bus-width = <8>;
    cap-mmc-highspeed;
    disable-wp;
    non-removable;
    num-slots = <1>;
    pinctrl-names = "default";
    pinctrl-0 = <&emmc_clk &emmc_cmd &emmc_pwr &emmc_bus8>;
    status = "okay";
};
&sdmmc {
    bus-width = <4>;
    cap-mmc-highspeed;
    cap-sd-highspeed;
    card-detect-delay = <200>;
    disable-wp;
    num-slots = <1>;
    pinctrl-names = "default";
    pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_cd &sdmmc_bus4>;
    status = "okay";
    supports-sd;
    vmmc-supply = <&vcc_sd>;
    vqmmc-supply = <&vccio_sd>;
};
&sdio0 {
    status = "okay";
    clock-frequency = <50000000>;
    clock-freq-min-max = <200000 50000000>;
    bus-width = <4>;
    cap-sd-highspeed;
    cap-sdio-irq;
    disable-wp;
    keep-power-in-suspend;
    mmc-pwrseq = <&sdio_pwrseq>;
    non-removable;
    num-slots = <1>;
    pinctrl-names = "default";
    pinctrl-0 = <&sdio0_bus4 &sdio0_cmd &sdio0_clk>;
    supports-sdio;
};
&gmac {
    assigned-clocks = <&cru SCLK_MAC>;
    assigned-clock-parents = <&ext_gmac>;
    clock_in_out = "input";
    pinctrl-names = "default";
    pinctrl-0 = <&rmii_pins>;
    phy-supply = <&vcc_lan>;
    phy-mode = "rmii";
    rx_delay = <0x20>;
    tx_delay = <0x30>;
    status = "okay";
    snps,reset-gpio = <&gpio4 7 0>;
};
&gpu {
    mali-supply = <&vdd_gpu>;
    status = "okay";
};
&hevc_service {
    status = "okay";
};
&i2c0 {
    status = "okay";
    clock-frequency = <400000>;
    rk808: pmic@1b {
        compatible = "rockchip,rk808";
        reg = <0x1b>;
        status = "okay";
        interrupt-parent = <&gpio0>;
        interrupts = <4 IRQ_TYPE_LEVEL_LOW>;
        #clock-cells = <1>;
        clock-output-names = "rk808-clkout1", "rk808-clkout2";
        pinctrl-names = "default";
        pinctrl-0 = <&pmic_int &global_pwroff>;
        rockchip,system-power-controller;
        wakeup-source;
        vcc1-supply = <&vcc_sys>;
        vcc2-supply = <&vcc_sys>;
        vcc3-supply = <&vcc_sys>;
        vcc4-supply = <&vcc_sys>;
        vcc6-supply = <&vcc_sys>;
        vcc7-supply = <&vcc_sys>;
        vcc8-supply = <&vcc_io>;
        vcc9-supply = <&vcc_io>;
        vcc10-supply = <&vcc_io>;
        vcc11-supply = <&vcc_io>;
        vcc12-supply = <&vcc_io>;
        vddio-supply = <&vcc_io>;
        regulators {
            vdd_cpu: DCDC_REG1 {
                regulator-always-on;
                regulator-boot-on;
                regulator-min-microvolt = <900000>;
                regulator-max-microvolt = <1500000>;
                regulator-name = "vdd_arm";
                regulator-state-mem {
                    regulator-off-in-suspend;
                };
            };
            vdd_gpu: DCDC_REG2 {
                regulator-always-on;
                regulator-boot-on;
                regulator-min-microvolt = <900000>;
                regulator-max-microvolt = <1500000>;
                regulator-name = "vdd_gpu";
                regulator-ramp-delay = <6000>;
                regulator-state-mem {
                    regulator-on-in-suspend;
                    regulator-suspend-microvolt = <1100000>;
                };
            };
            vcc_ddr: DCDC_REG3 {
                regulator-always-on;
                regulator-boot-on;
                regulator-name = "vcc_ddr";
                regulator-state-mem {
                    regulator-on-in-suspend;
                };
            };
            vcc_io: DCDC_REG4 {
                regulator-always-on;
                regulator-boot-on;
                regulator-min-microvolt = <3300000>;
                regulator-max-microvolt = <3300000>;
                regulator-name = "vcc_io";
                regulator-state-mem {
                    regulator-on-in-suspend;
                    regulator-suspend-microvolt = <3300000>;
                };
            };
            vccio_pmu: LDO_REG1 {
                regulator-always-on;
                regulator-boot-on;
                regulator-min-microvolt = <3300000>;
                regulator-max-microvolt = <3300000>;
                regulator-name = "vccio_pmu";
                regulator-state-mem {
                    regulator-on-in-suspend;
                    regulator-suspend-microvolt = <3300000>;
                };
            };
            vcca_33: LDO_REG2 {
                regulator-always-on;
                regulator-boot-on;
                regulator-min-microvolt = <3300000>;
                regulator-max-microvolt = <3300000>;
                regulator-name = "vcca_33";
                regulator-state-mem {
                    regulator-off-in-suspend;
                };
            };
            vdd_10: LDO_REG3 {
                regulator-always-on;
                regulator-boot-on;
                regulator-min-microvolt = <1000000>;
                regulator-max-microvolt = <1000000>;
                regulator-name = "vdd_10";
                regulator-state-mem {
                    regulator-on-in-suspend;
                    regulator-suspend-microvolt = <1000000>;
                };
            };
            vcc_wl: LDO_REG4 {
                regulator-always-on;
                regulator-boot-on;
                regulator-min-microvolt = <1800000>;
                regulator-max-microvolt = <1800000>;
                regulator-name = "vcc_wl";
                regulator-state-mem {
                    regulator-on-in-suspend;
                    regulator-suspend-microvolt = <1800000>;
                };
            };
            vccio_sd: LDO_REG5 {
                regulator-always-on;
                regulator-boot-on;
                regulator-min-microvolt = <1800000>;
                regulator-max-microvolt = <3300000>;
                regulator-name = "vccio_sd";
                regulator-state-mem {
                    regulator-on-in-suspend;
                    regulator-suspend-microvolt = <3300000>;
                };
            };
            vdd10_lcd: LDO_REG6 {
                regulator-always-on;
                regulator-boot-on;
                regulator-min-microvolt = <1000000>;
                regulator-max-microvolt = <1000000>;
                regulator-name = "vdd10_lcd";
                regulator-state-mem {
                    regulator-on-in-suspend;
                    regulator-suspend-microvolt = <1000000>;
                };
            };
            vcc_18: LDO_REG7 {
                regulator-always-on;
                regulator-boot-on;
                regulator-min-microvolt = <1800000>;
                regulator-max-microvolt = <1800000>;
                regulator-name = "vcc_18";
                regulator-state-mem {
                    regulator-on-in-suspend;
                    regulator-suspend-microvolt = <1800000>;
                };
            };
            vcc18_lcd: LDO_REG8 {
                regulator-always-on;
                regulator-boot-on;
                regulator-min-microvolt = <1800000>;
                regulator-max-microvolt = <1800000>;
                regulator-name = "vcc18_lcd";
                regulator-state-mem {
                    regulator-on-in-suspend;
                    regulator-suspend-microvolt = <1800000>;
                };
            };
            vcc_sd: SWITCH_REG1 {
                regulator-always-on;
                regulator-boot-on;
                regulator-name = "vcc_sd";
                regulator-state-mem {
                    regulator-on-in-suspend;
                };
            };
            vcc_lan: SWITCH_REG2 {
                regulator-always-on;
                regulator-boot-on;
                regulator-name = "vcc_lan";
                regulator-state-mem {
                    regulator-on-in-suspend;
                };
            };
        };
    };
};
&i2c1 {
    status = "okay";
};
&i2c2 {
    status = "okay";
};
&i2c3 {
    status = "okay";
};
&i2c4 {
    status = "okay";
};
&i2c5 {
    status = "disabled";
};
&i2s {
    #sound-dai-cells = <0>;
    status = "okay";
};
&io_domains {
    status = "okay";
};
&uart0 {
    status = "okay";
};
&uart1 {
    status = "okay";
};
&uart2 {
    status = "okay";
};
&uart3 {
    status = "okay";
};
&uart4 {
    status = "okay";
};
&usbphy {
    status = "okay";
};
&usb_host0_ehci {
    status = "okay";
    compatible = "rockchip,rk3288_rk_ehci_host";
};
&usb_host0_ohci {
    status = "okay";
};
&usb_host1 {
    status = "okay";
};
&usb_otg {
    status = "okay";
};
&vopb {
    status = "okay";
};
&vopb_mmu {
    status = "okay";
};
&vopl {
    status = "okay";
};
&vopl_mmu {
    status = "okay";
};
&vpu_service {
    status = "okay";
};
&wdt {
    status = "okay";
};
&pinctrl {
    pcfg_output_high: pcfg-output-high {
        output-high;
    };
    pcfg_output_low: pcfg-output-low {
        output-low;
    };
    pmic {
        pmic_int: pmic-int {
            rockchip,pins = <RK_GPIO0 4 RK_FUNC_GPIO &pcfg_pull_up>;
        };
    };
    sdio-pwrseq {
        wifi_enable_h: wifi-enable-h {
            rockchip,pins = <RK_GPIO4 28 RK_FUNC_GPIO &pcfg_pull_none>;
        };
    };
    usb_host {
        host_vbus_drv: host-vbus-drv {
            rockchip,pins = <RK_GPIO0 14 RK_FUNC_GPIO &pcfg_pull_none>;
        };
    };
    usb_otg {
        otg_vbus_drv: otg-vbus-drv {
            rockchip,pins = <RK_GPIO0 12 RK_FUNC_GPIO &pcfg_pull_none>;
        };
    };
};
rembo10 commented 2 years ago

Hey I know this is like, a 3 year old issue but I'm wondering if you ever got it solved? I'm trying to run the mainline kernel on a rk3288 device and am having some trouble with the usb...