devices.c 2.6 KB

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