spi-fsl-spi.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Freescale SPI controller driver.
  3. *
  4. * Maintainer: Kumar Gala
  5. *
  6. * Copyright (C) 2006 Polycom, Inc.
  7. * Copyright 2010 Freescale Semiconductor, Inc.
  8. *
  9. * CPM SPI and QE buffer descriptors mode support:
  10. * Copyright (c) 2009 MontaVista Software, Inc.
  11. * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
  12. *
  13. * GRLIB support:
  14. * Copyright (c) 2012 Aeroflex Gaisler AB.
  15. * Author: Andreas Larsson <andreas@gaisler.com>
  16. *
  17. * This program is free software; you can redistribute it and/or modify it
  18. * under the terms of the GNU General Public License as published by the
  19. * Free Software Foundation; either version 2 of the License, or (at your
  20. * option) any later version.
  21. */
  22. #ifndef __SPI_FSL_SPI_H__
  23. #define __SPI_FSL_SPI_H__
  24. /* SPI Controller registers */
  25. struct fsl_spi_reg {
  26. __be32 cap; /* TYPE_GRLIB specific */
  27. u8 res1[0x1C];
  28. __be32 mode;
  29. __be32 event;
  30. __be32 mask;
  31. __be32 command;
  32. __be32 transmit;
  33. __be32 receive;
  34. __be32 slvsel; /* TYPE_GRLIB specific */
  35. };
  36. /* SPI Controller mode register definitions */
  37. #define SPMODE_LOOP (1 << 30)
  38. #define SPMODE_CI_INACTIVEHIGH (1 << 29)
  39. #define SPMODE_CP_BEGIN_EDGECLK (1 << 28)
  40. #define SPMODE_DIV16 (1 << 27)
  41. #define SPMODE_REV (1 << 26)
  42. #define SPMODE_MS (1 << 25)
  43. #define SPMODE_ENABLE (1 << 24)
  44. #define SPMODE_LEN(x) ((x) << 20)
  45. #define SPMODE_PM(x) ((x) << 16)
  46. #define SPMODE_OP (1 << 14)
  47. #define SPMODE_CG(x) ((x) << 7)
  48. /* TYPE_GRLIB SPI Controller capability register definitions */
  49. #define SPCAP_SSEN(x) (((x) >> 16) & 0x1)
  50. #define SPCAP_SSSZ(x) (((x) >> 24) & 0xff)
  51. #define SPCAP_MAXWLEN(x) (((x) >> 20) & 0xf)
  52. /*
  53. * Default for SPI Mode:
  54. * SPI MODE 0 (inactive low, phase middle, MSB, 8-bit length, slow clk
  55. */
  56. #define SPMODE_INIT_VAL (SPMODE_CI_INACTIVEHIGH | SPMODE_DIV16 | SPMODE_REV | \
  57. SPMODE_MS | SPMODE_LEN(7) | SPMODE_PM(0xf))
  58. /* SPIE register values */
  59. #define SPIE_NE 0x00000200 /* Not empty */
  60. #define SPIE_NF 0x00000100 /* Not full */
  61. /* SPIM register values */
  62. #define SPIM_NE 0x00000200 /* Not empty */
  63. #define SPIM_NF 0x00000100 /* Not full */
  64. #endif /* __SPI_FSL_SPI_H__ */