Re: [PATCH v8 4/4] power: wm831x_power: Support USB charger current limit management

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 27 March 2016 at 16:22, Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
> On Thu, Mar 24, 2016 at 1:35 PM, Baolin Wang <baolin.wang@xxxxxxxxxx> wrote:
>> --- a/drivers/power/wm831x_power.c
>> +++ b/drivers/power/wm831x_power.c
>> @@ -13,6 +13,7 @@
>>  #include <linux/platform_device.h>
>>  #include <linux/power_supply.h>
>>  #include <linux/slab.h>
>> +#include <linux/usb/usb_charger.h>
>>
>>  #include <linux/mfd/wm831x/core.h>
>>  #include <linux/mfd/wm831x/auxadc.h>
>> @@ -31,6 +32,8 @@ struct wm831x_power {
>>         char usb_name[20];
>>         char battery_name[20];
>>         bool have_battery;
>> +       struct usb_charger *usb_charger;
>> +       struct notifier_block usb_notify;
>>  };
>>
>>  static int wm831x_power_check_online(struct wm831x *wm831x, int supply,
>> @@ -125,6 +128,43 @@ static enum power_supply_property wm831x_usb_props[] = {
>>         POWER_SUPPLY_PROP_VOLTAGE_NOW,
>>  };
>>
>> +/* In milliamps */
>> +static unsigned int wm831x_usb_limits[] = {
>
> const

OK.

>
>> +       0,
>> +       2,
>> +       100,
>> +       500,
>> +       900,
>> +       1500,
>> +       1800,
>> +       550,
>> +};
>> +
>> +static int wm831x_usb_limit_change(struct notifier_block *nb,
>> +                                  unsigned long limit, void *data)
>> +{
>> +       struct wm831x_power *wm831x_power = container_of(nb,
>> +                                                        struct wm831x_power,
>> +                                                        usb_notify);
>> +       int i, best;
>
> unsigned int

OK.

>
>> +
>> +       /* Find the highest supported limit */
>> +       best = 0;
>> +       for (i = 0; i < ARRAY_SIZE(wm831x_usb_limits); i++) {
>> +               if (limit >= wm831x_usb_limits[i] &&
>> +                   wm831x_usb_limits[best] < wm831x_usb_limits[i])
>> +                       best = i;
>> +       }
>> +
>> +       dev_dbg(wm831x_power->wm831x->dev,
>> +               "Limiting USB current to %dmA", wm831x_usb_limits[best]);
>
> %u

OK. Thanks for your comments.

>
> Gr{oetje,eeting}s,
>
>                         Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds



-- 
Baolin.wang
Best Regards
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux