Skip to content

Commit c917801

Browse files
authored
Talos QSPI-NOR support (#379)
Talos QSPI-NOR support
2 parents 5bfb36f + ba7bff5 commit c917801

4 files changed

Lines changed: 126 additions & 3 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ properties:
2020
compatible:
2121
items:
2222
- enum:
23+
- qcom,qcs615-qspi
2324
- qcom,sc7180-qspi
2425
- qcom,sc7280-qspi
2526
- qcom,sdm845-qspi

arch/arm64/boot/dts/qcom/qcs615-ride.dts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,18 @@
584584
};
585585
};
586586

587+
&qspi {
588+
status = "okay";
589+
590+
flash@0 {
591+
compatible = "jedec,spi-nor";
592+
reg = <0>;
593+
spi-max-frequency = <25000000>;
594+
spi-tx-bus-width = <2>;
595+
spi-rx-bus-width = <2>;
596+
};
597+
};
598+
587599
&qupv3_id_0 {
588600
status = "okay";
589601
};

arch/arm64/boot/dts/qcom/talos.dtsi

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,25 @@
538538

539539
};
540540

541+
qspi_opp_table: opp-table-qspi {
542+
compatible = "operating-points-v2";
543+
544+
opp-60000000 {
545+
opp-hz = /bits/ 64 <60000000>;
546+
required-opps = <&rpmhpd_opp_low_svs>;
547+
};
548+
549+
opp-133250000 {
550+
opp-hz = /bits/ 64 <133250000>;
551+
required-opps = <&rpmhpd_opp_svs>;
552+
};
553+
554+
opp-266500000 {
555+
opp-hz = /bits/ 64 <266500000>;
556+
required-opps = <&rpmhpd_opp_nom>;
557+
};
558+
};
559+
541560
qup_opp_table: opp-table-qup {
542561
compatible = "operating-points-v2";
543562

@@ -1661,6 +1680,34 @@
16611680
bias-pull-up;
16621681
};
16631682

1683+
qspi_cs0: qspi-cs0-state {
1684+
pins = "gpio44";
1685+
function = "qspi";
1686+
bias-disable;
1687+
drive-strength = <6>;
1688+
};
1689+
1690+
qspi_data0123: qspi-data0123-state {
1691+
pins = "gpio45", "gpio46", "gpio47", "gpio49";
1692+
function = "qspi";
1693+
bias-pull-down;
1694+
drive-strength = <6>;
1695+
};
1696+
1697+
qspi_clk: qspi-clk-state {
1698+
pins = "gpio48";
1699+
function = "qspi";
1700+
bias-pull-down;
1701+
drive-strength = <6>;
1702+
};
1703+
1704+
qspi_cs1: qspi-cs1-state {
1705+
pins = "gpio50";
1706+
function = "qspi";
1707+
bias-pull-down;
1708+
drive-strength = <6>;
1709+
};
1710+
16641711
qup_i2c1_data_clk: qup-i2c1-data-clk-state {
16651712
pins = "gpio4", "gpio5";
16661713
function = "qup0";
@@ -3955,6 +4002,39 @@
39554002
};
39564003
};
39574004

4005+
qspi: spi@88df000 {
4006+
compatible = "qcom,qcs615-qspi",
4007+
"qcom,qspi-v1";
4008+
reg = <0x0 0x088df000 0x0 0x1000>;
4009+
4010+
interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH 0>;
4011+
4012+
clocks = <&gcc GCC_QSPI_CNOC_PERIPH_AHB_CLK>,
4013+
<&gcc GCC_QSPI_CORE_CLK>;
4014+
clock-names = "iface",
4015+
"core";
4016+
4017+
interconnects = <&gem_noc MASTER_APPSS_PROC QCOM_ICC_TAG_ALWAYS
4018+
&config_noc SLAVE_QSPI QCOM_ICC_TAG_ALWAYS>,
4019+
<&aggre1_noc MASTER_QSPI QCOM_ICC_TAG_ALWAYS
4020+
&mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>;
4021+
interconnect-names = "qspi-config",
4022+
"qspi-memory";
4023+
4024+
power-domains = <&rpmhpd RPMHPD_CX>;
4025+
operating-points-v2 = <&qspi_opp_table>;
4026+
4027+
iommus = <&apps_smmu 0x160 0x0>;
4028+
4029+
pinctrl-0 = <&qspi_clk>, <&qspi_cs0>, <&qspi_data0123>;
4030+
pinctrl-names = "default";
4031+
4032+
#address-cells = <1>;
4033+
#size-cells = <0>;
4034+
4035+
status = "disabled";
4036+
};
4037+
39584038
dc_noc: interconnect@9160000 {
39594039
reg = <0x0 0x09160000 0x0 0x3200>;
39604040
compatible = "qcom,qcs615-dc-noc";

drivers/spi/spi-qcom-qspi.c

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ struct qcom_qspi {
174174
void *virt_cmd_desc[QSPI_MAX_SG];
175175
unsigned int n_cmd_desc;
176176
struct icc_path *icc_path_cpu_to_qspi;
177+
struct icc_path *icc_path_mem;
177178
unsigned long last_speed;
178179
/* Lock to protect data accessed by IRQs */
179180
spinlock_t lock;
@@ -272,7 +273,7 @@ static void qcom_qspi_handle_err(struct spi_controller *host,
272273
static int qcom_qspi_set_speed(struct qcom_qspi *ctrl, unsigned long speed_hz)
273274
{
274275
int ret;
275-
unsigned int avg_bw_cpu;
276+
unsigned int avg_bw_cpu, avg_bw_mem;
276277

277278
if (speed_hz == ctrl->last_speed)
278279
return 0;
@@ -285,7 +286,7 @@ static int qcom_qspi_set_speed(struct qcom_qspi *ctrl, unsigned long speed_hz)
285286
}
286287

287288
/*
288-
* Set BW quota for CPU.
289+
* Set BW quota for CPU and memory paths.
289290
* We don't have explicit peak requirement so keep it equal to avg_bw.
290291
*/
291292
avg_bw_cpu = Bps_to_icc(speed_hz);
@@ -296,6 +297,13 @@ static int qcom_qspi_set_speed(struct qcom_qspi *ctrl, unsigned long speed_hz)
296297
return ret;
297298
}
298299

300+
avg_bw_mem = Bps_to_icc(speed_hz);
301+
ret = icc_set_bw(ctrl->icc_path_mem, avg_bw_mem, avg_bw_mem);
302+
if (ret) {
303+
dev_err(ctrl->dev, "ICC BW voting failed for memory: %d\n", ret);
304+
return ret;
305+
}
306+
299307
ctrl->last_speed = speed_hz;
300308

301309
return 0;
@@ -729,6 +737,11 @@ static int qcom_qspi_probe(struct platform_device *pdev)
729737
return dev_err_probe(dev, PTR_ERR(ctrl->icc_path_cpu_to_qspi),
730738
"Failed to get cpu path\n");
731739

740+
ctrl->icc_path_mem = devm_of_icc_get(dev, "qspi-memory");
741+
if (IS_ERR(ctrl->icc_path_mem))
742+
return dev_err_probe(dev, PTR_ERR(ctrl->icc_path_mem),
743+
"Failed to get memory path\n");
744+
732745
/* Set BW vote for register access */
733746
ret = icc_set_bw(ctrl->icc_path_cpu_to_qspi, Bps_to_icc(1000),
734747
Bps_to_icc(1000));
@@ -830,6 +843,13 @@ static int __maybe_unused qcom_qspi_runtime_suspend(struct device *dev)
830843
return ret;
831844
}
832845

846+
ret = icc_disable(ctrl->icc_path_mem);
847+
if (ret) {
848+
dev_err_ratelimited(ctrl->dev, "ICC disable failed for memory: %d\n", ret);
849+
icc_enable(ctrl->icc_path_cpu_to_qspi);
850+
return ret;
851+
}
852+
833853
pinctrl_pm_select_sleep_state(dev);
834854

835855
return 0;
@@ -850,9 +870,19 @@ static int __maybe_unused qcom_qspi_runtime_resume(struct device *dev)
850870
return ret;
851871
}
852872

873+
ret = icc_enable(ctrl->icc_path_mem);
874+
if (ret) {
875+
dev_err_ratelimited(ctrl->dev, "ICC enable failed for memory: %d\n", ret);
876+
icc_disable(ctrl->icc_path_cpu_to_qspi);
877+
return ret;
878+
}
879+
853880
ret = clk_bulk_prepare_enable(QSPI_NUM_CLKS, ctrl->clks);
854-
if (ret)
881+
if (ret) {
882+
icc_disable(ctrl->icc_path_cpu_to_qspi);
883+
icc_disable(ctrl->icc_path_mem);
855884
return ret;
885+
}
856886

857887
return dev_pm_opp_set_rate(dev, ctrl->last_speed * 4);
858888
}

0 commit comments

Comments
 (0)