isp1760-core.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Driver for the NXP ISP1760 chip
  4. *
  5. * Copyright 2021 Linaro, Rui Miguel Silva
  6. * Copyright 2014 Laurent Pinchart
  7. * Copyright 2007 Sebastian Siewior
  8. *
  9. * Contacts:
  10. * Sebastian Siewior <bigeasy@linutronix.de>
  11. * Laurent Pinchart <laurent.pinchart@ideasonboard.com>
  12. * Rui Miguel Silva <rui.silva@linaro.org>
  13. */
  14. #ifndef _ISP1760_CORE_H_
  15. #define _ISP1760_CORE_H_
  16. #include <linux/ioport.h>
  17. #include <linux/regmap.h>
  18. #include "isp1760-hcd.h"
  19. #include "isp1760-udc.h"
  20. struct device;
  21. struct gpio_desc;
  22. /*
  23. * Device flags that can vary from board to board. All of these
  24. * indicate the most "atypical" case, so that a devflags of 0 is
  25. * a sane default configuration.
  26. */
  27. #define ISP1760_FLAG_BUS_WIDTH_16 0x00000002 /* 16-bit data bus width */
  28. #define ISP1760_FLAG_PERIPHERAL_EN 0x00000004 /* Port 1 supports Peripheral mode*/
  29. #define ISP1760_FLAG_ANALOG_OC 0x00000008 /* Analog overcurrent */
  30. #define ISP1760_FLAG_DACK_POL_HIGH 0x00000010 /* DACK active high */
  31. #define ISP1760_FLAG_DREQ_POL_HIGH 0x00000020 /* DREQ active high */
  32. #define ISP1760_FLAG_ISP1761 0x00000040 /* Chip is ISP1761 */
  33. #define ISP1760_FLAG_INTR_POL_HIGH 0x00000080 /* Interrupt polarity active high */
  34. #define ISP1760_FLAG_INTR_EDGE_TRIG 0x00000100 /* Interrupt edge triggered */
  35. #define ISP1760_FLAG_ISP1763 0x00000200 /* Chip is ISP1763 */
  36. #define ISP1760_FLAG_BUS_WIDTH_8 0x00000400 /* 8-bit data bus width */
  37. struct isp1760_device {
  38. struct device *dev;
  39. unsigned int devflags;
  40. struct gpio_desc *rst_gpio;
  41. struct isp1760_hcd hcd;
  42. struct isp1760_udc udc;
  43. };
  44. int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
  45. struct device *dev, unsigned int devflags);
  46. void isp1760_unregister(struct device *dev);
  47. void isp1760_set_pullup(struct isp1760_device *isp, bool enable);
  48. static inline u32 isp1760_field_read(struct regmap_field **fields, u32 field)
  49. {
  50. unsigned int val;
  51. regmap_field_read(fields[field], &val);
  52. return val;
  53. }
  54. static inline void isp1760_field_write(struct regmap_field **fields, u32 field,
  55. u32 val)
  56. {
  57. regmap_field_write(fields[field], val);
  58. }
  59. static inline void isp1760_field_set(struct regmap_field **fields, u32 field)
  60. {
  61. isp1760_field_write(fields, field, 0xFFFFFFFF);
  62. }
  63. static inline void isp1760_field_clear(struct regmap_field **fields, u32 field)
  64. {
  65. isp1760_field_write(fields, field, 0);
  66. }
  67. static inline u32 isp1760_reg_read(struct regmap *regs, u32 reg)
  68. {
  69. unsigned int val;
  70. regmap_read(regs, reg, &val);
  71. return val;
  72. }
  73. static inline void isp1760_reg_write(struct regmap *regs, u32 reg, u32 val)
  74. {
  75. regmap_write(regs, reg, val);
  76. }
  77. #endif