[IMX6Q][Android5.1]移植筆記 --- LCD背光控制
阿新 • • 發佈:2018-12-31
platform: imx6q
os: Android Lollipop 5.1
branch: l5.1.1_2.1.0-ga
LCD 背光的使能通過GPIO高低電平來控制, 因此本文也可以作為GPIO基本控制的一個例子。
硬體部分:
這裡是MB_LCD_BL引腳,原理圖如下:
最終對應的是KEY_COL4:
對應的GPIO是GPIO4_IO14:
軟體部分:
因此此引腳會與UART5功能複用,所以需要移除掉UART5的配置避免衝突
dts配置部分
[[email protected]:~/myandroid/kernel_imx]$ g df
diff --git a/arch/arm/boot/dts/eco/imx6qdl-sabresd.dtsi b/arch/arm/boot/dts/ecoimx6qdl-sabresd.dtsi
index efe0335..62ac4a2 100644
--- a/arch/arm/boot/dts/ecoimx6qdl-sabresd.dtsi
+++ b/arch/arm/boot/dts/ecoimx6qdl-sabresd.dtsi
@@ -103,6 +103,11 @@
status = "disabled";
};
+ /*Kris,20160324, add display power control.*/
+ display_power_ctrl {
+ bl_power_gpio = <&gpio4 14 1>;
+ };
+
mxcfb2: [email protected] {
compatible = "fsl,mxc_sdc_fb";
disp_dev = "hdmi";
@@ -408,6 +413,7 @@
MX6QDL_PAD_NANDF_CS1__GPIO6_IO14 0x80000000
MX6QDL_PAD_NANDF_CS2__GPIO6_IO15 0x80000000
MX6QDL_PAD_NANDF_CS3__GPIO6_IO16 0x80000000
+ MX6QDL_PAD_KEY_COL4__GPIO4_IO14 0x80000000
>;
};
@@ -559,15 +565,6 @@
};
/*Kris, 20160310, Use uart2 as console. }*/
- pinctrl_uart5_1: uart5grp-1 {
- fsl,pins = <
- MX6QDL_PAD_KEY_COL1__UART5_TX_DATA 0x1b0b1
- MX6QDL_PAD_KEY_ROW1__UART5_RX_DATA 0x1b0b1
- MX6QDL_PAD_KEY_COL4__UART5_RTS_B 0x1b0b1
- MX6QDL_PAD_KEY_ROW4__UART5_CTS_B 0x1b0b1
- >;
- };
-
pinctrl_uart5dte_1: uart5dtegrp-1 {
fsl,pins = <
MX6QDL_PAD_KEY_ROW1__UART5_TX_DATA 0x1b0b1
@@ -729,13 +726,6 @@
};
/*Kris, 20160310, Use uart2 as console. }*/
-&uart5 {
- pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_uart5_1>;
- fsl,uart-has-rtscts;
- status = "okay";
-};
-
&usbh1 {
diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
index 047aecc..12a84fb 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -36,7 +36,6 @@
serial1 = &uart2;
serial2 = &uart3;
serial3 = &uart4;
- serial4 = &uart5;
spi0 = &ecspi1;
spi1 = &ecspi2;
spi2 = &ecspi3;
注意:MX6QDL_PAD_KEY_COL4__GPIO4_IO14 0x80000000 這行不配置有可能導致GPIO無法拉高。
原始檔部分diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index 405889c..35f3abf 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -349,6 +349,24 @@ static void __init imx6q_mini_pcie_init(void)
}
}
+static void __init display_power_init(void)
+{
+ struct device_node *lcd = NULL;
+ int ret, bl_power_gpio;
+
+ lcd = of_find_node_by_name(NULL, "display_power_ctrl");
+ if (!lcd)
+ return;
+ bl_power_gpio = of_get_named_gpio(lcd, "bl_power_gpio", 0);
+ if (gpio_is_valid(bl_power_gpio)) {
+ ret = gpio_request_one(bl_power_gpio, GPIOF_OUT_INIT_HIGH,
+ "bl_power_gpio");
+ pr_info("request bl_power_gpio\n");
+ if (ret)
+ pr_warn("failed to request bl_power_gpio\n");
+ }
+}
+
static void __init imx6q_csi_mux_init(void)
{
/*
@@ -432,6 +450,9 @@ static void __init imx6q_init_machine(void)
imx6q_csi_mux_init();
cpu_is_imx6q() ? imx6q_pm_init() : imx6dl_pm_init();
imx6q_mini_pcie_init();
+
+ //Kris
+ display_power_init();
}