Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 1 | /* |
| 2 | * SAMSUNG EXYNOS5250 Flattened Device Tree enabled machine |
| 3 | * |
| 4 | * Copyright (c) 2012 Samsung Electronics Co., Ltd. |
| 5 | * http://www.samsung.com |
| 6 | * |
| 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. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/of_platform.h> |
Doug Anderson | 5b7897d | 2012-11-27 11:53:14 -0800 | [diff] [blame] | 13 | #include <linux/of_fdt.h> |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 14 | #include <linux/serial_core.h> |
Arun Kumar K | 2eae613 | 2012-10-23 22:51:33 +0900 | [diff] [blame] | 15 | #include <linux/memblock.h> |
Abhilash Kesavan | 7000fe8 | 2012-11-20 18:20:38 +0900 | [diff] [blame] | 16 | #include <linux/io.h> |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 17 | |
| 18 | #include <asm/mach/arch.h> |
| 19 | #include <asm/hardware/gic.h> |
| 20 | #include <mach/map.h> |
Abhilash Kesavan | 7000fe8 | 2012-11-20 18:20:38 +0900 | [diff] [blame] | 21 | #include <mach/regs-pmu.h> |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 22 | |
| 23 | #include <plat/cpu.h> |
| 24 | #include <plat/regs-serial.h> |
Arun Kumar K | 2eae613 | 2012-10-23 22:51:33 +0900 | [diff] [blame] | 25 | #include <plat/mfc.h> |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 26 | |
| 27 | #include "common.h" |
| 28 | |
| 29 | /* |
| 30 | * The following lookup table is used to override device names when devices |
| 31 | * are registered from device tree. This is temporarily added to enable |
| 32 | * device tree support addition for the EXYNOS5 architecture. |
| 33 | * |
| 34 | * For drivers that require platform data to be provided from the machine |
| 35 | * file, a platform data pointer can also be supplied along with the |
| 36 | * devices names. Usually, the platform data elements that cannot be parsed |
| 37 | * from the device tree by the drivers (example: function pointers) are |
| 38 | * supplied. But it should be noted that this is a temporary mechanism and |
| 39 | * at some point, the drivers should be capable of parsing all the platform |
| 40 | * data from the device tree. |
| 41 | */ |
| 42 | static const struct of_dev_auxdata exynos5250_auxdata_lookup[] __initconst = { |
| 43 | OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS5_PA_UART0, |
| 44 | "exynos4210-uart.0", NULL), |
| 45 | OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS5_PA_UART1, |
| 46 | "exynos4210-uart.1", NULL), |
| 47 | OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS5_PA_UART2, |
| 48 | "exynos4210-uart.2", NULL), |
| 49 | OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS5_PA_UART3, |
| 50 | "exynos4210-uart.3", NULL), |
Thomas Abraham | 380c3a5 | 2012-05-15 15:56:57 +0900 | [diff] [blame] | 51 | OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS5_PA_IIC(0), |
| 52 | "s3c2440-i2c.0", NULL), |
| 53 | OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS5_PA_IIC(1), |
| 54 | "s3c2440-i2c.1", NULL), |
Rahul Sharma | 62a1f83 | 2012-10-29 21:51:47 +0900 | [diff] [blame] | 55 | OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS5_PA_IIC(2), |
| 56 | "s3c2440-i2c.2", NULL), |
Olof Johansson | f5298e0 | 2012-11-21 13:45:52 +0900 | [diff] [blame] | 57 | OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS5_PA_IIC(3), |
| 58 | "s3c2440-i2c.3", NULL), |
| 59 | OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS5_PA_IIC(4), |
| 60 | "s3c2440-i2c.4", NULL), |
| 61 | OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS5_PA_IIC(5), |
| 62 | "s3c2440-i2c.5", NULL), |
| 63 | OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS5_PA_IIC(6), |
| 64 | "s3c2440-i2c.6", NULL), |
| 65 | OF_DEV_AUXDATA("samsung,s3c2440-i2c", EXYNOS5_PA_IIC(7), |
| 66 | "s3c2440-i2c.7", NULL), |
Rahul Sharma | 3e3e9ce | 2012-10-29 21:51:42 +0900 | [diff] [blame] | 67 | OF_DEV_AUXDATA("samsung,s3c2440-hdmiphy-i2c", EXYNOS5_PA_IIC(8), |
| 68 | "s3c2440-hdmiphy-i2c", NULL), |
Thomas Abraham | a5c1777 | 2012-09-26 08:54:42 +0900 | [diff] [blame] | 69 | OF_DEV_AUXDATA("samsung,exynos5250-dw-mshc", EXYNOS5_PA_DWMCI0, |
| 70 | "dw_mmc.0", NULL), |
| 71 | OF_DEV_AUXDATA("samsung,exynos5250-dw-mshc", EXYNOS5_PA_DWMCI1, |
| 72 | "dw_mmc.1", NULL), |
| 73 | OF_DEV_AUXDATA("samsung,exynos5250-dw-mshc", EXYNOS5_PA_DWMCI2, |
| 74 | "dw_mmc.2", NULL), |
| 75 | OF_DEV_AUXDATA("samsung,exynos5250-dw-mshc", EXYNOS5_PA_DWMCI3, |
| 76 | "dw_mmc.3", NULL), |
Thomas Abraham | b0b2781 | 2012-07-14 10:54:31 +0900 | [diff] [blame] | 77 | OF_DEV_AUXDATA("samsung,exynos4210-spi", EXYNOS5_PA_SPI0, |
| 78 | "exynos4210-spi.0", NULL), |
| 79 | OF_DEV_AUXDATA("samsung,exynos4210-spi", EXYNOS5_PA_SPI1, |
| 80 | "exynos4210-spi.1", NULL), |
| 81 | OF_DEV_AUXDATA("samsung,exynos4210-spi", EXYNOS5_PA_SPI2, |
| 82 | "exynos4210-spi.2", NULL), |
Vasanth Ananthan | c47d244 | 2012-11-20 21:02:11 +0900 | [diff] [blame] | 83 | OF_DEV_AUXDATA("samsung,exynos5-sata-ahci", 0x122F0000, |
| 84 | "exynos5-sata", NULL), |
| 85 | OF_DEV_AUXDATA("samsung,exynos5-sata-phy", 0x12170000, |
| 86 | "exynos5-sata-phy", NULL), |
| 87 | OF_DEV_AUXDATA("samsung,exynos5-sata-phy-i2c", 0x121D0000, |
| 88 | "exynos5-sata-phy-i2c", NULL), |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 89 | OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_PDMA0, "dma-pl330.0", NULL), |
| 90 | OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_PDMA1, "dma-pl330.1", NULL), |
Thomas Abraham | 6080622 | 2012-04-10 08:37:59 -0700 | [diff] [blame] | 91 | OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_MDMA1, "dma-pl330.2", NULL), |
Shaik Ameer Basha | 1128658 | 2012-09-07 14:13:08 +0900 | [diff] [blame] | 92 | OF_DEV_AUXDATA("samsung,exynos5-gsc", EXYNOS5_PA_GSC0, |
| 93 | "exynos-gsc.0", NULL), |
| 94 | OF_DEV_AUXDATA("samsung,exynos5-gsc", EXYNOS5_PA_GSC1, |
| 95 | "exynos-gsc.1", NULL), |
| 96 | OF_DEV_AUXDATA("samsung,exynos5-gsc", EXYNOS5_PA_GSC2, |
| 97 | "exynos-gsc.2", NULL), |
| 98 | OF_DEV_AUXDATA("samsung,exynos5-gsc", EXYNOS5_PA_GSC3, |
| 99 | "exynos-gsc.3", NULL), |
Rahul Sharma | 566cf8e | 2012-10-29 21:48:43 +0900 | [diff] [blame] | 100 | OF_DEV_AUXDATA("samsung,exynos5-hdmi", 0x14530000, |
| 101 | "exynos5-hdmi", NULL), |
Rahul Sharma | 5af0d8a | 2012-10-29 21:51:36 +0900 | [diff] [blame] | 102 | OF_DEV_AUXDATA("samsung,exynos5-mixer", 0x14450000, |
| 103 | "exynos5-mixer", NULL), |
Arun Kumar K | 2eae613 | 2012-10-23 22:51:33 +0900 | [diff] [blame] | 104 | OF_DEV_AUXDATA("samsung,mfc-v6", 0x11000000, "s5p-mfc-v6", NULL), |
Amit Daniel Kachhap | ef405e0 | 2012-10-29 21:23:29 +0900 | [diff] [blame] | 105 | OF_DEV_AUXDATA("samsung,exynos5250-tmu", 0x10060000, |
| 106 | "exynos-tmu", NULL), |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 107 | {}, |
| 108 | }; |
| 109 | |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 110 | static const struct of_dev_auxdata exynos5440_auxdata_lookup[] __initconst = { |
| 111 | OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS5440_PA_UART0, |
| 112 | "exynos4210-uart.0", NULL), |
| 113 | {}, |
| 114 | }; |
| 115 | |
| 116 | static void __init exynos5_dt_map_io(void) |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 117 | { |
Doug Anderson | 5b7897d | 2012-11-27 11:53:14 -0800 | [diff] [blame] | 118 | unsigned long root = of_get_flat_dt_root(); |
| 119 | |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 120 | exynos_init_io(NULL, 0); |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 121 | |
Doug Anderson | 5b7897d | 2012-11-27 11:53:14 -0800 | [diff] [blame] | 122 | if (of_flat_dt_is_compatible(root, "samsung,exynos5250")) |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 123 | s3c24xx_init_clocks(24000000); |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 124 | } |
| 125 | |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 126 | static void __init exynos5_dt_machine_init(void) |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 127 | { |
Abhilash Kesavan | 7000fe8 | 2012-11-20 18:20:38 +0900 | [diff] [blame] | 128 | struct device_node *i2c_np; |
| 129 | const char *i2c_compat = "samsung,s3c2440-i2c"; |
| 130 | unsigned int tmp; |
| 131 | |
| 132 | /* |
| 133 | * Exynos5's legacy i2c controller and new high speed i2c |
| 134 | * controller have muxed interrupt sources. By default the |
| 135 | * interrupts for 4-channel HS-I2C controller are enabled. |
| 136 | * If node for first four channels of legacy i2c controller |
| 137 | * are available then re-configure the interrupts via the |
| 138 | * system register. |
| 139 | */ |
| 140 | for_each_compatible_node(i2c_np, NULL, i2c_compat) { |
| 141 | if (of_device_is_available(i2c_np)) { |
| 142 | if (of_alias_get_id(i2c_np, "i2c") < 4) { |
| 143 | tmp = readl(EXYNOS5_SYS_I2C_CFG); |
| 144 | writel(tmp & ~(0x1 << of_alias_get_id(i2c_np, "i2c")), |
| 145 | EXYNOS5_SYS_I2C_CFG); |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 150 | if (of_machine_is_compatible("samsung,exynos5250")) |
| 151 | of_platform_populate(NULL, of_default_bus_match_table, |
| 152 | exynos5250_auxdata_lookup, NULL); |
| 153 | else if (of_machine_is_compatible("samsung,exynos5440")) |
| 154 | of_platform_populate(NULL, of_default_bus_match_table, |
| 155 | exynos5440_auxdata_lookup, NULL); |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 156 | } |
| 157 | |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 158 | static char const *exynos5_dt_compat[] __initdata = { |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 159 | "samsung,exynos5250", |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 160 | "samsung,exynos5440", |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 161 | NULL |
| 162 | }; |
| 163 | |
Arun Kumar K | 2eae613 | 2012-10-23 22:51:33 +0900 | [diff] [blame] | 164 | static void __init exynos5_reserve(void) |
| 165 | { |
Kukjin Kim | ade7ffb | 2012-12-06 17:02:44 +0900 | [diff] [blame^] | 166 | #ifdef CONFIG_S5P_DEV_MFC |
Arun Kumar K | 2eae613 | 2012-10-23 22:51:33 +0900 | [diff] [blame] | 167 | struct s5p_mfc_dt_meminfo mfc_mem; |
| 168 | |
| 169 | /* Reserve memory for MFC only if it's available */ |
| 170 | mfc_mem.compatible = "samsung,mfc-v6"; |
| 171 | if (of_scan_flat_dt(s5p_fdt_find_mfc_mem, &mfc_mem)) |
| 172 | s5p_mfc_reserve_mem(mfc_mem.roff, mfc_mem.rsize, mfc_mem.loff, |
| 173 | mfc_mem.lsize); |
Kukjin Kim | ade7ffb | 2012-12-06 17:02:44 +0900 | [diff] [blame^] | 174 | #endif |
Arun Kumar K | 2eae613 | 2012-10-23 22:51:33 +0900 | [diff] [blame] | 175 | } |
| 176 | |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 177 | DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)") |
| 178 | /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */ |
| 179 | .init_irq = exynos5_init_irq, |
Marc Zyngier | 06853ae | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 180 | .smp = smp_ops(exynos_smp_ops), |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 181 | .map_io = exynos5_dt_map_io, |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 182 | .handle_irq = gic_handle_irq, |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 183 | .init_machine = exynos5_dt_machine_init, |
Shawn Guo | bb13fab | 2012-04-26 10:35:40 +0800 | [diff] [blame] | 184 | .init_late = exynos_init_late, |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 185 | .timer = &exynos4_timer, |
Kukjin Kim | 2edb36c | 2012-11-15 15:48:56 +0900 | [diff] [blame] | 186 | .dt_compat = exynos5_dt_compat, |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 187 | .restart = exynos5_restart, |
Arun Kumar K | 2eae613 | 2012-10-23 22:51:33 +0900 | [diff] [blame] | 188 | .reserve = exynos5_reserve, |
Kukjin Kim | b3e68fb | 2012-02-10 13:13:15 +0900 | [diff] [blame] | 189 | MACHINE_END |