summaryrefslogtreecommitdiff
path: root/arch/arm/plat-aspeed/dev-sdhci.c
blob: bcc8cce49a9371f3c0d2fda1ac0222855b97363f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/********************************************************************************
* File Name     : linux/arch/arm/plat-aspeed/dev-sdhc.c
* Author        : Ryan chen
* Description   : ASPEED SDHC Device
*
* Copyright (C) ASPEED Technology Inc.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the Free Software Foundation;
* either version 2 of the License, or (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

* History      :
*    1. 2012/07/30 ryan chen create this file
*
********************************************************************************/

#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/platform_device.h>

#include <mach/irqs.h>
#include <mach/platform.h>
#include <plat/devs.h>
#include <plat/ast_sdhci.h>
#include <plat/ast-scu.h>


/* --------------------------------------------------------------------
 *  SDHC
 * -------------------------------------------------------------------- */
#if defined(CONFIG_MMC_AST) || defined(CONFIG_MMC_AST_MODULE)
static struct ast_sdhc_platform_data ast_sdhc_info = {
        .sd_clock_src_get = ast_get_sd_clock_src,
};

static struct resource ast_sdhci0_resource[] = {
	[0] = {
		.start = AST_SDHC_BASE + 0x100,
		.end = AST_SDHC_BASE + 0x100 + 0xFF,
		.flags = IORESOURCE_MEM,
	},
	[1] = {
		.start = IRQ_SDHC,
		.end = IRQ_SDHC,
		.flags = IORESOURCE_IRQ,
	},
};

static struct resource ast_sdhci1_resource[] = {
	[0] = {
		.start = AST_SDHC_BASE + 0x200,
		.end = AST_SDHC_BASE + 0x200 + 0xFF,
		.flags = IORESOURCE_MEM,
	},
	[1] = {
		.start = IRQ_SDHC,
		.end = IRQ_SDHC,
		.flags = IORESOURCE_IRQ,
	},
};

static u64 ast_sdhc_dma_mask = 0xffffffffUL;

static struct platform_device ast_sdhci_device0 = {
	.name	= "ast_sdhci",
    .id = 0,
    .dev = {
            .dma_mask = &ast_sdhc_dma_mask,
            .coherent_dma_mask = 0xffffffff,
            .platform_data = &ast_sdhc_info,
    },
	.resource = ast_sdhci0_resource,
	.num_resources = ARRAY_SIZE(ast_sdhci0_resource),
};

static struct platform_device ast_sdhci_device1 = {
	.name	= "ast_sdhci",
    .id = 1,
    .dev = {
            .dma_mask = &ast_sdhc_dma_mask,
            .coherent_dma_mask = 0xffffffff,
            .platform_data = &ast_sdhc_info,
    },
	.resource = ast_sdhci1_resource,
	.num_resources = ARRAY_SIZE(ast_sdhci1_resource),
};

void __init ast_add_device_sdhci(void)
{
	ast_scu_init_sdhci();
	//multipin. Remind: AST2300FPGA only supports one port at a time
	
	ast_scu_multi_func_sdhc_slot1(1);

	platform_device_register(&ast_sdhci_device0);

	ast_scu_multi_func_sdhc_slot2(1);

	platform_device_register(&ast_sdhci_device1);
}
#else
void __init ast_add_device_sdhci(void) {}
#endif