How to enable clock gating registers for GPIO

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to enable clock gating registers for GPIO

Jump to solution
2,192 Views
simon_willis
Contributor II

Hi There,

I'm in the process of bringing up an iMX6ULL based board with Linux imx6ul7d 5.4.24-2.1.0. We have a number of GPIO pins we need to use. However when I try to interact with them in Linux using sysfs, the board either locks up or nothing happens. I eventually chased this down to the clock gating registers not being set for the relevant GPIO clocks. In U-Boot we set all clock gating registers to 0xFFFFFFFF, however I read that Linux disables the unused clocks and I'm assuming this is the cause of our problem. I know there is a way to add a kernel command line parameter to prevent this. However, I was wondering if there is a better way to do this that integrates with the device tree.

Snipits from the device tree:

&gpio1 {
gpio-reserved-ranges = <0 32>;
gpio-ranges = <&iomuxc 0 23 10>, <&iomuxc 10 17 6>,
<&iomuxc 16 33 16>;
};

&gpio2 {
gpio-ranges = <&iomuxc 0 49 16>, <&iomuxc 16 111 6>;
};

&gpio3 {
gpio-ranges = <&iomuxc 0 65 29>;
status = "okay";
};

&gpio4 {
gpio-ranges = <&iomuxc 0 94 17>, <&iomuxc 17 117 12>;
};

&gpio5 {
gpio-ranges = <&iomuxc 0 7 10>, <&iomuxc 10 5 2>;
};

And we have a default iomuxc config

&iomuxc {
pinctrl-names = "default";
pinctrl-0 = <&BOARD_InitPins>;
imx6ul-evk {
BOARD_InitPins: BOARD_InitPinsGrp {
fsl,pins = <
MX6UL_PAD_SD1_CLK__GPIO2_IO17 0x0000B830

MX6UL_PAD_LCD_DATA04__GPIO3_IO09 0x0000B830
MX6UL_PAD_LCD_DATA05__GPIO3_IO10 0x00011030
MX6UL_PAD_LCD_DATA12__GPIO3_IO17 0x00011030
MX6UL_PAD_LCD_DATA13__GPIO3_IO18 0x00011030
MX6UL_PAD_LCD_DATA14__GPIO3_IO19 0x00011030
MX6UL_PAD_LCD_DATA15__GPIO3_IO20 0x00011030
MX6UL_PAD_LCD_DATA18__GPIO3_IO23 0x00011030
MX6UL_PAD_LCD_DATA19__GPIO3_IO24 0x0000B030
MX6UL_PAD_LCD_DATA23__GPIO3_IO28 0x00003030
>;
};

Also, I see all of the clocks defined in imx6ul-clock.h, however I do not see the GPIO clock gates. How do the integers assigned to each clock get mapped into the gating registers? Perhaps I'm miss understanding something here.

Any help is would be much appreciated.

Labels (2)
0 Kudos
Reply
1 Solution
2,142 Views
igorpadykov
NXP Employee
NXP Employee

Hi Simon

one can look at linux clock driver (like  imx_clk_hw_gate2("gpio2",..)

clk-imx6ul.c\imx\clk\drivers - linux-imx - i.MX Linux kernel 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
Reply
2 Replies
2,143 Views
igorpadykov
NXP Employee
NXP Employee

Hi Simon

one can look at linux clock driver (like  imx_clk_hw_gate2("gpio2",..)

clk-imx6ul.c\imx\clk\drivers - linux-imx - i.MX Linux kernel 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
2,142 Views
simon_willis
Contributor II

Thanks Igor. That helped a lot. It turns out that these clocks were not defined in the imx6ul-clocks.h header file I'm using (as per: imx6ul-clock.h\clock\dt-bindings\include - linux-imx - i.MX Linux kernel ). 

And then I just needed to add the clock definition to each GPIO node as per your link.

0 Kudos
Reply