{"action":"created","issue":{"url":"https://api.github.com/repos/networkimprov/arch-packages/issues/39","repository_url":"https://api.github.com/repos/networkimprov/arch-packages","labels_url":"https://api.github.com/repos/networkimprov/arch-packages/issues/39/labels{/name}","comments_url":"https://api.github.com/repos/networkimprov/arch-packages/issues/39/comments","events_url":"https://api.github.com/repos/networkimprov/arch-packages/issues/39/events","html_url":"https://github.com/networkimprov/arch-packages/issues/39","id":120576203,"number":39,"title":"battery charger driver","user":{"login":"networkimprov","id":458838,"avatar_url":"https://avatars.githubusercontent.com/u/458838?v=3","gravatar_id":"","url":"https://api.github.com/users/networkimprov","html_url":"https://github.com/networkimprov","followers_url":"https://api.github.com/users/networkimprov/followers","following_url":"https://api.github.com/users/networkimprov/following{/other_user}","gists_url":"https://api.github.com/users/networkimprov/gists{/gist_id}","starred_url":"https://api.github.com/users/networkimprov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/networkimprov/subscriptions","organizations_url":"https://api.github.com/users/networkimprov/orgs","repos_url":"https://api.github.com/users/networkimprov/repos","events_url":"https://api.github.com/users/networkimprov/events{/privacy}","received_events_url":"https://api.github.com/users/networkimprov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"mranostay","id":792377,"avatar_url":"https://avatars.githubusercontent.com/u/792377?v=3","gravatar_id":"","url":"https://api.github.com/users/mranostay","html_url":"https://github.com/mranostay","followers_url":"https://api.github.com/users/mranostay/followers","following_url":"https://api.github.com/users/mranostay/following{/other_user}","gists_url":"https://api.github.com/users/mranostay/gists{/gist_id}","starred_url":"https://api.github.com/users/mranostay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mranostay/subscriptions","organizations_url":"https://api.github.com/users/mranostay/orgs","repos_url":"https://api.github.com/users/mranostay/repos","events_url":"https://api.github.com/users/mranostay/events{/privacy}","received_events_url":"https://api.github.com/users/mranostay/received_events","type":"User","site_admin":false},"assignees":[{"login":"mranostay","id":792377,"avatar_url":"https://avatars.githubusercontent.com/u/792377?v=3","gravatar_id":"","url":"https://api.github.com/users/mranostay","html_url":"https://github.com/mranostay","followers_url":"https://api.github.com/users/mranostay/followers","following_url":"https://api.github.com/users/mranostay/following{/other_user}","gists_url":"https://api.github.com/users/mranostay/gists{/gist_id}","starred_url":"https://api.github.com/users/mranostay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mranostay/subscriptions","organizations_url":"https://api.github.com/users/mranostay/orgs","repos_url":"https://api.github.com/users/mranostay/repos","events_url":"https://api.github.com/users/mranostay/events{/privacy}","received_events_url":"https://api.github.com/users/mranostay/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/networkimprov/arch-packages/milestones/2","html_url":"https://github.com/networkimprov/arch-packages/milestones/DVT","labels_url":"https://api.github.com/repos/networkimprov/arch-packages/milestones/2/labels","id":1833113,"number":2,"title":"DVT","description":null,"creator":{"login":"networkimprov","id":458838,"avatar_url":"https://avatars.githubusercontent.com/u/458838?v=3","gravatar_id":"","url":"https://api.github.com/users/networkimprov","html_url":"https://github.com/networkimprov","followers_url":"https://api.github.com/users/networkimprov/followers","following_url":"https://api.github.com/users/networkimprov/following{/other_user}","gists_url":"https://api.github.com/users/networkimprov/gists{/gist_id}","starred_url":"https://api.github.com/users/networkimprov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/networkimprov/subscriptions","organizations_url":"https://api.github.com/users/networkimprov/orgs","repos_url":"https://api.github.com/users/networkimprov/repos","events_url":"https://api.github.com/users/networkimprov/events{/privacy}","received_events_url":"https://api.github.com/users/networkimprov/received_events","type":"User","site_admin":false},"open_issues":18,"closed_issues":3,"state":"open","created_at":"2016-06-16T20:06:08Z","updated_at":"2016-09-07T20:45:14Z","due_on":null,"closed_at":null},"comments":20,"created_at":"2015-12-05T17:56:23Z","updated_at":"2016-09-14T19:14:01Z","closed_at":null,"body":"Manual: http://www.ti.com/lit/ds/symlink/bq24190.pdf\r\nPMIC TRM: http://www.droid-developers.org/images/2/21/Tps65950_TRM.pdf\r\nSource: https://github.com/networkimprov/linux/blob/anvl-v4.7/drivers/power/bq24190_charger.c\r\nDiscussion of USB charging: https://lwn.net/Articles/694062/\r\nCharger Manager API: https://github.com/networkimprov/linux/blob/anvl-v4.7/include/linux/power/charger-manager.h\r\nSee also: https://github.com/networkimprov/usb-manager/issues/3\r\n\r\n1) Review commits to mainline source since it landed. Code was originally commissioned for anvl project. https://github.com/torvalds/linux/commits/master/drivers/power/bq24190_charger.c\r\n\r\n2) Check these variations of the driver for stuff we might need...\r\nbq2419x from android 3.10 Tegra kernel: https://android.googlesource.com/kernel/tegra/+/android-tegra-3.10/drivers/power/bq2419x-charger.c\r\npatches for it: https://github.com/CaptainThrowback/kernel_android-tegra-flounder-3.10/commits/BeyondStock-M/drivers/power/bq2419x-charger.c\r\nanother variation, pt 1: https://github.com/CaptainThrowback/kernel_android-tegra-flounder-3.10/blob/BeyondStock-M/drivers/power/bq2419x-charger-htc.c\r\npt 2: https://github.com/CaptainThrowback/kernel_android-tegra-flounder-3.10/blob/BeyondStock-M/drivers/power/htc_battery_bq2419x.c\r\ncharge-related patches in that repo: https://github.com/CaptainThrowback/kernel_android-tegra-flounder-3.10/commits/BeyondStock-M\r\n\r\n3) Attempt to enable charging after a disconnect on error. This can happen if the USB cable is not plugged into a hub in a straight angle and the USB hub port is loose enough to allow slight sideways movement.\r\n\r\n4) Handle OTG pin if its gpio is specified in the dts. See https://github.com/networkimprov/arch-packages/blob/master/archlinux-anvl/anvl-util/anvl-otg.sh\r\n\r\n5) power_supply_changed() uevents don't indicate what changed, so we can't write a udev rule that triggers only when vbus_stat changes. Possible fixes:\r\na) un/register bq24190-charger on vbus-up/down to issue add/remove uevents. Move the sysfs group to bq24190-battery. Enables this: http://unix.stackexchange.com/questions/63232/what-is-the-correct-way-to-write-a-udev-rule-to-stop-a-service-under-systemd\r\nb) un/register a virtual device on vbus-up/down to issue add/remove uevents. See http://stackoverflow.com/questions/5970595/create-a-device-node-in-code\r\nc) register a 3rd power_supply to call power_supply_changed on vbus up/down. See https://github.com/networkimprov/linux/commits/anvl-v4.7-hack_bq24190 (note: crashes on boot if usb connected)\r\nd) add user_stat field to let the user maintain a state value (e.g. previously reported vbus_stat value). This cannot be done with udev env{x} variables; see [1] below.\r\ne) implement sysfs_notify, so user apps can poll() /sys...charger/*\r\n\r\n6) uevent for disconnect often appears long after the plug is pulled. musb-hdrc sees it immediately. If we can't get a prompt event from the charger, we'll need one from usb subsystem.\r\n\r\n7) Issue bq24190-battery changed uevents only if f_reg or ss_reg change is relevant to battery.\r\n\r\n8) bq24190_charger_supplied_to gives \"main-battery\". Is there such an entity, if not should it be \"bq24190-battery\", and in either case would it actually receive charger events since no external_power_changed callback is implemented? https://www.kernel.org/doc/Documentation/power/power_supply_class.txt\r\n\r\n9) Clear bdi->ss_reg/f_reg in probe() and in resume() before interrupts enabled. Drop bdi->first_time. Drop reset() in suspend() and remove()? Drop power_supply_changed() in resume(). Move mutex_lock() in irq_handler after read().\r\n\r\n10) Do we get vbus_stat & chrg_stat msgs after hw_init() if USB connected before boot?\r\n\r\n11) What causes periodic 3-4s bursts of uevents when connected to usb charging port (usb phy modules blacklisted, no gadget config)?\r\n\r\n12) Verify that charger draws 1.5A from charging port given suitable cable.\r\n\r\n13) Is bq24190_irq_handler_thread(...) interruptible?\r\n\r\n14) For USB host mode, we need to add regulator framework support to the charger driver so the USB PHY driver can just request the regulator for 5V VBUS as needed.\r\n\r\n[1] These rules give multiple on and zero off results because env{vbus} gets erased\r\n```KERNEL==\"bq24190-charger\", ATTR{f_vbus_stat}!=\"0\", ENV{VBUS}!=\"1\", ENV{VBUS}=\"1\", RUN+=\"/bin/bash -c 'echo vbus_on > /dev/console'\"```\r\n```KERNEL==\"bq24190-charger\", ATTR{f_vbus_stat}==\"0\", ENV{VBUS}==\"1\", ENV{VBUS}=\"0\", RUN+=\"/bin/bash -c 'echo vbus_off > /dev/console'\"```\r\n"},"comment":{"url":"https://api.github.com/repos/networkimprov/arch-packages/issues/comments/247122928","html_url":"https://github.com/networkimprov/arch-packages/issues/39#issuecomment-247122928","issue_url":"https://api.github.com/repos/networkimprov/arch-packages/issues/39","id":247122928,"user":{"login":"networkimprov","id":458838,"avatar_url":"https://avatars.githubusercontent.com/u/458838?v=3","gravatar_id":"","url":"https://api.github.com/users/networkimprov","html_url":"https://github.com/networkimprov","followers_url":"https://api.github.com/users/networkimprov/followers","following_url":"https://api.github.com/users/networkimprov/following{/other_user}","gists_url":"https://api.github.com/users/networkimprov/gists{/gist_id}","starred_url":"https://api.github.com/users/networkimprov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/networkimprov/subscriptions","organizations_url":"https://api.github.com/users/networkimprov/orgs","repos_url":"https://api.github.com/users/networkimprov/repos","events_url":"https://api.github.com/users/networkimprov/events{/privacy}","received_events_url":"https://api.github.com/users/networkimprov/received_events","type":"User","site_admin":false},"created_at":"2016-09-14T19:14:01Z","updated_at":"2016-09-14T19:14:01Z","body":"That is a temporary condition while VBUS is rising after connect. Didja try patch?\r\n\r\nRe commit comments...\r\n\r\n>So want a uevent happening at every interrupt?\r\n\r\nIt's always been this way; I plan to get more selective.\r\n\r\n>This is going to cause double uevents with the fuel gauge driver I suspect\r\n\r\nPossibly but we can ignore them.\r\n\r\n>No issue with the zero'ing of everything here but devm_kzalloc() already did it\r\n>Do these ever get referenced without a bq24190_read() beforehand? So zeroing I don't think matters\r\n\r\nYes, they were ref'd before set in first call of irq_handle_thread()\r\n\r\n>You need to move the mutex_lock as well\r\n\r\nConsidered that; it's never used to protect reads elsewhere.\r\n"}}
{"actor":{"display_login":"networkimprov"}}