@@ -91,6 +91,18 @@ static void isp1704_charger_set_power(struct isp1704_charger *isp, bool on)
}
/*
+ * Set charger current from isp1704 if a function for it
+ * has been provided with platform data.
+ */
+static void isp1704_charger_set_current(struct isp1704_charger *isp, int mA)
+{
+ struct isp1704_charger_data *board = isp->dev->platform_data;
+
+ if (board && board->set_current)
+ board->set_current(mA);
+}
+
+/*
* Determine is the charging port DCP (dedicated charger) or CDP (Host/HUB
* chargers).
*
@@ -257,6 +269,7 @@ static void isp1704_charger_work(struct work_struct *data)
if (isp1704_charger_detect_dcp(isp)) {
isp->psy.type = POWER_SUPPLY_TYPE_USB_DCP;
isp->current_max = 1800;
+ isp1704_charger_set_current(isp, 1800);
} else {
isp->psy.type = POWER_SUPPLY_TYPE_USB;
isp->current_max = 500;
@@ -277,6 +290,8 @@ static void isp1704_charger_work(struct work_struct *data)
if (isp->current_max > 100)
isp->psy.type = POWER_SUPPLY_TYPE_USB_CDP;
+
+ isp1704_charger_set_current(isp, isp->current_max);
}
break;
case USB_EVENT_NONE:
@@ -297,6 +312,7 @@ static void isp1704_charger_work(struct work_struct *data)
usb_gadget_disconnect(isp->phy->otg->gadget);
isp1704_charger_set_power(isp, 0);
+ isp1704_charger_set_current(isp, 0);
break;
default:
goto out;
@@ -24,6 +24,7 @@
struct isp1704_charger_data {
void (*set_power)(bool on);
+ void (*set_current)(int mA);
};
#endif
This patch add callback function set_current to platform data. Driver will call this function when isp1704 change current and board provided this callback funtion in platform data. This patch is needed for Nokia RX-51 to tell bq2415x charging chip about connected wallcharger events. Signed-off-by: Pali Rohár <pali.rohar@gmail.com> --- drivers/power/isp1704_charger.c | 16 ++++++++++++++++ include/linux/power/isp1704_charger.h | 1 + 2 files changed, 17 insertions(+)