adsp: new combined pinctrl + GPIO driver - #3397
Conversation
|
Have you checked the possibility of having the gpio controllers pieces under drivers/gpio? AFAIU, that's now the preferred way... "The ADSP pinmux/conf/ctrl hardware configuration is smeared across both the PADS and PORT register spaces. This has led to an ugly interaction between pinctrl-adsp.c and gpio-adi-adsp-port.c, where the pinctrl driver dips into the GPIO driver to access the PORT MMR and takes a spinlock from its private driver data." I understand that going from pinctrl into a gpioctrl driver is not good but the other way around (using the existing generic gpio APIs is fine) |
|
Also given that you're re-writing the driver, it's maybe a good time to start naming them in a nicer way :). But I guess this is now just to show the intent |
63117ae to
7b92208
Compare
7b92208 to
653a58a
Compare
653a58a to
02cd23b
Compare
|
damn updating these device trees is so exhausting |
02cd23b to
d9f6272
Compare
|
I'll resolve the conflicts tomorrow. I also need to test this on sc58x and sc7x and sc594 somehow. |
d9f6272 to
feee947
Compare
feee947 to
4226310
Compare
Ah sorry, I didn't actually give you an answer @nunojsa. As usual with a gpiochip, the following ops need implementing: Right now I have this in the pinctrl-adsp.c driver. You are asking, why don't I put it in That above is the main reason. But I will also give you a more nebulous/gut-feeling reason. Consider the example from the bindings I wrote: Here If we were to separate the drivers, I would have to set all of those All of that dance just to have code in And, indeed, there are many examples of gpiochips being registered in |
Not sure I understand the above. You would just implement those the same way you have right now. But I do see that we need the IO addresses for the muxing configuration which would make the whole thing weird. Anyways, nevermind. I just asked about it because you have both "flavors" in the kernel (split drivers or all in pinctrl) and I had the feeling split was the preferred way. But looking at the docs there's no clear rule about this. |
I was under the impression that you wanted me to call into pinctrl APIs to implement the gpiochip ops. If that were possible, a split might have made more sense (notwithstanding the iomap issue I mentioned above). Below is a bit of an elaboration on my point, just FYI, but feel free to ignore ;D ... What I have right now is: Some of these, namely those assigned For The main purpose of this request/free invocation is to inform the pinctrl (pinmux specifically) subsystem of the GPIO mode; there is also the All of that said, the subsystems are still orthogonal. pinctrl handles electrical properties and muxing, while GPIO handles GPIO input (read val)/output (get val) operation. In the case of
The docs are a bit confusing and I definitely could have misunderstood, so it's good that you ask! :D |
[ NEEDS REWORK ] There is an obvious race between the probing of eMMC and the probing of the I2C GPIO expander which controls the eMMC enable signal. If eMMC is probed too early, the hog might be inactive, and probing can fail. Use the simple MMC power sequence provider to ensure proper synchronization. Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
These SoCs don't have an MMC controller. Remove. Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
The driver will be replaced with a new one. Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
| #interrupt-cells = <2>; | ||
| }; | ||
|
|
||
| pinctrl: pinctrl { |
There was a problem hiding this comment.
If there´s nothing referencing it, just pinctrl {...
There was a problem hiding this comment.
I have to specify it in the gpio-ranges properties of the gpio@ nodes in order to conform with the existing bindings. I wanted to remove it (since it's redundant) but there's no such variant of that. Do you want me to try and make a patch to relax this constraint? It might require some code changes to generic gpio/pinctrl DT parsing code.
| type: object | ||
| patternProperties: | ||
| "-pins$": | ||
| $ref: "#/$defs/pin-cfg" |
There was a problem hiding this comment.
Would be nice to have the above on the example
There was a problem hiding this comment.
What do you mean? The button-pins is an example of a pin-cfg type
| - required: [ pinmux ] | ||
| - required: [ pins ] | ||
|
|
||
| additionalProperties: false |
There was a problem hiding this comment.
maybe the def could be putted above the scope "-pins$" scope. Otherwise it makes it a bit weird to be in the middle of the two properties using it
There was a problem hiding this comment.
not sure exactly what you mean here, can you rephrase?
| .probe = adsp_pint_probe, | ||
| .remove = adsp_pint_remove, | ||
| }; | ||
| module_platform_driver(adsp_pint_driver); |
There was a problem hiding this comment.
So I assume these device don't really need to exist all the time :)?
There was a problem hiding this comment.
there's no hard requirement for it to be built-in (you can even run the SoC without pinctrl if you want)
| if (num_configs) { | ||
| ret = pinctrl_utils_add_map_configs( | ||
| pctldev, map, reserved_maps, num_maps, group, | ||
| configs, num_configs, PIN_MAP_TYPE_CONFIGS_PIN); |
| pctldev, child, map, &reserved_maps, num_maps); | ||
| if (ret) | ||
| goto out; | ||
| } |
There was a problem hiding this comment.
You could return right away and then put the else part in a neater indentation level
There was a problem hiding this comment.
I prefer it this way
| girq->parent_domain = irq_find_host(parent_np); | ||
| of_node_put(parent_np); | ||
| if (!girq->parent_domain) | ||
| return -EPROBE_DEFER; |
There was a problem hiding this comment.
Any special reason for -EPROBE_DEFER? I see there are some drivers doing the same upstream but other just error out.
There was a problem hiding this comment.
this is the irqdomain of PINT, which - if it hasn't yet probed - will mean that irq_find_host returns NULL. so I think it's correct to return -EPROBE_DEFER.
| "missing gpio-controller child nodes\n"); | ||
|
|
||
| pc->ports = | ||
| devm_kcalloc(dev, pc->nports, sizeof(*pc->ports), GFP_KERNEL); |
There was a problem hiding this comment.
clang-format again :p
There was a problem hiding this comment.
to clarify, I'm keeping as-is because I trust clang-format
The driver will be replaced with a new one. Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
The driver will be replaced with a new one. Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
The Pin Interrupt (PINT) controller is found on Analog Devices ADSP SoCs. It senses GPIO pins and demultiplexes the parent interrupt. Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
Analog Devices ADSP SoCs have a combined pinmux/GPIO block known as PORT. Document the hardware and add the appropriate dt-bindings headers for consumer device trees to set up the pinmux functions correctly. Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
Add support for the Pin Interrupt (PINT) controller found on Analog Devices ADSP SoCs. Each PINT is a hierarchical interrupt controller with 32 interrupt lines, cascaded from a single GIC SPI. It demultiplexes its parent interrupt to as many as 32 connected GPIO pins of the connected GPIO PORT peripherals. Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
4226310 to
b1bea2b
Compare
|
@nunojsa addressed or ignored all your comments. please resolve what you want |
Add pinctrl and GPIO support for the PORT peripheral found on Analog Devices ADSP SoCs. Each alphabetically indexed PORT consists of up to 16 physical pins: PORTA has PA_00, PA_01, etc., PORTB PB_00, etc. Each pin can function as a GPIO, or be muxed to up to four alternate peripheral signals. Standard GPIO functionality such as direction or output level is configured in the PORT MMR space. Since pinmux is also part of this register space, the GPIO driver registration is folded into the pinctrl driver itself. Electrical properties such as drive strength or bias is configured in the PADS MMR space, which also includes other unrelated miscellaneous SoC configuration registers. The access to these registers is handled via the PADS syscon interface. Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
The drivers and their bindings have been replaced. Update the device tree to reflect the new usage. Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
The drivers and their bindings have been replaced. Update the device tree to reflect the new usage. Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
The drivers and their bindings have been replaced. Update the device tree to reflect the new usage. Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
The drivers and their bindings have been replaced. Update the device tree to reflect the new usage. Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
b1bea2b to
071dac3
Compare
PR Description
Solution for #3381
Basically merge the pinctl and GPIO drivers into one under drivers/pinctrl. As a learning exercise I tried implementing this from scratch, also cause I found the existing drivers a bit hard to follow.
The main advantage, besides following upstream best practices and cleaning up, is that the design now allows for the mapping between PORT and PINT to be configurable in device tree. Doing so allows for race-free EDGE_BOTH interrupts. pinmux bindings are also nicer and now impossible to misconfigure for a given SoC.
You might also notice that OPEN_DRAIN configuration is missing, but that's deliberate, I'm just relying on gpiolib's default emulation since it should be good enough. Makes the code way simpler too.
NOTE: There is a
[HACK] ...patch at the start, because I was hitting a timing issue. Working on solving it in #3420 and analogdevicesinc/lnxdsp-adi-meta#132 but should not affect the review process.PR Type
PR Checklist