Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/irq.h> |
| 17 | #include <linux/io.h> |
| 18 | #include <asm/hardware/gic.h> |
| 19 | #include <mach/board.h> |
| 20 | #include <mach/msm_iomap.h> |
| 21 | #include <mach/irqs.h> |
| 22 | #include <mach/socinfo.h> |
Rohit Vaswani | f0ce9ae | 2011-08-23 22:18:38 -0700 | [diff] [blame] | 23 | #include <asm/hardware/cache-l2x0.h> |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 24 | #include "devices.h" |
Matt Wagantall | 44f672e | 2011-09-07 20:31:16 -0700 | [diff] [blame] | 25 | #include "acpuclock.h" |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 26 | |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 27 | /* Address of GSBI blocks */ |
| 28 | #define MSM_GSBI1_PHYS 0x16000000 |
| 29 | #define MSM_GSBI2_PHYS 0x16100000 |
| 30 | #define MSM_GSBI3_PHYS 0x16200000 |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 31 | #define MSM_GSBI4_PHYS 0x16300000 |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 32 | #define MSM_GSBI5_PHYS 0x16400000 |
| 33 | |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 34 | #define MSM_UART4DM_PHYS (MSM_GSBI4_PHYS + 0x40000) |
| 35 | |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 36 | /* GSBI QUP devices */ |
| 37 | #define MSM_GSBI1_QUP_PHYS (MSM_GSBI1_PHYS + 0x80000) |
| 38 | #define MSM_GSBI2_QUP_PHYS (MSM_GSBI2_PHYS + 0x80000) |
| 39 | #define MSM_GSBI3_QUP_PHYS (MSM_GSBI3_PHYS + 0x80000) |
| 40 | #define MSM_GSBI4_QUP_PHYS (MSM_GSBI4_PHYS + 0x80000) |
| 41 | #define MSM_GSBI5_QUP_PHYS (MSM_GSBI5_PHYS + 0x80000) |
| 42 | #define MSM_QUP_SIZE SZ_4K |
| 43 | |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame] | 44 | /* Address of SSBI CMD */ |
| 45 | #define MSM_PMIC1_SSBI_CMD_PHYS 0x00500000 |
| 46 | #define MSM_PMIC_SSBI_SIZE SZ_4K |
| 47 | |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 48 | static struct resource resources_uart_gsbi4[] = { |
| 49 | { |
| 50 | .start = GSBI4_UARTDM_IRQ, |
| 51 | .end = GSBI4_UARTDM_IRQ, |
| 52 | .flags = IORESOURCE_IRQ, |
| 53 | }, |
| 54 | { |
| 55 | .start = MSM_UART4DM_PHYS, |
| 56 | .end = MSM_UART4DM_PHYS + PAGE_SIZE - 1, |
| 57 | .name = "uartdm_resource", |
| 58 | .flags = IORESOURCE_MEM, |
| 59 | }, |
| 60 | { |
| 61 | .start = MSM_GSBI4_PHYS, |
| 62 | .end = MSM_GSBI4_PHYS + PAGE_SIZE - 1, |
| 63 | .name = "gsbi_resource", |
| 64 | .flags = IORESOURCE_MEM, |
| 65 | }, |
| 66 | }; |
| 67 | |
| 68 | struct platform_device msm9615_device_uart_gsbi4 = { |
| 69 | .name = "msm_serial_hsl", |
| 70 | .id = 0, |
| 71 | .num_resources = ARRAY_SIZE(resources_uart_gsbi4), |
| 72 | .resource = resources_uart_gsbi4, |
| 73 | }; |
| 74 | |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 75 | static struct resource resources_qup_i2c_gsbi5[] = { |
| 76 | { |
| 77 | .name = "gsbi_qup_i2c_addr", |
| 78 | .start = MSM_GSBI5_PHYS, |
| 79 | .end = MSM_GSBI5_PHYS + MSM_QUP_SIZE - 1, |
| 80 | .flags = IORESOURCE_MEM, |
| 81 | }, |
| 82 | { |
| 83 | .name = "qup_phys_addr", |
| 84 | .start = MSM_GSBI5_QUP_PHYS, |
| 85 | .end = MSM_GSBI5_QUP_PHYS + 4 - 1, |
| 86 | .flags = IORESOURCE_MEM, |
| 87 | }, |
| 88 | { |
| 89 | .name = "qup_err_intr", |
| 90 | .start = GSBI5_QUP_IRQ, |
| 91 | .end = GSBI5_QUP_IRQ, |
| 92 | .flags = IORESOURCE_IRQ, |
| 93 | }, |
| 94 | }; |
| 95 | |
| 96 | struct platform_device msm9615_device_qup_i2c_gsbi5 = { |
| 97 | .name = "qup_i2c", |
| 98 | .id = 0, |
| 99 | .num_resources = ARRAY_SIZE(resources_qup_i2c_gsbi5), |
| 100 | .resource = resources_qup_i2c_gsbi5, |
| 101 | }; |
| 102 | |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 103 | static struct resource resources_qup_spi_gsbi3[] = { |
| 104 | { |
| 105 | .name = "spi_base", |
| 106 | .start = MSM_GSBI3_QUP_PHYS, |
| 107 | .end = MSM_GSBI3_QUP_PHYS + SZ_4K - 1, |
| 108 | .flags = IORESOURCE_MEM, |
| 109 | }, |
| 110 | { |
| 111 | .name = "gsbi_base", |
| 112 | .start = MSM_GSBI3_PHYS, |
| 113 | .end = MSM_GSBI3_PHYS + 4 - 1, |
| 114 | .flags = IORESOURCE_MEM, |
| 115 | }, |
| 116 | { |
| 117 | .name = "spi_irq_in", |
| 118 | .start = GSBI3_QUP_IRQ, |
| 119 | .end = GSBI3_QUP_IRQ, |
| 120 | .flags = IORESOURCE_IRQ, |
| 121 | }, |
| 122 | }; |
| 123 | |
| 124 | struct platform_device msm9615_device_qup_spi_gsbi3 = { |
| 125 | .name = "spi_qsd", |
| 126 | .id = 0, |
| 127 | .num_resources = ARRAY_SIZE(resources_qup_spi_gsbi3), |
| 128 | .resource = resources_qup_spi_gsbi3, |
| 129 | }; |
| 130 | |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame] | 131 | static struct resource resources_ssbi_pmic1[] = { |
| 132 | { |
| 133 | .start = MSM_PMIC1_SSBI_CMD_PHYS, |
| 134 | .end = MSM_PMIC1_SSBI_CMD_PHYS + MSM_PMIC_SSBI_SIZE - 1, |
| 135 | .flags = IORESOURCE_MEM, |
| 136 | }, |
| 137 | }; |
| 138 | |
| 139 | struct platform_device msm9615_device_ssbi_pmic1 = { |
| 140 | .name = "msm_ssbi", |
| 141 | .id = 0, |
| 142 | .resource = resources_ssbi_pmic1, |
| 143 | .num_resources = ARRAY_SIZE(resources_ssbi_pmic1), |
| 144 | }; |
| 145 | |
Rohit Vaswani | f0ce9ae | 2011-08-23 22:18:38 -0700 | [diff] [blame] | 146 | #ifdef CONFIG_CACHE_L2X0 |
| 147 | static int __init l2x0_cache_init(void) |
| 148 | { |
| 149 | int aux_ctrl = 0; |
| 150 | |
| 151 | /* Way Size 010(0x2) 32KB */ |
| 152 | aux_ctrl = (0x1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) | \ |
| 153 | (0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) | \ |
| 154 | (0x1 << L2X0_AUX_CTRL_EVNT_MON_BUS_EN_SHIFT); |
| 155 | |
| 156 | /* L2 Latency setting required by hardware. Default is 0x20 |
| 157 | which is no good. |
| 158 | */ |
| 159 | writel_relaxed(0x220, MSM_L2CC_BASE + L2X0_DATA_LATENCY_CTRL); |
| 160 | l2x0_init(MSM_L2CC_BASE, aux_ctrl, L2X0_AUX_CTRL_MASK); |
| 161 | |
| 162 | return 0; |
| 163 | } |
| 164 | #else |
| 165 | static int __init l2x0_cache_init(void){ return 0; } |
| 166 | #endif |
| 167 | |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 168 | void __init msm9615_device_init(void) |
| 169 | { |
| 170 | if (socinfo_init() < 0) |
| 171 | pr_err("socinfo_init() failed!\n"); |
| 172 | |
Vikram Mulukutla | 489e39e | 2011-08-31 18:04:05 -0700 | [diff] [blame] | 173 | msm_clock_init(&msm9615_clock_init_data); |
Matt Wagantall | 44f672e | 2011-09-07 20:31:16 -0700 | [diff] [blame] | 174 | acpuclk_init(&acpuclk_9615_soc_data); |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | void __init msm9615_map_io(void) |
| 178 | { |
| 179 | msm_map_msm9615_io(); |
Rohit Vaswani | f0ce9ae | 2011-08-23 22:18:38 -0700 | [diff] [blame] | 180 | l2x0_cache_init(); |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | void __init msm9615_init_irq(void) |
| 184 | { |
| 185 | unsigned int i; |
| 186 | gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE, |
| 187 | (void *)MSM_QGIC_CPU_BASE); |
| 188 | |
| 189 | /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */ |
| 190 | writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4); |
| 191 | |
| 192 | writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET); |
| 193 | mb(); |
| 194 | |
| 195 | /* |
| 196 | * FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet |
| 197 | * as they are configured as level, which does not play nice with |
| 198 | * handle_percpu_irq. |
| 199 | */ |
| 200 | for (i = GIC_PPI_START; i < GIC_SPI_START; i++) { |
| 201 | if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE) |
| 202 | irq_set_handler(i, handle_percpu_irq); |
| 203 | } |
| 204 | } |