blob: a9e8bd157673a475ebfb5d78e81f0b8d6d621ed6 [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
Russell Kinga4e137a2005-08-18 10:06:59 +010013struct mcp_ops;
14
15struct mcp {
16 struct module *owner;
17 struct mcp_ops *ops;
18 spinlock_t lock;
19 int use_count;
20 unsigned int sclk_rate;
21 unsigned int rw_timeout;
Russell Kinga4e137a2005-08-18 10:06:59 +010022 struct device attached_device;
Russell Kinga4e137a2005-08-18 10:06:59 +010023};
24
25struct mcp_ops {
26 void (*set_telecom_divisor)(struct mcp *, unsigned int);
27 void (*set_audio_divisor)(struct mcp *, unsigned int);
28 void (*reg_write)(struct mcp *, unsigned int, unsigned int);
29 unsigned int (*reg_read)(struct mcp *, unsigned int);
30 void (*enable)(struct mcp *);
31 void (*disable)(struct mcp *);
32};
33
34void mcp_set_telecom_divisor(struct mcp *, unsigned int);
35void mcp_set_audio_divisor(struct mcp *, unsigned int);
36void mcp_reg_write(struct mcp *, unsigned int, unsigned int);
37unsigned int mcp_reg_read(struct mcp *, unsigned int);
38void mcp_enable(struct mcp *);
39void mcp_disable(struct mcp *);
40#define mcp_get_sclk_rate(mcp) ((mcp)->sclk_rate)
41
42struct mcp *mcp_host_alloc(struct device *, size_t);
Russell Kingabe06082012-01-20 22:13:52 +000043int mcp_host_add(struct mcp *, void *);
Russell King30816ac2012-01-20 22:51:07 +000044void mcp_host_del(struct mcp *);
45void mcp_host_free(struct mcp *);
Russell Kinga4e137a2005-08-18 10:06:59 +010046
47struct mcp_driver {
48 struct device_driver drv;
49 int (*probe)(struct mcp *);
50 void (*remove)(struct mcp *);
Russell Kinga4e137a2005-08-18 10:06:59 +010051};
52
53int mcp_driver_register(struct mcp_driver *);
54void mcp_driver_unregister(struct mcp_driver *);
55
56#define mcp_get_drvdata(mcp) dev_get_drvdata(&(mcp)->attached_device)
57#define mcp_set_drvdata(mcp,d) dev_set_drvdata(&(mcp)->attached_device, d)
58
Russell King2a7f51a2012-01-21 09:28:53 +000059static inline void *mcp_priv(struct mcp *mcp)
60{
61 return mcp + 1;
62}
Russell Kinga4e137a2005-08-18 10:06:59 +010063
64#endif