1515e64e3663abd1a557e339c0eb57d6f13d8117
[linux-flexiantxendom0-3.2.10.git] / include / linux / mfd / mcp.h
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
13 #include <linux/mod_devicetable.h>
14 #include <mach/dma.h>
15
16 struct mcp_ops;
17
18 struct mcp {
19         struct module   *owner;
20         struct mcp_ops  *ops;
21         spinlock_t      lock;
22         int             use_count;
23         unsigned int    sclk_rate;
24         unsigned int    rw_timeout;
25         dma_device_t    dma_audio_rd;
26         dma_device_t    dma_audio_wr;
27         dma_device_t    dma_telco_rd;
28         dma_device_t    dma_telco_wr;
29         struct device   attached_device;
30         const char      *codec;
31 };
32
33 struct mcp_ops {
34         void            (*set_telecom_divisor)(struct mcp *, unsigned int);
35         void            (*set_audio_divisor)(struct mcp *, unsigned int);
36         void            (*reg_write)(struct mcp *, unsigned int, unsigned int);
37         unsigned int    (*reg_read)(struct mcp *, unsigned int);
38         void            (*enable)(struct mcp *);
39         void            (*disable)(struct mcp *);
40 };
41
42 void mcp_set_telecom_divisor(struct mcp *, unsigned int);
43 void mcp_set_audio_divisor(struct mcp *, unsigned int);
44 void mcp_reg_write(struct mcp *, unsigned int, unsigned int);
45 unsigned int mcp_reg_read(struct mcp *, unsigned int);
46 void mcp_enable(struct mcp *);
47 void mcp_disable(struct mcp *);
48 const struct mcp_device_id *mcp_get_device_id(const struct mcp *mcp);
49 #define mcp_get_sclk_rate(mcp)  ((mcp)->sclk_rate)
50
51 struct mcp *mcp_host_alloc(struct device *, size_t);
52 int mcp_host_register(struct mcp *, void *);
53 void mcp_host_unregister(struct mcp *);
54
55 struct mcp_driver {
56         struct device_driver drv;
57         int (*probe)(struct mcp *);
58         void (*remove)(struct mcp *);
59         int (*suspend)(struct mcp *, pm_message_t);
60         int (*resume)(struct mcp *);
61         const struct mcp_device_id *id_table;
62 };
63
64 int mcp_driver_register(struct mcp_driver *);
65 void mcp_driver_unregister(struct mcp_driver *);
66
67 #define mcp_get_drvdata(mcp)    dev_get_drvdata(&(mcp)->attached_device)
68 #define mcp_set_drvdata(mcp,d)  dev_set_drvdata(&(mcp)->attached_device, d)
69
70 #define mcp_priv(mcp)           ((void *)((mcp)+1))
71
72 #endif