1*d0ebbb8dSJaehoon Chung /* 2*d0ebbb8dSJaehoon Chung * (C) Copyright 2012 SAMSUNG Electronics 3*d0ebbb8dSJaehoon Chung * Jaehoon Chung <jh80.chung@samsung.com> 4*d0ebbb8dSJaehoon Chung * 5*d0ebbb8dSJaehoon Chung * This program is free software; you can redistribute it and/or 6*d0ebbb8dSJaehoon Chung * modify it under the terms of the GNU General Public License as 7*d0ebbb8dSJaehoon Chung * published by the Free Software Foundation; either version 2 of 8*d0ebbb8dSJaehoon Chung * the License, or (at your option) any later version. 9*d0ebbb8dSJaehoon Chung * 10*d0ebbb8dSJaehoon Chung * This program is distributed in the hope that it will be useful, 11*d0ebbb8dSJaehoon Chung * but WITHOUT ANY WARRANTY; without even the implied warranty of 12*d0ebbb8dSJaehoon Chung * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*d0ebbb8dSJaehoon Chung * GNU General Public License for more details. 14*d0ebbb8dSJaehoon Chung * 15*d0ebbb8dSJaehoon Chung * You should have received a copy of the GNU General Public License 16*d0ebbb8dSJaehoon Chung * along with this program; if not, write to the Free Software 17*d0ebbb8dSJaehoon Chung * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18*d0ebbb8dSJaehoon Chung * 19*d0ebbb8dSJaehoon Chung */ 20*d0ebbb8dSJaehoon Chung 21*d0ebbb8dSJaehoon Chung #include <common.h> 22*d0ebbb8dSJaehoon Chung #include <malloc.h> 23*d0ebbb8dSJaehoon Chung #include <dwmmc.h> 24*d0ebbb8dSJaehoon Chung #include <asm/arch/dwmmc.h> 25*d0ebbb8dSJaehoon Chung #include <asm/arch/clk.h> 26*d0ebbb8dSJaehoon Chung 27*d0ebbb8dSJaehoon Chung static char *EXYNOS_NAME = "EXYNOS DWMMC"; 28*d0ebbb8dSJaehoon Chung 29*d0ebbb8dSJaehoon Chung static void exynos_dwmci_clksel(struct dwmci_host *host) 30*d0ebbb8dSJaehoon Chung { 31*d0ebbb8dSJaehoon Chung u32 val; 32*d0ebbb8dSJaehoon Chung val = DWMCI_SET_SAMPLE_CLK(DWMCI_SHIFT_0) | 33*d0ebbb8dSJaehoon Chung DWMCI_SET_DRV_CLK(DWMCI_SHIFT_0) | DWMCI_SET_DIV_RATIO(0); 34*d0ebbb8dSJaehoon Chung 35*d0ebbb8dSJaehoon Chung dwmci_writel(host, DWMCI_CLKSEL, val); 36*d0ebbb8dSJaehoon Chung } 37*d0ebbb8dSJaehoon Chung 38*d0ebbb8dSJaehoon Chung int exynos_dwmci_init(u32 regbase, int bus_width, int index) 39*d0ebbb8dSJaehoon Chung { 40*d0ebbb8dSJaehoon Chung struct dwmci_host *host = NULL; 41*d0ebbb8dSJaehoon Chung host = malloc(sizeof(struct dwmci_host)); 42*d0ebbb8dSJaehoon Chung if (!host) { 43*d0ebbb8dSJaehoon Chung printf("dwmci_host malloc fail!\n"); 44*d0ebbb8dSJaehoon Chung return 1; 45*d0ebbb8dSJaehoon Chung } 46*d0ebbb8dSJaehoon Chung 47*d0ebbb8dSJaehoon Chung host->name = EXYNOS_NAME; 48*d0ebbb8dSJaehoon Chung host->ioaddr = (void *)regbase; 49*d0ebbb8dSJaehoon Chung host->buswidth = bus_width; 50*d0ebbb8dSJaehoon Chung host->clksel = exynos_dwmci_clksel; 51*d0ebbb8dSJaehoon Chung host->dev_index = index; 52*d0ebbb8dSJaehoon Chung 53*d0ebbb8dSJaehoon Chung add_dwmci(host, 52000000, 400000); 54*d0ebbb8dSJaehoon Chung 55*d0ebbb8dSJaehoon Chung return 0; 56*d0ebbb8dSJaehoon Chung } 57*d0ebbb8dSJaehoon Chung 58