static int capella_cm3602_power(int on)
{
    int rc = 0;
    unsigned long flags;
    spin_lock_irqsave(&capella_cm3602_lock, flags);

    if (on) {
        if (!capella_cm3602_open_cnt++)
            rc = __capella_cm3602_power(1);
    } else if (capella_cm3602_open_cnt)
        if (!--capella_cm3602_open_cnt)
            rc = __capella_cm3602_power(0);

    spin_unlock_irqrestore(&capella_cm3602_lock, flags);
    return rc;
}
static int capella_cm3602_power(int pwr_device, uint8_t enable)
{
	unsigned int old_status = 0;
	int ret = 0, on = 0;
	mutex_lock(&capella_cm3602_lock);

	old_status = als_power_control;
	if (enable)
		als_power_control |= pwr_device;
	else
		als_power_control &= ~pwr_device;

	on = als_power_control ? 1 : 0;
	if (old_status == 0 && on)
		ret = __capella_cm3602_power(1);
	else if (!on)
		ret = __capella_cm3602_power(0);

	mutex_unlock(&capella_cm3602_lock);
	return ret;
}
static void __init latte_init(void)
{
    int rc;
    char *cid = NULL;
    printk("latte_init() revision = 0x%X\n", system_rev);
    board_get_cid_tag(&cid);

    /*
     * Setup common MSM GPIOS
     */
    config_gpios();

    /* We need to set this pin to 0 only once on power-up; we will
     * not actually enable the chip until we apply power to it via
     * vreg.
     */
    gpio_direction_output(LATTE_GPIO_LS_EN, 0);
    /* disable power for cm3602 chip */
    __capella_cm3602_power(0);

    msm_hw_reset_hook = latte_reset;

    msm_acpu_clock_init(&latte_clock_data);
    perflock_init(&latte_perflock_data);

#if defined(CONFIG_MSM_SERIAL_DEBUGGER)
    if (!opt_disable_uart3)
        msm_serial_debug_init(MSM_UART3_PHYS, INT_UART3,
                              &msm_device_uart3.dev, 1,
                              MSM_GPIO_TO_INT(LATTE_GPIO_UART3_RX));
#endif

    msm_add_devices();

#ifdef CONFIG_SERIAL_MSM_HS
    msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
    msm_add_serial_devices(3);
#else
    msm_add_serial_devices(0);
#endif

    msm_add_serial_devices(2);
    /*
    	msm_change_usb_id(0x0bb4, 0x0c10);
    */
    msm_add_usb_id_pin_gpio(LATTE_GPIO_USB_ID_PIN);

    msm_register_usb_phy_init_seq(espresso_phy_init_seq);
    msm_hsusb_set_product(espresso_usb_products,
                          ARRAY_SIZE(espresso_usb_products));
    msm_add_usb_devices(latte_phy_reset, latte_phy_shutdown);


    msm_add_mem_devices(&pmem_setting);

    msm_init_pmic_vibrator();
#ifdef CONFIG_MICROP_COMMON
    latte_microp_init();
#endif

    latte_init_h2w_power_gpio();

    rc = latte_init_mmc(system_rev);
    if (rc)
        printk(KERN_CRIT "%s: MMC init failure (%d)\n", __func__, rc);

    /* register flashlight at new-XA above */
    platform_device_register(&latte_flashlight_device);

    /* probe camera driver */
    i2c_register_board_info(0, i2c_camera_devices, ARRAY_SIZE(i2c_camera_devices));

    msm_device_i2c.dev.platform_data = &latte_i2c_device_data;
    platform_add_devices(devices, ARRAY_SIZE(devices));
    i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));

    latte_init_keypad();
}
static void __init buzzc_init(void)
{
	int rc;
	struct kobject *properties_kobj;

	printk("buzzc_init() revision=%d\n", system_rev);
	printk(KERN_INFO "mfg_mode=%d\n", board_mfg_mode());
	if (board_mfg_mode() == 1) {
		tssc_ts_device_data.cal_err = 25;
		printk(KERN_INFO "cal_err=%d\n", tssc_ts_device_data.cal_err);
	}


	/* for bcm */
	bt_export_bd_address();

	/*
	 * Setup common MSM GPIOS
	 */
	config_gpios();

	/* We need to set this pin to 0 only once on power-up; we will
	 * not actually enable the chip until we apply power to it via
	 * vreg.
	 */
	gpio_direction_output(BUZZC_GPIO_LS_EN, 0);
	/* disable power for cm3602 chip */
	__capella_cm3602_power(0);

	msm_hw_reset_hook = buzzc_reset;

	msm_acpu_clock_init(&buzzc_clock_data);
	perflock_init(&buzzc_perflock_data);
	/* adjust GPIOs based on bootloader request */

#if defined(CONFIG_MSM_SERIAL_DEBUGGER)
	if (!opt_disable_uart3)
		msm_serial_debug_init(MSM_UART3_PHYS, INT_UART3,
			&msm_device_uart3.dev, 1,
				MSM_GPIO_TO_INT(BUZZC_GPIO_UART3_RX));
#endif

#ifdef CONFIG_SERIAL_MSM_HS
	msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
	msm_device_uart_dm1.name = "msm_serial_hs_bcm";	/* for bcm */
	msm_add_serial_devices(3);
#else
	msm_add_serial_devices(0);
#endif

	msm_add_serial_devices(2);
	msm_add_usb_id_pin_gpio(BUZZC_GPIO_USB_ID_PIN);
	msm_add_usb_devices(buzzc_phy_reset, NULL);

	msm_add_mem_devices(&pmem_setting);
	msm_init_pmic_vibrator();
#ifdef CONFIG_MICROP_COMMON
	buzzc_microp_init();
#endif

	rc = buzzc_init_mmc(system_rev);
	if (rc)
		printk(KERN_CRIT "%s: MMC init failure (%d)\n", __func__, rc);

	properties_kobj = kobject_create_and_add("board_properties", NULL);

	if (properties_kobj)
		rc = sysfs_create_group(properties_kobj,
					 &buzzc_properties_attr_group);
	if (!properties_kobj || rc)
		pr_err("failed to create board_properties\n");

	msm_device_i2c.dev.platform_data = &buzzc_i2c_device_data;

	platform_add_devices(devices, ARRAY_SIZE(devices));

	i2c_register_board_info(0, i2c_sensor, ARRAY_SIZE(i2c_sensor));
	i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
	i2c_register_board_info(0 , &i2c_microp_devices, 1);

	buzzc_init_keypad();
}
static void __init desirec_init(void)
{
    int rc;
    struct kobject *properties_kobj;
    printk(KERN_INFO "%s() revision = %d\n", __func__, system_rev);

    config_gpios();

    if (system_rev > 0) {
        /* We need to set this pin to 0 only once on power-up; we will
         * not actually enable the chip until we apply power to it via
         * vreg.
         */
        gpio_direction_output(DESIREC_GPIO_CM3602_EN, 0);
        /* disable power for cm3602 chip */
        __capella_cm3602_power(0);
    }

    msm_hw_reset_hook = desirec_reset;

    msm_acpu_clock_init(&desirec_clock_data);
    perflock_init(&desirec_perflock_data);

#if defined(CONFIG_MSM_SERIAL_DEBUGGER)
    if (!opt_disable_uart3)
        msm_serial_debug_init(MSM_UART3_PHYS, INT_UART3,
                              &msm_device_uart3.dev, 1, INT_UART3_RX);
#endif

    msm_add_devices();

    clear_bluetooth_rx_irq_status();

#ifdef CONFIG_SERIAL_MSM_HS
    msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
    msm_add_serial_devices(MSM_SERIAL_UART1DM);
#else
    msm_add_serial_devices(MSM_SERIAL_UART1);
#endif

    msm_add_serial_devices(MSM_SERIAL_UART3);

    msm_add_usb_devices(desirec_phy_reset, desirec_phy_shutdown);

    if (board_mcp_monodie())
        msm_add_mem_devices(&pmem_mono_die_setting);
    else
        msm_add_mem_devices(&pmem_dual_die_setting);

    msm_init_pmic_vibrator();

    rc = desirec_init_mmc(system_rev);
    if (rc)
        printk(KERN_CRIT "%s: MMC init failure (%d)\n", __func__, rc);

    properties_kobj = kobject_create_and_add("board_properties", NULL);
    if (properties_kobj)
        rc = sysfs_create_group(properties_kobj,
                                &desirec_properties_attr_group);
    if (!properties_kobj || rc)
        pr_err("failed to create board_properties\n");

    msm_device_i2c.dev.platform_data = &desirec_i2c_device_data;

    if (system_rev > 0) /*Aobve XB*/
        platform_add_devices(devices, ARRAY_SIZE(devices));
    else /* XA */
        platform_add_devices(devices0, ARRAY_SIZE(devices0));

    if (system_rev > 0) {
        microp_data.ls_power = capella_cm3602_power;
        if (system_rev >= 2) {
            microp_data.num_pins = ARRAY_SIZE(microp_pins_2);
            microp_data.pin_config = microp_pins_2;
        }
    }

    i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
    /* r porting*///	i2c_register_board_info(0, &i2c_s5k3e2fx, 1);
}