Skip to content

Commit 460a2c1

Browse files
committed
Merge remote-tracking branch tech/bus/peripherals into qcom-next
2 parents a0731d7 + 6faf7f6 commit 460a2c1

12 files changed

Lines changed: 588 additions & 29 deletions

File tree

Documentation/devicetree/bindings/i2c/qcom,i2c-geni-qcom.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ required:
7575

7676
allOf:
7777
- $ref: /schemas/i2c/i2c-controller.yaml#
78+
- $ref: /schemas/soc/qcom/qcom,se-common-props.yaml#
7879
- if:
7980
properties:
8081
compatible:

Documentation/devicetree/bindings/serial/qcom,serial-geni-qcom.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ maintainers:
1212

1313
allOf:
1414
- $ref: /schemas/serial/serial.yaml#
15+
- $ref: /schemas/soc/qcom/qcom,se-common-props.yaml#
1516

1617
properties:
1718
compatible:
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/soc/qcom/qcom,se-common-props.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: QUP Peripheral-specific properties for I2C, SPI and SERIAL bus
8+
9+
description:
10+
The Generic Interface (GENI) based Qualcomm Universal Peripheral (QUP) is
11+
a programmable module that supports a wide range of serial interfaces
12+
such as UART, SPI, I2C, I3C, etc. This defines the common properties used
13+
across QUP-supported peripherals.
14+
15+
maintainers:
16+
- Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
17+
- Viken Dadhaniya <quic_vdadhani@quicinc.com>
18+
19+
properties:
20+
qcom,enable-gsi-dma:
21+
$ref: /schemas/types.yaml#/definitions/flag
22+
description:
23+
Configure the Serial Engine (SE) to transfer data in QCOM GPI DMA mode.
24+
By default, FIFO mode (PIO/CPU DMA) will be selected.
25+
26+
additionalProperties: true

Documentation/devicetree/bindings/spi/qcom,spi-geni-qcom.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ description:
2525

2626
allOf:
2727
- $ref: /schemas/spi/spi-controller.yaml#
28+
- $ref: /schemas/soc/qcom/qcom,se-common-props.yaml#
2829

2930
properties:
3031
compatible:

drivers/dma/qcom/gpi.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,17 @@ static void gpi_process_xfer_compl_event(struct gchan *gchan,
10721072
dev_dbg(gpii->gpi_dev->dev, "Residue %d\n", result.residue);
10731073

10741074
dma_cookie_complete(&vd->tx);
1075-
dmaengine_desc_get_callback_invoke(&vd->tx, &result);
1075+
if (gchan->protocol == QCOM_GPI_I2C) {
1076+
struct dmaengine_desc_callback cb;
1077+
struct gpi_i2c_result *i2c;
1078+
1079+
dmaengine_desc_get_callback(&vd->tx, &cb);
1080+
i2c = cb.callback_param;
1081+
i2c->status = compl_event->status;
1082+
dmaengine_desc_callback_invoke(&cb, &result);
1083+
} else {
1084+
dmaengine_desc_get_callback_invoke(&vd->tx, &result);
1085+
}
10761086

10771087
gpi_free_desc:
10781088
spin_lock_irqsave(&gchan->vc.lock, flags);

drivers/i2c/busses/i2c-qcom-geni.c

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
33

44
#include <linux/acpi.h>
5+
#include <linux/bitfield.h>
56
#include <linux/clk.h>
67
#include <linux/dmaengine.h>
78
#include <linux/dma-mapping.h>
@@ -67,6 +68,7 @@ enum geni_i2c_err_code {
6768
GENI_TIMEOUT,
6869
};
6970

71+
#define I2C_DMA_TX_IRQ_MASK GENMASK(12, 5)
7072
#define DM_I2C_CB_ERR ((BIT(NACK) | BIT(BUS_PROTO) | BIT(ARB_LOST)) \
7173
<< 5)
7274

@@ -99,6 +101,7 @@ struct geni_i2c_dev {
99101
struct dma_chan *rx_c;
100102
bool gpi_mode;
101103
bool abort_done;
104+
struct gpi_i2c_result i2c_result;
102105
};
103106

104107
struct geni_i2c_desc {
@@ -498,9 +501,18 @@ static int geni_i2c_tx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg,
498501

499502
static void i2c_gpi_cb_result(void *cb, const struct dmaengine_result *result)
500503
{
501-
struct geni_i2c_dev *gi2c = cb;
502-
503-
if (result->result != DMA_TRANS_NOERROR) {
504+
struct gpi_i2c_result *i2c_res = cb;
505+
struct geni_i2c_dev *gi2c = container_of(i2c_res, struct geni_i2c_dev, i2c_result);
506+
u32 status;
507+
508+
status = FIELD_GET(I2C_DMA_TX_IRQ_MASK, i2c_res->status);
509+
if (status == BIT(NACK)) {
510+
geni_i2c_err(gi2c, NACK);
511+
} else if (status == BIT(BUS_PROTO)) {
512+
geni_i2c_err(gi2c, BUS_PROTO);
513+
} else if (status == BIT(ARB_LOST)) {
514+
geni_i2c_err(gi2c, ARB_LOST);
515+
} else if (result->result != DMA_TRANS_NOERROR) {
504516
dev_err(gi2c->se.dev, "DMA txn failed:%d\n", result->result);
505517
gi2c->err = -EIO;
506518
} else if (result->residue) {
@@ -582,7 +594,7 @@ static int geni_i2c_gpi(struct geni_i2c_dev *gi2c, struct i2c_msg *msg,
582594
}
583595

584596
desc->callback_result = i2c_gpi_cb_result;
585-
desc->callback_param = gi2c;
597+
desc->callback_param = &gi2c->i2c_result;
586598

587599
dmaengine_submit(desc);
588600
*buf = dma_buf;
@@ -870,7 +882,13 @@ static int geni_i2c_probe(struct platform_device *pdev)
870882
goto err_clk;
871883
}
872884
proto = geni_se_read_proto(&gi2c->se);
873-
if (proto != GENI_SE_I2C) {
885+
if (proto == GENI_SE_INVALID_PROTO) {
886+
ret = geni_load_se_firmware(&gi2c->se, GENI_SE_I2C);
887+
if (ret) {
888+
dev_err_probe(dev, ret, "i2c firmware load failed ret: %d\n", ret);
889+
goto err_resources;
890+
}
891+
} else if (proto != GENI_SE_I2C) {
874892
ret = dev_err_probe(dev, -ENXIO, "Invalid proto %d\n", proto);
875893
goto err_resources;
876894
}

0 commit comments

Comments
 (0)