Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* linux/arch/arm/mach-msm/board-swordfish.c |
| 2 | * |
| 3 | * Copyright (C) 2009 Google, Inc. |
| 4 | * Author: Brian Swetland <swetland@google.com> |
| 5 | * |
| 6 | * This software is licensed under the terms of the GNU General Public |
| 7 | * License version 2, as published by the Free Software Foundation, and |
| 8 | * may be copied, distributed, and modified under those terms. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/platform_device.h> |
| 20 | #include <linux/io.h> |
| 21 | #include <linux/delay.h> |
| 22 | #include <linux/fs.h> |
| 23 | #include <linux/android_pmem.h> |
Jordan Crouse | 914de9b | 2012-07-09 13:49:46 -0600 | [diff] [blame] | 24 | #include <mach/kgsl.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 25 | |
| 26 | #include <mach/hardware.h> |
| 27 | #include <asm/mach-types.h> |
| 28 | #include <asm/mach/arch.h> |
| 29 | #include <asm/mach/map.h> |
| 30 | #include <asm/setup.h> |
| 31 | |
| 32 | #include <mach/board.h> |
| 33 | #include <mach/irqs.h> |
| 34 | #include <mach/msm_iomap.h> |
| 35 | #include <mach/msm_hsusb.h> |
| 36 | #include <mach/msm_ts.h> |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 37 | #include <mach/proc_comm.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 38 | #include <linux/usb/android_composite.h> |
| 39 | |
| 40 | #include "board-swordfish.h" |
| 41 | #include "devices.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 42 | |
| 43 | extern int swordfish_init_mmc(void); |
| 44 | |
| 45 | static struct resource smc91x_resources[] = { |
| 46 | [0] = { |
| 47 | .start = 0x70000300, |
| 48 | .end = 0x70000400, |
| 49 | .flags = IORESOURCE_MEM, |
| 50 | }, |
| 51 | [1] = { |
| 52 | .start = MSM_GPIO_TO_INT(156), |
| 53 | .end = MSM_GPIO_TO_INT(156), |
| 54 | .flags = IORESOURCE_IRQ, |
| 55 | }, |
| 56 | }; |
| 57 | |
| 58 | static struct platform_device smc91x_device = { |
| 59 | .name = "smc91x", |
| 60 | .id = 0, |
| 61 | .num_resources = ARRAY_SIZE(smc91x_resources), |
| 62 | .resource = smc91x_resources, |
| 63 | }; |
| 64 | |
| 65 | static int swordfish_phy_init_seq[] = { |
| 66 | 0x0C, 0x31, |
| 67 | 0x1D, 0x0D, |
| 68 | 0x1D, 0x10, |
| 69 | -1 |
| 70 | }; |
| 71 | |
| 72 | static void swordfish_usb_phy_reset(void) |
| 73 | { |
| 74 | u32 id; |
| 75 | int ret; |
| 76 | |
| 77 | id = PCOM_CLKRGM_APPS_RESET_USB_PHY; |
| 78 | ret = msm_proc_comm(PCOM_CLK_REGIME_SEC_RESET_ASSERT, &id, NULL); |
| 79 | if (ret) { |
| 80 | pr_err("%s: Cannot assert (%d)\n", __func__, ret); |
| 81 | return; |
| 82 | } |
| 83 | |
| 84 | msleep(1); |
| 85 | |
| 86 | id = PCOM_CLKRGM_APPS_RESET_USB_PHY; |
| 87 | ret = msm_proc_comm(PCOM_CLK_REGIME_SEC_RESET_DEASSERT, &id, NULL); |
| 88 | if (ret) { |
| 89 | pr_err("%s: Cannot assert (%d)\n", __func__, ret); |
| 90 | return; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | static void swordfish_usb_hw_reset(bool enable) |
| 95 | { |
| 96 | u32 id; |
| 97 | int ret; |
| 98 | u32 func; |
| 99 | |
| 100 | id = PCOM_CLKRGM_APPS_RESET_USBH; |
| 101 | if (enable) |
| 102 | func = PCOM_CLK_REGIME_SEC_RESET_ASSERT; |
| 103 | else |
| 104 | func = PCOM_CLK_REGIME_SEC_RESET_DEASSERT; |
| 105 | ret = msm_proc_comm(func, &id, NULL); |
| 106 | if (ret) |
| 107 | pr_err("%s: Cannot set reset to %d (%d)\n", __func__, enable, |
| 108 | ret); |
| 109 | } |
| 110 | |
| 111 | |
| 112 | static struct msm_hsusb_platform_data msm_hsusb_pdata = { |
| 113 | .phy_init_seq = swordfish_phy_init_seq, |
| 114 | .phy_reset = swordfish_usb_phy_reset, |
| 115 | .hw_reset = swordfish_usb_hw_reset, |
| 116 | }; |
| 117 | |
| 118 | static struct usb_mass_storage_platform_data mass_storage_pdata = { |
| 119 | .nluns = 1, |
| 120 | .vendor = "Qualcomm", |
| 121 | .product = "Swordfish", |
| 122 | .release = 0x0100, |
| 123 | }; |
| 124 | |
| 125 | static struct platform_device usb_mass_storage_device = { |
| 126 | .name = "usb_mass_storage", |
| 127 | .id = -1, |
| 128 | .dev = { |
| 129 | .platform_data = &mass_storage_pdata, |
| 130 | }, |
| 131 | }; |
| 132 | |
| 133 | static struct resource msm_kgsl_resources[] = { |
| 134 | { |
| 135 | .name = "kgsl_reg_memory", |
| 136 | .start = MSM_GPU_REG_PHYS, |
| 137 | .end = MSM_GPU_REG_PHYS + MSM_GPU_REG_SIZE - 1, |
| 138 | .flags = IORESOURCE_MEM, |
| 139 | }, |
| 140 | { |
| 141 | .name = "kgsl_phys_memory", |
| 142 | .start = MSM_GPU_MEM_BASE, |
| 143 | .end = MSM_GPU_MEM_BASE + MSM_GPU_MEM_SIZE - 1, |
| 144 | .flags = IORESOURCE_MEM, |
| 145 | }, |
| 146 | { |
| 147 | .start = INT_GRAPHICS, |
| 148 | .end = INT_GRAPHICS, |
| 149 | .flags = IORESOURCE_IRQ, |
| 150 | }, |
| 151 | }; |
| 152 | |
| 153 | static struct platform_device msm_kgsl_device = { |
| 154 | .name = "kgsl", |
| 155 | .id = -1, |
| 156 | .resource = msm_kgsl_resources, |
| 157 | .num_resources = ARRAY_SIZE(msm_kgsl_resources), |
| 158 | }; |
| 159 | |
| 160 | static struct android_pmem_platform_data mdp_pmem_pdata = { |
| 161 | .name = "pmem", |
| 162 | .start = MSM_PMEM_MDP_BASE, |
| 163 | .size = MSM_PMEM_MDP_SIZE, |
| 164 | .no_allocator = 0, |
| 165 | .cached = 1, |
| 166 | }; |
| 167 | |
| 168 | static struct android_pmem_platform_data android_pmem_gpu0_pdata = { |
| 169 | .name = "pmem_gpu0", |
| 170 | .start = MSM_PMEM_GPU0_BASE, |
| 171 | .size = MSM_PMEM_GPU0_SIZE, |
| 172 | .no_allocator = 0, |
| 173 | .cached = 0, |
| 174 | }; |
| 175 | |
| 176 | static struct android_pmem_platform_data android_pmem_gpu1_pdata = { |
| 177 | .name = "pmem_gpu1", |
| 178 | .start = MSM_PMEM_GPU1_BASE, |
| 179 | .size = MSM_PMEM_GPU1_SIZE, |
| 180 | .no_allocator = 0, |
| 181 | .cached = 0, |
| 182 | }; |
| 183 | |
| 184 | static struct android_pmem_platform_data android_pmem_adsp_pdata = { |
| 185 | .name = "pmem_adsp", |
| 186 | .start = MSM_PMEM_ADSP_BASE, |
| 187 | .size = MSM_PMEM_ADSP_SIZE, |
| 188 | .no_allocator = 0, |
| 189 | .cached = 0, |
| 190 | }; |
| 191 | |
| 192 | static struct platform_device android_pmem_mdp_device = { |
| 193 | .name = "android_pmem", |
| 194 | .id = 0, |
| 195 | .dev = { |
| 196 | .platform_data = &mdp_pmem_pdata |
| 197 | }, |
| 198 | }; |
| 199 | |
| 200 | static struct platform_device android_pmem_adsp_device = { |
| 201 | .name = "android_pmem", |
| 202 | .id = 1, |
| 203 | .dev = { |
| 204 | .platform_data = &android_pmem_adsp_pdata, |
| 205 | }, |
| 206 | }; |
| 207 | |
| 208 | static struct platform_device android_pmem_gpu0_device = { |
| 209 | .name = "android_pmem", |
| 210 | .id = 2, |
| 211 | .dev = { |
| 212 | .platform_data = &android_pmem_gpu0_pdata, |
| 213 | }, |
| 214 | }; |
| 215 | |
| 216 | static struct platform_device android_pmem_gpu1_device = { |
| 217 | .name = "android_pmem", |
| 218 | .id = 3, |
| 219 | .dev = { |
| 220 | .platform_data = &android_pmem_gpu1_pdata, |
| 221 | }, |
| 222 | }; |
| 223 | |
| 224 | static char *usb_functions[] = { "usb_mass_storage" }; |
| 225 | static char *usb_functions_adb[] = { "usb_mass_storage", "adb" }; |
| 226 | |
| 227 | static struct android_usb_product usb_products[] = { |
| 228 | { |
| 229 | .product_id = 0x0c01, |
| 230 | .num_functions = ARRAY_SIZE(usb_functions), |
| 231 | .functions = usb_functions, |
| 232 | }, |
| 233 | { |
| 234 | .product_id = 0x0c02, |
| 235 | .num_functions = ARRAY_SIZE(usb_functions_adb), |
| 236 | .functions = usb_functions_adb, |
| 237 | }, |
| 238 | }; |
| 239 | |
| 240 | static struct android_usb_platform_data android_usb_pdata = { |
| 241 | .vendor_id = 0x18d1, |
| 242 | .product_id = 0x0d01, |
| 243 | .version = 0x0100, |
| 244 | .serial_number = "42", |
| 245 | .product_name = "Swordfishdroid", |
| 246 | .manufacturer_name = "Qualcomm", |
| 247 | .num_products = ARRAY_SIZE(usb_products), |
| 248 | .products = usb_products, |
| 249 | .num_functions = ARRAY_SIZE(usb_functions_adb), |
| 250 | .functions = usb_functions_adb, |
| 251 | }; |
| 252 | |
| 253 | static struct platform_device android_usb_device = { |
| 254 | .name = "android_usb", |
| 255 | .id = -1, |
| 256 | .dev = { |
| 257 | .platform_data = &android_usb_pdata, |
| 258 | }, |
| 259 | }; |
| 260 | |
| 261 | static struct platform_device fish_battery_device = { |
| 262 | .name = "fish_battery", |
| 263 | }; |
| 264 | |
| 265 | static struct msm_ts_platform_data swordfish_ts_pdata = { |
| 266 | .min_x = 296, |
| 267 | .max_x = 3800, |
| 268 | .min_y = 296, |
| 269 | .max_y = 3800, |
| 270 | .min_press = 0, |
| 271 | .max_press = 256, |
| 272 | .inv_x = 4096, |
| 273 | .inv_y = 4096, |
| 274 | }; |
| 275 | |
| 276 | static struct platform_device *devices[] __initdata = { |
| 277 | #if !defined(CONFIG_MSM_SERIAL_DEBUGGER) |
| 278 | &msm_device_uart3, |
| 279 | #endif |
| 280 | &msm_device_smd, |
| 281 | &msm_device_dmov, |
| 282 | &msm_device_nand, |
| 283 | &msm_device_hsusb, |
| 284 | &usb_mass_storage_device, |
| 285 | &android_usb_device, |
| 286 | &fish_battery_device, |
| 287 | &smc91x_device, |
| 288 | &msm_device_touchscreen, |
| 289 | &android_pmem_mdp_device, |
| 290 | &android_pmem_adsp_device, |
| 291 | &android_pmem_gpu0_device, |
| 292 | &android_pmem_gpu1_device, |
| 293 | &msm_kgsl_device, |
| 294 | }; |
| 295 | |
| 296 | extern struct sys_timer msm_timer; |
| 297 | |
| 298 | static struct msm_acpu_clock_platform_data swordfish_clock_data = { |
| 299 | .acpu_switch_time_us = 20, |
| 300 | .max_speed_delta_khz = 256000, |
| 301 | .vdd_switch_time_us = 62, |
| 302 | .power_collapse_khz = 128000000, |
| 303 | .wait_for_irq_khz = 128000000, |
| 304 | }; |
| 305 | |
| 306 | void msm_serial_debug_init(unsigned int base, int irq, |
| 307 | struct device *clk_device, int signal_irq); |
| 308 | |
| 309 | static void __init swordfish_init(void) |
| 310 | { |
| 311 | int rc; |
| 312 | |
| 313 | msm_acpu_clock_init(&swordfish_clock_data); |
| 314 | #if defined(CONFIG_MSM_SERIAL_DEBUGGER) |
| 315 | msm_serial_debug_init(MSM_UART3_PHYS, INT_UART3, |
| 316 | &msm_device_uart3.dev, 1); |
| 317 | #endif |
| 318 | msm_device_hsusb.dev.platform_data = &msm_hsusb_pdata; |
| 319 | msm_device_touchscreen.dev.platform_data = &swordfish_ts_pdata; |
| 320 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 321 | msm_hsusb_set_vbus_state(1); |
| 322 | rc = swordfish_init_mmc(); |
| 323 | if (rc) |
| 324 | pr_crit("%s: MMC init failure (%d)\n", __func__, rc); |
| 325 | } |
| 326 | |
| 327 | static void __init swordfish_fixup(struct machine_desc *desc, struct tag *tags, |
| 328 | char **cmdline, struct meminfo *mi) |
| 329 | { |
| 330 | mi->nr_banks = 1; |
| 331 | mi->bank[0].start = PHYS_OFFSET; |
| 332 | mi->bank[0].node = PHYS_TO_NID(PHYS_OFFSET); |
| 333 | mi->bank[0].size = (101*1024*1024); |
| 334 | } |
| 335 | |
| 336 | static void __init swordfish_map_io(void) |
| 337 | { |
| 338 | msm_map_qsd8x50_io(); |
| 339 | msm_clock_init(msm_clocks_8x50, msm_num_clocks_8x50); |
| 340 | } |
| 341 | |
| 342 | MACHINE_START(SWORDFISH, "Swordfish Board (QCT SURF8250)") |
| 343 | #ifdef CONFIG_MSM_DEBUG_UART |
| 344 | .phys_io = MSM_DEBUG_UART_PHYS, |
| 345 | .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc, |
| 346 | #endif |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 347 | .atag_offset = 0x100, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 348 | .fixup = swordfish_fixup, |
| 349 | .map_io = swordfish_map_io, |
| 350 | .init_irq = msm_init_irq, |
| 351 | .init_machine = swordfish_init, |
| 352 | .timer = &msm_timer, |
| 353 | MACHINE_END |
| 354 | |
| 355 | MACHINE_START(QSD8X50_FFA, "qsd8x50 FFA Board (QCT FFA8250)") |
| 356 | #ifdef CONFIG_MSM_DEBUG_UART |
| 357 | .phys_io = MSM_DEBUG_UART_PHYS, |
| 358 | .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc, |
| 359 | #endif |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 360 | .atag_offset = 0x100, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 361 | .fixup = swordfish_fixup, |
| 362 | .map_io = swordfish_map_io, |
| 363 | .init_irq = msm_init_irq, |
| 364 | .init_machine = swordfish_init, |
| 365 | .timer = &msm_timer, |
| 366 | MACHINE_END |