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