|  | @@ -138,3 +138,187 @@ static void omap4_hsmmc1_before_set_reg(struct device *dev, int slot,
 | 
	
		
			
				|  |  |  	omap4_ctrl_pad_writel(reg, control_pbias_offset);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +static void omap4_hsmmc1_after_set_reg(struct device *dev, int slot,
 | 
	
		
			
				|  |  | +				 int power_on, int vdd)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	u32 reg;
 | 
	
		
			
				|  |  | +	unsigned long timeout;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	if (power_on) {
 | 
	
		
			
				|  |  | +		reg = omap4_ctrl_pad_readl(control_pbias_offset);
 | 
	
		
			
				|  |  | +		reg |= OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK;
 | 
	
		
			
				|  |  | +		if ((1 << vdd) <= MMC_VDD_165_195)
 | 
	
		
			
				|  |  | +			reg &= ~OMAP4_MMC1_PBIASLITE_VMODE_MASK;
 | 
	
		
			
				|  |  | +		else
 | 
	
		
			
				|  |  | +			reg |= OMAP4_MMC1_PBIASLITE_VMODE_MASK;
 | 
	
		
			
				|  |  | +		reg |= (OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK |
 | 
	
		
			
				|  |  | +			OMAP4_MMC1_PWRDNZ_MASK);
 | 
	
		
			
				|  |  | +		omap4_ctrl_pad_writel(reg, control_pbias_offset);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		timeout = jiffies + msecs_to_jiffies(5);
 | 
	
		
			
				|  |  | +		do {
 | 
	
		
			
				|  |  | +			reg = omap4_ctrl_pad_readl(control_pbias_offset);
 | 
	
		
			
				|  |  | +			if (!(reg & OMAP4_MMC1_PBIASLITE_VMODE_ERROR_MASK))
 | 
	
		
			
				|  |  | +				break;
 | 
	
		
			
				|  |  | +			usleep_range(100, 200);
 | 
	
		
			
				|  |  | +		} while (!time_after(jiffies, timeout));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		if (reg & OMAP4_MMC1_PBIASLITE_VMODE_ERROR_MASK) {
 | 
	
		
			
				|  |  | +			pr_err("Pbias Voltage is not same as LDO\n");
 | 
	
		
			
				|  |  | +			/* Caution : On VMODE_ERROR Power Down MMC IO */
 | 
	
		
			
				|  |  | +			reg &= ~(OMAP4_MMC1_PWRDNZ_MASK);
 | 
	
		
			
				|  |  | +			omap4_ctrl_pad_writel(reg, control_pbias_offset);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static void hsmmc2_select_input_clk_src(struct omap_mmc_platform_data *mmc)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	u32 reg;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	reg = omap_ctrl_readl(control_devconf1_offset);
 | 
	
		
			
				|  |  | +	if (mmc->slots[0].internal_clock)
 | 
	
		
			
				|  |  | +		reg |= OMAP2_MMCSDIO2ADPCLKISEL;
 | 
	
		
			
				|  |  | +	else
 | 
	
		
			
				|  |  | +		reg &= ~OMAP2_MMCSDIO2ADPCLKISEL;
 | 
	
		
			
				|  |  | +	omap_ctrl_writel(reg, control_devconf1_offset);
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static void hsmmc2_before_set_reg(struct device *dev, int slot,
 | 
	
		
			
				|  |  | +				   int power_on, int vdd)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	struct omap_mmc_platform_data *mmc = dev->platform_data;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	if (mmc->slots[0].remux)
 | 
	
		
			
				|  |  | +		mmc->slots[0].remux(dev, slot, power_on);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	if (power_on)
 | 
	
		
			
				|  |  | +		hsmmc2_select_input_clk_src(mmc);
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static int am35x_hsmmc2_set_power(struct device *dev, int slot,
 | 
	
		
			
				|  |  | +				  int power_on, int vdd)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	struct omap_mmc_platform_data *mmc = dev->platform_data;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	if (power_on)
 | 
	
		
			
				|  |  | +		hsmmc2_select_input_clk_src(mmc);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	return 0;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static int nop_mmc_set_power(struct device *dev, int slot, int power_on,
 | 
	
		
			
				|  |  | +							int vdd)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	return 0;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static inline void omap_hsmmc_mux(struct omap_mmc_platform_data *mmc_controller,
 | 
	
		
			
				|  |  | +			int controller_nr)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	if (gpio_is_valid(mmc_controller->slots[0].switch_pin) &&
 | 
	
		
			
				|  |  | +		(mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
 | 
	
		
			
				|  |  | +		omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
 | 
	
		
			
				|  |  | +					OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +	if (gpio_is_valid(mmc_controller->slots[0].gpio_wp) &&
 | 
	
		
			
				|  |  | +		(mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
 | 
	
		
			
				|  |  | +		omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
 | 
	
		
			
				|  |  | +					OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +	if (cpu_is_omap34xx()) {
 | 
	
		
			
				|  |  | +		if (controller_nr == 0) {
 | 
	
		
			
				|  |  | +			omap_mux_init_signal("sdmmc1_clk",
 | 
	
		
			
				|  |  | +				OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +			omap_mux_init_signal("sdmmc1_cmd",
 | 
	
		
			
				|  |  | +				OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +			omap_mux_init_signal("sdmmc1_dat0",
 | 
	
		
			
				|  |  | +				OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +			if (mmc_controller->slots[0].caps &
 | 
	
		
			
				|  |  | +				(MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
 | 
	
		
			
				|  |  | +				omap_mux_init_signal("sdmmc1_dat1",
 | 
	
		
			
				|  |  | +					OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +				omap_mux_init_signal("sdmmc1_dat2",
 | 
	
		
			
				|  |  | +					OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +				omap_mux_init_signal("sdmmc1_dat3",
 | 
	
		
			
				|  |  | +					OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			if (mmc_controller->slots[0].caps &
 | 
	
		
			
				|  |  | +						MMC_CAP_8_BIT_DATA) {
 | 
	
		
			
				|  |  | +				omap_mux_init_signal("sdmmc1_dat4",
 | 
	
		
			
				|  |  | +					OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +				omap_mux_init_signal("sdmmc1_dat5",
 | 
	
		
			
				|  |  | +					OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +				omap_mux_init_signal("sdmmc1_dat6",
 | 
	
		
			
				|  |  | +					OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +				omap_mux_init_signal("sdmmc1_dat7",
 | 
	
		
			
				|  |  | +					OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		if (controller_nr == 1) {
 | 
	
		
			
				|  |  | +			/* MMC2 */
 | 
	
		
			
				|  |  | +			omap_mux_init_signal("sdmmc2_clk",
 | 
	
		
			
				|  |  | +				OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +			omap_mux_init_signal("sdmmc2_cmd",
 | 
	
		
			
				|  |  | +				OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +			omap_mux_init_signal("sdmmc2_dat0",
 | 
	
		
			
				|  |  | +				OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			/*
 | 
	
		
			
				|  |  | +			 * For 8 wire configurations, Lines DAT4, 5, 6 and 7
 | 
	
		
			
				|  |  | +			 * need to be muxed in the board-*.c files
 | 
	
		
			
				|  |  | +			 */
 | 
	
		
			
				|  |  | +			if (mmc_controller->slots[0].caps &
 | 
	
		
			
				|  |  | +				(MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
 | 
	
		
			
				|  |  | +				omap_mux_init_signal("sdmmc2_dat1",
 | 
	
		
			
				|  |  | +					OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +				omap_mux_init_signal("sdmmc2_dat2",
 | 
	
		
			
				|  |  | +					OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +				omap_mux_init_signal("sdmmc2_dat3",
 | 
	
		
			
				|  |  | +					OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			if (mmc_controller->slots[0].caps &
 | 
	
		
			
				|  |  | +							MMC_CAP_8_BIT_DATA) {
 | 
	
		
			
				|  |  | +				omap_mux_init_signal("sdmmc2_dat4.sdmmc2_dat4",
 | 
	
		
			
				|  |  | +					OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +				omap_mux_init_signal("sdmmc2_dat5.sdmmc2_dat5",
 | 
	
		
			
				|  |  | +					OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +				omap_mux_init_signal("sdmmc2_dat6.sdmmc2_dat6",
 | 
	
		
			
				|  |  | +					OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +				omap_mux_init_signal("sdmmc2_dat7.sdmmc2_dat7",
 | 
	
		
			
				|  |  | +					OMAP_PIN_INPUT_PULLUP);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		/*
 | 
	
		
			
				|  |  | +		 * For MMC3 the pins need to be muxed in the board-*.c files
 | 
	
		
			
				|  |  | +		 */
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static int __init omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c,
 | 
	
		
			
				|  |  | +					struct omap_mmc_platform_data *mmc)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	char *hc_name;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	hc_name = kzalloc(sizeof(char) * (HSMMC_NAME_LEN + 1), GFP_KERNEL);
 | 
	
		
			
				|  |  | +	if (!hc_name) {
 | 
	
		
			
				|  |  | +		pr_err("Cannot allocate memory for controller slot name\n");
 | 
	
		
			
				|  |  | +		kfree(hc_name);
 | 
	
		
			
				|  |  | +		return -ENOMEM;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	if (c->name)
 | 
	
		
			
				|  |  | +		strncpy(hc_name, c->name, HSMMC_NAME_LEN);
 | 
	
		
			
				|  |  | +	else
 | 
	
		
			
				|  |  | +		snprintf(hc_name, (HSMMC_NAME_LEN + 1), "mmc%islot%i",
 | 
	
		
			
				|  |  | +								c->mmc, 1);
 | 
	
		
			
				|  |  | +	mmc->slots[0].name = hc_name;
 | 
	
		
			
				|  |  | +	mmc->nr_slots = 1;
 | 
	
		
			
				|  |  | +	mmc->slots[0].caps = c->caps;
 | 
	
		
			
				|  |  | +	mmc->slots[0].pm_caps = c->pm_caps;
 | 
	
		
			
				|  |  | +	mmc->slots[0].internal_clock = !c->ext_clock;
 | 
	
		
			
				|  |  | +	mmc->max_freq = c->max_freq;
 | 
	
		
			
				|  |  | +	if (cpu_is_omap44xx())
 | 
	
		
			
				|  |  | +		mmc->reg_offset = OMAP4_MMC_REG_OFFSET;
 | 
	
		
			
				|  |  | +	else
 | 
	
		
			
				|  |  | +		mmc->reg_offset = 0;
 | 
	
		
			
				|  |  | +
 |