mcp.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. struct mcp_ops;
  13. struct mcp {
  14. struct module *owner;
  15. struct mcp_ops *ops;
  16. spinlock_t lock;
  17. int use_count;
  18. unsigned int sclk_rate;
  19. unsigned int rw_timeout;
  20. struct device attached_device;
  21. };
  22. struct mcp_ops {
  23. void (*set_telecom_divisor)(struct mcp *, unsigned int);
  24. void (*set_audio_divisor)(struct mcp *, unsigned int);
  25. void (*reg_write)(struct mcp *, unsigned int, unsigned int);
  26. unsigned int (*reg_read)(struct mcp *, unsigned int);
  27. void (*enable)(struct mcp *);
  28. void (*disable)(struct mcp *);
  29. };
  30. void mcp_set_telecom_divisor(struct mcp *, unsigned int);
  31. void mcp_set_audio_divisor(struct mcp *, unsigned int);
  32. void mcp_reg_write(struct mcp *, unsigned int, unsigned int);
  33. unsigned int mcp_reg_read(struct mcp *, unsigned int);
  34. void mcp_enable(struct mcp *);
  35. void mcp_disable(struct mcp *);
  36. #define mcp_get_sclk_rate(mcp) ((mcp)->sclk_rate)
  37. struct mcp *mcp_host_alloc(struct device *, size_t);
  38. int mcp_host_add(struct mcp *, void *);
  39. void mcp_host_del(struct mcp *);
  40. void mcp_host_free(struct mcp *);
  41. struct mcp_driver {
  42. struct device_driver drv;
  43. int (*probe)(struct mcp *);
  44. void (*remove)(struct mcp *);
  45. };
  46. int mcp_driver_register(struct mcp_driver *);
  47. void mcp_driver_unregister(struct mcp_driver *);
  48. #define mcp_get_drvdata(mcp) dev_get_drvdata(&(mcp)->attached_device)
  49. #define mcp_set_drvdata(mcp,d) dev_set_drvdata(&(mcp)->attached_device, d)
  50. static inline void *mcp_priv(struct mcp *mcp)
  51. {
  52. return mcp + 1;
  53. }
  54. #endif