ath79/mikrotik: use routerbootpart partitions
[oweals/openwrt.git] / target / linux / layerscape / patches-5.4 / 820-usb-0003-usb-phy-show-USB-charger-type-for-user.patch
1 From 8eaa50485af15a4e1cc0c7c04f5ce3916e712ae1 Mon Sep 17 00:00:00 2001
2 From: Peter Chen <peter.chen@nxp.com>
3 Date: Wed, 6 Nov 2019 17:24:29 +0800
4 Subject: [PATCH] usb: phy: show USB charger type for user
5
6 Current USB charger framework only shows charger state for user, but the
7 user may also need charger type for further use, add support for it.
8
9 Signed-off-by: Peter Chen <peter.chen@nxp.com>
10 ---
11  drivers/usb/phy/phy.c | 13 ++++++++++++-
12  1 file changed, 12 insertions(+), 1 deletion(-)
13
14 --- a/drivers/usb/phy/phy.c
15 +++ b/drivers/usb/phy/phy.c
16 @@ -34,6 +34,14 @@ struct phy_devm {
17         struct notifier_block *nb;
18  };
19  
20 +static const char *const usb_chger_type[] = {
21 +       [UNKNOWN_TYPE]                  = "USB_CHARGER_UNKNOWN_TYPE",
22 +       [SDP_TYPE]                      = "USB_CHARGER_SDP_TYPE",
23 +       [CDP_TYPE]                      = "USB_CHARGER_CDP_TYPE",
24 +       [DCP_TYPE]                      = "USB_CHARGER_DCP_TYPE",
25 +       [ACA_TYPE]                      = "USB_CHARGER_ACA_TYPE",
26 +};
27 +
28  static struct usb_phy *__usb_find_phy(struct list_head *list,
29         enum usb_phy_type type)
30  {
31 @@ -98,7 +106,8 @@ static void usb_phy_notify_charger_work(
32  {
33         struct usb_phy *usb_phy = container_of(work, struct usb_phy, chg_work);
34         char uchger_state[50] = { 0 };
35 -       char *envp[] = { uchger_state, NULL };
36 +       char uchger_type[50] = { 0 };
37 +       char *envp[] = { uchger_state, uchger_type, NULL };
38         unsigned int min, max;
39  
40         switch (usb_phy->chg_state) {
41 @@ -122,6 +131,8 @@ static void usb_phy_notify_charger_work(
42                 return;
43         }
44  
45 +       snprintf(uchger_type, ARRAY_SIZE(uchger_type),
46 +                "USB_CHARGER_TYPE=%s", usb_chger_type[usb_phy->chg_type]);
47         kobject_uevent_env(&usb_phy->dev->kobj, KOBJ_CHANGE, envp);
48  }
49