How to read gpio value in s32v234 uboot

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read gpio value in s32v234 uboot

1,263 Views
zhaocq
Contributor II

How to read gpio value in s32v234 uboot | NXP Community

hi NXP,

          s32v234 uboot  stage, we want to use Port PB5 and PB6 as GPIO function, we want to simulate i2c. Now we can set PB5 and PB6 to output high and low, set as below:

writel(config , SIUL2_MSCRn(19));
writel(value_off, SIUL2_GPDOn(SIUL2_GPDO_for_GPIO(19)));

writel(config , SIUL2_MSCRn(20));
writel(value_off, SIUL2_GPDOn(SIUL2_GPDO_for_GPIO(20)));

through the wavelet, we can get high and low. 

Also we need to read the data input, I set below codes, but still can not read  correct value.

u32 config1 = (0<<0 | 1<<19);

writel(config1 , SIUL2_IMCRn(273));
get_value = readl(SIUL2_IMCRn(273));
printf("Board: test_gpio_i2c get_value=%x\n",get_value);

Could you tell me how to set the input and read the input value? Thanks in advances!

zhaocq 

15818603417

Labels (1)
0 Kudos
3 Replies

1,078 Views
bpe
NXP TechSupport
NXP TechSupport

At the first glance, you are printing the value of IMCR while it should be
GPDI if you want to display the level on the pad. You can refer to Linux
S32V234 GPIO driver, routine siul2_gpio_get() for reading pads. Hardware
level details on setting and reading GPIO pins can be found in S32V234
Reference Manual, Sections 20.2.11, 20.2.12 and 20.2.14

Hope this helps

Platon

0 Kudos

1,078 Views
zhaocq
Contributor II

hi Platon,

Thanks for your reply.

S32V234 platform we can not see the function siul2_gpio_get() for reading pads.

As the S32V234 Reference Manual, we should config the registers MSCR, IMCR and   GPDI for reading.

as the below we want to read Port PB3, but can not success. 

u32 config2 = (0<<0 | 0<<21 | 1<< 20 | 1<< 19 | 7<< 8);

writel(config2 , SIUL2_MSCRn(19));

u32 config1 = 2;

writel(config1 , SIUL2_IMCRn(273));

get_value = readl(SIUL2_GPDIn(19));
printf("Board: test_gpio_i2c get_value=%x\n",get_value);

before reading , I have set the pin to high level, but get the value is still 0. Could you tell us what's wrong with this?  I don't know how to set the GPDI register. Pls help, Thanks.

0 Kudos

1,078 Views
bpe
NXP TechSupport
NXP TechSupport

Use the link below to access the file containing siul2_gpio_get() function. Use the function as a reference:

gpio-siul2.c\gpio\drivers - linux - Automotive S32 Linux Kernel 

S32V234RM, Sections 20.2.11, 20.2.12 and 20.2.14 provide all necessary
information on setting pads as inputs and reading their levels.
If your code does not work as expected: (a) compare it to the reference
code mentioned above; (b) verify it against the description in the
Reference Manual; (c) step through it in a debugger
verifying addresses and respective values it writes to the target registers
to make sure they are set according to (a) and (b).

Regards,

Platon

0 Kudos