Exemplo n.º 1
0
static uint32_t buzz_sdslot_switchvdd(struct device *dev, unsigned int vdd)
{
	int i;

	BUG_ON(!vreg_sdslot);

	if (vdd == sdslot_vdd)
		return 0;

	sdslot_vdd = vdd;

	if (vdd == 0) {
		printk(KERN_INFO "%s: Disabling SD slot power\n", __func__);
		writel(MCI_PWR_OFF, MSM_SDC2_BASE + MMCIPOWER);
		mdelay(1);
		config_gpio_table(sdcard_off_gpio_table,
				  ARRAY_SIZE(sdcard_off_gpio_table));
		vreg_disable(vreg_sdslot);
		sdslot_vreg_enabled = 0;
		return 0;
	}

	if (!sdslot_vreg_enabled) {
		mdelay(5);
		vreg_enable(vreg_sdslot);
	}

	for (i = 0; i < ARRAY_SIZE(mmc_vdd_table); i++) {
		if (mmc_vdd_table[i].mask == (1 << vdd)) {
			printk(KERN_INFO "%s: Setting level to %u\n",
					__func__, mmc_vdd_table[i].level);
			vreg_set_level(vreg_sdslot, mmc_vdd_table[i].level);
			if (!sdslot_vreg_enabled)
				break;
			else
				return 0;
		}
	}

	/* All vdd match failed */
	if (i == ARRAY_SIZE(mmc_vdd_table))
		goto out;

	if (!sdslot_vreg_enabled) {
		u32 pwr = 0;

		/* Power on MCI controller */
		mdelay(5);
		pwr = readl(MSM_SDC2_BASE + MMCIPOWER);
		writel(pwr | MCI_PWR_UP, MSM_SDC2_BASE + MMCIPOWER);
		mdelay(5);
		pwr = readl(MSM_SDC2_BASE + MMCIPOWER);
		writel(pwr | MCI_PWR_ON, MSM_SDC2_BASE + MMCIPOWER);
		mdelay(5);

		/* ..then, config GPIO */
		config_gpio_table(sdcard_on_gpio_table,
				  ARRAY_SIZE(sdcard_on_gpio_table));
		sdslot_vreg_enabled = 1;
		return 0;
	}

out:
	printk(KERN_ERR "%s: Invalid VDD %d specified\n", __func__, vdd);
	return 0;
}
void config_marvelc_camera_off_gpios(void)
{
	config_gpio_table(camera_off_gpio_table,
		ARRAY_SIZE(camera_off_gpio_table));
}
static void marvelc_config_serial_debug_gpios(void)
{
	config_gpio_table(marvelc_serial_debug_table,
			ARRAY_SIZE(marvelc_serial_debug_table));
}
static void config_marvelc_flashlight_gpios(void)
{
	config_gpio_table(fl_gpio_table, ARRAY_SIZE(fl_gpio_table));
}