Message ID | 1477920093-28180-1-git-send-email-stefan.wahren@i2se.com |
---|---|
State | New |
Headers | show |
Stefan Wahren <stefan.wahren@i2se.com> writes: > Since the BCM2835 datasheet doesn't exactly specify the set-up time for > the GPIO Pull-up/down Clock Registers there was an assumption of 150 cycles > at a clock rate of 1 MHz. During a discussion [1] in the Raspberry Pi forum > it turns out that clock rate refers to the VPU which has a rate of 250 MHz. > So we can reduce the delay to a sensible value and update the comment above. > > I tested this optimization with a Raspberry Pi B and a multimeter. > > [1] - https://www.raspberrypi.org/forums/viewtopic.php?f=72&t=163352 > > Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> I've confirmed that the only clock input to the hardware module that contains the GPPUD registers is the VPU clock, and I don't see anything else over in the pads area either. Reviewed-by: Eric Anholt <eric@anholt.net>
On Mon, Oct 31, 2016 at 2:21 PM, Stefan Wahren <stefan.wahren@i2se.com> wrote: > Since the BCM2835 datasheet doesn't exactly specify the set-up time for > the GPIO Pull-up/down Clock Registers there was an assumption of 150 cycles > at a clock rate of 1 MHz. During a discussion [1] in the Raspberry Pi forum > it turns out that clock rate refers to the VPU which has a rate of 250 MHz. > So we can reduce the delay to a sensible value and update the comment above. > > I tested this optimization with a Raspberry Pi B and a multimeter. > > [1] - https://www.raspberrypi.org/forums/viewtopic.php?f=72&t=163352 > > Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Patch applied with Eric's review tag. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c index fa77165..b2dd278 100644 --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -917,12 +917,14 @@ static int bcm2835_pinconf_set(struct pinctrl_dev *pctldev, bcm2835_gpio_wr(pc, GPPUD, arg & 3); /* - * Docs say to wait 150 cycles, but not of what. We assume a - * 1 MHz clock here, which is pretty slow... + * BCM2835 datasheet say to wait 150 cycles, but not of what. + * But the VideoCore firmware delay for this operation + * based nearly on the same amount of VPU cycles and this clock + * runs at 250 MHz. */ - udelay(150); + udelay(1); bcm2835_gpio_wr(pc, GPPUDCLK0 + (off * 4), BIT(bit)); - udelay(150); + udelay(1); bcm2835_gpio_wr(pc, GPPUDCLK0 + (off * 4), 0); } /* for each config */
Since the BCM2835 datasheet doesn't exactly specify the set-up time for the GPIO Pull-up/down Clock Registers there was an assumption of 150 cycles at a clock rate of 1 MHz. During a discussion [1] in the Raspberry Pi forum it turns out that clock rate refers to the VPU which has a rate of 250 MHz. So we can reduce the delay to a sensible value and update the comment above. I tested this optimization with a Raspberry Pi B and a multimeter. [1] - https://www.raspberrypi.org/forums/viewtopic.php?f=72&t=163352 Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)