dev-spi.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2009-2011 Florian Fainelli <florian@openwrt.org>
  7. * Copyright (C) 2010 Tanguy Bouzeloc <tanguy.bouzeloc@efixo.com>
  8. */
  9. #include <linux/init.h>
  10. #include <linux/kernel.h>
  11. #include <linux/export.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/err.h>
  14. #include <linux/clk.h>
  15. #include <bcm63xx_cpu.h>
  16. #include <bcm63xx_dev_spi.h>
  17. #include <bcm63xx_regs.h>
  18. static struct resource spi_resources[] = {
  19. {
  20. .start = -1, /* filled at runtime */
  21. .end = -1, /* filled at runtime */
  22. .flags = IORESOURCE_MEM,
  23. },
  24. {
  25. .start = -1, /* filled at runtime */
  26. .flags = IORESOURCE_IRQ,
  27. },
  28. };
  29. static struct platform_device bcm63xx_spi_device = {
  30. .id = -1,
  31. .num_resources = ARRAY_SIZE(spi_resources),
  32. .resource = spi_resources,
  33. };
  34. int __init bcm63xx_spi_register(void)
  35. {
  36. if (BCMCPU_IS_6328() || BCMCPU_IS_6345())
  37. return -ENODEV;
  38. spi_resources[0].start = bcm63xx_regset_address(RSET_SPI);
  39. spi_resources[0].end = spi_resources[0].start;
  40. spi_resources[1].start = bcm63xx_get_irq_number(IRQ_SPI);
  41. if (BCMCPU_IS_6338() || BCMCPU_IS_6348()) {
  42. bcm63xx_spi_device.name = "bcm6348-spi",
  43. spi_resources[0].end += BCM_6348_RSET_SPI_SIZE - 1;
  44. }
  45. if (BCMCPU_IS_3368() || BCMCPU_IS_6358() || BCMCPU_IS_6362() ||
  46. BCMCPU_IS_6368()) {
  47. bcm63xx_spi_device.name = "bcm6358-spi",
  48. spi_resources[0].end += BCM_6358_RSET_SPI_SIZE - 1;
  49. }
  50. return platform_device_register(&bcm63xx_spi_device);
  51. }