07 Sep, 2016

1 commit

  • After the change to use the gpio descriptor interface, we get a warning if
    -Wmaybe-uninitialized is added back to the build flags (it is currently
    disabled:

    drivers/power/supply/sbs-battery.c: In function 'sbs_probe':
    drivers/power/supply/sbs-battery.c:760:28: error: 'pdata' may be used uninitialized in this function [-Werror=maybe-uninitialized]

    The problem is that if neither the DT properties nor a platform_data
    pointer are provided, the chip->pdata pointer gets set to an uninitialized
    value.

    Looking at the code some more, I found that the sbs_of_populate_pdata
    function is more complex than necessary and has confusing calling
    conventions of possibly returning a valid pointer, a NULL pointer
    or an ERR_PTR pointer (in addition to the uninitialized pointer).

    To fix all of that, this gets rid of the chip->pdata pointer and
    simply moves the two integers into the sbs_info structure. This
    makes it much clearer from reading sbs_probe() what the precedence
    of the three possible values are (pdata, DT, hardcoded defaults)
    and completely avoids the #ifdef CONFIG_OF guards as
    of_property_read_u32() gets replaced with a compile-time stub
    when that is disabled, and returns an error if passed a NULL of_node
    pointer.

    Signed-off-by: Arnd Bergmann
    Fixes: 3b5dd3a49496 ("power: supply: sbs-battery: Use gpio_desc and sleeping calls for battery detect")
    Signed-off-by: Sebastian Reichel

    Arnd Bergmann
     

05 Sep, 2016

1 commit

  • This requests the status GPIO with initial input setup. It is required
    to read the GPIO status at probe time and thus correctly avoid sending
    I2C messages when AC is not plugged.

    When requesting the GPIO without initial input setup, it always reads 0
    which causes probe to fail as it assumes the charger is connected, sends
    I2C messages and fails.

    While at it, this switches the driver over to gpiod API.

    Signed-off-by: Paul Kocialkowski
    Signed-off-by: Sebastian Reichel

    Paul Kocialkowski
     

01 Sep, 2016

3 commits


31 Aug, 2016

8 commits


29 Aug, 2016

1 commit

  • When the charger is missing (disconnected), it is safe to assume that
    the charger chip is no charging.

    This is especially relevant when a status GPIO is present and the
    charger is getting disconnected. bq24735_charger_is_charging will be
    triggered due to the interrupt then, it will attempt to read whether it
    is charging through i2c, which will fail as the charger is disconnected.

    This also fixes that specific issue.

    Signed-off-by: Paul Kocialkowski
    Signed-off-by: Sebastian Reichel

    Paul Kocialkowski
     

17 Aug, 2016

1 commit


16 Aug, 2016

21 commits

  • Power Supply Fixes for 4.8 cycle

    Sebastian Reichel
     
  • alloc_ordered_workqueue() with WQ_MEM_RECLAIM set replaces
    deprecated create_singlethread_workqueue(). This is the identity
    conversion.

    The workqueue "monitor_wqueue" is used to monitor the battery
    status. It has been identity converted.

    It queues multiple work items viz &di->monitor_work,
    &di->set_charged_work, which require execution ordering.
    Hence, alloc_workqueue has been used to replace the
    deprecated create_singlethread_workqueue instance.

    WQ_MEM_RECLAIM flag has been set to ensure forward progress under
    memory pressure.

    Signed-off-by: Bhaktipriya Shridhar
    Signed-off-by: Sebastian Reichel

    Bhaktipriya Shridhar
     
  • alloc_ordered_workqueue() with WQ_MEM_RECLAIM set replaces
    deprecated create_singlethread_workqueue(). This is the identity
    conversion.

    The workqueue "fg_wq" is used for running the FG algorithm periodically.
    It has been identity converted.

    It has multiple work items viz fg_periodic_work, fg_low_bat_work,
    fg_reinit_work, fg_work, fg_acc_cur_work and fg_check_hw_failure_work,
    which require execution ordering. Hence, a dedicated ordered workqueue
    has been used here.

    The WQ_MEM_RECLAIM flag has been set to guarantee forward progress under
    memory pressure.

    Signed-off-by: Bhaktipriya Shridhar
    Signed-off-by: Sebastian Reichel

    Bhaktipriya Shridhar
     
  • The workqueue "wq" is used for handling battery related tasks.

    It has a single work item viz &mb->update and hence it doesn't require
    execution ordering. Hence, alloc_workqueue has been used to replace the
    deprecated create_singlethread_workqueue instance.

    The WQ_MEM_RECLAIM flag has been set to ensure forward progress under
    memory pressure.

    Since there is a single work item, explicit concurrency
    limit is unnecessary here.

    Signed-off-by: Bhaktipriya Shridhar
    Signed-off-by: Sebastian Reichel

    Bhaktipriya Shridhar
     
  • alloc_ordered_workqueue() with WQ_MEM_RECLAIM set replaces
    deprecated create_singlethread_workqueue(). This is the identity
    conversion.

    The workqueue "charger_wq" is used for the IRQs and checking HW state of
    the charger. It has been identity converted.

    It has multiple work items viz usb_charger_attached_work, kick_wd_work,
    check_vbat_work, check_hw_failure_work, usb_charger_attached_work,
    ac_work, ac_charger_attached_work, attach_work and check_usbchgnotok_work,
    which require execution ordering. Hence, a dedicated ordered workqueue
    has been used here.

    The WQ_MEM_RECLAIM flag has also been set to ensure
    forward progress under memory pressure.

    Signed-off-by: Bhaktipriya Shridhar
    Signed-off-by: Sebastian Reichel

    Bhaktipriya Shridhar
     
  • The workqueue "monitor_wqueue" is used to monitor the PMIC battery status.
    It queues a single work item (pbi->monitor_battery) and hence doesn't
    require ordering. Hence, alloc_workqueue has been used to replace the
    deprecated create_singlethread_workqueue instance.

    Since PMIC battery status needs to be monitored for any change, the
    WQ_MEM_RECLAIM flag has been set to ensure forward progress under memory
    pressure.

    Since there is a single work item, explicit concurrency
    limit is unnecessary here.

    Signed-off-by: Bhaktipriya Shridhar
    Signed-off-by: Sebastian Reichel

    Bhaktipriya Shridhar
     
  • alloc_ordered_workqueue() with WQ_MEM_RECLAIM set replaces
    deprecated create_singlethread_workqueue(). This is the identity
    conversion.

    The workqueue "charger_wq" is used for running all the charger related
    tasks. This involves charger detection, checking for HW failure and HW
    status. This workqueue has been identity converted.

    It queues multiple workitems viz &pm2->check_main_thermal_prot_work,
    &pm2->check_hw_failure_work, &pm2->ac_work. Hence, the deprecated
    create_singlethread_workqueue() instance has been replaced with a
    dedicated ordered workqueue.

    The WQ_MEM_RECLAIM flag has been set to ensure forward progress under
    memory pressure.

    Signed-off-by: Bhaktipriya Shridhar
    Signed-off-by: Sebastian Reichel

    Bhaktipriya Shridhar
     
  • The workqueue "btemp_wq" is used for measuring the temperature
    periodically. It queues a single workitem (btemp_periodic_work) and
    hence doesn't require ordering. Thus, the deprecated
    create_singlethread_workqueue() instance has been replaced with
    alloc_workqueue().

    The WQ_MEM_RECLAIM flag has been set to ensure forward progress under
    memory pressure.

    Since there is a single work item, explicit concurrency
    limit is unnecessary here.

    Signed-off-by: Bhaktipriya Shridhar
    Signed-off-by: Sebastian Reichel

    Bhaktipriya Shridhar
     
  • alloc_ordered_workqueue() with WQ_MEM_RECLAIM set replaces
    deprecated create_singlethread_workqueue(). This is the identity
    conversion.

    The workqueue "chargalg_wq" is used for running the charging algorithm.
    It has multiple workitems viz &di->chargalg_periodic_work,
    &di->chargalg_wd_work, &di->chargalg_work per abx500_chargalg, which
    require ordering. It has been identity converted.

    Also, WQ_MEM_RECLAIM has been set to ensure forward progress under
    memory pressure.

    Signed-off-by: Bhaktipriya Shridhar
    Signed-off-by: Sebastian Reichel

    Bhaktipriya Shridhar
     
  • Remove duplicated include.

    Signed-off-by: Wei Yongjun
    Acked-by: Chen-Yu Tsai
    Signed-off-by: Sebastian Reichel

    Wei Yongjun
     
  • Remove duplicated include.

    Signed-off-by: Wei Yongjun
    Acked-by: Chen-Yu Tsai
    Signed-off-by: Sebastian Reichel

    Wei Yongjun
     
  • Remove .owner field if calls are used which set it automatically.

    Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

    Signed-off-by: Wei Yongjun
    Signed-off-by: Sebastian Reichel

    Wei Yongjun
     
  • Use the managed resource version of reboot_mode_register().

    Signed-off-by: Bjorn Andersson
    Tested-by: John Stultz
    Signed-off-by: Sebastian Reichel

    Bjorn Andersson
     
  • Provide managed resource version of reboot_mode_register() and
    reboot_mode_unregister() to simplify implementations.

    Signed-off-by: Bjorn Andersson
    Tested-by: John Stultz
    Signed-off-by: Sebastian Reichel

    Bjorn Andersson
     
  • Battery capacity level is a standard feature of sbs battery
    That can be used to tell what the remainig battery capacity is, and
    can tell if the battery has not been calibrated/initialized, which makes
    the capacity and charging/discharging percentages invalid.

    Signed-off-by: Joshua Clayton
    Signed-off-by: Sebastian Reichel

    Joshua Clayton
     
  • Add missing platform_set_drvdata() in tps65217_charger_probe(), otherwise
    calling platform_get_drvdata() in remove returns NULL.

    This is detected by Coccinelle semantic patch.

    Fixes: 3636859b280c ("power_supply: Add support for tps65217-charger")
    Signed-off-by: Wei Yongjun
    Signed-off-by: Sebastian Reichel

    Wei Yongjun
     
  • Use devm_power_supply_register instead of power_supply_register.
    Remove call to power_supply_unregister.

    Signed-off-by: Phil Reid
    Signed-off-by: Sebastian Reichel

    Phil Reid
     
  • Currently the battery detect gpio can not be used with a chained interrupt
    controller that requires threaded irq handlers. Use threaded irq instead.
    In addition this was not going to be working at present because
    chip->power_supply is assigned after the request irq call.

    Signed-off-by: Phil Reid
    Signed-off-by: Sebastian Reichel

    Phil Reid
     
  • Use devm_kzalloc to allow memory to be freed automatically on
    driver probe failure or removal.

    Signed-off-by: Phil Reid
    Signed-off-by: Sebastian Reichel

    Phil Reid
     
  • The bq27000 and bq27010 have a single byte FLAGS register.
    Other gauges have 16 bit FLAGS registers.

    For reading the FLAGS register it is sufficient to read the single
    register instead of reading RSOC at the next higher address as
    well and then ignore the high byte.

    This does not change functionality but optimizes i2c and hdq
    traffic.

    Signed-off-by: H. Nikolaus Schaller
    Acked-by: Pali Rohár
    Acked-by: Andrew F. Davis
    Signed-off-by: Sebastian Reichel

    H. Nikolaus Schaller
     
  • Make use of IRQ resources defined in tps65217 mfd code. If they are valid
    we use them instead separate poll task, in order to define AC power state.

    Signed-off-by: Marcin Niestroj
    Signed-off-by: Sebastian Reichel

    Marcin Niestroj
     

13 Aug, 2016

3 commits

  • Free memory mapping, if probe is not successful.

    Fixes: 4a9b37371822 ("power: reset: move hisilicon reboot code")
    Signed-off-by: Arvind Yadav
    Signed-off-by: Sebastian Reichel

    Arvind Yadav
     
  • commit 4fcd504edbf7 ("power: reset: add reboot mode driver") uses api from
    syscon, and syscon uses ioremap/iounmap which depends on HAS_IOMEM, so
    let's depend on MFD_SYSCON instead of selecting it directly to avoid the
    um-allyesconfig like build error on archs that without iomem:

    drivers/mfd/syscon.c: In function 'of_syscon_register':
    drivers/mfd/syscon.c:67:9: error: implicit declaration of function 'ioremap' [-Werror=implicit-function-declaration]
    base = ioremap(res.start, resource_size(&res));
    ^
    drivers/mfd/syscon.c:67:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
    base = ioremap(res.start, resource_size(&res));
    ^
    drivers/mfd/syscon.c:109:2: error: implicit declaration of function 'iounmap' [-Werror=implicit-function-declaration]
    iounmap(base);
    ^

    Reported-by: Kbuild test robot
    Fixes: 4fcd504edbf7("power: reset: add reboot mode driver")
    Signed-off-by: Andy Yan
    Reviewed-by: Krzysztof Kozlowski
    Signed-off-by: Sebastian Reichel

    Andy Yan
     
  • The device's model download function returns the model data as
    an array of u32s, which is later compared to the reference
    model data. However, since the latter is an array of u16s,
    the comparison does not happen correctly, and model verification
    fails. This in turn breaks the POR initialization sequence.

    Fixes: 39e7213edc4f3 ("max17042_battery: Support regmap to access device's registers")
    Reported-by: Dan Carpenter
    Signed-off-by: Sven Van Asbroeck
    Reviewed-by: Krzysztof Kozlowski
    Signed-off-by: Sebastian Reichel

    Sven Van Asbroeck
     

11 Aug, 2016

1 commit

  • Currently the power supply device tree documentation is spread
    in .../bindings/power_supply and .../bindings/power. This
    unifies the files for chargers and battery fuel gauges in
    .../bindings/power/supply and the ones for system reset/shutdown
    in .../bindings/power/reset (same structure as used for the
    drivers itself).

    Signed-off-by: Sebastian Reichel

    Sebastian Reichel