mcp.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * linux/drivers/mfd/mcp.h
  3. *
  4. * Copyright (C) 2001 Russell King, All Rights Reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License.
  9. */
  10. #ifndef MCP_H
  11. #define MCP_H
  12. #include <linux/device.h>
  13. struct mcp_ops;
  14. struct mcp {
  15. struct module *owner;
  16. struct mcp_ops *ops;
  17. spinlock_t lock;
  18. int use_count;
  19. unsigned int sclk_rate;
  20. unsigned int rw_timeout;
  21. struct device attached_device;
  22. };
  23. struct mcp_ops {
  24. void (*set_telecom_divisor)(struct mcp *, unsigned int);
  25. void (*set_audio_divisor)(struct mcp *, unsigned int);
  26. void (*reg_write)(struct mcp *, unsigned int, unsigned int);
  27. unsigned int (*reg_read)(struct mcp *, unsigned int);
  28. void (*enable)(struct mcp *);
  29. void (*disable)(struct mcp *);
  30. };
  31. void mcp_set_telecom_divisor(struct mcp *, unsigned int);
  32. void mcp_set_audio_divisor(struct mcp *, unsigned int);
  33. void mcp_reg_write(struct mcp *, unsigned int, unsigned int);
  34. unsigned int mcp_reg_read(struct mcp *, unsigned int);
  35. void mcp_enable(struct mcp *);
  36. void mcp_disable(struct mcp *);
  37. #define mcp_get_sclk_rate(mcp) ((mcp)->sclk_rate)
  38. struct mcp *mcp_host_alloc(struct device *, size_t);
  39. int mcp_host_add(struct mcp *, void *);
  40. void mcp_host_del(struct mcp *);
  41. void mcp_host_free(struct mcp *);
  42. struct mcp_driver {
  43. struct device_driver drv;
  44. int (*probe)(struct mcp *);
  45. void (*remove)(struct mcp *);
  46. };
  47. int mcp_driver_register(struct mcp_driver *);
  48. void mcp_driver_unregister(struct mcp_driver *);
  49. #define mcp_get_drvdata(mcp) dev_get_drvdata(&(mcp)->attached_device)
  50. #define mcp_set_drvdata(mcp,d) dev_set_drvdata(&(mcp)->attached_device, d)
  51. static inline void *mcp_priv(struct mcp *mcp)
  52. {
  53. return mcp + 1;
  54. }
  55. #endif