mcp.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * linux/drivers/mfd/mcp.h
  4. *
  5. * Copyright (C) 2001 Russell King, All Rights Reserved.
  6. */
  7. #ifndef MCP_H
  8. #define MCP_H
  9. #include <linux/device.h>
  10. struct mcp_ops;
  11. struct mcp {
  12. struct module *owner;
  13. struct mcp_ops *ops;
  14. spinlock_t lock;
  15. int use_count;
  16. unsigned int sclk_rate;
  17. unsigned int rw_timeout;
  18. struct device attached_device;
  19. };
  20. struct mcp_ops {
  21. void (*set_telecom_divisor)(struct mcp *, unsigned int);
  22. void (*set_audio_divisor)(struct mcp *, unsigned int);
  23. void (*reg_write)(struct mcp *, unsigned int, unsigned int);
  24. unsigned int (*reg_read)(struct mcp *, unsigned int);
  25. void (*enable)(struct mcp *);
  26. void (*disable)(struct mcp *);
  27. };
  28. void mcp_set_telecom_divisor(struct mcp *, unsigned int);
  29. void mcp_set_audio_divisor(struct mcp *, unsigned int);
  30. void mcp_reg_write(struct mcp *, unsigned int, unsigned int);
  31. unsigned int mcp_reg_read(struct mcp *, unsigned int);
  32. void mcp_enable(struct mcp *);
  33. void mcp_disable(struct mcp *);
  34. #define mcp_get_sclk_rate(mcp) ((mcp)->sclk_rate)
  35. struct mcp *mcp_host_alloc(struct device *, size_t);
  36. int mcp_host_add(struct mcp *, void *);
  37. void mcp_host_del(struct mcp *);
  38. void mcp_host_free(struct mcp *);
  39. struct mcp_driver {
  40. struct device_driver drv;
  41. int (*probe)(struct mcp *);
  42. void (*remove)(struct mcp *);
  43. };
  44. int mcp_driver_register(struct mcp_driver *);
  45. void mcp_driver_unregister(struct mcp_driver *);
  46. #define mcp_get_drvdata(mcp) dev_get_drvdata(&(mcp)->attached_device)
  47. #define mcp_set_drvdata(mcp,d) dev_set_drvdata(&(mcp)->attached_device, d)
  48. static inline void *mcp_priv(struct mcp *mcp)
  49. {
  50. return mcp + 1;
  51. }
  52. #endif