]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
MLK-9975-2 imx6sx-ard: fix CAN unwork if power up the borad on first time
authorDong Aisheng <b29396@freescale.com>
Tue, 9 Dec 2014 08:43:37 +0000 (16:43 +0800)
committerDong Aisheng <b29396@freescale.com>
Wed, 21 Jan 2015 10:23:25 +0000 (18:23 +0800)
The CAN transceiver on MX6SX Sabreauto board seems in sleep mode
by default after power up the board. User has to press the wakeup
key on ARD baseboard before using the transceiver, or it may not
work properly when power up the board at the first time(warm reset
does not have such issue).

This patch wakeup the transceiver firstly if needed during intialization
by control the wakeup pin, then user do not have to press wakeup key
button to enable the transceiver.
BTW, stby gpio is also updated which is wrong before.

Conflicts:

arch/arm/mach-imx/mach-imx6sx.c

Signed-off-by: Dong Aisheng <b29396@freescale.com>
(cherry picked from commit 3141bfc97e667de4b3d88968aa18668699d735ea)
(cherry picked from commit 05eb2a0b27d37740ba6cc4769b095706c064d823)

arch/arm/boot/dts/imx6sx-sabreauto.dts
arch/arm/mach-imx/mach-imx6sx.c

index 2991ef3a749178442cc778a1a0f466ed1719ea03..bdf4b8eed3a4a28c29a3fae343dfb2fc49579c89 100644 (file)
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_flexcan1_1>;
        trx-en-gpio = <&max7310_b 5 GPIO_ACTIVE_HIGH>;
-       trx-stby-gpio = <&max7310_b 3 GPIO_ACTIVE_HIGH>;
+       trx-stby-gpio = <&max7310_b 4 GPIO_ACTIVE_HIGH>;
+       trx-wakeup-gpio = <&max7310_b 7 GPIO_ACTIVE_HIGH>;
        status = "okay";
 };
 
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_flexcan2_1>;
        trx-en-gpio = <&max7310_b 5 GPIO_ACTIVE_HIGH>;
-       trx-stby-gpio = <&max7310_b 3 GPIO_ACTIVE_HIGH>;
+       trx-stby-gpio = <&max7310_b 4 GPIO_ACTIVE_HIGH>;
+       trx-wakeup-gpio = <&max7310_b 7 GPIO_ACTIVE_HIGH>;
        status = "okay";
 };
 
index 0389276889706c3da0c32ea99e45d27d7634de69..ddf6aec84a620e80c80f9747c5ab2c2152d2abd2 100755 (executable)
@@ -120,13 +120,24 @@ static int __init imx6sx_arm2_flexcan_fixup(void)
        struct device_node *np;
        enum of_gpio_flags en_flags, stby_flags;
        bool canfd_en = false;
+       int wakeup_gpio;
 
        np = of_find_node_by_path("/soc/aips-bus@02000000/can@02090000");
        if (!np)
                return -ENODEV;
 
+
+       /* Wakeup transceiver first in case it's in sleep mode by default */
+       wakeup_gpio = of_get_named_gpio(np, "trx-wakeup-gpio", 0);
+       if (gpio_is_valid(wakeup_gpio) &&
+               !gpio_request_one(wakeup_gpio, GPIOF_OUT_INIT_HIGH, "flexcan-trx-wakeup")) {
+               gpio_set_value_cansleep(wakeup_gpio, 0);
+               gpio_set_value_cansleep(wakeup_gpio, 1);
+       }
+
        flexcan_en_gpio = of_get_named_gpio_flags(np, "trx-en-gpio", 0, &en_flags);
        flexcan_stby_gpio = of_get_named_gpio_flags(np, "trx-stby-gpio", 0, &stby_flags);
+
        if (gpio_is_valid(flexcan_en_gpio) && gpio_is_valid(flexcan_stby_gpio) &&
                !gpio_request_one(flexcan_en_gpio, GPIOF_DIR_OUT, "flexcan-trx-en") &&
                !gpio_request_one(flexcan_stby_gpio, GPIOF_DIR_OUT, "flexcan-trx-stby")) {
@@ -282,7 +293,8 @@ static void __init imx6sx_init_late(void)
                platform_device_register(&imx6sx_cpufreq_pdev);
        }
 
-       if (of_machine_is_compatible("fsl,imx6sx-sdb"))
+       if (of_machine_is_compatible("fsl,imx6sx-sdb") ||
+               of_machine_is_compatible("fsl,imx6sx-sabreauto"))
                imx6sx_arm2_flexcan_fixup();
 
        imx6sx_cpuidle_init();