コード例 #1
0
int __init cardhu_fixed_regulator_init(void)
{
	int i;
	struct board_info board_info;
	struct board_info pmu_board_info;
	struct board_info display_board_info;
	struct platform_device **fixed_reg_devs;
	int    nfixreg_devs;

	if (!is_cardhu_machine)
		return 0;

	tegra_get_board_info(&board_info);
	tegra_get_pmu_board_info(&pmu_board_info);
	tegra_get_display_board_info(&display_board_info);

	if (pmu_board_info.board_id == BOARD_PMU_PM298)
		return cardhu_pm298_gpio_switch_regulator_init();

	if (pmu_board_info.board_id == BOARD_PMU_PM299)
		return cardhu_pm299_gpio_switch_regulator_init();

	switch (board_info.board_id) {
	case BOARD_E1198:
		if (board_info.fab <= BOARD_FAB_A01) {
			nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_e1198_base);
			fixed_reg_devs = fixed_reg_devs_e1198_base;
		} else {
			nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_e1198_a02);
			fixed_reg_devs = fixed_reg_devs_e1198_a02;
		}
		break;

	case BOARD_E1291:
		if (board_info.fab == BOARD_FAB_A03) {
			nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_e1291_a03);
			fixed_reg_devs = fixed_reg_devs_e1291_a03;
		} else if ((board_info.fab == BOARD_FAB_A04) ||
				(board_info.fab == BOARD_FAB_A05)) {
			nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_e1291_a04);
			fixed_reg_devs = fixed_reg_devs_e1291_a04;
		} else {
			nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_e1198_base);
			fixed_reg_devs = fixed_reg_devs_e1198_base;
		}
		break;

	case BOARD_PM311:
	case BOARD_PM305:
		nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_pm311);
		fixed_reg_devs = fixed_reg_devs_pm311;
		if (display_board_info.board_id == BOARD_DISPLAY_PM313) {
			nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_pm311_pm313);
			fixed_reg_devs = fixed_reg_devs_pm311_pm313;
		}
		break;

	case BOARD_PM269:
	case BOARD_E1257:
		nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_pm269);
		fixed_reg_devs = fixed_reg_devs_pm269;
		if (display_board_info.board_id == BOARD_DISPLAY_PM313) {
			nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_pm269_pm313);
			fixed_reg_devs = fixed_reg_devs_pm269_pm313;
		} else {
			nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_pm269);
			fixed_reg_devs = fixed_reg_devs_pm269;
		}
		break;

	default:
		if (display_board_info.board_id == BOARD_DISPLAY_PM313) {
			nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_e118x_pm313);
			fixed_reg_devs = fixed_reg_devs_e118x_pm313;
		} else {
			nfixreg_devs = ARRAY_SIZE(fixed_reg_devs_e118x);
			fixed_reg_devs = fixed_reg_devs_e118x;
		}
		break;
	}

	for (i = 0; i < nfixreg_devs; ++i) {
		int gpio_nr;
		if (!strncmp(fixed_reg_devs[i]->name, "gpio", 4)) {
			struct gpio_switch_regulator_platform_data *gs_pdata =
				fixed_reg_devs[i]->dev.platform_data;
			gpio_nr = gs_pdata->subdevs[0]->gpio_nr;
		} else {
			struct fixed_voltage_config *fixed_reg_pdata =
				fixed_reg_devs[i]->dev.platform_data;
			gpio_nr = fixed_reg_pdata->gpio;
		}

		if (gpio_nr < TEGRA_NR_GPIOS)
			tegra_gpio_enable(gpio_nr);
	}
	return platform_add_devices(fixed_reg_devs, nfixreg_devs);
}
コード例 #2
0
int __init cardhu_gpio_switch_regulator_init(void)
{
	int i;
	struct board_info board_info;
	struct board_info pmu_board_info;
	struct board_info display_board_info;

	tegra_get_board_info(&board_info);
	tegra_get_pmu_board_info(&pmu_board_info);
	tegra_get_display_board_info(&display_board_info);

	if (pmu_board_info.board_id == BOARD_PMU_PM299)
		return cardhu_pm299_gpio_switch_regulator_init();
	switch (board_info.board_id) {
	case BOARD_E1198:
		if (board_info.fab <= BOARD_FAB_A01) {
			gswitch_pdata.num_subdevs = ARRAY_SIZE(gswitch_subdevs_e1198_base);
			gswitch_pdata.subdevs = gswitch_subdevs_e1198_base;
		} else {
			gswitch_pdata.num_subdevs = ARRAY_SIZE(gswitch_subdevs_e1198_a02);
			gswitch_pdata.subdevs = gswitch_subdevs_e1198_a02;
		}
		break;

	case BOARD_E1291:
		if (board_info.fab == BOARD_FAB_A03) {
			gswitch_pdata.num_subdevs =
					ARRAY_SIZE(gswitch_subdevs_e1291_a03);
			gswitch_pdata.subdevs = gswitch_subdevs_e1291_a03;
		} else if (board_info.fab == BOARD_FAB_A04) {
			gswitch_pdata.num_subdevs =
					ARRAY_SIZE(gswitch_subdevs_e1291_a04);
			gswitch_pdata.subdevs = gswitch_subdevs_e1291_a04;
		} else {
			gswitch_pdata.num_subdevs =
					ARRAY_SIZE(gswitch_subdevs_e1198_base);
			gswitch_pdata.subdevs = gswitch_subdevs_e1198_base;
		}
		break;

	case BOARD_PM269:
	//case BOARD_PM305:
	//case BOARD_PM311:
	//case BOARD_E1257:
		gswitch_pdata.num_subdevs = ARRAY_SIZE(gswitch_subdevs_pm269);
		gswitch_pdata.subdevs = gswitch_subdevs_pm269;
		if (display_board_info.board_id == BOARD_DISPLAY_PM313) {
			gswitch_pdata.num_subdevs = ARRAY_SIZE(gswitch_subdevs_pm269_pm313);
			gswitch_pdata.subdevs = gswitch_subdevs_pm269_pm313;
		} else {
			gswitch_pdata.num_subdevs = ARRAY_SIZE(gswitch_subdevs_pm269);
			gswitch_pdata.subdevs = gswitch_subdevs_pm269;
		}
		break;
	default:
		if (display_board_info.board_id == BOARD_DISPLAY_PM313) {
			gswitch_pdata.num_subdevs = ARRAY_SIZE(gswitch_subdevs_e118x_pm313);
			gswitch_pdata.subdevs = gswitch_subdevs_e118x_pm313;
		} else {
			gswitch_pdata.num_subdevs = ARRAY_SIZE(gswitch_subdevs_e118x);
			gswitch_pdata.subdevs = gswitch_subdevs_e118x;
		}
		break;
	}

	for (i = 0; i < gswitch_pdata.num_subdevs; ++i) {
		struct gpio_switch_regulator_subdev_data *gswitch_data = gswitch_pdata.subdevs[i];
		if (gswitch_data->gpio_nr <= TEGRA_NR_GPIOS)
			tegra_gpio_enable(gswitch_data->gpio_nr);
	}

	return platform_device_register(&gswitch_regulator_pdata);
}