blob: b01a3011462275365e18110b8749c470f2cc9ecd [file] [log] [blame]
Anton Vorontsov6279d0e2010-05-28 13:14:44 +04001/*
2 * CNS3xxx common devices
3 *
4 * Copyright 2008 Cavium Networks
5 * Scott Shu
6 * Copyright 2010 MontaVista Software, LLC.
7 * Anton Vorontsov <avorontsov@mvista.com>
8 *
9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/io.h>
15#include <linux/init.h>
16#include <linux/compiler.h>
17#include <linux/platform_device.h>
18#include <mach/cns3xxx.h>
19#include <mach/irqs.h>
20#include "core.h"
21#include "devices.h"
22
23/*
24 * SDHCI
25 */
26static struct resource cns3xxx_sdhci_resources[] = {
27 [0] = {
28 .start = CNS3XXX_SDIO_BASE,
29 .end = CNS3XXX_SDIO_BASE + SZ_4K - 1,
30 .flags = IORESOURCE_MEM,
31 },
32 [1] = {
33 .start = IRQ_CNS3XXX_SDIO,
34 .end = IRQ_CNS3XXX_SDIO,
35 .flags = IORESOURCE_IRQ,
36 },
37};
38
39static struct platform_device cns3xxx_sdhci_pdev = {
40 .name = "sdhci-cns3xxx",
41 .id = 0,
42 .num_resources = ARRAY_SIZE(cns3xxx_sdhci_resources),
43 .resource = cns3xxx_sdhci_resources,
44};
45
46void __init cns3xxx_sdhci_init(void)
47{
48 u32 __iomem *gpioa = __io(CNS3XXX_MISC_BASE_VIRT + 0x0014);
49 u32 gpioa_pins = __raw_readl(gpioa);
50
51 /* MMC/SD pins share with GPIOA */
52 gpioa_pins |= 0x1fff0004;
53 __raw_writel(gpioa_pins, gpioa);
54
55 cns3xxx_pwr_clk_en(CNS3XXX_PWR_CLK_EN(SDIO));
56 cns3xxx_pwr_soft_rst(CNS3XXX_PWR_SOFTWARE_RST(SDIO));
57
58 platform_device_register(&cns3xxx_sdhci_pdev);
59}