Merge 4.19.196 into android-4.19-stable
Linux 4.19.196
i2c: robotfuzz-osif: fix control-request directions
nilfs2: fix memory leak in nilfs_sysfs_delete_device_group
pinctrl: stm32: fix the reported number of GPIO lines per bank
net: ll_temac: Avoid ndo_start_xmit returning NETDEV_TX_BUSY
PCI: Add AMD RS690 quirk to enable 64-bit DMA
net: qed: Fix memcpy() overflow of qed_dcbx_params()
KVM: selftests: Fix kvm_check_cap() assertion
r8169: Avoid memcpy() over-reading of ETH_SS_STATS
sh_eth: Avoid memcpy() over-reading of ETH_SS_STATS
* r8152: Avoid memcpy() over-reading of ETH_SS_STATS
drivers/net/usb/r8152.c
* net/packet: annotate accesses to po->ifindex
net/packet/af_packet.c
* net/packet: annotate accesses to po->bind
net/packet/af_packet.c
net: caif: fix memory leak in ldisc_open
* inet: annotate date races around sk->sk_txhash
include/net/sock.h
* ping: Check return value of function 'ping_queue_rcv_skb'
net/ipv4/ping.c
* net: ethtool: clear heap allocations for ethtool function
net/core/ethtool.c
mac80211: drop multicast fragments
* cfg80211: call cfg80211_leave_ocb when switching away from OCB
net/wireless/util.c
mac80211: remove warning in ieee80211_get_sband()
* Revert "PCI: PM: Do not read power state in pci_enable_device_flags()"
drivers/pci/pci.c
MIPS: generic: Update node names to avoid unit addresses
* Makefile: Move -Wno-unused-but-set-variable out of GCC only block
Makefile
ARM: 9081/1: fix gcc-10 thumb2-kernel regression
drm/radeon: wait for moving fence after pinning
drm/nouveau: wait for moving fence after pinning v2
* module: limit enabling module.sig_enforce
kernel/module.c
x86/fpu: Reset state for all signal restore failures
* usb: dwc3: core: fix kernel panic when do reboot
drivers/usb/dwc3/core.c
* usb: dwc3: debugfs: Add and remove endpoint dirs dynamically
drivers/usb/dwc3/debug.h
drivers/usb/dwc3/debugfs.c
drivers/usb/dwc3/gadget.c
* inet: use bigger hash table for IP ID generation
net/ipv4/route.c
can: bcm/raw/isotp: use per module netdevice notifier
KVM: arm/arm64: Fix KVM_VGIC_V3_ADDR_TYPE_REDIST read
tools headers UAPI: Sync linux/in.h copy with the kernel sources
net: fec_ptp: add clock rate zero check
* mm/slub.c: include swab.h
mm/slub.c
* mm/slub: clarify verification reporting
mm/slub.c
net: bridge: fix vlan tunnel dst refcnt when egressing
* net: bridge: fix vlan tunnel dst null pointer dereference
net/bridge/br_private.h
* cfg80211: make certificate generation more robust
net/wireless/Makefile
dmaengine: pl330: fix wrong usage of spinlock flags in dma_cyclc
ARCv2: save ABI registers across signal handling
* PCI: Work around Huawei Intelligent NIC VF FLR erratum
drivers/pci/quirks.c
* PCI: Add ACS quirk for Broadcom BCM57414 NIC
drivers/pci/quirks.c
* PCI: Mark some NVIDIA GPUs to avoid bus reset
drivers/pci/quirks.c
* PCI: Mark TI C667X to avoid bus reset
drivers/pci/quirks.c
* tracing: Do no increment trace_clock_global() by one
kernel/trace/trace_clock.c
* tracing: Do not stop recording comms if the trace file is being read
kernel/trace/trace.c
* tracing: Do not stop recording cmdlines when tracing is off
kernel/trace/trace.c
* usb: core: hub: Disable autosuspend for Cypress CY7C65632
drivers/usb/core/hub.c
can: mcba_usb: fix memory leak in mcba_usb
can: bcm: fix infoleak in struct bcm_msg_head
hwmon: (scpi-hwmon) shows the negative temperature properly
radeon: use memcpy_to/fromio for UVD fw upload
pinctrl: ralink: rt2880: avoid to error in calls is pin is already enabled
ASoC: rt5659: Fix the lost powers for the HDA header
net: ethernet: fix potential use-after-free in ec_bhf_remove
* icmp: don't send out ICMP messages with a source address of 0.0.0.0
include/uapi/linux/in.h
net/ipv4/icmp.c
net: cdc_eem: fix tx fixup skb leak
net: hamradio: fix memory leak in mkiss_close
be2net: Fix an error handling path in 'be_probe()'
* net/af_unix: fix a data-race in unix_dgram_sendmsg / unix_release_sock
net/unix/af_unix.c
* net: ipv4: fix memory leak in ip_mc_add1_src
net/ipv4/igmp.c
net: fec_ptp: fix issue caused by refactor the fec_devtype
net: usb: fix possible use-after-free in smsc75xx_bind
* net: cdc_ncm: switch to eth%d interface naming
drivers/net/usb/cdc_ncm.c
* ptp: improve max_adj check against unreasonable values
drivers/ptp/ptp_clock.c
include/linux/ptp_clock_kernel.h
* ptp: ptp_clock: Publish scaled_ppm_to_ppb
drivers/ptp/ptp_clock.c
include/linux/ptp_clock_kernel.h
* net: qrtr: fix OOB Read in qrtr_endpoint_post
net/qrtr/qrtr.c
netxen_nic: Fix an error handling path in 'netxen_nic_probe()'
qlcnic: Fix an error handling path in 'qlcnic_probe()'
* net: make get_net_ns return error if NET_NS is disabled
include/linux/socket.h
include/net/net_namespace.h
net/core/net_namespace.c
net/socket.c
* net: add documentation to socket.c
include/linux/net.h
include/linux/socket.h
net/socket.c
net: stmmac: dwmac1000: Fix extended MAC address registers definition
alx: Fix an error handling path in 'alx_probe()'
sch_cake: Fix out of bounds when parsing TCP options and header
netfilter: synproxy: Fix out of bounds when parsing TCP options
net/mlx5e: Block offload of outer header csum for UDP tunnels
net/mlx5e: Remove dependency in IPsec initialization flows
* rtnetlink: Fix regression in bridge VLAN configuration
net/core/rtnetlink.c
* udp: fix race between close() and udp_abort()
net/ipv4/udp.c
net/ipv6/udp.c
net: rds: fix memory leak in rds_recvmsg
* net: ipv4: fix memory leak in netlbl_cipsov4_add_std
net/ipv4/cipso_ipv4.c
batman-adv: Avoid WARN_ON timing related checks
mm/memory-failure: make sure wait for page writeback in memory_failure
afs: Fix an IS_ERR() vs NULL check
dmaengine: stedma40: add missing iounmap() on error in d40_probe()
* dmaengine: QCOM_HIDMA_MGMT depends on HAS_IOMEM
drivers/dma/qcom/Kconfig
* dmaengine: ALTERA_MSGDMA depends on HAS_IOMEM
drivers/dma/Kconfig
* fib: Return the correct errno code
net/core/fib_rules.c
* net: Return the correct errno code
net/compat.c
net/x25: Return the correct errno code
* rtnetlink: Fix missing error code in rtnl_bridge_notify()
net/core/rtnetlink.c
* net: ipconfig: Don't override command-line hostnames or domains
net/ipv4/ipconfig.c
nvme-loop: check for NVME_LOOP_Q_LIVE in nvme_loop_destroy_admin_queue()
nvme-loop: clear NVME_LOOP_Q_LIVE when nvme_loop_configure_admin_queue() fails
nvme-loop: reset queue count to 1 in nvme_loop_destroy_io_queues()
* scsi: scsi_devinfo: Add blacklist entry for HPE OPEN-V
drivers/scsi/scsi_devinfo.c
ethernet: myri10ge: Fix missing error code in myri10ge_probe()
scsi: target: core: Fix warning on realtime kernels
gfs2: Fix use-after-free in gfs2_glock_shrink_scan
HID: gt683r: add missing MODULE_DEVICE_TABLE
gfs2: Prevent direct-I/O write fallback errors from getting lost
ARM: OMAP2+: Fix build warning when mmc_omap is not built
* HID: usbhid: fix info leak in hid_submit_ctrl
drivers/hid/usbhid/hid-core.c
include/linux/hid.h
* HID: Add BUS_VIRTUAL to hid_connect logging
drivers/hid/hid-core.c
HID: hid-sensor-hub: Return error for hid_set_field() failure
* HID: quirks: Set INCREMENT_USAGE_ON_DUPLICATE for Saitek X65
drivers/hid/hid-ids.h
drivers/hid/hid-quirks.c
net: ieee802154: fix null deref in parse dev addr
* FROMGIT: bpf: Do not change gso_size during bpf_skb_change_proto()
net/core/filter.c
ANDROID: gki_config: disable per-cgroup pressure tracking
* BACKPORT: cgroup: make per-cgroup pressure stall tracking configurable
include/linux/cgroup-defs.h
include/linux/cgroup.h
kernel/cgroup/cgroup.c
kernel/sched/psi.c
* ANDROID: selinux: modify RTM_GETNEIGH{TBL}
security/selinux/include/classmap.h
security/selinux/include/security.h
security/selinux/nlmsgtab.c
security/selinux/ss/policydb.c
security/selinux/ss/policydb.h
security/selinux/ss/services.c
BACKPORT: x86, lto: Pass -stack-alignment only on LLD < 13.0.0
* ANDROID: Add CONFIG_LLD_VERSION
init/Kconfig
scripts/lld-version.sh
ANDROID: GKI: Update the ABI XML
ANDROID: GKI: Update the symbol list
* Revert "perf/core: Fix endless multiplex timer"
kernel/events/core.c
Merge 4.19.195 into android-4.19-stable
Linux 4.19.195
* proc: only require mm_struct for writing
fs/proc/base.c
* tracing: Correct the length check which causes memory corruption
kernel/trace/trace.c
ftrace: Do not blindly read the ip address in ftrace_bug()
* scsi: core: Only put parent device if host state differs from SHOST_CREATED
drivers/scsi/hosts.c
* scsi: core: Put .shost_dev in failure path if host state changes to RUNNING
drivers/scsi/hosts.c
* scsi: core: Fix error handling of scsi_host_alloc()
drivers/scsi/hosts.c
NFSv4: nfs4_proc_set_acl needs to restore NFS_CAP_UIDGID_NOMAP on error.
NFSv4: Fix second deadlock in nfs4_evict_inode()
NFS: Fix use-after-free in nfs4_init_client()
* kvm: fix previous commit for 32-bit builds
include/linux/kvm_host.h
perf session: Correct buffer copying when peeking events
NFSv4: Fix deadlock between nfs4_evict_inode() and nfs4_opendata_get_inode()
NFS: Fix a potential NULL dereference in nfs_get_client()
IB/mlx5: Fix initializing CQ fragments buffer
* sched/fair: Make sure to update tg contrib for blocked load
kernel/sched/fair.c
* perf: Fix data race between pin_count increment/decrement
kernel/events/core.c
* vmlinux.lds.h: Avoid orphan section with !SMP
include/asm-generic/vmlinux.lds.h
* RDMA/mlx4: Do not map the core_clock page to user space unless enabled
include/linux/mlx4/device.h
regulator: max77620: Use device_set_of_node_from_dev()
* regulator: core: resolve supply for boot-on/always-on regulators
drivers/regulator/core.c
* usb: fix various gadget panics on 10gbps cabling
drivers/usb/gadget/config.c
* usb: fix various gadgets null ptr deref on 10gbps cabling.
drivers/usb/gadget/function/f_hid.c
usb: gadget: eem: fix wrong eem header operation
USB: serial: cp210x: fix alternate function for CP2102N QFN20
USB: serial: quatech2: fix control-request directions
USB: serial: omninet: add device id for Zyxel Omni 56K Plus
USB: serial: ftdi_sio: add NovaTech OrionMX product ID
* usb: gadget: f_fs: Ensure io_completion_wq is idle during unbind
drivers/usb/gadget/function/f_fs.c
usb: typec: ucsi: Clear PPM capability data in ucsi_init() error path
* usb: dwc3: ep0: fix NULL pointer exception
drivers/usb/dwc3/ep0.c
* usb: pd: Set PD_T_SINK_WAIT_CAP to 310ms
include/linux/usb/pd.h
* usb: f_ncm: only first packet of aggregate needs to start timer
drivers/usb/gadget/function/f_ncm.c
* USB: f_ncm: ncm_bitrate (speed) is unsigned
drivers/usb/gadget/function/f_ncm.c
* cgroup1: don't allow '\n' in renaming
kernel/cgroup/cgroup-v1.c
btrfs: return value from btrfs_mark_extent_written() in case of error
staging: rtl8723bs: Fix uninitialized variables
* kvm: avoid speculation-based attacks from out-of-range memslot accesses
include/linux/kvm_host.h
* drm: Lock pointer access in drm_master_release()
drivers/gpu/drm/drm_auth.c
* drm: Fix use-after-free read in drm_getunique()
drivers/gpu/drm/drm_ioctl.c
ARM: dts: imx6q-dhcom: Add PU,VDD1P1,VDD2P5 regulators
ARM: dts: imx6qdl-sabresd: Assign corresponding power supply for LDOs
i2c: mpc: implement erratum A-004447 workaround
i2c: mpc: Make use of i2c_recover_bus()
powerpc/fsl: set fsl,i2c-erratum-a004447 flag for P1010 i2c controllers
powerpc/fsl: set fsl,i2c-erratum-a004447 flag for P2041 i2c controllers
bnx2x: Fix missing error code in bnx2x_iov_init_one()
MIPS: Fix kernel hang under FUNCTION_GRAPH_TRACER and PREEMPT_TRACER
nvme-fabrics: decode host pathing error for connect
net: appletalk: cops: Fix data race in cops_probe1
net: macb: ensure the device is available before accessing GEMGXL control registers
scsi: target: qla2xxx: Wait for stop_phase1 at WWN removal
scsi: vmw_pvscsi: Set correct residual data length
scsi: bnx2fc: Return failure if io_req is already in ABTS processing
RDS tcp loopback connection can hang
net/qla3xxx: fix schedule while atomic in ql_sem_spinlock
* wq: handle VM suspension in stall detection
kernel/workqueue.c
* cgroup: disable controllers at parse time
kernel/cgroup/cgroup.c
* net: mdiobus: get rid of a BUG_ON()
drivers/net/phy/mdio_bus.c
* netlink: disable IRQs for netlink_lock_table()
net/netlink/af_netlink.c
* bonding: init notify_work earlier to avoid uninitialized use
drivers/net/bonding/bond_main.c
isdn: mISDN: netjet: Fix crash in nj_probe:
ASoC: sti-sas: add missing MODULE_DEVICE_TABLE
ASoC: Intel: bytcr_rt5640: Add quirk for the Lenovo Miix 3-830 tablet
ASoC: Intel: bytcr_rt5640: Add quirk for the Glavey TM800A550L tablet
net/nfc/rawsock.c: fix a permission check bug
* proc: Track /proc/$pid/attr/ opener mm_struct
fs/proc/base.c
* perf/core: Fix endless multiplex timer
kernel/events/core.c
* Revert "perf/cgroups: Don't rotate events for cgroups unnecessarily"
include/linux/perf_event.h
kernel/events/core.c
* Revert "perf/core: Fix corner case in perf_rotate_context()"
kernel/events/core.c
Merge 4.19.194 into android-4.19-stable
Linux 4.19.194
xen-pciback: redo VF placement in the virtual topology
* sched/fair: Optimize select_idle_cpu
kernel/sched/fair.c
ACPI: EC: Look for ECDT EC after calling acpi_load_tables()
ACPI: probe ECDT before loading AML tables regardless of module-level code flag
KVM: arm64: Fix debug register indexing
KVM: SVM: Truncate GPR value for DR and CR accesses in !64-bit mode
btrfs: fix unmountable seed device after fstrim
* perf/core: Fix corner case in perf_rotate_context()
kernel/events/core.c
* perf/cgroups: Don't rotate events for cgroups unnecessarily
include/linux/perf_event.h
kernel/events/core.c
bnxt_en: Remove the setting of dev_port.
selftests/bpf: Avoid running unprivileged tests with alignment requirements
selftests/bpf: add "any alignment" annotation for some tests
bpf: Apply F_NEEDS_EFFICIENT_UNALIGNED_ACCESS to more ACCEPT test cases.
bpf: Make more use of 'any' alignment in test_verifier.c
bpf: Adjust F_NEEDS_EFFICIENT_UNALIGNED_ACCESS handling in test_verifier.c
* bpf: Add BPF_F_ANY_ALIGNMENT.
include/uapi/linux/bpf.h
kernel/bpf/syscall.c
kernel/bpf/verifier.c
selftests/bpf: Generalize dummy program types
bpf: test make sure to run unpriv test cases in test_verifier
bpf: fix test suite to enable all unpriv program types
mm, hugetlb: fix simple resv_huge_pages underflow on UFFDIO_COPY
btrfs: fixup error handling in fixup_inode_link_counts
btrfs: return errors from btrfs_del_csums in cleanup_ref_head
btrfs: fix error handling in btrfs_del_csums
btrfs: mark ordered extent and inode with error if we fail to finish
x86/apic: Mark _all_ legacy interrupts when IO/APIC is missing
nfc: fix NULL ptr dereference in llcp_sock_getname() after failed connect
ocfs2: fix data corruption by fallocate
* pid: take a reference when initializing `cad_pid`
init/main.c
usb: dwc2: Fix build in periphal-only mode
* ext4: fix bug on in ext4_es_cache_extent as ext4_split_extent_at failed
fs/ext4/extents.c
ALSA: hda: Fix for mute key LED for HP Pavilion 15-CK0xx
* ALSA: timer: Fix master timer notification
sound/core/timer.c
* HID: multitouch: require Finger field to mark Win8 reports as MT
drivers/hid/hid-multitouch.c
net: caif: fix memory leak in cfusbl_device_notify
net: caif: fix memory leak in caif_device_notify
* net: caif: add proper error handling
include/net/caif/caif_dev.h
include/net/caif/cfcnfg.h
* net: caif: added cfserl_release function
include/net/caif/cfserl.h
* Bluetooth: use correct lock to prevent UAF of hdev object
net/bluetooth/hci_sock.c
* Bluetooth: fix the erroneous flush_work() order
net/bluetooth/hci_core.c
* tipc: fix unique bearer names sanity check
net/tipc/bearer.c
* tipc: add extack messages for bearer/media failure
net/tipc/bearer.c
ixgbevf: add correct exception tracing for XDP
ieee802154: fix error return code in ieee802154_llsec_getparams()
ieee802154: fix error return code in ieee802154_add_iface()
netfilter: nfnetlink_cthelper: hit EBUSY on updates if size mismatches
HID: i2c-hid: fix format string mismatch
HID: pidff: fix error return code in hid_pidff_init()
ipvs: ignore IP_VS_SVC_F_HASHED flag when adding service
vfio/platform: fix module_put call in error flow
samples: vfio-mdev: fix error handing in mdpy_fb_probe()
* vfio/pci: zap_vma_ptes() needs MMU
drivers/vfio/pci/Kconfig
vfio/pci: Fix error return code in vfio_ecap_init()
efi: cper: fix snprintf() use in cper_dimm_err_location()
efi: Allow EFI_MEMORY_XP and EFI_MEMORY_RO both to be cleared
* nl80211: validate key indexes for cfg80211_registered_device
net/wireless/core.h
net/wireless/nl80211.c
net/wireless/util.c
* ALSA: usb: update old-style static const declaration
sound/usb/mixer_quirks.c
* net: usb: cdc_ncm: don't spew notifications
drivers/net/usb/cdc_ncm.c
include/linux/usb/usbnet.h
Merge 4.19.193 into android-4.19-stable
Linux 4.19.193
* usb: core: reduce power-on-good delay time of root hub
drivers/usb/core/hub.h
net: hns3: check the return of skb_checksum_help()
drivers/net/ethernet: clean up unused assignments
* hugetlbfs: hugetlb_fault_mutex_hash() cleanup
include/linux/hugetlb.h
MIPS: ralink: export rt_sysc_membase for rt2880_wdt.c
MIPS: alchemy: xxs1500: add gpio-au1000.h header file
sch_dsmark: fix a NULL deref in qdisc_reset()
* ipv6: record frag_max_size in atomic fragments in input path
net/ipv6/reassembly.c
scsi: libsas: Use _safe() loop in sas_resume_port()
ixgbe: fix large MTU request from VF
* bpf: Set mac_len in bpf_skb_change_head
net/core/filter.c
ASoC: cs35l33: fix an error code in probe()
staging: emxx_udc: fix loop in _nbu2ss_nuke()
* mld: fix panic in mld_newpack()
net/ipv6/mcast.c
net: bnx2: Fix error return code in bnx2_init_board()
openvswitch: meter: fix race when getting now_ms.
net: mdio: octeon: Fix some double free issues
net: mdio: thunder: Fix a double free issue in the .remove function
net: fec: fix the potential memory leak in fec_enet_init()
net: dsa: fix error code getting shifted with 4 in dsa_slave_get_sset_count
net: netcp: Fix an error message
drm/amdgpu: Fix a use-after-free
drm/amd/amdgpu: fix refcount leak
drm/amd/display: Disconnect non-DP with no EDID
SMB3: incorrect file id in requests compounded with open
platform/x86: intel_punit_ipc: Append MODULE_DEVICE_TABLE for ACPI
platform/x86: hp-wireless: add AMD's hardware id to the supported list
btrfs: do not BUG_ON in link_to_fixup_dir
openrisc: Define memory barrier mb
scsi: BusLogic: Fix 64-bit system enumeration error for Buslogic
media: gspca: properly check for errors in po1030_probe()
media: dvb: Add check on sp8870_readreg return
ASoC: cs43130: handle errors in cs43130_probe() properly
libertas: register sysfs groups properly
dmaengine: qcom_hidma: comment platform_driver_register call
isdn: mISDNinfineon: check/cleanup ioremap failure correctly in setup_io
char: hpet: add checks after calling ioremap
net: caif: remove BUG_ON(dev == NULL) in caif_xmit
net: fujitsu: fix potential null-ptr-deref
serial: max310x: unregister uart driver in case of failure and abort
platform/x86: hp_accel: Avoid invoking _INI to speed up resume
perf jevents: Fix getting maximum number of fds
i2c: i801: Don't generate an interrupt on bus reset
i2c: s3c2410: fix possible NULL pointer deref on read message after write
net: dsa: fix a crash if ->get_sset_count() fails
net: dsa: mt7530: fix VLAN traffic leaks
* tipc: skb_linearize the head skb when reassembling msgs
net/tipc/msg.c
* Revert "net:tipc: Fix a double free in tipc_sk_mcast_rcv"
net/tipc/socket.c
net/mlx4: Fix EEPROM dump support
drm/meson: fix shutdown crash when component not probed
NFSv4: Fix v4.0/v4.1 SEEK_DATA return -ENOTSUPP when set NFS_V4_2 config
NFS: Don't corrupt the value of pg_bytes_written in nfs_do_recoalesce()
NFS: fix an incorrect limit in filelayout_decode_layout()
Bluetooth: cmtp: fix file refcount when cmtp_attach_device fails
spi: mt7621: Don't leak SPI master in probe error path
spi: mt7621: Disable clock in probe error path
spi: gpio: Don't leak SPI master in probe error path
* bpf: No need to simulate speculative domain for immediates
kernel/bpf/verifier.c
* bpf: Fix mask direction swap upon off reg sign change
kernel/bpf/verifier.c
* bpf: Wrap aux data inside bpf_sanitize_info container
kernel/bpf/verifier.c
* bpf: Fix leakage of uninitialized bpf stack under speculation
include/linux/bpf_verifier.h
kernel/bpf/verifier.c
bpf: Update selftests to reflect new error states
* bpf: Tighten speculative pointer arithmetic mask
kernel/bpf/verifier.c
* bpf: Move sanitize_val_alu out of op switch
kernel/bpf/verifier.c
* bpf: Refactor and streamline bounds check into helper
kernel/bpf/verifier.c
* bpf: Improve verifier error messages for users
kernel/bpf/verifier.c
* bpf: Rework ptr_limit into alu_limit and add common error path
kernel/bpf/verifier.c
* bpf: Ensure off_reg has no mixed signed bounds for all types
kernel/bpf/verifier.c
* bpf: Move off_reg into sanitize_ptr_alu
kernel/bpf/verifier.c
bpf, test_verifier: switch bpf_get_stack's 0 s> r8 test
bpf: Test_verifier, bpf_get_stack return value add <0
* bpf: extend is_branch_taken to registers
kernel/bpf/verifier.c
selftests/bpf: add selftest part of "bpf: improve verifier branch analysis"
selftests/bpf: Test narrow loads with off > 0 in test_verifier
bpf, selftests: Fix up some test_verifier cases for unprivileged
bpf: fix up selftests after backports were fixed
net: usb: fix memory leak in smsc75xx_bind
usb: gadget: udc: renesas_usb3: Fix a race in usb3_start_pipen()
* usb: dwc3: gadget: Properly track pending and queued SG
drivers/usb/dwc3/gadget.c
USB: serial: pl2303: add device id for ADLINK ND-6530 GC
USB: serial: ftdi_sio: add IDs for IDS GmbH Products
USB: serial: option: add Telit LE910-S1 compositions 0x7010, 0x7011
USB: serial: ti_usb_3410_5052: add startech.com device id
serial: rp2: use 'request_firmware' instead of 'request_firmware_nowait'
serial: sh-sci: Fix off-by-one error in FIFO threshold register setting
* USB: usbfs: Don't WARN about excessively large memory allocations
drivers/usb/core/devio.c
USB: trancevibrator: fix control-request direction
iio: adc: ad7793: Add missing error code in ad7793_setup()
staging: iio: cdc: ad7746: avoid overwrite of num_channels
mei: request autosuspend after sending rx flow control
thunderbolt: dma_port: Fix NVM read buffer bounds and offset issue
misc/uss720: fix memory leak in uss720_probe
kgdb: fix gcc-11 warnings harder
* dm snapshot: properly fix a crash when an origin has no snapshots
drivers/md/dm-snap.c
ath10k: Validate first subframe of A-MSDU before processing the list
mac80211: extend protection against mixed key and fragment cache attacks
mac80211: do not accept/forward invalid EAPOL frames
mac80211: prevent attacks on TKIP/WEP as well
mac80211: check defrag PN against current frame
mac80211: add fragment cache to sta_info
mac80211: drop A-MSDUs on old ciphers
* cfg80211: mitigate A-MSDU aggregation attacks
net/wireless/util.c
* mac80211: properly handle A-MSDUs that start with an RFC 1042 header
include/net/cfg80211.h
net/wireless/util.c
mac80211: prevent mixed key and fragment cache attacks
mac80211: assure all fragments are encrypted
net: hso: fix control-request directions
* proc: Check /proc/$pid/attr/ writes against file opener
fs/proc/base.c
perf intel-pt: Fix transaction abort handling
perf intel-pt: Fix sample instruction bytes
iommu/vt-d: Fix sysfs leak in alloc_iommu()
NFSv4: Fix a NULL pointer dereference in pnfs_mark_matching_lsegs_return()
cifs: set server->cipher_type to AES-128-CCM for SMB3.0
* NFC: nci: fix memory leak in nci_allocate_device
include/net/nfc/nci_core.h
* usb: dwc3: gadget: Enable suspend events
drivers/usb/dwc3/gadget.c
* mm, vmstat: drop zone->lock in /proc/pagetypeinfo
mm/vmstat.c
Merge 4.19.192 into android-4.19-stable
* Revert "spi: Fix use-after-free with devm_spi_alloc_*"
drivers/spi/spi.c
include/linux/spi/spi.h
* Revert "modules: inherit TAINT_PROPRIETARY_MODULE"
include/linux/module.h
kernel/module.c
Linux 4.19.192
* Bluetooth: SMP: Fail if remote and local public keys are identical
net/bluetooth/smp.c
video: hgafb: correctly handle card detect failure during probe
tty: vt: always invoke vc->vc_sw->con_resize callback
* vt: Fix character height handling with VT_RESIZEX
include/linux/console_struct.h
vgacon: Record video mode changes with VT_RESIZEX
video: hgafb: fix potential NULL pointer dereference
qlcnic: Add null check after calling netdev_alloc_skb
leds: lp5523: check return value of lp5xx_read and jump to cleanup code
net: rtlwifi: properly check for alloc_workqueue() failure
scsi: ufs: handle cleanup correctly on devm_reset_control_get error
net: stmicro: handle clk_prepare() failure during init
ethernet: sun: niu: fix missing checks of niu_pci_eeprom_read()
Revert "niu: fix missing checks of niu_pci_eeprom_read"
Revert "qlcnic: Avoid potential NULL pointer dereference"
Revert "rtlwifi: fix a potential NULL pointer dereference"
Revert "media: rcar_drif: fix a memory disclosure"
cdrom: gdrom: initialize global variable at init time
cdrom: gdrom: deallocate struct gdrom_unit fields in remove_gdrom
Revert "gdrom: fix a memory leak bug"
Revert "scsi: ufs: fix a missing check of devm_reset_control_get"
* Revert "ecryptfs: replace BUG_ON with error handling code"
fs/ecryptfs/crypto.c
Revert "video: imsttfb: fix potential NULL pointer dereferences"
Revert "hwmon: (lm80) fix a missing check of bus read in lm80 probe"
Revert "leds: lp5523: fix a missing check of return value of lp55xx_read"
Revert "net: stmicro: fix a missing check of clk_prepare"
Revert "video: hgafb: fix potential NULL pointer dereference"
* dm snapshot: fix crash with transient storage and zero chunk size
drivers/md/dm-snap.c
xen-pciback: reconfigure also from backend watch handler
Revert "serial: mvebu-uart: Fix to avoid a potential NULL pointer dereference"
rapidio: handle create_workqueue() failure
Revert "rapidio: fix a NULL pointer dereference when create_workqueue() fails"
ALSA: hda/realtek: Add some CLOVE SSIDs of ALC293
ALSA: hda/realtek: reset eapd coeff to default value for alc287
Revert "ALSA: sb8: add a check for request_region"
* ALSA: bebob/oxfw: fix Kconfig entry for Mackie d.2 Pro
sound/firewire/Kconfig
* ALSA: usb-audio: Validate MS endpoint descriptors
sound/usb/midi.c
ALSA: dice: fix stream format at middle sampling rate for Alesis iO 26
ALSA: line6: Fix racy initialization of LINE6 MIDI
ALSA: dice: fix stream format for TC Electronic Konnekt Live at high sampling transfer frequency
cifs: fix memory leak in smb2_copychunk_range
* locking/mutex: clear MUTEX_FLAGS if wait_list is empty due to signal
kernel/locking/mutex.c
kernel/locking/mutex.h
nvmet: seset ns->file when open fails
* ptrace: make ptrace() fail if the tracee changed its pid unexpectedly
kernel/ptrace.c
platform/x86: dell-smbios-wmi: Fix oops on rmmod dell_smbios
RDMA/mlx5: Recover from fatal event in dual port mode
scsi: qla2xxx: Fix error return code in qla82xx_write_flash_dword()
RDMA/rxe: Clear all QP fields if creation failed
openrisc: Fix a memory leak
firmware: arm_scpi: Prevent the ternary sign expansion bug
Bug: 192919066
Change-Id: I94d2e40c5024fc0f1b6fac206b04c73765df4cb0
Signed-off-by: Lucas Wei <lucaswei@google.com>
478 lines
14 KiB
C
478 lines
14 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* Copyright 2015-2017 Google, Inc
|
|
*/
|
|
|
|
#ifndef __LINUX_USB_PD_H
|
|
#define __LINUX_USB_PD_H
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/types.h>
|
|
#include <linux/usb/typec.h>
|
|
|
|
/* USB PD Messages */
|
|
enum pd_ctrl_msg_type {
|
|
/* 0 Reserved */
|
|
PD_CTRL_GOOD_CRC = 1,
|
|
PD_CTRL_GOTO_MIN = 2,
|
|
PD_CTRL_ACCEPT = 3,
|
|
PD_CTRL_REJECT = 4,
|
|
PD_CTRL_PING = 5,
|
|
PD_CTRL_PS_RDY = 6,
|
|
PD_CTRL_GET_SOURCE_CAP = 7,
|
|
PD_CTRL_GET_SINK_CAP = 8,
|
|
PD_CTRL_DR_SWAP = 9,
|
|
PD_CTRL_PR_SWAP = 10,
|
|
PD_CTRL_VCONN_SWAP = 11,
|
|
PD_CTRL_WAIT = 12,
|
|
PD_CTRL_SOFT_RESET = 13,
|
|
/* 14-15 Reserved */
|
|
PD_CTRL_NOT_SUPP = 16,
|
|
PD_CTRL_GET_SOURCE_CAP_EXT = 17,
|
|
PD_CTRL_GET_STATUS = 18,
|
|
PD_CTRL_FR_SWAP = 19,
|
|
PD_CTRL_GET_PPS_STATUS = 20,
|
|
PD_CTRL_GET_COUNTRY_CODES = 21,
|
|
/* 22-31 Reserved */
|
|
};
|
|
|
|
enum pd_data_msg_type {
|
|
/* 0 Reserved */
|
|
PD_DATA_SOURCE_CAP = 1,
|
|
PD_DATA_REQUEST = 2,
|
|
PD_DATA_BIST = 3,
|
|
PD_DATA_SINK_CAP = 4,
|
|
PD_DATA_BATT_STATUS = 5,
|
|
PD_DATA_ALERT = 6,
|
|
PD_DATA_GET_COUNTRY_INFO = 7,
|
|
/* 8-14 Reserved */
|
|
PD_DATA_VENDOR_DEF = 15,
|
|
/* 16-31 Reserved */
|
|
};
|
|
|
|
enum pd_ext_msg_type {
|
|
/* 0 Reserved */
|
|
PD_EXT_SOURCE_CAP_EXT = 1,
|
|
PD_EXT_STATUS = 2,
|
|
PD_EXT_GET_BATT_CAP = 3,
|
|
PD_EXT_GET_BATT_STATUS = 4,
|
|
PD_EXT_BATT_CAP = 5,
|
|
PD_EXT_GET_MANUFACTURER_INFO = 6,
|
|
PD_EXT_MANUFACTURER_INFO = 7,
|
|
PD_EXT_SECURITY_REQUEST = 8,
|
|
PD_EXT_SECURITY_RESPONSE = 9,
|
|
PD_EXT_FW_UPDATE_REQUEST = 10,
|
|
PD_EXT_FW_UPDATE_RESPONSE = 11,
|
|
PD_EXT_PPS_STATUS = 12,
|
|
PD_EXT_COUNTRY_INFO = 13,
|
|
PD_EXT_COUNTRY_CODES = 14,
|
|
/* 15-31 Reserved */
|
|
};
|
|
|
|
#define PD_REV10 0x0
|
|
#define PD_REV20 0x1
|
|
#define PD_REV30 0x2
|
|
#define PD_MAX_REV PD_REV30
|
|
|
|
#define PD_HEADER_EXT_HDR BIT(15)
|
|
#define PD_HEADER_CNT_SHIFT 12
|
|
#define PD_HEADER_CNT_MASK 0x7
|
|
#define PD_HEADER_ID_SHIFT 9
|
|
#define PD_HEADER_ID_MASK 0x7
|
|
#define PD_HEADER_PWR_ROLE BIT(8)
|
|
#define PD_HEADER_REV_SHIFT 6
|
|
#define PD_HEADER_REV_MASK 0x3
|
|
#define PD_HEADER_DATA_ROLE BIT(5)
|
|
#define PD_HEADER_TYPE_SHIFT 0
|
|
#define PD_HEADER_TYPE_MASK 0x1f
|
|
|
|
#define PD_HEADER(type, pwr, data, rev, id, cnt, ext_hdr) \
|
|
((((type) & PD_HEADER_TYPE_MASK) << PD_HEADER_TYPE_SHIFT) | \
|
|
((pwr) == TYPEC_SOURCE ? PD_HEADER_PWR_ROLE : 0) | \
|
|
((data) == TYPEC_HOST ? PD_HEADER_DATA_ROLE : 0) | \
|
|
(rev << PD_HEADER_REV_SHIFT) | \
|
|
(((id) & PD_HEADER_ID_MASK) << PD_HEADER_ID_SHIFT) | \
|
|
(((cnt) & PD_HEADER_CNT_MASK) << PD_HEADER_CNT_SHIFT) | \
|
|
((ext_hdr) ? PD_HEADER_EXT_HDR : 0))
|
|
|
|
#define PD_HEADER_LE(type, pwr, data, rev, id, cnt, ext_hdr) \
|
|
cpu_to_le16(PD_HEADER((type), (pwr), (data), (rev), (id), (cnt),\
|
|
(ext_hdr)))
|
|
|
|
#define PD_HEADER_SOP_PRIME(type, id, cnt, rev) \
|
|
((((type) & PD_HEADER_TYPE_MASK) << PD_HEADER_TYPE_SHIFT) | \
|
|
(rev << PD_HEADER_REV_SHIFT) | \
|
|
(((id) & PD_HEADER_ID_MASK) << PD_HEADER_ID_SHIFT) | \
|
|
(((cnt) & PD_HEADER_CNT_MASK) << PD_HEADER_CNT_SHIFT))
|
|
|
|
#define PD_HEADER_SOP_PRIME_LE(type, id, cnt, rev) \
|
|
cpu_to_le16(PD_HEADER_SOP_PRIME((type), (id), (cnt), (rev)))
|
|
|
|
|
|
static inline unsigned int pd_header_cnt(u16 header)
|
|
{
|
|
return (header >> PD_HEADER_CNT_SHIFT) & PD_HEADER_CNT_MASK;
|
|
}
|
|
|
|
static inline unsigned int pd_header_cnt_le(__le16 header)
|
|
{
|
|
return pd_header_cnt(le16_to_cpu(header));
|
|
}
|
|
|
|
static inline unsigned int pd_header_type(u16 header)
|
|
{
|
|
return (header >> PD_HEADER_TYPE_SHIFT) & PD_HEADER_TYPE_MASK;
|
|
}
|
|
|
|
static inline unsigned int pd_header_type_le(__le16 header)
|
|
{
|
|
return pd_header_type(le16_to_cpu(header));
|
|
}
|
|
|
|
static inline unsigned int pd_header_msgid(u16 header)
|
|
{
|
|
return (header >> PD_HEADER_ID_SHIFT) & PD_HEADER_ID_MASK;
|
|
}
|
|
|
|
static inline unsigned int pd_header_msgid_le(__le16 header)
|
|
{
|
|
return pd_header_msgid(le16_to_cpu(header));
|
|
}
|
|
|
|
static inline unsigned int pd_header_rev(u16 header)
|
|
{
|
|
return (header >> PD_HEADER_REV_SHIFT) & PD_HEADER_REV_MASK;
|
|
}
|
|
|
|
static inline unsigned int pd_header_rev_le(__le16 header)
|
|
{
|
|
return pd_header_rev(le16_to_cpu(header));
|
|
}
|
|
|
|
#define PD_EXT_HDR_CHUNKED BIT(15)
|
|
#define PD_EXT_HDR_CHUNK_NUM_SHIFT 11
|
|
#define PD_EXT_HDR_CHUNK_NUM_MASK 0xf
|
|
#define PD_EXT_HDR_REQ_CHUNK BIT(10)
|
|
#define PD_EXT_HDR_DATA_SIZE_SHIFT 0
|
|
#define PD_EXT_HDR_DATA_SIZE_MASK 0x1ff
|
|
|
|
#define PD_EXT_HDR(data_size, req_chunk, chunk_num, chunked) \
|
|
((((data_size) & PD_EXT_HDR_DATA_SIZE_MASK) << PD_EXT_HDR_DATA_SIZE_SHIFT) | \
|
|
((req_chunk) ? PD_EXT_HDR_REQ_CHUNK : 0) | \
|
|
(((chunk_num) & PD_EXT_HDR_CHUNK_NUM_MASK) << PD_EXT_HDR_CHUNK_NUM_SHIFT) | \
|
|
((chunked) ? PD_EXT_HDR_CHUNKED : 0))
|
|
|
|
#define PD_EXT_HDR_LE(data_size, req_chunk, chunk_num, chunked) \
|
|
cpu_to_le16(PD_EXT_HDR((data_size), (req_chunk), (chunk_num), (chunked)))
|
|
|
|
static inline unsigned int pd_ext_header_chunk_num(u16 ext_header)
|
|
{
|
|
return (ext_header >> PD_EXT_HDR_CHUNK_NUM_SHIFT) &
|
|
PD_EXT_HDR_CHUNK_NUM_MASK;
|
|
}
|
|
|
|
static inline unsigned int pd_ext_header_data_size(u16 ext_header)
|
|
{
|
|
return (ext_header >> PD_EXT_HDR_DATA_SIZE_SHIFT) &
|
|
PD_EXT_HDR_DATA_SIZE_MASK;
|
|
}
|
|
|
|
static inline unsigned int pd_ext_header_data_size_le(__le16 ext_header)
|
|
{
|
|
return pd_ext_header_data_size(le16_to_cpu(ext_header));
|
|
}
|
|
|
|
#define PD_MAX_PAYLOAD 7
|
|
#define PD_EXT_MAX_CHUNK_DATA 26
|
|
#define PD_MAX_EXT_MSG_LEN 260
|
|
|
|
/**
|
|
* struct pd_chunked_ext_message_data - PD chunked extended message data as
|
|
* seen on wire
|
|
* @header: PD extended message header
|
|
* @data: PD extended message data
|
|
*/
|
|
struct pd_chunked_ext_message_data {
|
|
__le16 header;
|
|
u8 data[PD_EXT_MAX_CHUNK_DATA];
|
|
} __packed;
|
|
|
|
/**
|
|
* struct pd_message - PD message as seen on wire
|
|
* @header: PD message header
|
|
* @payload: PD message payload
|
|
* @ext_msg: PD message chunked extended message data
|
|
*/
|
|
struct pd_message {
|
|
__le16 header;
|
|
union {
|
|
__le32 payload[PD_MAX_PAYLOAD];
|
|
struct pd_chunked_ext_message_data ext_msg;
|
|
};
|
|
} __packed;
|
|
|
|
/* PDO: Power Data Object */
|
|
#define PDO_MAX_OBJECTS 7
|
|
|
|
enum pd_pdo_type {
|
|
PDO_TYPE_FIXED = 0,
|
|
PDO_TYPE_BATT = 1,
|
|
PDO_TYPE_VAR = 2,
|
|
PDO_TYPE_APDO = 3,
|
|
};
|
|
|
|
#define PDO_TYPE_SHIFT 30
|
|
#define PDO_TYPE_MASK 0x3
|
|
|
|
#define PDO_TYPE(t) ((t) << PDO_TYPE_SHIFT)
|
|
|
|
#define PDO_VOLT_MASK 0x3ff
|
|
#define PDO_CURR_MASK 0x3ff
|
|
#define PDO_PWR_MASK 0x3ff
|
|
|
|
#define PDO_FIXED_DUAL_ROLE BIT(29) /* Power role swap supported */
|
|
#define PDO_FIXED_SUSPEND BIT(28) /* USB Suspend supported (Source) */
|
|
#define PDO_FIXED_HIGHER_CAP BIT(28) /* Requires more than vSafe5V (Sink) */
|
|
#define PDO_FIXED_EXTPOWER BIT(27) /* Externally powered */
|
|
#define PDO_FIXED_USB_COMM BIT(26) /* USB communications capable */
|
|
#define PDO_FIXED_DATA_SWAP BIT(25) /* Data role swap supported */
|
|
#define PDO_FIXED_UNCHUNK_EXT BIT(24) /* Unchunked Ext. Msg. supp (Source) */
|
|
#define PDO_FIXED_FRS_CURR_MASK (BIT(24) | BIT(23)) /* FR_Swap Current (Sink) */
|
|
#define PDO_FIXED_VOLT_SHIFT 10 /* 50mV units */
|
|
#define PDO_FIXED_CURR_SHIFT 0 /* 10mA units */
|
|
|
|
#define PDO_FIXED_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_FIXED_VOLT_SHIFT)
|
|
#define PDO_FIXED_CURR(ma) ((((ma) / 10) & PDO_CURR_MASK) << PDO_FIXED_CURR_SHIFT)
|
|
|
|
#define PDO_FIXED(mv, ma, flags) \
|
|
(PDO_TYPE(PDO_TYPE_FIXED) | (flags) | \
|
|
PDO_FIXED_VOLT(mv) | PDO_FIXED_CURR(ma))
|
|
|
|
#define VSAFE5V 5000 /* mv units */
|
|
|
|
#define PDO_BATT_MAX_VOLT_SHIFT 20 /* 50mV units */
|
|
#define PDO_BATT_MIN_VOLT_SHIFT 10 /* 50mV units */
|
|
#define PDO_BATT_MAX_PWR_SHIFT 0 /* 250mW units */
|
|
|
|
#define PDO_BATT_MIN_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MIN_VOLT_SHIFT)
|
|
#define PDO_BATT_MAX_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MAX_VOLT_SHIFT)
|
|
#define PDO_BATT_MAX_POWER(mw) ((((mw) / 250) & PDO_PWR_MASK) << PDO_BATT_MAX_PWR_SHIFT)
|
|
|
|
#define PDO_BATT(min_mv, max_mv, max_mw) \
|
|
(PDO_TYPE(PDO_TYPE_BATT) | PDO_BATT_MIN_VOLT(min_mv) | \
|
|
PDO_BATT_MAX_VOLT(max_mv) | PDO_BATT_MAX_POWER(max_mw))
|
|
|
|
#define PDO_VAR_MAX_VOLT_SHIFT 20 /* 50mV units */
|
|
#define PDO_VAR_MIN_VOLT_SHIFT 10 /* 50mV units */
|
|
#define PDO_VAR_MAX_CURR_SHIFT 0 /* 10mA units */
|
|
|
|
#define PDO_VAR_MIN_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MIN_VOLT_SHIFT)
|
|
#define PDO_VAR_MAX_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MAX_VOLT_SHIFT)
|
|
#define PDO_VAR_MAX_CURR(ma) ((((ma) / 10) & PDO_CURR_MASK) << PDO_VAR_MAX_CURR_SHIFT)
|
|
|
|
#define PDO_VAR(min_mv, max_mv, max_ma) \
|
|
(PDO_TYPE(PDO_TYPE_VAR) | PDO_VAR_MIN_VOLT(min_mv) | \
|
|
PDO_VAR_MAX_VOLT(max_mv) | PDO_VAR_MAX_CURR(max_ma))
|
|
|
|
enum pd_apdo_type {
|
|
APDO_TYPE_PPS = 0,
|
|
};
|
|
|
|
#define PDO_APDO_TYPE_SHIFT 28 /* Only valid value currently is 0x0 - PPS */
|
|
#define PDO_APDO_TYPE_MASK 0x3
|
|
|
|
#define PDO_APDO_TYPE(t) ((t) << PDO_APDO_TYPE_SHIFT)
|
|
|
|
#define PDO_PPS_APDO_MAX_VOLT_SHIFT 17 /* 100mV units */
|
|
#define PDO_PPS_APDO_MIN_VOLT_SHIFT 8 /* 100mV units */
|
|
#define PDO_PPS_APDO_MAX_CURR_SHIFT 0 /* 50mA units */
|
|
|
|
#define PDO_PPS_APDO_VOLT_MASK 0xff
|
|
#define PDO_PPS_APDO_CURR_MASK 0x7f
|
|
|
|
#define PDO_PPS_APDO_MIN_VOLT(mv) \
|
|
((((mv) / 100) & PDO_PPS_APDO_VOLT_MASK) << PDO_PPS_APDO_MIN_VOLT_SHIFT)
|
|
#define PDO_PPS_APDO_MAX_VOLT(mv) \
|
|
((((mv) / 100) & PDO_PPS_APDO_VOLT_MASK) << PDO_PPS_APDO_MAX_VOLT_SHIFT)
|
|
#define PDO_PPS_APDO_MAX_CURR(ma) \
|
|
((((ma) / 50) & PDO_PPS_APDO_CURR_MASK) << PDO_PPS_APDO_MAX_CURR_SHIFT)
|
|
|
|
#define PDO_PPS_APDO(min_mv, max_mv, max_ma) \
|
|
(PDO_TYPE(PDO_TYPE_APDO) | PDO_APDO_TYPE(APDO_TYPE_PPS) | \
|
|
PDO_PPS_APDO_MIN_VOLT(min_mv) | PDO_PPS_APDO_MAX_VOLT(max_mv) | \
|
|
PDO_PPS_APDO_MAX_CURR(max_ma))
|
|
|
|
static inline enum pd_pdo_type pdo_type(u32 pdo)
|
|
{
|
|
return (pdo >> PDO_TYPE_SHIFT) & PDO_TYPE_MASK;
|
|
}
|
|
|
|
static inline unsigned int pdo_fixed_voltage(u32 pdo)
|
|
{
|
|
return ((pdo >> PDO_FIXED_VOLT_SHIFT) & PDO_VOLT_MASK) * 50;
|
|
}
|
|
|
|
static inline unsigned int pdo_min_voltage(u32 pdo)
|
|
{
|
|
return ((pdo >> PDO_VAR_MIN_VOLT_SHIFT) & PDO_VOLT_MASK) * 50;
|
|
}
|
|
|
|
static inline unsigned int pdo_max_voltage(u32 pdo)
|
|
{
|
|
return ((pdo >> PDO_VAR_MAX_VOLT_SHIFT) & PDO_VOLT_MASK) * 50;
|
|
}
|
|
|
|
static inline unsigned int pdo_max_current(u32 pdo)
|
|
{
|
|
return ((pdo >> PDO_VAR_MAX_CURR_SHIFT) & PDO_CURR_MASK) * 10;
|
|
}
|
|
|
|
static inline unsigned int pdo_max_power(u32 pdo)
|
|
{
|
|
return ((pdo >> PDO_BATT_MAX_PWR_SHIFT) & PDO_PWR_MASK) * 250;
|
|
}
|
|
|
|
static inline enum pd_apdo_type pdo_apdo_type(u32 pdo)
|
|
{
|
|
return (pdo >> PDO_APDO_TYPE_SHIFT) & PDO_APDO_TYPE_MASK;
|
|
}
|
|
|
|
static inline unsigned int pdo_pps_apdo_min_voltage(u32 pdo)
|
|
{
|
|
return ((pdo >> PDO_PPS_APDO_MIN_VOLT_SHIFT) &
|
|
PDO_PPS_APDO_VOLT_MASK) * 100;
|
|
}
|
|
|
|
static inline unsigned int pdo_pps_apdo_max_voltage(u32 pdo)
|
|
{
|
|
return ((pdo >> PDO_PPS_APDO_MAX_VOLT_SHIFT) &
|
|
PDO_PPS_APDO_VOLT_MASK) * 100;
|
|
}
|
|
|
|
static inline unsigned int pdo_pps_apdo_max_current(u32 pdo)
|
|
{
|
|
return ((pdo >> PDO_PPS_APDO_MAX_CURR_SHIFT) &
|
|
PDO_PPS_APDO_CURR_MASK) * 50;
|
|
}
|
|
|
|
/* RDO: Request Data Object */
|
|
#define RDO_OBJ_POS_SHIFT 28
|
|
#define RDO_OBJ_POS_MASK 0x7
|
|
#define RDO_GIVE_BACK BIT(27) /* Supports reduced operating current */
|
|
#define RDO_CAP_MISMATCH BIT(26) /* Not satisfied by source caps */
|
|
#define RDO_USB_COMM BIT(25) /* USB communications capable */
|
|
#define RDO_NO_SUSPEND BIT(24) /* USB Suspend not supported */
|
|
|
|
#define RDO_PWR_MASK 0x3ff
|
|
#define RDO_CURR_MASK 0x3ff
|
|
|
|
#define RDO_FIXED_OP_CURR_SHIFT 10
|
|
#define RDO_FIXED_MAX_CURR_SHIFT 0
|
|
|
|
#define RDO_OBJ(idx) (((idx) & RDO_OBJ_POS_MASK) << RDO_OBJ_POS_SHIFT)
|
|
|
|
#define PDO_FIXED_OP_CURR(ma) ((((ma) / 10) & RDO_CURR_MASK) << RDO_FIXED_OP_CURR_SHIFT)
|
|
#define PDO_FIXED_MAX_CURR(ma) ((((ma) / 10) & RDO_CURR_MASK) << RDO_FIXED_MAX_CURR_SHIFT)
|
|
|
|
#define RDO_FIXED(idx, op_ma, max_ma, flags) \
|
|
(RDO_OBJ(idx) | (flags) | \
|
|
PDO_FIXED_OP_CURR(op_ma) | PDO_FIXED_MAX_CURR(max_ma))
|
|
|
|
#define RDO_BATT_OP_PWR_SHIFT 10 /* 250mW units */
|
|
#define RDO_BATT_MAX_PWR_SHIFT 0 /* 250mW units */
|
|
|
|
#define RDO_BATT_OP_PWR(mw) ((((mw) / 250) & RDO_PWR_MASK) << RDO_BATT_OP_PWR_SHIFT)
|
|
#define RDO_BATT_MAX_PWR(mw) ((((mw) / 250) & RDO_PWR_MASK) << RDO_BATT_MAX_PWR_SHIFT)
|
|
|
|
#define RDO_BATT(idx, op_mw, max_mw, flags) \
|
|
(RDO_OBJ(idx) | (flags) | \
|
|
RDO_BATT_OP_PWR(op_mw) | RDO_BATT_MAX_PWR(max_mw))
|
|
|
|
#define RDO_PROG_VOLT_MASK 0x7ff
|
|
#define RDO_PROG_CURR_MASK 0x7f
|
|
|
|
#define RDO_PROG_VOLT_SHIFT 9
|
|
#define RDO_PROG_CURR_SHIFT 0
|
|
|
|
#define RDO_PROG_VOLT_MV_STEP 20
|
|
#define RDO_PROG_CURR_MA_STEP 50
|
|
|
|
#define PDO_PROG_OUT_VOLT(mv) \
|
|
((((mv) / RDO_PROG_VOLT_MV_STEP) & RDO_PROG_VOLT_MASK) << RDO_PROG_VOLT_SHIFT)
|
|
#define PDO_PROG_OP_CURR(ma) \
|
|
((((ma) / RDO_PROG_CURR_MA_STEP) & RDO_PROG_CURR_MASK) << RDO_PROG_CURR_SHIFT)
|
|
|
|
#define RDO_PROG(idx, out_mv, op_ma, flags) \
|
|
(RDO_OBJ(idx) | (flags) | \
|
|
PDO_PROG_OUT_VOLT(out_mv) | PDO_PROG_OP_CURR(op_ma))
|
|
|
|
static inline unsigned int rdo_index(u32 rdo)
|
|
{
|
|
return (rdo >> RDO_OBJ_POS_SHIFT) & RDO_OBJ_POS_MASK;
|
|
}
|
|
|
|
static inline unsigned int rdo_op_current(u32 rdo)
|
|
{
|
|
return ((rdo >> RDO_FIXED_OP_CURR_SHIFT) & RDO_CURR_MASK) * 10;
|
|
}
|
|
|
|
static inline unsigned int rdo_max_current(u32 rdo)
|
|
{
|
|
return ((rdo >> RDO_FIXED_MAX_CURR_SHIFT) &
|
|
RDO_CURR_MASK) * 10;
|
|
}
|
|
|
|
static inline unsigned int rdo_op_power(u32 rdo)
|
|
{
|
|
return ((rdo >> RDO_BATT_OP_PWR_SHIFT) & RDO_PWR_MASK) * 250;
|
|
}
|
|
|
|
static inline unsigned int rdo_max_power(u32 rdo)
|
|
{
|
|
return ((rdo >> RDO_BATT_MAX_PWR_SHIFT) & RDO_PWR_MASK) * 250;
|
|
}
|
|
|
|
/* USB PD timers and counters */
|
|
#define PD_T_NO_RESPONSE 5000 /* 4.5 - 5.5 seconds */
|
|
#define PD_T_DB_DETECT 10000 /* 10 - 15 seconds */
|
|
#define PD_T_SEND_SOURCE_CAP 150 /* 100 - 200 ms */
|
|
#define PD_T_SENDER_RESPONSE 60 /* 24 - 30 ms, relaxed */
|
|
#define PD_T_SOURCE_ACTIVITY 45
|
|
#define PD_T_SINK_ACTIVITY 135
|
|
#define PD_T_SINK_WAIT_CAP 310 /* 310 - 620 ms */
|
|
#define PD_T_PS_TRANSITION 500
|
|
#define PD_T_SRC_TRANSITION 35
|
|
#define PD_T_DRP_SNK 40
|
|
#define PD_T_DRP_SRC 30
|
|
#define PD_T_PS_SOURCE_OFF 920
|
|
#define PD_T_PS_SOURCE_ON 480
|
|
#define PD_T_PS_SOURCE_ON_PRS 450 /* 390 - 480ms */
|
|
#define PD_T_PS_HARD_RESET 30
|
|
#define PD_T_SRC_RECOVER 760
|
|
#define PD_T_SRC_RECOVER_MAX 1000
|
|
#define PD_T_SRC_TURN_ON 275
|
|
#define PD_T_SAFE_0V 650
|
|
#define PD_T_VCONN_SOURCE_ON 100
|
|
#define PD_T_SINK_REQUEST 100 /* 100 ms minimum */
|
|
#define PD_T_ERROR_RECOVERY 100 /* minimum 25 is insufficient */
|
|
#define PD_T_SRCSWAPSTDBY 625 /* Maximum of 650ms */
|
|
#define PD_T_NEWSRC 250 /* Maximum of 275ms */
|
|
#define PD_T_SINK_TX 16 /* 16 - 20 ms */
|
|
#define PD_T_CHUNK_NOT_SUPP 42 /* 40 - 50 ms */
|
|
#define PD_T_CHUNK_SENDER_RESPONSE 30 /* 24 - 30 ms */
|
|
#define PD_T_CHUNK_SENDER_REQUEST 30 /* 24 - 30 ms */
|
|
#define PD_T_SWAP_SRC_START 20 /* Minimum of 20ms */
|
|
|
|
#define PD_T_DRP_TRY 100 /* 75 - 150 ms */
|
|
#define PD_T_DRP_TRYWAIT 600 /* 400 - 800 ms */
|
|
|
|
#define PD_T_CC_DEBOUNCE 200 /* 100 - 200 ms */
|
|
#define PD_T_PD_DEBOUNCE 20 /* 10 - 20 ms */
|
|
|
|
#define PD_N_CAPS_COUNT (PD_T_NO_RESPONSE / PD_T_SEND_SOURCE_CAP)
|
|
#define PD_N_HARD_RESET_COUNT 2
|
|
|
|
#define PD_P_SNK_STDBY_5V 500 /* 2500 mw - 500mA @ 5V */
|
|
#define PD_P_SNK_STDBY 2500 /* 2500 mW */
|
|
#endif /* __LINUX_USB_PD_H */
|