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