static int simple_sd_ioctl_set_driving(struct msdc_ioctl *msdc_ctl)
{
	void __iomem *base;
	struct msdc_host *host;
#if DEBUG_MMC_IOCTL
	unsigned int l_value;
#endif

	if(!msdc_ctl)
		return -EINVAL;

	if((msdc_ctl->host_num < 0) || (msdc_ctl->host_num >= HOST_MAX_NUM)){
		pr_err("invalid host num: %d\n", msdc_ctl->host_num);
		return -EINVAL;
	}else if (msdc_ctl->host_num == 0){
#ifndef CFG_DEV_MSDC0
		pr_err("host%d is not config\n", msdc_ctl->host_num);
		return -EINVAL;
#endif
	} else if (msdc_ctl->host_num == 1) {
#ifndef CFG_DEV_MSDC1
		pr_err("host%d is not config\n", msdc_ctl->host_num);
		return -EINVAL;
#endif
	} else if (msdc_ctl->host_num == 2) {
#ifndef CFG_DEV_MSDC2
		pr_err("host%d is not config\n", msdc_ctl->host_num);
		return -EINVAL;
#endif
	} else if (msdc_ctl->host_num == 3) {
#ifndef CFG_DEV_MSDC3
		pr_err("host%d is not config\n", msdc_ctl->host_num);
		return -EINVAL;
#endif
	} else if (msdc_ctl->host_num == 4) {
#ifndef CFG_DEV_MSDC4
		pr_err("host%d is not config\n", msdc_ctl->host_num);
		return -EINVAL;
#endif
    }else {
        pr_err("invalid host num: %d\n", msdc_ctl->host_num);
		return -EINVAL;
	}

	host = mtk_msdc_host[msdc_ctl->host_num];
	BUG_ON(!host);

	base = host->base;
#ifndef FPGA_PLATFORM
#ifdef CONFIG_MTK_LEGACY
	enable_clock(MT_CG_PERI_MSDC30_0 + host->id, "SD");
#else
	clk_enable(host->clock_control);
#endif
#if DEBUG_MMC_IOCTL
	pr_debug("set: clk driving is 0x%x\n", msdc_ctl->clk_pu_driving);
	pr_debug("set: cmd driving is 0x%x\n", msdc_ctl->cmd_pu_driving);
	pr_debug("set: dat driving is 0x%x\n", msdc_ctl->dat_pu_driving);
	pr_debug("set: rst driving is 0x%x\n", msdc_ctl->rst_pu_driving);
	pr_debug("set: ds driving is 0x%x\n", msdc_ctl->ds_pu_driving);
#endif
	host->hw->clk_drv = msdc_ctl->clk_pu_driving;
	host->hw->cmd_drv = msdc_ctl->cmd_pu_driving;
	host->hw->dat_drv = msdc_ctl->dat_pu_driving;
	host->hw->rst_drv = msdc_ctl->rst_pu_driving;
	host->hw->ds_drv = msdc_ctl->ds_pu_driving;
	host->hw->clk_drv_sd_18 = msdc_ctl->clk_pu_driving;
	host->hw->cmd_drv_sd_18 = msdc_ctl->cmd_pu_driving;
	host->hw->dat_drv_sd_18 = msdc_ctl->dat_pu_driving;
	msdc_set_driving(host, host->hw, 0);
#if DEBUG_MMC_IOCTL
  #if 0
    msdc_dump_padctl(host);
  #endif
#endif
#endif

	return 0;
}
Beispiel #2
0
static int simple_sd_ioctl_set_driving(struct msdc_ioctl* msdc_ctl)
{
    void __iomem *base;
#ifndef FPGA_PLATFORM
    struct msdc_host *host;
#endif

    if (msdc_ctl->host_num == 0){
#ifndef CFG_DEV_MSDC0
        printk("host%d is not config\n", msdc_ctl->host_num);
        return -1;
#endif
    } else if (msdc_ctl->host_num == 1) {
#ifndef CFG_DEV_MSDC1
        printk("host%d is not config\n", msdc_ctl->host_num);
        return -1;
#endif
    } else if (msdc_ctl->host_num == 2) {
#ifndef CFG_DEV_MSDC2
        printk("host%d is not config\n", msdc_ctl->host_num);
        return -1;
#endif
    } else if (msdc_ctl->host_num == 3) {
#ifndef CFG_DEV_MSDC3
        printk("host%d is not config\n", msdc_ctl->host_num);
        return -1;
#endif
    } else if (msdc_ctl->host_num == 4) {
#ifndef CFG_DEV_MSDC4
            printk("host%d is not config\n", msdc_ctl->host_num);
            return -1;
#endif
    }
    base = mtk_msdc_host[msdc_ctl->host_num]->base;
#ifndef FPGA_PLATFORM
   enable_clock(msdc_cg_clk_id[msdc_ctl->host_num], "SD"); 
#if DEBUG_MMC_IOCTL
    printk("set: clk driving is 0x%x\n", msdc_ctl->clk_pu_driving);
    printk("set: cmd driving is 0x%x\n", msdc_ctl->cmd_pu_driving);
    printk("set: dat driving is 0x%x\n", msdc_ctl->dat_pu_driving);
    printk("set: rst driving is 0x%x\n", msdc_ctl->rst_pu_driving);
    printk("set: ds driving is 0x%x\n", msdc_ctl->ds_pu_driving);
#endif
    host = mtk_msdc_host[msdc_ctl->host_num];
    host->hw->clk_drv = msdc_ctl->clk_pu_driving;
    host->hw->cmd_drv = msdc_ctl->cmd_pu_driving;
    host->hw->dat_drv = msdc_ctl->dat_pu_driving;
    host->hw->rst_drv = msdc_ctl->rst_pu_driving;
    host->hw->ds_drv = msdc_ctl->ds_pu_driving;
    host->hw->clk_drv_sd_18 = msdc_ctl->clk_pu_driving;
    host->hw->cmd_drv_sd_18 = msdc_ctl->cmd_pu_driving;
    host->hw->dat_drv_sd_18 = msdc_ctl->dat_pu_driving;
    msdc_set_driving(host,host->hw,0);
#if DEBUG_MMC_IOCTL
  #if 0
    msdc_dump_padctl(host, GPIO_CLK_CTRL); 
    msdc_dump_padctl(host, GPIO_CMD_CTRL); 
    msdc_dump_padctl(host, GPIO_DAT_CTRL); 
    msdc_dump_padctl(host, GPIO_RST_CTRL); 
    msdc_dump_padctl(host, GPIO_DS_CTRL); 
  #endif
#endif
#endif

    return 0;
}