Ben Dooks | 5718df9 | 2008-10-21 14:07:09 +0100 | [diff] [blame] | 1 | /* linux/arch/arm/mach-s3c6410/mach-smdk6410.c |
| 2 | * |
| 3 | * Copyright 2008 Openmoko, Inc. |
| 4 | * Copyright 2008 Simtec Electronics |
| 5 | * Ben Dooks <ben@simtec.co.uk> |
| 6 | * http://armlinux.simtec.co.uk/ |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/types.h> |
| 16 | #include <linux/interrupt.h> |
| 17 | #include <linux/list.h> |
| 18 | #include <linux/timer.h> |
| 19 | #include <linux/init.h> |
| 20 | #include <linux/serial_core.h> |
| 21 | #include <linux/platform_device.h> |
| 22 | #include <linux/io.h> |
Ben Dooks | 096941e | 2008-10-31 16:14:59 +0000 | [diff] [blame] | 23 | #include <linux/i2c.h> |
Ben Dooks | 438a5d4 | 2008-11-19 15:41:34 +0000 | [diff] [blame] | 24 | #include <linux/fb.h> |
| 25 | #include <linux/gpio.h> |
| 26 | #include <linux/delay.h> |
| 27 | |
| 28 | #include <video/platform_lcd.h> |
Ben Dooks | 5718df9 | 2008-10-21 14:07:09 +0100 | [diff] [blame] | 29 | |
| 30 | #include <asm/mach/arch.h> |
| 31 | #include <asm/mach/map.h> |
| 32 | #include <asm/mach/irq.h> |
| 33 | |
| 34 | #include <mach/hardware.h> |
Ben Dooks | 438a5d4 | 2008-11-19 15:41:34 +0000 | [diff] [blame] | 35 | #include <mach/regs-fb.h> |
Ben Dooks | 5718df9 | 2008-10-21 14:07:09 +0100 | [diff] [blame] | 36 | #include <mach/map.h> |
| 37 | |
| 38 | #include <asm/irq.h> |
| 39 | #include <asm/mach-types.h> |
| 40 | |
| 41 | #include <plat/regs-serial.h> |
Ben Dooks | d6662c3 | 2008-12-12 00:24:40 +0000 | [diff] [blame^] | 42 | #include <plat/regs-modem.h> |
| 43 | #include <plat/regs-gpio.h> |
| 44 | #include <plat/regs-sys.h> |
Ben Dooks | d85fa24 | 2008-10-31 16:14:52 +0000 | [diff] [blame] | 45 | #include <plat/iic.h> |
Ben Dooks | 438a5d4 | 2008-11-19 15:41:34 +0000 | [diff] [blame] | 46 | #include <plat/fb.h> |
Ben Dooks | 5718df9 | 2008-10-21 14:07:09 +0100 | [diff] [blame] | 47 | |
| 48 | #include <plat/s3c6410.h> |
| 49 | #include <plat/clock.h> |
| 50 | #include <plat/devs.h> |
| 51 | #include <plat/cpu.h> |
| 52 | |
| 53 | #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK |
| 54 | #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB |
| 55 | #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE |
| 56 | |
| 57 | static struct s3c2410_uartcfg smdk6410_uartcfgs[] __initdata = { |
| 58 | [0] = { |
| 59 | .hwport = 0, |
| 60 | .flags = 0, |
| 61 | .ucon = 0x3c5, |
| 62 | .ulcon = 0x03, |
| 63 | .ufcon = 0x51, |
| 64 | }, |
| 65 | [1] = { |
| 66 | .hwport = 1, |
| 67 | .flags = 0, |
| 68 | .ucon = 0x3c5, |
| 69 | .ulcon = 0x03, |
| 70 | .ufcon = 0x51, |
| 71 | }, |
| 72 | }; |
| 73 | |
Ben Dooks | 438a5d4 | 2008-11-19 15:41:34 +0000 | [diff] [blame] | 74 | /* framebuffer and LCD setup. */ |
| 75 | |
| 76 | /* GPF15 = LCD backlight control |
| 77 | * GPF13 => Panel power |
| 78 | * GPN5 = LCD nRESET signal |
| 79 | * PWM_TOUT1 => backlight brightness |
| 80 | */ |
| 81 | |
| 82 | static void smdk6410_lcd_power_set(struct plat_lcd_data *pd, |
| 83 | unsigned int power) |
| 84 | { |
| 85 | if (power) { |
| 86 | gpio_direction_output(S3C64XX_GPF(13), 1); |
| 87 | gpio_direction_output(S3C64XX_GPF(15), 1); |
| 88 | |
| 89 | /* fire nRESET on power up */ |
| 90 | gpio_direction_output(S3C64XX_GPN(5), 0); |
| 91 | msleep(10); |
| 92 | gpio_direction_output(S3C64XX_GPN(5), 1); |
| 93 | msleep(1); |
| 94 | } else { |
| 95 | gpio_direction_output(S3C64XX_GPF(15), 0); |
| 96 | gpio_direction_output(S3C64XX_GPF(13), 0); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | static struct plat_lcd_data smdk6410_lcd_power_data = { |
| 101 | .set_power = smdk6410_lcd_power_set, |
| 102 | }; |
| 103 | |
| 104 | static struct platform_device smdk6410_lcd_powerdev = { |
| 105 | .name = "platform-lcd", |
| 106 | .dev.parent = &s3c_device_fb.dev, |
| 107 | .dev.platform_data = &smdk6410_lcd_power_data, |
| 108 | }; |
| 109 | |
| 110 | static struct s3c_fb_pd_win smdk6410_fb_win0 = { |
| 111 | /* this is to ensure we use win0 */ |
| 112 | .win_mode = { |
| 113 | .pixclock = 41094, |
| 114 | .left_margin = 8, |
| 115 | .right_margin = 13, |
| 116 | .upper_margin = 7, |
| 117 | .lower_margin = 5, |
| 118 | .hsync_len = 3, |
| 119 | .vsync_len = 1, |
| 120 | .xres = 800, |
| 121 | .yres = 480, |
| 122 | }, |
| 123 | .max_bpp = 32, |
| 124 | .default_bpp = 16, |
| 125 | }; |
| 126 | |
| 127 | /* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */ |
| 128 | static struct s3c_fb_platdata smdk6410_lcd_pdata __initdata = { |
| 129 | .setup_gpio = s3c64xx_fb_gpio_setup_24bpp, |
| 130 | .win[0] = &smdk6410_fb_win0, |
| 131 | .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB, |
| 132 | .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC, |
| 133 | }; |
| 134 | |
Mark Brown | 027191a | 2009-01-23 16:29:43 +0000 | [diff] [blame] | 135 | static struct map_desc smdk6410_iodesc[] = {}; |
Ben Dooks | 5718df9 | 2008-10-21 14:07:09 +0100 | [diff] [blame] | 136 | |
| 137 | static struct platform_device *smdk6410_devices[] __initdata = { |
Ben Dooks | b24636c | 2008-11-03 20:14:53 +0000 | [diff] [blame] | 138 | #ifdef CONFIG_SMDK6410_SD_CH0 |
Ben Dooks | 39057f2 | 2008-10-31 16:14:29 +0000 | [diff] [blame] | 139 | &s3c_device_hsmmc0, |
Ben Dooks | b24636c | 2008-11-03 20:14:53 +0000 | [diff] [blame] | 140 | #endif |
| 141 | #ifdef CONFIG_SMDK6410_SD_CH1 |
| 142 | &s3c_device_hsmmc1, |
| 143 | #endif |
Ben Dooks | d85fa24 | 2008-10-31 16:14:52 +0000 | [diff] [blame] | 144 | &s3c_device_i2c0, |
Ben Dooks | d7ea374 | 2008-10-31 16:14:57 +0000 | [diff] [blame] | 145 | &s3c_device_i2c1, |
Ben Dooks | 438a5d4 | 2008-11-19 15:41:34 +0000 | [diff] [blame] | 146 | &s3c_device_fb, |
| 147 | &smdk6410_lcd_powerdev, |
Ben Dooks | 5718df9 | 2008-10-21 14:07:09 +0100 | [diff] [blame] | 148 | }; |
| 149 | |
Ben Dooks | 096941e | 2008-10-31 16:14:59 +0000 | [diff] [blame] | 150 | static struct i2c_board_info i2c_devs0[] __initdata = { |
| 151 | { I2C_BOARD_INFO("24c08", 0x50), }, |
Mark Brown | 778974797 | 2009-01-23 16:29:41 +0000 | [diff] [blame] | 152 | { I2C_BOARD_INFO("wm8580", 0x1b), }, |
Ben Dooks | 096941e | 2008-10-31 16:14:59 +0000 | [diff] [blame] | 153 | }; |
| 154 | |
| 155 | static struct i2c_board_info i2c_devs1[] __initdata = { |
| 156 | { I2C_BOARD_INFO("24c128", 0x57), }, /* Samsung S524AD0XD1 */ |
Ben Dooks | 5718df9 | 2008-10-21 14:07:09 +0100 | [diff] [blame] | 157 | }; |
| 158 | |
Ben Dooks | 5718df9 | 2008-10-21 14:07:09 +0100 | [diff] [blame] | 159 | static void __init smdk6410_map_io(void) |
| 160 | { |
Ben Dooks | d6662c3 | 2008-12-12 00:24:40 +0000 | [diff] [blame^] | 161 | u32 tmp; |
| 162 | |
Ben Dooks | 5718df9 | 2008-10-21 14:07:09 +0100 | [diff] [blame] | 163 | s3c64xx_init_io(smdk6410_iodesc, ARRAY_SIZE(smdk6410_iodesc)); |
| 164 | s3c24xx_init_clocks(12000000); |
| 165 | s3c24xx_init_uarts(smdk6410_uartcfgs, ARRAY_SIZE(smdk6410_uartcfgs)); |
Ben Dooks | d6662c3 | 2008-12-12 00:24:40 +0000 | [diff] [blame^] | 166 | |
| 167 | /* set the LCD type */ |
| 168 | |
| 169 | tmp = __raw_readl(S3C64XX_SPCON); |
| 170 | tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK; |
| 171 | tmp |= S3C64XX_SPCON_LCD_SEL_RGB; |
| 172 | __raw_writel(tmp, S3C64XX_SPCON); |
| 173 | |
| 174 | /* remove the lcd bypass */ |
| 175 | tmp = __raw_readl(S3C64XX_MODEM_MIFPCON); |
| 176 | tmp &= ~MIFPCON_LCD_BYPASS; |
| 177 | __raw_writel(tmp, S3C64XX_MODEM_MIFPCON); |
Ben Dooks | 5718df9 | 2008-10-21 14:07:09 +0100 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | static void __init smdk6410_machine_init(void) |
| 181 | { |
Ben Dooks | d85fa24 | 2008-10-31 16:14:52 +0000 | [diff] [blame] | 182 | s3c_i2c0_set_platdata(NULL); |
Ben Dooks | d7ea374 | 2008-10-31 16:14:57 +0000 | [diff] [blame] | 183 | s3c_i2c1_set_platdata(NULL); |
Ben Dooks | 438a5d4 | 2008-11-19 15:41:34 +0000 | [diff] [blame] | 184 | s3c_fb_set_platdata(&smdk6410_lcd_pdata); |
Ben Dooks | 096941e | 2008-10-31 16:14:59 +0000 | [diff] [blame] | 185 | |
Mark Brown | b7f9a94 | 2009-04-08 16:12:35 +0100 | [diff] [blame] | 186 | gpio_request(S3C64XX_GPN(5), "LCD power"); |
| 187 | gpio_request(S3C64XX_GPF(13), "LCD power"); |
| 188 | gpio_request(S3C64XX_GPF(15), "LCD power"); |
| 189 | |
Ben Dooks | 096941e | 2008-10-31 16:14:59 +0000 | [diff] [blame] | 190 | i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0)); |
| 191 | i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1)); |
| 192 | |
Ben Dooks | 5718df9 | 2008-10-21 14:07:09 +0100 | [diff] [blame] | 193 | platform_add_devices(smdk6410_devices, ARRAY_SIZE(smdk6410_devices)); |
| 194 | } |
| 195 | |
| 196 | MACHINE_START(SMDK6410, "SMDK6410") |
| 197 | /* Maintainer: Ben Dooks <ben@fluff.org> */ |
| 198 | .phys_io = S3C_PA_UART & 0xfff00000, |
| 199 | .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc, |
| 200 | .boot_params = S3C64XX_PA_SDRAM + 0x100, |
| 201 | |
| 202 | .init_irq = s3c6410_init_irq, |
| 203 | .map_io = smdk6410_map_io, |
| 204 | .init_machine = smdk6410_machine_init, |
| 205 | .timer = &s3c24xx_timer, |
| 206 | MACHINE_END |