summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2015-12-27 13:53:50 +0100
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2018-12-24 01:27:34 +0100
commita2cbd4ab6c2d3b2f7cf2fb1312ec4f08fe01d5dc (patch)
treeed326c7382f206cd38f0ef6cb63ce7dc2c49e09b
parent46c0a5fd2d406b74a7e97e914bd71365dd30ef47 (diff)
chipidea: make usb charger optional
The USB charger functionality depends on functions provided by CONFIG_POWER_SUPPLY but this dependency is not forced through Kconfig. Don't compile the functionality in when CONFIG_POWER_SUPPLY is not set. This fixes linker errors of not found symbols. power_supply_changed power_supply_register power_supply_unregister Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com> Signed-off-by: Stefan Agner <stefan.agner@toradex.com> (cherry picked from commit e23e2335dbc3ad604f65886b9b1373a586406b53)
-rw-r--r--drivers/usb/chipidea/ci_hdrc_imx.c14
-rw-r--r--drivers/usb/chipidea/usbmisc_imx.c12
2 files changed, 25 insertions, 1 deletions
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index 53f48cc2eeb5..00bb8d6caec1 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -130,6 +130,7 @@ struct ci_hdrc_imx_data {
struct pm_qos_request pm_qos_req;
};
+#ifdef CONFIG_POWER_SUPPLY
static char *imx_usb_charger_supplied_to[] = {
"imx_usb_charger",
};
@@ -139,6 +140,7 @@ static enum power_supply_property imx_usb_charger_power_props[] = {
POWER_SUPPLY_PROP_ONLINE, /* VBUS online */
POWER_SUPPLY_PROP_CURRENT_MAX, /* Maximum current in mA */
};
+#endif
/* Common functions shared by usbmisc drivers */
@@ -319,6 +321,7 @@ static int ci_hdrc_imx_notify_event(struct ci_hdrc *ci, unsigned event)
int ret = 0;
switch (event) {
+#ifdef CONFIG_POWER_SUPPLY
case CI_HDRC_CONTROLLER_VBUS_EVENT:
if (data->usbmisc_data && ci->vbus_active) {
if (data->imx_usb_charger_detection) {
@@ -339,6 +342,7 @@ static int ci_hdrc_imx_notify_event(struct ci_hdrc *ci, unsigned event)
return ret;
imx_usbmisc_charger_secondary_detection(data->usbmisc_data);
break;
+#endif
case CI_HDRC_IMX_HSIC_ACTIVE_EVENT:
if (!IS_ERR(data->pinctrl) &&
!IS_ERR(data->pinctrl_hsic_active)) {
@@ -378,6 +382,7 @@ static int ci_hdrc_imx_notify_event(struct ci_hdrc *ci, unsigned event)
return ret;
}
+#ifdef CONFIG_POWER_SUPPLY
static int imx_usb_charger_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
@@ -441,6 +446,7 @@ static int imx_usb_register_charger(struct usb_charger *charger,
return 0;
}
+#endif
static int ci_hdrc_imx_probe(struct platform_device *pdev)
{
@@ -575,6 +581,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
if (of_find_property(np, "imx-usb-charger-detection", NULL) &&
data->usbmisc_data) {
+#ifdef CONFIG_POWER_SUPPLY
data->imx_usb_charger_detection = true;
data->charger.dev = dev;
data->usbmisc_data->charger = &data->charger;
@@ -583,7 +590,12 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
if (ret && ret != -ENODEV)
goto disable_hsic_regulator;
if (!ret)
- dev_dbg(dev, "USB Charger is created\n");
+ dev_dbg(&pdev->dev,
+ "USB Charger is created\n");
+#else
+ dev_err(&pdev->dev,
+ "USB Charger requires CONFIG_POWER_SUPPLY\n");
+#endif
}
ret = imx_usbmisc_init(data->usbmisc_data);
diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
index b7d21b052c19..6ed020113926 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -609,6 +609,7 @@ static int usbmisc_imx7d_power_lost_check(struct imx_usbmisc_data *data)
/***************************************************************************/
/* imx usb charger detecton */
/***************************************************************************/
+#ifdef CONFIG_POWER_SUPPLY
static void usb_charger_is_present(struct usb_charger *charger, bool present)
{
if (present)
@@ -762,7 +763,9 @@ static int usbmisc_imx6sx_power_lost_check(struct imx_usbmisc_data *data)
else
return 0;
}
+#endif
+#ifdef CONFIG_POWER_SUPPLY
static void imx7_disable_charger_detector(struct imx_usbmisc_data *data)
{
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
@@ -919,6 +922,7 @@ int imx7d_charger_secondary_detection(struct imx_usbmisc_data *data)
return 0;
}
+#endif
static int usbmisc_term_select_override(struct imx_usbmisc_data *data,
bool enable, int val)
@@ -967,8 +971,10 @@ static const struct usbmisc_ops imx53_usbmisc_ops = {
static const struct usbmisc_ops imx6q_usbmisc_ops = {
.set_wakeup = usbmisc_imx6q_set_wakeup,
.init = usbmisc_imx6q_init,
+#ifdef CONFIG_POWER_SUPPLY
.charger_primary_detection = imx6_charger_primary_detection,
.charger_secondary_detection = imx6_charger_secondary_detection,
+#endif
.hsic_set_connect = usbmisc_imx6_hsic_set_connect,
.hsic_set_clk = usbmisc_imx6_hsic_set_clk,
};
@@ -980,9 +986,11 @@ static const struct usbmisc_ops vf610_usbmisc_ops = {
static const struct usbmisc_ops imx6sx_usbmisc_ops = {
.set_wakeup = usbmisc_imx6q_set_wakeup,
.init = usbmisc_imx6sx_init,
+#ifdef CONFIG_POWER_SUPPLY
.charger_primary_detection = imx6_charger_primary_detection,
.charger_secondary_detection = imx6_charger_secondary_detection,
.power_lost_check = usbmisc_imx6sx_power_lost_check,
+#endif
.hsic_set_connect = usbmisc_imx6_hsic_set_connect,
.hsic_set_clk = usbmisc_imx6_hsic_set_clk,
};
@@ -990,9 +998,11 @@ static const struct usbmisc_ops imx6sx_usbmisc_ops = {
static const struct usbmisc_ops imx7d_usbmisc_ops = {
.init = usbmisc_imx7d_init,
.set_wakeup = usbmisc_imx7d_set_wakeup,
+#ifdef CONFIG_POWER_SUPPLY
.power_lost_check = usbmisc_imx7d_power_lost_check,
.charger_primary_detection = imx7d_charger_primary_detection,
.charger_secondary_detection = imx7d_charger_secondary_detection,
+#endif
.term_select_override = usbmisc_term_select_override,
.hsic_set_connect = usbmisc_imx6_hsic_set_connect,
.hsic_set_clk = usbmisc_imx6_hsic_set_clk,
@@ -1048,6 +1058,7 @@ int imx_usbmisc_set_wakeup(struct imx_usbmisc_data *data, bool enabled)
}
EXPORT_SYMBOL_GPL(imx_usbmisc_set_wakeup);
+#ifdef CONFIG_POWER_SUPPLY
int imx_usbmisc_charger_detection(struct imx_usbmisc_data *data, bool connect)
{
struct imx_usbmisc *usbmisc;
@@ -1099,6 +1110,7 @@ int imx_usbmisc_charger_secondary_detection(struct imx_usbmisc_data *data)
return usbmisc->ops->charger_secondary_detection(data);
}
EXPORT_SYMBOL_GPL(imx_usbmisc_charger_secondary_detection);
+#endif
int imx_usbmisc_power_lost_check(struct imx_usbmisc_data *data)
{