[Galaxy S I9000 Android Development] Arise:
Hi there.

So, a couple of people wanted details about this. So here is my sharing part.

// disclaimer
/*
First. I don't know much. Or I know much, but MUCH of this much is bull****. So always think yourself and don't take things as easy as I do. :)
You can fry your microUSB port or you may brick your phone so use common sense and your own judgement.
*/
// end of disclaimer

It all started when the user handarmbeinfuss (MIA for couple of months) started to play with this and also set up a repository. You can read about in page 5.

Not much success on its side then, however the code has changed. Much changed because Samsung updated their sources. Beware people with american versions of the Galaxy S like vibrant, fascinate, epic. (if you are still on 2.1 sourcecode)

Also, just a note. In 2.1 we had USB OTG drivers for host (please read again, as I don't know how to explain better) We had OTG drivers to handle host communication. Again I'm not talking about "USB Host drivers" but "USB OTG drivers" to handle Host!!!

But in froyo we don't have this anymore. This part is removed from the sourcecode tree.

However now we have updated ehci and ohci drivers for the Host side (not talking about OTG here, only pure host). My success enumerating the internal usb hub port came after I compiled host support in the kernel.

If previous (in eclair) we had S5PC110 drivers, now in Froyo we S5PV210 drivers.

I've checked the latest sources from ODROID and they are kinda similar with the Samsung Sources. Both have S5PV210 drivers.

The big problem with this is that you can't have Host and Client part in the same time. So we need something like an OTG driver (to auto-manage host/client) or we have to load the proper modules host or client depending on what we are trying to achieve.

I went on the second option.

So, in order to load host we must not have client in the kernel, so we have to load client as modules (with insmod).

But just switching the M flag in make menuconfig doesn't help because the usb client part resides in the same source files as the charging part.

We need the charging part (I guess and I assume we need this) because the phone (at least until now) is not convinced to provide power in host mode. So I guess we need to supply our own power to the phone and also to the connected device. So we need an active usb hub, and most important a non standard one.

A full compliant usb hub is not allowed to send power on the upstream port. We need exactly that. We need a non compliant hub that send current on the upstream port. This way the phone will charge and also the usb stick/hdd/mouse/keyboard will be powered. Also hopefully we will also be able to use them. :)

So, in order to achieve this we have to split the charging part from the usb client part.

Everything is in https://github.com/handarmbeinfuss repository.

The first split is done against regulators.

max8998_function.c -> max8998_usbstuff.c & max8998_function.c

The second split is done across

fsa9480_i2c.c -> fsa9480_usbstuff.c & fsa9480_i2c.c

Also some other files like

adb_ums_acm_mtp_rndis.c

s3c_udc_otg.c

s5pc110_battery.c

are touched.

Also take notice of the new file: usb_cable_notifier.c

Now, in order to compile everything.

max8998_usbstuff.c must be compiled as a module

s3c_udc_otg.c must be compiled as a module

g_android (several files compiled here) as a module

Inside g_android-objs we no longer compile fsa9480_i2c.o. Instead we replace it with fsa9480_usbstuff.o

g_android-objs	:= adb_ums_acm_mtp_rndis.o f_adb.o f_mass_storage.o u_serial.o f_acm.o serial_acm.o u_ether.o	rndis.o	f_rndis.o	f_mtp.o fsa9480_usbstuff.o composite.o $(C_UTILS)

I assume fsa9480_i2c.o goes to the kernel alongside usb_cable_notifier.o

obj-$(CONFIG_USB_CABLEHANDLING) := usb_cable_notifier.o fsa9480_i2c.o