devices.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  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. #include <linux/io.h>
  14. #include <linux/init.h>
  15. #include <linux/compiler.h>
  16. #include <linux/dma-mapping.h>
  17. #include <linux/platform_device.h>
  18. #include <mach/cns3xxx.h>
  19. #include <mach/irqs.h>
  20. #include <mach/pm.h>
  21. #include "core.h"
  22. #include "devices.h"
  23. /*
  24. * AHCI
  25. */
  26. static struct resource cns3xxx_ahci_resource[] = {
  27. [0] = {
  28. .start = CNS3XXX_SATA2_BASE,
  29. .end = CNS3XXX_SATA2_BASE + CNS3XXX_SATA2_SIZE - 1,
  30. .flags = IORESOURCE_MEM,
  31. },
  32. [1] = {
  33. .start = IRQ_CNS3XXX_SATA,
  34. .end = IRQ_CNS3XXX_SATA,
  35. .flags = IORESOURCE_IRQ,
  36. },
  37. };
  38. static u64 cns3xxx_ahci_dmamask = DMA_BIT_MASK(32);
  39. static struct platform_device cns3xxx_ahci_pdev = {
  40. .name = "ahci",
  41. .id = 0,
  42. .resource = cns3xxx_ahci_resource,
  43. .num_resources = ARRAY_SIZE(cns3xxx_ahci_resource),
  44. .dev = {
  45. .dma_mask = &cns3xxx_ahci_dmamask,
  46. .coherent_dma_mask = DMA_BIT_MASK(32),
  47. },
  48. };
  49. void __init cns3xxx_ahci_init(void)
  50. {
  51. u32 tmp;
  52. tmp = __raw_readl(MISC_SATA_POWER_MODE);
  53. tmp |= 0x1 << 16; /* Disable SATA PHY 0 from SLUMBER Mode */
  54. tmp |= 0x1 << 17; /* Disable SATA PHY 1 from SLUMBER Mode */
  55. __raw_writel(tmp, MISC_SATA_POWER_MODE);
  56. /* Enable SATA PHY */
  57. cns3xxx_pwr_power_up(0x1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_SATA_PHY0);
  58. cns3xxx_pwr_power_up(0x1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_SATA_PHY1);
  59. /* Enable SATA Clock */
  60. cns3xxx_pwr_clk_en(0x1 << PM_CLK_GATE_REG_OFFSET_SATA);
  61. /* De-Asscer SATA Reset */
  62. cns3xxx_pwr_soft_rst(CNS3XXX_PWR_SOFTWARE_RST(SATA));
  63. platform_device_register(&cns3xxx_ahci_pdev);
  64. }
  65. /*
  66. * SDHCI
  67. */
  68. static struct resource cns3xxx_sdhci_resources[] = {
  69. [0] = {
  70. .start = CNS3XXX_SDIO_BASE,
  71. .end = CNS3XXX_SDIO_BASE + SZ_4K - 1,
  72. .flags = IORESOURCE_MEM,
  73. },
  74. [1] = {
  75. .start = IRQ_CNS3XXX_SDIO,
  76. .end = IRQ_CNS3XXX_SDIO,
  77. .flags = IORESOURCE_IRQ,
  78. },
  79. };
  80. static struct platform_device cns3xxx_sdhci_pdev = {
  81. .name = "sdhci-cns3xxx",
  82. .id = 0,
  83. .num_resources = ARRAY_SIZE(cns3xxx_sdhci_resources),
  84. .resource = cns3xxx_sdhci_resources,
  85. };
  86. void __init cns3xxx_sdhci_init(void)
  87. {
  88. u32 __iomem *gpioa = __io(CNS3XXX_MISC_BASE_VIRT + 0x0014);
  89. u32 gpioa_pins = __raw_readl(gpioa);
  90. /* MMC/SD pins share with GPIOA */
  91. gpioa_pins |= 0x1fff0004;
  92. __raw_writel(gpioa_pins, gpioa);
  93. cns3xxx_pwr_clk_en(CNS3XXX_PWR_CLK_EN(SDIO));
  94. cns3xxx_pwr_soft_rst(CNS3XXX_PWR_SOFTWARE_RST(SDIO));
  95. platform_device_register(&cns3xxx_sdhci_pdev);
  96. }