[Galaxy S III Android Development] mad_ady:
<ProffesorFarnsworth>Good news, everyone!</ProffesorFarnsworth>

I managed to isolate the bug that caused the phone to freeze when plugged into a Samsung Dock.

TL;DR version - it was due to MHL (CONFIG_SAMSUNG_MHL) being enabled. With it disabled, the phone no longer freezes when plugged into a dock. Of course, HDMI output from the dock doesn't work (but I haven't heard of it working on any AOSP ROM). [MENTION=947981]Lord Boeffla[/MENTION] I sent you a git push request for the defconfig file (just learning how github works in the process)...

The long version: Here's my iterative process I used to isolate this (hopefully it will help others in the same situation):

1. I started with building a working kernel from the sources (I will post a FAQ update soon so that others don't have to struggle). When that kernel booted, I started to make small changes.

2. As instructed by Lord Boeffla, I started with drivers/battery/samsung_battery.c and added "break" calls in the switch when it had to deal with a dock. Recompiled the kernel and it still hanged.

3. I decided to disable samsung_battery.c alltogether to see if the problem is there. I had to turn off the following settings before my kernel compiled: CONFIG_BATTERY_SAMSUNG=n, CHARGE_LEVEL=n, BATTERY_MAX77693_CHARGER=n, TOUCH_WAKE=n. The kernel booted, and it reported 0 battery level, with no feedback on wether it was charging or discharging (I stayed at 0% for the whole day :D). The phone froze when plugged into the charger, so that wasn't it (hooray!)

4. I ran a grep on the .config file to see what other SAMSUNG specific entries there were. I decided to try to disable SAMSUNG_SMARTDOCK next (Drivers -> Multimedia -> MHL). Recompiled the kernel, still hanged

5. I also decided to disable MHL support (from the same place in the kernel). Recompiled the kernel and bingo - phone didn't freeze in dock.

The rest of the steps were to find the minimum changes needed to keep the phone from freezing (the tests were done incrementally, so a lot of options got disabled when I got to step 5). It turns out that having CONFIG_SAMSUNG_MHL=n was enough and the phone is stable in the dock now!

Implications: Well, disabling this option turns off HDMI output for your phone which, as far as I know doesn't work anyway due to missing Touchwiz bits in AOSP ROMs.

Problems: All the kernels I built and flashed worked (ok, the first kernels didn't boot, but that's a different story), but WIFI never worked after flashing. I kept Lord Boeffla's modules and never flashed new modules, but the modules would load with my custom kernel. However, when flashing my ROM's kernel (dd if=/sdcard/Sale/boot.img of=/dev/block/mmcblk0p5), it would boot but wifi would still be broken. I'd like to know why wifi was broken after I flashed my kernel (I didn't change anything in the wifi part and the wifi drivers were built-in, not modules). Do I need a cleanup script of some sort?

Also, [MENTION=947981]Lord Boeffla[/MENTION], would you consider adding /proc/config.gz support to your kernel? It would make it easier to compare features with other kernels (if those kernels support the same thing).