Some power supplies such as batteries are connected via a bus such as i2c.
When we want to resume the battery we must resume the bus also, otherwise
it will not be possible to communicate with it.
Add a function which returns the device that a power supply is connected
on, to permit a caller to resume the bus also.
BUG=chrome-os-partner:10617
TEST=build and boot to kernel prompt on snow
Use charger-manager, with other changes, and see that in the
suspend_again() handler, the battery temperature can be read successfully.
This indicates that the i2c bus is working properly.
Change-Id: I1f19606861e0cb7f86621c2ad22415d7761cb060
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43012
Reviewed-by: Benson Leung <bleung@chromium.org>
}
#endif
+#ifdef CONFIG_PM
+struct device *sbs_to_i2c_dev(struct power_supply *psy)
+{
+ struct sbs_info *chip;
+
+ chip = container_of(psy, struct sbs_info, power_supply);
+ return &chip->client->adapter->dev;
+}
+#else
+#define sbs_to_i2c_dev NULL
+#endif
+
static int __devinit sbs_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
chip->ignore_changes = 1;
chip->last_state = POWER_SUPPLY_STATUS_UNKNOWN;
chip->power_supply.external_power_changed = sbs_external_power_changed;
+ chip->power_supply.to_bus_dev = sbs_to_i2c_dev;
pdata = sbs_of_populate_pdata(client);
enum power_supply_property psp);
void (*external_power_changed)(struct power_supply *psy);
void (*set_charged)(struct power_supply *psy);
+ /**
+ * @to_bus_dev - Get the device this power supply connects to
+ *
+ * This can be used in a suspend_again() handler to resume
+ * communications (e.g. attached i2c port) and put it back
+ * into suspend afterwards.
+ *
+ * @psy: Power supply
+ */
+ struct device *(*to_bus_dev)(struct power_supply *psy);
/* For APM emulation, think legacy userspace. */
int use_for_apm;