查看“MY-IMX6 Linux-3.0.35 GPIO Development”的源代码
←
MY-IMX6 Linux-3.0.35 GPIO Development
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
<div> = '''GPIO output & input''' = GPIO output & input take SD1_CLK leads as an example.<br> == '''Modification “.h” file''' == 1)Check configuration for SD1_CLK in file.<br> Example:<br> $ sed -n "/PAD_SD1_CLK/p" arch/arm/mach-mx6/board-mx6q_sabresd.h<br> <br> 2)Configuration for SD1_CLK in comment header file.<br> Example:<br> $ sed -i "s/MX6Q_PAD_SD1_CLK/\/\/ &/g" arch/arm/mach-mx6/board-mx6q_sabresd.h<br> <br> 3)Adding configuration for SD1_CLK in mx6q_sabresd_pads <br> Configure SD1_CLK function as MX6Q_PAD_SD1_CLK__GPIO_1_20 <br> Example:<br> $ sed -i "/mx6q_sabresd_pads/a\\\t MX6Q_PAD_SD1_CLK__GPIO_1_20," \<br> arch/arm/mach-mx6/board-mx6q_sabresd.h<br> <br> 4)Check modified result<br> Example:<br> $ sed -n "/PAD_SD1_CLK/p" arch/arm/mach-mx6/board-mx6q_sabresd.h<br> == '''Configure kernel''' == *Mamu position<br> Device Drivers ---> -*- GPIO Support ---> [*] /sys/class/gpio/... (sysfs interface)<br> [[File:my_imx6_gpio_1.2.0.1.jpg]]<br> == '''Compilation''' == :make uImage<br> == '''Re-program system and boot''' == == '''Device operation''' == === Check out gpio directory === GPIO led out can bee seen under /sys/class/gpio/ directory <br> $ ls /sys/class/gpio/<br> <br> [[File:my_imx6_gpio_1.5.1.1.jpg]]<br> <br> === Register GPIO to system === Register GPIO_1_20 to system with echo,then an extra gpio20 directory can be found under gpio directory.<br> Tips:I.MX6 GPIO value is calculation this way(where grouped - 1) * 32 + order number,so lead number of GPIO_1_20 is(1 – 1) * 32 + 20 = 20.<br> $ echo 20 > /sys/class/gpio/export<br> <br> [[File:my_imx6_gpio_1.5.2.1.jpg]]<br> <br> ===GPIO output control === *Set leads as output state <br> $ echo out > /sys/class/gpio/gpio20/direction<br> *Set lead output at high electrical level<br> echo 1 > /sys/class/gpio/gpio20/value<br> *Set lead output at low electrical level <br> echo 0 > /sys/class/gpio/gpio20/value<br> === Set lead as input state === *Set lead as input state.<br> echo in > /sys/class/gpio/gpio20/direction<br> *Gain lead value<br> cat /sys/class/gpio/gpio20/value<br> === Logout GPIO interface === *Logout GPIO_1_20<br> echo 20 > /sys/class/gpio/unexport<br> = '''GPIO LED''' = ---- Instruction:take GPIO LED以PAD NANDF_CS0 as example.<br> == '''Enter kernel directory''' == $ cd ~/MY-I.MX6/linux-3.0.35/<br> [[File:my_imx6_gpio_2.1.0.1.jpg]]<br> == '''Add code''' == === Modification.h file === 1)Check out configuration for NANDF_CS0 in header file.<br> Example:<br> $ sed -n "/PAD_NANDF_CS0/p" arch/arm/mach-mx6/board-mx6q_sabresd.h<br> <br> 2)Comment configuration for NANDF_CS0 in header file.<br> Example:<br> $ sed -i "s/MX6Q_PAD_NANDF_CS0/\/\/ &/g" arch/arm/mach-mx6/board-mx6q_sabresd.h<br> <br> 3)Add configuration for NANDF_CS0 in mx6q_sabresd_pads.<br> Configure NANDF_CS0 function as MX6Q_PAD_NANDF_CS0__GPIO_6_11.<br> Example:<br> $ sed -i "/mx6q_sabresd_pads/a\\\tMX6Q_PAD_NANDF_CS0__GPIO_6_11," arch/arm/mach-mx6/board-mx6q_sabresd.h<br> <br> 4)Check out modified result.<br> Example:<br> $ sed -n "/PAD_NANDF_CS0/p" arch/arm/mach-mx6/board-mx6q_sabresd.h<br> === Modification.c file === 1)Check out whether GPIO is used repeatedly in .c file<br> Example:<br> $ sed -n '/IMX_GPIO_NR(6,.11)/p' arch/arm/mach-mx6/board-mx6q_sabresd.c<br> <br> 2)Add macro definition of GPIOin .c file<br> Add #define SABRESD_USER_LED IMX_GPIO_NR(6, 11) <br> Example:<br> $ GPIO_DEFINE="#define SABRESD_USER_LED\tIMX_GPIO_NR(6, 11)"<br> $ sed -i "1,/#define/{/#define/s/#define/${GPIO_DEFINE}\n&/}" arch/arm/mach-mx6/board-mx6q_sabresd.c<br> <br> 2)Check out data definition with gpio_led<br> Example:<br> $ sed -n '/struct gpio_led /,/\}/p' arch/arm/mach-mx6/board-mx6q_sabresd.c<br> <br> 3)Add data definition of user_led<br> static struct gpio_led imx6q_gpio_leds[] = {<br> GPIO_LED(SABRESD_USER_LED, "user_led", 0, 1,<br> "charger"),<br> };<br> == '''Kernel configuration''' == *manu position<br> Device Drivers ---> [*] LED Support ---> <*> LED Support for GPIO connected LEDs<br> [[File:my_imx6_gpio_2.3.0.1.jpg]]<br> == '''Compilation''' == make uImage<br> == '''Re-program system and boot''' == == '''GPIO_LED operation''' == === Device file directory === To be saved under /sys/class/leds/user_led directory after booting system,which can be seen with ls.<br> $ ls /sys/class/leds/user_led<br> <br> [[File:my_imx6_gpio_2.6.1.1.jpg]]<br> <br> === Operating example === 1)Set NANDF_CS0 as 1<br> $ echo 1 > /sys/class/leds/user_led/brightness<br> 2)Set NANDF_CS0 as 0<br> $ echo 0 > /sys/class/leds/user_led/brightness<br> = '''GPIO key''' = ---- GPIO key by taking GPIO_4、EIM_BCLK、CSI0_DATA_EN as example,are separetely SW2,SW3和SW4 in schematic.<br> == '''Modification.h file''' == 1)Check out configuration for PAD in header file.<br> Example:<br> $ sed -n "/PAD_GPIO_4/p" arch/arm/mach-mx6/board-mx6q_sabresd.h<br> $ sed -n "/PAD_EIM_BCLK/p" arch/arm/mach-mx6/board-mx6q_sabresd.h<br> $ sed -n "/PAD_CSI0_DATA_EN/p" arch/arm/mach-mx6/board-mx6q_sabresd.h<br> <br> 2)Comment configuration for PAD in header file.<br> Example:<br> $ sed -i "s/MX6Q_PAD_GPIO_4/\/\/ &/g" arch/arm/mach-mx6/board-mx6q_sabresd.h<br> $ sed -i "s/MX6Q_PAD_EIM_BCLK/\/\/ &/g" arch/arm/mach-mx6/board-mx6q_sabresd.h<br> $ sed -i "s/MX6Q_PAD_CSI0_DATA_EN/\/\/ &/g" arch/arm/mach-mx6/board-mx6q_sabresd.h<br> <br> 3)Add configuration for PAD in mx6q_sabresd_pads.<br> Configure GPIO_4 function as MX6Q_PAD_GPIO_4__GPIO_1_4.<br> Example:<br> $ sed -i "/mx6q_sabresd_pads/a\\\tMX6Q_PAD_GPIO_4__GPIO_1_4," arch/arm/mach-mx6/board-mx6q_sabresd.h<br> Configure EIM_BCLK function as MX6Q_PAD_EIM_BCLK__GPIO_6_31.<br> Example:<br> $ sed -i "/mx6q_sabresd_pads/a\\\tMX6Q_PAD_EIM_BCLK__GPIO_6_31," arch/arm/mach-mx6/board-mx6q_sabresd.h<br> Configrue PAD function of CSI0_DATA_EN as MX6Q_PAD_CSI0_DATA_EN__GPIO_5_20.<br> Example:<br> $ sed -i "/mx6q_sabresd_pads/a\\\tMX6Q_PAD_CSI0_DATA_EN__GPIO_5_20," arch/arm/mach-mx6/board-mx6q_sabresd.h<br> <br> 4)Check out modified result<br> Example:<br> $ sed -n "/PAD_GPIO_4/p" arch/arm/mach-mx6/board-mx6q_sabresd.h<br> $ sed -n "/PAD_EIM_BCLK/p" arch/arm/mach-mx6/board-mx6q_sabresd.h<br> $ sed -n "/PAD_CSI0_DATA_EN/p" arch/arm/mach-mx6/board-mx6q_sabresd.h<br> == '''Modification.c file''' == 1)Check out whether GPIO is used repeatedly in .c file.<br> Example:<br> $ sed -n '/IMX_GPIO_NR(1,.4)/p' arch/arm/mach-mx6/board-mx6q_sabresd.c<br> $ sed -n '/IMX_GPIO_NR(6,.31)/p' arch/arm/mach-mx6/board-mx6q_sabresd.c<br> $ sed -n '/IMX_GPIO_NR(5,.20)/p' arch/arm/mach-mx6/board-mx6q_sabresd.c<br> <br> 2)Add macro definition of GPIO in .c file.<br> *MX6Q_PAD_GPIO_4__GPIO_1_4<br> In .c file add #define SABRESD_POWER_OFF IMX_GPIO_NR(1, 4))<br> Example:<br> $ GPIO_DEFINE="#define SABRESD_POWER_OFF\tIMX_GPIO_NR(1, 4)"<br> $ sed -i "1,/#define/{/#define/s/#define/${GPIO_DEFINE}\n&/}" arch/arm/mach-mx6/board-mx6q_sabresd.c<br> *MX6Q_PAD_CSI0_DATA_EN__GPIO_5_20<br> In .c file add #define SABRESD_VOLUME_UP IMX_GPIO_NR(6, 31).<br> Example:<br> $ GPIO_DEFINE="#define SABRESD_VOLUME_UP\tIMX_GPIO_NR(6, 31)"<br> $ sed -i "1,/#define/{/#define/s/#define/${GPIO_DEFINE}\n&/}" arch/arm/mach-mx6/board-mx6q_sabresd.c<br> *MX6Q_PAD_CSI0_DATA_EN__GPIO_5_20<br> In .c file add #define SABRESD_VOLUME_DN IMX_GPIO_NR(5, 20)) <br> Example:<br> $ GPIO_DEFINE="#define SABRESD_VOLUME_DN\tIMX_GPIO_NR(5, 20)"<br> $ sed -i "1,/#define/{/#define/s/#define/${GPIO_DEFINE}\n&/}" arch/arm/mach-mx6/board-mx6q_sabresd.c<br> <br> 3)Chech out data definition with gpio_keys_button.<br> Example:<br> $ sed -n '/gpio_keys_button/,/\}/p' arch/arm/mach-mx6/board-mx6q_sabresd.c<br> <br> 4)Add data definition for volume-up、volume-down、power.<br> static struct gpio_keys_button imx6q_buttons[] = {<br> GPIO_BUTTON(SABRESD_VOLUME_UP, KEY_VOLUMEUP, 1, "volume-up", 0, 1),<br> GPIO_BUTTON(SABRESD_VOLUME_DN, KEY_VOLUMEDOWN, 1, "volume-down", 0, 1),<br> GPIO_BUTTON(SABRESD_POWER_OFF, KEY_POWER, 1, "power", 1, 1),<br> };<br> == '''Kernel configuration''' == *manu position:<br> Device Drivers ---> Input device support ---> [*] Keyboards ---> <*> GPIO Buttons<br> [[File:my_imx6_gpio_3.2.0.1.jpg]]<br> == '''Compilation''' == make uImage<br> == '''Re-program system and boot''' == == '''GPIO key operation''' == ===GPIO_KEYS device === To be saved under /sys/devices/platform/gpio-keys directory after booting system,which can be seen with ls.<br> <br> [[File:my_imx6_gpio_3.5.1.1.jpg]]<br> <br> $ ls /sys/devices/platform/gpio-keys<br> === Check out device information === Relatie information can be found in proc file system.<br> $ cat /proc/bus/input/devices<br> <br> [[File:my_imx6_gpio_3.5.2.1.jpg]]<br> <br> === Device file === Event0 is matched up with device file corresponding to gpio key,check out with ls.<br> <br> [[File:my_imx6_gpio_3.5.3.1.jpg]]<br> <br> $ ls /dev/input/event0 –la<br> === Operating example === Refer to Linux test manual.<br> </div>
返回至
MY-IMX6 Linux-3.0.35 GPIO Development
。
导航菜单
个人工具
登录
命名空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
[-_-]
NXP平台:
MYZR-IMX6-EK200
MYZR-IMX6-EK200(EN)
MYZR-IMX6-EK314
MYZR-IMX6-EK314(EN)
MYZR-IMX6-EK336
MYZR-IMX6-EK336(EN)
MYZR-IMX6-EK140
MYZR-IMX6-EK140(EN)
MYZR-IMX6-EK140P
MYZR-IMX6-EK140P(EN)
MYZR-IMX8M-EK300
MYZR-IMX8M-EK300(EN)
MYZR-IMX8M-EVK
MYZR-IMX8Mmini-EK240
MYZR-IMX8Mmini-EK240(EN)
MYZR-IMX28-EK142
MYZR-IMX28-EK142(EN)
MYZR-LS1012A-EK200
MYZR-LS1012A-EK200(EN)
Rockchip平台:
MYZR-RK3288-EK314
MYZR-RK3288-EK314(EN)
MYZR-RK3399-EK314
MYZR-RK3399-EK314(EN)
Allwinner平台:
MYZR-R16-EK166
MYZR-R16-EK166(EN)
Microchip平台:
MYZR-SAMA5-EK200
MYZR-SAMA5-EK200(EN)
网关产品:
GW200
GW300
GW310/GW311
ST平台:
MYZR-STM32-EK152
所有页面
工具
链入页面
相关更改
特殊页面
页面信息