Russell King | a4e137a | 2005-08-18 10:06:59 +0100 | [diff] [blame] | 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 | |
Andrea Adami | 62480dc | 2013-07-21 01:07:42 +0200 | [diff] [blame] | 13 | #include <linux/device.h> |
| 14 | |
Russell King | a4e137a | 2005-08-18 10:06:59 +0100 | [diff] [blame] | 15 | struct mcp_ops; |
| 16 | |
| 17 | struct 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 King | a4e137a | 2005-08-18 10:06:59 +0100 | [diff] [blame] | 24 | struct device attached_device; |
Russell King | a4e137a | 2005-08-18 10:06:59 +0100 | [diff] [blame] | 25 | }; |
| 26 | |
| 27 | struct 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 | |
| 36 | void mcp_set_telecom_divisor(struct mcp *, unsigned int); |
| 37 | void mcp_set_audio_divisor(struct mcp *, unsigned int); |
| 38 | void mcp_reg_write(struct mcp *, unsigned int, unsigned int); |
| 39 | unsigned int mcp_reg_read(struct mcp *, unsigned int); |
| 40 | void mcp_enable(struct mcp *); |
| 41 | void mcp_disable(struct mcp *); |
| 42 | #define mcp_get_sclk_rate(mcp) ((mcp)->sclk_rate) |
| 43 | |
| 44 | struct mcp *mcp_host_alloc(struct device *, size_t); |
Russell King | abe0608 | 2012-01-20 22:13:52 +0000 | [diff] [blame] | 45 | int mcp_host_add(struct mcp *, void *); |
Russell King | 30816ac | 2012-01-20 22:51:07 +0000 | [diff] [blame] | 46 | void mcp_host_del(struct mcp *); |
| 47 | void mcp_host_free(struct mcp *); |
Russell King | a4e137a | 2005-08-18 10:06:59 +0100 | [diff] [blame] | 48 | |
| 49 | struct mcp_driver { |
| 50 | struct device_driver drv; |
| 51 | int (*probe)(struct mcp *); |
| 52 | void (*remove)(struct mcp *); |
Russell King | a4e137a | 2005-08-18 10:06:59 +0100 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | int mcp_driver_register(struct mcp_driver *); |
| 56 | void 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 King | 2a7f51a | 2012-01-21 09:28:53 +0000 | [diff] [blame] | 61 | static inline void *mcp_priv(struct mcp *mcp) |
| 62 | { |
| 63 | return mcp + 1; |
| 64 | } |
Russell King | a4e137a | 2005-08-18 10:06:59 +0100 | [diff] [blame] | 65 | |
| 66 | #endif |