2 * SAMSUNG EXYNOS5250 Flattened Device Tree enabled machine
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/gpio.h>
13 #include <linux/of_platform.h>
14 #include <linux/serial_core.h>
15 #include <linux/smsc911x.h>
16 #include <linux/delay.h>
17 #include <linux/i2c.h>
18 #include <linux/pwm_backlight.h>
19 #include <linux/mfd/wm8994/pdata.h>
20 #include <linux/regulator/machine.h>
22 #include <asm/mach/arch.h>
23 #include <asm/hardware/gic.h>
25 #include <mach/ohci.h>
26 #include <mach/regs-pmu.h>
29 #include <plat/regs-serial.h>
30 #include <plat/regs-srom.h>
31 #include <plat/backlight.h>
32 #include <plat/devs.h>
33 #include <plat/usb-phy.h>
35 #include <video/platform_lcd.h>
39 static void __init smsc911x_init(int ncs)
43 /* configure nCS1 width to 16 bits */
44 data = __raw_readl(S5P_SROM_BW) &
45 ~(S5P_SROM_BW__CS_MASK << (ncs * 4));
46 data |= ((1 << S5P_SROM_BW__DATAWIDTH__SHIFT) |
47 (1 << S5P_SROM_BW__WAITENABLE__SHIFT) |
48 (1 << S5P_SROM_BW__BYTEENABLE__SHIFT)) << (ncs * 4);
49 __raw_writel(data, S5P_SROM_BW);
51 /* set timing for nCS1 suitable for ethernet chip */
52 __raw_writel((0x1 << S5P_SROM_BCX__PMC__SHIFT) |
53 (0x9 << S5P_SROM_BCX__TACP__SHIFT) |
54 (0xc << S5P_SROM_BCX__TCAH__SHIFT) |
55 (0x1 << S5P_SROM_BCX__TCOH__SHIFT) |
56 (0x6 << S5P_SROM_BCX__TACC__SHIFT) |
57 (0x1 << S5P_SROM_BCX__TCOS__SHIFT) |
58 (0x1 << S5P_SROM_BCX__TACS__SHIFT),
59 S5P_SROM_BC0 + (ncs * 4));
62 static void mipi_lcd_set_power(struct plat_lcd_data *pd,
66 gpio_request_one(EXYNOS5_GPX1(5), GPIOF_OUT_INIT_HIGH, "GPX1");
70 /* fire nRESET on power up */
71 gpio_set_value(EXYNOS5_GPX1(5), 0);
73 gpio_set_value(EXYNOS5_GPX1(5), 1);
75 gpio_free(EXYNOS5_GPX1(5));
77 /* fire nRESET on power off */
78 gpio_set_value(EXYNOS5_GPX1(5), 0);
80 gpio_set_value(EXYNOS5_GPX1(5), 1);
82 gpio_free(EXYNOS5_GPX1(5));
86 * Request lcd_bl_en GPIO for smdk5250_bl_notify().
87 * TODO: Fix this so we are not at risk of requesting the GPIO
88 * multiple times, this should be done with device tree, and
89 * likely integrated into the plat-samsung/dev-backlight.c init.
91 gpio_request_one(EXYNOS5_GPX3(0), GPIOF_OUT_INIT_LOW, "GPX3");
94 static int smdk5250_match_fb(struct plat_lcd_data *pd, struct fb_info *info)
96 /* Don't call .set_power callback while unblanking */
100 static struct plat_lcd_data smdk5250_mipi_lcd_data = {
101 .set_power = mipi_lcd_set_power,
102 .match_fb = smdk5250_match_fb,
105 static struct platform_device smdk5250_mipi_lcd = {
106 .name = "platform-lcd",
107 .dev.platform_data = &smdk5250_mipi_lcd_data,
110 static int smdk5250_bl_notify(struct device *unused, int brightness)
112 /* manage lcd_bl_en signal */
114 gpio_set_value(EXYNOS5_GPX3(0), 1);
116 gpio_set_value(EXYNOS5_GPX3(0), 0);
121 /* LCD Backlight data */
122 static struct samsung_bl_gpio_info smdk5250_bl_gpio_info = {
123 .no = EXYNOS5_GPB2(0),
124 .func = S3C_GPIO_SFN(2),
127 static struct platform_pwm_backlight_data smdk5250_bl_data = {
128 .pwm_period_ns = 1000,
129 .notify = smdk5250_bl_notify,
132 struct platform_device exynos_device_md0 = {
133 .name = "exynos-mdev",
137 struct platform_device exynos_device_md1 = {
138 .name = "exynos-mdev",
142 struct platform_device exynos_device_md2 = {
143 .name = "exynos-mdev",
147 static struct regulator_consumer_supply wm8994_avdd1_supply =
148 REGULATOR_SUPPLY("AVDD1", "1-001a");
150 static struct regulator_consumer_supply wm8994_dcvdd_supply =
151 REGULATOR_SUPPLY("DCVDD", "1-001a");
153 static struct regulator_init_data wm8994_ldo1_data = {
157 .num_consumer_supplies = 1,
158 .consumer_supplies = &wm8994_avdd1_supply,
161 static struct regulator_init_data wm8994_ldo2_data = {
165 .num_consumer_supplies = 1,
166 .consumer_supplies = &wm8994_dcvdd_supply,
169 static struct wm8994_pdata wm8994_platform_data = {
170 /* configure gpio1 function: 0x0001(Logic level input/output) */
171 .gpio_defaults[0] = 0x0001,
172 /* If the i2s0 and i2s2 is enabled simultaneously */
173 .gpio_defaults[7] = 0x8100, /* GPIO8 DACDAT3 in */
174 .gpio_defaults[8] = 0x0100, /* GPIO9 ADCDAT3 out */
175 .gpio_defaults[9] = 0x0100, /* GPIO10 LRCLK3 out */
176 .gpio_defaults[10] = 0x0100,/* GPIO11 BCLK3 out */
177 .ldo[0] = { 0, &wm8994_ldo1_data },
178 .ldo[1] = { 0, &wm8994_ldo2_data },
181 static struct i2c_board_info i2c_devs1[] __initdata = {
183 I2C_BOARD_INFO("wm8994", 0x1a),
184 .platform_data = &wm8994_platform_data,
189 * The following lookup table is used to override device names when devices
190 * are registered from device tree. This is temporarily added to enable
191 * device tree support addition for the EXYNOS5 architecture.
193 * For drivers that require platform data to be provided from the machine
194 * file, a platform data pointer can also be supplied along with the
195 * devices names. Usually, the platform data elements that cannot be parsed
196 * from the device tree by the drivers (example: function pointers) are
197 * supplied. But it should be noted that this is a temporary mechanism and
198 * at some point, the drivers should be capable of parsing all the platform
199 * data from the device tree.
201 static const struct of_dev_auxdata exynos5250_auxdata_lookup[] __initconst = {
202 OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS5_PA_UART0,
203 "exynos4210-uart.0", NULL),
204 OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS5_PA_UART1,
205 "exynos4210-uart.1", NULL),
206 OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS5_PA_UART2,
207 "exynos4210-uart.2", NULL),
208 OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS5_PA_UART3,
209 "exynos4210-uart.3", NULL),
210 OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS5_PA_IIC(0),
211 "s3c2440-i2c.0", NULL),
212 OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS5_PA_IIC(1),
213 "s3c2440-i2c.1", NULL),
214 OF_DEV_AUXDATA("synopsis,dw-mshc-exynos5250", 0x12200000,
216 OF_DEV_AUXDATA("synopsis,dw-mshc-exynos5250", 0x12210000,
218 OF_DEV_AUXDATA("synopsis,dw-mshc-exynos5250", 0x12220000,
220 OF_DEV_AUXDATA("synopsis,dw-mshc-exynos5250", 0x12230000,
222 OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_PDMA0, "dma-pl330.0", NULL),
223 OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_PDMA1, "dma-pl330.1", NULL),
224 OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_MDMA1, "dma-pl330.2", NULL),
228 static struct platform_device *smdk5250_devices[] __initdata = {
229 &smdk5250_mipi_lcd, /* for platform_lcd device */
230 &exynos_device_md0, /* for media device framework */
231 &exynos_device_md1, /* for media device framework */
232 &exynos_device_md2, /* for media device framework */
233 &samsung_asoc_dma, /* for audio dma interface device */
236 static void __init exynos5250_dt_map_io(void)
238 exynos_init_io(NULL, 0);
239 s3c24xx_init_clocks(24000000);
242 static void __init exynos5_reserve(void)
244 /* required to have enough address range to remap the IOMMU
245 * allocated buffers */
246 init_consistent_dma_size(SZ_64M);
249 static void s5p_tv_setup(void)
251 /* direct HPD to HDMI chip */
252 gpio_request(EXYNOS5_GPX3(7), "hpd-plug");
254 gpio_direction_input(EXYNOS5_GPX3(7));
255 s3c_gpio_cfgpin(EXYNOS5_GPX3(7), S3C_GPIO_SFN(0x3));
256 s3c_gpio_setpull(EXYNOS5_GPX3(7), S3C_GPIO_PULL_NONE);
259 static void exynos5_i2c_setup(void)
261 /* Setup the low-speed i2c controller interrupts */
262 writel(0x0, EXYNOS5_SYS_I2C_CFG);
265 static void __init exynos5250_dt_machine_init(void)
267 if (of_machine_is_compatible("samsung,smdk5250"))
269 samsung_bl_set(&smdk5250_bl_gpio_info, &smdk5250_bl_data);
271 if (gpio_request_one(EXYNOS5_GPX2(6), GPIOF_OUT_INIT_HIGH,
272 "HOST_VBUS_CONTROL")) {
273 printk(KERN_ERR "failed to request gpio_host_vbus\n");
275 s3c_gpio_setpull(EXYNOS5_GPX2(6), S3C_GPIO_PULL_NONE);
276 gpio_free(EXYNOS5_GPX2(6));
281 i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
283 of_platform_populate(NULL, of_default_bus_match_table,
284 exynos5250_auxdata_lookup, NULL);
288 platform_add_devices(smdk5250_devices, ARRAY_SIZE(smdk5250_devices));
291 static char const *exynos5250_dt_compat[] __initdata = {
292 "samsung,exynos5250",
296 DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
297 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
298 .init_irq = exynos5_init_irq,
299 .reserve = exynos5_reserve,
300 .map_io = exynos5250_dt_map_io,
301 .handle_irq = gic_handle_irq,
302 .init_machine = exynos5250_dt_machine_init,
303 .timer = &exynos4_timer,
304 .dt_compat = exynos5250_dt_compat,
305 .restart = exynos5_restart,