0001
0002
0003
0004
0005
0006
0007 #ifndef MCP_H
0008 #define MCP_H
0009
0010 #include <linux/device.h>
0011
0012 struct mcp_ops;
0013
0014 struct mcp {
0015 struct module *owner;
0016 struct mcp_ops *ops;
0017 spinlock_t lock;
0018 int use_count;
0019 unsigned int sclk_rate;
0020 unsigned int rw_timeout;
0021 struct device attached_device;
0022 };
0023
0024 struct mcp_ops {
0025 void (*set_telecom_divisor)(struct mcp *, unsigned int);
0026 void (*set_audio_divisor)(struct mcp *, unsigned int);
0027 void (*reg_write)(struct mcp *, unsigned int, unsigned int);
0028 unsigned int (*reg_read)(struct mcp *, unsigned int);
0029 void (*enable)(struct mcp *);
0030 void (*disable)(struct mcp *);
0031 };
0032
0033 void mcp_set_telecom_divisor(struct mcp *, unsigned int);
0034 void mcp_set_audio_divisor(struct mcp *, unsigned int);
0035 void mcp_reg_write(struct mcp *, unsigned int, unsigned int);
0036 unsigned int mcp_reg_read(struct mcp *, unsigned int);
0037 void mcp_enable(struct mcp *);
0038 void mcp_disable(struct mcp *);
0039 #define mcp_get_sclk_rate(mcp) ((mcp)->sclk_rate)
0040
0041 struct mcp *mcp_host_alloc(struct device *, size_t);
0042 int mcp_host_add(struct mcp *, void *);
0043 void mcp_host_del(struct mcp *);
0044 void mcp_host_free(struct mcp *);
0045
0046 struct mcp_driver {
0047 struct device_driver drv;
0048 int (*probe)(struct mcp *);
0049 void (*remove)(struct mcp *);
0050 };
0051
0052 int mcp_driver_register(struct mcp_driver *);
0053 void mcp_driver_unregister(struct mcp_driver *);
0054
0055 #define mcp_get_drvdata(mcp) dev_get_drvdata(&(mcp)->attached_device)
0056 #define mcp_set_drvdata(mcp,d) dev_set_drvdata(&(mcp)->attached_device, d)
0057
0058 static inline void *mcp_priv(struct mcp *mcp)
0059 {
0060 return mcp + 1;
0061 }
0062
0063 #endif