Comment 23 for bug 1229658

Revision history for this message
sanjay singh rawat (sanjay-rawat) wrote : Re: [Bug 1229658] Re: Information is unavailable on "Gpio" page in powerdebug 0.7.1 with vexpress A9 Android.

Hi Meraj,

Your patch assumes the gpio numbers sequentially listed in the debug
file, which is a wrong assumption. It will export gpios which are not
listed.

e.g. below is the gpio debug info for panda

GPIOs 0-31, gpio:
  gpio-0 (tfp410 PD ) out lo
  gpio-1 (hsusb1_vbus ) out hi

GPIOs 32-63, gpio:
  gpio-41 (hdmi_ls_oe ) out lo
  gpio-43 (vwl1271 ) out hi
  gpio-60 (hdmi_ct_cp_hpd ) out hi
  gpio-62 (hsusb1_phy.8 ) out hi
  gpio-63 (hdmi_hpd ) in lo IRQ

GPIOs 64-95, gpio:

GPIOs 96-127, gpio:
  gpio-127 (audpwron ) out hi

GPIOs 128-159, gpio:

GPIOs 160-191, gpio:

On Monday 26 May 2014 02:43 PM, Mohammad Merajul Islam Molla wrote:
> Hello Sanjay/Botao,
>
> It looks like there is a problem in the code portion below -
>
> while (read = getline(&line, &len, fgpio) != -1) {
> char *str;
>
> if (strstr(line, "gpio-")) {
> str = strtok(line, " ");
> sscanf(str, "gpio-%d", &gpio[num]);
> fprintf(fgpio_export, "%d", gpio[num]);
> num++;
> }
>
> /sys/kernel/debug/gpio will have lines as below only if those gpio pins
> have already been exported by writing to /sys/class/gpio/export file -
>
> gpio-1 (sysfs ) in hi
> gpio-2 (sysfs ) in lo
> gpio-3 (sysfs ) in hi
> gpio-4 (sysfs ) in lo
> gpio-5 (sysfs ) in lo
> gpio-6 (sysfs ) in hi
> gpio-7 (sysfs ) in hi
>
>
> I have attached a patch which fixes the problem. Now it dynamically determines maximum number of gpios on the platform and exports those via /sys/class/gpio/export file.
>
> Please review/comment/test the patch attached.
>
> *** NOTE: The earlier patch (mentioned above) is no longer necessary.
> This patch contains all the other fixes too.
>
>
> Thanks,
> -Meraj
>
> ** Attachment added: "powerdebug_gpio_info_patch"
> https://bugs.launchpad.net/linaro-powerdebug/+bug/1229658/+attachment/4119672/+files/powerdebug_gpio_info_patch
>

--
sanjay