1
0
Fork 0
Commit Graph

888152 Commits (zero-colors)

Author SHA1 Message Date
Lars Ivar Miljeteig 7d5ee0bdcb otgcontrol: Fix race condition at OTG enable
Quickfix.

The ci_hdrc crashes if the DR mode is set to HOST while
it is interpreting the "set MODE bits to 0xf" state.

Possible chip errata, where the ci_hdrc has to be
powered on and off to work again.

Fixed by adding a delay of 300-400ms between enabling
OTG power out and setting USB mode to HOST mode.

NOTE: This should be further investigated, as a
delay of 300-400ms in kernel code is A LOT.
2021-03-19 23:32:43 +01:00
Steinar Bakkemo 3b89925719 otgcontrol: change charger_mode property string to comply with power_supply_sysfs.c
OTG_supply -> OTG Supply
2021-03-19 23:32:43 +01:00
Steinar Bakkemo 59b6835752 otgcontrol: read current GPIO state directly from sysfs attribute_show method
In order to read the current GPIO state regardless of the current controller
mode, and thus regardless of whether the GPIO irq is enabled, a direct
read of the raw GPIO state is done directly from the sysfs attribute_show
method.

Required synchronization was added to the access method to prevent race
if the attribute is read at the same time the irq handler is running.
2021-03-19 23:32:43 +01:00
Steinar Bakkemo b76b2487e8 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).
2021-03-19 23:32:43 +01:00
Steinar Bakkemo bf31862d1b 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.
2021-03-19 23:32:43 +01:00
Steinar Bakkemo 1b9d1bc819 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.
2021-03-19 23:32:43 +01:00
Steinar Bakkemo 2e0615850e 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.
2021-03-19 23:32:42 +01:00
Shawn Guo 25fdcab971 otgcontrol: select pinctrl state during suspend/resume
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>
2021-03-19 23:32:42 +01:00
Steinar Bakkemo 345489a4b4 otgcontrol: improve driver output during boot when defering probe (not error) 2021-03-19 23:32:42 +01:00
Steinar Bakkemo b8e1a3487c otgcontrol: add support for setting charger mode to OFF 2021-03-19 23:32:42 +01:00
Steinar Bakkemo d05ea11ca6 otgcntrol: fix simple dev_dbg outputting error message => dev_err 2021-03-19 23:32:42 +01:00
Steinar Bakkemo 602ef33a8f otgcontrol: enable readback of last written USB OTG dr mode
Fix bug not storing this when setting the USB OTG dr mode
2021-03-19 23:32:42 +01:00
Steinar Bakkemo d204f85907 otgcontrol: cleanup sysfs code and fix ugly bug causing unregister to fail 2021-03-19 23:32:42 +01:00
Steinar Bakkemo 9cfedd1e3a otgcontrol: add CONFIG_RM_OTGCONTROL_DEBUG
Update Makefile to build with DDEBUG only when CONFIG_RM_OTGCONTROL_DEBUG
is defined
2021-03-19 23:32:41 +01:00
Steinar Bakkemo ac82834753 otgcontrol: remove un-needed deallocation/un-init code
Ref. discussion on this when using devm_xxx(..) version of
allocation/init routines.
2021-03-19 23:32:41 +01:00
Steinar Bakkemo cc5d2bc9d1 otgcontrol: replace module_init/module_exit with module_platform_driver 2021-03-19 23:32:41 +01:00
Steinar Bakkemo d8cc9ad0eb otgcontrol: remove hard-coded one-wire tty device name/path 2021-03-19 23:32:41 +01:00
Steinar Bakkemo 1c05f535e7 otgcontrol: remove deprecated CONFIG_OF checks 2021-03-19 23:32:41 +01:00
Steinar Bakkemo e843efb4c3 otgcontrol: move include/linux/rm-otgcontrol.h => drivers/misc/rm-otgcontrol/ 2021-03-19 23:32:41 +01:00
Steinar Bakkemo 745d2a449b otgcontrol: adapt to changed charger-driver interface
Original "set mode + set online" => "set mode"
2021-03-19 23:32:40 +01:00
Steinar Bakkemo a600ccc26b otgcontrol: add synch. to device-connected sysfs prop./fix pinctrl read bug
Device-connected sysfs property is vulnerable for simultanious access by
IRQ handler and sysfs property show handler.

Fix bug causing kernel stack-dump/crash when trying to read current pinctrl state through sysfs property
2021-03-19 23:32:40 +01:00
Steinar Bakkemo b811e990d7 otgcontrol: improve device OTG control mode handling/authentication handling
Temporary skip  authentication of calling application

Check connection state before changing state (to keep connection state while
changing mode).

Other cleanup
2021-03-19 23:32:40 +01:00
Steinar Bakkemo 517eeaffc1 otgcontrol: add synchronization helpers for synchronization of flags
Add synchronization to one_wire_gpio_irq_is_handling flag checked and
set by GPIO IRQ handler and reset by GPIO IRQ worker.
2021-03-19 23:32:40 +01:00
Steinar Bakkemo e633d8b220 otgcontrol: move pdata properties from otgc_data to otgc_data->pdata structure 2021-03-19 23:32:40 +01:00
Steinar Bakkemo 135d3a07d4 otgcontrol: adjust to 8 char tab width and squeeze code within 80 chars, dyndbg
Convert printk's to dev_dbg.

Fix tabs (8 chars) and wrap lines to fit within 80 chars, according to kernel
standards.
2021-03-19 23:32:40 +01:00
Steinar Bakkemo 51d542c59b otgcontrol: improve pdata initialization and probe defer/unallocation sequence 2021-03-19 23:32:40 +01:00
Steinar Bakkemo 9896a0c499 otgcontrol: improve sysfs attribute group allocation
Add static sysfs attribute definitions										.
Add attribute group de-allocation during un-init of the sysfs structures
2021-03-19 23:32:40 +01:00
Steinar Bakkemo 82b5190419 otgcontrol: clean up uninitialize code in driver probe 2021-03-19 23:32:39 +01:00
Steinar Bakkemo db96de931c otgcontrol: improve ow/pogo IRQ handling (500 ms debounce/filter), bugfix
Fix bug caused by calling wrong method when trying to switch USB OTG DR mode
2021-03-19 23:32:39 +01:00
Grzegorz Jaszczyk d8da631d17 otgcontrol: fix compilation by aligning to v5.4 kernel API
Replace non existing get_ds() with KERNEL_DS as an alignment for v5.4
kernel.

Signed-off-by: Grzegorz Jaszczyk <grzegorz.jaszczyk@linaro.org>
2021-03-19 23:32:39 +01:00
Steinar Bakkemo 3347c6dfca otgcontrol: implement initial FSM
Complete disabling of authenticated USB device connection in all modes

Code cleanup
- Spaces -> tabs
- Cleaner initiation sequence
2021-03-19 23:32:39 +01:00
Steinar Bakkemo 86fa04f597 otgcontrol: add one-wire gpio irq handling
- Fix typo in devicetree causing pincontrol not being registered
- Change pin mux states to use both RX and TX pin
- Implement preliminary first attempt to communicate over ow (wip)
- Add registration as extcon device
- Add ow tty property in device-tree
- Add ow gpio property in device-tree
- Add GPIO IRQ initiation/hanndling in delayed worker
2021-03-19 23:32:39 +01:00
Grzegorz Jaszczyk 22f202eeac otgcontrol: fix compilation by including proper header for v5.4 kernel
Fix compilation by including <linux/extcon-provider.h> which is required
after porting otgcontrol from kernel v4.14 to v5.4.

Additionally fix the existing rm-otgcontrol.h header guard (#ifndef).

Signed-off-by: Grzegorz Jaszczyk <grzegorz.jaszczyk@linaro.org>
2021-03-19 23:32:39 +01:00
Steinar Bakkemo 9d4755578b otgcontrol: add excton device registration (emulate OTG VID signal -> OTG driver) 2021-03-19 23:32:39 +01:00
Steinar Bakkemo 90d597fb16 otgcontrol: rm-otgcontrol driver initial commit 2021-03-19 23:32:38 +01:00
Lars Ivar Miljeteig a4ab733d6c pm-imx7: LPSR: Button ON_TIME & GPIO wakeup tweaks
Differentiate SNVS button click time for LPSR sleep
and power on:
Power off -> On - 500ms
LPSR Sleep -> Wake-up - 50ms

Turn off GPIO wake-up hack when not in LPSR sleep
2021-03-19 23:32:38 +01:00
Shawn Guo 303f08eb20 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>
2021-03-19 23:32:38 +01:00
Shawn Guo 7fdccd9015 pm-imx7: disable watchdog powerdown when waking up from LPSR
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>
2021-03-19 23:32:38 +01:00
Lars Ivar Miljeteig 6f8964b659 max77818: Add licensing info 2021-03-19 23:32:38 +01:00
Lars Ivar Miljeteig 75e0ea8631 power: max77818_battery: Handle errors
- Handle return code for regmap_write & regmap_read
- Rename some functions with misleading names
  i.e "verify" when it actually writes, differentiate
  between reading params from chip or device tree, etc
- Don't clear POR bit if writing data failed
- Set init complete even if "write custom params" fail,
  as it will eventually time out and continue init anyhow
2021-03-19 23:32:38 +01:00
Steinar Bakkemo 59c5de20ee max77818-battery: add boot-time verification for critical FG params 2021-03-19 23:32:37 +01:00
Steinar Bakkemo 603c0889f0 max77818-charger: force false chgin connection status
The max77818 charger device reports a valid connection status for
the chgin interface, regardless of whether it has been disabled or not
with chgin_sel.

The charging status is thus not reported correct, as the device is not
charging from the pogo interface even if the connection state indicates
otherweiz.

In order to report a correct state to userspace, the charger connection
state is now always reported to be false for the chgin interface (as
this is always turned off as soon as the connection state changes)
2021-03-19 23:32:37 +01:00
Steinar Bakkemo 50312c0497 max77818-battery: add locking option for all custom params
In order to be able to synchronize initial register write with other
drivers possibly accessing the same registers during init, an option
to apply a mutex lock (defined at the mfd level) is introduced.

The config register is also given a requirement to be locked, as this
register holds the FGCC bit which is the main cause of this option.
2021-03-19 23:32:37 +01:00
Steinar Bakkemo 9fe6351786 max77818-battery: skip default verify/write for all custom params
Due to uncertainty related to how safe it is to verify each custom
param during every boot, set the skip_verify flag for every custom param except
for the config register which is verified against current DT and reset if changed
for some reason since last boot.

This ensures that if an operation performed through the max77818 charger driver
was aborted by a reboot for instance, and the FGCC bit remained 0, it will be
restored to 1 after a reboot.
2021-03-19 23:32:37 +01:00
Steinar Bakkemo 3845cd6501 max77818-battery: add skip flag to learn-cfg custom param 2021-03-19 23:32:37 +01:00
Steinar Bakkemo b8b444998f max77818-battery: do initial max current adj. during boot (after other init)
Due to the normal FG driver init configuring FGCC to be enabled during its normal
run, where all custom params configured in DT are verified and restored to the
original value if changed since last boot, charger driver sync has to be done
after completion of normal init.

This is now done in a separate worker which waits for the other init to complete
using a simple completion obj.

Also, unlock mutex at early return errors.
2021-03-19 23:32:37 +01:00
Steinar Bakkemo 0eeafd4f56 max77818-battery: fix initial status_ex read bug
The status_ex is read during driver initiation, but the local shadow
variable was not updated, causing the status_ex to be "not connected"
even if the device was powered on with USB-C charger connected.max77818-battery: fix initial status_ex read bug
2021-03-19 23:32:37 +01:00
Steinar Bakkemo 2276d22df7 max77818-charger: remove warnings due to failed read from device
Failed read from device is likely to occur when the charger driver
properties are read directly from the charger driver and not via
the FG driver which makes sure the FGCC mode is turned off before
trying to access the charger device.

The warnings generated clutters the journal, and cause suspicion that
the driver or device is not working properly.
2021-03-19 23:32:37 +01:00
Steinar Bakkemo 03edb37b6f max77818-battery-utils: add output of op_descr in START_FGCC_OP/FINISH_FGCC_OP 2021-03-19 23:32:36 +01:00
Steinar Bakkemo ca4232aee1 max77818-battery: add init routine for charger init ops and disable chgin by def
Operations done during FG driver initiation which address the charger driver is
collected in new init routine, which now reads initial status information required
to be shadowed in the FG driver (status_ex) and disables the chgin interface by
default.
2021-03-19 23:32:36 +01:00