ocelot.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* SPDX-License-Identifier: GPL-2.0 OR MIT */
  2. /* Copyright 2021, 2022 Innovative Advantage Inc. */
  3. #ifndef _MFD_OCELOT_H
  4. #define _MFD_OCELOT_H
  5. #include <linux/kconfig.h>
  6. struct device;
  7. struct regmap;
  8. struct resource;
  9. /**
  10. * struct ocelot_ddata - Private data for an external Ocelot chip
  11. * @gcb_regmap: General Configuration Block regmap. Used for
  12. * operations like chip reset.
  13. * @cpuorg_regmap: CPU Device Origin Block regmap. Used for operations
  14. * like SPI bus configuration.
  15. * @spi_padding_bytes: Number of padding bytes that must be thrown out before
  16. * read data gets returned. This is calculated during
  17. * initialization based on bus speed.
  18. * @dummy_buf: Zero-filled buffer of spi_padding_bytes size. The dummy
  19. * bytes that will be sent out between the address and
  20. * data of a SPI read operation.
  21. */
  22. struct ocelot_ddata {
  23. struct regmap *gcb_regmap;
  24. struct regmap *cpuorg_regmap;
  25. int spi_padding_bytes;
  26. void *dummy_buf;
  27. };
  28. int ocelot_chip_reset(struct device *dev);
  29. int ocelot_core_init(struct device *dev);
  30. /* SPI-specific routines that won't be necessary for other interfaces */
  31. struct regmap *ocelot_spi_init_regmap(struct device *dev,
  32. const struct resource *res);
  33. #define OCELOT_SPI_BYTE_ORDER_LE 0x00000000
  34. #define OCELOT_SPI_BYTE_ORDER_BE 0x81818181
  35. #ifdef __LITTLE_ENDIAN
  36. #define OCELOT_SPI_BYTE_ORDER OCELOT_SPI_BYTE_ORDER_LE
  37. #else
  38. #define OCELOT_SPI_BYTE_ORDER OCELOT_SPI_BYTE_ORDER_BE
  39. #endif
  40. #endif