Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
devices.c
Go to the documentation of this file.
1 /*
2  * CNS3xxx common devices
3  *
4  * Copyright 2008 Cavium Networks
5  * Scott Shu
6  * Copyright 2010 MontaVista Software, LLC.
7  * Anton Vorontsov <[email protected]>
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/dma-mapping.h>
18 #include <linux/platform_device.h>
19 #include <mach/cns3xxx.h>
20 #include <mach/irqs.h>
21 #include <mach/pm.h>
22 #include "core.h"
23 #include "devices.h"
24 
25 /*
26  * AHCI
27  */
28 static struct resource cns3xxx_ahci_resource[] = {
29  [0] = {
30  .start = CNS3XXX_SATA2_BASE,
32  .flags = IORESOURCE_MEM,
33  },
34  [1] = {
35  .start = IRQ_CNS3XXX_SATA,
36  .end = IRQ_CNS3XXX_SATA,
37  .flags = IORESOURCE_IRQ,
38  },
39 };
40 
41 static u64 cns3xxx_ahci_dmamask = DMA_BIT_MASK(32);
42 
43 static struct platform_device cns3xxx_ahci_pdev = {
44  .name = "ahci",
45  .id = 0,
46  .resource = cns3xxx_ahci_resource,
47  .num_resources = ARRAY_SIZE(cns3xxx_ahci_resource),
48  .dev = {
49  .dma_mask = &cns3xxx_ahci_dmamask,
50  .coherent_dma_mask = DMA_BIT_MASK(32),
51  },
52 };
53 
55 {
56  u32 tmp;
57 
59  tmp |= 0x1 << 16; /* Disable SATA PHY 0 from SLUMBER Mode */
60  tmp |= 0x1 << 17; /* Disable SATA PHY 1 from SLUMBER Mode */
62 
63  /* Enable SATA PHY */
66 
67  /* Enable SATA Clock */
69 
70  /* De-Asscer SATA Reset */
72 
73  platform_device_register(&cns3xxx_ahci_pdev);
74 }
75 
76 /*
77  * SDHCI
78  */
79 static struct resource cns3xxx_sdhci_resources[] = {
80  [0] = {
81  .start = CNS3XXX_SDIO_BASE,
82  .end = CNS3XXX_SDIO_BASE + SZ_4K - 1,
83  .flags = IORESOURCE_MEM,
84  },
85  [1] = {
86  .start = IRQ_CNS3XXX_SDIO,
87  .end = IRQ_CNS3XXX_SDIO,
88  .flags = IORESOURCE_IRQ,
89  },
90 };
91 
92 static struct platform_device cns3xxx_sdhci_pdev = {
93  .name = "sdhci-cns3xxx",
94  .id = 0,
95  .num_resources = ARRAY_SIZE(cns3xxx_sdhci_resources),
96  .resource = cns3xxx_sdhci_resources,
97 };
98 
100 {
101  u32 __iomem *gpioa = IOMEM(CNS3XXX_MISC_BASE_VIRT + 0x0014);
102  u32 gpioa_pins = __raw_readl(gpioa);
103 
104  /* MMC/SD pins share with GPIOA */
105  gpioa_pins |= 0x1fff0004;
106  __raw_writel(gpioa_pins, gpioa);
107 
110 
111  platform_device_register(&cns3xxx_sdhci_pdev);
112 }