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配置部分
[kris@ecovacs:~/myandroid/kernel_imx]$ g df diff --git a/arch/arm/boot/dts/ecovacsimx6qdl-sabresd.dtsi b/arch/arm/boot/dts/ecovacsimx6qdl-sabresd.dtsi index efe0335..62ac4a2 100644 --- a/arch/arm/boot/dts/ecovacsimx6qdl-sabresd.dtsi +++ b/arch/arm/boot/dts/ecovacsimx6qdl-sabresd.dtsi @@ -103,6 +103,11 @@ status = "disabled"; }; + /*Kris,20160324, add display power control.*/ + display_power_ctrl { + bl_power_gpio = <&gpio4 14 1>; + }; + mxcfb2: fb@1 { 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(); }
参考:
http://www.kosagi.com/w/index.php?title=Definitive_GPIO_guide
https://community.freescale.com/message/529415
https://community.freescale.com/thread/323719