htcleo: add Cotulla's fixes for non-android touchscreen!
[htc-linux.git] / arch / arm / mach-msm / pwrtest.c
blobcc451be5f9db6e1c065a874e2efd7c5d7a317004
1 /* linux/arch/arm/mach-msm/pwrtest.c
3 * * Copyright (C) 2009 HTC Corporation.
4 * Author:
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #include <linux/gpio.h>
17 #include "devices.h"
18 #include "proc_comm.h"
20 enum CPLD_REG_ID {
21 CPLD_REG_MISC2 = 0,
22 CPLD_REG_MISC3,
23 CPLD_REG_MISC4,
24 CPLD_REG_MISC5,
25 CPLD_REG_INT2,
26 CPLD_REG_MISC1,
27 CPLD_REG_INT3,
28 CPLD_REG_INT1,
29 CPLD_REG_NUM,
32 typedef struct _tagSUSPEND_PIN_CONFIG {
33 unsigned char arGpio[200]; /* the maximum should be 1024 bytes */
34 } SUSPEND_PIN_CONFIG, *PSUSPEND_PIN_CONFIG;
36 void gpio_set_diag_gpio_table(unsigned long * dwMFG_gpio_table)
38 int i = 0;
39 unsigned cfg;
40 PSUSPEND_PIN_CONFIG pSuspendPinConfig = 0;
42 pSuspendPinConfig = (PSUSPEND_PIN_CONFIG)(dwMFG_gpio_table);
43 #if defined(CONFIG_ARCH_MSM7X00A)
44 for (i = 0; i <= 121; i++)
45 #elif defined(CONFIG_ARCH_MSM7225)
46 for (i = 0; i < 132; i++)
47 #elif defined(CONFIG_ARCH_MSM7227)
48 for (i = 0; i < 132; i++)
49 #elif defined(CONFIG_ARCH_QSD8X50)
50 for (i = 0; i <= 164; i++)
51 #elif defined(CONFIG_ARCH_MSM7X30)
52 for (i = 0; i <= 181; i++)
53 #endif
55 unsigned char tempGpio = pSuspendPinConfig->arGpio[i];
57 if(tempGpio & 0x1) {
58 /* configure by the settings from DIAG */
59 unsigned long dwGpioKind, dwGpioConfig, dwOutputLevel;
60 if(tempGpio & 0x2) { /* GPIO INPUT PIN */
61 dwGpioKind = GPIO_INPUT;
62 dwOutputLevel = 0;
63 } else { /* GPIO_OUTPUT_PIN */
64 dwGpioKind = GPIO_OUTPUT;
65 if (tempGpio & 0x4)
66 dwOutputLevel = 1;
67 else
68 dwOutputLevel = 0;
71 // config GpioPullStatus
72 if ((tempGpio & 0x10) && (tempGpio & 0x08))
73 dwGpioConfig = GPIO_PULL_UP;
74 else if (tempGpio & 0x08)
75 dwGpioConfig = GPIO_PULL_DOWN;
76 else if (tempGpio & 0x10)
77 dwGpioConfig = GPIO_KEEPER;
78 else
79 dwGpioConfig = GPIO_NO_PULL;
81 cfg = PCOM_GPIO_CFG(i, 0, dwGpioKind, dwGpioConfig, GPIO_2MA);
83 msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &cfg, 0);
85 if (dwGpioKind == GPIO_OUTPUT)
86 gpio_direction_output(i, dwOutputLevel);
87 } else {
88 /* DIAG does not want to config this GPIO */
89 continue;
93 EXPORT_SYMBOL(gpio_set_diag_gpio_table);