<vorian45620>
I am working on a custom carrier for the sopine SOM, and as part of that project attempting to configure the axp803. I am really struggling to determine where and how to change values within the axp registers, as well as configure my system to handle the interrupts from the device.
<smaeul>
there are several drivers for the various functions of the AXP803 chip -- the first is that ATF (trusted firmware) enables and sets regulator voltages at boot. then Linux has drivers for the regulators, power key, GPIO, AC and USB inputs, and battery charger
<smaeul>
however, there's a decent chunk of functionality still with no drivers
<vorian45620>
Ok, so lets say for example I wanted to change the power ok short press time. Is that something done in the device tree? I have been reading through the mfd drivers in linux mainline but I cannot find a method for this.
<vorian45620>
power ok short press interrupt*
<smaeul>
the power key times are configurable via sysfs
<smaeul>
(the driver is INPUT_AXP20X_PEK)
<smaeul>
only the startup/shutdown times are there currently, because the driver doesn't use the long/short events, only falling/rising
<smaeul>
but if you wanted to implement short/long presses, with some arbitrary keycode, that would be the driver to put them in
<smaeul>
if you want to play with registers for testing, you can do that with a one line kernel patch, and the regmap debugfs interface
<smaeul>
the parts that go in the device tree are the regulators and GPIOs
<smaeul>
for the power supplies and the battery, enabling the device in the device tree exposes it to userspace, but that's not required for the PMIC to work -- it's pretty autonomous
<vorian45620>
Ok, that helps a lot thank you. I have a rootfs I built using buildroot on the 5.8, and I am struggling to find anything under sys for power key times.
<smaeul>
all of the subdevices will show up under /sys/bus/sunxi-rsb/devices/sunxi-rsb-3a3, so the two sysfs files for power key times are /sys/bus/sunxi-rsb/devices/sunxi-rsb-3a3/axp221-pek/{startup,shutdown}
<vorian45620>
Are all of the axp803 interrupts available or do some of them fall under the decent chunk of functionality without drivers?
<smaeul>
you mean the virtual interrupts that get multiplexed to the one IRQ pin?
<smaeul>
they are all available at the MFD driver level -- you could write a driver that used any one of them without writing any plumbing
<smaeul>
and any of them can be used to wake the system from deep sleep
<vorian45620>
Yes, that was what I meant. Thanks a lot! That was more info than I got from hours of digging.
<smaeul>
hmm, that's not quite accurate. see the "struct resource" arrays in drivers/mfd/axp20x.c. you'd need to add more DEFINE_RES_IRQ_NAMED to hook up an IRQ to your mfd cell
<smaeul>
but all of the IRQs are at least enumerated for you in include/linux/mfd/axp20x.h
<smaeul>
and all of the multiplexing is already handled for you
<vorian45620>
I am a little new to this, so I don't follow exactly what you mean by "you'd need to add more DEFINE_RES_IRQ_NAMED to hook up an IRQ to your mfd cell" but is there a line you could point me at for an already existing example of one of those defines?
<smaeul>
sure, take for example the power key. the driver is referenced by name ("axp221-pek") in axp803_cells on line 30, and it's given the resources in axp803_pek_resources defined on line 223
<smaeul>
s/line 30/line 730/
<smaeul>
the DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_RIS_EDGE, "PEK_DBR"), on line 224 maps the bit offset in the register to a name that the axp221-pek driver can use
<smaeul>
which it does in drivers/input/misc/axp20x-pek.c:442: axp20x_pek->irq_dbr = platform_get_irq_byname(pdev, "PEK_DBR");
<smaeul>
so when adding a new mfd cell, you would need to create a new array similar to axp803_pek_resources (or add to an existing array), and reference that from your entry in axp803_cells