#include "manifest.h"
#include "endo.h"
#include "svc.h"
+#include "firmware.h"
#include "module.h"
#include "control.h"
#include "interface.h"
.match_flags = GREYBUS_DEVICE_ID_MATCH_SERIAL, \
.serial_number = (s),
-/* XXX I couldn't get my Kconfig file to be noticed for out-of-tree build */
-#ifndef CONFIG_CPORT_ID_MAX
-#define CONFIG_CPORT_ID_MAX 128
-#endif /* !CONFIG_CPORT_ID_MAX */
-
-/* Maximum number of CPorts usable by a host device */
-/* XXX This should really be determined by the AP module manifest */
-#define CPORT_ID_MAX CONFIG_CPORT_ID_MAX
-#define CPORT_ID_BAD U16_MAX /* UniPro max id is 4095 */
+/* Maximum number of CPorts */
+#define CPORT_ID_MAX 4095 /* UniPro max id is 4095 */
+#define CPORT_ID_BAD U16_MAX
/* For SP1 hardware, we are going to "hardcode" each device to have all logical
* blocks in order to be able to address them as one unified "unit". Then
*/
struct greybus_host_device;
-struct svc_msg;
/* Greybus "Host driver" structure, needed by a host controller driver to be
* able to handle both SVC control as well as "real" greybus messages
struct greybus_host_driver {
size_t hd_priv_size;
+ void (*connection_create)(struct gb_connection *connection);
+ void (*connection_destroy)(struct gb_connection *connection);
int (*message_send)(struct greybus_host_device *hd, u16 dest_cport_id,
struct gb_message *message, gfp_t gfp_mask);
void (*message_cancel)(struct gb_message *message);
- int (*submit_svc)(struct svc_msg *svc_msg,
- struct greybus_host_device *hd);
};
struct greybus_host_device {
struct ida cport_id_map;
u8 device_id;
+ /* Number of CPorts supported by the UniPro IP */
+ size_t num_cports;
+
/* Host device buffer constraints */
size_t buffer_size_max;
struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *hd,
struct device *parent,
- size_t buffer_size_max);
+ size_t buffer_size_max,
+ size_t num_cports);
int greybus_endo_setup(struct greybus_host_device *hd, u16 endo_id,
u8 ap_intf_id);
void greybus_remove_hd(struct greybus_host_device *hd);
return dev->type == &greybus_connection_type;
}
-static inline bool cport_id_valid(u16 cport_id)
+static inline bool cport_id_valid(struct greybus_host_device *hd, u16 cport_id)
{
- return cport_id != CPORT_ID_BAD && cport_id <= CPORT_ID_MAX;
+ return cport_id != CPORT_ID_BAD && cport_id < hd->num_cports;
}
#endif /* __KERNEL__ */