Skip to content

1-wire gpio driver (w1-gpio) issues #601

Closed

Description

@ajlennon

Hi,

I'm looking at support for a DS18B20 1-wire temp sensor and have run into a couple of issues with the implementation.

I'm using rpi-3.12.y branch building meta-raspberry with Yocto/OpenEmbedded but it looks as though this is current in newer branches.

(1) Driver doesn't de-allocate pullup GPIO

ref: https://github.com/raspberrypi/linux/blob/rpi-3.12.y/drivers/w1/masters/w1-gpio.c

w1_gpio_probe() calls gpio_request() for the 1-wire pin and an external pull-up logic pin if it is configured, however

w1_gpio_remove() frees the 1-wire pin, but does not free the pull-up logic pin

The failure mode can be replicated with w1-gpio built as a module and

modprobe w1-gpio

Driver for 1-wire Dallas network protocol.

rmmod w1-gpio
modprobe w1-gpio

w1-gpio w1-gpio: gpio_request_one (ext_pullup_enable_pin) failed
w1-gpio: probe of w1-gpio failed with error -16

(2) RPi BSP provides invalid pullup GPIO to w1_gpio driver

I believe (1) is an issue because the retrieved pull-up pin in the driver is a 0 which is a valid GPIO pin, and thus GPIO0 is requested and used

pdata->ext_pullup_enable_pin = of_get_gpio(np, 1);

I believe this is occurring because the board support code for bcm2708.c hardcodes the 1-wire GPIO GPIO4 but does not set the pullup pin. This means that the pullup pin will default to GPIO0 rather than an invalid value, say -1

static struct w1_gpio_platform_data w1_gpio_pdata = {
.pin = W1_GPIO,
+++ ext_pullup_enable_pin = WL_GPIO_PULLUP ( == -1)
.is_open_drain = 0,
};

(3) bcm2708.c doesn't enable pull-up configuration (e.g. kernel boot command line) and w1-gpio doesn't enable either gpio or pull-up configuration

Assuming I understand the above correctly I'd like to provide a patch to (1), (2), (3) if there would be interest.

Alex

Activity

  1. popcornmix commented on May 24, 2014

    @popcornmix
    Collaborator

    Please submit a pull request.

  2. ajlennon commented on May 24, 2014

    @ajlennon
    Author

    Will do.

  3. ajlennon commented on May 26, 2014

    @ajlennon
    Author

    It looks like this may also relate to #545, #435

  4. ajlennon commented on May 27, 2014

    @ajlennon
    Author

    @popcornmix No problem. Would you mind if I ask about the etiquette of applying patches into different branches? For example if a maintainer merges a pull request into a main branch like 3.12.y then would the maintainer or a.n.other usually plan to merge that into the head branch, if all goes well, or is that something a pull-requester like me should be thinking about? Thanks

  5. popcornmix commented on May 28, 2014

    @popcornmix
    Collaborator

    For this repo I tend to maintain the default kernel (3.12.y) and the latest stable kernel (currently 3.14.y).
    You should expect any pactches merged into 3.12.y to appear in 3.14.y (and later) kernels.

  6. ajlennon commented on May 28, 2014

    @ajlennon
    Author

    Thanks

  7. popcornmix commented on Jun 29, 2014

    @popcornmix
    Collaborator

    Should be resolved by #602

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions