hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/spi/spi-rockchip.c
....@@ -221,6 +221,7 @@
221221 bool slave_aborted;
222222 bool cs_inactive; /* spi slave tansmition stop when cs inactive */
223223 bool cs_high_supported; /* native CS supports active-high polarity */
224
+ struct gpio_desc *ready; /* spi slave transmission ready */
224225
225226 struct spi_transfer *xfer; /* Store xfer temporarily */
226227 phys_addr_t base_addr_phy;
....@@ -859,8 +860,17 @@
859860 ret = rockchip_spi_prepare_irq(rs, ctlr, xfer);
860861 }
861862
863
+ if (rs->ready) {
864
+ gpiod_set_value(rs->ready, 0);
865
+ udelay(1);
866
+ gpiod_set_value(rs->ready, 1);
867
+ }
868
+
862869 if (ret > 0)
863870 ret = rockchip_spi_transfer_wait(ctlr, xfer);
871
+
872
+ if (rs->ready)
873
+ gpiod_set_value(rs->ready, 0);
864874
865875 return ret;
866876 }
....@@ -969,6 +979,7 @@
969979 bool slave_mode;
970980 struct pinctrl *pinctrl = NULL;
971981 const struct rockchip_spi_quirks *quirks_cfg;
982
+ u32 val;
972983
973984 slave_mode = of_property_read_bool(np, "spi-slave");
974985
....@@ -982,6 +993,7 @@
982993 if (!ctlr)
983994 return -ENOMEM;
984995
996
+ ctlr->rt = device_property_read_bool(&pdev->dev, "rockchip,rt");
985997 platform_set_drvdata(pdev, ctlr);
986998
987999 rs = spi_controller_get_devdata(ctlr);
....@@ -1095,6 +1107,13 @@
10951107 if (quirks_cfg)
10961108 rs->max_baud_div_in_cpha = quirks_cfg->max_baud_div_in_cpha;
10971109
1110
+ if (!device_property_read_u32(&pdev->dev, "rockchip,autosuspend-delay-ms", &val)) {
1111
+ if (val > 0) {
1112
+ pm_runtime_set_autosuspend_delay(&pdev->dev, val);
1113
+ pm_runtime_use_autosuspend(&pdev->dev);
1114
+ }
1115
+ }
1116
+
10981117 pm_runtime_set_active(&pdev->dev);
10991118 pm_runtime_enable(&pdev->dev);
11001119
....@@ -1175,6 +1194,8 @@
11751194 rs->cs_inactive = false;
11761195 break;
11771196 }
1197
+ if (device_property_read_bool(&pdev->dev, "rockchip,cs-inactive-disable"))
1198
+ rs->cs_inactive = false;
11781199
11791200 pinctrl = devm_pinctrl_get(&pdev->dev);
11801201 if (!IS_ERR(pinctrl)) {
....@@ -1183,6 +1204,13 @@
11831204 dev_warn(&pdev->dev, "no high_speed pinctrl state\n");
11841205 rs->high_speed_state = NULL;
11851206 }
1207
+ }
1208
+
1209
+ rs->ready = devm_gpiod_get_optional(&pdev->dev, "ready", GPIOD_OUT_HIGH);
1210
+ if (IS_ERR(rs->ready)) {
1211
+ ret = dev_err_probe(&pdev->dev, PTR_ERR(rs->ready),
1212
+ "invalid ready-gpios property in node\n");
1213
+ goto err_free_dma_rx;
11861214 }
11871215
11881216 ret = devm_spi_register_controller(&pdev->dev, ctlr);
....@@ -1207,7 +1235,8 @@
12071235 dev_info(&pdev->dev, "register misc device %s\n", misc_name);
12081236 }
12091237
1210
- dev_info(rs->dev, "probed, poll=%d, rsd=%d\n", rs->poll, rs->rsd);
1238
+ dev_info(rs->dev, "probed, poll=%d, rsd=%d, cs-inactive=%d, ready=%d\n",
1239
+ rs->poll, rs->rsd, rs->cs_inactive, rs->ready ? 1 : 0);
12111240
12121241 return 0;
12131242