Quoting Linus Walleij <linus.walleij@xxxxxxxxxx>:
On Thu, Nov 7, 2019 at 10:48 PM René van Dorst <opensource@xxxxxxxxxx> wrote:
DTS:
&gpio {
sfp_i2c_clk_gate {
gpio-hog;
gpios = <7 GPIO_ACTIVE_LOW>;
output-high;
};
};
root@OpenWrt:/# dmesg | grep hog
[ 3.095360] GPIO line 487 (sfp_i2c_clk_gate) hogged as output/high
This looks correct, output/high and "high" in this case means
asserted and it's active low so that should mean it is driven
low.
gpiochip0: GPIOs 480-511, parent: platform/1e000600.gpio,
1e000600.gpio-bank0:
gpio-487 ( |sfp_i2c_clk_gate ) out hi ACTIVE LOW
So that is wrong :(
DTS:
&gpio {
sfp_i2c_clk_gate {
gpio-hog;
gpios = <7 GPIO_ACTIVE_HIGH>;
output-high;
};
};
(...)
gpio-487 ( |sfp_i2c_clk_gate ) out hi
OK that worked... sheer luck I guess.
DTS:
&gpio {
sfp_i2c_clk_gate {
gpio-hog;
gpios = <7 GPIO_ACTIVE_HIGH>;
output-low;
};
};
(...)
gpio-487 ( |sfp_i2c_clk_gate ) out hi
Yeah now it is wrong again...
So as you can see gpio-hog is parsed well by the kernel.
But it setting up the data value is not.
Please drill into the functions.
What happens down in the callback to the actual driver?
Can you check whether the .set_value() gets the right value
or not so we see if there is a logical or physical problem?
The mt7621 driver uses gpio-mmio so you should patch
drivers/gpio/gpio-mmio.c function bgpio_set() or
bgpio_set_set() I think.
Hi Linus,
Thanks for pointing me in the direction where to start debuging.
mt7621 used bgpio_set_with_clear() because we have `set` and `clear`
registers.
[ 3.096085] gpiochip_find_base: found new base at 480
[ 3.106063] bgpio_set_with_clear: gpio-480 gpio:7 val:0x0 mask:0x80
reg:0xbe000640
[ 3.118968] bgpio_set_with_clear: before: gpio:7 reg:0xbe000640:
value-of-data-reg:0xb75f7de, masked data:0x80
[ 3.134845] bgpio_write32: 0xbe000640 <= 0x80
[ 3.142116] bgpio_set_with_clear: after: gpio:7 reg:0xbe000640:
value-of-data-reg:0xb75f7de, masked data:0x80
It seems that writing to the 'clear' register doesn't do anything.
I noticed that register address is 0x1e000000 in the DTS but in the
code it is 0xbe000000.
[ 3.158002] bgpio_write32: 0xbe000600 <= 0x80
[ 3.165258] GPIO line 487 (sfp_i2c_clk_gate) hogged as output/high
[ 3.177532] gpiochip_add_data_with_key: gpiochip0 gpio7: 0x843
When using program 'io' writing to the `clear` register 0x1e000640
does have effect.
root@OpenWrt:/# io -4 0x1e000620
1e000620: 0b75f7de
root@OpenWrt:/# io -4 -w 0x1e000640 0x80
root@OpenWrt:/# io -4 0x1e000620
1e000620: 0b75f74e
If I change the bgpio_init() values so that we don't have the `set`
and `clear` registers.
With the patch below I do get right results.
diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c
index d1d785f983a7..186e8d6f3c64 100644
--- a/drivers/gpio/gpio-mt7621.c
+++ b/drivers/gpio/gpio-mt7621.c
@@ -228,7 +228,8 @@ mediatek_gpio_bank_probe(struct device *dev,
diro = mtk->base + GPIO_REG_CTRL + (rg->bank * GPIO_BANK_STRIDE);
ret = bgpio_init(&rg->chip, dev, 4,
- dat, set, ctrl, diro, NULL, 0);
+ dat, NULL, NULL, diro, NULL, 0);
+
if (ret) {
dev_err(dev, "bgpio_init() failed\n");
return ret;
Any idea what this can be?
Greats,
René
Yours,
Linus Walleij