Funny you should ask about pin 4; I had the same question and had just researched the answer.
In short: it is hard coded in the kernel to pin 4. It is not used until you load the w1-gpio kernel module; at that point pin 4 is dedicated to the one-wire bus until you unload the w1-gpio kernel module.
The actual assignment is made in https://github.com/raspberrypi/linux/blob/rpi-3.6.y/arch/arm/mach-bcm2708/bcm2708.c
. The pin is assigned around the "#define W1_GPIO 4" line. Look for w1_gpio_platform_data to see the actual structure definition.
As far as I can tell: this version of the kernel is completely hard coded; it doesn't even allow overriding the pin defintions at module load time.
The kernel that comes with openwrt has a w1_gpio_custom module. This module allows pin definitions to be made at module load time. But that module seems to only live with openwrt, and hasn't been ported anywhere else.