1 // SPDX-License-Identifier: GPL-2.0-only
3 * CNS3xxx common devices
5 * Copyright 2008 Cavium Networks
7 * Copyright 2010 MontaVista Software, LLC.
8 * Anton Vorontsov <avorontsov@mvista.com>
12 #include <linux/init.h>
13 #include <linux/compiler.h>
14 #include <linux/dma-mapping.h>
15 #include <linux/platform_device.h>
24 static struct resource cns3xxx_ahci_resource
[] = {
26 .start
= CNS3XXX_SATA2_BASE
,
27 .end
= CNS3XXX_SATA2_BASE
+ CNS3XXX_SATA2_SIZE
- 1,
28 .flags
= IORESOURCE_MEM
,
31 .start
= IRQ_CNS3XXX_SATA
,
32 .end
= IRQ_CNS3XXX_SATA
,
33 .flags
= IORESOURCE_IRQ
,
37 static u64 cns3xxx_ahci_dmamask
= DMA_BIT_MASK(32);
39 static struct platform_device cns3xxx_ahci_pdev
= {
42 .resource
= cns3xxx_ahci_resource
,
43 .num_resources
= ARRAY_SIZE(cns3xxx_ahci_resource
),
45 .dma_mask
= &cns3xxx_ahci_dmamask
,
46 .coherent_dma_mask
= DMA_BIT_MASK(32),
50 void __init
cns3xxx_ahci_init(void)
54 tmp
= __raw_readl(MISC_SATA_POWER_MODE
);
55 tmp
|= 0x1 << 16; /* Disable SATA PHY 0 from SLUMBER Mode */
56 tmp
|= 0x1 << 17; /* Disable SATA PHY 1 from SLUMBER Mode */
57 __raw_writel(tmp
, MISC_SATA_POWER_MODE
);
60 cns3xxx_pwr_power_up(0x1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_SATA_PHY0
);
61 cns3xxx_pwr_power_up(0x1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_SATA_PHY1
);
63 /* Enable SATA Clock */
64 cns3xxx_pwr_clk_en(0x1 << PM_CLK_GATE_REG_OFFSET_SATA
);
66 /* De-Asscer SATA Reset */
67 cns3xxx_pwr_soft_rst(CNS3XXX_PWR_SOFTWARE_RST(SATA
));
69 platform_device_register(&cns3xxx_ahci_pdev
);
75 static struct resource cns3xxx_sdhci_resources
[] = {
77 .start
= CNS3XXX_SDIO_BASE
,
78 .end
= CNS3XXX_SDIO_BASE
+ SZ_4K
- 1,
79 .flags
= IORESOURCE_MEM
,
82 .start
= IRQ_CNS3XXX_SDIO
,
83 .end
= IRQ_CNS3XXX_SDIO
,
84 .flags
= IORESOURCE_IRQ
,
88 static struct platform_device cns3xxx_sdhci_pdev
= {
89 .name
= "sdhci-cns3xxx",
91 .num_resources
= ARRAY_SIZE(cns3xxx_sdhci_resources
),
92 .resource
= cns3xxx_sdhci_resources
,
95 void __init
cns3xxx_sdhci_init(void)
97 u32 __iomem
*gpioa
= IOMEM(CNS3XXX_MISC_BASE_VIRT
+ 0x0014);
98 u32 gpioa_pins
= __raw_readl(gpioa
);
100 /* MMC/SD pins share with GPIOA */
101 gpioa_pins
|= 0x1fff0004;
102 __raw_writel(gpioa_pins
, gpioa
);
104 cns3xxx_pwr_clk_en(CNS3XXX_PWR_CLK_EN(SDIO
));
105 cns3xxx_pwr_soft_rst(CNS3XXX_PWR_SOFTWARE_RST(SDIO
));
107 platform_device_register(&cns3xxx_sdhci_pdev
);