blob: f682953043ba9c81686ef35293d0274d402b5326 [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
Andrea Adami62480dc2013-07-21 01:07:42 +020013#include <linux/device.h>
14
Russell Kinga4e137a2005-08-18 10:06:59 +010015struct mcp_ops;
16
17struct mcp {
18 struct module *owner;
19 struct mcp_ops *ops;
20 spinlock_t lock;
21 int use_count;
22 unsigned int sclk_rate;
23 unsigned int rw_timeout;
Russell Kinga4e137a2005-08-18 10:06:59 +010024 struct device attached_device;
Russell Kinga4e137a2005-08-18 10:06:59 +010025};
26
27struct mcp_ops {
28 void (*set_telecom_divisor)(struct mcp *, unsigned int);
29 void (*set_audio_divisor)(struct mcp *, unsigned int);
30 void (*reg_write)(struct mcp *, unsigned int, unsigned int);
31 unsigned int (*reg_read)(struct mcp *, unsigned int);
32 void (*enable)(struct mcp *);
33 void (*disable)(struct mcp *);
34};
35
36void mcp_set_telecom_divisor(struct mcp *, unsigned int);
37void mcp_set_audio_divisor(struct mcp *, unsigned int);
38void mcp_reg_write(struct mcp *, unsigned int, unsigned int);
39unsigned int mcp_reg_read(struct mcp *, unsigned int);
40void mcp_enable(struct mcp *);
41void mcp_disable(struct mcp *);
42#define mcp_get_sclk_rate(mcp) ((mcp)->sclk_rate)
43
44struct mcp *mcp_host_alloc(struct device *, size_t);
Russell Kingabe06082012-01-20 22:13:52 +000045int mcp_host_add(struct mcp *, void *);
Russell King30816ac2012-01-20 22:51:07 +000046void mcp_host_del(struct mcp *);
47void mcp_host_free(struct mcp *);
Russell Kinga4e137a2005-08-18 10:06:59 +010048
49struct mcp_driver {
50 struct device_driver drv;
51 int (*probe)(struct mcp *);
52 void (*remove)(struct mcp *);
Russell Kinga4e137a2005-08-18 10:06:59 +010053};
54
55int mcp_driver_register(struct mcp_driver *);
56void mcp_driver_unregister(struct mcp_driver *);
57
58#define mcp_get_drvdata(mcp) dev_get_drvdata(&(mcp)->attached_device)
59#define mcp_set_drvdata(mcp,d) dev_set_drvdata(&(mcp)->attached_device, d)
60
Russell King2a7f51a2012-01-21 09:28:53 +000061static inline void *mcp_priv(struct mcp *mcp)
62{
63 return mcp + 1;
64}
Russell Kinga4e137a2005-08-18 10:06:59 +010065
66#endif