1
0
Fork 0
Commit Graph

721750 Commits (zero-sugar)

Author SHA1 Message Date
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
Steinar Bakkemo ef355be946 power-supply: add POWER_SUPPLY_PROP_STATUS_EX property with enumarated values 2020-10-08 20:41:17 +02:00
thomasing e5bbdbe1d5 video: maxsfb: Set LCDIF cur pointer in mxsfb_set_par. This is to be able to control which frame is run as the first frame after unblanking. (#41) 2020-10-08 20:41:17 +02:00
Steinar Bakkemo ad88355c92 otgcontrol: add device connection state check when entering unauthorized mode
In order to prevent need for disconnection and reconnection of the QR code
reader during typical test-runs in factory, a check for current connection
state is added when entering unauthorized mode.

In addition, the device disconnect procedure setting charger/USB OTG back
to charging/device mode is performed when entering authorized mode, in which
device connection/disconnection detection is currently disabled.
2020-10-08 20:41:13 +02:00
Steinar Bakkemo e27d817e3c otgcontrol: add debug hack disabling OTG detection in default state
Due to the authorized mode (default state) not being implemented
properly yet with filtering and such, a concern regarding short
while in a bag or such was discussed.

As a hot fix, the device connection (POGO ID pin) is deactivated
in default mode until this has been properly implemented, but
enabled when explicitly entering unauthorized mode from the
test-application in order to use the QR code reader.
2020-10-08 20:34:32 +02:00
Steinar Bakkemo 2edbefedce otgcontrol: fix init problem causing uninit. default sysfs controllermode shadow value
When reading the otg controller mode from sysfs before changing it, returns 0.
This is not correct, as the default mode is 1.

As the controllermode is changed, the sysfs attribute shadow value is also changed.
Now also during fsm init.
2020-10-08 20:07:16 +02:00
Shawn Guo 71ccb636fb max77818_battery: add SOC alert event support
The MAX77818 SOC max/min alert is being used to report 1% SOC change.
It's not such an useful event.  We need to use the alert to report low
battery event to user space.  This patch drops 1% SOC reporting and uses
the max/min alert to report battery SOC event to user space by calling
sysfs_notify() on corresponding sysfs entry.

It disables max SOC alert and set min SOC alert as 10% by default, but
the value can be updated by writing desired value into

 /sys/class/power_supply/max77818_battery/capacity_alert_min
 /sys/class/power_supply/max77818_battery/capacity_alert_max

Saying we have capacity_alert_min be 10, once SOC goes to 9, INTR_SOCMIN
will be triggered, and the user space program polling capacity_alert_min
sysfs entry will return successfully.

While dropping max77818_set_soc_threshold(), .suspend/.resume hooks are
removed altogether, as enable_irq_wake() has been handled by MAX77818
mfd driver, and disable_irq() has been handled by PM core anyway.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:07:16 +02:00