devices.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/platform_device.h>
  17. #include <mach/cns3xxx.h>
  18. #include <mach/irqs.h>
  19. #include "core.h"
  20. #include "devices.h"
  21. /*
  22. * SDHCI
  23. */
  24. static struct resource cns3xxx_sdhci_resources[] = {
  25. [0] = {
  26. .start = CNS3XXX_SDIO_BASE,
  27. .end = CNS3XXX_SDIO_BASE + SZ_4K - 1,
  28. .flags = IORESOURCE_MEM,
  29. },
  30. [1] = {
  31. .start = IRQ_CNS3XXX_SDIO,
  32. .end = IRQ_CNS3XXX_SDIO,
  33. .flags = IORESOURCE_IRQ,
  34. },
  35. };
  36. static struct platform_device cns3xxx_sdhci_pdev = {
  37. .name = "sdhci-cns3xxx",
  38. .id = 0,
  39. .num_resources = ARRAY_SIZE(cns3xxx_sdhci_resources),
  40. .resource = cns3xxx_sdhci_resources,
  41. };
  42. void __init cns3xxx_sdhci_init(void)
  43. {
  44. u32 __iomem *gpioa = __io(CNS3XXX_MISC_BASE_VIRT + 0x0014);
  45. u32 gpioa_pins = __raw_readl(gpioa);
  46. /* MMC/SD pins share with GPIOA */
  47. gpioa_pins |= 0x1fff0004;
  48. __raw_writel(gpioa_pins, gpioa);
  49. cns3xxx_pwr_clk_en(CNS3XXX_PWR_CLK_EN(SDIO));
  50. cns3xxx_pwr_soft_rst(CNS3XXX_PWR_SOFTWARE_RST(SDIO));
  51. platform_device_register(&cns3xxx_sdhci_pdev);
  52. }