Merge branch 'for-2.6.27' of git://linux-nfs.org/~bfields/linux
[pandora-kernel.git] / arch / arm / mach-s3c2410 / mach-n30.c
index 476b15c..43c2e91 100644 (file)
@@ -84,18 +84,17 @@ static struct s3c2410_uartcfg n30_uartcfgs[] = {
 
 static void n30_udc_pullup(enum s3c2410_udc_cmd_e cmd)
 {
-       switch (cmd)
-       {
-               case S3C2410_UDC_P_ENABLE :
-                       s3c2410_gpio_setpin(S3C2410_GPB3, 1);
-                       break;
-               case S3C2410_UDC_P_DISABLE :
-                       s3c2410_gpio_setpin(S3C2410_GPB3, 0);
-                       break;
-               case S3C2410_UDC_P_RESET :
-                       break;
-               default:
-                       break;
+       switch (cmd) {
+       case S3C2410_UDC_P_ENABLE :
+               s3c2410_gpio_setpin(S3C2410_GPB3, 1);
+               break;
+       case S3C2410_UDC_P_DISABLE :
+               s3c2410_gpio_setpin(S3C2410_GPB3, 0);
+               break;
+       case S3C2410_UDC_P_RESET :
+               break;
+       default:
+               break;
        }
 }
 
@@ -293,28 +292,29 @@ static struct platform_device n30_warning_led = {
 };
 
 static struct s3c2410fb_display n30_display __initdata = {
-       .type = S3C2410_LCDCON1_TFT,
-       .width = 240,
-       .height = 320,
-       .pixclock = 170000,
-       .xres = 240,
-       .yres = 320,
-       .bpp = 16,
-       .left_margin = 3,
-       .right_margin = 40,
-       .hsync_len = 40,
-       .upper_margin = 2,
-       .lower_margin = 3,
-       .vsync_len = 2,
+       .type           = S3C2410_LCDCON1_TFT,
+       .width          = 240,
+       .height         = 320,
+       .pixclock       = 170000,
+
+       .xres           = 240,
+       .yres           = 320,
+       .bpp            = 16,
+       .left_margin    = 3,
+       .right_margin   = 40,
+       .hsync_len      = 40,
+       .upper_margin   = 2,
+       .lower_margin   = 3,
+       .vsync_len      = 2,
 
        .lcdcon5 = S3C2410_LCDCON5_INVVLINE | S3C2410_LCDCON5_INVVFRAME,
 };
 
 static struct s3c2410fb_mach_info n30_fb_info __initdata = {
-       .displays = &n30_display,
-       .num_displays = 1,
+       .displays       = &n30_display,
+       .num_displays   = 1,
        .default_display = 0,
-       .lpcsel=        0x06,
+       .lpcsel         = 0x06,
 };
 
 static struct platform_device *n30_devices[] __initdata = {
@@ -345,9 +345,148 @@ static struct s3c2410_platform_i2c n30_i2ccfg = {
        .max_freq       = 10*1000,
 };
 
+/* Lots of hardcoded stuff, but it sets up the hardware in a useful
+ * state so that we can boot Linux directly from flash. */
+static void __init n30_hwinit(void)
+{
+       /* GPA0-11 special functions -- unknown what they do
+        * GPA12 N30 special function -- unknown what it does
+        *       N35/PiN output -- unknown what it does
+        *
+        * A12 is nGCS1 on the N30 and an output on the N35/PiN.  I
+        * don't think it does anything useful on the N30, so I ought
+        * to make it an output there too since it always driven to 0
+        * as far as I can tell. */
+       if (machine_is_n30())
+               __raw_writel(0x007fffff, S3C2410_GPACON);
+       if (machine_is_n35())
+               __raw_writel(0x007fefff, S3C2410_GPACON);
+       __raw_writel(0x00000000, S3C2410_GPADAT);
+
+       /* GPB0 TOUT0 backlight level
+        * GPB1 output 1=backlight on
+        * GPB2 output IrDA enable 0=transceiver enabled, 1=disabled
+        * GPB3 output USB D+ pull up 0=disabled, 1=enabled
+        * GPB4 N30 output -- unknown function
+        *      N30/PiN GPS control 0=GPS enabled, 1=GPS disabled
+        * GPB5 output -- unknown function
+        * GPB6 input -- unknown function
+        * GPB7 output -- unknown function
+        * GPB8 output -- probably LCD driver enable
+        * GPB9 output -- probably LCD VSYNC driver enable
+        * GPB10 output -- probably LCD HSYNC driver enable
+        */
+       __raw_writel(0x00154556, S3C2410_GPBCON);
+       __raw_writel(0x00000750, S3C2410_GPBDAT);
+       __raw_writel(0x00000073, S3C2410_GPBUP);
+
+       /* GPC0 input RS232 DCD/DSR/RI
+        * GPC1 LCD
+        * GPC2 output RS232 DTR?
+        * GPC3 input RS232 DCD/DSR/RI
+        * GPC4 LCD
+        * GPC5 output 0=NAND write enabled, 1=NAND write protect
+        * GPC6 input -- unknown function
+        * GPC7 input charger status 0=charger connected
+        *      this input can be triggered by power on the USB device
+        *      port too, but will go back to disconnected soon after.
+        * GPC8 N30/N35 output -- unknown function, always driven to 1
+        *      PiN input -- unknown function, always read as 1
+        *      Make it an input with a pull up for all models.
+        * GPC9-15 LCD
+        */
+       __raw_writel(0xaaa80618, S3C2410_GPCCON);
+       __raw_writel(0x0000014c, S3C2410_GPCDAT);
+       __raw_writel(0x0000fef2, S3C2410_GPCUP);
+
+       /* GPD0 input -- unknown function
+        * GPD1-D7 LCD
+        * GPD8 N30 output -- unknown function
+        *      N35/PiN output 1=GPS LED on
+        * GPD9 output 0=power led blinks red, 1=normal power led function
+        * GPD10 output -- unknown function
+        * GPD11-15 LCD drivers
+        */
+       __raw_writel(0xaa95aaa4, S3C2410_GPDCON);
+       __raw_writel(0x00000601, S3C2410_GPDDAT);
+       __raw_writel(0x0000fbfe, S3C2410_GPDUP);
+
+       /* GPE0-4 I2S audio bus
+        * GPE5-10 SD/MMC bus
+        * E11-13 outputs -- unknown function, probably power management
+        * E14-15 I2C bus connected to the battery controller
+        */
+       __raw_writel(0xa56aaaaa, S3C2410_GPECON);
+       __raw_writel(0x0000efc5, S3C2410_GPEDAT);
+       __raw_writel(0x0000f81f, S3C2410_GPEUP);
+
+       /* GPF0  input 0=power button pressed
+        * GPF1  input SD/MMC switch 0=card present
+        * GPF2  N30 1=reset button pressed (inverted compared to the rest)
+        *       N35/PiN 0=reset button pressed
+        * GPF3  N30/PiN input -- unknown function
+        *       N35 input GPS antenna position, 0=antenna closed, 1=open
+        * GPF4  input 0=button 4 pressed
+        * GPF5  input 0=button 3 pressed
+        * GPF6  input 0=button 2 pressed
+        * GPF7  input 0=button 1 pressed
+        */
+       __raw_writel(0x0000aaaa, S3C2410_GPFCON);
+       __raw_writel(0x00000000, S3C2410_GPFDAT);
+       __raw_writel(0x000000ff, S3C2410_GPFUP);
+
+       /* GPG0  input RS232 DCD/DSR/RI
+        * GPG1  input 1=USB gadget port has power from a host
+        * GPG2  N30 input -- unknown function
+        *       N35/PiN input 0=headphones plugged in, 1=not plugged in
+        * GPG3  N30 output -- unknown function
+        *       N35/PiN input with unknown function
+        * GPG4  N30 output 0=MMC enabled, 1=MMC disabled
+        * GPG5  N30 output 0=BlueTooth chip disabled, 1=enabled
+        *       N35/PiN input joystick right
+        * GPG6  N30 output 0=blue led on, 1=off
+        *       N35/PiN input joystick left
+        * GPG7  input 0=thumbwheel pressed
+        * GPG8  input 0=thumbwheel down
+        * GPG9  input 0=thumbwheel up
+        * GPG10 input SD/MMC write protect switch
+        * GPG11 N30 input -- unknown function
+        *       N35 output 0=GPS antenna powered, 1=not powered
+        *       PiN output -- unknown function
+        * GPG12-15 touch screen functions
+        *
+        * The pullups differ between the models, so enable all
+        * pullups that are enabled on any of the models.
+        */
+       if (machine_is_n30())
+               __raw_writel(0xff0a956a, S3C2410_GPGCON);
+       if (machine_is_n35())
+               __raw_writel(0xff4aa92a, S3C2410_GPGCON);
+       __raw_writel(0x0000e800, S3C2410_GPGDAT);
+       __raw_writel(0x0000f86f, S3C2410_GPGUP);
+
+       /* GPH0/1/2/3 RS232 serial port
+        * GPH4/5 IrDA serial port
+        * GPH6/7  N30 BlueTooth serial port
+        *         N35/PiN GPS receiver
+        * GPH8 input -- unknown function
+        * GPH9 CLKOUT0 HCLK -- unknown use
+        * GPH10 CLKOUT1 FCLK -- unknown use
+        *
+        * The pull ups for H6/H7 are enabled on N30 but not on the
+        * N35/PiN.  I suppose is useful for a budget model of the N30
+        * with no bluetooh.  It doesn't hurt to have the pull ups
+        * enabled on the N35, so leave them enabled for all models.
+        */
+       __raw_writel(0x0028aaaa, S3C2410_GPHCON);
+       __raw_writel(0x000005ef, S3C2410_GPHDAT);
+       __raw_writel(0x0000063f, S3C2410_GPHUP);
+}
+
 static void __init n30_map_io(void)
 {
        s3c24xx_init_io(n30_iodesc, ARRAY_SIZE(n30_iodesc));
+       n30_hwinit();
        s3c24xx_init_clocks(0);
        s3c24xx_init_uarts(n30_uartcfgs, ARRAY_SIZE(n30_uartcfgs));
 }