Thanks for the great work Nick.
I recently bought a SPI screen and managed to drive it with panel-mipi-dbi in the newer kernel (apparently this module didn't exist in Radxa's official image with kernel 5.15).
The panel was a ST7789V 240*320 TFT LCD and I have a A7Z, with the `Radxa-cubie-A7a-a7z-v0.6.4` server image installed.
And I have put the work on [Github](https://github.com/parker-int64/sun60i-a733-dtoverlays). During the experiment, I discovered that the PWM (used for display backlight) in the allwinner BSP seems to have a bug.
The Allwinner Sunxi PWM driver may incorrectly reverts the PWM pin to GPIO input immediately after switching the pinctrl state. Thus I can control the PWM with the file nodes but can't attached it to related pins.
For example, I'm using the `sun60i-a733-pwm1-7.dtso` overlay, which is supposed to enable the PJ25. After enabling the overlay, I noticed that the PWM nodes were created and I can controll these nodes. But the pinctrl suggest that it was unclamied:
$ cat /sys/kernel/debug/pinctrl/2000000.pinctrl/pinmux-
pins | grep PJ25
pin 313 (PJ25): UNCLAIMED
Later on, AI found out that the `devm_pinctrl_put(pctl);` in bsp/drivers/pwm/pwm-sunxi.c may have been incorrectly called on the clean stage of the `sunxi_pwm_pin_set_state`:
520 static int sunxi_pwm_pin_set_state(struct device *dev, char *name)
521 {
522 struct pinctrl *pctl;
523 struct pinctrl_state *state = NULL;
524 int err;
525
526 pctl = devm_pinctrl_get(dev);
527 if (IS_ERR(pctl)) {
528 sunxi_err(dev, "pinctrl_get failed\n");
529 err = PTR_ERR(pctl);
530 return err;
531 }
532
533 state = pinctrl_lookup_state(pctl, name);
534 if (IS_ERR(state)) {
535 sunxi_err(dev, "pinctrl_lookup_state(%s) failed\n", name);
536 err = PTR_ERR(state);
537 goto exit;
538 }
539
540 err = pinctrl_select_state(pctl, state);
541 if (err) {
542 sunxi_err(dev, "pinctrl_select_state(%s) failed\n", name);
543 goto exit;
544 }
545
546 exit:
547 /*
548 * devm_pinctrl_put() releases the last pinctrl reference,
549 * causing pinmux_disable_setting() to restore the pin to
550 * its default GPIO function. The devres framework will
551 * release this resource automatically when the device is
552 * destroyed.
553 */
554 devm_pinctrl_put(pctl);
555 return err;
556
557 }
Also it gives me a workaround `sunxi-pwm-child-pinctrl.c`, introduces an additional pinctrl reference, preventing `devm_pinctrl_put()` from reducing the reference count to zero. Both the patch file and the workaround source is available on Github. However I only tried the workaround since I have some trouble compile the full kernel at the moment, will try some time later and update more details on Github.
And at last the pwm-backlight worked as expected and my LCD light up.