summaryrefslogtreecommitdiffstats
path: root/target/linux/ar71xx/patches-4.4/001-revert_spi_device_tree_support.patch
blob: 9821eb7a8586229e2b5d47a1bda1bb2fddc5e5b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
--- a/arch/mips/include/asm/mach-ath79/ath79_spi_platform.h
+++ b/arch/mips/include/asm/mach-ath79/ath79_spi_platform.h
@@ -16,4 +16,8 @@ struct ath79_spi_platform_data {
 	unsigned	num_chipselect;
 };
 
+struct ath79_spi_controller_data {
+	unsigned	gpio;
+};
+
 #endif /* _ATH79_SPI_PLATFORM_H */
--- a/drivers/spi/spi-ath79.c
+++ b/drivers/spi/spi-ath79.c
@@ -79,8 +79,10 @@ static void ath79_spi_chipselect(struct
 	}
 
 	if (spi->chip_select) {
+		struct ath79_spi_controller_data *cdata = spi->controller_data;
+
 		/* SPI is normally active-low */
-		gpio_set_value(spi->cs_gpio, cs_high);
+		gpio_set_value(cdata->gpio, cs_high);
 	} else {
 		if (cs_high)
 			sp->ioc_base |= AR71XX_SPI_IOC_CS0;
@@ -116,9 +118,10 @@ static void ath79_spi_disable(struct ath
 static int ath79_spi_setup_cs(struct spi_device *spi)
 {
 	struct ath79_spi *sp = ath79_spidev_to_sp(spi);
+	struct ath79_spi_controller_data *cdata = spi->controller_data;
 	int status;
 
-	if (spi->chip_select && !gpio_is_valid(spi->cs_gpio))
+	if (spi->chip_select && (!cdata || !gpio_is_valid(cdata->gpio)))
 		return -EINVAL;
 
 	status = 0;
@@ -131,7 +134,7 @@ static int ath79_spi_setup_cs(struct spi
 		else
 			flags |= GPIOF_INIT_HIGH;
 
-		status = gpio_request_one(spi->cs_gpio, flags,
+		status = gpio_request_one(cdata->gpio, flags,
 					  dev_name(&spi->dev));
 	} else {
 		if (spi->mode & SPI_CS_HIGH)
@@ -148,7 +151,8 @@ static int ath79_spi_setup_cs(struct spi
 static void ath79_spi_cleanup_cs(struct spi_device *spi)
 {
 	if (spi->chip_select) {
-		gpio_free(spi->cs_gpio);
+		struct ath79_spi_controller_data *cdata = spi->controller_data;
+		gpio_free(cdata->gpio);
 	}
 }
 
@@ -220,7 +224,6 @@ static int ath79_spi_probe(struct platfo
 	}
 
 	sp = spi_master_get_devdata(master);
-	master->dev.of_node = pdev->dev.of_node;
 	platform_set_drvdata(pdev, sp);
 
 	pdata = dev_get_platdata(&pdev->dev);
@@ -300,18 +303,12 @@ static void ath79_spi_shutdown(struct pl
 	ath79_spi_remove(pdev);
 }
 
-static const struct of_device_id ath79_spi_of_match[] = {
-	{ .compatible = "qca,ar7100-spi", },
-	{ },
-};
-
 static struct platform_driver ath79_spi_driver = {
 	.probe		= ath79_spi_probe,
 	.remove		= ath79_spi_remove,
 	.shutdown	= ath79_spi_shutdown,
 	.driver		= {
 		.name	= DRV_NAME,
-		.of_match_table = ath79_spi_of_match,
 	},
 };
 module_platform_driver(ath79_spi_driver);