1
0
Fork 0
Commit Graph

721638 Commits (460927241136e46ffe80df30347dfc1adbc87b94)

Author SHA1 Message Date
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
Shawn Guo ac13f89f6f max77818_battery: drop some unhelpful properties
Right now, max77818_battery driver already has 31 sysfs entries
(and thus uevents for power_supply class), which is reaching the
maximum number 32 (see UEVENT_NUM_ENVP in include/linux/kobject.h).
So when trying to add more properties, we will get the following
kernel WARNING in calling power_supply_uevent() -> add_uevent_var().

  WARNING: CPU: 1 PID: 93 at lib/kobject_uevent.c:568 add_uevent_var+0xa4/0xcc
  add_uevent_var: too many keys

Let's drop some unhelpful properties which do not reflect any hardware
states to leave room for other new useful properties.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:07:16 +02:00
Shawn Guo bd3f8efec8 mfd: bd7181x: set LPSR_MODE bit only when system sleeps
Bit LPSR_MODE should be cleared only when system is going to sleep in
LPSR state.  Other than that, the bit should be set for system to get
powered off in SNVS state.

All BUCKs and LDOs will be turned off in SNVS state, only except LDO3.
So we need to change the default setting to turn off LDO3 in SNVS state.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:07:15 +02:00
Lars Ivar Miljeteig 0542f9eae9 max77818: Don't disable charging when unplugged
Keep charging on at all times, to avoid brick faults

If a device has low battery, and you:
1. Unplugg chargers
2. Set mode to "Charger" in sysfs
3. Shutdown the device

It is bricked until the battery is plugged in and out.

This should fix that.
2020-10-08 20:07:15 +02:00
Shawn Guo cd93f18a0a max77818-charger: fix bug on CHG_CNFG registers setting
The ffs() is for finding the first set bit, not what we want - the last
set bit of a bit mask.  Actually, the whole ffs/fls can go wrong very
easily depending on what the bit mask is.  Let's explicitly define the
needed bit shift and kill ffs/fls use completely, so that we fix
incorrect setting on register CNFG_01, CNFG_03 and CNFG_04.

While at it, simply the writing to CNFG_04 by using regmap_write()
rather than regmap_update_bits(), since we need to update all fields
of the register, i.e. CHG_CV_PRM and MINVSYS.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:07:15 +02:00
Steinar Bakkemo 78a2099765 zero-sugar dts: (max77818) adapt CHARGER_INTB config according to HW change
Change pin mux from GPIO6.22 => GPIO1.7
Change internal PU => 100K, disable hysteresis, drivestrength and slewrate config
Change interrupt config accordingly for max77818 driver
2020-10-08 20:07:15 +02:00
Shawn Guo 4fdeebcb42 mfd: bd7181x: disable unused functions to save power
As suggested by Bent, it disables unused/unneeded BD71815 functions,
like RTC, charger, battery, LED and so on, to save a bit more power.

Since we are now doing more BD71815 hardware initialization than LPSR
related configuration, function bd7181x_lpsr_init() gets renamed to
bd7181x_hw_init().

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:07:15 +02:00
Shawn Guo e1f06de912 dts/zero-sugar: decrease delay of digitizer power control to 100 ms
As confirmed by Bent, 100 ms delay should be good enough for digitizer
power control.  So let's decrease it to 100 ms to avoid unnecessary
longer delay.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:07:15 +02:00
Shawn Guo 0d48c715fe dts/zero-sugar: add regulator for digitizer and touch
Rather than relying on U-Boot to turn on power to digitizer and touch,
let's add regulator for the devices to control power via GPIOs.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:07:15 +02:00
Shawn Guo 069e8a2682 touch: cyttsp5: use regulator to control power
VDD_3V3_TOUCH power to cyttsp5 touch is controlled by GPIO TOUCH_PWR_EN.
Rather than relying on U-Boot to initialize the power, let's use
regulator to control it.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:07:15 +02:00
Shawn Guo 192cf86226 touch: wacom: use regulator to control power
VDD_3V3_DIGITIZER power to digitizer is controlled by GPIO
DIGITIZER_PWR_EN.  Rather than relying on U-Boot to initialize the
power, let's use regulator to control it.

While at it, fix the memory leak on wac_i2c allocation in failure of
wacom_query_device() and other calls.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2020-10-08 20:07:15 +02:00
Lars Ivar Miljeteig 2bafa4cefa zero-sugar dts: Disable touchscreen blanking 2020-10-08 20:07:15 +02:00
Lars Ivar Miljeteig bd16c306a1 cyttsp5: fb blanking configurable in devtree
Add an optional  device tree parameter
  cy,fb_blanking_disabled

This parameter controls the blanking notifier.
If the parameter is set in the device tree,
the cyttsp5 device will NOT change its state
according to the state of the framebuffer
device.
2020-10-08 20:07:15 +02:00