pruss.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * PRU-ICSS Subsystem user interfaces
  4. *
  5. * Copyright (C) 2015-2023 Texas Instruments Incorporated - http://www.ti.com
  6. * MD Danish Anwar <danishanwar@ti.com>
  7. */
  8. #ifndef _SOC_TI_PRUSS_H_
  9. #define _SOC_TI_PRUSS_H_
  10. #include <linux/bits.h>
  11. #include <linux/regmap.h>
  12. /*
  13. * PRU_ICSS_CFG registers
  14. * SYSCFG, ISRP, ISP, IESP, IECP, SCRP applicable on AMxxxx devices only
  15. */
  16. #define PRUSS_CFG_REVID 0x00
  17. #define PRUSS_CFG_SYSCFG 0x04
  18. #define PRUSS_CFG_GPCFG(x) (0x08 + (x) * 4)
  19. #define PRUSS_CFG_CGR 0x10
  20. #define PRUSS_CFG_ISRP 0x14
  21. #define PRUSS_CFG_ISP 0x18
  22. #define PRUSS_CFG_IESP 0x1C
  23. #define PRUSS_CFG_IECP 0x20
  24. #define PRUSS_CFG_SCRP 0x24
  25. #define PRUSS_CFG_PMAO 0x28
  26. #define PRUSS_CFG_MII_RT 0x2C
  27. #define PRUSS_CFG_IEPCLK 0x30
  28. #define PRUSS_CFG_SPP 0x34
  29. #define PRUSS_CFG_PIN_MX 0x40
  30. /* PRUSS_GPCFG register bits */
  31. #define PRUSS_GPCFG_PRU_GPI_MODE_MASK GENMASK(1, 0)
  32. #define PRUSS_GPCFG_PRU_GPI_MODE_SHIFT 0
  33. #define PRUSS_GPCFG_PRU_MUX_SEL_SHIFT 26
  34. #define PRUSS_GPCFG_PRU_MUX_SEL_MASK GENMASK(29, 26)
  35. /* PRUSS_MII_RT register bits */
  36. #define PRUSS_MII_RT_EVENT_EN BIT(0)
  37. /* PRUSS_SPP register bits */
  38. #define PRUSS_SPP_XFER_SHIFT_EN BIT(1)
  39. #define PRUSS_SPP_PRU1_PAD_HP_EN BIT(0)
  40. #define PRUSS_SPP_RTU_XFR_SHIFT_EN BIT(3)
  41. /**
  42. * pruss_cfg_read() - read a PRUSS CFG sub-module register
  43. * @pruss: the pruss instance handle
  44. * @reg: register offset within the CFG sub-module
  45. * @val: pointer to return the value in
  46. *
  47. * Reads a given register within the PRUSS CFG sub-module and
  48. * returns it through the passed-in @val pointer
  49. *
  50. * Return: 0 on success, or an error code otherwise
  51. */
  52. static int pruss_cfg_read(struct pruss *pruss, unsigned int reg, unsigned int *val)
  53. {
  54. if (IS_ERR_OR_NULL(pruss))
  55. return -EINVAL;
  56. return regmap_read(pruss->cfg_regmap, reg, val);
  57. }
  58. /**
  59. * pruss_cfg_update() - configure a PRUSS CFG sub-module register
  60. * @pruss: the pruss instance handle
  61. * @reg: register offset within the CFG sub-module
  62. * @mask: bit mask to use for programming the @val
  63. * @val: value to write
  64. *
  65. * Programs a given register within the PRUSS CFG sub-module
  66. *
  67. * Return: 0 on success, or an error code otherwise
  68. */
  69. static int pruss_cfg_update(struct pruss *pruss, unsigned int reg,
  70. unsigned int mask, unsigned int val)
  71. {
  72. if (IS_ERR_OR_NULL(pruss))
  73. return -EINVAL;
  74. return regmap_update_bits(pruss->cfg_regmap, reg, mask, val);
  75. }
  76. #endif /* _SOC_TI_PRUSS_H_ */