GTA02 USB and battery current profile

Felipe Balbi me at felipebalbi.com
Sun Mar 9 16:31:10 CET 2008


On Sun, Mar 09, 2008 at 03:07:32PM +0000, Andy Green wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Somebody in the thread at some point said:
> > On Sun, Mar 09, 2008 at 11:45:09AM -0300, Werner Almesberger wrote:
> >> Felipe Balbi wrote:
> >>> Just passed through my mind this idea, it would be nice to popup the
> >>> user about which module to use, like when you attach an Nseries nokia
> >>> phone to your pc, it asks "Pc-suite, Data transfer". How about that ?
> >> Please send patches :-)
> > 
> > That would be done in userspace :-p
> > Are you guys using HAL?
> > 
> > You could install a hall-addon to check whether vbus is active and
> > whether the cable attached is mini-b. If both are true this means we're
> > attached as peripheral and instead of just starting g_ether (which is
> > now statically linked to the kernel) you popup a screen for the user
> > to choose.
> > 
> > This means, g_ether and g_file_storage should be modules not statically
> > linked to kernel.
> 
> What we need before this is a plan for the dynamic host / gadget
> switching in the kernel.  We can poll the USB ID to find if it is
> grounded, floating, or with the "1A" charger... then what do we do if we
> find the situation changed?

struct otg_transceiver has set_host and set_peripheral callbacks, we
could just call them. Of course we need to set them at some level. Board
files doesn't seem a good place though.

If you checkout the kernel source from repository.maemo.org for OS2008,
you will see how we did on testing purposes. We have a sysfs entry where
we can force desired modes to usb.

echo host > /sys/devices/platform/musb_hdrc/mode will force device into
host even though we have a micro-b connector attached.

echo peripheral > /sys/devices/platform/musb_hdrc/mode will put it into
peripheral mode

echo otg > /sys/devices/platform/musb_hdrc/mode will restore id pin
detection mechanism.

We could have something similar on openmoko.

if (id_pin_is_grounded())
	otg_set_host(otg);
else if (id_pin_is_floating())
	otg_set_peripheral(otg);
else if (id_pin_charger())
	usb_start_charging();
else {
	printk(KERN_ERR "Unknown mode\n");
	return -ENODEV;
}

Or something like that.

-- 
Best Regards,

Felipe Balbi
me at felipebalbi.com
http://blog.felipebalbi.com




More information about the openmoko-kernel mailing list