1
0
Fork 0
Commit Graph

721756 Commits (redonkable)

Author SHA1 Message Date
Shawn Guo 608c0894ef max77818-charger: improve max77818_charger_set_enable() call
It improves max77818_charger_set_enable() function call and usage in
the following aspects.

- Print MODE value to be set with dev_info().
- Add error messages for possible failures, so that we do not have to
  check return for every single calling.
- Always set MODE_OTG_BUCK_BOOST as long as we set enabling for OTG
  mode, because we do not want implicit disabling but explicit disabling
  by calling max77818_charger_set_enable(0).
- When we set charger_mode property, we should enable or disable charger
  according to charger availability, rather than always disabling.
- Change dev_info() to dev_dbg() in max77818_do_irq(), as we are already
  printing MODE value, which is more important.
- Ignore interrupt in OTG mode, as we do not want to actively manage
  charger on/off for OTG mode, but only when charger_mode property is
  set.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:41 +02:00
Shawn Guo 16eee8f15e max77818-charger: drop 'present' from struct max77818_charger
The field 'present' is only used once in max77818_charger_update()
function.  It doesn't really need to be defined in struct
max77818_charger.  Let's drop it.  In the meantime, move around the
code a little bit and save the xxx_UNKNOWN assignments, as they have
been done just above.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:41 +02:00
Shawn Guo 984cf1cf5e max77818-charger: fix UVLO charging check
Charging in FASTCHARGE_CC/CV could be because of that the other charger
rather than the one being checked is present.  So we need to add one
more condition to ensure the other charger is not present.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:41 +02:00
Shawn Guo 8ee53f4baf max77818-charger: fix dtls[] data type
The dtls[] data type should be u8, so that regmap_buck_read() can read
correct DTLS_00 ~ DTLS02 values into dtls[3].

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:41 +02:00
Shawn Guo d9ac174917 max77818-charger: drop max77818_charger_init_dev and max77818_charger_exit_dev
These two functions now only enable/disable charger and are called by
max77818_do_irq().  Let's simplify the code a little bit by drop the
functions and call max77818_charger_set_enable() from max77818_do_irq()
directly.

While at it, flip the order of dev_info() message output and
max77818_charger_set_enable() call, as it's more natural to print the
event message and then take action on the event.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:41 +02:00
Shawn Guo 2d50391fec max77818-charger: drop max77818_charger_set_charge_current() function
As charge current can not be set by .set_property hook any more, the
only place we need to set charge current is from max77818_charger_initialize().
So let's drop max77818_charger_set_charge_current() function and write
register directly in max77818_charger_initialize().

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:41 +02:00
Shawn Guo 5e8c4d9508 max77818-charger: report online per charging state
There could be situation where charger is present but it's not charging,
like charger is in timer fault, suspend, input invalid, junction
temperature (see register DETAILS_01, bits CHG_DTLS for details).
As battery driver reports its charging status by looking at online
property of charger device, this causes confusion that charger reports
Not Charging while in the meantime battery reports Charging status.

It's more accurate to report charger online status by looking at
CHARGING state, so that charger and battery stay consistent on charging
status.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:41 +02:00
Shawn Guo 072d94ccf2 max77818-charger: change MODE_OTG_BUCK_BOOST to 0x0F
In OTG supply mode, we should allow WCIN to power system and charge
battery.  So mode 0x0F should be better than 0x0E.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:41 +02:00
Shawn Guo b0f287847e dts/zero-sugar: update charger parameters
It updates charger parameters per zero-sugar and battery pack
characteristics.  Among of these, input_current_limit_chgin and
input_current_limit_wcin are still in discussion and may be updated
later.  But input_current_limit_chgin shouldn't exceed fast_charge_current
so much, so let's match it with fast_charge_current for now.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:41 +02:00
Shawn Guo 7417accbec max77818-charger: update default settings to match hardware reset ones
In case there is no corresponding properties found in device tree, the
charger settings should be using values coming out of hardware reset,
which are most sensible ones.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:40 +02:00
Shawn Guo 8ac34b3f4d max77818-charger: make current properties non-writeable
The fast charge current and input current limit property shouldn't be
changed by user space.  Let's make them non-writeable.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:40 +02:00
Shawn Guo 16f244e726 max77818-charger: enable low battery prequalification support
It enables Low Battery Prequalification Mode support for charger.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:40 +02:00
Lars Ivar Miljeteig da07c03e61 zero-sugar config: Turn off evbug and brcm debug 2020-10-08 01:38:40 +02:00
Shawn Guo 77bb1a30e6 regulator: bd7181x: skip DVS buck setup if it's not enabled
The DVS buck setup should only be done in case that i2c_dvs_enable is
true.  Otherwise, we should skip it to avoid the following noisy
messages.

  bd7181x-pmic bd7181x-pmic: Buck0: DVS High-Low[0 - 0].
  bd7181x-pmic bd7181x-pmic: bd7181x_buck12_dvs_init(): not found selector for voltage [0]
  bd7181x-pmic bd7181x-pmic: bd7181x_buck12_dvs_init(): not found selector for voltage [0]

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:40 +02:00
Shawn Guo 025677441b dts/zero-sugar: remove unreasonable charger settings
We do not really want to disable fast-charge and top-off timer, as the
former prevents charger from staying in fast-charge stage for too long,
and the latter triggers the entering to top-off stage.  So before we
get best settings for our battery pack from vendor, let's drop the
settings from device tree and let driver use the default.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:40 +02:00
Shawn Guo 5d28b95c80 battery: improve the comment in max77818_resume()
Improve the comment on max77818_set_soc_threshold() call in
max77818_resume(), to make it clear why we need to reprogram SOC
threshold when we are back from suspend/sleep state.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:40 +02:00
Shawn Guo 1a0fcd0b46 zero-sugar config: build in max77818 drivers
The max77818 charger, batter and regulator drivers are working.  Let's
build them in by default.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:40 +02:00
Shawn Guo 06b26361ca ARM: dts: zero-sugar: update max77818 related devices
It mixes quite a few max77818 related changes:

- Update fuelgauge device node with all those parameters required by
  max77818-fuelgauge driver for initialization.
- SAFEOUT1 regulator shouldn't be boot-on and always-on. Instead, it
  supplies OTG1 VBUS which can be turn on/off as needed by USB driver.
  As a result, reg_usb_otg1_vbus can be dropped.
- Drop buggy "restart_threshold" property from charger node and let
  driver use default setting.
- Add pinctrl for GPIO6_22 which is used as max77818 interrupt line.
- Drop "max77818,int-gpio" which is not needed.
- Drop "okay" status which is only needed to flip device status from
  "disabled" from "okay".
- Fix coding style and indentation.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:40 +02:00
Shawn Guo 49eea8db6c mfd: max77818: remove unused headers
With max77818 mfd, charger, battery and regulator drivers being
cleaned up, these headers are now unneeded.  Remove them.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:40 +02:00
Shawn Guo 585744b043 mfd: clean up max77818 driver code
- Fix kernel WARNING below, which is caused by irq_set_status_flags()
  with argument IRQ_NOAUTOEN and enable_irq().
  WARNING: CPU: 1 PID: 1 at kernel/irq/manage.c:1390 __setup_irq+0x6d0/0x71c
- Improve coding style of the driver to make it a classic Linux style
  driver.
- Clean up unused and unnecessary codes, like IO accessors, IRQ helpers,
  as sub-device driver can handle these on their own needs.
- Drop unnecessary mutex locking.
- Save functions max77818_pmic_irq_int(), max77818_pmic_setup() and
  max77818_destroy() by putting related code into .probe/.remove to
  simplify calling sequence.
- Drop max77818_pmic_get_platdata() since we do not need to parse
  "max77818,int-gpio" property to get IRQ number on our (recent) kernel
  version.
- Add .of_compatible field into max77818_devices[], so that sub-device
  driver doesn't need to find and attach their of_node.
- Use module_i2c_driver() to save max77818_init() and max77818_exit().
- Clean up include/linux/mfd/max77818/max77818.h to drop unused stuff.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:40 +02:00
Shawn Guo 0b59a199ad regulator: clean up max77818 reglator code
The regulator driver is much overloaded on our (recent) kernel version.
Let's clean up the code only needed for old version kernel, and also
remove the code parsing regulator init data from device tree, as
regulator core code is able to handle it, as long as we pass required
info via .of_match and .regulators_node in struct regulator_desc.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:40 +02:00
Shawn Guo bcdd832781 power: supply: clean up max77818 charger driver
Starting with the task to have a thorough review on the driver, I ended
up with fixing a couple of issues and cleaning up the code quite a lot.

- The termination_time is written to the wrong register. It should be
  CNFG_03 instead of CNFG_09.
- A reasonable default topoff_timer should be 30 minutes according to
  the reset value in data sheet.
- Fix broken interrupt code and CHGIN/WCIN insert/remove event can now
  be triggered.
- Remove those verbose debugging message output.
- Improve coding style of the driver to make it a classic Linux style
  driver.
- Rather than calling helpers provided max77818 mfd driver, call into
  regmap functions directly, as those helpers are not so helpful, and
  we may want to drop them from max77818 mfd driver later.
- Drop max77818_charger_pm_ops as the functions do nothing there.
- Use module_platform_driver() to save some code.

There are quite many function shifting and code tweaking with the
cleanup, which makes the reviewing code a lot harder (sorry about that).
So it might be easier to review the driver file rather than diff.  At
end of the day, the commit shouldn't introduce any regression but only
fix issues and enable interrupt support.

But there are still a few things worth discussion and possibly further
works.

- The driver currently allows user to change charger current setting.
  Should we really allow this?  I quote the following from max77818
  data sheet:

  "Maxim recommends that CHG_CC be set to the maximum acceptable charge
   rate for your battery – there is typically no need to actively adjust
   the CHG_CC setting based on the capabilities of the source at CHGIN,
   system load, or thermal limitations of the PCB"

- MAX77818 data sheet stats that for a particular battery/system, the
  following parameters should be set properly.

  Determine the following registers bit settings by considering the
  characteristics of the battery:

  . Charger Restart Threshold - CHG_RSTRT
    Default (reset) is 150mV below CHG_CV_PRM (0x01), and we set it
    3400mV, which is wrong (I'm fixing it).

  . Fast-Charge Timer (tFC) - FCHGTIME
    Default is 4 hours (0x01), and we set it disabled (0x00). Is this
    really what we want?

  . Fast-Charge Current - CHG_CC
    Default is 450mA (0x09), and we set it 2800mA (0x38).

  . Top-Off Time - TO_TIME
    Default is 30 minutes, and we set it 0 minutes (0x00). Is this
    really what we want?  I'm not even sure what 0x00 means here.

  . Top-Off Current - TO_ITH
    Default is 150mA (0x01), we set it 200mA (0x04).

  . Battery Regulation Voltage - CHG_CV_PRM
    Default is 4.2V (0x16), and we set it 4.3V (0x1A).

  Determine the following register bit settings by considering the
  characteristics of the system:

  . Low Battery Prequalification Enable: PQEN
    Default is disabled, we use default.

  . Minimum System Regulation Voltage: MINVSYS
    Default is 3.6V (0x02), and we set it 3.4V (0x00).

  . Junction Temperature Thermal Regulation Loop Setpoint: REGTEMP
    Default is 115C (0x02), and we use default.

- Do we need to enable watchdog timer?

- Do we need to detect and handle over-current condition by setting
  bit DISIBS in CNFG_00 to force MBATT-SYS FET off?

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:40 +02:00
Shawn Guo 9a508cfbbf power: supply: add max77818 battery driver
The max77818 battery block is simillar to max17042_battery, so we choose
to create max77818_battery by reusing majority of max17042_battery
driver code.

The max77818_battery reuses header max17042_battery.h directly and adds
max77818 specific defines in there.  But we do not reuse max17042_battery.c
directly, because it supports I2C device probing while we need platform
device probing.  Also the startup sequence and initialization is quite
different between max17042 and max77818. So we end up creating a new
max77818_battery driver with max77818 specific custom parameter parsing
from DT and startup sequence implementation.  The majority of
.get_property/.set_property code are copied from max17042 driver, and
we support two more properties, TIME_TO_EMPTY_NOW and TIME_TO_FULL_NOW,
with max77818 driver though.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:39 +02:00
Shawn Guo 4b7d7344ce power: supply: remove max77818_battery driver
The driver is buggy and not functional at all.  Let's remove it and
start over again.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:39 +02:00
Lars Ivar Miljeteig 9cd386c0a9 zero-sugar config: Remove unused HDMI driver 2020-10-08 01:38:39 +02:00
Lars Ivar Miljeteig 7f499cfd7e zero-sugar config: Remove unused graphics devices
Get ridd of /dev/fb1 and all its problems
This removes unused graphics drivers.
It also removes the overlay support
2020-10-08 01:38:39 +02:00
Lars Ivar Miljeteig f8351fdd9d wacom_i2c: Clean-up logging, whitespace, deadcode
Removed SBA printk messages
Removed deadcode for test LED etc
Cleaned up whitespace (tabs, not spaces in kernel)
2020-10-08 01:38:39 +02:00
Lars Ivar Miljeteig 67720f68e0 zero-sugar dts: Activate prevent-frying-pan mode 2020-10-08 01:38:39 +02:00
Lars Ivar Miljeteig dbc32384db ARM: fbdev-mxsfb: Add property to save display
Add prevent-frying-pan property in device tree
to prevent the pan function from looping bad
data to the display. Without this fix, a SW
crash can potentially fry the eInk display.

This is only relevant for the zero-sugar
plattform by reMarkable AS.
2020-10-08 01:38:39 +02:00
Thomas Ingebretsen 85ff106cfb Switch to zero frame after each pan to avoid pushing same frame multiple times unintentionally. 2020-10-08 01:38:34 +02:00
Shawn Guo 3f72117bf5 ARM: dts: zero-sugar: drop reset-gpio and enable-gpio from digitizer
The reset-gpio and enable-gpio are not used/supported by digitizer
driver right now.  Let's drop them.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:34 +02:00
Shawn Guo 8fc85322fb input: wacom_i2c: drop reset sequence on GPIO
The reset sequence via GPIO makes digitizer non-functional. This was not
an issue when we have GPIO1_0 pad configured as WDOG function, because
the reset sequence setting on the GPIO doesn't take any effect.  But now
pad configuration is gone and the pad works in GPIO mode by default, so
the reset sequence is taking effect.  Let drop this problematic reset
and get digitizer back to work.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:34 +02:00
Lars Ivar Miljeteig bbc4326e71 zero-sugar config: Enable rfkill 2020-10-08 01:38:34 +02:00
Lars Ivar Miljeteig cbc198f3b0 zero-sugar config: Attempt at minimal config
Removed CAN, bluetooth, SATA
Removed some PMICs: MAX17135, PFUZE100, PF1550, MC13xxx
Removed video support (webcams etc)
Removed console output to framebuffer
Removed DRM framebuffer support
2020-10-08 01:38:33 +02:00
Shawn Guo b12dc7e3c3 ARM: dts: zero-sugar: clean up bd7181x device
Those buck1 dvs properties and gpo node are not used by us, and those
regulator-virtuals are only for testing and unneeded here.  Let's clean
them up.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:33 +02:00
Shawn Guo 14d7057847 ARM: dts: zero-sugar: fix supply property for cpu0
We use CONFIG_CPUFREQ_DT driver on imx7d.  The driver looks for
regulator using 'cpu-supply' property rather than 'arm-supply'.  Let's
fix it so that cpufreq-dt driver can actually scale voltage along with
frequency.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:33 +02:00
Shawn Guo 72699ab595 ARM: zero-sugar_defconfig: disable unused BD7181X device drivers
Right now, only BD7181X PMIC driver is used.  Charger, RTC and GPIO are
not used.  Let's disable them for now, and re-enable them with proper
testing when needed.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:33 +02:00
Shawn Guo 172e44dafc regulator: bd7181x: drop unneeded register initialization
The initial register settings on PWRCTRL, GPO and CHG_SET1 are not
really necessary.

1. RESTARTEN is the mask of Bit0, which is for ROHM factory only in
   PWRCTRL.
2. We do not use GPIO of BD7181X so far, and there is no need for
   initial setting.
3. We do not use BD7181X charger but a separate charger MAX77818, so
   it shouldn't be enabled at all.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:33 +02:00
Shawn Guo 2c90ce8703 regulator: bd7181x: fix section mismatch warning
There is a section mismatch warning seen at the kernel image link stage.

  LD      vmlinux.o
  MODPOST vmlinux.o
WARNING: modpost: Found 1 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'

Build kernel with CONFIG_DEBUG_SECTION_MISMATCH=y, and turns out the
warning comes from bd7181x regulator driver.

WARNING: vmlinux.o(.data+0x1fd3c): Section mismatch in reference from
the variable bd7181x_driver to the function .init.text:bd7181x_probe()
The variable bd7181x_driver references
the function __init bd7181x_probe()

Fix it by dropping __init and __exit annotation which shouldn't be
there.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:33 +02:00
Steinar Bakkemo 5f9fb3c5d4 max77818-charger: add support for charger_mode/other cleanup 2020-10-08 01:38:33 +02:00
Steinar Bakkemo ccb451fa03 power-supply: add POWER_SUPPLY_PROP_CHARGER_MODE
Add new charger_mode sysfs property to standard power supply sysfs props.
2020-10-08 01:38:33 +02:00
Steinar Bakkemo 9e65cd2d73 zero-sugar wifi-cal dts: re-enable 100/200 MHz operation (SDIO bus freq)
Re-introduce 100/200MHz SD-interface options for wifi
(after fixing antenna connector issue).

Add zero-sugar-wifi-cal.dts to Makefile
2020-10-08 01:38:30 +02:00
Shawn Guo 31bb7360af ARM: dts: zero-sugar: enable WDOG1 for reboot support
Enable WDOG1 which will use WDOG_B signal to do a cold reset on external
PMIC through ENET1_COL pad.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 01:38:30 +02:00
Steinar Bakkemo 15f1d674f5 max77818-charger: add support for setting charger mode (charging/OTG) 2020-10-08 01:38:30 +02:00
Steinar Bakkemo 5bee878491 power-supply: add POWER_SUPPLY_PROP_CHARGER_MODE 2020-10-08 01:38:30 +02:00
Steinar Bakkemo dc357d2b8c zero-sugar dts: (max77818) fix max77818 int-gpio definition 2020-10-08 01:38:30 +02:00
Steinar Bakkemo 41e3f9a651 zero-sugar config: add max77818 FG/charger drivers to defconfig 2020-10-08 01:38:30 +02:00
Steinar Bakkemo 0b65333af4 max77818: fix power supply reg. issue causing kernal panic/add sep. max cur. adj
Extract powersupply config to static data structure.
Add support for setting max current separately for chgin/wcin.
2020-10-08 01:37:33 +02:00
Steinar Bakkemo 9a03c3cc7b zero-sugar dts: add max77818 2020-10-08 01:37:33 +02:00
Steinar Bakkemo e4c9b4df47 max77818: add max77818 driver (driver received from Maxim, ported to 4.14.79 kernel) 2020-10-08 01:37:04 +02:00