blob: 52444342dccc774e035e989a618cee7a29721615 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2010-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#include <linux/kernel.h>
14#include <linux/irq.h>
15#include <linux/gpio.h>
16#include <linux/platform_device.h>
17#include <linux/delay.h>
18#include <linux/io.h>
19#include <linux/mfd/pmic8058.h>
20#include <linux/regulator/pmic8058-regulator.h>
21#include <linux/i2c.h>
22#include <linux/dma-mapping.h>
23#include <linux/dmapool.h>
24#include <linux/regulator/pm8058-xo.h>
25
26#include <asm/mach-types.h>
27#include <asm/mach/arch.h>
28#include <asm/setup.h>
29
30#include <mach/mpp.h>
31#include <mach/board.h>
32#include <mach/memory.h>
33#include <mach/msm_iomap.h>
34#include <mach/dma.h>
35#include <mach/sirc.h>
36#include <mach/pmic.h>
37
38#include <mach/vreg.h>
39#include <mach/socinfo.h>
40#include "devices.h"
41#include "timer.h"
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070042#include "acpuclock.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070043#include "pm.h"
44#include "spm.h"
45#include <linux/regulator/consumer.h>
46#include <linux/regulator/machine.h>
47#include <linux/msm_adc.h>
48#include <linux/pmic8058-xoadc.h>
49#include <linux/m_adcproc.h>
50#include <linux/platform_data/qcom_crypto_device.h>
51
52#define PMIC_GPIO_INT 144
53#define PMIC_VREG_WLAN_LEVEL 2900
54#define PMIC_GPIO_SD_DET 165
55
56#define GPIO_EPHY_RST_N 37
57
58#define GPIO_GRFC_FTR0_0 136 /* GRFC 20 */
59#define GPIO_GRFC_FTR0_1 137 /* GRFC 21 */
60#define GPIO_GRFC_FTR1_0 145 /* GRFC 22 */
61#define GPIO_GRFC_FTR1_1 93 /* GRFC 19 */
62#define GPIO_GRFC_2 110
63#define GPIO_GRFC_3 109
64#define GPIO_GRFC_4 108
65#define GPIO_GRFC_5 107
66#define GPIO_GRFC_6 106
67#define GPIO_GRFC_7 105
68#define GPIO_GRFC_8 104
69#define GPIO_GRFC_9 103
70#define GPIO_GRFC_10 102
71#define GPIO_GRFC_11 101
72#define GPIO_GRFC_13 99
73#define GPIO_GRFC_14 98
74#define GPIO_GRFC_15 97
75#define GPIO_GRFC_16 96
76#define GPIO_GRFC_17 95
77#define GPIO_GRFC_18 94
78#define GPIO_GRFC_24 150
79#define GPIO_GRFC_25 151
80#define GPIO_GRFC_26 152
81#define GPIO_GRFC_27 153
82#define GPIO_GRFC_28 154
83#define GPIO_GRFC_29 155
84
Rohit Vaswani26512de2011-07-11 16:01:13 -070085#define GPIO_USER_FIRST 58
86#define GPIO_USER_LAST 63
87
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070088#define FPGA_SDCC_STATUS 0x8E0001A8
89
90/* Macros assume PMIC GPIOs start at 0 */
91#define PM8058_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio + NR_MSM_GPIOS)
92#define PM8058_GPIO_SYS_TO_PM(sys_gpio) (sys_gpio - NR_MSM_GPIOS)
93
94#define PMIC_GPIO_5V_PA_PWR 21 /* PMIC GPIO Number 22 */
95#define PMIC_GPIO_4_2V_PA_PWR 22 /* PMIC GPIO Number 23 */
96#define PMIC_MPP_3 2 /* PMIC MPP Number 3 */
97#define PMIC_MPP_6 5 /* PMIC MPP Number 6 */
98#define PMIC_MPP_7 6 /* PMIC MPP Number 7 */
99#define PMIC_MPP_10 9 /* PMIC MPP Number 10 */
100
101/*
102 * PM8058
103 */
104
105static int pm8058_gpios_init(void)
106{
107 int i;
108 int rc;
109 struct pm8058_gpio_cfg {
110 int gpio;
111 struct pm8058_gpio cfg;
112 };
113
114 struct pm8058_gpio_cfg gpio_cfgs[] = {
115 { /* 5V PA Power */
116 PMIC_GPIO_5V_PA_PWR,
117 {
118 .vin_sel = 0,
119 .direction = PM_GPIO_DIR_BOTH,
120 .output_value = 1,
121 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
122 .pull = PM_GPIO_PULL_DN,
123 .out_strength = PM_GPIO_STRENGTH_HIGH,
124 .function = PM_GPIO_FUNC_NORMAL,
125 .inv_int_pol = 0,
126 },
127 },
128 { /* 4.2V PA Power */
129 PMIC_GPIO_4_2V_PA_PWR,
130 {
131 .vin_sel = 0,
132 .direction = PM_GPIO_DIR_BOTH,
133 .output_value = 1,
134 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
135 .pull = PM_GPIO_PULL_DN,
136 .out_strength = PM_GPIO_STRENGTH_HIGH,
137 .function = PM_GPIO_FUNC_NORMAL,
138 .inv_int_pol = 0,
139 },
140 },
141 };
142
143 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
144 rc = pm8058_gpio_config(gpio_cfgs[i].gpio, &gpio_cfgs[i].cfg);
145 if (rc < 0) {
146 pr_err("%s pmic gpio config failed\n", __func__);
147 return rc;
148 }
149 }
150
151 return 0;
152}
153
154static int pm8058_mpps_init(void)
155{
156 int rc;
157
158 /* Set up MPP 3 and 6 as analog outputs at 1.25V */
159 rc = pm8058_mpp_config_analog_output(PMIC_MPP_3,
160 PM_MPP_AOUT_LVL_1V25_2, PM_MPP_AOUT_CTL_ENABLE);
161 if (rc) {
162 pr_err("%s: Config mpp3 on pmic 8058 failed\n", __func__);
163 return rc;
164 }
165
166 rc = pm8058_mpp_config_analog_output(PMIC_MPP_6,
167 PM_MPP_AOUT_LVL_1V25_2, PM_MPP_AOUT_CTL_ENABLE);
168 if (rc) {
169 pr_err("%s: Config mpp5 on pmic 8058 failed\n", __func__);
170 return rc;
171 }
172 return 0;
173}
174
175static struct pm8058_gpio_platform_data pm8058_gpio_data = {
176 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
177 .irq_base = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, 0),
178 .init = pm8058_gpios_init,
179};
180
181static struct pm8058_gpio_platform_data pm8058_mpp_data = {
182 .gpio_base = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS),
183 .irq_base = PM8058_MPP_IRQ(PMIC8058_IRQ_BASE, 0),
184 .init = pm8058_mpps_init,
185};
186
187static struct regulator_consumer_supply pm8058_vreg_supply[PM8058_VREG_MAX] = {
188 [PM8058_VREG_ID_L3] = REGULATOR_SUPPLY("8058_l3", NULL),
189 [PM8058_VREG_ID_L8] = REGULATOR_SUPPLY("8058_l8", NULL),
190 [PM8058_VREG_ID_L9] = REGULATOR_SUPPLY("8058_l9", NULL),
191 [PM8058_VREG_ID_L14] = REGULATOR_SUPPLY("8058_l14", NULL),
192 [PM8058_VREG_ID_L15] = REGULATOR_SUPPLY("8058_l15", NULL),
193 [PM8058_VREG_ID_L18] = REGULATOR_SUPPLY("8058_l18", NULL),
194 [PM8058_VREG_ID_S4] = REGULATOR_SUPPLY("8058_s4", NULL),
195
196 [PM8058_VREG_ID_LVS0] = REGULATOR_SUPPLY("8058_lvs0", NULL),
197};
198
199#define PM8058_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
200 _always_on, _pull_down) \
201 [_id] = { \
202 .init_data = { \
203 .constraints = { \
204 .valid_modes_mask = _modes, \
205 .valid_ops_mask = _ops, \
206 .min_uV = _min_uV, \
207 .max_uV = _max_uV, \
208 .apply_uV = _apply_uV, \
209 .always_on = _always_on, \
210 }, \
211 .num_consumer_supplies = 1, \
212 .consumer_supplies = &pm8058_vreg_supply[_id], \
213 }, \
214 .pull_down_enable = _pull_down, \
215 .pin_ctrl = 0, \
216 .pin_fn = PM8058_VREG_PIN_FN_ENABLE, \
217 }
218
219#define PM8058_VREG_INIT_LDO(_id, _min_uV, _max_uV) \
220 PM8058_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL | \
221 REGULATOR_MODE_IDLE | REGULATOR_MODE_STANDBY, \
222 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS | \
223 REGULATOR_CHANGE_MODE, 1, 1, 1)
224
225#define PM8058_VREG_INIT_SMPS(_id, _min_uV, _max_uV) \
226 PM8058_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL | \
227 REGULATOR_MODE_IDLE | REGULATOR_MODE_STANDBY, \
228 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS | \
229 REGULATOR_CHANGE_MODE, 1, 1, 1)
230
231#define PM8058_VREG_INIT_LVS(_id, _min_uV, _max_uV) \
232 PM8058_VREG_INIT(_id, _min_uV, _min_uV, REGULATOR_MODE_NORMAL, \
233 REGULATOR_CHANGE_STATUS, 0, 0, 1)
234
235static struct pm8058_vreg_pdata pm8058_vreg_init[PM8058_VREG_MAX] = {
236 PM8058_VREG_INIT_LDO(PM8058_VREG_ID_L3, 1800000, 1800000),
237 PM8058_VREG_INIT_LDO(PM8058_VREG_ID_L8, 2200000, 2200000),
238 PM8058_VREG_INIT_LDO(PM8058_VREG_ID_L9, 2050000, 2050000),
239 PM8058_VREG_INIT_LDO(PM8058_VREG_ID_L14, 2850000, 2850000),
240 PM8058_VREG_INIT_LDO(PM8058_VREG_ID_L15, 2200000, 2200000),
241 PM8058_VREG_INIT_LDO(PM8058_VREG_ID_L18, 2200000, 2200000),
242 PM8058_VREG_INIT_LVS(PM8058_VREG_ID_LVS0, 1800000, 1800000),
243 PM8058_VREG_INIT_SMPS(PM8058_VREG_ID_S4, 1300000, 1300000),
244};
245
246#define PM8058_VREG(_id) { \
247 .name = "pm8058-regulator", \
248 .id = _id, \
249 .platform_data = &pm8058_vreg_init[_id], \
250}
251
252#ifdef CONFIG_SENSORS_MSM_ADC
253static struct resource resources_adc[] = {
254 {
255 .start = PM8058_ADC_IRQ(PMIC8058_IRQ_BASE),
256 .end = PM8058_ADC_IRQ(PMIC8058_IRQ_BASE),
257 .flags = IORESOURCE_IRQ,
258 },
259};
260
261static struct adc_access_fn xoadc_fn = {
262 pm8058_xoadc_select_chan_and_start_conv,
263 pm8058_xoadc_read_adc_code,
264 pm8058_xoadc_get_properties,
265 pm8058_xoadc_slot_request,
266 pm8058_xoadc_restore_slot,
267 pm8058_xoadc_calibrate,
268};
269
270static struct msm_adc_channels msm_adc_channels_data[] = {
271 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
272 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
273 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
274 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
275 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
276 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
277 {"fsm_therm", CHANNEL_ADC_FSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE6,
278 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
279 {"pa_therm", CHANNEL_ADC_PA_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
280 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
281};
282
283static struct msm_adc_platform_data msm_adc_pdata = {
284 .channel = msm_adc_channels_data,
285 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
286 .target_hw = FSM_9xxx,
287};
288
289static struct platform_device msm_adc_device = {
290 .name = "msm_adc",
291 .id = -1,
292 .dev = {
293 .platform_data = &msm_adc_pdata,
294 },
295};
296
297static void pmic8058_xoadc_mpp_config(void)
298{
299 int rc;
300
301 rc = pm8058_mpp_config_analog_input(XOADC_MPP_7,
302 PM_MPP_AIN_AMUX_CH5, PM_MPP_AOUT_CTL_DISABLE);
303 if (rc)
304 pr_err("%s: Config mpp7 on pmic 8058 failed\n", __func__);
305
306 rc = pm8058_mpp_config_analog_input(XOADC_MPP_10,
307 PM_MPP_AIN_AMUX_CH6, PM_MPP_AOUT_CTL_DISABLE);
308 if (rc)
309 pr_err("%s: Config mpp10 on pmic 8058 failed\n", __func__);
310}
311
312static struct regulator *vreg_ldo18_adc;
313
314static int pmic8058_xoadc_vreg_config(int on)
315{
316 int rc;
317
318 if (on) {
319 rc = regulator_enable(vreg_ldo18_adc);
320 if (rc)
321 pr_err("%s: Enable of regulator ldo18_adc "
322 "failed\n", __func__);
323 } else {
324 rc = regulator_disable(vreg_ldo18_adc);
325 if (rc)
326 pr_err("%s: Disable of regulator ldo18_adc "
327 "failed\n", __func__);
328 }
329
330 return rc;
331}
332
333static int pmic8058_xoadc_vreg_setup(void)
334{
335 int rc;
336
337 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
338 if (IS_ERR(vreg_ldo18_adc)) {
339 pr_err("%s: vreg get failed (%ld)\n",
340 __func__, PTR_ERR(vreg_ldo18_adc));
341 rc = PTR_ERR(vreg_ldo18_adc);
342 goto fail;
343 }
344
345 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
346 if (rc) {
347 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
348 goto fail;
349 }
350
351 return rc;
352fail:
353 regulator_put(vreg_ldo18_adc);
354 return rc;
355}
356
357static void pmic8058_xoadc_vreg_shutdown(void)
358{
359 regulator_put(vreg_ldo18_adc);
360}
361
362/* usec. For this ADC,
363 * this time represents clk rate @ txco w/ 1024 decimation ratio.
364 * Each channel has different configuration, thus at the time of starting
365 * the conversion, xoadc will return actual conversion time
366 * */
367static struct adc_properties pm8058_xoadc_data = {
368 .adc_reference = 2200, /* milli-voltage for this adc */
369 .bitresolution = 15,
370 .bipolar = 0,
371 .conversiontime = 54,
372};
373
374static struct xoadc_platform_data xoadc_pdata = {
375 .xoadc_prop = &pm8058_xoadc_data,
376 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
377 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
378 .xoadc_num = XOADC_PMIC_0,
379 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
380 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
381};
382#endif
383
Rohit Vaswani4c0d3042011-07-13 14:19:23 -0700384#define XO_CONSUMERS(_id) \
385 static struct regulator_consumer_supply xo_consumers_##_id[]
386
387/*
388 * Consumer specific regulator names:
389 * regulator name consumer dev_name
390 */
391XO_CONSUMERS(A0) = {
392 REGULATOR_SUPPLY("8058_xo_a0", NULL),
393 REGULATOR_SUPPLY("a0_clk_buffer", "fsm_xo_driver"),
394};
395XO_CONSUMERS(A1) = {
396 REGULATOR_SUPPLY("8058_xo_a1", NULL),
397 REGULATOR_SUPPLY("a1_clk_buffer", "fsm_xo_driver"),
398};
399
400#define PM8058_XO_INIT(_id, _modes, _ops, _always_on) \
401 [PM8058_XO_ID_##_id] = { \
402 .init_data = { \
403 .constraints = { \
404 .valid_modes_mask = _modes, \
405 .valid_ops_mask = _ops, \
Rohit Vaswani7beff902011-08-15 13:42:31 -0700406 .boot_on = 1, \
Rohit Vaswani4c0d3042011-07-13 14:19:23 -0700407 .always_on = _always_on, \
408 }, \
409 .num_consumer_supplies = \
410 ARRAY_SIZE(xo_consumers_##_id),\
411 .consumer_supplies = xo_consumers_##_id, \
412 }, \
413 }
414
415#define PM8058_XO_INIT_AX(_id) \
416 PM8058_XO_INIT(_id, REGULATOR_MODE_NORMAL, REGULATOR_CHANGE_STATUS, 0)
417
418static struct pm8058_xo_pdata pm8058_xo_init_pdata[PM8058_XO_ID_MAX] = {
419 PM8058_XO_INIT_AX(A0),
420 PM8058_XO_INIT_AX(A1),
421};
422
423#define PM8058_XO(_id) { \
424 .name = PM8058_XO_BUFFER_DEV_NAME, \
425 .id = _id, \
426 .platform_data = &pm8058_xo_init_pdata[_id], \
427 .pdata_size = sizeof(pm8058_xo_init_pdata[_id]), \
428}
429
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700430/* Put sub devices with fixed location first in sub_devices array */
431static struct mfd_cell pm8058_subdevs[] = {
432 { .name = "pm8058-mpp",
433 .platform_data = &pm8058_mpp_data,
434 .pdata_size = sizeof(pm8058_mpp_data),
435 },
436 {
437 .name = "pm8058-gpio",
438 .id = -1,
439 .platform_data = &pm8058_gpio_data,
440 .pdata_size = sizeof(pm8058_gpio_data),
441 },
442#ifdef CONFIG_SENSORS_MSM_ADC
443 {
444 .name = "pm8058-xoadc",
445 .id = -1,
446 .num_resources = ARRAY_SIZE(resources_adc),
447 .resources = resources_adc,
448 .platform_data = &xoadc_pdata,
449 .pdata_size =sizeof(xoadc_pdata),
450 },
451#endif
452 PM8058_VREG(PM8058_VREG_ID_L3),
453 PM8058_VREG(PM8058_VREG_ID_L8),
454 PM8058_VREG(PM8058_VREG_ID_L9),
455 PM8058_VREG(PM8058_VREG_ID_L14),
456 PM8058_VREG(PM8058_VREG_ID_L15),
457 PM8058_VREG(PM8058_VREG_ID_L18),
458 PM8058_VREG(PM8058_VREG_ID_S4),
459 PM8058_VREG(PM8058_VREG_ID_LVS0),
460 PM8058_XO(PM8058_XO_ID_A0),
461 PM8058_XO(PM8058_XO_ID_A1),
462};
463
464static struct pm8058_platform_data pm8058_fsm9xxx_data = {
465 .irq_base = PMIC8058_IRQ_BASE,
466
467 .num_subdevs = ARRAY_SIZE(pm8058_subdevs),
468 .sub_devices = pm8058_subdevs,
469};
470
471static struct i2c_board_info pm8058_boardinfo[] __initdata = {
472 {
473 I2C_BOARD_INFO("pm8058-core", 0x55),
474 .irq = MSM_GPIO_TO_INT(47),
475 .platform_data = &pm8058_fsm9xxx_data,
476 },
477};
478
479static int __init buses_init(void)
480{
481 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 5, GPIO_CFG_INPUT,
482 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
483 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
484 __func__, PMIC_GPIO_INT);
485
486 i2c_register_board_info(0 /* I2C_SSBI ID */, pm8058_boardinfo,
487 ARRAY_SIZE(pm8058_boardinfo));
488
489 return 0;
490}
491
492/*
493 * EPHY
494 */
495
496static struct msm_gpio phy_config_data[] = {
497 { GPIO_CFG(GPIO_EPHY_RST_N, 0, GPIO_CFG_OUTPUT,
498 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "MAC_RST_N" },
499};
500
501static int __init phy_init(void)
502{
503 msm_gpios_request_enable(phy_config_data, ARRAY_SIZE(phy_config_data));
504 gpio_direction_output(GPIO_EPHY_RST_N, 0);
505 udelay(100);
506 gpio_set_value(GPIO_EPHY_RST_N, 1);
507
508 return 0;
509}
510
511/*
512 * RF
513 */
514
515static struct msm_gpio grfc_config_data[] = {
516 { GPIO_CFG(GPIO_GRFC_FTR0_0, 7, GPIO_CFG_OUTPUT,
517 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "HH_RFMODE1_0" },
518 { GPIO_CFG(GPIO_GRFC_FTR0_1, 7, GPIO_CFG_OUTPUT,
519 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "HH_RFMODE1_1" },
520 { GPIO_CFG(GPIO_GRFC_FTR1_0, 7, GPIO_CFG_OUTPUT,
521 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "HH_RFMODE2_0" },
522 { GPIO_CFG(GPIO_GRFC_FTR1_1, 7, GPIO_CFG_OUTPUT,
523 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "HH_RFMODE2_1" },
524 { GPIO_CFG(GPIO_GRFC_2, 7, GPIO_CFG_OUTPUT,
525 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_2" },
526 { GPIO_CFG(GPIO_GRFC_3, 7, GPIO_CFG_OUTPUT,
527 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_3" },
528 { GPIO_CFG(GPIO_GRFC_4, 7, GPIO_CFG_OUTPUT,
529 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_4" },
530 { GPIO_CFG(GPIO_GRFC_5, 7, GPIO_CFG_OUTPUT,
531 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_5" },
532 { GPIO_CFG(GPIO_GRFC_6, 7, GPIO_CFG_OUTPUT,
533 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_6" },
534 { GPIO_CFG(GPIO_GRFC_7, 7, GPIO_CFG_OUTPUT,
535 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_7" },
536 { GPIO_CFG(GPIO_GRFC_8, 7, GPIO_CFG_OUTPUT,
537 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_8" },
538 { GPIO_CFG(GPIO_GRFC_9, 7, GPIO_CFG_OUTPUT,
539 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_9" },
540 { GPIO_CFG(GPIO_GRFC_10, 7, GPIO_CFG_OUTPUT,
541 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_10" },
542 { GPIO_CFG(GPIO_GRFC_11, 7, GPIO_CFG_OUTPUT,
543 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_11" },
544 { GPIO_CFG(GPIO_GRFC_13, 7, GPIO_CFG_OUTPUT,
545 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_13" },
546 { GPIO_CFG(GPIO_GRFC_14, 7, GPIO_CFG_OUTPUT,
547 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_14" },
548 { GPIO_CFG(GPIO_GRFC_15, 7, GPIO_CFG_OUTPUT,
549 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_15" },
550 { GPIO_CFG(GPIO_GRFC_16, 7, GPIO_CFG_OUTPUT,
551 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_16" },
552 { GPIO_CFG(GPIO_GRFC_17, 7, GPIO_CFG_OUTPUT,
553 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_17" },
554 { GPIO_CFG(GPIO_GRFC_18, 7, GPIO_CFG_OUTPUT,
555 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_18" },
556 { GPIO_CFG(GPIO_GRFC_24, 7, GPIO_CFG_OUTPUT,
557 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_24" },
558 { GPIO_CFG(GPIO_GRFC_25, 7, GPIO_CFG_OUTPUT,
559 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_25" },
560 { GPIO_CFG(GPIO_GRFC_26, 7, GPIO_CFG_OUTPUT,
561 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_26" },
562 { GPIO_CFG(GPIO_GRFC_27, 7, GPIO_CFG_OUTPUT,
563 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_27" },
564 { GPIO_CFG(GPIO_GRFC_28, 7, GPIO_CFG_OUTPUT,
565 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_28" },
566 { GPIO_CFG(GPIO_GRFC_29, 7, GPIO_CFG_OUTPUT,
567 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_29" },
568 { GPIO_CFG(39, 1, GPIO_CFG_OUTPUT,
569 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "PP2S_EXT_SYNC" },
570};
571
572static int __init grfc_init(void)
573{
574 msm_gpios_request_enable(grfc_config_data,
575 ARRAY_SIZE(grfc_config_data));
576
577 return 0;
578}
579
580/*
581 * UART
582 */
583
584#ifdef CONFIG_SERIAL_MSM_CONSOLE
585static struct msm_gpio uart1_config_data[] = {
586 { GPIO_CFG(138, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
587 "UART1_Rx" },
588 { GPIO_CFG(139, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
589 "UART1_Tx" },
590};
591
592static void fsm9xxx_init_uart1(void)
593{
594 msm_gpios_request_enable(uart1_config_data,
595 ARRAY_SIZE(uart1_config_data));
596
597}
598#endif
599
600/*
601 * SSBI
602 */
603
604#ifdef CONFIG_I2C_SSBI
605static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi1_pdata = {
606 .controller_type = FSM_SBI_CTRL_SSBI,
607};
608
609static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi2_pdata = {
610 .controller_type = FSM_SBI_CTRL_SSBI,
611};
612
613static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi3_pdata = {
614 .controller_type = FSM_SBI_CTRL_SSBI,
615};
616
617/* Intialize GPIO configuration for SSBI */
618static struct msm_gpio ssbi_gpio_config_data[] = {
619 { GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA),
620 "SSBI_1" },
621 { GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA),
622 "SSBI_2" },
623 { GPIO_CFG(92, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA),
624 "SSBI_3" },
625};
626
627static void
628fsm9xxx_init_ssbi_gpio(void)
629{
630 msm_gpios_request_enable(ssbi_gpio_config_data,
631 ARRAY_SIZE(ssbi_gpio_config_data));
632
633}
634#endif
635
636/*
Rohit Vaswani26512de2011-07-11 16:01:13 -0700637 * User GPIOs
638 */
639
640static void user_gpios_init(void)
641{
642 unsigned int gpio;
643
644 for (gpio = GPIO_USER_FIRST; gpio <= GPIO_USER_LAST; ++gpio)
645 gpio_tlmm_config(GPIO_CFG(gpio, 0, GPIO_CFG_INPUT,
646 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
647}
648
649/*
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700650 * Crypto
651 */
652
653#define QCE_SIZE 0x10000
654
655#define QCE_0_BASE 0x80C00000
656#define QCE_1_BASE 0x80E00000
657#define QCE_2_BASE 0x81000000
658
659#define QCE_NO_HW_KEY_SUPPORT 0 /* No shared HW key with external */
660#define QCE_NO_SHARE_CE_RESOURCE 0 /* No CE resource shared with TZ */
661#define QCE_NO_CE_SHARED 0 /* CE not shared with TZ */
662#define QCE_NO_SHA_HMAC_SUPPORT 0 /* No SHA-HMAC by SHA operation */
663
664static struct resource qcrypto_resources[] = {
665 [0] = {
666 .start = QCE_0_BASE,
667 .end = QCE_0_BASE + QCE_SIZE - 1,
668 .flags = IORESOURCE_MEM,
669 },
670 [1] = {
671 .name = "crypto_channels",
672 .start = DMOV_CE1_IN_CHAN,
673 .end = DMOV_CE1_OUT_CHAN,
674 .flags = IORESOURCE_DMA,
675 },
676 [2] = {
677 .name = "crypto_crci_in",
678 .start = DMOV_CE1_IN_CRCI,
679 .end = DMOV_CE1_IN_CRCI,
680 .flags = IORESOURCE_DMA,
681 },
682 [3] = {
683 .name = "crypto_crci_out",
684 .start = DMOV_CE1_OUT_CRCI,
685 .end = DMOV_CE1_OUT_CRCI,
686 .flags = IORESOURCE_DMA,
687 },
688 [4] = {
689 .name = "crypto_crci_hash",
690 .start = DMOV_CE1_HASH_CRCI,
691 .end = DMOV_CE1_HASH_CRCI,
692 .flags = IORESOURCE_DMA,
693 },
694};
695
696static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
697 .ce_shared = QCE_NO_CE_SHARED,
698 .shared_ce_resource = QCE_NO_SHARE_CE_RESOURCE,
699 .hw_key_support = QCE_NO_HW_KEY_SUPPORT,
700 .sha_hmac = QCE_NO_SHA_HMAC_SUPPORT,
701};
702
703struct platform_device qcrypto_device = {
704 .name = "qcrypto",
705 .id = 0,
706 .num_resources = ARRAY_SIZE(qcrypto_resources),
707 .resource = qcrypto_resources,
708 .dev = {
709 .coherent_dma_mask = DMA_BIT_MASK(32),
710 .platform_data = &qcrypto_ce_hw_suppport,
711 },
712};
713
714static struct resource qcedev_resources[] = {
715 [0] = {
716 .start = QCE_0_BASE,
717 .end = QCE_0_BASE + QCE_SIZE - 1,
718 .flags = IORESOURCE_MEM,
719 },
720 [1] = {
721 .name = "crypto_channels",
722 .start = DMOV_CE1_IN_CHAN,
723 .end = DMOV_CE1_OUT_CHAN,
724 .flags = IORESOURCE_DMA,
725 },
726 [2] = {
727 .name = "crypto_crci_in",
728 .start = DMOV_CE1_IN_CRCI,
729 .end = DMOV_CE1_IN_CRCI,
730 .flags = IORESOURCE_DMA,
731 },
732 [3] = {
733 .name = "crypto_crci_out",
734 .start = DMOV_CE1_OUT_CRCI,
735 .end = DMOV_CE1_OUT_CRCI,
736 .flags = IORESOURCE_DMA,
737 },
738 [4] = {
739 .name = "crypto_crci_hash",
740 .start = DMOV_CE1_HASH_CRCI,
741 .end = DMOV_CE1_HASH_CRCI,
742 .flags = IORESOURCE_DMA,
743 },
744};
745
746static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
747 .ce_shared = QCE_NO_CE_SHARED,
748 .shared_ce_resource = QCE_NO_SHARE_CE_RESOURCE,
749 .hw_key_support = QCE_NO_HW_KEY_SUPPORT,
750 .sha_hmac = QCE_NO_SHA_HMAC_SUPPORT,
751};
752
753static struct platform_device qcedev_device = {
754 .name = "qce",
755 .id = 0,
756 .num_resources = ARRAY_SIZE(qcedev_resources),
757 .resource = qcedev_resources,
758 .dev = {
759 .coherent_dma_mask = DMA_BIT_MASK(32),
760 .platform_data = &qcedev_ce_hw_suppport,
761 },
762};
763
764static struct resource ota_qcrypto_resources[] = {
765 [0] = {
766 .start = QCE_1_BASE,
767 .end = QCE_1_BASE + QCE_SIZE - 1,
768 .flags = IORESOURCE_MEM,
769 },
770 [1] = {
771 .name = "crypto_channels",
772 .start = DMOV_CE2_IN_CHAN,
773 .end = DMOV_CE2_OUT_CHAN,
774 .flags = IORESOURCE_DMA,
775 },
776 [2] = {
777 .name = "crypto_crci_in",
778 .start = DMOV_CE2_IN_CRCI,
779 .end = DMOV_CE2_IN_CRCI,
780 .flags = IORESOURCE_DMA,
781 },
782 [3] = {
783 .name = "crypto_crci_out",
784 .start = DMOV_CE2_OUT_CRCI,
785 .end = DMOV_CE2_OUT_CRCI,
786 .flags = IORESOURCE_DMA,
787 },
788 [4] = {
789 .name = "crypto_crci_hash",
790 .start = DMOV_CE2_HASH_CRCI,
791 .end = DMOV_CE2_HASH_CRCI,
792 .flags = IORESOURCE_DMA,
793 },
794};
795
796struct platform_device ota_qcrypto_device = {
797 .name = "qcota",
798 .id = 0,
799 .num_resources = ARRAY_SIZE(ota_qcrypto_resources),
800 .resource = ota_qcrypto_resources,
801 .dev = {
802 .coherent_dma_mask = DMA_BIT_MASK(32),
803 },
804};
805
806/*
807 * Devices
808 */
809
810static struct platform_device *devices[] __initdata = {
811 &msm_device_smd,
812 &msm_device_dmov,
813 &msm_device_nand,
814#ifdef CONFIG_I2C_SSBI
815 &msm_device_ssbi1,
816 &msm_device_ssbi2,
817 &msm_device_ssbi3,
818#endif
819#ifdef CONFIG_SENSORS_MSM_ADC
820 &msm_adc_device,
821#endif
822#ifdef CONFIG_I2C_QUP
823 &msm_gsbi1_qup_i2c_device,
824#endif
825#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
826 &msm_device_uart1,
827#endif
828#if defined(CONFIG_QFP_FUSE)
829 &fsm_qfp_fuse_device,
830#endif
831 &qfec_device,
832 &qcrypto_device,
833 &qcedev_device,
834 &ota_qcrypto_device,
Rohit Vaswani4c0d3042011-07-13 14:19:23 -0700835 &fsm_xo_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700836};
837
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700838static void __init fsm9xxx_init_irq(void)
839{
840 msm_init_irq();
841 msm_init_sirc();
842}
843
844#ifdef CONFIG_MSM_SPM
845static struct msm_spm_platform_data msm_spm_data __initdata = {
846 .reg_base_addr = MSM_SAW_BASE,
847
848 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
849 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
850 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
851 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
852
853 .reg_init_values[MSM_SPM_REG_SAW_SPM_PMIC_CTL] = 0xE0F272,
854 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
855 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
856 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
857
858 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
859 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
860 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
861
862 .awake_vlevel = 0xF2,
863 .retention_vlevel = 0xE0,
864 .collapse_vlevel = 0x72,
865 .retention_mid_vlevel = 0xE0,
866 .collapse_mid_vlevel = 0xE0,
867};
868#endif
869
870static void __init fsm9xxx_init(void)
871{
Matt Wagantallec57f062011-08-16 23:54:46 -0700872 acpuclk_init(&acpuclk_9xxx_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700873
874 regulator_has_full_constraints();
875
876 platform_add_devices(devices, ARRAY_SIZE(devices));
877
878#ifdef CONFIG_MSM_SPM
879 msm_spm_init(&msm_spm_data, 1);
880#endif
881 buses_init();
882 phy_init();
883 grfc_init();
Rohit Vaswani26512de2011-07-11 16:01:13 -0700884 user_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700885
886#ifdef CONFIG_SERIAL_MSM_CONSOLE
887 fsm9xxx_init_uart1();
888#endif
889#ifdef CONFIG_I2C_SSBI
890 fsm9xxx_init_ssbi_gpio();
891 msm_device_ssbi1.dev.platform_data = &msm_i2c_ssbi1_pdata;
892 msm_device_ssbi2.dev.platform_data = &msm_i2c_ssbi2_pdata;
893 msm_device_ssbi3.dev.platform_data = &msm_i2c_ssbi3_pdata;
894#endif
895}
896
897static void __init fsm9xxx_map_io(void)
898{
899 msm_shared_ram_phys = 0x00100000;
900 msm_map_fsm9xxx_io();
Stephen Boydbb600ae2011-08-02 20:11:40 -0700901 msm_clock_init(&fsm9xxx_clock_init_data);
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -0700902 if (socinfo_init() < 0)
903 pr_err("%s: socinfo_init() failed!\n",
904 __func__);
905
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700906}
907
908MACHINE_START(FSM9XXX_SURF, "QCT FSM9XXX")
909 .boot_params = PHYS_OFFSET + 0x100,
910 .map_io = fsm9xxx_map_io,
911 .init_irq = fsm9xxx_init_irq,
912 .init_machine = fsm9xxx_init,
913 .timer = &msm_timer,
914MACHINE_END