1
0
Fork 0
Commit Graph

721756 Commits (redonkable)

Author SHA1 Message Date
Steinar Bakkemo a0d2974708 otgcontrol: adapt otg1_chargermode property to take both int/string as input
When reading the otg1_chargermode property, a list of valid strings are
returned.

Valid enum values may be given when writing to the otg1_chargermode
property, in addition to one of the strings returned when reading
the property (Charger, OTG_supply, Off).
2020-10-08 20:41:21 +02:00
Steinar Bakkemo 6cd088d951 otgcontrol: change vbus-supply from charger to FG driver
Due to FGCC mode requiring charger control through FG driver,
otgcontrol now references the FG driver as vbus-supply.
2020-10-08 20:41:21 +02:00
Steinar Bakkemo fbd41b2b95 max77818-battery: bugfix that was missed before merge (FGCC support) 2020-10-08 20:41:21 +02:00
Steinar Bakkemo bee9783e9d max77818-battery/charger: fix IRQ init issue (charger)
Fix flaw in probe causing IRQ init to be performed in FGCC mode and not when
FGCC is disabled (which is the intension).

Simplify FGCC re-enable code during FG driver init.
2020-10-08 20:41:21 +02:00
Steinar Bakkemo 98c52ea4e0 zero-sugar dts: (max77818) FG param cleanup
Remove confusing comments in FG params (DT)
2020-10-08 20:41:21 +02:00
Steinar Bakkemo 8834246346 max77818-charger: added errorhandling to CURRENT_MAX property
The current_max property was not read correctly in FGCC mode,
due to missing errorhandling when charger device is not accessible
over the I2C bus.

An error message is now returned instead of a false value when FGCC
mode is active.
2020-10-08 20:41:21 +02:00
Steinar Bakkemo 3357a12e75 max77818-charger: do actual read from device when getting charger_mode
To make sure the actual charger_mode is returned, an actual read is
done refreshing the shadow value when charger_mode property is read.
2020-10-08 20:41:21 +02:00
Steinar Bakkemo 439c77cbae max77818-mfd/charger: add charger regmap ERR_OR_NULL check + 'property get' bugfix
The charger regmap should not be NULL, but to be sure that the regmap is never used
if NULL or ERR_PTR, a check for this has been introduced wherever this is used in
the charger driver.

A check is also done in the MFD driver before trying to initialize the charger irq.

In addition to this, a bug causing a stack dump during boot was found, causing
the powersupply subsystem's initial calls to get_property to fail due to the
mutex was created too late in the probe routine.
2020-10-08 20:41:21 +02:00
Steinar Bakkemo 064253197a max77818-battery: add missing mutex init 2020-10-08 20:41:21 +02:00
Steinar Bakkemo 9a79902db6 max77818-battery/charger: changes as requested in PR
MAX77818 MFD driver:
- Let drvdata->regmap_chg remain NULL if not initialized,
  for simple validity check
- Remove no longer used label

MAX77818 charger driver:
- Indicate error if chgin_stat_gpio state/wcin_stat_gpio states cannot be read
- Let chgin_stat_gpio/wcin_stat_gpio remain NULL if not initialized,
  for simple validity check
- Define MODE_ALL_OFF = 0x00 (POWER_SUPPLY_MODE_ALL_OFF)
- Add initial charger_mode read from device during initialization,
  and set to Charger if unknown mode is read
  (not corresponding to defined power supply charger modes)
- charger_update routine no longer returns a value

MAX77818 battery/FG driver:
- Define CONFIG_FGCC_BIT
- Add mutex to drvdata
- Improve variable naming
- Add mutex locking to charger_mode get/set functions
- Add proper FGCC mode restoration check in charger_mode get function
- Add warnings if regmap read/writes fails during custom param init
2020-10-08 20:41:20 +02:00
Steinar Bakkemo 1ee8bde61f max77818-battery/charger: add support for charger_mode readback through FG drv 2020-10-08 20:41:20 +02:00
Steinar Bakkemo 68b21489b5 max77818-battery: add charger_mode property to be forwarded to charger
charger_mode property was added to FG driver in order to disable
FGCC mode before forwarding the property change request to the charger driver,
before turning the FGCC mode back on after successfully changing the charger mode.
2020-10-08 20:41:20 +02:00
Steinar Bakkemo 636c297ace max77818-mfd/charger: add support for 'zombie' max77818 charger driver
Add support for "zombie" max77818-charger driver with GPIO based con-stat
- The max77818-battery and the max77818-charger drivers are now loaded regardless
of the failed communication with the charger device over I2C.

Adapt status_ex property to use GPIO based connection status when charger
device is offline from the I2C bus.
2020-10-08 20:41:20 +02:00
Steinar Bakkemo e0e5797ba1 zero-sugar dts: (max77818) en. FGCC/dis. SAFEOUT reg./en. GPIO based chg status
Tune JEITA configuration (mainly) and other settings, FGCC mode seems to work
as expected.

Disable regulator definition for SAFEOUT signals, thus leave the SAFEOUT
config as default, following CHGIN charger presence.

Add required pinctrl config for GPIO based connection status read from charger
device when this is offline from the I2C bus (100K PU).
2020-10-08 20:41:20 +02:00
Steinar Bakkemo bf1959d8ef max77818-battery: fix "comma+space" issue in custom_param_list (PR comment) 2020-10-08 20:41:20 +02:00
Steinar Bakkemo bff78ec9e3 zero-sugar dts: (max77818) fix DT property name errors
Remove double maxim prefix.
2020-10-08 20:41:20 +02:00
Steinar Bakkemo efb95553a4 max77818-battery: improve custom property retrieval from DT
Parameters are verified, and not-given parameters now results in
a warning and default values are kept instead of writing 0 for all
properties not found in DT.
2020-10-08 20:41:20 +02:00
Steinar Bakkemo 898a9919bf max77818-battery: fix ordering of new smart charge register definitions
Correct FG parameter ordering (by register offset)
2020-10-08 20:41:20 +02:00
Steinar Bakkemo f5c02a191a zero-sugar dts: (max77818) fix JEITA config issue/disable FGCC by default
Fix devicetree bug (params not being written as expected)
- New JEITA config parameters were configured with incorrect DT property name,
  and were thus reset to default or written as 0 depending on driver version.
2020-10-08 20:41:20 +02:00
Steinar Bakkemo e6be52aeed max77818-battery: add debug output/warnings in DT parameter parsing
Optional debug output when parameter is written.
Warning if parameter is not given.
Warning if paraeter is given, but value is not expected format (not u16).
2020-10-08 20:41:20 +02:00
Steinar Bakkemo 41f6aa6aa3 max77818-battery: add support for DT params related to smart charging/FGCC
Add support for new params defined in DT (register definitions/driver init):
    TAlrtTh
    TAlrtTh2
    JEITA_Curr
    JEITA_Volt
    ChargeState0..7
2020-10-08 20:41:20 +02:00
Steinar Bakkemo 411f4a9e96 zero-sugar dts: (max77818) enable support for smart charging controlled by FG
Add support for required extra parameters in devicetree:
    TAlrtTh
    TAlrtTh2
    JEITA_Curr
    JEITA_Volt
    ChargeState0..7

Set decent default parameters required for smart charge:
    Enable FGCC (CONFIG register)
    Set T1=disabled (TAlrtTh2 register)
    Set T2=10 deg (TAlrtTh register)
    Set T3=40 deg (TAlrtTh register)
    Set T4=50 deg (TAlrtTh2 register)
    Set JEITA_Curr = 50%/100%/81.25%
    Set JEITA_Volt = 4.15V/4.2V/4.15V

Add ChargeState0..7 to be adjusted later if required (use default values)
2020-10-08 20:41:20 +02:00
Thomas Ingebretsen eb72f683b5 wacom_i2c: Set custom timestamp to get better accuracy. The timestamp is sampled before i2c data transfer. 2020-10-08 20:41:20 +02:00
Thomas Ingebretsen 3b3aa48d1a evdev: Applied patch https://patchwork.kernel.org/patch/11049457/ to be able to set custom timestamps for input events. 2020-10-08 20:41:19 +02:00
Lars Ivar Miljeteig 871b0416e2 touchscreen: cyttsp5: Do FW update as delayed work
The touchscreen firmware is not loaded when the
file system is not ready. This patch will make
the cyttsp5 driver wait 8 seconds before looking
for the firmware file.
2020-10-08 20:41:19 +02:00
Shawn Guo d9d1fda08d touch: put touch into sleep when digitizer is in scanning
When digitizer is in scanning (pen is on screen), touch can be put into
sleep state to save power, and then be waken up when pen leaves screen.

The implementation is to have digitizer interrupt handler actively
notifies touch driver that digitizer is in scanning.  The notifier
callback in touch driver will detect the first call which indicates the
begin of digitizer scanning, and then it puts touch into sleep.  And
every time the callback gets invoked, it resets a timer until notifier
stops calling.  In that case, the timer will timeout, and it indicates
that digitizer stops scanning and touch will be woken up and back to
work.

As the procedure of putting touch device into sleep and waking-up
involves I2C data transfer which can sleep, it cannot be done in an
interrupt context, so a work is created for that.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:41:19 +02:00
Shawn Guo 434f5cf892 touch: cyttsp5: support wake-up from 'standby' sleep
To support system wake-up from 'standby' sleep via single tapping with
sensed touch data, we need to distinguish suspend type between 'mem' and
'standby', and only puts touch device into sleep for 'mem' sleep.  It's
basically a rewriting of suspend/resume hooks, including:

 - Drop easy-wake gesture handling, as we do not support it.
 - Deal with pinctrl state, touch sleep and IRQ disabling only in case
   of 'mem' sleep.
 - Enable touch as a system wake-up source in case of 'standby' sleep.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:41:19 +02:00
Shawn Guo 6378890c45 mfd: bd7181x: turn off power rails for SUSPEND mode
In standby sleep, system PMIC BD71815 will go into SUSPEND mode.  Let's
turn off those power rails unneeded in SUSPEND mode to save power.

Note: VDD_3V3, LDO1_3V3 and LDO5_1V8 need to be retained, as we want
to wake up system from standby via touch, digitizer and wifi.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:41:19 +02:00
Shawn Guo 37632186cb dts/zero-sugar: enable Wifi wake-up support
It enables WoWLAN support by adding WIFI_HOST_WAKE interrupt pin and
'wakeup-source' property for SDIO interface.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:41:19 +02:00
Shawn Guo a0ac46313f dts/zero-sugar: add keep-power-in-suspend for wifi SDIO interface
For WoWLAN testing purpose, let's add keep-power-in-suspend for wifi
SDIO interface, so that WLAN power will be retained during 'standby'
sleep.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:41:19 +02:00
Shawn Guo f1f8e8d290 suspend: get 'standby' as suspend without LPSR
To support system suspend during idle, we define 'standy' as sleep
without LPSR, while 'mem' as LPSR sleep.  In this case, DT property
"fsl,enable-lpsr" is not needed any more, as lpsr_enabled should always
be true to support 'mem' sleep.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:41:19 +02:00
Shawn Guo aa13419a71 touch: wacom: enable device as a wakeup source
To support system suspend during idle, we need to wake up system via
digitizer.  With this change, we can disable/enable the wakeup at
run-time as below.

 $ echo disabled >| /sys/bus/i2c/devices/0-0009/power/wakeup
 $ echo enabled >| /sys/bus/i2c/devices/0-0009/power/wakeup

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:41:19 +02:00
Thomas Ingebretsen 85e7f75ffd wacom_i2c: return wacom_setup_device return code. 2020-10-08 20:41:19 +02:00
Thomas Ingebretsen 07e01e13f0 wacom_i2c: call wacom_setup_device() after resume to setup sample rate after returning from sleep. 2020-10-08 20:41:19 +02:00
Lars Ivar Miljeteig 62916086bb sy7636a mfd: Add sysfs attr for power state
Added
  state = Reads fault state
  power_good = Reads power good flag
2020-10-08 20:41:19 +02:00
Lars Ivar Miljeteig 00766882cb sy7636a regulator: Use dev_pm_ops 2020-10-08 20:41:19 +02:00
Lars Ivar Miljeteig fc8d4cb0e1 sy7636a: Remember vcom value after deep sleep
Store vcom value when suspending, and restore
value when resuming.
2020-10-08 20:41:18 +02:00
Shawn Guo f3ac0f71b5 zero-sugar_defconfig: enable CYTTSP5 firmware upgrade via sysfs
It enables option TOUCHSCREEN_CYPRESS_CYTTSP5_MANUAL_TTCONFIG_UPGRADE
to support CYTTSP5 firmware upgrade via sysfs.  The command sequence
is like below.

 $ echo 1 >| /sys/bus/i2c/devices/2-0024/manual_upgrade
 $ echo 1 >|  /sys/class/firmware/cyttsp5_fw_manual_upgrade/loading
 $ cat xxx.bin >| /sys/class/firmware/cyttsp5_fw_manual_upgrade/data
 $ echo 0 >| /sys/class/firmware/cyttsp5_fw_manual_upgrade/loading

The last command will take quite a few seconds to finish.

Note: The SY7636A and MEMTEST options are moved around as a result
of savedefconfig.  They do not bring any effective changes.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:41:18 +02:00
Shawn Guo af6f07c690 touch: cyttsp5: increase CY_HID_OUTPUT_TIMEOUT to 1000ms
The firmware upgrade testing discovers that 200ms CY_HID_OUTPUT_TIMEOUT
is not good enough, and causes suspend scanning call in
cyttsp5_get_ic_crc_() fail.  Let's increase it to 1000ms as per vendor's
suggestion.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:41:18 +02:00
Shawn Guo 1adec42136 snvs_pwrkey: shorten ON_TIME to get a faster reaction on wake-up
The default 500ms ON_TIME is too long, and thus causes a slow reaction
on power key wake-up.  Let's change it to 50ms to get a faster reaction.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:41:18 +02:00
Shawn Guo 7ba84f2463 dts/zero-sugar: disable unused peripherals
The following peripherals are not used on reMarkable device.

 - Messaging Unit (MU)
 - APBH-Bridge-DMA
 - Cryptographic Acceleration and Assurance Module (CAAM)

Let's disable them, so that Linux kernel driver will not probe these
devices and turn on their clocks.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:41:18 +02:00
Shawn Guo 092e8c9a38 max77818_battery: work around battery presence issue
MAX77818 battery presence STATUS bit is not working on our device for
some reason unknown yet. We are working around the issue here by reading
temperature register, in which a negative value indicates absence of
battery.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:41:18 +02:00
Shawn Guo aca7ebc3a9 dts/zero-sugar: fix memory size
The memory size should be 1G rather than 2G. It explodes after we have
DDRC configuration fixed in plugin, in case that we launch kernel image
with fastboot where the memory size in device tree gets passed to
kernel.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:41:18 +02:00
Steinar Bakkemo e9e3814946 max77818-battery: add support for tGain/tOFF/tCurve FG params
Read tGain/tOFF/tCurve from DT during driver init.

Note:
FG/battery driver has to re-init the device for changes to occur on
already configured devices, and this is normally only done right after
initial power-on with un-configured device.

A solution for this is however under development, which will make sure
that selected FG parameters are validated during each boot.
2020-10-08 20:41:18 +02:00
Steinar Bakkemo 2051f54210 zero-sugar dts: (max77818) battery temp. measurement parms accord. to HW design
Add tGain, tOFF and tCurve FG params configured according to ref. config
found for similar thermistor with same beta-value as in our design.
2020-10-08 20:41:18 +02:00
Shawn Guo b27cab889d dts/zero-sugar: set Aen bit in FG CONFIG register
Aen bit of CONFIG register needs to be set for enabling alert on
fuel-gauge outputs like low SOC interrupt.  This is a missing piece from
the original low battery alert commit.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:41:18 +02:00
Shawn Guo 40207bd6a4 mfd: bd7181x: keep LDO_DVREF on for LPSR sleep
LDO_DVREF should be on during LPSR sleep, as it provides the reference
voltage to LPDDR3.  So let's keep it on for LPSR state.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:41:18 +02:00
Shawn Guo 0004d5660a dts/zero-sugar: enable LPSR sleep mode
Suspend code will check this 'fsl,enable-lpsr' to determine if it needs
to go into LPSR mode for sleep.

Because WiFi driver doesn't support suspend with power shutdown, we need
to remove WiFi module in sleep and reinstall it when system wakes up.
In this case, property 'keep-power-in-suspend' needs to be dropped to
get MMC stack be aware of power losing in LPSR sleep.  The command
sequence looks like:

 $ rmmod brcmfmac
 $ echo mem >| /sys/power/state
   system suspends, and wakes up
 $ insmod brcmfmac.ko
 $ dhcpcd wlan0

WiFi should be back to work then.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:41:18 +02:00
Steinar Bakkemo e2b3b99c8a max77818-charger: add check for OTG mode when returning status_ex property
Ignore POGO connection state when in OTG mode, as the charger driver
always reports CHGIN OK (aka. connected) when charger_mode = OTG Supply
2020-10-08 20:41:18 +02:00
Steinar Bakkemo 3e0b6b929a max77818-charger: add support for new POWER_SUPPLY_PROP_STATUS_EX property
Add support for reading connection state through new status_ex sysfs property.
2020-10-08 20:41:18 +02:00