blob: f7e50fdcda97ba8e299e8a0d6a73b6d82ea90cf4 [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], \
Anirudh Ghayalc339d082011-10-12 19:17:24 -0400250 .pdata_size = sizeof(pm8058_vreg_init[_id]), \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700251}
252
253#ifdef CONFIG_SENSORS_MSM_ADC
254static struct resource resources_adc[] = {
255 {
256 .start = PM8058_ADC_IRQ(PMIC8058_IRQ_BASE),
257 .end = PM8058_ADC_IRQ(PMIC8058_IRQ_BASE),
258 .flags = IORESOURCE_IRQ,
259 },
260};
261
262static struct adc_access_fn xoadc_fn = {
263 pm8058_xoadc_select_chan_and_start_conv,
264 pm8058_xoadc_read_adc_code,
265 pm8058_xoadc_get_properties,
266 pm8058_xoadc_slot_request,
267 pm8058_xoadc_restore_slot,
268 pm8058_xoadc_calibrate,
269};
270
271static struct msm_adc_channels msm_adc_channels_data[] = {
272 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
273 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
274 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
275 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
276 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
277 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
278 {"fsm_therm", CHANNEL_ADC_FSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE6,
279 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
280 {"pa_therm", CHANNEL_ADC_PA_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
281 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
282};
283
284static struct msm_adc_platform_data msm_adc_pdata = {
285 .channel = msm_adc_channels_data,
286 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
287 .target_hw = FSM_9xxx,
288};
289
290static struct platform_device msm_adc_device = {
291 .name = "msm_adc",
292 .id = -1,
293 .dev = {
294 .platform_data = &msm_adc_pdata,
295 },
296};
297
298static void pmic8058_xoadc_mpp_config(void)
299{
300 int rc;
301
302 rc = pm8058_mpp_config_analog_input(XOADC_MPP_7,
303 PM_MPP_AIN_AMUX_CH5, PM_MPP_AOUT_CTL_DISABLE);
304 if (rc)
305 pr_err("%s: Config mpp7 on pmic 8058 failed\n", __func__);
306
307 rc = pm8058_mpp_config_analog_input(XOADC_MPP_10,
308 PM_MPP_AIN_AMUX_CH6, PM_MPP_AOUT_CTL_DISABLE);
309 if (rc)
310 pr_err("%s: Config mpp10 on pmic 8058 failed\n", __func__);
311}
312
313static struct regulator *vreg_ldo18_adc;
314
315static int pmic8058_xoadc_vreg_config(int on)
316{
317 int rc;
318
319 if (on) {
320 rc = regulator_enable(vreg_ldo18_adc);
321 if (rc)
322 pr_err("%s: Enable of regulator ldo18_adc "
323 "failed\n", __func__);
324 } else {
325 rc = regulator_disable(vreg_ldo18_adc);
326 if (rc)
327 pr_err("%s: Disable of regulator ldo18_adc "
328 "failed\n", __func__);
329 }
330
331 return rc;
332}
333
334static int pmic8058_xoadc_vreg_setup(void)
335{
336 int rc;
337
338 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
339 if (IS_ERR(vreg_ldo18_adc)) {
340 pr_err("%s: vreg get failed (%ld)\n",
341 __func__, PTR_ERR(vreg_ldo18_adc));
342 rc = PTR_ERR(vreg_ldo18_adc);
343 goto fail;
344 }
345
346 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
347 if (rc) {
348 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
349 goto fail;
350 }
351
352 return rc;
353fail:
354 regulator_put(vreg_ldo18_adc);
355 return rc;
356}
357
358static void pmic8058_xoadc_vreg_shutdown(void)
359{
360 regulator_put(vreg_ldo18_adc);
361}
362
363/* usec. For this ADC,
364 * this time represents clk rate @ txco w/ 1024 decimation ratio.
365 * Each channel has different configuration, thus at the time of starting
366 * the conversion, xoadc will return actual conversion time
367 * */
368static struct adc_properties pm8058_xoadc_data = {
369 .adc_reference = 2200, /* milli-voltage for this adc */
370 .bitresolution = 15,
371 .bipolar = 0,
372 .conversiontime = 54,
373};
374
375static struct xoadc_platform_data xoadc_pdata = {
376 .xoadc_prop = &pm8058_xoadc_data,
377 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
378 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
379 .xoadc_num = XOADC_PMIC_0,
380 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
381 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
382};
383#endif
384
Rohit Vaswani4c0d3042011-07-13 14:19:23 -0700385#define XO_CONSUMERS(_id) \
386 static struct regulator_consumer_supply xo_consumers_##_id[]
387
388/*
389 * Consumer specific regulator names:
390 * regulator name consumer dev_name
391 */
392XO_CONSUMERS(A0) = {
393 REGULATOR_SUPPLY("8058_xo_a0", NULL),
394 REGULATOR_SUPPLY("a0_clk_buffer", "fsm_xo_driver"),
395};
396XO_CONSUMERS(A1) = {
397 REGULATOR_SUPPLY("8058_xo_a1", NULL),
398 REGULATOR_SUPPLY("a1_clk_buffer", "fsm_xo_driver"),
399};
400
401#define PM8058_XO_INIT(_id, _modes, _ops, _always_on) \
402 [PM8058_XO_ID_##_id] = { \
403 .init_data = { \
404 .constraints = { \
405 .valid_modes_mask = _modes, \
406 .valid_ops_mask = _ops, \
Rohit Vaswani7beff902011-08-15 13:42:31 -0700407 .boot_on = 1, \
Rohit Vaswani4c0d3042011-07-13 14:19:23 -0700408 .always_on = _always_on, \
409 }, \
410 .num_consumer_supplies = \
411 ARRAY_SIZE(xo_consumers_##_id),\
412 .consumer_supplies = xo_consumers_##_id, \
413 }, \
414 }
415
416#define PM8058_XO_INIT_AX(_id) \
417 PM8058_XO_INIT(_id, REGULATOR_MODE_NORMAL, REGULATOR_CHANGE_STATUS, 0)
418
419static struct pm8058_xo_pdata pm8058_xo_init_pdata[PM8058_XO_ID_MAX] = {
420 PM8058_XO_INIT_AX(A0),
421 PM8058_XO_INIT_AX(A1),
422};
423
424#define PM8058_XO(_id) { \
425 .name = PM8058_XO_BUFFER_DEV_NAME, \
426 .id = _id, \
427 .platform_data = &pm8058_xo_init_pdata[_id], \
428 .pdata_size = sizeof(pm8058_xo_init_pdata[_id]), \
429}
430
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700431/* Put sub devices with fixed location first in sub_devices array */
432static struct mfd_cell pm8058_subdevs[] = {
433 { .name = "pm8058-mpp",
434 .platform_data = &pm8058_mpp_data,
435 .pdata_size = sizeof(pm8058_mpp_data),
436 },
437 {
438 .name = "pm8058-gpio",
439 .id = -1,
440 .platform_data = &pm8058_gpio_data,
441 .pdata_size = sizeof(pm8058_gpio_data),
442 },
443#ifdef CONFIG_SENSORS_MSM_ADC
444 {
445 .name = "pm8058-xoadc",
446 .id = -1,
447 .num_resources = ARRAY_SIZE(resources_adc),
448 .resources = resources_adc,
449 .platform_data = &xoadc_pdata,
450 .pdata_size =sizeof(xoadc_pdata),
451 },
452#endif
453 PM8058_VREG(PM8058_VREG_ID_L3),
454 PM8058_VREG(PM8058_VREG_ID_L8),
455 PM8058_VREG(PM8058_VREG_ID_L9),
456 PM8058_VREG(PM8058_VREG_ID_L14),
457 PM8058_VREG(PM8058_VREG_ID_L15),
458 PM8058_VREG(PM8058_VREG_ID_L18),
459 PM8058_VREG(PM8058_VREG_ID_S4),
460 PM8058_VREG(PM8058_VREG_ID_LVS0),
461 PM8058_XO(PM8058_XO_ID_A0),
462 PM8058_XO(PM8058_XO_ID_A1),
463};
464
465static struct pm8058_platform_data pm8058_fsm9xxx_data = {
466 .irq_base = PMIC8058_IRQ_BASE,
467
468 .num_subdevs = ARRAY_SIZE(pm8058_subdevs),
469 .sub_devices = pm8058_subdevs,
470};
471
472static struct i2c_board_info pm8058_boardinfo[] __initdata = {
473 {
474 I2C_BOARD_INFO("pm8058-core", 0x55),
475 .irq = MSM_GPIO_TO_INT(47),
476 .platform_data = &pm8058_fsm9xxx_data,
477 },
478};
479
480static int __init buses_init(void)
481{
482 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 5, GPIO_CFG_INPUT,
483 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
484 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
485 __func__, PMIC_GPIO_INT);
486
487 i2c_register_board_info(0 /* I2C_SSBI ID */, pm8058_boardinfo,
488 ARRAY_SIZE(pm8058_boardinfo));
489
490 return 0;
491}
492
493/*
494 * EPHY
495 */
496
497static struct msm_gpio phy_config_data[] = {
498 { GPIO_CFG(GPIO_EPHY_RST_N, 0, GPIO_CFG_OUTPUT,
499 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "MAC_RST_N" },
500};
501
502static int __init phy_init(void)
503{
504 msm_gpios_request_enable(phy_config_data, ARRAY_SIZE(phy_config_data));
505 gpio_direction_output(GPIO_EPHY_RST_N, 0);
506 udelay(100);
507 gpio_set_value(GPIO_EPHY_RST_N, 1);
508
509 return 0;
510}
511
512/*
513 * RF
514 */
515
516static struct msm_gpio grfc_config_data[] = {
517 { GPIO_CFG(GPIO_GRFC_FTR0_0, 7, GPIO_CFG_OUTPUT,
518 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "HH_RFMODE1_0" },
519 { GPIO_CFG(GPIO_GRFC_FTR0_1, 7, GPIO_CFG_OUTPUT,
520 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "HH_RFMODE1_1" },
521 { GPIO_CFG(GPIO_GRFC_FTR1_0, 7, GPIO_CFG_OUTPUT,
522 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "HH_RFMODE2_0" },
523 { GPIO_CFG(GPIO_GRFC_FTR1_1, 7, GPIO_CFG_OUTPUT,
524 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "HH_RFMODE2_1" },
525 { GPIO_CFG(GPIO_GRFC_2, 7, GPIO_CFG_OUTPUT,
526 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_2" },
527 { GPIO_CFG(GPIO_GRFC_3, 7, GPIO_CFG_OUTPUT,
528 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_3" },
529 { GPIO_CFG(GPIO_GRFC_4, 7, GPIO_CFG_OUTPUT,
530 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_4" },
531 { GPIO_CFG(GPIO_GRFC_5, 7, GPIO_CFG_OUTPUT,
532 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_5" },
533 { GPIO_CFG(GPIO_GRFC_6, 7, GPIO_CFG_OUTPUT,
534 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_6" },
535 { GPIO_CFG(GPIO_GRFC_7, 7, GPIO_CFG_OUTPUT,
536 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_7" },
537 { GPIO_CFG(GPIO_GRFC_8, 7, GPIO_CFG_OUTPUT,
538 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_8" },
539 { GPIO_CFG(GPIO_GRFC_9, 7, GPIO_CFG_OUTPUT,
540 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_9" },
541 { GPIO_CFG(GPIO_GRFC_10, 7, GPIO_CFG_OUTPUT,
542 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_10" },
543 { GPIO_CFG(GPIO_GRFC_11, 7, GPIO_CFG_OUTPUT,
544 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_11" },
545 { GPIO_CFG(GPIO_GRFC_13, 7, GPIO_CFG_OUTPUT,
546 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_13" },
547 { GPIO_CFG(GPIO_GRFC_14, 7, GPIO_CFG_OUTPUT,
548 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_14" },
549 { GPIO_CFG(GPIO_GRFC_15, 7, GPIO_CFG_OUTPUT,
550 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_15" },
551 { GPIO_CFG(GPIO_GRFC_16, 7, GPIO_CFG_OUTPUT,
552 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_16" },
553 { GPIO_CFG(GPIO_GRFC_17, 7, GPIO_CFG_OUTPUT,
554 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_17" },
555 { GPIO_CFG(GPIO_GRFC_18, 7, GPIO_CFG_OUTPUT,
556 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_18" },
557 { GPIO_CFG(GPIO_GRFC_24, 7, GPIO_CFG_OUTPUT,
558 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_24" },
559 { GPIO_CFG(GPIO_GRFC_25, 7, GPIO_CFG_OUTPUT,
560 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_25" },
561 { GPIO_CFG(GPIO_GRFC_26, 7, GPIO_CFG_OUTPUT,
562 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_26" },
563 { GPIO_CFG(GPIO_GRFC_27, 7, GPIO_CFG_OUTPUT,
564 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_27" },
565 { GPIO_CFG(GPIO_GRFC_28, 7, GPIO_CFG_OUTPUT,
566 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_28" },
567 { GPIO_CFG(GPIO_GRFC_29, 7, GPIO_CFG_OUTPUT,
568 GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "GPIO_GRFC_29" },
569 { GPIO_CFG(39, 1, GPIO_CFG_OUTPUT,
570 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "PP2S_EXT_SYNC" },
571};
572
573static int __init grfc_init(void)
574{
575 msm_gpios_request_enable(grfc_config_data,
576 ARRAY_SIZE(grfc_config_data));
577
578 return 0;
579}
580
581/*
582 * UART
583 */
584
585#ifdef CONFIG_SERIAL_MSM_CONSOLE
586static struct msm_gpio uart1_config_data[] = {
587 { GPIO_CFG(138, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
588 "UART1_Rx" },
589 { GPIO_CFG(139, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
590 "UART1_Tx" },
591};
592
593static void fsm9xxx_init_uart1(void)
594{
595 msm_gpios_request_enable(uart1_config_data,
596 ARRAY_SIZE(uart1_config_data));
597
598}
599#endif
600
601/*
602 * SSBI
603 */
604
605#ifdef CONFIG_I2C_SSBI
606static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi1_pdata = {
607 .controller_type = FSM_SBI_CTRL_SSBI,
608};
609
610static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi2_pdata = {
611 .controller_type = FSM_SBI_CTRL_SSBI,
612};
613
614static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi3_pdata = {
615 .controller_type = FSM_SBI_CTRL_SSBI,
616};
617
618/* Intialize GPIO configuration for SSBI */
619static struct msm_gpio ssbi_gpio_config_data[] = {
620 { GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA),
621 "SSBI_1" },
622 { GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA),
623 "SSBI_2" },
624 { GPIO_CFG(92, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA),
625 "SSBI_3" },
626};
627
628static void
629fsm9xxx_init_ssbi_gpio(void)
630{
631 msm_gpios_request_enable(ssbi_gpio_config_data,
632 ARRAY_SIZE(ssbi_gpio_config_data));
633
634}
635#endif
636
637/*
Rohit Vaswani26512de2011-07-11 16:01:13 -0700638 * User GPIOs
639 */
640
641static void user_gpios_init(void)
642{
643 unsigned int gpio;
644
645 for (gpio = GPIO_USER_FIRST; gpio <= GPIO_USER_LAST; ++gpio)
646 gpio_tlmm_config(GPIO_CFG(gpio, 0, GPIO_CFG_INPUT,
647 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
648}
649
650/*
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700651 * Crypto
652 */
653
654#define QCE_SIZE 0x10000
655
656#define QCE_0_BASE 0x80C00000
657#define QCE_1_BASE 0x80E00000
658#define QCE_2_BASE 0x81000000
659
660#define QCE_NO_HW_KEY_SUPPORT 0 /* No shared HW key with external */
661#define QCE_NO_SHARE_CE_RESOURCE 0 /* No CE resource shared with TZ */
662#define QCE_NO_CE_SHARED 0 /* CE not shared with TZ */
663#define QCE_NO_SHA_HMAC_SUPPORT 0 /* No SHA-HMAC by SHA operation */
664
665static struct resource qcrypto_resources[] = {
666 [0] = {
667 .start = QCE_0_BASE,
668 .end = QCE_0_BASE + QCE_SIZE - 1,
669 .flags = IORESOURCE_MEM,
670 },
671 [1] = {
672 .name = "crypto_channels",
673 .start = DMOV_CE1_IN_CHAN,
674 .end = DMOV_CE1_OUT_CHAN,
675 .flags = IORESOURCE_DMA,
676 },
677 [2] = {
678 .name = "crypto_crci_in",
679 .start = DMOV_CE1_IN_CRCI,
680 .end = DMOV_CE1_IN_CRCI,
681 .flags = IORESOURCE_DMA,
682 },
683 [3] = {
684 .name = "crypto_crci_out",
685 .start = DMOV_CE1_OUT_CRCI,
686 .end = DMOV_CE1_OUT_CRCI,
687 .flags = IORESOURCE_DMA,
688 },
689 [4] = {
690 .name = "crypto_crci_hash",
691 .start = DMOV_CE1_HASH_CRCI,
692 .end = DMOV_CE1_HASH_CRCI,
693 .flags = IORESOURCE_DMA,
694 },
695};
696
697static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
698 .ce_shared = QCE_NO_CE_SHARED,
699 .shared_ce_resource = QCE_NO_SHARE_CE_RESOURCE,
700 .hw_key_support = QCE_NO_HW_KEY_SUPPORT,
701 .sha_hmac = QCE_NO_SHA_HMAC_SUPPORT,
702};
703
704struct platform_device qcrypto_device = {
705 .name = "qcrypto",
706 .id = 0,
707 .num_resources = ARRAY_SIZE(qcrypto_resources),
708 .resource = qcrypto_resources,
709 .dev = {
710 .coherent_dma_mask = DMA_BIT_MASK(32),
711 .platform_data = &qcrypto_ce_hw_suppport,
712 },
713};
714
715static struct resource qcedev_resources[] = {
716 [0] = {
717 .start = QCE_0_BASE,
718 .end = QCE_0_BASE + QCE_SIZE - 1,
719 .flags = IORESOURCE_MEM,
720 },
721 [1] = {
722 .name = "crypto_channels",
723 .start = DMOV_CE1_IN_CHAN,
724 .end = DMOV_CE1_OUT_CHAN,
725 .flags = IORESOURCE_DMA,
726 },
727 [2] = {
728 .name = "crypto_crci_in",
729 .start = DMOV_CE1_IN_CRCI,
730 .end = DMOV_CE1_IN_CRCI,
731 .flags = IORESOURCE_DMA,
732 },
733 [3] = {
734 .name = "crypto_crci_out",
735 .start = DMOV_CE1_OUT_CRCI,
736 .end = DMOV_CE1_OUT_CRCI,
737 .flags = IORESOURCE_DMA,
738 },
739 [4] = {
740 .name = "crypto_crci_hash",
741 .start = DMOV_CE1_HASH_CRCI,
742 .end = DMOV_CE1_HASH_CRCI,
743 .flags = IORESOURCE_DMA,
744 },
745};
746
747static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
748 .ce_shared = QCE_NO_CE_SHARED,
749 .shared_ce_resource = QCE_NO_SHARE_CE_RESOURCE,
750 .hw_key_support = QCE_NO_HW_KEY_SUPPORT,
751 .sha_hmac = QCE_NO_SHA_HMAC_SUPPORT,
752};
753
754static struct platform_device qcedev_device = {
755 .name = "qce",
756 .id = 0,
757 .num_resources = ARRAY_SIZE(qcedev_resources),
758 .resource = qcedev_resources,
759 .dev = {
760 .coherent_dma_mask = DMA_BIT_MASK(32),
761 .platform_data = &qcedev_ce_hw_suppport,
762 },
763};
764
765static struct resource ota_qcrypto_resources[] = {
766 [0] = {
767 .start = QCE_1_BASE,
768 .end = QCE_1_BASE + QCE_SIZE - 1,
769 .flags = IORESOURCE_MEM,
770 },
771 [1] = {
772 .name = "crypto_channels",
773 .start = DMOV_CE2_IN_CHAN,
774 .end = DMOV_CE2_OUT_CHAN,
775 .flags = IORESOURCE_DMA,
776 },
777 [2] = {
778 .name = "crypto_crci_in",
779 .start = DMOV_CE2_IN_CRCI,
780 .end = DMOV_CE2_IN_CRCI,
781 .flags = IORESOURCE_DMA,
782 },
783 [3] = {
784 .name = "crypto_crci_out",
785 .start = DMOV_CE2_OUT_CRCI,
786 .end = DMOV_CE2_OUT_CRCI,
787 .flags = IORESOURCE_DMA,
788 },
789 [4] = {
790 .name = "crypto_crci_hash",
791 .start = DMOV_CE2_HASH_CRCI,
792 .end = DMOV_CE2_HASH_CRCI,
793 .flags = IORESOURCE_DMA,
794 },
795};
796
797struct platform_device ota_qcrypto_device = {
798 .name = "qcota",
799 .id = 0,
800 .num_resources = ARRAY_SIZE(ota_qcrypto_resources),
801 .resource = ota_qcrypto_resources,
802 .dev = {
803 .coherent_dma_mask = DMA_BIT_MASK(32),
804 },
805};
806
807/*
808 * Devices
809 */
810
811static struct platform_device *devices[] __initdata = {
812 &msm_device_smd,
813 &msm_device_dmov,
814 &msm_device_nand,
815#ifdef CONFIG_I2C_SSBI
816 &msm_device_ssbi1,
817 &msm_device_ssbi2,
818 &msm_device_ssbi3,
819#endif
820#ifdef CONFIG_SENSORS_MSM_ADC
821 &msm_adc_device,
822#endif
823#ifdef CONFIG_I2C_QUP
824 &msm_gsbi1_qup_i2c_device,
825#endif
826#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
827 &msm_device_uart1,
828#endif
829#if defined(CONFIG_QFP_FUSE)
830 &fsm_qfp_fuse_device,
831#endif
832 &qfec_device,
833 &qcrypto_device,
834 &qcedev_device,
835 &ota_qcrypto_device,
Rohit Vaswani4c0d3042011-07-13 14:19:23 -0700836 &fsm_xo_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700837};
838
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700839static void __init fsm9xxx_init_irq(void)
840{
841 msm_init_irq();
842 msm_init_sirc();
843}
844
845#ifdef CONFIG_MSM_SPM
846static struct msm_spm_platform_data msm_spm_data __initdata = {
847 .reg_base_addr = MSM_SAW_BASE,
848
849 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
850 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
851 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
852 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
853
854 .reg_init_values[MSM_SPM_REG_SAW_SPM_PMIC_CTL] = 0xE0F272,
855 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
856 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
857 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
858
859 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
860 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
861 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
862
863 .awake_vlevel = 0xF2,
864 .retention_vlevel = 0xE0,
865 .collapse_vlevel = 0x72,
866 .retention_mid_vlevel = 0xE0,
867 .collapse_mid_vlevel = 0xE0,
868};
869#endif
870
871static void __init fsm9xxx_init(void)
872{
Matt Wagantallec57f062011-08-16 23:54:46 -0700873 acpuclk_init(&acpuclk_9xxx_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700874
875 regulator_has_full_constraints();
876
877 platform_add_devices(devices, ARRAY_SIZE(devices));
878
879#ifdef CONFIG_MSM_SPM
880 msm_spm_init(&msm_spm_data, 1);
881#endif
882 buses_init();
883 phy_init();
884 grfc_init();
Rohit Vaswani26512de2011-07-11 16:01:13 -0700885 user_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700886
887#ifdef CONFIG_SERIAL_MSM_CONSOLE
888 fsm9xxx_init_uart1();
889#endif
890#ifdef CONFIG_I2C_SSBI
891 fsm9xxx_init_ssbi_gpio();
892 msm_device_ssbi1.dev.platform_data = &msm_i2c_ssbi1_pdata;
893 msm_device_ssbi2.dev.platform_data = &msm_i2c_ssbi2_pdata;
894 msm_device_ssbi3.dev.platform_data = &msm_i2c_ssbi3_pdata;
895#endif
896}
897
898static void __init fsm9xxx_map_io(void)
899{
900 msm_shared_ram_phys = 0x00100000;
901 msm_map_fsm9xxx_io();
Stephen Boydbb600ae2011-08-02 20:11:40 -0700902 msm_clock_init(&fsm9xxx_clock_init_data);
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -0700903 if (socinfo_init() < 0)
904 pr_err("%s: socinfo_init() failed!\n",
905 __func__);
906
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700907}
908
909MACHINE_START(FSM9XXX_SURF, "QCT FSM9XXX")
910 .boot_params = PHYS_OFFSET + 0x100,
911 .map_io = fsm9xxx_map_io,
912 .init_irq = fsm9xxx_init_irq,
913 .init_machine = fsm9xxx_init,
914 .timer = &msm_timer,
915MACHINE_END