| 1 |
/* linux/arch/arm/mach-msm/board-htcdiamond.c |
| 2 |
* |
| 3 |
* Copyright (C) 2007 Google, Inc. |
| 4 |
* Author: Brian Swetland <swetland@google.com>, |
| 5 |
* Octavian Voicu, Martijn Stolk |
| 6 |
* |
| 7 |
* This software is licensed under the terms of the GNU General Public |
| 8 |
* License version 2, as published by the Free Software Foundation, and |
| 9 |
* may be copied, distributed, and modified under those terms. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
*/ |
| 17 |
|
| 18 |
#include <linux/kernel.h> |
| 19 |
#include <linux/init.h> |
| 20 |
#include <linux/platform_device.h> |
| 21 |
#include <linux/input.h> |
| 22 |
|
| 23 |
#include <linux/mtd/nand.h> |
| 24 |
#include <linux/mtd/partitions.h> |
| 25 |
#include <linux/i2c.h> |
| 26 |
#include <linux/mm.h> |
| 27 |
#include <linux/gpio_event.h> |
| 28 |
|
| 29 |
|
| 30 |
#include <mach/hardware.h> |
| 31 |
#include <asm/mach-types.h> |
| 32 |
#include <asm/mach/arch.h> |
| 33 |
#include <asm/mach/map.h> |
| 34 |
#include <asm/mach/flash.h> |
| 35 |
#include <asm/mach/mmc.h> |
| 36 |
#include <asm/setup.h> |
| 37 |
|
| 38 |
#include <mach/board.h> |
| 39 |
#include <mach/msm_iomap.h> |
| 40 |
#include <mach/system.h> |
| 41 |
#include <mach/msm_fb.h> |
| 42 |
#include <mach/msm_hsusb.h> |
| 43 |
#include <mach/msm_serial_hs.h> |
| 44 |
#include <mach/vreg.h> |
| 45 |
#include <mach/htc_battery.h> |
| 46 |
#include <mach/htc_pwrsink.h> |
| 47 |
#include <mach/board_htc.h> |
| 48 |
|
| 49 |
#include <mach/gpio.h> |
| 50 |
#include <mach/io.h> |
| 51 |
#include <linux/delay.h> |
| 52 |
#ifdef CONFIG_HTC_HEADSET |
| 53 |
#include <mach/htc_headset.h> |
| 54 |
#endif |
| 55 |
|
| 56 |
#include "proc_comm_wince.h" |
| 57 |
#include "devices.h" |
| 58 |
#include "htc_hw.h" |
| 59 |
#include "board-htcdiamond.h" |
| 60 |
#include "htc-usb.h" |
| 61 |
|
| 62 |
#include <mach/htc_acoustic_wince.h> |
| 63 |
|
| 64 |
static int extra_bank; |
| 65 |
module_param_named(extra_bank, extra_bank, int, S_IRUGO | S_IWUSR | S_IWGRP); |
| 66 |
|
| 67 |
static void htcdiamond_device_specific_fixes(void); |
| 68 |
|
| 69 |
extern int init_mmc(void); |
| 70 |
extern void msm_init_pmic_vibrator(void); |
| 71 |
|
| 72 |
static int usb_phy_init_seq_diam100[] = { |
| 73 |
0x40, 0x31, /* Leave this pair out for USB Host Mode */ |
| 74 |
0x1D, 0x0D, |
| 75 |
0x1D, 0x10, |
| 76 |
-1 |
| 77 |
}; |
| 78 |
|
| 79 |
static int usb_phy_init_seq_diam800[] = { |
| 80 |
0x04, 0x48, /* Host mode is unsure for diam800 */ |
| 81 |
0x3A, 0x10, |
| 82 |
0x3B, 0x10, |
| 83 |
-1 |
| 84 |
}; |
| 85 |
|
| 86 |
static void usb_phy_shutdown(void) |
| 87 |
{ |
| 88 |
gpio_set_value(0x64, 1); |
| 89 |
gpio_set_value(0x64, 0); |
| 90 |
} |
| 91 |
static void usb_phy_reset(void) |
| 92 |
{ |
| 93 |
usb_phy_shutdown(); |
| 94 |
gpio_set_value(0x64, 0); |
| 95 |
mdelay(1); |
| 96 |
gpio_set_value(0x64, 1); |
| 97 |
mdelay(3); |
| 98 |
htc_usb_ulpi_config(1); |
| 99 |
} |
| 100 |
|
| 101 |
#if defined(CONFIG_MSM_CAMERA) && ( defined(CONFIG_MT9T013) || defined(CONFIG_MT9V113) ) |
| 102 |
|
| 103 |
static struct msm_gpio_config camera_off_gpio_table[] = { |
| 104 |
/* CAMERA */ |
| 105 |
DEX_GPIO_CFG(2, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0), /* DAT2 */ |
| 106 |
DEX_GPIO_CFG(3, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0), /* DAT3 */ |
| 107 |
DEX_GPIO_CFG(4, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0), /* DAT4 */ |
| 108 |
DEX_GPIO_CFG(5, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0), /* DAT5 */ |
| 109 |
DEX_GPIO_CFG(6, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0), /* DAT6 */ |
| 110 |
DEX_GPIO_CFG(7, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0), /* DAT7 */ |
| 111 |
DEX_GPIO_CFG(8, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0), /* DAT8 */ |
| 112 |
DEX_GPIO_CFG(9, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0), /* DAT9 */ |
| 113 |
DEX_GPIO_CFG(10, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0), /* DAT10 */ |
| 114 |
DEX_GPIO_CFG(11, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0), /* DAT11 */ |
| 115 |
DEX_GPIO_CFG(12, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0), /* PCLK */ |
| 116 |
DEX_GPIO_CFG(13, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0), /* HSYNC_IN */ |
| 117 |
DEX_GPIO_CFG(14, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0), /* VSYNC_IN */ |
| 118 |
DEX_GPIO_CFG(15, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_16MA, 0), /* MCLK */ |
| 119 |
}; |
| 120 |
|
| 121 |
static struct msm_gpio_config camera_on_gpio_table[] = { |
| 122 |
/* CAMERA */ |
| 123 |
DEX_GPIO_CFG(2, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA, 0), /* DAT2 */ |
| 124 |
DEX_GPIO_CFG(3, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA, 0), /* DAT3 */ |
| 125 |
DEX_GPIO_CFG(4, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA, 0), /* DAT4 */ |
| 126 |
DEX_GPIO_CFG(5, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA, 0), /* DAT5 */ |
| 127 |
DEX_GPIO_CFG(6, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA, 0), /* DAT6 */ |
| 128 |
DEX_GPIO_CFG(7, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA, 0), /* DAT7 */ |
| 129 |
DEX_GPIO_CFG(8, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA, 0), /* DAT8 */ |
| 130 |
DEX_GPIO_CFG(9, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA, 0), /* DAT9 */ |
| 131 |
DEX_GPIO_CFG(10, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA, 0), /* DAT10 */ |
| 132 |
DEX_GPIO_CFG(11, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA, 0), /* DAT11 */ |
| 133 |
DEX_GPIO_CFG(12, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA, 0), /* PCLK */ |
| 134 |
DEX_GPIO_CFG(13, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA, 0), /* HSYNC_IN */ |
| 135 |
DEX_GPIO_CFG(14, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA, 0), /* VSYNC_IN */ |
| 136 |
DEX_GPIO_CFG(15, 1, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_16MA, 0), /* MCLK */ |
| 137 |
}; |
| 138 |
|
| 139 |
static void config_gpio_table(struct msm_gpio_config *table, int len) |
| 140 |
{ |
| 141 |
int n; |
| 142 |
struct msm_gpio_config id; |
| 143 |
for(n = 0; n < len; n++) { |
| 144 |
id = table[n]; |
| 145 |
msm_gpio_set_function( id ); |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 149 |
static void config_camera_on_gpios(int bFrontCam) |
| 150 |
{ |
| 151 |
struct msm_dex_command dex = { .cmd = PCOM_PMIC_REG_ON, .has_data=1 }; |
| 152 |
char SKUID_PCBA_PN0, SKUID_PCBA_PN1, SKUID_SKU; |
| 153 |
int cam_pwr_gpio; |
| 154 |
|
| 155 |
if ( machine_is_htcdiamond() ) { |
| 156 |
/* VDD 1.8V */ |
| 157 |
dex.data=0x100; |
| 158 |
msm_proc_comm_wince(&dex,0); |
| 159 |
mdelay(20); |
| 160 |
/* VDD 2.65V */ |
| 161 |
dex.data=0x400000; |
| 162 |
msm_proc_comm_wince(&dex,0); |
| 163 |
mdelay(20); |
| 164 |
/* VDD 2.85V */ |
| 165 |
dex.data=0x20; |
| 166 |
msm_proc_comm_wince(&dex,0); |
| 167 |
mdelay(20); |
| 168 |
} else { |
| 169 |
/* VDDD 2.65V */ |
| 170 |
dex.data=0x100; |
| 171 |
msm_proc_comm_wince(&dex,0); |
| 172 |
mdelay(20); |
| 173 |
/* VDDIO 1.8V */ |
| 174 |
dex.data=0x200000; |
| 175 |
msm_proc_comm_wince(&dex,0); |
| 176 |
mdelay(20); |
| 177 |
/* VCM VDDD 1.8V */ |
| 178 |
dex.data=0x8000; |
| 179 |
msm_proc_comm_wince(&dex,0); |
| 180 |
mdelay(20); |
| 181 |
/* VDDA 2.85V */ |
| 182 |
dex.data=0x20; |
| 183 |
msm_proc_comm_wince(&dex,0); |
| 184 |
mdelay(20); |
| 185 |
} |
| 186 |
|
| 187 |
/* Configure common camera pins */ |
| 188 |
config_gpio_table(camera_on_gpio_table, |
| 189 |
ARRAY_SIZE(camera_on_gpio_table)); |
| 190 |
|
| 191 |
msm_gpio_set_function( DEX_GPIO_CFG(107, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0) ); |
| 192 |
|
| 193 |
if ( machine_is_htcdiamond() ) { |
| 194 |
SKUID_PCBA_PN0 = readb( MSM_SPL_BASE + 0x81C00 ) ; |
| 195 |
SKUID_PCBA_PN1 = readb( MSM_SPL_BASE + 0x81C01 ) ; |
| 196 |
SKUID_SKU = readb( MSM_SPL_BASE + 0x81C04 ) ; |
| 197 |
|
| 198 |
if ( (SKUID_PCBA_PN0 == 0xE5) || (SKUID_PCBA_PN1 != 1) ) { |
| 199 |
cam_pwr_gpio = DIAMx00_CAM_PWR2; |
| 200 |
} else { |
| 201 |
cam_pwr_gpio = DIAMx00_CAM_PWR1; |
| 202 |
} |
| 203 |
printk("%s : cam_pwr_gpio (1) = %d\n", __func__, cam_pwr_gpio); |
| 204 |
|
| 205 |
/* Select camera (front or back) */ |
| 206 |
msm_gpio_set_function( DEX_GPIO_CFG(cam_pwr_gpio , 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, bFrontCam) ); |
| 207 |
msm_gpio_set_function( DEX_GPIO_CFG(DIAMx00_MT9T013_RST, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0) ); |
| 208 |
msm_gpio_set_function( DEX_GPIO_CFG(DIAMx00_MT9V113_RST, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0) ); |
| 209 |
|
| 210 |
if ( (SKUID_PCBA_PN0 == 0xE5) || (SKUID_PCBA_PN1 != 1) ) { |
| 211 |
cam_pwr_gpio = DIAMx00_CAM_PWR1; |
| 212 |
} else { |
| 213 |
cam_pwr_gpio = DIAMx00_CAM_PWR2; |
| 214 |
} |
| 215 |
printk("%s : cam_pwr_gpio (2) = %d\n", __func__, cam_pwr_gpio); |
| 216 |
|
| 217 |
msm_gpio_set_function( DEX_GPIO_CFG(cam_pwr_gpio , 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0) ); |
| 218 |
msm_gpio_set_function( DEX_GPIO_CFG(DIAMx00_VCM_PWDN , 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 1) ); |
| 219 |
} |
| 220 |
} |
| 221 |
|
| 222 |
static void config_camera_off_gpios(void) |
| 223 |
{ |
| 224 |
struct msm_dex_command dex = { .cmd = PCOM_PMIC_REG_OFF, .has_data=1 }; |
| 225 |
|
| 226 |
if ( machine_is_htcdiamond() ) { |
| 227 |
/* VDD 1.8V */ |
| 228 |
dex.data=0x100; |
| 229 |
msm_proc_comm_wince(&dex,0); |
| 230 |
mdelay(20); |
| 231 |
/* VDD 2.65V */ |
| 232 |
dex.data=0x400000; |
| 233 |
msm_proc_comm_wince(&dex,0); |
| 234 |
mdelay(20); |
| 235 |
/* VDD 2.85V */ |
| 236 |
dex.data=0x20; |
| 237 |
msm_proc_comm_wince(&dex,0); |
| 238 |
mdelay(20); |
| 239 |
} else { |
| 240 |
/* VCM VDDD 1.8V */ |
| 241 |
dex.data=0x8000; |
| 242 |
msm_proc_comm_wince(&dex,0); |
| 243 |
mdelay(20); |
| 244 |
/* VDDA 2.85V */ |
| 245 |
dex.data=0x20; |
| 246 |
msm_proc_comm_wince(&dex,0); |
| 247 |
mdelay(20); |
| 248 |
/* VDDD 2.65V */ |
| 249 |
dex.data=0x100; |
| 250 |
msm_proc_comm_wince(&dex,0); |
| 251 |
mdelay(20); |
| 252 |
/* VDDIO 1.8V */ |
| 253 |
dex.data=0x200000; |
| 254 |
msm_proc_comm_wince(&dex,0); |
| 255 |
mdelay(20); |
| 256 |
} |
| 257 |
|
| 258 |
if ( machine_is_htcdiamond() ) { |
| 259 |
/* Reset camera select gpio to main (back) camera */ |
| 260 |
gpio_direction_output(DIAMx00_CAM_PWR1, 1); |
| 261 |
} |
| 262 |
|
| 263 |
config_gpio_table(camera_off_gpio_table, |
| 264 |
ARRAY_SIZE(camera_off_gpio_table)); |
| 265 |
|
| 266 |
msm_gpio_set_function( DEX_GPIO_CFG(107 , 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA, 0) ); |
| 267 |
} |
| 268 |
|
| 269 |
#ifdef CONFIG_MT9T013 |
| 270 |
static void config_camera_on_gpios_mt9t013(void) |
| 271 |
{ |
| 272 |
config_camera_on_gpios(0); |
| 273 |
} |
| 274 |
#endif |
| 275 |
|
| 276 |
#ifdef CONFIG_MT9V113 |
| 277 |
static void config_camera_on_gpios_mt9v113(void) |
| 278 |
{ |
| 279 |
config_camera_on_gpios(1); |
| 280 |
} |
| 281 |
#endif |
| 282 |
|
| 283 |
#endif |
| 284 |
|
| 285 |
static struct i2c_board_info i2c_devices[] = { |
| 286 |
{ |
| 287 |
// LED & Backlight controller |
| 288 |
I2C_BOARD_INFO("microp-klt", 0x66), |
| 289 |
}, |
| 290 |
#if defined(CONFIG_MSM_CAMERA) && defined(CONFIG_MT9T013) |
| 291 |
{ |
| 292 |
I2C_BOARD_INFO("mt9t013", 0x6C), |
| 293 |
}, |
| 294 |
#endif |
| 295 |
#if defined(CONFIG_MSM_CAMERA) && defined(CONFIG_MT9V113) |
| 296 |
{ |
| 297 |
I2C_BOARD_INFO("mt9v113", 0x78), |
| 298 |
}, |
| 299 |
#endif |
| 300 |
{ |
| 301 |
// Raphael NaviPad (cy8c20434) |
| 302 |
I2C_BOARD_INFO("raph_navi_pad", 0x62), |
| 303 |
}, |
| 304 |
{ |
| 305 |
// Accelerometer |
| 306 |
I2C_BOARD_INFO("kionix-kxsd9", 0x18), |
| 307 |
}, |
| 308 |
|
| 309 |
}; |
| 310 |
|
| 311 |
static smem_batt_t msm_battery_pdata = { |
| 312 |
.gpio_battery_detect = RAPH100_BAT_IRQ, |
| 313 |
.gpio_charger_enable = RAPH100_CHARGE_EN_N, |
| 314 |
.gpio_charger_current_select = RAPH100_USB_AC_PWR, |
| 315 |
.smem_offset = 0xfc140, |
| 316 |
.smem_field_size = 4, |
| 317 |
}; |
| 318 |
|
| 319 |
static struct platform_device raphael_rfkill = { |
| 320 |
.name = "htcraphael_rfkill", |
| 321 |
.id = -1, |
| 322 |
}; |
| 323 |
|
| 324 |
#define SND(num, desc) { .name = desc, .id = num } |
| 325 |
static struct snd_endpoint snd_endpoints_list[] = { |
| 326 |
SND(0, "HANDSET"), |
| 327 |
SND(1, "SPEAKER"), |
| 328 |
SND(2, "HEADSET"), |
| 329 |
SND(2, "NO_MIC_HEADSET"), |
| 330 |
SND(3, "BT"), |
| 331 |
SND(3, "BT_EC_OFF"), |
| 332 |
|
| 333 |
SND(0xD, "IDLE"), |
| 334 |
SND(256, "CURRENT"), |
| 335 |
}; |
| 336 |
#undef SND |
| 337 |
|
| 338 |
static struct msm_snd_endpoints raphael_snd_endpoints = { |
| 339 |
.endpoints = snd_endpoints_list, |
| 340 |
.num = ARRAY_SIZE(snd_endpoints_list), |
| 341 |
}; |
| 342 |
|
| 343 |
static struct platform_device raphael_snd = { |
| 344 |
.name = "msm_snd", |
| 345 |
.id = -1, |
| 346 |
.dev = { |
| 347 |
.platform_data = &raphael_snd_endpoints, |
| 348 |
}, |
| 349 |
}; |
| 350 |
|
| 351 |
#ifdef CONFIG_MSM_CAMERA |
| 352 |
|
| 353 |
#ifdef CONFIG_MT9T013 |
| 354 |
static struct msm_camera_device_platform_data msm_camera_device_data_mt9t013 = { |
| 355 |
.camera_gpio_on = config_camera_on_gpios_mt9t013, |
| 356 |
.camera_gpio_off = config_camera_off_gpios, |
| 357 |
.ioext.mdcphy = MSM_MDC_PHYS, |
| 358 |
.ioext.mdcsz = MSM_MDC_SIZE, |
| 359 |
.ioext.appphy = MSM_CLK_CTL_PHYS, |
| 360 |
.ioext.appsz = MSM_CLK_CTL_SIZE, |
| 361 |
}; |
| 362 |
|
| 363 |
static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = { |
| 364 |
.sensor_name = "mt9t013", |
| 365 |
.sensor_node = 0, |
| 366 |
.sensor_reset = DIAMx00_MT9T013_RST, |
| 367 |
// .sensor_pwd = DIAMx00_CAM_PWR1, // Only used for ov8810 & ov9665 sensors |
| 368 |
.vcm_pwd = DIAMx00_VCM_PWDN, |
| 369 |
.pdata = &msm_camera_device_data_mt9t013, |
| 370 |
}; |
| 371 |
|
| 372 |
static struct platform_device msm_camera_sensor_mt9t013 = { |
| 373 |
.name = "msm_camera_mt9t013", |
| 374 |
.dev = { |
| 375 |
.platform_data = &msm_camera_sensor_mt9t013_data, |
| 376 |
}, |
| 377 |
}; |
| 378 |
|
| 379 |
static void msm_camera_mt9t013_cdma500_fixup(void) { |
| 380 |
int HwBoardID = readb( MSM_SPL_BASE + 0x81030 ) ; |
| 381 |
|
| 382 |
/* DIAM500 do not use vcm_pwd pin. Disable it */ |
| 383 |
msm_camera_sensor_mt9t013_data.vcm_pwd = 0; |
| 384 |
|
| 385 |
/* Sensor reset pin depends on board ID */ |
| 386 |
if ( HwBoardID < 2 ) { |
| 387 |
msm_camera_sensor_mt9t013_data.sensor_reset = DIAMx00_MT9T013_RST; |
| 388 |
} else { |
| 389 |
msm_camera_sensor_mt9t013_data.sensor_reset = DIAMx00_CAM_PWR2; |
| 390 |
} |
| 391 |
} |
| 392 |
#endif |
| 393 |
|
| 394 |
#ifdef CONFIG_MT9V113 |
| 395 |
static struct msm_camera_device_platform_data msm_camera_device_data_mt9v113 = { |
| 396 |
.camera_gpio_on = config_camera_on_gpios_mt9v113, |
| 397 |
.camera_gpio_off = config_camera_off_gpios, |
| 398 |
.ioext.mdcphy = MSM_MDC_PHYS, |
| 399 |
.ioext.mdcsz = MSM_MDC_SIZE, |
| 400 |
.ioext.appphy = MSM_CLK_CTL_PHYS, |
| 401 |
.ioext.appsz = MSM_CLK_CTL_SIZE, |
| 402 |
}; |
| 403 |
|
| 404 |
static struct msm_camera_sensor_info msm_camera_sensor_mt9v113_data = { |
| 405 |
.sensor_name = "mt9v113", |
| 406 |
.sensor_node = 1, |
| 407 |
.sensor_reset = DIAMx00_MT9V113_RST, |
| 408 |
.sensor_pwd = DIAMx00_CAM_PWR1, |
| 409 |
.vcm_pwd = 0, // 0 means not used |
| 410 |
.pdata = &msm_camera_device_data_mt9v113, |
| 411 |
}; |
| 412 |
|
| 413 |
static struct platform_device msm_camera_sensor_mt9v113 = { |
| 414 |
.name = "msm_camera_mt9v113", |
| 415 |
.dev = { |
| 416 |
.platform_data = &msm_camera_sensor_mt9v113_data, |
| 417 |
}, |
| 418 |
}; |
| 419 |
#endif |
| 420 |
|
| 421 |
#endif |
| 422 |
|
| 423 |
|
| 424 |
static struct pwr_sink diamond_pwrsink_table[] = { |
| 425 |
{ |
| 426 |
.id = PWRSINK_AUDIO, |
| 427 |
.ua_max = 90000, |
| 428 |
}, |
| 429 |
{ |
| 430 |
.id = PWRSINK_BACKLIGHT, |
| 431 |
.ua_max = 128000, |
| 432 |
}, |
| 433 |
{ |
| 434 |
.id = PWRSINK_LED_BUTTON, |
| 435 |
.ua_max = 17000, |
| 436 |
}, |
| 437 |
{ |
| 438 |
.id = PWRSINK_LED_KEYBOARD, |
| 439 |
.ua_max = 22000, |
| 440 |
}, |
| 441 |
{ |
| 442 |
.id = PWRSINK_GP_CLK, |
| 443 |
.ua_max = 30000, |
| 444 |
}, |
| 445 |
{ |
| 446 |
.id = PWRSINK_BLUETOOTH, |
| 447 |
.ua_max = 15000, |
| 448 |
}, |
| 449 |
{ |
| 450 |
.id = PWRSINK_CAMERA, |
| 451 |
.ua_max = 0, |
| 452 |
}, |
| 453 |
{ |
| 454 |
.id = PWRSINK_SDCARD, |
| 455 |
.ua_max = 0, |
| 456 |
}, |
| 457 |
{ |
| 458 |
.id = PWRSINK_VIDEO, |
| 459 |
.ua_max = 0, |
| 460 |
}, |
| 461 |
{ |
| 462 |
.id = PWRSINK_WIFI, |
| 463 |
.ua_max = 200000, |
| 464 |
}, |
| 465 |
{ |
| 466 |
.id = PWRSINK_SYSTEM_LOAD, |
| 467 |
.ua_max = 100000, |
| 468 |
.percent_util = 38, |
| 469 |
}, |
| 470 |
}; |
| 471 |
|
| 472 |
static struct pwr_sink_platform_data diamond_pwrsink_data = { |
| 473 |
.num_sinks = ARRAY_SIZE(diamond_pwrsink_table), |
| 474 |
.sinks = diamond_pwrsink_table, |
| 475 |
.suspend_late = NULL, |
| 476 |
.resume_early = NULL, |
| 477 |
.suspend_early = NULL, |
| 478 |
.resume_late = NULL, |
| 479 |
}; |
| 480 |
|
| 481 |
static struct platform_device diamond_pwr_sink = { |
| 482 |
.name = "htc_pwrsink", |
| 483 |
.id = -1, |
| 484 |
.dev = { |
| 485 |
.platform_data = &diamond_pwrsink_data, |
| 486 |
}, |
| 487 |
}; |
| 488 |
|
| 489 |
|
| 490 |
#ifdef CONFIG_HTC_HEADSET |
| 491 |
|
| 492 |
static void h2w_config_cpld(int route); |
| 493 |
static void h2w_init_cpld(void); |
| 494 |
static struct h2w_platform_data diamond_h2w_data = { |
| 495 |
.cable_in1 = 18,//TROUT_GPIO_CABLE_IN1, |
| 496 |
.cable_in2 = 45,//TROUT_GPIO_CABLE_IN2, |
| 497 |
.h2w_clk = 46,//TROUT_GPIO_H2W_CLK_GPI, |
| 498 |
.h2w_data = 31,//TROUT_GPIO_H2W_DAT_GPI, |
| 499 |
.debug_uart = H2W_UART3, |
| 500 |
.config_cpld = h2w_config_cpld, |
| 501 |
.init_cpld = h2w_init_cpld, |
| 502 |
.headset_mic_35mm = 17, |
| 503 |
}; |
| 504 |
|
| 505 |
static void h2w_config_cpld(int route) |
| 506 |
{ |
| 507 |
switch (route) { |
| 508 |
case H2W_UART3: |
| 509 |
gpio_set_value(0, 1); |
| 510 |
break; |
| 511 |
case H2W_GPIO: |
| 512 |
gpio_set_value(0, 0); |
| 513 |
break; |
| 514 |
} |
| 515 |
} |
| 516 |
|
| 517 |
static void h2w_init_cpld(void) |
| 518 |
{ |
| 519 |
h2w_config_cpld(H2W_UART3); |
| 520 |
gpio_set_value(diamond_h2w_data.h2w_clk, 0); |
| 521 |
gpio_set_value(diamond_h2w_data.h2w_data, 0); |
| 522 |
} |
| 523 |
|
| 524 |
static struct platform_device diamond_h2w = { |
| 525 |
.name = "h2w", |
| 526 |
.id = -1, |
| 527 |
.dev = { |
| 528 |
.platform_data = &diamond_h2w_data, |
| 529 |
}, |
| 530 |
}; |
| 531 |
#endif |
| 532 |
|
| 533 |
static struct platform_device touchscreen = { |
| 534 |
.name = "tssc-manager", |
| 535 |
.id = -1, |
| 536 |
}; |
| 537 |
|
| 538 |
static struct platform_device *devices[] __initdata = { |
| 539 |
// &diamond_pwr_sink, |
| 540 |
&raphael_rfkill, |
| 541 |
&msm_device_smd, |
| 542 |
&msm_device_nand, |
| 543 |
&msm_device_i2c, |
| 544 |
&msm_device_rtc, |
| 545 |
&msm_device_htc_hw, |
| 546 |
#if !defined(CONFIG_MSM_SERIAL_DEBUGGER) && !defined(CONFIG_HTC_HEADSET) |
| 547 |
// &msm_device_uart1, |
| 548 |
#endif |
| 549 |
#ifdef CONFIG_SERIAL_MSM_HS |
| 550 |
&msm_device_uart_dm2, |
| 551 |
#endif |
| 552 |
&msm_device_htc_battery, |
| 553 |
&raphael_snd, |
| 554 |
&touchscreen, |
| 555 |
#ifdef CONFIG_HTC_HEADSET |
| 556 |
&diamond_h2w, |
| 557 |
#endif |
| 558 |
#ifdef CONFIG_MT9T013 |
| 559 |
&msm_camera_sensor_mt9t013, |
| 560 |
#endif |
| 561 |
&acoustic_device, |
| 562 |
}; |
| 563 |
|
| 564 |
extern struct sys_timer msm_timer; |
| 565 |
|
| 566 |
static void __init halibut_init_irq(void) |
| 567 |
{ |
| 568 |
msm_init_irq(); |
| 569 |
} |
| 570 |
|
| 571 |
static struct msm_acpu_clock_platform_data halibut_clock_data = { |
| 572 |
.acpu_switch_time_us = 50, |
| 573 |
.max_speed_delta_khz = 256000, |
| 574 |
.vdd_switch_time_us = 62, |
| 575 |
.power_collapse_khz = 19200, |
| 576 |
.wait_for_irq_khz = 128000, |
| 577 |
}; |
| 578 |
|
| 579 |
void msm_serial_debug_init(unsigned int base, int irq, |
| 580 |
const char *clkname, int signal_irq); |
| 581 |
|
| 582 |
#ifdef CONFIG_SERIAL_MSM_HS |
| 583 |
static struct msm_serial_hs_platform_data msm_uart_dm2_pdata = { |
| 584 |
.wakeup_irq = MSM_GPIO_TO_INT(21), |
| 585 |
.inject_rx_on_wakeup = 1, |
| 586 |
.rx_to_inject = 0x32, |
| 587 |
}; |
| 588 |
#endif |
| 589 |
|
| 590 |
static htc_hw_pdata_t msm_htc_hw_pdata = { |
| 591 |
.set_vibrate = msm_proc_comm_wince_vibrate, |
| 592 |
.battery_smem_offset = 0xfc140, //XXX: raph800 |
| 593 |
.battery_smem_field_size = 4, |
| 594 |
}; |
| 595 |
|
| 596 |
static void htcdiamond_set_headset_amp(bool enable) { |
| 597 |
if (machine_is_htcdiamond_cdma()) { |
| 598 |
if (enable) |
| 599 |
{ |
| 600 |
/* Power up headphone amp */ |
| 601 |
gpio_configure(DIAMx00_HS_AMP_PWR, GPIOF_DRIVE_OUTPUT | GPIOF_OUTPUT_HIGH); |
| 602 |
} |
| 603 |
else |
| 604 |
{ |
| 605 |
/* Power down headphone amp */ |
| 606 |
gpio_configure(DIAMx00_HS_AMP_PWR, GPIOF_DRIVE_OUTPUT | GPIOF_OUTPUT_LOW); |
| 607 |
} |
| 608 |
gpio_set_value(DIAMx00_HS_AMP_PWR, enable); |
| 609 |
} |
| 610 |
} |
| 611 |
|
| 612 |
static struct htc_acoustic_wce_board_data htcdiamond_acoustic_data = { |
| 613 |
.set_headset_amp = htcdiamond_set_headset_amp, |
| 614 |
}; |
| 615 |
|
| 616 |
static void __init halibut_init(void) |
| 617 |
{ |
| 618 |
struct htc_acoustic_wce_amss_data *acoustic_pdata; |
| 619 |
|
| 620 |
// Fix data in arrays depending on GSM/CDMA version |
| 621 |
htcdiamond_device_specific_fixes(); |
| 622 |
|
| 623 |
msm_acpu_clock_init(&halibut_clock_data); |
| 624 |
msm_proc_comm_wince_init(); |
| 625 |
|
| 626 |
#if defined(CONFIG_MSM_CAMERA) && defined(CONFIG_MT9T013) |
| 627 |
if (!machine_is_htcdiamond()) { |
| 628 |
msm_camera_mt9t013_cdma500_fixup(); |
| 629 |
} |
| 630 |
#endif |
| 631 |
|
| 632 |
// Device pdata overrides |
| 633 |
msm_device_htc_hw.dev.platform_data = &msm_htc_hw_pdata; |
| 634 |
msm_device_htc_battery.dev.platform_data = &msm_battery_pdata; |
| 635 |
|
| 636 |
if(machine_is_htcdiamond()) |
| 637 |
msm_add_usb_devices(usb_phy_reset, NULL, usb_phy_init_seq_diam100); |
| 638 |
else |
| 639 |
msm_add_usb_devices(usb_phy_reset, NULL, usb_phy_init_seq_diam800); |
| 640 |
#ifdef CONFIG_SERIAL_MSM_HS |
| 641 |
msm_device_uart_dm2.dev.platform_data = &msm_uart_dm2_pdata; |
| 642 |
#endif |
| 643 |
|
| 644 |
#ifndef CONFIG_MACH_SAPPHIRE |
| 645 |
msm_init_pmic_vibrator(); |
| 646 |
#endif |
| 647 |
|
| 648 |
// Set acoustic device specific parameters |
| 649 |
acoustic_pdata = acoustic_device.dev.platform_data; |
| 650 |
if ( machine_is_htcdiamond() ) { |
| 651 |
acoustic_pdata->mic_bias_callback = NULL; |
| 652 |
} |
| 653 |
htc_acoustic_wce_board_data = &htcdiamond_acoustic_data; |
| 654 |
|
| 655 |
// Register devices |
| 656 |
platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 657 |
|
| 658 |
// Register I2C devices |
| 659 |
i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices)); |
| 660 |
|
| 661 |
#if defined(CONFIG_MSM_CAMERA) && defined(CONFIG_MT9V113) |
| 662 |
if (!machine_is_htcdiamond()) { |
| 663 |
platform_add_device(&msm_camera_sensor_mt9v113); |
| 664 |
} |
| 665 |
#endif |
| 666 |
|
| 667 |
// Initialize SD controllers |
| 668 |
init_mmc(); |
| 669 |
|
| 670 |
/* TODO: detect vbus and correctly notify USB about its presence |
| 671 |
* For now we just declare that VBUS is present at boot and USB |
| 672 |
* copes, but this is not ideal. |
| 673 |
*/ |
| 674 |
msm_hsusb_set_vbus_state(1); |
| 675 |
|
| 676 |
msm_proc_comm_wince_vibrate_welcome(); |
| 677 |
} |
| 678 |
|
| 679 |
static void __init halibut_map_io(void) |
| 680 |
{ |
| 681 |
msm_map_common_io(); |
| 682 |
msm_clock_init(); |
| 683 |
} |
| 684 |
|
| 685 |
static void __init htcdiamond_fixup(struct machine_desc *desc, struct tag *tags, |
| 686 |
char **cmdline, struct meminfo *mi) |
| 687 |
{ |
| 688 |
mi->nr_banks = 1; |
| 689 |
mi->bank[0].start = PAGE_ALIGN(PHYS_OFFSET); |
| 690 |
mi->bank[0].node = PHYS_TO_NID(mi->bank[0].start); |
| 691 |
mi->bank[0].size = (106 * 1024 * 1024); // See pmem.c |
| 692 |
//mi->nr_banks++; |
| 693 |
mi->bank[1].start = PAGE_ALIGN(0x02000000+(14+2+8+8)*1024*1024); |
| 694 |
mi->bank[1].node = PHYS_TO_NID(mi->bank[1].start); |
| 695 |
mi->bank[1].size = (32-2/*fb*/-14/*pmem*/-8/*adsp*/-8/*camera*/)*1024*1024; |
| 696 |
printk(KERN_INFO "fixup: nr_banks = %d\n", mi->nr_banks); |
| 697 |
printk(KERN_INFO "fixup: bank0 start=%08lx, node=%08x, size=%08lx\n", mi->bank[0].start, mi->bank[0].node, mi->bank[0].size); |
| 698 |
if(mi->nr_banks==2) |
| 699 |
printk(KERN_INFO "fixup: bank1 start=%08lx, node=%08x, size=%08lx\n", mi->bank[1].start, mi->bank[1].node, mi->bank[1].size); |
| 700 |
} |
| 701 |
|
| 702 |
static void __init htcdiamond_cdma_fixup(struct machine_desc *desc, struct tag *tags, |
| 703 |
char **cmdline, struct meminfo *mi) |
| 704 |
{ |
| 705 |
mi->nr_banks = 1; |
| 706 |
mi->bank[0].start = PAGE_ALIGN(PHYS_OFFSET); |
| 707 |
mi->bank[0].node = PHYS_TO_NID(mi->bank[0].start); |
| 708 |
mi->bank[0].size = (107 * 1024 * 1024); |
| 709 |
mi->nr_banks++; |
| 710 |
mi->bank[1].start = PAGE_ALIGN(PHYS_OFFSET + 0x10000000); |
| 711 |
mi->bank[1].node = PHYS_TO_NID(mi->bank[1].start); |
| 712 |
mi->bank[1].size = 128*1024*1024-(50*1024*1024); // See pmem.c |
| 713 |
printk(KERN_INFO "fixup: nr_banks = %d\n", mi->nr_banks); |
| 714 |
printk(KERN_INFO "fixup: bank0 start=%08lx, node=%08x, size=%08lx\n", mi->bank[0].start, mi->bank[0].node, mi->bank[0].size); |
| 715 |
printk(KERN_INFO "fixup: bank1 start=%08lx, node=%08x, size=%08lx\n", mi->bank[1].start, mi->bank[1].node, mi->bank[1].size); |
| 716 |
} |
| 717 |
|
| 718 |
/* Already implemented for the Raphael board, to facilitate differences between GSM/CDMA */ |
| 719 |
static void htcdiamond_device_specific_fixes(void) |
| 720 |
{ |
| 721 |
if (machine_is_htcdiamond()) { |
| 722 |
msm_htc_hw_pdata.battery_smem_offset = 0xfc110; |
| 723 |
msm_htc_hw_pdata.battery_smem_field_size = 2; |
| 724 |
msm_battery_pdata.smem_offset = 0xfc110; |
| 725 |
msm_battery_pdata.smem_field_size = 2; |
| 726 |
} |
| 727 |
if (machine_is_htcdiamond_cdma()) { |
| 728 |
msm_htc_hw_pdata.battery_smem_offset = 0xfc140; |
| 729 |
msm_htc_hw_pdata.battery_smem_field_size = 4; |
| 730 |
msm_battery_pdata.smem_offset = 0xfc140; |
| 731 |
msm_battery_pdata.smem_field_size = 4; |
| 732 |
} |
| 733 |
} |
| 734 |
|
| 735 |
MACHINE_START(HTCDIAMOND, "HTC Diamond GSM phone (aka HTC Touch Diamond)") |
| 736 |
.fixup = htcdiamond_fixup, |
| 737 |
.boot_params = 0x10000100, |
| 738 |
.map_io = halibut_map_io, |
| 739 |
.init_irq = halibut_init_irq, |
| 740 |
.init_machine = halibut_init, |
| 741 |
.timer = &msm_timer, |
| 742 |
MACHINE_END |
| 743 |
|
| 744 |
MACHINE_START(HTCDIAMOND_CDMA, "HTC Diamond CDMA phone (aka HTC Touch Diamond)") |
| 745 |
.fixup = htcdiamond_cdma_fixup, |
| 746 |
.boot_params = 0x10000100, |
| 747 |
.map_io = halibut_map_io, |
| 748 |
.init_irq = halibut_init_irq, |
| 749 |
.init_machine = halibut_init, |
| 750 |
.timer = &msm_timer, |
| 751 |
MACHINE_END |