// we will want to keep the battery stats in here as we will be getting
// updates from the SVC "on the fly" so we don't have to always go ask
// the battery for some information. Hopefully...
- struct gb_module *gmod;
+ struct gb_connection *connection;
+ u8 version_major;
+ u8 version_minor;
+
};
#define to_gb_battery(x) container_of(x, struct gb_battery, bat)
POWER_SUPPLY_PROP_VOLTAGE_NOW,
};
-int gb_battery_probe(struct gb_module *gmod,
- const struct greybus_module_id *id)
+int gb_battery_device_init(struct gb_connection *connection)
{
struct gb_battery *gb;
struct power_supply *b;
if (!gb)
return -ENOMEM;
+ gb->connection = connection; // FIXME refcount!
+
b = &gb->bat;
// FIXME - get a better (i.e. unique) name
// FIXME - anything else needs to be set?
b->num_properties = ARRAY_SIZE(battery_props),
b->get_property = get_property,
- retval = power_supply_register(&gmod->dev, b);
+ retval = power_supply_register(&connection->interface->gmod->dev, b);
if (retval) {
kfree(gb);
return retval;
}
- gmod->gb_battery = gb;
return 0;
}
switch (connection->protocol) {
case GREYBUS_PROTOCOL_I2C:
return gb_i2c_device_init(connection);
- case GREYBUS_PROTOCOL_CONTROL:
- case GREYBUS_PROTOCOL_AP:
case GREYBUS_PROTOCOL_GPIO:
return gb_gpio_controller_init(connection);
+ case GREYBUS_PROTOCOL_BATTERY:
+ return gb_battery_device_init(connection);
+ case GREYBUS_PROTOCOL_CONTROL:
+ case GREYBUS_PROTOCOL_AP:
case GREYBUS_PROTOCOL_UART:
case GREYBUS_PROTOCOL_HID:
case GREYBUS_PROTOCOL_VENDOR:
extern const struct attribute_group *greybus_module_groups[];
int gb_i2c_device_init(struct gb_connection *connection);
+int gb_battery_device_init(struct gb_connection *connection);
int gb_gpio_controller_init(struct gb_connection *connection);
int gb_tty_init(void);
GREYBUS_PROTOCOL_I2C = 0x03,
GREYBUS_PROTOCOL_UART = 0x04,
GREYBUS_PROTOCOL_HID = 0x05,
+ GREYBUS_PROTOCOL_BATTERY = 0x08,
/* ... */
GREYBUS_PROTOCOL_VENDOR = 0xff,
};
[GREYBUS_PROTOCOL_I2C] = gb_operation_recv_none,
[GREYBUS_PROTOCOL_UART] = NULL,
[GREYBUS_PROTOCOL_HID] = NULL,
+ [GREYBUS_PROTOCOL_BATTERY] = gb_operation_recv_none,
[GREYBUS_PROTOCOL_VENDOR] = NULL,
};