blob: 82def46e5ab14bffb50d8af1fc1cfb9eba027001 [file] [log] [blame]
Alex Eldere1e9dbd2014-10-01 21:54:11 -05001/*
2 * Greybus modules
3 *
4 * Copyright 2014 Google Inc.
5 *
6 * Released under the GPLv2 only.
7 */
8
9#ifndef __MODULE_H
10#define __MODULE_H
11
12/* Increase these values if needed */
13#define MAX_CPORTS_PER_MODULE 10
14#define MAX_STRINGS_PER_MODULE 10
15
16struct gb_module {
17 struct device dev;
18
Alex Elder8c12cde2014-10-01 21:54:12 -050019 struct list_head interfaces;
Alex Eldere1e9dbd2014-10-01 21:54:11 -050020 struct list_head links; /* greybus_host_device->modules */
21 u8 module_id; /* Physical location within the Endo */
22
Alex Elderb09c94a2014-10-01 21:54:16 -050023 /* Information taken from the manifest module descriptor */
24 u16 vendor;
25 u16 product;
26 u16 version;
Alex Elderb09c94a2014-10-01 21:54:16 -050027 char *vendor_string;
28 char *product_string;
Alex Elder63cc9322014-10-02 12:30:02 -050029 u64 unique_id;
Alex Elderb09c94a2014-10-01 21:54:16 -050030
Alex Eldere1e9dbd2014-10-01 21:54:11 -050031 struct greybus_host_device *hd;
32
Alex Eldere1e9dbd2014-10-01 21:54:11 -050033 struct gb_tty *gb_tty;
Alex Eldere1e9dbd2014-10-01 21:54:11 -050034};
35#define to_gb_module(d) container_of(d, struct gb_module, dev)
36
37static inline void
38gb_module_set_drvdata(struct gb_module *gmod, void *data)
39{
40 dev_set_drvdata(&gmod->dev, data);
41}
42
43static inline void *gb_module_get_drvdata(struct gb_module *gmod)
44{
45 return dev_get_drvdata(&gmod->dev);
46}
47
48const struct greybus_module_id *gb_module_match_id(struct gb_module *gmod,
49 const struct greybus_module_id *id);
50
51struct gb_module *gb_module_create(struct greybus_host_device *hd,
52 u8 module_id);
53void gb_module_destroy(struct gb_module *module);
54
Matt Porter6271b5b2014-10-21 22:43:29 -040055struct gb_module *gb_module_find(struct greybus_host_device *hd,
56 u8 module_id);
57
Alex Elder574341c2014-10-16 06:35:35 -050058void gb_module_interfaces_init(struct gb_module *gmod);
59
Alex Eldere1e9dbd2014-10-01 21:54:11 -050060#endif /* __MODULE_H */