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; }
static int simple_sd_ioctl_set_driving(struct msdc_ioctl* msdc_ctl) { u32 base; struct msdc_host *host; #if DEBUG_MMC_IOCTL unsigned int l_value; #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(MT_CG_PERI_MSDC30_0 + mtk_msdc_host[msdc_ctl->host_num]->id, "SD"); #endif #if DEBUG_MMC_IOCTL //printk("set: clk pull down driving is 0x%x\n", msdc_ctl->clk_pd_driving); printk("set: clk driving is 0x%x\n", msdc_ctl->clk_pu_driving); //printk("set: cmd pull down driving is 0x%x\n", msdc_ctl->cmd_pd_driving); printk("set: cmd driving is 0x%x\n", msdc_ctl->cmd_pu_driving); //printk("set: dat pull down driving is 0x%x\n", msdc_ctl->dat_pd_driving); printk("set: dat driving is 0x%x\n", msdc_ctl->dat_pu_driving); #endif #ifdef FPGA_PLATFORM sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVN, msdc_ctl->clk_pd_driving); sdr_set_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVP, msdc_ctl->clk_pu_driving); sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVN, msdc_ctl->cmd_pd_driving); sdr_set_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVP, msdc_ctl->cmd_pu_driving); sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVN, msdc_ctl->dat_pd_driving); sdr_set_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVP, msdc_ctl->dat_pu_driving); #else 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->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); #endif #if DEBUG_MMC_IOCTL l_value = 0; //sdr_get_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVN, l_value); //printk("read: clk pull down driving is 0x%x\n", l_value); l_value = (msdc_dump_padctl0(msdc_ctl->host_num) & 0x7); //sdr_get_field(MSDC_PAD_CTL0, MSDC_PAD_CTL0_CLKDRVP, l_value); printk("read: clk driving is 0x%x\n", l_value); l_value = (msdc_dump_padctl1(msdc_ctl->host_num) & 0x7);; //sdr_get_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVN, l_value); printk("read: cmd driving is 0x%x\n", l_value); //l_value = 0; //sdr_get_field(MSDC_PAD_CTL1, MSDC_PAD_CTL1_CMDDRVP, l_value); //printk("read: cmd pull up driving is 0x%x\n", l_value); l_value = (msdc_dump_padctl2(msdc_ctl->host_num) & 0x7);; //sdr_get_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVN, l_value); printk("read: dat driving is 0x%x\n", l_value); //l_value = 0; //sdr_get_field(MSDC_PAD_CTL2, MSDC_PAD_CTL2_DATDRVP, l_value); //printk("read: dat pull up driving is 0x%x\n", l_value); #endif return 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; }