blob: 1515e64e3663abd1a557e339c0eb57d6f13d8117 [file] [log] [blame]
Russell Kinga4e137a2005-08-18 10:06:59 +01001/*
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
Jochen Friedrich5dd7bf52011-11-27 22:00:54 +010013#include <linux/mod_devicetable.h>
Thomas Kunzec8602ed2009-02-10 14:54:57 +010014#include <mach/dma.h>
15
Russell Kinga4e137a2005-08-18 10:06:59 +010016struct mcp_ops;
17
18struct 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;
Jochen Friedrich5dd7bf52011-11-27 22:00:54 +010030 const char *codec;
Russell Kinga4e137a2005-08-18 10:06:59 +010031};
32
33struct 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
42void mcp_set_telecom_divisor(struct mcp *, unsigned int);
43void mcp_set_audio_divisor(struct mcp *, unsigned int);
44void mcp_reg_write(struct mcp *, unsigned int, unsigned int);
45unsigned int mcp_reg_read(struct mcp *, unsigned int);
46void mcp_enable(struct mcp *);
47void mcp_disable(struct mcp *);
Jochen Friedrich5dd7bf52011-11-27 22:00:54 +010048const struct mcp_device_id *mcp_get_device_id(const struct mcp *mcp);
Russell Kinga4e137a2005-08-18 10:06:59 +010049#define mcp_get_sclk_rate(mcp) ((mcp)->sclk_rate)
50
51struct mcp *mcp_host_alloc(struct device *, size_t);
Jochen Friedrich5dd7bf52011-11-27 22:00:54 +010052int mcp_host_register(struct mcp *, void *);
Russell Kinga4e137a2005-08-18 10:06:59 +010053void mcp_host_unregister(struct mcp *);
54
55struct 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 *);
Jochen Friedrich5dd7bf52011-11-27 22:00:54 +010061 const struct mcp_device_id *id_table;
Russell Kinga4e137a2005-08-18 10:06:59 +010062};
63
64int mcp_driver_register(struct mcp_driver *);
65void 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