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.
With LPSR sleep support coming, cyttsp5 will lose power completely
during system sleeps. To get cyttsp5 driver support the power state
better, we should add CY_CORE_FLAG_POWEROFF_ON_SLEEP flag for cyttsp5
core device. See enum cyttsp5_core_platform_flags in
include/linux/platform_data/cyttsp5.h for full list of flags.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
During LPSR sleep, all IOMUXC settings will be lost because of power
down of the block. To restore the IOMUXC settings in LPSR wake-up,
drivers will select 'sleep' state pinctrl in suspend, and later select
'default' state pinctrl when system resumes. To cope with that, we need
to have both pinctrl states in device tree. A simple approach would be
have both states point to the 'default' pinctrl, since IOMUXC block will
be completely powered down in LPSR mode anyway.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
To support suspend/resume from LPSR mode, we need to select default
pinctrl state in resume, so that IOMUXC settings can be restored from
power losing.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
To support suspend/resume from LPSR mode, we need to select default
pinctrl state in resume, so that IOMUXC settings can be restored from
power losing.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
To support suspend/resume from LPSR mode, we need to select default
pinctrl state in resume, so that IOMUXC settings can be restored from
power losing.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
To support suspend/resume from LPSR mode, we need to select default
pinctrl state in resume, so that IOMUXC settings can be restored from
power losing.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
To support suspend/resume from LPSR mode, we need to select default
pinctrl state in resume, so that IOMUXC settings can be restored from
power losing.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
In wake-up from LPSR, all watchdog powerdown gets enabled due to the
re-powering of SoC. We need to temporarily enable root and CCGR clock
of each watchdog and clear powerdown bit. Otherwise, system will reset
after 16 seconds. This watchdog initialization has been done by U-Boot
for the first time boot, and needs to be done for LPSR resume as well.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
To support suspend/resume from LPSR mode, we need to select default
pinctrl state in resume, so that IOMUXC settings can be restored.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
BD71815 device uses GPIO6_IO16 as the PMIC_INT_B interrupt line. Even
though we are currently not using the interrupt from the device, there
should be a pinctrl for PMIC_INT_B to make the hardware description more
complete and correct.
While at it, rename the device node to bd71815 for an explicit naming.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
If the charging mode 0 is retained during device reset,
this will possibly cause a "deadlock" requiring complete battery
drain before device may be re-charged.
There is a 2 cycles (32K clock) delay required between WIFI_PWR_EN and
WL_REG_ON assertion. Let's use 'startup-delay-us' of WIFI_PWR_EN
regulator to add that delay. We increase the delay from required 61 us
to 150 us for some margin.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Besides WIFI_REG_ON handled by wifi_pwrseq, we need to deal with
WIFI_PWR_EN as well to get BCM43455 WiFi chip powered properly. This
WIFI_PWR_EN is currently handled in U-Boot. As we have fixed-regulator
infrastructure in kernel which can handle this nicely, let's use it, so
that we can drop the code from U-Boot.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
The pinctrl_wifi is all about configuring pins used by wifi_pwrseq,
including the 32K clock and WIFI_PWR_EN. So let's move the pinctrl
into wifi_pwrseq device.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
The standard pwrseq bindings (bindings/mmc/mmc-pwrseq-simple.txt) has
an 'ext_clock' which can be used to handle BCM43455 32K clock. Let's
use it.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Add multi-function device to interface the
sy7636a EPD PMIC chip from Silergy.
- Regulator driver for VCOM
- Hwmon driver for thermistor temperature
- MFD driver for i2c regmap
Reads
* flip-tilt-x
* flip-tilt-y
* flip-pos-x
* flip-pos-y
* flip-distance
* flip-pressure
from the device tree, and acts accordingly.
Also cleans up memory management in probe, and stores
the features information for later usage.
With recent kernel version, there is no need for a container node in
iomuxc nodes. Let's drop them to save one level of indentation.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
It's a bit easier for checking pinctrl configurations to put omuxc_lpsr
together with iomuxc node.
While at it, drop the unneeded pinctrl-names from both nodes.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>