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.
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).
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)
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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
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>
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>
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>
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.
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.
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.
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>
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>
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>
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.
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>
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>
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>
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>
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>
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>
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.