libera/#maemo-leste/ Saturday, 2022-11-12

tmlindWizzup: so the MASTER_USBHOSTHS corresponds to ohci/echi, so usbhshost in omap4-l4.dtsi, seems that on low battery mdm6600 shuts down, and the usb phy is on the mdm6600 causing invalid access to the phy, or at least that's my guess06:31
tmlindseems like usbhs_omap_remove() or similar should get called to remove the related phys at that point06:34
tmlindfreemangordon: to me it seems that usb gadget framework should add/remove a vbus regulator as needed telling the max current, then chargers could try to get it and check the max current after connecting.. somehow the regulator should be drivers/phy instance specific though.. just trying to think of ideas how it could be done06:38
freemangordontmlind: and what about just adding second notifier that is dedicated to chargers?07:58
freemangordonhmm, wait. don;t we already have a regulator for vbus?07:59
freemangordonso, what about gadget asking phy for the regulator and setting the max current on it>08:00
freemangordon?08:00
freemangordonphy can do as well, if needed08:01
freemangordonand ti is needed, in host mode08:01
freemangordonso, phy core can register some "usb-charger" regulator and this can be used by chargers to limit the current and gadgets or phy itself to set the current limit08:06
freemangordondo you like that?08:07
freemangordonI just wonder if it should be only one, global, regulator or per phy08:38
freemangordonah, you said it should not e global08:53
freemangordonwell, phy_create() can create a dummy regulator based on device name or some other string (phy label?)08:58
tmlindyeah that vbus regulator could be common to the phy framework maybe, then gadget would somehow set max value, then charger could query it..10:16
tmlindor how about add phy_set_charge_current() and phy_get_charge_current() ?10:17
freemangordonwe already have that10:17
tmlindoh we do?10:17
freemangordonusb_phy_get_charger_current10:17
freemangordonand usb_phy_set_charger_current(10:17
freemangordonI was about to add regulator in usb_phy struct10:18
tmlindok but that's specific to the old drivers/usb/phy and won't work with drivers/phy?10:18
freemangordonis it?10:18
tmlindi think so, it's a different old framework for drivers/usb/phy10:18
freemangordoncpcap phy calls usb_add_phy_dev()10:19
freemangordonis this obsolete too?10:19
tmlindoh not sure10:19
tmlindit might be legacy needed for musb still10:19
freemangordonwhat I see is that usb_phy is used all over the place10:19
tmlindok maybe it's still the way to go10:20
freemangordonso, what I think is:10:20
tmlindvbus_get_charge_current(phy) vbus_set_charge_current(phy) ?10:20
freemangordonadd regulator in usb_phy and create it in  usb_charger_init()10:20
tmlindso how do you map a phy instance to that particular vbus regulator?10:21
freemangordon usb_charger_init is called by usb_add_phy_dev and usb_add_phy_dev10:21
tmlindor vbus supply..10:21
freemangordonvbus supply is another regulator10:21
freemangordonthis one is $device_name-charger or something10:22
freemangordonand is a member of phy struct10:22
freemangordonso chargers can either use regulator framework to register notigier on it10:22
freemangordonor we can have usb_charger_notifier_register() function10:22
tmlindhmm so looks like there's common vbus-supply devicetree property10:23
freemangordonand in DTS we set the phy on the charger10:23
freemangordonthere is10:23
freemangordonbut it is not what we need10:23
tmlindok10:23
freemangordonIIUC10:23
freemangordonmaybe I am wrong10:23
freemangordonbut, this supply is the one that exists in the device, no?10:24
freemangordonwhy we want some dummy regulator used to carry the min/max current10:24
tmlindDocumentation/devicetree/bindings/connector/usb-connector.yaml10:24
tmlinddocuments vbus-supply10:24
freemangordonok, but this is the internal supply, no?10:24
* freemangordon reads the docs10:25
tmlindcompatible = "usb-b-connector"10:25
freemangordonhmm10:25
tmlindnot sure what is handling it, but cpcap-charger could query it10:25
freemangordonI dont think anyone uses that, lemme grep10:25
tmlindcpcap-charger must not try to claim it on init though.. loading the phy should be optional, otherwise assume 500mA max current if regulator not available10:26
freemangordonsure10:26
freemangordonthe same as in wm831x driver10:27
tmlindok10:27
freemangordonso, if  devm_usb_get_phy_by_phandle() fails, we just assume 500mA10:27
tmlindlooks like we may just need to add the usb-b-connector node as a child of the usb or the phy10:27
Wizzuptmlind: I see, it clearly was proceeded by an empty battery warning, but it looks like what triggered it was the modem dropping off?10:28
freemangordonwho is going to set that?10:28
Wizzupoh, you wrote that too.10:28
freemangordontmlind: hmm, this is usb-conn-gpio.c10:29
freemangordonso this vbus-supply is specific to this driver, no?10:30
freemangordontmlind: BTW, did you look at https://www.mail-archive.com/linux-usb@vger.kernel.org/msg93172.html10:33
freemangordonwe still have that and I see no signs of it being obsolete10:33
freemangordonbut what do I know :)10:33
freemangordonstill, with soma small fixes this can be made to use a dummy regulator10:34
freemangordonand everything will start working10:34
freemangordonthe real issue right now is that code currently uses the same atomic notifier as what gadget network uses to report VBUS state10:35
freemangordons/gadget network/gadget framework10:35
freemangordonso my idea is to fix that by doing regulator_get() (that creates dummy regulator) in usb_charger_init()10:38
freemangordonand then usb_charger_notifier_register() registering notifier on that regulator to be used by charger10:39
freemangordonor, simply adding second notifier to the phy10:40
tmlindseems like there are multiple drivers setting up a usb connector: git grep -C20 usb-b-connector arch/arm*/boot/dts10:40
freemangordonsure10:40
freemangordonbut this is gpio based charger detection10:40
freemangordonIIUC10:40
tmlindwell adding gpio support for connect and vbus to cpcap would be trivial, it has all kind of gpios anyways10:43
tmlindwe're just not using them right now10:43
* freemangordon is looking in usb-conn-gpio.c10:43
tmlindseems like to use that we should add drivers/gpio/gpio-cpcap.c, the gpio code for cpcap is there in the v3.0.8 android kernel10:43
freemangordontmlind: umm, I don;t get that, like, how we are goping to detect ACA by using gpios?10:44
freemangordonor even a simple charger?10:44
freemangordonfor ACA we have to do voltage measurement10:44
freemangordonandroid kernel uses switch driver for charger detection == extcon10:45
freemangordonmaybe I don;t understand the idea10:45
tmlindhmm what's aca?10:47
tmlindsome regulator somewhere to query would be still needed it seems10:48
tmlindbbl, family10:48
freemangordontmlind: "Accessory Charger Adaptor"10:50
freemangordontmlind: ok, I will create some small patch to have something to discuss :)10:51
freemangordontmlind: this https://pastebin.com/WfVwFwYL11:42
sicelofreemangordon: regarding my kernel size issue ... i build a kernel with plain omap2plus_defconfig. kernel size was exactly 5MB (i.e. 500kB less than before). the irq problem still happens. tbh, i doubt it's related to kernel size. plus, the only one with missing irq is musb. other drivers don't have the issue15:32
freemangordonhmm15:32
freemangordonI still think it is DTB related, but yeah, maybe it is not the size that bugs it15:33
freemangordonuvos: tmlind: https://pastebin.com/S7wusWBf15:38
Wizzupsicelo: is it always attached?15:39
Wizzup(dtb)15:39
Wizzupmaybe you need to adjust the u-boot load addrs15:40
freemangordonuvos: tmlind: this is the patch https://pastebin.com/xHpWzDth15:40
siceloWizzup: yes i'm using attached dtb. Not sure how to make u-boot use a standalone dtb yet on n900, although that'd be a nice thing to have15:43
freemangordonoh, and as a side effect now we have stable usb ethernet even when the battery is full :D15:49
freemangordonWizzup: ^^^15:49
Wizzupfreemangordon: that is so lovely, I'm so happy about that15:49
freemangordonon the cons side - dumb chargers does not work :p15:49
Wizzupreally15:49
Wizzupheh15:49
sicelodumb charger being?15:50
freemangordonwall charger :)15:50
* freemangordon hides15:50
sicelohehe15:50
sicelodoes not work - doesn't charge the device now?15:50
freemangordonsure15:50
freemangordonwe need one more driver15:51
freemangordoncpcap-extcon15:51
freemangordonthat detects wall chargers15:51
freemangordonbut, I want tmlind to confirm what I have done so far is correct15:51
freemangordonas writing extcon driver from scratch is not a fun and if I am doing something wrong will be in vain15:52
freemangordonwhich I want to avoid15:52
uvossicelo: so if you compile dtb and then decompile it again with dtc is the irq there?15:53
freemangordonyes15:53
uvosok15:53
uvoswhat about after attaching it, pull it back out of the uboot image15:54
uvosmaybe it gets messed up there15:54
sicelomaybe ... but the question would then be - why it it's fine in 5.18.x, and not fine in 5.19.1 :-)15:55
sicelobut yes, let me see if can find how to 'detach' it from uImage15:55
uvossicelo: no idea just thinking of steps, clearly somehow it gets ruined on the way to ram15:56
uvosso some step in the process must be doing it15:56
freemangordonuvos: attaching it to uImage is simply doing cat, so can't be this15:56
uvosfreemangordon: ok15:57
uvosmaybe sicelo has a broken flash cell in a inauspicious place15:57
freemangordonI'd rather bet on u-boot allocating no enough RAM, or not reading the full uImage15:57
freemangordonor not reading the full attached DTB15:57
freemangordonPali: ^^^15:57
freemangordonany idea?15:57
uvossure maybe15:57
Paliu-boot should be able to load separate zImage and separate DTB without any issue15:59
uvosnot really a reason to ignore it breaking uimage15:59
freemangordonPali: yeah, the point is that it seems it somehow breaks the attached DTB16:00
freemangordoneither u-boot or kernel16:00
PaliYou can enable CONFIG_DEBUG_LL and kernel starts printing debug info prior reading attached dtb to serial console16:01
Paliserial console is available also in u-boot16:02
PaliIIRC it prints attached dtb address and size16:02
Paliso you can verify if the issue is in kernel code16:02
freemangordonsicelo: ^^^16:02
freemangordonthat should help16:02
freemangordonPali: is ther some size limit on DTB?16:02
sicelo the CONFIG_DEBUG_LL should be enabled in u-boot? or kernel?16:03
freemangordonu-boot16:03
PaliIn past there was a DTB limit. And n900 dtb file triggered that limit, so it was increased16:03
Paliin kernel16:03
freemangordonmaybe it triggered it again?16:03
Paliit is part of zImage wrapper16:03
freemangordondo you remember file was that limit in?16:04
Paliit was in zImage wrapper, so some in arch/arm/boot/16:05
freemangordonok, thanks16:05
PaliAlso enable CONFIG_DEBUG_OMAP3UART316:05
sicelounfortunately i don't have access to good/reliable serial. but let me first try with u-boot that has serial enabled, although i recall this just loses connectivity as soon as kernel starts16:07
Paliright, this would not work. kernel prints only to UART, not to usb16:08
Palibut you can test it in qemu16:08
Paliqemu has working UART nad kernel CONFIG_DEBUG_LL can print to it16:09
sicelo standard `qemu-system-arm`, or a special/n900 one?16:10
Palispecial n900 one16:10
Palilinaro's qemu-system-arm16:10
Palihttps://u-boot.readthedocs.io/en/latest/board/nokia/rx51.html#run-in-qemu16:11
sicelothanks very much16:14
siceloPali: u-boot should be able to load separate zImage and separate DTB without any issue <--- how would one know which memory address to use for the dtb blob?16:16
Paliyou can use any unused address16:17
Palifor example ${initrdaddr} if you are not going to use initrd16:17
Palie.g.: load mmc ${mmcnum}:${mmcpart} ${kernaddr} zImage && load mmc ${mmcnum}:${mmcpart} ${initrdaddr} dtb && bootz ${kernaddr} - ${initrdaddr}16:17
Paliit boots zImage (not uImage)16:20
sicelothank you. i'll give this a try. charging the device for now16:22
freemangordonuvos: could you please test the ^^^ patch, to see if it still crashes the device with 30mA limit16:33
uvosfreemangordon: yes16:33
uvosi will16:33
freemangordonok, thanks16:33
freemangordonthat'd confirm I am on the right track16:34
uvosi mean the implementation looks fine16:34
uvosi just dont know if its the right way to do it16:34
uvosso cant really comment on that16:35
freemangordonsure, but if it fixes the issue...16:35
freemangordonhmm...16:35
freemangordonmy a33 supports OTG16:36
freemangordonI can test there16:36
uvosfreemangordon: reducing the current in sysfs16:36
uvosalso fixes the issue atm16:36
uvosso i see no reason why the patch would not alos16:36
uvosbut i will test16:36
uvosthe device trying to pull 500mA just trippes the over current protection in xt1602 causing it to resett16:37
freemangordonsure, but there might be some transitions or who knows what that'd break it still16:41
freemangordontablet seems to provide 500 mA17:21

Generated by irclog2html.py 2.17.0 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!