1
0
Fork 0
Commit Graph

48313 Commits (redonkable)

Author SHA1 Message Date
Li Jun 2273e2dcd9 MLK-20220 staging: typec: tcpci: fix improper use of negative value
Coverity complains CID 3411292: Improper use of negative valure
(NEGATIVE_RETURNS), as possibly assign a negative value to unsigned
int, fix it by use an int temp value for negative value return.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
(cherry picked from commit 9ab72e25fcda73a455a434993c8186663c241f27)
2018-11-23 19:48:45 +08:00
Li Jun 75fc02b7d6 MLK-20105 staging: typec: tcpm: keep non-PD session for no GoodCRC
In case of vbus_never_low, if source setup a typye-c only session, sink
time out on waiting for source capability message and send soft reset,
the source does not response by goodcrc for the soft reset message, we
don't do hard reset, but keep a non-PD typec session, because the source
maybe PD capable, this hard reset will make the source terminate the
session by turn off vbus, if this type-c port is the system power supply,
the whole system will reboot.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-11-02 15:07:21 +08:00
Li Jun 50b9d0b752 MLK-18744 staging: typec: tcpm: qos handling fix
Commit 661b7ec2359e ("MLK-17921-2 staging: typec: tcpm: add qos for
PD transfer") introduce qos for tcpm transfer between typec controller
and CPU, but the request and remove are not balanced well, the initial
request should be moved to tcpm_port_register as tcpm_init will be called
for every hard reset, and also move qos hold&release to where port state
changes.

Fixes: 661b7ec2359e ("MLK-17921-2 staging: typec: tcpm: add qos for PD transfer")
Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun f6f814d5cb MLK-17921-2 staging: typec: tcpm: add qos for PD transfer
TCPCI based typec port controller needs very strict low latency
on i2c transfer, this patch is to improve this by adding qos and
high bus handling in tcpm during PD session setup.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 0d2d088b62 MLK-17921-1 staging: typec: tcpci: improve properties parse
Current typec and PD properties parse can't work well for sink or source
only port, this patch is to improve it.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Song Bing f14c444263 MLK-18834 ion: Enable ion on Kernel 4.14
Enable ion driver on Linux platform for Kernel 4.14.

Signed-off-by: Song Bing <bing.song@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 31bb5cd35c MLK-18531 staging: typec: don't do vbus source disable for dead battery
In PTN5110 design, DisableSourceVBUS command also disables the sink
enable signal because the EN_SNK can be used to source higher voltage,
and, there is only one TCPC command to disable sourcing voltage without
telling whether to disable 5V or the high voltage, and to keep the
design simple they designed the PTN5110 to disable both. with this
fact, we use the flag drive_vbus to check if the source vbus enable was
issued, if yes we then do vbus source disable, in dead battery case,
we never did vbus source enable, so will not issue vbus source disable
command.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun a7246ec48c MLK-17108-4 staging: typec: tcpci: correct read data msg length
Per tcpci spec, the TCPC_RX_BYTE_CNT is the number of bytes in the
RX_BUFFER_DATA_OBJECTS plus three (for the RX_BUF_FRAME_TYPE and
RX_BUF_HEADER), so after read out the header, we should only read
TCPC_RX_BYTE_CNT-3 bytes for data if this is a data message.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 4adece561e MLK-17108-3 staging: typec: tcpci: don't do force discharge if enable vbus sink
We use vbus force discharge to have a quick vbus off for power role swap,
which works like this: enable vbus force discharge and wait the vbus fall
below vbus low threshold, when reaches, an alarm generated and tcpm can go
forward. but current code do vbus force discharge in any disable source
vbus case, in enable vbus charge case, we firstly disable source vbus and
then turn on vbus sink, in between, vbus force discharge should not be
enabled.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Jun Li 876270659b MLK-17108-2 staging: typec: support dead battery charging
If the vbus is aready on and remote cc state is Rp while typec init, we
think it's a dead battery case, this needs the PD session already setup
by bootloader,  so kernel can negotiate a new power session by soft reset,
this patch use the exsiting flag vbus_never_low as boot from dead battery
flag, but update the condition of setting it: not only check vbus, also
the cc status to make sure remote is a power source, if yes, bypass the
vbus sink disable. If the vbus is from local, we will still disable vbus
charge so original code intention is kept.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Peter Chen c02f40f91e MLK-17237 staging: typec: return error when tcpci_parse_config has failed
Otherwise, the probe would be considered successfully, and without
do any destroy jobs, eg, the interrupt has still registered.

Acked-by: Jun Li <jun.li@nxp.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 8c3a6d4ba6 MLK-17242-1 staging: typec: tcpci: add sink setting for sink-disable
Adding fixed sink power settings for sink-disable case, which
is only for PD protocol talk to know the cc orientation if connects
to a PD capable host, HW doesn't really sink any power in this case.

Tested-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun df4146c99a MLK-17217 staging: typec: tcpci: system wakeup source support
As GPIO normally can be system wakeup source, so enable typec events
as system wakeup source if user requested.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 070f35aae6 MLK-17128-3 staging: typec: reading max_snk_mw setting from OF
It's missing while do typec related properties read, sink
needs it to check if the provided PDO can match the required
power.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun d4f36fbd26 MLK-17092 staging: typec: enable vbus voltage low alarm
We use vbus low voltage alarm to start vbus discharge to meet
timing requirement on turning off vbus for power swap from
source to sink, per type-C port controller spec(tcpci), the
Voltage Alarms Power status reporting is disabled by default,
so we need enable it at tcpci init.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun c5500a2ee4 MLK-17077 staging: typec: clear vbus change event in irq handler
For vbus change event, we need read the vbus status to clear
the alert. Current code do this in queue work, this has problem
on single core running, the queue work of vbus change may have
no chance to be scheduled as we continue receive the vbus change
event in threaded irq.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun b50c752971 MLK-16820-2 staging: typec: tcpci: add sink_disable flag for source only power
As we need to use DRP config for data role, but the power role is source only,
so introduce a property sink-disable to avoid sink vbus command.

Signed-off-by: Li Jun <jun.li@nxp.com>
Acked-by: Peter Chen <peter.chen@nxp.com>
2018-10-29 11:10:38 +08:00
Keith Packard b65bdf9c68 drm: Pass struct drm_file * to __drm_mode_object_find [v2]
This will allow __drm_mode_object_file to be extended to perform
access control checks based on the file in use.

v2: Also fix up vboxvideo driver in staging

[airlied: merging early as this is an API change]

Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit 418da17214)
2018-10-29 11:10:38 +08:00
Li Jun 54dd46dd75 MLK-16776 staging: typec: tcpci: use vbus from partner for EXTCON_USB
Change to use the vbus from partner to notify EXTCON_USB.
This is to work around the case of source only typec port
connecting to Host PC via a Rp fixed cable.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun ada8b67b8a MLK-16697 staging: typec: tcpci: add notfication for device attach
Some usb device driver can't know the connect and disconnect to host
if the vbus is always on, if use typec we can rely on cc line status
to know that, so add a notification to let controller driver know
device attach and detach from host.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Peter Chen dbb7fba24e MLK-16285-2 staging: typec: tcpci: add optional reset pin support
Some USB3 differential channel switch chips need to do reset before
functional, we add this support here.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
Acked-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Peter Chen 82d23ff109 MLK-16285-1 staging: typec: tcpci: move request interrupt to the end of probe
The tcpci_irq may visit tcpci->port if unexpected interrupt occurs
(eg, board design issue causes GPIO status is incorrect) and cause
NULL pointer dereference issue.

Besides, delete clear TCPC_ALERT and TCPC_ALERT_MASK code which are
already done at tcpci_init.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
Acked-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 2a23a6d08b MLK-16298-1 staging: typec: make super speed signal mux select configurable
Instead of fixed pull up super speed mux selection gpio for cc1, use
GPIO_ACTIVE_HIGH/LOW to map the CC1/CC2 orientation via gpiod api, So
for ss-sel-gpios:
GPIO_ACTIVE_HIGH: CC1 <--> GPIO high
GPIO_ACTIVE_LOW : CC1 <--> GPIO low

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 04cabfd329 MLK-16013-44 staging: typec: tcpm: set data role after src detach
As the default data role is device mode if the port is not host,
so set the port data role to be device mode after src detach, this
is to fix the issue of port data role still kept to be host while
the port is open.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun b25bbcfac5 MLK-16013-43 staging: typec: tcpci: add extcon for data role switch
Use extcon device for dual role switch on typec port.

Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 60376f48b4 MLK-16013-37 staging: typec: Power swap force discharge for source
VBus off only means the vbus falls to be below 4v, we can use vbus
force discharge and vbus low alarm to go forward.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun b7e8918476 MLK-16013-36 staging: typec: wait for cc change on ERROR_RECOVERY
We should wait at least tErrorRecovery before move to unattached state.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 24da254134 MLK-16013-34 staging: typec: Support cc changes on RP pull-up value
CC line changes on souce side RP value is permitted per standard, in
this case we should move to SNK_ATTACH_WAIT.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun e56e789e1f MLK-16013-33 staging: typec: Do not switch to unattached state for BIST
If we received unsupported BIST command, we should by pass it and ready
to accept following command for test, not unconditionly to set the port
to be unattached state and terminate the test.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 84a0449c10 MLK-16013-32 staging: typec: refine source to sink swap handling
To early start sink power after source turn off vbus, move the set power
role after vbus is turned off in PR_SWAP_SRC_SNK_SOURCE_OFF, also per
spec, we should do error recovery if the sink side does not turn on
vbus in PD_T_PS_SOURCE_ON.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 7584195685 MLK-16013-31 staging: typec: Set to unattached state if souce disconnected
In SNK_HARD_RESET_SINK_ON, if the source disconnected, we should set
state to be unattached state intead of startup sink.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 5217d2cb3a MLK-16013-30 staging: typec: Reset hard_reset_count to be 0 after send source cap
Per standard, we should clear the hard reset count to be 0 after souce
sent the source cap.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun fe6c3fd1d8 MLK-16013-29 staging: typec: tcpm: Don't reset message id after soft reset
If the power source sent soft reset and the other end accepted, we should
not reset the message id as it was already updated by pd_transmit when
handling the soft reset.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun e10d8d3c13 MLK-16013-28 staging: typec: tcpci: Populate config from dt
Instead of static config, use dt to pass basic PD config for
below settings:
- Source pdo list
- Sink pdo list
- Max sink voltage
- Max sink current
- Sink operating power
- TypeC port type
- TypeC port preferred role

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 13f735b060 MLK-16013-27 staging: typec: add super speed signal mux selection
According to the polarity of cc line, we need to do USB3 signal mux
selection if it's controlled by software.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 45927e4eb2 MLK-16013-26 staging: typec: tcpm: update PD timing
This patch is to update several PD timings for PD compliance, all
those timing definitions should be configurable via user config,
this can be improved later, for now I just update its values in PD
spec defined range.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 670af5c7bc MLK-16013-25 staging: typec: tcpm: correct the PD_T_SENDER_RESPONSE value
Per PD spec, the sender response should be in a small range 24~30ms, so
correct the PD_T_SENDER_RESPONSE to be 25.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 9cd3840e86 MLK-16013-24 staging: typec: tcpm: use hrtimer for send response
As the sender response timer have very small margin(25~30ms), so
use a hrtimer to handle it.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 8e0d4bef56 MLK-16013-23 staging: typec: tcpm: Do soft reset for unexpected get sink cap
A source or sink should receive the get_sink_cap message when in SRC_RDY or
SNK_RDY, if the port receives a get sink capability request before ready,
which means there is message sync error, we should do soft reset to recover
from it, instead of sending a reject message.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 740f03463c MLK-16013-22 staging: typec: tcpm: split operations of power swap from sink to source
Add one more state:PR_SWAP_SNK_SRC_ASSERT_RP, as the next state of
PR_SWAP_SNK_SRC_SINK_OFF, it will turn on vbus and wait the vbus
is really on and then send the PS_RDY to the other side.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun d332e35efc MLK-16013-21 staging: typec: tcpm: handle pd message send failure
If the PD message send failed, we need to do soft reset, further if
soft reset failed, we have to start a hard reset.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun e4c6f14104 MLK-16013-20 staging: typec: Add bist test mode support
BIST(Built In Self-Test – Power Delivery testing mechanism for
the PHY Layer), see PD 3.0 spec 5.9 Built in Self-Test (BIST), is
added to support BIST message handling in PD compliance test.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 772248ed7a MLK-16013-19 staging: typec: tcpci: Only touch target bit when enable vconn
We need a read and then write back to avoid touch any other bits when
enable or disable vconn.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 0b7b017eb7 MLK-16013-18 staging: typec: handle unexpected vbus from sink
Power source detected the attachment of sink, will firstly check
the vbus level to make sure power sink isn't sourcing vbus(< 600mv)
before going forward, otherwise it will terminate the session and
go to SRC_UNATTACHED state, this is required by PD compliance.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 5e217b1604 MLK-16013-17 staging: typec: tcpm: optimise cc toggling for drp port
We should only enable drp auto toggling when unattached, so add one
more parameter; when attached, we set the cc line state according to
the other end cc status.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 9f8e612ad9 MLK-16013-16: staging: typec: tcpm: tcpm init sequence update
Force an error recovery is not a good way to handle all cases and may
break the case of power up with typec already connected. Also the tcpc
init should start after tcpm init setup is done, as tcpc init will
turn on HW event alert so may generate events immediately and drive
tcpm state machine go forward, so move it at the end of tcpm_init.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 2cb98d0029 MLK-16013-15: staging: typec: tcpci: Enable vbus force discharge
Enable vbus low voltage alert and do force discharge, this can aid turn
off vbus quickly.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 8fad7eed21 MLK-16013-14: staging: typec: tcpci: handle fault event
We need clear any fault alerts to make tcpci controller to recover
from fault.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 06261909c1 MLK-16013-13: staging: typec: tcpci: handle rx buffer overflow event
Add rx buffer overflow event handling.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00
Li Jun 0b5a180023 MLK-16013-12: staging: typec: tcpci: clear pending events before request irq
Clear all possible pending events before request irq.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
2018-10-29 11:10:38 +08:00