altera-a10sr.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright Intel Corporation (C) 2014-2016. All Rights Reserved
  4. *
  5. * Declarations for Altera Arria10 MAX5 System Resource Chip
  6. *
  7. * Adapted from DA9052
  8. */
  9. #ifndef __MFD_ALTERA_A10SR_H
  10. #define __MFD_ALTERA_A10SR_H
  11. #include <linux/completion.h>
  12. #include <linux/list.h>
  13. #include <linux/mfd/core.h>
  14. #include <linux/regmap.h>
  15. #include <linux/slab.h>
  16. /* Write registers are always on even addresses */
  17. #define WRITE_REG_MASK 0xFE
  18. /* Odd registers are always on odd addresses */
  19. #define READ_REG_MASK 0x01
  20. #define ALTR_A10SR_BITS_PER_REGISTER 8
  21. /*
  22. * To find the correct register, we divide the input GPIO by
  23. * the number of GPIO in each register. We then need to multiply
  24. * by 2 because the reads are at odd addresses.
  25. */
  26. #define ALTR_A10SR_REG_OFFSET(X) (((X) / ALTR_A10SR_BITS_PER_REGISTER) << 1)
  27. #define ALTR_A10SR_REG_BIT(X) ((X) % ALTR_A10SR_BITS_PER_REGISTER)
  28. #define ALTR_A10SR_REG_BIT_CHG(X, Y) ((X) << ALTR_A10SR_REG_BIT(Y))
  29. #define ALTR_A10SR_REG_BIT_MASK(X) (1 << ALTR_A10SR_REG_BIT(X))
  30. /* Arria10 System Controller Register Defines */
  31. #define ALTR_A10SR_NOP 0x00 /* No Change */
  32. #define ALTR_A10SR_VERSION_READ 0x00 /* MAX5 Version Read */
  33. #define ALTR_A10SR_LED_REG 0x02 /* LED - Upper 4 bits */
  34. /* LED register Bit Definitions */
  35. #define ALTR_A10SR_LED_VALID_SHIFT 4 /* LED - Upper 4 bits valid */
  36. #define ALTR_A10SR_OUT_VALID_RANGE_LO ALTR_A10SR_LED_VALID_SHIFT
  37. #define ALTR_A10SR_OUT_VALID_RANGE_HI 7
  38. #define ALTR_A10SR_PBDSW_REG 0x04 /* PB & DIP SW - Input only */
  39. #define ALTR_A10SR_PBDSW_IRQ_REG 0x06 /* PB & DIP SW Flag Clear */
  40. /* Pushbutton & DIP Switch Bit Definitions */
  41. #define ALTR_A10SR_IN_VALID_RANGE_LO 8
  42. #define ALTR_A10SR_IN_VALID_RANGE_HI 15
  43. #define ALTR_A10SR_PWR_GOOD1_REG 0x08 /* Power Good1 Read */
  44. #define ALTR_A10SR_PWR_GOOD2_REG 0x0A /* Power Good2 Read */
  45. #define ALTR_A10SR_PWR_GOOD3_REG 0x0C /* Power Good3 Read */
  46. #define ALTR_A10SR_FMCAB_REG 0x0E /* FMCA/B & PCIe Pwr Enable */
  47. #define ALTR_A10SR_HPS_RST_REG 0x10 /* HPS Reset */
  48. #define ALTR_A10SR_USB_QSPI_REG 0x12 /* USB, BQSPI, FILE Reset */
  49. #define ALTR_A10SR_SFPA_REG 0x14 /* SFPA Control Reg */
  50. #define ALTR_A10SR_SFPB_REG 0x16 /* SFPB Control Reg */
  51. #define ALTR_A10SR_I2C_M_REG 0x18 /* I2C Master Select */
  52. #define ALTR_A10SR_WARM_RST_REG 0x1A /* HPS Warm Reset */
  53. #define ALTR_A10SR_WR_KEY_REG 0x1C /* HPS Warm Reset Key */
  54. #define ALTR_A10SR_PMBUS_REG 0x1E /* HPS PM Bus */
  55. /**
  56. * struct altr_a10sr - Altera Max5 MFD device private data structure
  57. * @dev: : this device
  58. * @regmap: the regmap assigned to the parent device.
  59. */
  60. struct altr_a10sr {
  61. struct device *dev;
  62. struct regmap *regmap;
  63. };
  64. #endif /* __MFD_ALTERA_A10SR_H */