diff options
| -rw-r--r-- | Documentation/devicetree/bindings/staging/ion/hi6220-ion.txt | 31 | ||||
| -rw-r--r-- | MAINTAINERS | 11 | ||||
| -rw-r--r-- | drivers/staging/android/ion/devicetree.txt | 51 | ||||
| -rw-r--r-- | drivers/staging/ccree/ssi_request_mgr.c | 1 | ||||
| -rw-r--r-- | drivers/staging/fsl-dpaa2/Kconfig | 1 | ||||
| -rw-r--r-- | drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 24 | ||||
| -rw-r--r-- | drivers/staging/rtl8192e/rtl819x_TSProc.c | 15 | ||||
| -rw-r--r-- | drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 1 | ||||
| -rw-r--r-- | drivers/staging/typec/fusb302/fusb302.c | 86 | ||||
| -rw-r--r-- | drivers/staging/typec/pd.h | 10 | ||||
| -rw-r--r-- | drivers/staging/typec/pd_vdo.h | 4 | ||||
| -rw-r--r-- | drivers/staging/typec/tcpci.c | 2 | ||||
| -rw-r--r-- | drivers/staging/typec/tcpm.c | 77 | ||||
| -rw-r--r-- | drivers/staging/typec/tcpm.h | 3 | ||||
| -rw-r--r-- | drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 31 |
15 files changed, 183 insertions, 165 deletions
diff --git a/Documentation/devicetree/bindings/staging/ion/hi6220-ion.txt b/Documentation/devicetree/bindings/staging/ion/hi6220-ion.txt deleted file mode 100644 index c59e27c632c1..000000000000 --- a/Documentation/devicetree/bindings/staging/ion/hi6220-ion.txt +++ /dev/null | |||
| @@ -1,31 +0,0 @@ | |||
| 1 | Hi6220 SoC ION | ||
| 2 | =================================================================== | ||
| 3 | Required properties: | ||
| 4 | - compatible : "hisilicon,hi6220-ion" | ||
| 5 | - list of the ION heaps | ||
| 6 | - heap name : maybe heap_sys_user@0 | ||
| 7 | - heap id : id should be unique in the system. | ||
| 8 | - heap base : base ddr address of the heap,0 means that | ||
| 9 | it is dynamic. | ||
| 10 | - heap size : memory size and 0 means it is dynamic. | ||
| 11 | - heap type : the heap type of the heap, please also | ||
| 12 | see the define in ion.h(drivers/staging/android/uapi/ion.h) | ||
| 13 | ------------------------------------------------------------------- | ||
| 14 | Example: | ||
| 15 | hi6220-ion { | ||
| 16 | compatible = "hisilicon,hi6220-ion"; | ||
| 17 | heap_sys_user@0 { | ||
| 18 | heap-name = "sys_user"; | ||
| 19 | heap-id = <0x0>; | ||
| 20 | heap-base = <0x0>; | ||
| 21 | heap-size = <0x0>; | ||
| 22 | heap-type = "ion_system"; | ||
| 23 | }; | ||
| 24 | heap_sys_contig@0 { | ||
| 25 | heap-name = "sys_contig"; | ||
| 26 | heap-id = <0x1>; | ||
| 27 | heap-base = <0x0>; | ||
| 28 | heap-size = <0x0>; | ||
| 29 | heap-type = "ion_system_contig"; | ||
| 30 | }; | ||
| 31 | }; | ||
diff --git a/MAINTAINERS b/MAINTAINERS index 503bcf4e3e8f..9e984645c4b0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -846,7 +846,6 @@ M: Laura Abbott <labbott@redhat.com> | |||
| 846 | M: Sumit Semwal <sumit.semwal@linaro.org> | 846 | M: Sumit Semwal <sumit.semwal@linaro.org> |
| 847 | L: devel@driverdev.osuosl.org | 847 | L: devel@driverdev.osuosl.org |
| 848 | S: Supported | 848 | S: Supported |
| 849 | F: Documentation/devicetree/bindings/staging/ion/ | ||
| 850 | F: drivers/staging/android/ion | 849 | F: drivers/staging/android/ion |
| 851 | F: drivers/staging/android/uapi/ion.h | 850 | F: drivers/staging/android/uapi/ion.h |
| 852 | F: drivers/staging/android/uapi/ion_test.h | 851 | F: drivers/staging/android/uapi/ion_test.h |
| @@ -3116,6 +3115,14 @@ F: drivers/net/ieee802154/cc2520.c | |||
| 3116 | F: include/linux/spi/cc2520.h | 3115 | F: include/linux/spi/cc2520.h |
| 3117 | F: Documentation/devicetree/bindings/net/ieee802154/cc2520.txt | 3116 | F: Documentation/devicetree/bindings/net/ieee802154/cc2520.txt |
| 3118 | 3117 | ||
| 3118 | CCREE ARM TRUSTZONE CRYPTOCELL 700 REE DRIVER | ||
| 3119 | M: Gilad Ben-Yossef <gilad@benyossef.com> | ||
| 3120 | L: linux-crypto@vger.kernel.org | ||
| 3121 | L: driverdev-devel@linuxdriverproject.org | ||
| 3122 | S: Supported | ||
| 3123 | F: drivers/staging/ccree/ | ||
| 3124 | W: https://developer.arm.com/products/system-ip/trustzone-cryptocell/cryptocell-700-family | ||
| 3125 | |||
| 3119 | CEC FRAMEWORK | 3126 | CEC FRAMEWORK |
| 3120 | M: Hans Verkuil <hans.verkuil@cisco.com> | 3127 | M: Hans Verkuil <hans.verkuil@cisco.com> |
| 3121 | L: linux-media@vger.kernel.org | 3128 | L: linux-media@vger.kernel.org |
| @@ -5695,7 +5702,7 @@ M: Alex Elder <elder@kernel.org> | |||
| 5695 | M: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 5702 | M: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| 5696 | S: Maintained | 5703 | S: Maintained |
| 5697 | F: drivers/staging/greybus/ | 5704 | F: drivers/staging/greybus/ |
| 5698 | L: greybus-dev@lists.linaro.org | 5705 | L: greybus-dev@lists.linaro.org (moderated for non-subscribers) |
| 5699 | 5706 | ||
| 5700 | GREYBUS AUDIO PROTOCOLS DRIVERS | 5707 | GREYBUS AUDIO PROTOCOLS DRIVERS |
| 5701 | M: Vaibhav Agarwal <vaibhav.sr@gmail.com> | 5708 | M: Vaibhav Agarwal <vaibhav.sr@gmail.com> |
diff --git a/drivers/staging/android/ion/devicetree.txt b/drivers/staging/android/ion/devicetree.txt deleted file mode 100644 index 168715271f06..000000000000 --- a/drivers/staging/android/ion/devicetree.txt +++ /dev/null | |||
| @@ -1,51 +0,0 @@ | |||
| 1 | Ion Memory Manager | ||
| 2 | |||
| 3 | Ion is a memory manager that allows for sharing of buffers via dma-buf. | ||
| 4 | Ion allows for different types of allocation via an abstraction called | ||
| 5 | a 'heap'. A heap represents a specific type of memory. Each heap has | ||
| 6 | a different type. There can be multiple instances of the same heap | ||
| 7 | type. | ||
| 8 | |||
| 9 | Specific heap instances are tied to heap IDs. Heap IDs are not to be specified | ||
| 10 | in the devicetree. | ||
| 11 | |||
| 12 | Required properties for Ion | ||
| 13 | |||
| 14 | - compatible: "linux,ion" PLUS a compatible property for the device | ||
| 15 | |||
| 16 | All child nodes of a linux,ion node are interpreted as heaps | ||
| 17 | |||
| 18 | required properties for heaps | ||
| 19 | |||
| 20 | - compatible: compatible string for a heap type PLUS a compatible property | ||
| 21 | for the specific instance of the heap. Current heap types | ||
| 22 | -- linux,ion-heap-system | ||
| 23 | -- linux,ion-heap-system-contig | ||
| 24 | -- linux,ion-heap-carveout | ||
| 25 | -- linux,ion-heap-chunk | ||
| 26 | -- linux,ion-heap-dma | ||
| 27 | -- linux,ion-heap-custom | ||
| 28 | |||
| 29 | Optional properties | ||
| 30 | - memory-region: A phandle to a memory region. Required for DMA heap type | ||
| 31 | (see reserved-memory.txt for details on the reservation) | ||
| 32 | |||
| 33 | Example: | ||
| 34 | |||
| 35 | ion { | ||
| 36 | compatbile = "hisilicon,ion", "linux,ion"; | ||
| 37 | |||
| 38 | ion-system-heap { | ||
| 39 | compatbile = "hisilicon,system-heap", "linux,ion-heap-system" | ||
| 40 | }; | ||
| 41 | |||
| 42 | ion-camera-region { | ||
| 43 | compatible = "hisilicon,camera-heap", "linux,ion-heap-dma" | ||
| 44 | memory-region = <&camera_region>; | ||
| 45 | }; | ||
| 46 | |||
| 47 | ion-fb-region { | ||
| 48 | compatbile = "hisilicon,fb-heap", "linux,ion-heap-dma" | ||
| 49 | memory-region = <&fb_region>; | ||
| 50 | }; | ||
| 51 | } | ||
diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c index 522bd62c102e..8611adf3bb2e 100644 --- a/drivers/staging/ccree/ssi_request_mgr.c +++ b/drivers/staging/ccree/ssi_request_mgr.c | |||
| @@ -376,7 +376,6 @@ int send_request( | |||
| 376 | rc = ssi_power_mgr_runtime_get(&drvdata->plat_dev->dev); | 376 | rc = ssi_power_mgr_runtime_get(&drvdata->plat_dev->dev); |
| 377 | if (rc != 0) { | 377 | if (rc != 0) { |
| 378 | SSI_LOG_ERR("ssi_power_mgr_runtime_get returned %x\n",rc); | 378 | SSI_LOG_ERR("ssi_power_mgr_runtime_get returned %x\n",rc); |
| 379 | spin_unlock_bh(&req_mgr_h->hw_lock); | ||
| 380 | return rc; | 379 | return rc; |
| 381 | } | 380 | } |
| 382 | #endif | 381 | #endif |
diff --git a/drivers/staging/fsl-dpaa2/Kconfig b/drivers/staging/fsl-dpaa2/Kconfig index 2e325cb747ae..730fd6d4db33 100644 --- a/drivers/staging/fsl-dpaa2/Kconfig +++ b/drivers/staging/fsl-dpaa2/Kconfig | |||
| @@ -12,6 +12,7 @@ config FSL_DPAA2 | |||
| 12 | config FSL_DPAA2_ETH | 12 | config FSL_DPAA2_ETH |
| 13 | tristate "Freescale DPAA2 Ethernet" | 13 | tristate "Freescale DPAA2 Ethernet" |
| 14 | depends on FSL_DPAA2 && FSL_MC_DPIO | 14 | depends on FSL_DPAA2 && FSL_MC_DPIO |
| 15 | depends on NETDEVICES && ETHERNET | ||
| 15 | ---help--- | 16 | ---help--- |
| 16 | Ethernet driver for Freescale DPAA2 SoCs, using the | 17 | Ethernet driver for Freescale DPAA2 SoCs, using the |
| 17 | Freescale MC bus driver | 18 | Freescale MC bus driver |
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index 4723a0bd5067..1c6ed5b2a6f9 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | |||
| @@ -97,8 +97,9 @@ void rtl92e_set_reg(struct net_device *dev, u8 variable, u8 *val) | |||
| 97 | 97 | ||
| 98 | switch (variable) { | 98 | switch (variable) { |
| 99 | case HW_VAR_BSSID: | 99 | case HW_VAR_BSSID: |
| 100 | rtl92e_writel(dev, BSSIDR, ((u32 *)(val))[0]); | 100 | /* BSSIDR 2 byte alignment */ |
| 101 | rtl92e_writew(dev, BSSIDR+2, ((u16 *)(val+2))[0]); | 101 | rtl92e_writew(dev, BSSIDR, *(u16 *)val); |
| 102 | rtl92e_writel(dev, BSSIDR + 2, *(u32 *)(val + 2)); | ||
| 102 | break; | 103 | break; |
| 103 | 104 | ||
| 104 | case HW_VAR_MEDIA_STATUS: | 105 | case HW_VAR_MEDIA_STATUS: |
| @@ -624,7 +625,7 @@ void rtl92e_get_eeprom_size(struct net_device *dev) | |||
| 624 | struct r8192_priv *priv = rtllib_priv(dev); | 625 | struct r8192_priv *priv = rtllib_priv(dev); |
| 625 | 626 | ||
| 626 | RT_TRACE(COMP_INIT, "===========>%s()\n", __func__); | 627 | RT_TRACE(COMP_INIT, "===========>%s()\n", __func__); |
| 627 | curCR = rtl92e_readl(dev, EPROM_CMD); | 628 | curCR = rtl92e_readw(dev, EPROM_CMD); |
| 628 | RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD, | 629 | RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD, |
| 629 | curCR); | 630 | curCR); |
| 630 | priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EEPROM_93C56 : | 631 | priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EEPROM_93C56 : |
| @@ -961,8 +962,8 @@ static void _rtl92e_net_update(struct net_device *dev) | |||
| 961 | rtl92e_config_rate(dev, &rate_config); | 962 | rtl92e_config_rate(dev, &rate_config); |
| 962 | priv->dot11CurrentPreambleMode = PREAMBLE_AUTO; | 963 | priv->dot11CurrentPreambleMode = PREAMBLE_AUTO; |
| 963 | priv->basic_rate = rate_config &= 0x15f; | 964 | priv->basic_rate = rate_config &= 0x15f; |
| 964 | rtl92e_writel(dev, BSSIDR, ((u32 *)net->bssid)[0]); | 965 | rtl92e_writew(dev, BSSIDR, *(u16 *)net->bssid); |
| 965 | rtl92e_writew(dev, BSSIDR+4, ((u16 *)net->bssid)[2]); | 966 | rtl92e_writel(dev, BSSIDR + 2, *(u32 *)(net->bssid + 2)); |
| 966 | 967 | ||
| 967 | if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { | 968 | if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { |
| 968 | rtl92e_writew(dev, ATIMWND, 2); | 969 | rtl92e_writew(dev, ATIMWND, 2); |
| @@ -1182,8 +1183,7 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc, | |||
| 1182 | struct cb_desc *cb_desc, struct sk_buff *skb) | 1183 | struct cb_desc *cb_desc, struct sk_buff *skb) |
| 1183 | { | 1184 | { |
| 1184 | struct r8192_priv *priv = rtllib_priv(dev); | 1185 | struct r8192_priv *priv = rtllib_priv(dev); |
| 1185 | dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, | 1186 | dma_addr_t mapping; |
| 1186 | PCI_DMA_TODEVICE); | ||
| 1187 | struct tx_fwinfo_8190pci *pTxFwInfo; | 1187 | struct tx_fwinfo_8190pci *pTxFwInfo; |
| 1188 | 1188 | ||
| 1189 | pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data; | 1189 | pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data; |
| @@ -1194,8 +1194,6 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc, | |||
| 1194 | pTxFwInfo->Short = _rtl92e_query_is_short(pTxFwInfo->TxHT, | 1194 | pTxFwInfo->Short = _rtl92e_query_is_short(pTxFwInfo->TxHT, |
| 1195 | pTxFwInfo->TxRate, cb_desc); | 1195 | pTxFwInfo->TxRate, cb_desc); |
| 1196 | 1196 | ||
| 1197 | if (pci_dma_mapping_error(priv->pdev, mapping)) | ||
| 1198 | netdev_err(dev, "%s(): DMA Mapping error\n", __func__); | ||
| 1199 | if (cb_desc->bAMPDUEnable) { | 1197 | if (cb_desc->bAMPDUEnable) { |
| 1200 | pTxFwInfo->AllowAggregation = 1; | 1198 | pTxFwInfo->AllowAggregation = 1; |
| 1201 | pTxFwInfo->RxMF = cb_desc->ampdu_factor; | 1199 | pTxFwInfo->RxMF = cb_desc->ampdu_factor; |
| @@ -1230,6 +1228,14 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc, | |||
| 1230 | } | 1228 | } |
| 1231 | 1229 | ||
| 1232 | memset((u8 *)pdesc, 0, 12); | 1230 | memset((u8 *)pdesc, 0, 12); |
| 1231 | |||
| 1232 | mapping = pci_map_single(priv->pdev, skb->data, skb->len, | ||
| 1233 | PCI_DMA_TODEVICE); | ||
| 1234 | if (pci_dma_mapping_error(priv->pdev, mapping)) { | ||
| 1235 | netdev_err(dev, "%s(): DMA Mapping error\n", __func__); | ||
| 1236 | return; | ||
| 1237 | } | ||
| 1238 | |||
| 1233 | pdesc->LINIP = 0; | 1239 | pdesc->LINIP = 0; |
| 1234 | pdesc->CmdInit = 1; | 1240 | pdesc->CmdInit = 1; |
| 1235 | pdesc->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; | 1241 | pdesc->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; |
diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 48bbd9e8a52f..dcc4eb691889 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c | |||
| @@ -306,11 +306,6 @@ static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, | |||
| 306 | pTsCommonInfo->TClasNum = TCLAS_Num; | 306 | pTsCommonInfo->TClasNum = TCLAS_Num; |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | static bool IsACValid(unsigned int tid) | ||
| 310 | { | ||
| 311 | return tid < 7; | ||
| 312 | } | ||
| 313 | |||
| 314 | bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, | 309 | bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, |
| 315 | u8 *Addr, u8 TID, enum tr_select TxRxSelect, bool bAddNewTs) | 310 | u8 *Addr, u8 TID, enum tr_select TxRxSelect, bool bAddNewTs) |
| 316 | { | 311 | { |
| @@ -328,12 +323,6 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, | |||
| 328 | if (ieee->current_network.qos_data.supported == 0) { | 323 | if (ieee->current_network.qos_data.supported == 0) { |
| 329 | UP = 0; | 324 | UP = 0; |
| 330 | } else { | 325 | } else { |
| 331 | if (!IsACValid(TID)) { | ||
| 332 | netdev_warn(ieee->dev, "%s(): TID(%d) is not valid\n", | ||
| 333 | __func__, TID); | ||
| 334 | return false; | ||
| 335 | } | ||
| 336 | |||
| 337 | switch (TID) { | 326 | switch (TID) { |
| 338 | case 0: | 327 | case 0: |
| 339 | case 3: | 328 | case 3: |
| @@ -351,6 +340,10 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, | |||
| 351 | case 7: | 340 | case 7: |
| 352 | UP = 7; | 341 | UP = 7; |
| 353 | break; | 342 | break; |
| 343 | default: | ||
| 344 | netdev_warn(ieee->dev, "%s(): TID(%d) is not valid\n", | ||
| 345 | __func__, TID); | ||
| 346 | return false; | ||
| 354 | } | 347 | } |
| 355 | } | 348 | } |
| 356 | 349 | ||
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 5e7a61f24f8d..36c3189fc4b7 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | |||
| @@ -3531,7 +3531,6 @@ int rtw_wdev_alloc(struct adapter *padapter, struct device *dev) | |||
| 3531 | pwdev_priv->power_mgmt = true; | 3531 | pwdev_priv->power_mgmt = true; |
| 3532 | else | 3532 | else |
| 3533 | pwdev_priv->power_mgmt = false; | 3533 | pwdev_priv->power_mgmt = false; |
| 3534 | kfree((u8 *)wdev); | ||
| 3535 | 3534 | ||
| 3536 | return ret; | 3535 | return ret; |
| 3537 | 3536 | ||
diff --git a/drivers/staging/typec/fusb302/fusb302.c b/drivers/staging/typec/fusb302/fusb302.c index 2cee9a952c9b..4a356e509fe4 100644 --- a/drivers/staging/typec/fusb302/fusb302.c +++ b/drivers/staging/typec/fusb302/fusb302.c | |||
| @@ -264,22 +264,36 @@ static void fusb302_debugfs_exit(const struct fusb302_chip *chip) { } | |||
| 264 | 264 | ||
| 265 | #define FUSB302_RESUME_RETRY 10 | 265 | #define FUSB302_RESUME_RETRY 10 |
| 266 | #define FUSB302_RESUME_RETRY_SLEEP 50 | 266 | #define FUSB302_RESUME_RETRY_SLEEP 50 |
| 267 | static int fusb302_i2c_write(struct fusb302_chip *chip, | 267 | |
| 268 | u8 address, u8 data) | 268 | static bool fusb302_is_suspended(struct fusb302_chip *chip) |
| 269 | { | 269 | { |
| 270 | int retry_cnt; | 270 | int retry_cnt; |
| 271 | int ret = 0; | ||
| 272 | 271 | ||
| 273 | atomic_set(&chip->i2c_busy, 1); | ||
| 274 | for (retry_cnt = 0; retry_cnt < FUSB302_RESUME_RETRY; retry_cnt++) { | 272 | for (retry_cnt = 0; retry_cnt < FUSB302_RESUME_RETRY; retry_cnt++) { |
| 275 | if (atomic_read(&chip->pm_suspend)) { | 273 | if (atomic_read(&chip->pm_suspend)) { |
| 276 | pr_err("fusb302_i2c: pm suspend, retry %d/%d\n", | 274 | dev_err(chip->dev, "i2c: pm suspend, retry %d/%d\n", |
| 277 | retry_cnt + 1, FUSB302_RESUME_RETRY); | 275 | retry_cnt + 1, FUSB302_RESUME_RETRY); |
| 278 | msleep(FUSB302_RESUME_RETRY_SLEEP); | 276 | msleep(FUSB302_RESUME_RETRY_SLEEP); |
| 279 | } else { | 277 | } else { |
| 280 | break; | 278 | return false; |
| 281 | } | 279 | } |
| 282 | } | 280 | } |
| 281 | |||
| 282 | return true; | ||
| 283 | } | ||
| 284 | |||
| 285 | static int fusb302_i2c_write(struct fusb302_chip *chip, | ||
| 286 | u8 address, u8 data) | ||
| 287 | { | ||
| 288 | int ret = 0; | ||
| 289 | |||
| 290 | atomic_set(&chip->i2c_busy, 1); | ||
| 291 | |||
| 292 | if (fusb302_is_suspended(chip)) { | ||
| 293 | atomic_set(&chip->i2c_busy, 0); | ||
| 294 | return -ETIMEDOUT; | ||
| 295 | } | ||
| 296 | |||
| 283 | ret = i2c_smbus_write_byte_data(chip->i2c_client, address, data); | 297 | ret = i2c_smbus_write_byte_data(chip->i2c_client, address, data); |
| 284 | if (ret < 0) | 298 | if (ret < 0) |
| 285 | fusb302_log(chip, "cannot write 0x%02x to 0x%02x, ret=%d", | 299 | fusb302_log(chip, "cannot write 0x%02x to 0x%02x, ret=%d", |
| @@ -292,21 +306,17 @@ static int fusb302_i2c_write(struct fusb302_chip *chip, | |||
| 292 | static int fusb302_i2c_block_write(struct fusb302_chip *chip, u8 address, | 306 | static int fusb302_i2c_block_write(struct fusb302_chip *chip, u8 address, |
| 293 | u8 length, const u8 *data) | 307 | u8 length, const u8 *data) |
| 294 | { | 308 | { |
| 295 | int retry_cnt; | ||
| 296 | int ret = 0; | 309 | int ret = 0; |
| 297 | 310 | ||
| 298 | if (length <= 0) | 311 | if (length <= 0) |
| 299 | return ret; | 312 | return ret; |
| 300 | atomic_set(&chip->i2c_busy, 1); | 313 | atomic_set(&chip->i2c_busy, 1); |
| 301 | for (retry_cnt = 0; retry_cnt < FUSB302_RESUME_RETRY; retry_cnt++) { | 314 | |
| 302 | if (atomic_read(&chip->pm_suspend)) { | 315 | if (fusb302_is_suspended(chip)) { |
| 303 | pr_err("fusb302_i2c: pm suspend, retry %d/%d\n", | 316 | atomic_set(&chip->i2c_busy, 0); |
| 304 | retry_cnt + 1, FUSB302_RESUME_RETRY); | 317 | return -ETIMEDOUT; |
| 305 | msleep(FUSB302_RESUME_RETRY_SLEEP); | ||
| 306 | } else { | ||
| 307 | break; | ||
| 308 | } | ||
| 309 | } | 318 | } |
| 319 | |||
| 310 | ret = i2c_smbus_write_i2c_block_data(chip->i2c_client, address, | 320 | ret = i2c_smbus_write_i2c_block_data(chip->i2c_client, address, |
| 311 | length, data); | 321 | length, data); |
| 312 | if (ret < 0) | 322 | if (ret < 0) |
| @@ -320,19 +330,15 @@ static int fusb302_i2c_block_write(struct fusb302_chip *chip, u8 address, | |||
| 320 | static int fusb302_i2c_read(struct fusb302_chip *chip, | 330 | static int fusb302_i2c_read(struct fusb302_chip *chip, |
| 321 | u8 address, u8 *data) | 331 | u8 address, u8 *data) |
| 322 | { | 332 | { |
| 323 | int retry_cnt; | ||
| 324 | int ret = 0; | 333 | int ret = 0; |
| 325 | 334 | ||
| 326 | atomic_set(&chip->i2c_busy, 1); | 335 | atomic_set(&chip->i2c_busy, 1); |
| 327 | for (retry_cnt = 0; retry_cnt < FUSB302_RESUME_RETRY; retry_cnt++) { | 336 | |
| 328 | if (atomic_read(&chip->pm_suspend)) { | 337 | if (fusb302_is_suspended(chip)) { |
| 329 | pr_err("fusb302_i2c: pm suspend, retry %d/%d\n", | 338 | atomic_set(&chip->i2c_busy, 0); |
| 330 | retry_cnt + 1, FUSB302_RESUME_RETRY); | 339 | return -ETIMEDOUT; |
| 331 | msleep(FUSB302_RESUME_RETRY_SLEEP); | ||
| 332 | } else { | ||
| 333 | break; | ||
| 334 | } | ||
| 335 | } | 340 | } |
| 341 | |||
| 336 | ret = i2c_smbus_read_byte_data(chip->i2c_client, address); | 342 | ret = i2c_smbus_read_byte_data(chip->i2c_client, address); |
| 337 | *data = (u8)ret; | 343 | *data = (u8)ret; |
| 338 | if (ret < 0) | 344 | if (ret < 0) |
| @@ -345,33 +351,31 @@ static int fusb302_i2c_read(struct fusb302_chip *chip, | |||
| 345 | static int fusb302_i2c_block_read(struct fusb302_chip *chip, u8 address, | 351 | static int fusb302_i2c_block_read(struct fusb302_chip *chip, u8 address, |
| 346 | u8 length, u8 *data) | 352 | u8 length, u8 *data) |
| 347 | { | 353 | { |
| 348 | int retry_cnt; | ||
| 349 | int ret = 0; | 354 | int ret = 0; |
| 350 | 355 | ||
| 351 | if (length <= 0) | 356 | if (length <= 0) |
| 352 | return ret; | 357 | return ret; |
| 353 | atomic_set(&chip->i2c_busy, 1); | 358 | atomic_set(&chip->i2c_busy, 1); |
| 354 | for (retry_cnt = 0; retry_cnt < FUSB302_RESUME_RETRY; retry_cnt++) { | 359 | |
| 355 | if (atomic_read(&chip->pm_suspend)) { | 360 | if (fusb302_is_suspended(chip)) { |
| 356 | pr_err("fusb302_i2c: pm suspend, retry %d/%d\n", | 361 | atomic_set(&chip->i2c_busy, 0); |
| 357 | retry_cnt + 1, FUSB302_RESUME_RETRY); | 362 | return -ETIMEDOUT; |
| 358 | msleep(FUSB302_RESUME_RETRY_SLEEP); | ||
| 359 | } else { | ||
| 360 | break; | ||
| 361 | } | ||
| 362 | } | 363 | } |
| 364 | |||
| 363 | ret = i2c_smbus_read_i2c_block_data(chip->i2c_client, address, | 365 | ret = i2c_smbus_read_i2c_block_data(chip->i2c_client, address, |
| 364 | length, data); | 366 | length, data); |
| 365 | if (ret < 0) { | 367 | if (ret < 0) { |
| 366 | fusb302_log(chip, "cannot block read 0x%02x, len=%d, ret=%d", | 368 | fusb302_log(chip, "cannot block read 0x%02x, len=%d, ret=%d", |
| 367 | address, length, ret); | 369 | address, length, ret); |
| 368 | return ret; | 370 | goto done; |
| 369 | } | 371 | } |
| 370 | if (ret != length) { | 372 | if (ret != length) { |
| 371 | fusb302_log(chip, "only read %d/%d bytes from 0x%02x", | 373 | fusb302_log(chip, "only read %d/%d bytes from 0x%02x", |
| 372 | ret, length, address); | 374 | ret, length, address); |
| 373 | return -EIO; | 375 | ret = -EIO; |
| 374 | } | 376 | } |
| 377 | |||
| 378 | done: | ||
| 375 | atomic_set(&chip->i2c_busy, 0); | 379 | atomic_set(&chip->i2c_busy, 0); |
| 376 | 380 | ||
| 377 | return ret; | 381 | return ret; |
| @@ -489,7 +493,7 @@ static int tcpm_init(struct tcpc_dev *dev) | |||
| 489 | ret = fusb302_i2c_read(chip, FUSB_REG_STATUS0, &data); | 493 | ret = fusb302_i2c_read(chip, FUSB_REG_STATUS0, &data); |
| 490 | if (ret < 0) | 494 | if (ret < 0) |
| 491 | return ret; | 495 | return ret; |
| 492 | chip->vbus_present = !!(FUSB_REG_STATUS0 & FUSB_REG_STATUS0_VBUSOK); | 496 | chip->vbus_present = !!(data & FUSB_REG_STATUS0_VBUSOK); |
| 493 | ret = fusb302_i2c_read(chip, FUSB_REG_DEVICE_ID, &data); | 497 | ret = fusb302_i2c_read(chip, FUSB_REG_DEVICE_ID, &data); |
| 494 | if (ret < 0) | 498 | if (ret < 0) |
| 495 | return ret; | 499 | return ret; |
| @@ -1025,7 +1029,7 @@ static int fusb302_pd_send_message(struct fusb302_chip *chip, | |||
| 1025 | buf[pos++] = FUSB302_TKN_SYNC1; | 1029 | buf[pos++] = FUSB302_TKN_SYNC1; |
| 1026 | buf[pos++] = FUSB302_TKN_SYNC2; | 1030 | buf[pos++] = FUSB302_TKN_SYNC2; |
| 1027 | 1031 | ||
| 1028 | len = pd_header_cnt(msg->header) * 4; | 1032 | len = pd_header_cnt_le(msg->header) * 4; |
| 1029 | /* plug 2 for header */ | 1033 | /* plug 2 for header */ |
| 1030 | len += 2; | 1034 | len += 2; |
| 1031 | if (len > 0x1F) { | 1035 | if (len > 0x1F) { |
| @@ -1481,7 +1485,7 @@ static int fusb302_pd_read_message(struct fusb302_chip *chip, | |||
| 1481 | (u8 *)&msg->header); | 1485 | (u8 *)&msg->header); |
| 1482 | if (ret < 0) | 1486 | if (ret < 0) |
| 1483 | return ret; | 1487 | return ret; |
| 1484 | len = pd_header_cnt(msg->header) * 4; | 1488 | len = pd_header_cnt_le(msg->header) * 4; |
| 1485 | /* add 4 to length to include the CRC */ | 1489 | /* add 4 to length to include the CRC */ |
| 1486 | if (len > PD_MAX_PAYLOAD * 4) { | 1490 | if (len > PD_MAX_PAYLOAD * 4) { |
| 1487 | fusb302_log(chip, "PD message too long %d", len); | 1491 | fusb302_log(chip, "PD message too long %d", len); |
| @@ -1663,14 +1667,12 @@ static int init_gpio(struct fusb302_chip *chip) | |||
| 1663 | if (ret < 0) { | 1667 | if (ret < 0) { |
| 1664 | fusb302_log(chip, | 1668 | fusb302_log(chip, |
| 1665 | "cannot set GPIO Int_N to input, ret=%d", ret); | 1669 | "cannot set GPIO Int_N to input, ret=%d", ret); |
| 1666 | gpio_free(chip->gpio_int_n); | ||
| 1667 | return ret; | 1670 | return ret; |
| 1668 | } | 1671 | } |
| 1669 | ret = gpio_to_irq(chip->gpio_int_n); | 1672 | ret = gpio_to_irq(chip->gpio_int_n); |
| 1670 | if (ret < 0) { | 1673 | if (ret < 0) { |
| 1671 | fusb302_log(chip, | 1674 | fusb302_log(chip, |
| 1672 | "cannot request IRQ for GPIO Int_N, ret=%d", ret); | 1675 | "cannot request IRQ for GPIO Int_N, ret=%d", ret); |
| 1673 | gpio_free(chip->gpio_int_n); | ||
| 1674 | return ret; | 1676 | return ret; |
| 1675 | } | 1677 | } |
| 1676 | chip->gpio_int_n_irq = ret; | 1678 | chip->gpio_int_n_irq = ret; |
| @@ -1787,11 +1789,13 @@ static const struct of_device_id fusb302_dt_match[] = { | |||
| 1787 | {.compatible = "fcs,fusb302"}, | 1789 | {.compatible = "fcs,fusb302"}, |
| 1788 | {}, | 1790 | {}, |
| 1789 | }; | 1791 | }; |
| 1792 | MODULE_DEVICE_TABLE(of, fusb302_dt_match); | ||
| 1790 | 1793 | ||
| 1791 | static const struct i2c_device_id fusb302_i2c_device_id[] = { | 1794 | static const struct i2c_device_id fusb302_i2c_device_id[] = { |
| 1792 | {"typec_fusb302", 0}, | 1795 | {"typec_fusb302", 0}, |
| 1793 | {}, | 1796 | {}, |
| 1794 | }; | 1797 | }; |
| 1798 | MODULE_DEVICE_TABLE(i2c, fusb302_i2c_device_id); | ||
| 1795 | 1799 | ||
| 1796 | static const struct dev_pm_ops fusb302_pm_ops = { | 1800 | static const struct dev_pm_ops fusb302_pm_ops = { |
| 1797 | .suspend = fusb302_pm_suspend, | 1801 | .suspend = fusb302_pm_suspend, |
diff --git a/drivers/staging/typec/pd.h b/drivers/staging/typec/pd.h index 8d97bdb95f23..510ef7279900 100644 --- a/drivers/staging/typec/pd.h +++ b/drivers/staging/typec/pd.h | |||
| @@ -92,6 +92,16 @@ static inline unsigned int pd_header_type_le(__le16 header) | |||
| 92 | return pd_header_type(le16_to_cpu(header)); | 92 | return pd_header_type(le16_to_cpu(header)); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | static inline unsigned int pd_header_msgid(u16 header) | ||
| 96 | { | ||
| 97 | return (header >> PD_HEADER_ID_SHIFT) & PD_HEADER_ID_MASK; | ||
| 98 | } | ||
| 99 | |||
| 100 | static inline unsigned int pd_header_msgid_le(__le16 header) | ||
| 101 | { | ||
| 102 | return pd_header_msgid(le16_to_cpu(header)); | ||
| 103 | } | ||
| 104 | |||
| 95 | #define PD_MAX_PAYLOAD 7 | 105 | #define PD_MAX_PAYLOAD 7 |
| 96 | 106 | ||
| 97 | struct pd_message { | 107 | struct pd_message { |
diff --git a/drivers/staging/typec/pd_vdo.h b/drivers/staging/typec/pd_vdo.h index dba172e0e0d1..d92259f8de0a 100644 --- a/drivers/staging/typec/pd_vdo.h +++ b/drivers/staging/typec/pd_vdo.h | |||
| @@ -22,6 +22,9 @@ | |||
| 22 | * VDM object is minimum of VDM header + 6 additional data objects. | 22 | * VDM object is minimum of VDM header + 6 additional data objects. |
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | #define VDO_MAX_OBJECTS 6 | ||
| 26 | #define VDO_MAX_SIZE (VDO_MAX_OBJECTS + 1) | ||
| 27 | |||
| 25 | /* | 28 | /* |
| 26 | * VDM header | 29 | * VDM header |
| 27 | * ---------- | 30 | * ---------- |
| @@ -34,7 +37,6 @@ | |||
| 34 | * <5> :: reserved (SVDM), command type (UVDM) | 37 | * <5> :: reserved (SVDM), command type (UVDM) |
| 35 | * <4:0> :: command | 38 | * <4:0> :: command |
| 36 | */ | 39 | */ |
| 37 | #define VDO_MAX_SIZE 7 | ||
| 38 | #define VDO(vid, type, custom) \ | 40 | #define VDO(vid, type, custom) \ |
| 39 | (((vid) << 16) | \ | 41 | (((vid) << 16) | \ |
| 40 | ((type) << 15) | \ | 42 | ((type) << 15) | \ |
diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c index 5e5be74c7850..df72d8b01e73 100644 --- a/drivers/staging/typec/tcpci.c +++ b/drivers/staging/typec/tcpci.c | |||
| @@ -425,7 +425,7 @@ static const struct regmap_config tcpci_regmap_config = { | |||
| 425 | .max_register = 0x7F, /* 0x80 .. 0xFF are vendor defined */ | 425 | .max_register = 0x7F, /* 0x80 .. 0xFF are vendor defined */ |
| 426 | }; | 426 | }; |
| 427 | 427 | ||
| 428 | const struct tcpc_config tcpci_tcpc_config = { | 428 | static const struct tcpc_config tcpci_tcpc_config = { |
| 429 | .type = TYPEC_PORT_DFP, | 429 | .type = TYPEC_PORT_DFP, |
| 430 | .default_role = TYPEC_SINK, | 430 | .default_role = TYPEC_SINK, |
| 431 | }; | 431 | }; |
diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c index abba655ba00a..20eb4ebcf8c3 100644 --- a/drivers/staging/typec/tcpm.c +++ b/drivers/staging/typec/tcpm.c | |||
| @@ -238,6 +238,7 @@ struct tcpm_port { | |||
| 238 | unsigned int hard_reset_count; | 238 | unsigned int hard_reset_count; |
| 239 | bool pd_capable; | 239 | bool pd_capable; |
| 240 | bool explicit_contract; | 240 | bool explicit_contract; |
| 241 | unsigned int rx_msgid; | ||
| 241 | 242 | ||
| 242 | /* Partner capabilities/requests */ | 243 | /* Partner capabilities/requests */ |
| 243 | u32 sink_request; | 244 | u32 sink_request; |
| @@ -251,6 +252,8 @@ struct tcpm_port { | |||
| 251 | unsigned int nr_src_pdo; | 252 | unsigned int nr_src_pdo; |
| 252 | u32 snk_pdo[PDO_MAX_OBJECTS]; | 253 | u32 snk_pdo[PDO_MAX_OBJECTS]; |
| 253 | unsigned int nr_snk_pdo; | 254 | unsigned int nr_snk_pdo; |
| 255 | u32 snk_vdo[VDO_MAX_OBJECTS]; | ||
| 256 | unsigned int nr_snk_vdo; | ||
| 254 | 257 | ||
| 255 | unsigned int max_snk_mv; | 258 | unsigned int max_snk_mv; |
| 256 | unsigned int max_snk_ma; | 259 | unsigned int max_snk_ma; |
| @@ -997,6 +1000,7 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const __le32 *payload, int cnt, | |||
| 997 | struct pd_mode_data *modep; | 1000 | struct pd_mode_data *modep; |
| 998 | int rlen = 0; | 1001 | int rlen = 0; |
| 999 | u16 svid; | 1002 | u16 svid; |
| 1003 | int i; | ||
| 1000 | 1004 | ||
| 1001 | tcpm_log(port, "Rx VDM cmd 0x%x type %d cmd %d len %d", | 1005 | tcpm_log(port, "Rx VDM cmd 0x%x type %d cmd %d len %d", |
| 1002 | p0, cmd_type, cmd, cnt); | 1006 | p0, cmd_type, cmd, cnt); |
| @@ -1007,6 +1011,14 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const __le32 *payload, int cnt, | |||
| 1007 | case CMDT_INIT: | 1011 | case CMDT_INIT: |
| 1008 | switch (cmd) { | 1012 | switch (cmd) { |
| 1009 | case CMD_DISCOVER_IDENT: | 1013 | case CMD_DISCOVER_IDENT: |
| 1014 | /* 6.4.4.3.1: Only respond as UFP (device) */ | ||
| 1015 | if (port->data_role == TYPEC_DEVICE && | ||
| 1016 | port->nr_snk_vdo) { | ||
| 1017 | for (i = 0; i < port->nr_snk_vdo; i++) | ||
| 1018 | response[i + 1] | ||
| 1019 | = cpu_to_le32(port->snk_vdo[i]); | ||
| 1020 | rlen = port->nr_snk_vdo + 1; | ||
| 1021 | } | ||
| 1010 | break; | 1022 | break; |
| 1011 | case CMD_DISCOVER_SVID: | 1023 | case CMD_DISCOVER_SVID: |
| 1012 | break; | 1024 | break; |
| @@ -1415,6 +1427,7 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port, | |||
| 1415 | break; | 1427 | break; |
| 1416 | case SOFT_RESET_SEND: | 1428 | case SOFT_RESET_SEND: |
| 1417 | port->message_id = 0; | 1429 | port->message_id = 0; |
| 1430 | port->rx_msgid = -1; | ||
| 1418 | if (port->pwr_role == TYPEC_SOURCE) | 1431 | if (port->pwr_role == TYPEC_SOURCE) |
| 1419 | next_state = SRC_SEND_CAPABILITIES; | 1432 | next_state = SRC_SEND_CAPABILITIES; |
| 1420 | else | 1433 | else |
| @@ -1503,6 +1516,22 @@ static void tcpm_pd_rx_handler(struct work_struct *work) | |||
| 1503 | port->attached); | 1516 | port->attached); |
| 1504 | 1517 | ||
| 1505 | if (port->attached) { | 1518 | if (port->attached) { |
| 1519 | enum pd_ctrl_msg_type type = pd_header_type_le(msg->header); | ||
| 1520 | unsigned int msgid = pd_header_msgid_le(msg->header); | ||
| 1521 | |||
| 1522 | /* | ||
| 1523 | * USB PD standard, 6.6.1.2: | ||
| 1524 | * "... if MessageID value in a received Message is the | ||
| 1525 | * same as the stored value, the receiver shall return a | ||
| 1526 | * GoodCRC Message with that MessageID value and drop | ||
| 1527 | * the Message (this is a retry of an already received | ||
| 1528 | * Message). Note: this shall not apply to the Soft_Reset | ||
| 1529 | * Message which always has a MessageID value of zero." | ||
| 1530 | */ | ||
| 1531 | if (msgid == port->rx_msgid && type != PD_CTRL_SOFT_RESET) | ||
| 1532 | goto done; | ||
| 1533 | port->rx_msgid = msgid; | ||
| 1534 | |||
| 1506 | /* | 1535 | /* |
| 1507 | * If both ends believe to be DFP/host, we have a data role | 1536 | * If both ends believe to be DFP/host, we have a data role |
| 1508 | * mismatch. | 1537 | * mismatch. |
| @@ -1520,6 +1549,7 @@ static void tcpm_pd_rx_handler(struct work_struct *work) | |||
| 1520 | } | 1549 | } |
| 1521 | } | 1550 | } |
| 1522 | 1551 | ||
| 1552 | done: | ||
| 1523 | mutex_unlock(&port->lock); | 1553 | mutex_unlock(&port->lock); |
| 1524 | kfree(event); | 1554 | kfree(event); |
| 1525 | } | 1555 | } |
| @@ -1719,8 +1749,7 @@ static int tcpm_pd_build_request(struct tcpm_port *port, u32 *rdo) | |||
| 1719 | } | 1749 | } |
| 1720 | ma = min(ma, port->max_snk_ma); | 1750 | ma = min(ma, port->max_snk_ma); |
| 1721 | 1751 | ||
| 1722 | /* XXX: Any other flags need to be set? */ | 1752 | flags = RDO_USB_COMM | RDO_NO_SUSPEND; |
| 1723 | flags = 0; | ||
| 1724 | 1753 | ||
| 1725 | /* Set mismatch bit if offered power is less than operating power */ | 1754 | /* Set mismatch bit if offered power is less than operating power */ |
| 1726 | mw = ma * mv / 1000; | 1755 | mw = ma * mv / 1000; |
| @@ -1957,6 +1986,12 @@ static void tcpm_reset_port(struct tcpm_port *port) | |||
| 1957 | port->attached = false; | 1986 | port->attached = false; |
| 1958 | port->pd_capable = false; | 1987 | port->pd_capable = false; |
| 1959 | 1988 | ||
| 1989 | /* | ||
| 1990 | * First Rx ID should be 0; set this to a sentinel of -1 so that | ||
| 1991 | * we can check tcpm_pd_rx_handler() if we had seen it before. | ||
| 1992 | */ | ||
| 1993 | port->rx_msgid = -1; | ||
| 1994 | |||
| 1960 | port->tcpc->set_pd_rx(port->tcpc, false); | 1995 | port->tcpc->set_pd_rx(port->tcpc, false); |
| 1961 | tcpm_init_vbus(port); /* also disables charging */ | 1996 | tcpm_init_vbus(port); /* also disables charging */ |
| 1962 | tcpm_init_vconn(port); | 1997 | tcpm_init_vconn(port); |
| @@ -2170,6 +2205,7 @@ static void run_state_machine(struct tcpm_port *port) | |||
| 2170 | port->pwr_opmode = TYPEC_PWR_MODE_USB; | 2205 | port->pwr_opmode = TYPEC_PWR_MODE_USB; |
| 2171 | port->caps_count = 0; | 2206 | port->caps_count = 0; |
| 2172 | port->message_id = 0; | 2207 | port->message_id = 0; |
| 2208 | port->rx_msgid = -1; | ||
| 2173 | port->explicit_contract = false; | 2209 | port->explicit_contract = false; |
| 2174 | tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0); | 2210 | tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0); |
| 2175 | break; | 2211 | break; |
| @@ -2329,6 +2365,7 @@ static void run_state_machine(struct tcpm_port *port) | |||
| 2329 | typec_set_pwr_opmode(port->typec_port, TYPEC_PWR_MODE_USB); | 2365 | typec_set_pwr_opmode(port->typec_port, TYPEC_PWR_MODE_USB); |
| 2330 | port->pwr_opmode = TYPEC_PWR_MODE_USB; | 2366 | port->pwr_opmode = TYPEC_PWR_MODE_USB; |
| 2331 | port->message_id = 0; | 2367 | port->message_id = 0; |
| 2368 | port->rx_msgid = -1; | ||
| 2332 | port->explicit_contract = false; | 2369 | port->explicit_contract = false; |
| 2333 | tcpm_set_state(port, SNK_DISCOVERY, 0); | 2370 | tcpm_set_state(port, SNK_DISCOVERY, 0); |
| 2334 | break; | 2371 | break; |
| @@ -2496,6 +2533,7 @@ static void run_state_machine(struct tcpm_port *port) | |||
| 2496 | /* Soft_Reset states */ | 2533 | /* Soft_Reset states */ |
| 2497 | case SOFT_RESET: | 2534 | case SOFT_RESET: |
| 2498 | port->message_id = 0; | 2535 | port->message_id = 0; |
| 2536 | port->rx_msgid = -1; | ||
| 2499 | tcpm_pd_send_control(port, PD_CTRL_ACCEPT); | 2537 | tcpm_pd_send_control(port, PD_CTRL_ACCEPT); |
| 2500 | if (port->pwr_role == TYPEC_SOURCE) | 2538 | if (port->pwr_role == TYPEC_SOURCE) |
| 2501 | tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0); | 2539 | tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0); |
| @@ -2504,6 +2542,7 @@ static void run_state_machine(struct tcpm_port *port) | |||
| 2504 | break; | 2542 | break; |
| 2505 | case SOFT_RESET_SEND: | 2543 | case SOFT_RESET_SEND: |
| 2506 | port->message_id = 0; | 2544 | port->message_id = 0; |
| 2545 | port->rx_msgid = -1; | ||
| 2507 | if (tcpm_pd_send_control(port, PD_CTRL_SOFT_RESET)) | 2546 | if (tcpm_pd_send_control(port, PD_CTRL_SOFT_RESET)) |
| 2508 | tcpm_set_state_cond(port, hard_reset_state(port), 0); | 2547 | tcpm_set_state_cond(port, hard_reset_state(port), 0); |
| 2509 | else | 2548 | else |
| @@ -2568,6 +2607,14 @@ static void run_state_machine(struct tcpm_port *port) | |||
| 2568 | break; | 2607 | break; |
| 2569 | case PR_SWAP_SRC_SNK_SOURCE_OFF: | 2608 | case PR_SWAP_SRC_SNK_SOURCE_OFF: |
| 2570 | tcpm_set_cc(port, TYPEC_CC_RD); | 2609 | tcpm_set_cc(port, TYPEC_CC_RD); |
| 2610 | /* | ||
| 2611 | * USB-PD standard, 6.2.1.4, Port Power Role: | ||
| 2612 | * "During the Power Role Swap Sequence, for the initial Source | ||
| 2613 | * Port, the Port Power Role field shall be set to Sink in the | ||
| 2614 | * PS_RDY Message indicating that the initial Source’s power | ||
| 2615 | * supply is turned off" | ||
| 2616 | */ | ||
| 2617 | tcpm_set_pwr_role(port, TYPEC_SINK); | ||
| 2571 | if (tcpm_pd_send_control(port, PD_CTRL_PS_RDY)) { | 2618 | if (tcpm_pd_send_control(port, PD_CTRL_PS_RDY)) { |
| 2572 | tcpm_set_state(port, ERROR_RECOVERY, 0); | 2619 | tcpm_set_state(port, ERROR_RECOVERY, 0); |
| 2573 | break; | 2620 | break; |
| @@ -2575,7 +2622,6 @@ static void run_state_machine(struct tcpm_port *port) | |||
| 2575 | tcpm_set_state_cond(port, SNK_UNATTACHED, PD_T_PS_SOURCE_ON); | 2622 | tcpm_set_state_cond(port, SNK_UNATTACHED, PD_T_PS_SOURCE_ON); |
| 2576 | break; | 2623 | break; |
| 2577 | case PR_SWAP_SRC_SNK_SINK_ON: | 2624 | case PR_SWAP_SRC_SNK_SINK_ON: |
| 2578 | tcpm_set_pwr_role(port, TYPEC_SINK); | ||
| 2579 | tcpm_swap_complete(port, 0); | 2625 | tcpm_swap_complete(port, 0); |
| 2580 | tcpm_set_state(port, SNK_STARTUP, 0); | 2626 | tcpm_set_state(port, SNK_STARTUP, 0); |
| 2581 | break; | 2627 | break; |
| @@ -2587,8 +2633,15 @@ static void run_state_machine(struct tcpm_port *port) | |||
| 2587 | case PR_SWAP_SNK_SRC_SOURCE_ON: | 2633 | case PR_SWAP_SNK_SRC_SOURCE_ON: |
| 2588 | tcpm_set_cc(port, tcpm_rp_cc(port)); | 2634 | tcpm_set_cc(port, tcpm_rp_cc(port)); |
| 2589 | tcpm_set_vbus(port, true); | 2635 | tcpm_set_vbus(port, true); |
| 2590 | tcpm_pd_send_control(port, PD_CTRL_PS_RDY); | 2636 | /* |
| 2637 | * USB PD standard, 6.2.1.4: | ||
| 2638 | * "Subsequent Messages initiated by the Policy Engine, | ||
| 2639 | * such as the PS_RDY Message sent to indicate that Vbus | ||
| 2640 | * is ready, will have the Port Power Role field set to | ||
| 2641 | * Source." | ||
| 2642 | */ | ||
| 2591 | tcpm_set_pwr_role(port, TYPEC_SOURCE); | 2643 | tcpm_set_pwr_role(port, TYPEC_SOURCE); |
| 2644 | tcpm_pd_send_control(port, PD_CTRL_PS_RDY); | ||
| 2592 | tcpm_swap_complete(port, 0); | 2645 | tcpm_swap_complete(port, 0); |
| 2593 | tcpm_set_state(port, SRC_STARTUP, 0); | 2646 | tcpm_set_state(port, SRC_STARTUP, 0); |
| 2594 | break; | 2647 | break; |
| @@ -3292,6 +3345,20 @@ static int tcpm_copy_pdos(u32 *dest_pdo, const u32 *src_pdo, | |||
| 3292 | return nr_pdo; | 3345 | return nr_pdo; |
| 3293 | } | 3346 | } |
| 3294 | 3347 | ||
| 3348 | static int tcpm_copy_vdos(u32 *dest_vdo, const u32 *src_vdo, | ||
| 3349 | unsigned int nr_vdo) | ||
| 3350 | { | ||
| 3351 | unsigned int i; | ||
| 3352 | |||
| 3353 | if (nr_vdo > VDO_MAX_OBJECTS) | ||
| 3354 | nr_vdo = VDO_MAX_OBJECTS; | ||
| 3355 | |||
| 3356 | for (i = 0; i < nr_vdo; i++) | ||
| 3357 | dest_vdo[i] = src_vdo[i]; | ||
| 3358 | |||
| 3359 | return nr_vdo; | ||
| 3360 | } | ||
| 3361 | |||
| 3295 | void tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo, | 3362 | void tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo, |
| 3296 | unsigned int nr_pdo) | 3363 | unsigned int nr_pdo) |
| 3297 | { | 3364 | { |
| @@ -3382,6 +3449,8 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) | |||
| 3382 | tcpc->config->nr_src_pdo); | 3449 | tcpc->config->nr_src_pdo); |
| 3383 | port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcpc->config->snk_pdo, | 3450 | port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcpc->config->snk_pdo, |
| 3384 | tcpc->config->nr_snk_pdo); | 3451 | tcpc->config->nr_snk_pdo); |
| 3452 | port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcpc->config->snk_vdo, | ||
| 3453 | tcpc->config->nr_snk_vdo); | ||
| 3385 | 3454 | ||
| 3386 | port->max_snk_mv = tcpc->config->max_snk_mv; | 3455 | port->max_snk_mv = tcpc->config->max_snk_mv; |
| 3387 | port->max_snk_ma = tcpc->config->max_snk_ma; | 3456 | port->max_snk_ma = tcpc->config->max_snk_ma; |
diff --git a/drivers/staging/typec/tcpm.h b/drivers/staging/typec/tcpm.h index 969b365e6549..19c307d31a5a 100644 --- a/drivers/staging/typec/tcpm.h +++ b/drivers/staging/typec/tcpm.h | |||
| @@ -60,6 +60,9 @@ struct tcpc_config { | |||
| 60 | const u32 *snk_pdo; | 60 | const u32 *snk_pdo; |
| 61 | unsigned int nr_snk_pdo; | 61 | unsigned int nr_snk_pdo; |
| 62 | 62 | ||
| 63 | const u32 *snk_vdo; | ||
| 64 | unsigned int nr_snk_vdo; | ||
| 65 | |||
| 63 | unsigned int max_snk_mv; | 66 | unsigned int max_snk_mv; |
| 64 | unsigned int max_snk_ma; | 67 | unsigned int max_snk_ma; |
| 65 | unsigned int max_snk_mw; | 68 | unsigned int max_snk_mw; |
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index 988ee61fb4a7..d04db3f55519 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | |||
| @@ -502,8 +502,15 @@ create_pagelist(char __user *buf, size_t count, unsigned short type, | |||
| 502 | */ | 502 | */ |
| 503 | sg_init_table(scatterlist, num_pages); | 503 | sg_init_table(scatterlist, num_pages); |
| 504 | /* Now set the pages for each scatterlist */ | 504 | /* Now set the pages for each scatterlist */ |
| 505 | for (i = 0; i < num_pages; i++) | 505 | for (i = 0; i < num_pages; i++) { |
| 506 | sg_set_page(scatterlist + i, pages[i], PAGE_SIZE, 0); | 506 | unsigned int len = PAGE_SIZE - offset; |
| 507 | |||
| 508 | if (len > count) | ||
| 509 | len = count; | ||
| 510 | sg_set_page(scatterlist + i, pages[i], len, offset); | ||
| 511 | offset = 0; | ||
| 512 | count -= len; | ||
| 513 | } | ||
| 507 | 514 | ||
| 508 | dma_buffers = dma_map_sg(g_dev, | 515 | dma_buffers = dma_map_sg(g_dev, |
| 509 | scatterlist, | 516 | scatterlist, |
| @@ -524,20 +531,20 @@ create_pagelist(char __user *buf, size_t count, unsigned short type, | |||
| 524 | u32 addr = sg_dma_address(sg); | 531 | u32 addr = sg_dma_address(sg); |
| 525 | 532 | ||
| 526 | /* Note: addrs is the address + page_count - 1 | 533 | /* Note: addrs is the address + page_count - 1 |
| 527 | * The firmware expects the block to be page | 534 | * The firmware expects blocks after the first to be page- |
| 528 | * aligned and a multiple of the page size | 535 | * aligned and a multiple of the page size |
| 529 | */ | 536 | */ |
| 530 | WARN_ON(len == 0); | 537 | WARN_ON(len == 0); |
| 531 | WARN_ON(len & ~PAGE_MASK); | 538 | WARN_ON(i && (i != (dma_buffers - 1)) && (len & ~PAGE_MASK)); |
| 532 | WARN_ON(addr & ~PAGE_MASK); | 539 | WARN_ON(i && (addr & ~PAGE_MASK)); |
| 533 | if (k > 0 && | 540 | if (k > 0 && |
| 534 | ((addrs[k - 1] & PAGE_MASK) | | 541 | ((addrs[k - 1] & PAGE_MASK) + |
| 535 | ((addrs[k - 1] & ~PAGE_MASK) + 1) << PAGE_SHIFT) | 542 | (((addrs[k - 1] & ~PAGE_MASK) + 1) << PAGE_SHIFT)) |
| 536 | == addr) { | 543 | == (addr & PAGE_MASK)) |
| 537 | addrs[k - 1] += (len >> PAGE_SHIFT); | 544 | addrs[k - 1] += ((len + PAGE_SIZE - 1) >> PAGE_SHIFT); |
| 538 | } else { | 545 | else |
| 539 | addrs[k++] = addr | ((len >> PAGE_SHIFT) - 1); | 546 | addrs[k++] = (addr & PAGE_MASK) | |
| 540 | } | 547 | (((len + PAGE_SIZE - 1) >> PAGE_SHIFT) - 1); |
| 541 | } | 548 | } |
| 542 | 549 | ||
| 543 | /* Partial cache lines (fragments) require special measures */ | 550 | /* Partial cache lines (fragments) require special measures */ |
