.. | .. |
---|
221 | 221 | bool slave_aborted; |
---|
222 | 222 | bool cs_inactive; /* spi slave tansmition stop when cs inactive */ |
---|
223 | 223 | bool cs_high_supported; /* native CS supports active-high polarity */ |
---|
| 224 | + struct gpio_desc *ready; /* spi slave transmission ready */ |
---|
224 | 225 | |
---|
225 | 226 | struct spi_transfer *xfer; /* Store xfer temporarily */ |
---|
226 | 227 | phys_addr_t base_addr_phy; |
---|
.. | .. |
---|
477 | 478 | { |
---|
478 | 479 | u32 i; |
---|
479 | 480 | |
---|
480 | | - /* burst size: 1, 2, 4, 8 */ |
---|
481 | | - for (i = 1; i < 8; i <<= 1) { |
---|
| 481 | + /* burst size: 1, 2, 4, 8, 16 */ |
---|
| 482 | + for (i = 1; i < 16; i <<= 1) { |
---|
482 | 483 | if (data_len & i) |
---|
483 | 484 | break; |
---|
484 | 485 | } |
---|
.. | .. |
---|
859 | 860 | ret = rockchip_spi_prepare_irq(rs, ctlr, xfer); |
---|
860 | 861 | } |
---|
861 | 862 | |
---|
| 863 | + if (rs->ready) { |
---|
| 864 | + gpiod_set_value(rs->ready, 0); |
---|
| 865 | + udelay(1); |
---|
| 866 | + gpiod_set_value(rs->ready, 1); |
---|
| 867 | + } |
---|
| 868 | + |
---|
862 | 869 | if (ret > 0) |
---|
863 | 870 | ret = rockchip_spi_transfer_wait(ctlr, xfer); |
---|
| 871 | + |
---|
| 872 | + if (rs->ready) |
---|
| 873 | + gpiod_set_value(rs->ready, 0); |
---|
864 | 874 | |
---|
865 | 875 | return ret; |
---|
866 | 876 | } |
---|
.. | .. |
---|
896 | 906 | cr0 |= ((spi->mode & 0x3) << CR0_SCPH_OFFSET); |
---|
897 | 907 | if (spi->mode & SPI_CS_HIGH) |
---|
898 | 908 | cr0 |= BIT(spi->chip_select) << CR0_SOI_OFFSET; |
---|
| 909 | + if (spi_controller_is_slave(spi->controller)) |
---|
| 910 | + cr0 |= CR0_OPM_SLAVE << CR0_OPM_OFFSET; |
---|
899 | 911 | |
---|
900 | 912 | writel_relaxed(cr0, rs->regs + ROCKCHIP_SPI_CTRLR0); |
---|
901 | 913 | |
---|
.. | .. |
---|
969 | 981 | bool slave_mode; |
---|
970 | 982 | struct pinctrl *pinctrl = NULL; |
---|
971 | 983 | const struct rockchip_spi_quirks *quirks_cfg; |
---|
| 984 | + u32 val; |
---|
972 | 985 | |
---|
973 | 986 | slave_mode = of_property_read_bool(np, "spi-slave"); |
---|
974 | 987 | |
---|
.. | .. |
---|
982 | 995 | if (!ctlr) |
---|
983 | 996 | return -ENOMEM; |
---|
984 | 997 | |
---|
| 998 | + ctlr->rt = device_property_read_bool(&pdev->dev, "rockchip,rt"); |
---|
985 | 999 | platform_set_drvdata(pdev, ctlr); |
---|
986 | 1000 | |
---|
987 | 1001 | rs = spi_controller_get_devdata(ctlr); |
---|
.. | .. |
---|
1095 | 1109 | if (quirks_cfg) |
---|
1096 | 1110 | rs->max_baud_div_in_cpha = quirks_cfg->max_baud_div_in_cpha; |
---|
1097 | 1111 | |
---|
| 1112 | + if (!device_property_read_u32(&pdev->dev, "rockchip,autosuspend-delay-ms", &val)) { |
---|
| 1113 | + if (val > 0) { |
---|
| 1114 | + pm_runtime_set_autosuspend_delay(&pdev->dev, val); |
---|
| 1115 | + pm_runtime_use_autosuspend(&pdev->dev); |
---|
| 1116 | + } |
---|
| 1117 | + } |
---|
| 1118 | + |
---|
1098 | 1119 | pm_runtime_set_active(&pdev->dev); |
---|
1099 | 1120 | pm_runtime_enable(&pdev->dev); |
---|
1100 | 1121 | |
---|
.. | .. |
---|
1175 | 1196 | rs->cs_inactive = false; |
---|
1176 | 1197 | break; |
---|
1177 | 1198 | } |
---|
| 1199 | + if (device_property_read_bool(&pdev->dev, "rockchip,cs-inactive-disable")) |
---|
| 1200 | + rs->cs_inactive = false; |
---|
1178 | 1201 | |
---|
1179 | 1202 | pinctrl = devm_pinctrl_get(&pdev->dev); |
---|
1180 | 1203 | if (!IS_ERR(pinctrl)) { |
---|
.. | .. |
---|
1183 | 1206 | dev_warn(&pdev->dev, "no high_speed pinctrl state\n"); |
---|
1184 | 1207 | rs->high_speed_state = NULL; |
---|
1185 | 1208 | } |
---|
| 1209 | + } |
---|
| 1210 | + |
---|
| 1211 | + rs->ready = devm_gpiod_get_optional(&pdev->dev, "ready", GPIOD_OUT_HIGH); |
---|
| 1212 | + if (IS_ERR(rs->ready)) { |
---|
| 1213 | + ret = dev_err_probe(&pdev->dev, PTR_ERR(rs->ready), |
---|
| 1214 | + "invalid ready-gpios property in node\n"); |
---|
| 1215 | + goto err_free_dma_rx; |
---|
1186 | 1216 | } |
---|
1187 | 1217 | |
---|
1188 | 1218 | ret = devm_spi_register_controller(&pdev->dev, ctlr); |
---|
.. | .. |
---|
1207 | 1237 | dev_info(&pdev->dev, "register misc device %s\n", misc_name); |
---|
1208 | 1238 | } |
---|
1209 | 1239 | |
---|
1210 | | - dev_info(rs->dev, "probed, poll=%d, rsd=%d\n", rs->poll, rs->rsd); |
---|
| 1240 | + dev_info(rs->dev, "probed, poll=%d, rsd=%d, cs-inactive=%d, ready=%d\n", |
---|
| 1241 | + rs->poll, rs->rsd, rs->cs_inactive, rs->ready ? 1 : 0); |
---|
1211 | 1242 | |
---|
1212 | 1243 | return 0; |
---|
1213 | 1244 | |
---|