Re: [PATCH v3] power_supply: Add driver for TWL4030/TPS65950 BCI charger
Hi, please re-send this email without the HTML formatting. Please follow the netiquette [1]. [1] http://elinux.org/Netiquette -- balbi -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] power_supply: Add driver for TWL4030/TPS65950 BCI charger
hello, On Mon, Sep 27, 2010 at 9:18 AM, Felipe Balbi ba...@ti.com wrote: On Sun, Sep 26, 2010 at 02:35:40PM -0500, Grazvydas Ignotas wrote: TWL4030/TPS65950 is a multi-function device with integrated charger, which allows charging from AC or USB. This driver enables the charger and provides several monitoring functions. Tested on OMAP3 Pandora board. Signed-off-by: Grazvydas Ignotas nota...@gmail.com --- This is v3 of BCI charger driver I first sent nearly a year ago [1]. I've updated it to use the new OTG notifiers for VBUS notifications, however it still is not able to determine charge current to use. For that reason there is now a temporary module param to enable USB charging, until I can figure out how to get that info from the gadget stack (hopefully Felipe can help me here). You need to send USB_EVENT_ENUMERATED from usb_gadget_vbus_draw(), but wait until the UDC class is finished, then we will have a common location to do those stuff. ok, I hope I can get CCed or notified in some way as I might miss that. snip + + ret = request_threaded_irq(bci-irq_bci, NULL, + twl4030_bci_interrupt, 0, pdev-name, bci); + if (ret 0) { + dev_err(pdev-dev, could not request irq %d, status %d\n, + bci-irq_bci, ret); + goto fail_bci_irq; + } you should register the power_supply before enabling the IRQ lines, otherwise you might call power_supply_changed() to a non-existent power_supply. good catch, will do. snip + +#ifdef CONFIG_USB_OTG_UTILS + bci-transceiver = otg_get_transceiver(); +#endif this driver should actually depend on that. It won't work without access to the transceiver anyway. Well it can still do AC charging fine without OTG stuff. Or you add something like: #ifdef CONFIG_USB_OTG_UTILS extern struct otg_transceiver *otg_get_transceiver(void); extern void otg_put_transceiver(struct otg_transceiver *); #else static inline struct otg_transceiver *otg_get_transceiver(void) { return NULL; } static inline void otg_put_transceiver(struct otg_transceiver *x) { } #endif I much prefer that, will send a patch. to the otg.h and avoid having to use that ifdef here and on any other driver. (should be a separate patch though). +static struct platform_driver twl4030_bci_driver = { + .probe = twl4030_bci_probe, drivers should not reference __init sections anymore. If you make this statically linked to the kernel, you'll get section mismatches. It's better to make probe __init remove it from here and call platform_driver_probe() from module_init(); Tried that and did not get any section mismatches, but will switch anyway to better match trends. + .remove = __devexit_p(twl4030_bci_remove), + .driver = { + .name = twl4030_bci, + .owner = THIS_MODULE, + }, +}; -- balbi -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] power_supply: Add driver for TWL4030/TPS65950 BCI charger
On Mon, Sep 27, 2010 at 10:21 AM, Arun Murthy arunrmurthy...@gmail.com wrote: On Mon, Sep 27, 2010 at 1:05 AM, Grazvydas Ignotas nota...@gmail.com wrote: --- This is v3 of BCI charger driver I first sent nearly a year ago [1]. I've updated it to use the new OTG notifiers for VBUS notifications, however it still is not able to determine charge current to use. For that reason there is now a temporary module param to enable USB charging, until I can figure out how to get that info from the gadget stack (hopefully Felipe can help me here). On detecting USB plug, the driver is suppose to detect the type of usb device. Then if the device is a PC(standard host) the charging current is to be obtained from the usb stack. Hence the driver will have to wait until the usb stack or driver notifies the current that can be drawn. The usb stack or driver gets to know the amount of current to be drawn through the negotiations that happen between the host and device. I'm aware of that, the question was how to get that from Linux USB stack (which Felipe already responded). snip Only AC and USB monitoring is achieved by registering with power supply class. How is battery monitored? An instance of battery is to be registered with power supply class in order to monitor battery. The problem is that BCI is only active while charging, when it is not charging most (all?) monitoring registers freeze and no monitoring happens (BCI registers read frozen values from last charge). So I don't register battery as it has no useful data to report. I heard it is possible to use MADC to perform monitoring while not charging, so battery can be added when MADC driver is merged and corresponding code is written for this driver. + +static struct platform_driver twl4030_bci_driver = { + .probe = twl4030_bci_probe, + .remove = __devexit_p(twl4030_bci_remove), + .driver = { + .name = twl4030_bci, + .owner = THIS_MODULE, + }, +}; dev_pm_ops can be use nothing to do there right now, the driver relies on FSM change interrupts from BCI to update state. -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] power_supply: Add driver for TWL4030/TPS65950 BCI charger
On Mon, Sep 27, 2010 at 1:05 AM, Grazvydas Ignotas nota...@gmail.com wrote: TWL4030/TPS65950 is a multi-function device with integrated charger, which allows charging from AC or USB. This driver enables the charger and provides several monitoring functions. Tested on OMAP3 Pandora board. Signed-off-by: Grazvydas Ignotas nota...@gmail.com --- This is v3 of BCI charger driver I first sent nearly a year ago [1]. I've updated it to use the new OTG notifiers for VBUS notifications, however it still is not able to determine charge current to use. For that reason there is now a temporary module param to enable USB charging, until I can figure out how to get that info from the gadget stack (hopefully Felipe can help me here). On detecting USB plug, the driver is suppose to detect the type of usb device. Then if the device is a PC(standard host) the charging current is to be obtained from the usb stack. Hence the driver will have to wait until the usb stack or driver notifies the current that can be drawn. The usb stack or driver gets to know the amount of current to be drawn through the negotiations that happen between the host and device. + + platform_set_drvdata(pdev, bci); + + bci-ac.name = twl4030_ac; + bci-ac.type = POWER_SUPPLY_TYPE_MAINS; + bci-ac.properties = twl4030_charger_props; + bci-ac.num_properties = ARRAY_SIZE(twl4030_charger_props); + bci-ac.get_property = twl4030_bci_get_property; + + ret = power_supply_register(pdev-dev, bci-ac); + if (ret) { + dev_err(pdev-dev, failed to register ac: %d\n, ret); + goto fail_register_ac; + } + + bci-usb.name = twl4030_usb; + bci-usb.type = POWER_SUPPLY_TYPE_USB; + bci-usb.properties = twl4030_charger_props; + bci-usb.num_properties = ARRAY_SIZE(twl4030_charger_props); + bci-usb.get_property = twl4030_bci_get_property; + + ret = power_supply_register(pdev-dev, bci-usb); + if (ret) { + dev_err(pdev-dev, failed to register usb: %d\n, ret); + goto fail_register_usb; + } Only AC and USB monitoring is achieved by registering with power supply class. How is battery monitored? An instance of battery is to be registered with power supply class in order to monitor battery. Thanks and Regards, Arun R Murthy - -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] power_supply: Add driver for TWL4030/TPS65950 BCI charger
On Mon, Sep 27, 2010 at 4:24 PM, Grazvydas Ignotas nota...@gmail.com wrote: On Mon, Sep 27, 2010 at 10:21 AM, Arun Murthy arunrmurthy...@gmail.com wrote: On Mon, Sep 27, 2010 at 1:05 AM, Grazvydas Ignotas nota...@gmail.com wrote: --- Only AC and USB monitoring is achieved by registering with power supply class. How is battery monitored? An instance of battery is to be registered with power supply class in order to monitor battery. The problem is that BCI is only active while charging, when it is not charging most (all?) monitoring registers freeze and no monitoring happens (BCI registers read frozen values from last charge). So I don't register battery as it has no useful data to report. I heard it is possible to use MADC to perform monitoring while not charging, so battery can be added when MADC driver is merged and corresponding code is written for this driver. How do I check the battery voltage? I need to check the battery voltage/current/temp and, if I am not wrong these are obtained from MADC. MADC driver has to be added first and then the battery. With being able to read the basic parameter battery voltage, this driver becomes incomplete. How do I get notified if battery voltage is low and needs charging from user space? Thanks and Regards, Arun R Murthy - -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] power_supply: Add driver for TWL4030/TPS65950 BCI charger
On Mon, Sep 27, 2010 at 3:35 PM, Arun Murthy arunrmurthy...@gmail.com wrote: On Mon, Sep 27, 2010 at 4:24 PM, Grazvydas Ignotas nota...@gmail.com wrote: On Mon, Sep 27, 2010 at 10:21 AM, Arun Murthy arunrmurthy...@gmail.com wrote: The problem is that BCI is only active while charging, when it is not charging most (all?) monitoring registers freeze and no monitoring happens (BCI registers read frozen values from last charge). So I don't register battery as it has no useful data to report. I heard it is possible to use MADC to perform monitoring while not charging, so battery can be added when MADC driver is merged and corresponding code is written for this driver. How do I check the battery voltage? I need to check the battery voltage/current/temp and, if I am not wrong these are obtained from MADC. MADC driver has to be added first and then the battery. With being able to read the basic parameter battery voltage, this driver becomes incomplete. Incomplete driver is better than no driver, don't you think? There are some boards like pandora or oswald that have additional battery monitoring chips (as twl monitoring is pretty crude anyway), those boards would have fully functional charging now. Currently mainline kernel is not very useful with them simply because the battery runs flat. How do I get notified if battery voltage is low and needs charging from user space? Either additional monitoring chip notifies you (if you are lucky and have one), or wait for update of this driver :) There are efforts to merge MADC driver [1], but it may take some time. [1] http://marc.info/?t=12846153572r=1w=2 -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] power_supply: Add driver for TWL4030/TPS65950 BCI charger
On Mon, Sep 27, 2010 at 6:38 PM, Grazvydas Ignotas nota...@gmail.com wrote: On Mon, Sep 27, 2010 at 3:35 PM, Arun Murthy arunrmurthy...@gmail.com wrote: On Mon, Sep 27, 2010 at 4:24 PM, Grazvydas Ignotas nota...@gmail.com wrote: On Mon, Sep 27, 2010 at 10:21 AM, Arun Murthy arunrmurthy...@gmail.com wrote: The problem is that BCI is only active while charging, when it is not charging most (all?) monitoring registers freeze and no monitoring happens (BCI registers read frozen values from last charge). So I don't register battery as it has no useful data to report. I heard it is possible to use MADC to perform monitoring while not charging, so battery can be added when MADC driver is merged and corresponding code is written for this driver. How do I check the battery voltage? I need to check the battery voltage/current/temp and, if I am not wrong these are obtained from MADC. MADC driver has to be added first and then the battery. With being able to read the basic parameter battery voltage, this driver becomes incomplete. Incomplete driver is better than no driver, don't you think? There are some boards like pandora or oswald that have additional battery monitoring chips (as twl monitoring is pretty crude anyway), those boards would have fully functional charging now. Currently mainline kernel is not very useful with them simply because the battery runs flat. I agree, but I feel it would be better to make driver compatible with all boards(Zoom2, OMAP3430SDP, Chameleon, BeagleBoard etc). Even support for back-up battery is not supported. This is just a suggestion to have a full fledged driver for twl4030 Battery Charger Interface as a module. You may discard this if you have some strong reasons. How do I get notified if battery voltage is low and needs charging from user space? Either additional monitoring chip notifies you (if you are lucky and have one), or wait for update of this driver :) There are efforts to merge MADC driver [1], but it may take some time. But using MADC, I can get the battery voltage and by means of monitoring battery voltage we can get to know low battery notification. [1] http://marc.info/?t=12846153572r=1w=2 Thanks and Regards, Arun R Murthy -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] power_supply: Add driver for TWL4030/TPS65950 BCI charger
How do I get notified if battery voltage is low and needs charging from user space? Either additional monitoring chip notifies you (if you are lucky and have one), or wait for update of this driver :) There are efforts to merge MADC driver [1], but it may take some time. But using MADC, I can get the battery voltage and by means of monitoring battery voltage we can get to know low battery notification. True, but let's wait for MADC driver to be merged for that first. [1] http://marc.info/?t=12846153572r=1w=2 Thanks and Regards, Arun R Murthy -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html