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