uvos__ has quit [Ping timeout: 260 seconds]
sunshavi_ has joined #maemo-leste
xes_ has quit [Ping timeout: 260 seconds]
xes_ has joined #maemo-leste
elastic_dog has quit [Ping timeout: 252 seconds]
elastic_dog has joined #maemo-leste
joerg is now known as Guest7841
Guest7841 has quit [Killed (tantalum.libera.chat (Nickname regained by services))]
joerg has joined #maemo-leste
mardy has joined #maemo-leste
ceene has joined #maemo-leste
xmn has quit [Ping timeout: 248 seconds]
<freemangordon> uvos: well, it seems that batd always starts with 1800 mA when a charger is detected
<freemangordon> this is logcat for a Nokia wall charger (AC 10E) https://pastebin.com/9wRX7kfH
alex1216 has joined #maemo-leste
alex1216 has quit [Quit: WeeChat 2.3]
alex1216 has joined #maemo-leste
Twig has joined #maemo-leste
sixwheeledbeast has quit [*.net *.split]
elle has quit [*.net *.split]
Blikje has quit [*.net *.split]
asriel has quit [*.net *.split]
sfa has quit [*.net *.split]
jrayhawk has quit [*.net *.split]
dos has quit [*.net *.split]
sfa has joined #maemo-leste
sixwheeledbeast has joined #maemo-leste
elle has joined #maemo-leste
dos has joined #maemo-leste
asriel has joined #maemo-leste
Blikje has joined #maemo-leste
uvos has joined #maemo-leste
akossh has joined #maemo-leste
Twig has quit [Remote host closed the connection]
Twig has joined #maemo-leste
<uvos> freemangordon: thats correct a "dumb" charger (ie data pins tied) is assumed to be able to handle at least 2A this isent a spec but was common practice when the d4 was designed. this we can implement fairly easy
<uvos> the greater problem from a safty perspective is that on a smart port
<uvos> d4 dosent negotiate for power, either via usb2.0 spec to get 500mA or using one of the qc specs for more
<uvos> (In leste here, the d4 negotiates for power in android via 2.0 spec)
<uvos> atm for instance pluging in a d4 into my xt1602 make it resett it because it can only output 30mA
<uvos> could cause damage alos
meridion has quit [Ping timeout: 246 seconds]
meridion has joined #maemo-leste
<Wizzup> uvos: this week or weekend I'll have time for droid 3 tests, do you have a refresher on what you needed me to do?
<Wizzup> rather what to dump/analyse
uvos has quit [Ping timeout: 252 seconds]
akossh has quit [Read error: Connection reset by peer]
mardy has quit [Read error: Connection reset by peer]
mardy has joined #maemo-leste
akossh has joined #maemo-leste
rafael2k has joined #maemo-leste
<Wizzup> btw: got a mail from a happy d4 user
<Wizzup> something about the modem in the US, but also:
<Wizzup> So i have a week testing the Motorola Moserati and Mameo Leste then i really like how so good feeling. Thank you for the work!
uvos__ has joined #maemo-leste
<uvos__> Wizzup: so we need: full cpcap dumps, while loaded and while idle
<uvos__> we need a dump of the emif registers (see omap4 trm)
<uvos__> also loaded and idle
<uvos__> we need dumps of the led cpcap registers at different keyboard and display brightnesses
<uvos__> we require a dump of the lm i forget the number led controller too but that might be hard to pull off on android
<uvos__> that should be a start
<uvos__> nice @ user
<uvos__> probubly a d3 would be good for him, being in us
<uvos__> or bionic
<Wizzup> I did mention the bionic
<Wizzup> check @ data
<freemangordon> uvos__: detecting usb/charger should be easy
<freemangordon> detecting the type of USB I am not sure
<uvos__> right unfortinatly dumb chargers are getting a bit rare, usally you get qc implementing smat ports these days
<uvos__> *smart
<uvos__> but detecting tied usb data pins is a start
<uvos__> no doubt
<freemangordon> are you sure d4 ever draws more than 500mA from USB port?
<uvos__> you cant draw 500mA from a usb port is the problem
<uvos__> you have to ask the port
<uvos__> 500mA is just the max you could ask for in usb2.0
<freemangordon> I see
<freemangordon> does d4 android fullows that?
<uvos__> yes
<freemangordon> ok
<freemangordon> still, I will start with dumb/fast charger detection
<uvos__> also no android dosent implement usb qc
<uvos__> that wasent around at the time
<uvos__> it could tho
<freemangordon> do you know how wall charger (d+d- short) can be distinguished from 2.4 A charger?
<uvos__> but this is soemthing for later
<freemangordon> like, is there some difference in resistance, or ID pi or something?
<uvos__> not sure what you mean, the dumb chargers cant be identified
<uvos__> you just have to assume something
<uvos__> this was a huge issue
<uvos__> and is the reason why usb qc exists
<uvos__> its usualy safe to assume 2a
<uvos__> this seams to have been most common practivce
<uvos__> *practice
<freemangordon> I am not sure 2.4A charger I have here is a dumb one
<uvos__> it might implement usb qc
<uvos__> of some kind
<freemangordon> because it has 2 outputs, one marker as "1A", which is wallcharger for sure
<uvos__> this allows you to negotate up to 65W or so
<freemangordon> *marked
<freemangordon> isn;t that USB C?
<uvos__> no thats usb pd
<freemangordon> BC1.2?
<uvos__> yes 65w might be over usb c only not sure
<uvos__> anyhow you can negotiate more than 500mA after usb2.0
<uvos__> 3.0 base spec supports 1a allready i think and then theres more extensions
<uvos__> it gets pretty complicated ;)
<freemangordon> something with d lines resistance?
<uvos__> no, same protocoll as used in 2.0 to negotiate for 500mA
<uvos__> at least for 3.0 base
<uvos__> idk how the more advance stuff works
<uvos__> where you can ask for different voltages too etc
<freemangordon> ah, this is something that is out of control of SW, I guess
<uvos__> no idea
<uvos__> i pretty much checked out after usb 3.0
<uvos__> :P
<uvos__> usb spec: USB devices shall limit the power they consume from VBUS to one unit load or less until configured.
<uvos__> thats 100uA
<freemangordon> right
<freemangordon> but, this is what musb shall already do, no?
<sicelo> uvos__: freemangordon: you call the chargers dumb? anyway "the dumb chargers cant be identified" ... can't be exactly correct. in some cases at least, the identification of the 'dumb charger' as you call it happens in the pmic. there's no assumption. it knows when the d-pins are shorted
<freemangordon> sicelo: I call it "wall charger" :)
<freemangordon> and yes, we can detect d lines shortened
<sicelo> i'd call it that too :-)
<uvos__> sicelo: dumb charges cant be idenfied in terms of capapbiliy
<uvos__> there are 1A devices with pins shorted and 3A
<freemangordon> right
<freemangordon> I think originally it was 1A
<sicelo> okay. that's a different statement now
<freemangordon> I wonder how android managed to correctly identify 1200 mA
<freemangordon> this is what nokia charger is capable of
<freemangordon> still I am not sure that cpcap-charger is responsible for any USB negotiation
<freemangordon> IIUC it shall ask usb driver for remote port parameters and adhere to it, no?
<uvos__> no
<uvos__> the slave supplies the host with a series of configurations
<uvos__> and the host chooses one
<freemangordon> ok
<freemangordon> but this is not that charger driver job to do it
Twig has quit [Remote host closed the connection]
<freemangordon> but usb driver
<uvos__> sure but they must communicate somehow obv
<freemangordon> right
<freemangordon> lemme see what gets negotiated here
<freemangordon> but usb driver
<freemangordon> *by
<sicelo> freemangordon: just wild guess ... i see 11-10 09:26:00.633 177 177 I BATTD : set_charge_current=1300
<sicelo> 11-10 09:26:01.642 177 177 I BATTD : set_charge_current=1200
<uvos__> so on some usb chips
<uvos__> just takling form expieriance working embedded stuff
<sicelo> so maybe it just adjusts what it can pull vs what it can get ... and thus ends up at 1200
<uvos__> the usb chip dose everything in hw/fw
<uvos__> wrt negotation with host
<uvos__> dont know how typical this is on smartphones
<sicelo> at least on N900 it is
<sicelo> the negotiation is done by the phy (isp1707)
<freemangordon> sicelo: ok, but how does it know that it can't draw 1800?
<sicelo> does it ever do 1800 (assuming an 1800-capable charger)?
<freemangordon> I guess yes
<uvos__> eh 1800 is aufully close to 1c
<uvos__> the reccomended speed to charge a lipo....
<uvos__> since the d4 has 1750mah batt 1800 is esentally 1c
<freemangordon> uvos__: this is the current drawn from the charger, not charging current ;)
<uvos__> right
<uvos__> still they may have done this to ensure charging speed never exceeds 1c
<uvos__> possibly
Twig has joined #maemo-leste
<sicelo> freemangordon: so yes, as you stated, it starts by attempting to pull 1800. evidently it notices this fails, then switches to 1300, etc. until it lands on the highest that it can really pull
<freemangordon> no
<freemangordon> I doubt it can load to 1800mA by will
<uvos__> on dumb chargers i dont
<uvos__> phones breaking weak dumb chargers was common and the reason for better specs with usb 3+
<uvos__> it might really be just monitoring votlage drop
<uvos__> if a dumb charger is detected
<uvos__> on a smart port however, yes, no it negotiates
<freemangordon> voltage drop?
<uvos__> if vbus drops below a threshold cpcap generates an irq
<freemangordon> hmm, hmm
<freemangordon> but still, we need to load
<freemangordon> or, it sets to max, if irq comes , it reduces max current, etc
<freemangordon> do you think it wokrs like that?
<uvos__> i hope it goes the other way
<uvos__> but yes this might be what it dose on a dumb charger
<freemangordon> not really, by looking at batd code and logcat
<uvos__> ok
<freemangordon> it seems to always set ititial max to 1800
<freemangordon> *initial
<uvos__> are you using a motorola charger btw
<uvos__> or a random one
<uvos__> its possible motorola did soemthing totaly cusom on stock chargers
<uvos__> samsung for sure did
<uvos__> (some codeing with voltage deviders on data pins)
<uvos__> but this was not wide spread
<freemangordon> samsung/iqos/nokia/cellularline/asus battery pack :)
<uvos__> ok what vintage are we talking here?
<sicelo> tbh it's interesting for this one to start with 1800 and work its way down. N900/bq24150 starts with 100mA, then 500, and finally 1800
<freemangordon> sicelo: it starts with 1800 when it detects wall charger
<freemangordon> uvos__: what do you mean "vintage". only Nokia one is really old
<freemangordon> I am testing with different ones to see how it works
<uvos__> ie before usb 3.0 and qc specs
<uvos__> ie is just a dumb charger with pins tied
<freemangordon> I bet most of the charger I have here are qc ones
<freemangordon> *chargers
<freemangordon> for sure cellularline and battery pack are
<uvos__> ok
<freemangordon> not that they are detected by d4 though
<freemangordon> they are treated like wall chargers if you ask me
<uvos__> not sure how it knows to do that
<freemangordon> cpcap does it
<freemangordon> there are several interrupts
<uvos__> sure but how it knows that a qc port is not a normal usb port
<uvos__> ie is to be handled like a dumb charger
<freemangordon> ah
<freemangordon> well, seems some kind of handshake happens
<uvos__> hmm have to look at specs
<freemangordon> look at MC13783UG.pdf
<freemangordon> chapter 8
<uvos__> ok
<freemangordon> uvos__: seems 200k on ID pin means "Type 1 charger" and 442k "Type 2 Charger"
<uvos__> non universal extension
<uvos__> since you dont even have the id pin
<uvos__> on most chargers
xes_ has quit [Quit: WeeChat 3.5]
<freemangordon> the point is that ID pin can be used to detect carkit accessories
<uvos__> sure
<freemangordon> and there are 2 types of carckit chargers it seems
<freemangordon> *carkit
<uvos__> also lapdock is special probubly
<uvos__> but most chargers have just a usba so the id pin dosent help there
<freemangordon> hmm, right
<freemangordon> ok, so, lets assume d4 cannot detect anything but wall charger and move on
<uvos__> well and usb 2.0 power
<freemangordon> right
<freemangordon> though, I wonder where is that data available (max port current)
<uvos__> the usb driver must send a (or list) of configureattions supported
<uvos__> this incl power draw
<uvos__> and if the host reqjects the configureation the device dosent charge, this works ok if i connect d4 to xt1602 while running
<freemangordon> yeah, maybe, I just have to find where it sends that data
<uvos__> while running android
<freemangordon> ok
<freemangordon> but still, max port current should be available somewhere
<uvos__> sure you can query for it too
<uvos__> i dosent seam like android dose this tho
<freemangordon> where?
<uvos__> from the host i mean
<uvos__> android dosent seam to obay anything but the host rejecting the configuration tho
<freemangordon> ah
<uvos__> since it just dosent charge
<uvos__> instead of taking less
<uvos__> then again maybe 30mA is just to little for it to bother with
<uvos__> it might when offered 100mA
<freemangordon> ok, but I wonder how cpcap-charger can get that info
<uvos__> no idea
<uvos__> maybe its just cpcap-uc's doing
<uvos__> i would make some sense to put this safty critical feature (dont charge if host rejects) into fw
<freemangordon> I doubt we cannot get USB port max current draw
<uvos__> sure but maybe the motorola driver dosent
<uvos__> (idk just speculateing)
<uvos__> if you cant find it
<freemangordon> well, I don't know where it is supposed to be, to start with :)
<freemangordon> tmlind: ping
<freemangordon> hmm, I think configurations are done via gadgetfs
<freemangordon> right now we ahve only one configuration with maxPower of 2mA, IIUC
<freemangordon> uvos__: so, in order to do what android does, I think we shall set CONFIG_USB_GADGET_VBUS_DRAW=500
<freemangordon> that way your XT_whatever will reject the configuration
<freemangordon> at least you can try it
<freemangordon> but I am almost sure this will fix we breaking the specs
<uvos__> how would cpcap-charger (mainline) here know to not acctivate charging when the configuration is rejected
<freemangordon> I think if configuration is rejected, there will be no USB interrupt
<uvos__> the device has to avoid taking current when rejected the host dosent turn off power or anything like that
<uvos__> freemangordon: ok
<freemangordon> still, wild guess, but we can at least try
<freemangordon> hmm, lemme check what is the max port current of the hubs I have around
<uvos__> aside from otg ports and some laptops
<uvos__> i think <500mA ports are pretty rare
<uvos__> you could use another mapphone as the host
<uvos__> its also dose 30mA max i think
<uvos__> or something like that
<freemangordon> well, 4 ports non-powered hub should not report 500 mA/port, no?
<uvos__> it can
<freemangordon> I know
<uvos__> if just one slave is connected
<freemangordon> but it should not
<uvos__> ok
<freemangordon> I am checking what my reports
<freemangordon> MaxPower 100mA
<freemangordon> :)
<freemangordon> also, I am sure I hade some tool around that I was able to switch individual ports o/off
<uvos__> some fancy hubs can do that
<uvos__> yeah
<freemangordon> ID 05e3:0608 Genesys Logic, Inc. Hub
<uvos__> no idea :P
<freemangordon> a couple of years ago I was playing with it
<freemangordon> just have to remember what I did back then
<freemangordon> IIRC I was also able to control max power
<freemangordon> uhubctrl ;)
xes has joined #maemo-leste
jrayhawk has joined #maemo-leste
jrayhawk has quit [Ping timeout: 260 seconds]
jrayhawk has joined #maemo-leste
elle has quit [Ping timeout: 260 seconds]
elle has joined #maemo-leste
xmn has joined #maemo-leste
<freemangordon> uvos__: ok, so far I was able to find this: https://elixir.bootlin.com/linux/v5.18.19/source/drivers/usb/musb/musb_gadget.c#L1624
<freemangordon> printk() there shows that it is called, with correct mA
<freemangordon> ant it turn it calls usb_phy_set_power()
<freemangordon> *and
rafael2k has quit [Ping timeout: 255 seconds]
<sicelo> freemangordon: while there, how would one use printk (or some other facility) to see if *gadget contains correct parameters (using that function as an example)
<freemangordon> not sure I understand the question
<freemangordon> printk is like printf, more or less
alex1216 has quit [Quit: WeeChat 2.3]
<sicelo> i guess in that function, you can see the mA is correct because it's passed as an int already. how would you inspect *gadget, since that's a struct?
<freemangordon> just dereference the structure
<freemangordon> gadget->struct_member
<freemangordon> for example:
<freemangordon> printk("%s %s\n", __FUNCTION__, gadget->name);
<sicelo> alright. thanks. i guess i was doing it correctly then ... but i suppose i must spend more time with the struct
<sicelo> basically i wanted to see what *dev really contains in https://elixir.bootlin.com/linux/v5.18.19/source/drivers/base/platform.c#L435
<freemangordon> if you expect things like js "console.log(JSON.stringify(object))"
<freemangordon> there is no such thing :)
<freemangordon> you must print meber by member
<freemangordon> *member
<uvos__> THIS IS C
<freemangordon> mhm
<uvos__> :P
<uvos__> you could run a debugger on the kernel and have gdb print the struct
<uvos__> but not on d4
<sicelo> freemangordon: because the error is "[ 1.389648] musb-hdrc musb-hdrc.0.auto: error -ENXIO: IRQ mc not found" ... it's that function which should find this 'mc' IRQ
<uvos__> dose the n900 debug kit have jtag?
<uvos__> btw
<uvos__> just curious
<freemangordon> sicelo: something is missing in the DTS
<sicelo> if i hardcore the IRQ from DTS in musb/musb_core.c, it works, so i think this is what i should follow until i find out why the function can't get it correctly
<sicelo> freemangordon: the mc interrupt is there in dts, and it's correct.
<freemangordon> could it be that DTB is too big?
<freemangordon> I remember there were some issues with attached DTBs
<freemangordon> also, do you see that irq in /sys/firmware where it is expected?
<freemangordon> ok, but do you see the same on the device
<freemangordon> in /sys/firmware/...
<sicelo> sys firmware? mmm, i can check.
<freemangordon> yes, you have DTB there visible on a booted system
<freemangordon> also, if you decompile the DTB, doo you see that interrupt there?
<sicelo> at least with decompiled dtb, it's there
<sicelo> interrupts = <0x5c 0x5d>;
<sicelo> interrupt-names = "mc\0dma";
<freemangordon> check on the device
<freemangordon> could be broken attached DTB
ceene has quit [Remote host closed the connection]
<buZz> sicelo: mc\0dma might be wrong?
<buZz> shouldnt it be just 'mc'
<freemangordon> uvos__: ugh, this is what is bugging us, for start https://elixir.bootlin.com/linux/v5.18.19/source/drivers/usb/musb/musb_gadget.c#L1628
<freemangordon> buZz: there are 2 interrupts, see dts
<buZz> oh, right, but \0 as seperator?
<freemangordon> yep, that
<freemangordon> 's fine
<buZz> i see stuff like ; interrupt-names = "rx", "tx";
<uvos__> freemangordon: and who shal support that? omap phy?
<freemangordon> uvos__: the point is that this function must not check for set_power()
<freemangordon> the check is there, but after usb_phy_set_charger_current() is called
<freemangordon> usb_phy_set_charger_current() calls notifiers
<freemangordon> (in theory)
<freemangordon> I registered in cpcap_charger, but callback is not called, besides for VBUS
<buZz> we cant set the constant charging voltage above 4.2v yet, can we?
<freemangordon> yes, we can
<buZz> i only succeeded in setting it below, not above
<buZz> without kernel mods?
<freemangordon> yes
<freemangordon> but you have to set ti in /usb, not in /battery
<freemangordon> some bug I guess
<buZz> :O what am i doing wrong then, shouldnt it be > 1651429464 <uvos> echo 4300000 > constant_charge_voltage
<buZz> well, if i set it above 4200000 it doesnt stick , but 4100000 works
* buZz tries again :P
<sicelo> " but you have to set ti in /usb, not in /battery" .. isn't it correct? /usb is the charger
<buZz> its not taking
<freemangordon> no idea then, maybe there is some hard limit to be fixed
<buZz> yeah i guess, should i check my diff for my 'explosive droid4' kernel? :P
<uvos__> yes it being in usb makes perfect sense
<uvos__> that is the charger
<uvos__> it should work, it worked on my device before
<uvos__> its possible you also have to ajust something in battery
<buZz> does it currently on the latest -devel ?
<uvos__> cant check rn
<buZz> ah ok
<uvos__> i dont have a battery it would detect as 4.35
<buZz> AHA!
<buZz> i need to do '4300000' > /sys/class/power_supply/battery/constant_charge_voltage -first-
<uvos__> right
<uvos__> thats expected
<buZz> -then- '4300000' > /sys/class/power_supply/usb/constant_charge_voltage works :D
<uvos__> the charger and the battery have to agnolage
<uvos__> er acknowledge
<uvos__> atho maybe we should make that sync automaticly
<buZz> hmmm, it doesnt take '4349000' as my battery reports, limits to 4330000 in /usb
<buZz> but, i guess fine for now
<uvos__> not sure how the kernel interfaces expect this to happen
<freemangordon> there is code to do that, but it seems to be broken
* buZz charges
<uvos__> buZz: cpcap has limited register resolution
<uvos__> id have to check if its that
<uvos__> or if there is a < check where there should be <=
<buZz> ah, possibly yeah
<sicelo> freemangordon: in /sys/firmware, the interrupt numbers are not there. but interrupt names is there.
<freemangordon> not good
<freemangordon> how big is DTB?
<freemangordon> you may try to enable thumb2 kernel, to see if reduced size is going to help
<sicelo> it's thumb2
<freemangordon> hmm
<freemangordon> well
<freemangordon> move something out of the kernel, into a module
<freemangordon> or, change the compression
<freemangordon> can't think of anything better
<uvos__> if we are significantly space limited on n900 we might have to start building a special kernel for it again
<sicelo> dtb is 78632 bytes
<uvos__> since rn theres lots of stuff built in we really only need on mapphones/omap4
<freemangordon> ugh
<sicelo> i'm quite sure the dtb didn't change size
<freemangordon> how big is kernel+dtb?
<sicelo> 5517960 Nov 5 00:04 zImage
<freemangordon> ugh
<freemangordon> why so big?
<freemangordon> move some stuff to modules
<uvos__> really why so big
<uvos__> current kernel on my d4 is 4982776
<uvos__> why is it 500kb bigger
<freemangordon> mhm
freemangordon has quit [Quit: Leaving.]
<sicelo> majority of stuff is in modules actually
freemangordon has joined #maemo-leste
<freemangordon> gnome crashed :(
<freemangordon> uvos__: so, after the fix, I see usb_phy_set_charger_current() called, but usb_phy->chg_type is UNKNOWN_TYPE, as expected
<freemangordon> TBH, I have no idea which exactly phy it is about, maybe I shall trace it
uvos__ has quit [Ping timeout: 252 seconds]
<freemangordon> also, I am not sure where shall charger detection be implemented
<freemangordon> it seems extcon driver is the correct option
<freemangordon> but, I think we need tmlind here to help
uvos__ has joined #maemo-leste
uvos has joined #maemo-leste
Danct12 has quit [Quit: Quitting]
<sicelo> for completeness, here's the kernel config (extracted from /proc/config.gz)
Twig has quit [Ping timeout: 252 seconds]
Twig has joined #maemo-leste
Twig has quit [Max SendQ exceeded]
Twig has joined #maemo-leste
mardy has quit [Quit: WeeChat 3.5]
mogolobogo[m] has joined #maemo-leste
<sicelo> freemangordon: uvos: https://paste.debian.net/1260284/ ... this makes it all work just fine
<sicelo> of course it's a super ugly hack
Twig has quit [Ping timeout: 260 seconds]
<sicelo> < freemangordon> I remember there were some issues with attached DTBs ... <-- would you remember the source of this info? i would like to investigate further
akossh has quit [Ping timeout: 246 seconds]
Langoor has quit [Ping timeout: 248 seconds]
nohit has quit [Read error: Software caused connection abort]
nohit has joined #maemo-leste
uvos has quit [Ping timeout: 268 seconds]