hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/spi/spi-bcm63xx.c
....@@ -1,18 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Broadcom BCM63xx SPI controller support
34 *
45 * Copyright (C) 2009-2012 Florian Fainelli <florian@openwrt.org>
56 * Copyright (C) 2010 Tanguy Bouzeloc <tanguy.bouzeloc@efixo.com>
6
- *
7
- * This program is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU General Public License
9
- * as published by the Free Software Foundation; either version 2
10
- * of the License, or (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
167 */
178
189 #include <linux/kernel.h>
....@@ -27,6 +18,7 @@
2718 #include <linux/err.h>
2819 #include <linux/pm_runtime.h>
2920 #include <linux/of.h>
21
+#include <linux/reset.h>
3022
3123 /* BCM 6338/6348 SPI core */
3224 #define SPI_6348_RSET_SIZE 64
....@@ -134,7 +126,7 @@
134126 SPI_MSG_DATA_SIZE,
135127 };
136128
137
-#define BCM63XX_SPI_MAX_PREPEND 15
129
+#define BCM63XX_SPI_MAX_PREPEND 7
138130
139131 #define BCM63XX_SPI_MAX_CS 8
140132 #define BCM63XX_SPI_BUS_NUM 0
....@@ -377,7 +369,7 @@
377369 }
378370
379371 /* CS will be deasserted directly after transfer */
380
- if (t->delay_usecs) {
372
+ if (t->delay_usecs || t->delay.value) {
381373 dev_err(&spi->dev, "unable to keep CS asserted after transfer\n");
382374 status = -EINVAL;
383375 goto exit;
....@@ -502,6 +494,7 @@
502494 struct bcm63xx_spi *bs;
503495 int ret;
504496 u32 num_cs = BCM63XX_SPI_MAX_CS;
497
+ struct reset_control *reset;
505498
506499 if (dev->of_node) {
507500 const struct of_device_id *match;
....@@ -529,16 +522,18 @@
529522 }
530523
531524 irq = platform_get_irq(pdev, 0);
532
- if (irq < 0) {
533
- dev_err(dev, "no irq: %d\n", irq);
525
+ if (irq < 0)
534526 return irq;
535
- }
536527
537528 clk = devm_clk_get(dev, "spi");
538529 if (IS_ERR(clk)) {
539530 dev_err(dev, "no clock for device\n");
540531 return PTR_ERR(clk);
541532 }
533
+
534
+ reset = devm_reset_control_get_optional_exclusive(dev, NULL);
535
+ if (IS_ERR(reset))
536
+ return PTR_ERR(reset);
542537
543538 master = spi_alloc_master(dev, sizeof(*bs));
544539 if (!master) {
....@@ -590,6 +585,12 @@
590585 if (ret)
591586 goto out_err;
592587
588
+ ret = reset_control_reset(reset);
589
+ if (ret) {
590
+ dev_err(dev, "unable to reset device: %d\n", ret);
591
+ goto out_clk_disable;
592
+ }
593
+
593594 bcm_spi_writeb(bs, SPI_INTR_CLEAR_ALL, SPI_INT_STATUS);
594595
595596 /* register and we are done */