int __init pluto_sensors_init(void)
{
	int err;

	tegra_get_board_info(&board_info);

	pr_debug("%s: ++\n", __func__);

#ifndef CONFIG_OF
	pluto_camera_init();
#endif
	err = pluto_nct1008_init();
	if (err)
		return err;

	err = i2c_register_board_info(0, pluto_i2c1_isl_board_info,
				ARRAY_SIZE(pluto_i2c1_isl_board_info));
	if (err)
		pr_err("%s: isl board register failed.\n", __func__);

	mpuirq_init();
	max77665_init();

	if (get_power_supply_type() == POWER_SUPPLY_TYPE_BATTERY)
		max17042_pdata.is_battery_present = true;

	err = i2c_register_board_info(0, max17042_device,
				ARRAY_SIZE(max17042_device));
	if (err)
		pr_err("%s: max17042 device register failed.\n", __func__);


	return 0;
}
void __init macallan_sysedp_init(void)
{
	struct edp_governor *g;
	int r;

	if (!IS_ENABLED(CONFIG_EDP_FRAMEWORK))
		return;

	if (get_power_supply_type() != POWER_SUPPLY_TYPE_BATTERY)
		macallan_sysedp_manager.max = INT_MAX;

	r = edp_register_manager(&macallan_sysedp_manager);
	WARN_ON(r);
	if (r)
		return;

	/* start with priority governor */
	g = edp_get_governor("priority");
	WARN_ON(!g);
	if (!g)
		return;

	r = edp_set_governor(&macallan_sysedp_manager, g);
	WARN_ON(r);
}
Esempio n. 3
0
int __init macallan_regulator_init(void)
{
	struct board_info board_info;
	tegra_get_board_info(&board_info);

#ifdef CONFIG_ARCH_TEGRA_HAS_CL_DVFS
	macallan_cl_dvfs_init();
#endif
	macallan_palmas_regulator_init();

	if (board_info.board_id == BOARD_E1569) {
		if (get_power_supply_type() != POWER_SUPPLY_TYPE_BATTERY) {
			/* Disable charger when adapter is power source. */
			macallan_bq2419x_pdata.bcharger_pdata = NULL;
		}
		else {
			/* Only register fuel gauge when using battery. */
			i2c_register_board_info(0, macallan_max17048_boardinfo,
						1);
		}
	} else {
		/* forced make null to prevent charging for E1545. */
		macallan_bq2419x_pdata.bcharger_pdata = NULL;
	}

	bq2419x_boardinfo[0].irq = gpio_to_irq(TEGRA_GPIO_PJ0);
	i2c_register_board_info(0, bq2419x_boardinfo,
			ARRAY_SIZE(bq2419x_boardinfo));

	platform_device_register(&psy_extcon_device);
	platform_device_register(&macallan_pda_power_device);

	return 0;
}
int __init enterprise_regulator_init(void)
{
	void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
	u32 pmc_ctrl;
	u32 pmc_dpd_pads;

	/* configure the power management controller to trigger PMU
	 * interrupts when low */

	pmc_ctrl = readl(pmc + PMC_CTRL);
	writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);

	pmc_dpd_pads = readl(pmc + PMC_DPD_PADS_ORIDE);
	writel(pmc_dpd_pads & ~PMC_DPD_PADS_ORIDE_BLINK , pmc + PMC_DPD_PADS_ORIDE);

	/* Disable battery charging if power adapter is connected. */
	if (get_power_supply_type() == POWER_SUPPLY_TYPE_MAINS) {
		bcharger_pdata.num_consumer_supplies = 0;
		bcharger_pdata.consumer_supplies = NULL;
		battery_gauge_data.battery_present = 0;
	}

	i2c_register_board_info(4, enterprise_regulators, 1);
	pm_power_off = enterprise_power_off;
	is_enterprise_machine = true;

	return 0;
}
Esempio n. 5
0
int __init laguna_regulator_init(void)
{

#ifdef CONFIG_ARCH_TEGRA_HAS_CL_DVFS
	laguna_cl_dvfs_init();
#endif
	tegra_pmc_pmu_interrupt_polarity(true);

	if (get_power_supply_type() == POWER_SUPPLY_TYPE_BATTERY)
		i2c_register_board_info(1, bq2471x_boardinfo,
			ARRAY_SIZE(bq2471x_boardinfo));

	return 0;
}
void __init max77665_init(void)
{
	int err;

	/* For battery presence into charger driver */
	if (get_power_supply_type() == POWER_SUPPLY_TYPE_BATTERY)
		max77665_charger.is_battery_present = true;

	err = i2c_register_board_info(4, pluto_i2c_board_info_max77665,
		ARRAY_SIZE(pluto_i2c_board_info_max77665));
	if (err)
		pr_err("%s: max77665 device register failed.\n", __func__);

	platform_device_register(&psy_extcon_device);

	return;
}
int __init enterprise_regulator_init(void)
{
	void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
	u32 pmc_ctrl;
	u32 pmc_dpd_pads;
	struct board_info board_info;

	tegra_get_board_info(&board_info);

	/* configure the power management controller to trigger PMU
	 * interrupts when low */

	pmc_ctrl = readl(pmc + PMC_CTRL);
	writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);

	pmc_dpd_pads = readl(pmc + PMC_DPD_PADS_ORIDE);
	writel(pmc_dpd_pads & ~PMC_DPD_PADS_ORIDE_BLINK , pmc + PMC_DPD_PADS_ORIDE);

	/* Disable battery charging if power adapter is connected. */
	if (get_power_supply_type() == POWER_SUPPLY_TYPE_MAINS) {
		bcharger_pdata.num_consumer_supplies = 0;
		bcharger_pdata.consumer_supplies = NULL;
		battery_gauge_data.battery_present = 0;
	}

	if (board_info.fab < BOARD_FAB_A03) {
		tps_platform.num_subdevs = ARRAY_SIZE(tps80031_devs_a02);
		tps_platform.subdevs = tps80031_devs_a02;
	} else {
		tps_platform.num_subdevs = ARRAY_SIZE(tps80031_devs_a03);
		tps_platform.subdevs = tps80031_devs_a03;
		tps_platform.pupd_init_data = pupd_idata;
		tps_platform.pupd_init_data_size = ARRAY_SIZE(pupd_idata);
	}

	i2c_register_board_info(4, enterprise_regulators, 1);
	pm_power_off = enterprise_power_off;
	is_enterprise_machine = true;

	return 0;
}
int __init tegratab_regulator_init(void)
{

#ifdef CONFIG_ARCH_TEGRA_HAS_CL_DVFS
	tegratab_cl_dvfs_init();
#endif
	tegratab_palmas_regulator_init();

	i2c_register_board_info(0, tegratab_max17048_boardinfo, 1);

	/* Disable charger when adapter is power source. */
	if (get_power_supply_type() != POWER_SUPPLY_TYPE_BATTERY)
		tegratab_bq2419x_pdata.bcharger_pdata = NULL;

	tegratab_bq2419x_boardinfo[0].irq = gpio_to_irq(TEGRA_GPIO_PJ0);
	i2c_register_board_info(0, tegratab_bq2419x_boardinfo, 1);

	platform_device_register(&tegratab_pda_power_device);

	return 0;
}
int __init enterprise_regulator_init(void)
{
	void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
	u32 pmc_ctrl;

	/* configure the power management controller to trigger PMU
	 * interrupts when low */

	pmc_ctrl = readl(pmc + PMC_CTRL);
	writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);

	/* Disable battery charging if power adapter is connected. */
	if (get_power_supply_type() == power_supply_adapter) {
		bcharger_pdata.num_consumer_supplies = 0;
		bcharger_pdata.consumer_supplies = NULL;
	}
	i2c_register_board_info(4, enterprise_regulators, 1);
	enterprise_gpio_switch_regulator_init();
	pm_power_off = enterprise_power_off;

	return 0;
}
int __init ardbeg_sensors_init(void)
{
	struct board_info board_info;
	tegra_get_board_info(&board_info);
	/* PM363 and PM359 , PM375, PM377 don't have mpu 9250 mounted */
	/* TN8 sensors use Device Tree */
	if (board_info.board_id != BOARD_PM363 &&
		board_info.board_id != BOARD_PM359 &&
		board_info.board_id != BOARD_PM375 &&
		board_info.board_id != BOARD_PM377 &&
		!of_machine_is_compatible("nvidia,tn8"))
		mpuirq_init();
	ardbeg_camera_init();

	if (board_info.board_id == BOARD_P1761 ||
		board_info.board_id == BOARD_E1784 ||
		board_info.board_id == BOARD_E1922) {
		platform_add_devices(gadc_thermal_devices,
				ARRAY_SIZE(gadc_thermal_devices));
		thermistor_table = &tn8_thermistor_table[0];
		thermistor_table_size = ARRAY_SIZE(tn8_thermistor_table);
	} else
		ardbeg_nct72_init();

	/* TN8 and PM359, PM375, PM377 don't have ALS CM32181 */
	if (!of_machine_is_compatible("nvidia,tn8") &&
	    board_info.board_id != BOARD_PM359 &&
	    board_info.board_id != BOARD_PM375 &&
	    board_info.board_id != BOARD_PM377)
		i2c_register_board_info(0, ardbeg_i2c_board_info_cm32181,
			ARRAY_SIZE(ardbeg_i2c_board_info_cm32181));

	if (get_power_supply_type() == POWER_SUPPLY_TYPE_BATTERY)
		i2c_register_board_info(1, bq20z45_pdata,
			ARRAY_SIZE(bq20z45_pdata));

	return 0;
}
int __init atlantis_regulator_init(void)
{
	struct board_info board_info;
	void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
	u32 pmc_ctrl;
	int i;
	bool wdt_disable;

	/* configure the power management controller to trigger PMU
	 * interrupts when high */
	pmc_ctrl = readl(pmc + PMC_CTRL);
	writel(pmc_ctrl & ~PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);

	tegra_get_board_info(&board_info);
	for (i = 0; i < PALMAS_NUM_REGS ; i++) {
		pmic_platform.reg_data[i] = atlantis_reg_data[i];
		pmic_platform.reg_init[i] = atlantis_reg_init[i];
	}

	reg_init_data_ldo5.tracking_regulator = PALMAS_REG_SMPS6;
	/* Enable full constraints to disable unused rails */
	regulator_has_full_constraints();

	/* Set LDO11 startup time to 600us */
	reg_idata_ldo11.constraints.startup_delay = 600;

	if (((board_info.fab != BOARD_FAB_A00) ||
		 (board_info.board_id == BOARD_E1740)))
			reg_idata_regen7.num_consumer_supplies = 0;

	if (board_info.sku == BOARD_SKU_110) {
		pmic_platform.reg_data[PALMAS_REG_SMPS12] = NULL;
		pmic_platform.reg_init[PALMAS_REG_SMPS12] = NULL;

		lp8755_regulator_init();
	} else if (board_info.sku == BOARD_SKU_100 ||
		 board_info.board_id == BOARD_E1740) {
		reg_init_data_smps12.roof_floor = PALMAS_EXT_CONTROL_ENABLE1;
	} else if (board_info.sku == BOARD_SKU_120) {
		pmic_platform.reg_data[PALMAS_REG_SMPS12] =
				atlantis_reg_data[PALMAS_REG_SMPS6];
		pmic_platform.reg_data[PALMAS_REG_SMPS12]->constraints.name =
				palmas_rails(smps12);
		pmic_platform.reg_init[PALMAS_REG_SMPS12] =
				atlantis_reg_init[PALMAS_REG_SMPS6];
		pmic_platform.reg_data[PALMAS_REG_SMPS6] = NULL;
		pmic_platform.reg_init[PALMAS_REG_SMPS6] = NULL;
		reg_init_data_ldo5.config_flags =
				PALMAS_REGULATOR_CONFIG_TRACKING_ENABLE;
		reg_init_data_ldo5.tracking_regulator = PALMAS_REG_SMPS12;

		lp8755_regulator_init();
	}

	platform_device_register(&power_supply_extcon_device);
	if (board_info.board_id == BOARD_E1670) {
		gadc_thermal_battery_pdata.adc_temp_lookup =
				atlanties_ers_batt_temperature_table;
		gadc_thermal_battery_pdata.lookup_table_size =
				ARRAY_SIZE(atlanties_ers_batt_temperature_table);
		gadc_thermal_battery_pdata.first_index_temp = 119;
		gadc_thermal_battery_pdata.last_index_temp = -40;
	} else if (board_info.board_id == BOARD_E1740) {
		gadc_thermal_battery_pdata.adc_temp_lookup = atlantis_ffd_batt_temperature_table;
		gadc_thermal_battery_pdata.lookup_table_size = ARRAY_SIZE(atlantis_ffd_batt_temperature_table);
		gadc_thermal_battery_pdata.first_index_temp = 125;
		gadc_thermal_battery_pdata.last_index_temp = -40;
	}

	if (get_power_supply_type() == POWER_SUPPLY_TYPE_BATTERY) {
		palmas_pdata.battery_pdata->is_battery_present = true;
		palmas_pdata.charger_pdata->bcharger_pdata =
						&palmas_bcharger_pdata;
		platform_device_register(&gadc_thermal_battery);
	}

	wdt_disable = is_pmic_wdt_disabled_at_boot();
	if (wdt_disable)
		palmas_pdata.watchdog_timer_initial_period = 0;

	i2c_register_board_info(4, palma_device,
			ARRAY_SIZE(palma_device));

	return 0;
}
int __init x3_regulator_init(void)
{
	void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
	u32 pmc_ctrl;

	/* configure the power management controller to trigger PMU
	 * interrupts when low */

	pmc_ctrl = readl(pmc + PMC_CTRL);
	writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);

#if defined(CONFIG_MFD_TPS80031)
	/* Disable battery charging if power adapter is connected. */
	if (get_power_supply_type() == POWER_SUPPLY_TYPE_MAINS) {
		bcharger_pdata.num_consumer_supplies = 0;
		bcharger_pdata.consumer_supplies = NULL;
		battery_gauge_data.battery_present = 0;
	}
#endif

	i2c_register_board_info(4, x3_regulators,
			ARRAY_SIZE(x3_regulators));

#if defined(CONFIG_REGULATOR_AAT2870)
	i2c_register_board_info(2, x3_aat2870_i2c_board_info,
			ARRAY_SIZE(x3_aat2870_i2c_board_info));
#endif

#if defined(CONFIG_REGULATOR_GPIO_SWITCH)

#if defined(MACH_X3_REV_B) || defined(MACH_X3_REV_C) || defined(MACH_X3_REV_D) || defined(MACH_X3_REV_E) || defined(MACH_X3_REV_1_0)
	x3_gpio_switch_regulator_init();
#else

//                                          
#if defined(CONFIG_MACH_VU10)
	gpio_switch_regulator_init();
#else
	switch(x3_get_hw_rev_pcb_version())
	{
		case hw_rev_pcb_type_A :
		case hw_rev_pcb_type_B :
		case hw_rev_pcb_type_C :
			x3_gpio_switch_regulator_init_rev_C();
			break;
		case hw_rev_pcb_type_D :
			x3_gpio_switch_regulator_init_rev_D();
			break;
		case hw_rev_pcb_type_E :
		default :
			x3_gpio_switch_regulator_init_rev_E();
			break;
	}
#endif
//                                          

#endif

#endif
	pm_power_off = x3_power_off;
	return 0;
}
static int pmic_chrg_usb_set_property(struct power_supply *psy,
                                      enum power_supply_property psp,
                                      const union power_supply_propval *val)
{
    struct pmic_chrg_info *info = container_of(psy,
                                  struct pmic_chrg_info,
                                  psy_usb);
    int ret = 0;

    mutex_lock(&info->lock);

    switch (psp) {
    case POWER_SUPPLY_PROP_PRESENT:
        info->present = val->intval;
        break;
    case POWER_SUPPLY_PROP_ONLINE:
        info->online = val->intval;
        break;
    case POWER_SUPPLY_PROP_ENABLE_CHARGING:
        ret = pmic_chrg_enable_charging(info, val->intval);
        if (ret < 0)
            dev_warn(&info->pdev->dev, "enable charging failed\n");
        info->is_charging_enabled = val->intval;
        if (!val->intval)
            /* Cancel Full charge worker when disable charging */
            cancel_delayed_work_sync(&info->chrg_full_wrkr);
        break;
    case POWER_SUPPLY_PROP_ENABLE_CHARGER:
        /*
         * Disabling the VSYS or Charger is not
         * allowing the PMIC to detect the subsequent
         * USB plug events. For better to keep the
         * default VBUS ON bit always to have better
         * user experience. So commenting teh actual
         * enable_charger() and for charger enable/disable
         * we need to use teh same enable_charginig() to
         * align with charegr framework.
         *
         * ret = pmic_chrg_enable_charger(info, val->intval);
         */
        ret = pmic_chrg_enable_charging(info, val->intval);
        if (ret < 0)
            dev_warn(&info->pdev->dev, "enable charger failed\n");
        info->is_charger_enabled = val->intval;
        break;
    case POWER_SUPPLY_PROP_CHARGE_CURRENT:
        ret = pmic_chrg_set_cc(info, val->intval);
        if (ret < 0)
            dev_warn(&info->pdev->dev, "set inlimit failed\n");
        info->cc = val->intval;
        break;
    case POWER_SUPPLY_PROP_INLMT:
        ret = pmic_chrg_set_inlmt(info, val->intval);
        if (ret < 0)
            dev_warn(&info->pdev->dev, "set inlimit failed\n");
        info->inlmt = val->intval;
        break;
    case POWER_SUPPLY_PROP_CHARGE_VOLTAGE:
        ret = pmic_chrg_set_cv(info, val->intval);
        if (ret < 0)
            dev_warn(&info->pdev->dev, "set inlimit failed\n");
        info->cv = val->intval;
        break;
    case POWER_SUPPLY_PROP_MAX_CHARGE_CURRENT:
        info->max_cc = val->intval;
        break;
    case POWER_SUPPLY_PROP_MAX_CHARGE_VOLTAGE:
        info->max_cv = val->intval;
        break;
    case POWER_SUPPLY_PROP_CHARGE_TERM_CUR:
        info->iterm = val->intval;
        break;
    case POWER_SUPPLY_PROP_CABLE_TYPE:
        info->cable_type = val->intval;
        info->psy_usb.type = get_power_supply_type(info->cable_type);
        break;
    case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT:
        info->cntl_state = val->intval;
        break;
    case POWER_SUPPLY_PROP_MAX_TEMP:
        info->max_temp = val->intval;
        break;
    case POWER_SUPPLY_PROP_MIN_TEMP:
        info->min_temp = val->intval;
        break;
    default:
        ret = -EINVAL;
    }

    mutex_unlock(&info->lock);
    return ret;
}
static int crystalcove_chgr_usb_set_property(struct power_supply *psy,
				    enum power_supply_property psp,
				    const union power_supply_propval *val)
{
	struct chgr_info *info = container_of(psy,
						    struct chgr_info,
						    psy_usb);
	int ret = 0;

	mutex_lock(&info->lock);

	switch (psp) {
	case POWER_SUPPLY_PROP_PRESENT:
		info->present = val->intval;
		break;
	case POWER_SUPPLY_PROP_ONLINE:
		info->online = val->intval;
		break;
	case POWER_SUPPLY_PROP_ENABLE_CHARGING:
		ret = crystalcove_chgr_enable_charging(info, val->intval);
		if (ret < 0)
			dev_warn(&info->pdev->dev, "crystalcove enable charging failed\n");

		info->is_charging_enabled = val->intval;
		break;
	case POWER_SUPPLY_PROP_ENABLE_CHARGER:

		ret = crystalcove_chgr_enable_charging(info, val->intval);
		if (ret < 0)
			dev_warn(&info->pdev->dev, "crystalcove enable charger failed\n");

		 info->is_charger_enabled = val->intval;
		break;
	case POWER_SUPPLY_PROP_CHARGE_CURRENT:
		info->cc = val->intval;
		break;
	case POWER_SUPPLY_PROP_INLMT:
		info->inlmt = val->intval;
		break;
	case POWER_SUPPLY_PROP_CHARGE_VOLTAGE:
		info->cv = val->intval;
		break;
	case POWER_SUPPLY_PROP_MAX_CHARGE_CURRENT:
		info->max_cc = val->intval;
		break;
	case POWER_SUPPLY_PROP_MAX_CHARGE_VOLTAGE:
		info->max_cv = val->intval;
		break;
	case POWER_SUPPLY_PROP_CHARGE_TERM_CUR:
		info->iterm = val->intval;
		break;
	case POWER_SUPPLY_PROP_CABLE_TYPE:
		info->cable_type = val->intval;
		info->psy_usb.type = get_power_supply_type(info->cable_type);
		break;
	case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT:
		info->cntl_state = val->intval;
		break;
	case POWER_SUPPLY_PROP_MAX_TEMP:
		info->max_temp = val->intval;
		break;
	case POWER_SUPPLY_PROP_MIN_TEMP:
		info->min_temp = val->intval;
		break;
	default:
		ret = -EINVAL;
	}

	mutex_unlock(&info->lock);
	return ret;
}