Letux Kernel

Issue 659: twl4030 strange dependency between drivers/phy/phy-twl4030-usb and drivers/power/twl4030_charger.c

Reported by Nikolaus Schaller, Sep 9, 2014

currently, both drivers are coupled by a private function call which 
makes it impossible to link if they are configured as modules.

This is not mainline code but introduced by our GTA04 stuff.

The code is also marked as "hack":


static ssize_t twl4030_usb_vbus_out_store(struct device *dev,
		struct device_attribute *attr,
		const char *buf, size_t n)
{
	struct twl4030_usb *twl = dev_get_drvdata(dev);
	/* hack, should probably not be called directly this way */
	extern void twl4030_charger_enable_usb_ext(bool);

	if (sysfs_streq(buf, "on")) {
		twl4030_charger_enable_usb_ext(0);
		twl4030_i2c_access(twl, 1);
		twl4030_usb_set_bits(twl, ULPI_OTG_CTRL, ULPI_OTG_CTRL_DRVVBUS);
		twl4030_i2c_access(twl, 0);
	} else if (sysfs_streq(buf, "off")) {
		twl4030_i2c_access(twl, 1);
		twl4030_usb_clear_bits(twl, ULPI_OTG_CTRL,
			ULPI_OTG_CTRL_DRVVBUS);
		twl4030_i2c_access(twl, 0);
		twl4030_charger_enable_usb_ext(1);
	} else
		return -EINVAL;
	return n;
}

As far as I understand this code it disables charging if the OTG 
VBUS driver is turned on.

But it also appears that twl4030_usb_vbus_out_store() is only called 
if someone writes "on" or "off" to 
/sys/.../vbus_out

So we can simply ask the user space that writes "on" to 
disable the charger...

On the other hand the twl4030_charger listens to some 
usb_notifier_block and passes an event to its work procedure in 
twl4030_bci_usb_ncb().

So there is some communication path between the usb (phy) and the 
charger. We just need to create and send the correct 
notification_block in drivers/phy/phy-twl4030-usb.

The events we should send are:
USB_EVENT_VBUS / USB_EVENT_CHARGER or USB_EVENT_NONE.

They are usually sent by: --- hm good question. I did not find any 
code that sends something using the USB_EVENT_CHARGER constant?!?

Comment 1 by Marek Belisko, Sep 18, 2014

Issue was introduced by: 8c52a7cf8e066d7ce202e38863c225a7d4d0bfeb

Maybe we can ask Andreas to clean it up or just drop it?

Comment 2 by Nikolaus Schaller, Aug 20, 2015

has been guarded by #ifndef MODULE so that we can compile with 
omap2plus_defconfig
Labels: Priority:Medium Priority:Critical

Comment 3 by Nikolaus Schaller, Aug 20, 2015

Summary: twl4030 strange dependency between drivers/phy/phy-twl4030-usb and drivers/power/twl4030_charger.c

Comment 4 by Nikolaus Schaller, Feb 13, 2016

The dependency has completely disappeared in 4.5.
Status: Fixed

Created: 10 years 6 months ago by Nikolaus Schaller

Updated: 9 years 1 month ago

Status: Fixed

Followed by: 1 person

Labels:
Type:Defect
Priority:Medium

This issue is related to
653 - Fix...o define them as modules