Skip to content

Commit 793681d

Browse files
committed
add COMPILE_TEST support
Merge series from Rosen Penev <rosenp@gmail.com>: Allows the buildbots to test compilation. The driver has nothing architecture specific.
2 parents c42e36a + ff9a785 commit 793681d

2 files changed

Lines changed: 18 additions & 21 deletions

File tree

drivers/spi/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,8 @@ config SPI_ROCKCHIP_SFC
916916

917917
config SPI_RB4XX
918918
tristate "Mikrotik RB4XX SPI master"
919-
depends on SPI_MASTER && ATH79
919+
depends on SPI_MASTER && (ATH79 || COMPILE_TEST)
920+
depends on OF
920921
help
921922
SPI controller driver for the Mikrotik RB4xx series boards.
922923

drivers/spi/spi-rb4xx.c

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@
1616
#include <linux/spi/spi.h>
1717
#include <linux/of.h>
1818

19-
#include <asm/mach-ath79/ar71xx_regs.h>
19+
#define AR71XX_SPI_REG_FS 0x00 /* Function Select */
20+
#define AR71XX_SPI_REG_CTRL 0x04 /* SPI Control */
21+
#define AR71XX_SPI_REG_IOC 0x08 /* SPI I/O Control */
22+
#define AR71XX_SPI_REG_RDS 0x0c /* Read Data Shift */
23+
24+
#define AR71XX_SPI_FS_GPIO BIT(0) /* Enable GPIO mode */
25+
26+
#define AR71XX_SPI_IOC_DO BIT(0) /* Data Out pin */
27+
#define AR71XX_SPI_IOC_CLK BIT(8) /* CLK pin */
28+
#define AR71XX_SPI_IOC_CS(n) BIT(16 + (n))
2029

2130
struct rb4xx_spi {
2231
void __iomem *base;
@@ -63,7 +72,7 @@ static inline void do_spi_clk_two(struct rb4xx_spi *rbspi, u32 spi_ioc,
6372
if (value & BIT(1))
6473
regval |= AR71XX_SPI_IOC_DO;
6574
if (value & BIT(0))
66-
regval |= AR71XX_SPI_IOC_CS2;
75+
regval |= AR71XX_SPI_IOC_CS(2);
6776

6877
rb4xx_write(rbspi, AR71XX_SPI_REG_IOC, regval);
6978
rb4xx_write(rbspi, AR71XX_SPI_REG_IOC, regval | AR71XX_SPI_IOC_CLK);
@@ -89,7 +98,7 @@ static void rb4xx_set_cs(struct spi_device *spi, bool enable)
8998
*/
9099
if (enable)
91100
rb4xx_write(rbspi, AR71XX_SPI_REG_IOC,
92-
AR71XX_SPI_IOC_CS0 | AR71XX_SPI_IOC_CS1);
101+
AR71XX_SPI_IOC_CS(0) | AR71XX_SPI_IOC_CS(1));
93102
}
94103

95104
static int rb4xx_transfer_one(struct spi_controller *host,
@@ -109,10 +118,10 @@ static int rb4xx_transfer_one(struct spi_controller *host,
109118
*/
110119
if (spi_get_chipselect(spi, 0) == 2)
111120
/* MMC */
112-
spi_ioc = AR71XX_SPI_IOC_CS0;
121+
spi_ioc = AR71XX_SPI_IOC_CS(0);
113122
else
114123
/* Boot flash and CPLD */
115-
spi_ioc = AR71XX_SPI_IOC_CS1;
124+
spi_ioc = AR71XX_SPI_IOC_CS(1);
116125

117126
tx_buf = t->tx_buf;
118127
rx_buf = t->rx_buf;
@@ -147,7 +156,7 @@ static int rb4xx_spi_probe(struct platform_device *pdev)
147156
if (!host)
148157
return -ENOMEM;
149158

150-
ahb_clk = devm_clk_get(&pdev->dev, "ahb");
159+
ahb_clk = devm_clk_get_enabled(&pdev->dev, "ahb");
151160
if (IS_ERR(ahb_clk))
152161
return PTR_ERR(ahb_clk);
153162

@@ -163,31 +172,19 @@ static int rb4xx_spi_probe(struct platform_device *pdev)
163172
rbspi = spi_controller_get_devdata(host);
164173
rbspi->base = spi_base;
165174
rbspi->clk = ahb_clk;
166-
platform_set_drvdata(pdev, rbspi);
167175

168176
err = devm_spi_register_controller(&pdev->dev, host);
169177
if (err) {
170178
dev_err(&pdev->dev, "failed to register SPI host\n");
171179
return err;
172180
}
173181

174-
err = clk_prepare_enable(ahb_clk);
175-
if (err)
176-
return err;
177-
178182
/* Enable SPI */
179183
rb4xx_write(rbspi, AR71XX_SPI_REG_FS, AR71XX_SPI_FS_GPIO);
180184

181185
return 0;
182186
}
183187

184-
static void rb4xx_spi_remove(struct platform_device *pdev)
185-
{
186-
struct rb4xx_spi *rbspi = platform_get_drvdata(pdev);
187-
188-
clk_disable_unprepare(rbspi->clk);
189-
}
190-
191188
static const struct of_device_id rb4xx_spi_dt_match[] = {
192189
{ .compatible = "mikrotik,rb4xx-spi" },
193190
{ },
@@ -196,10 +193,9 @@ MODULE_DEVICE_TABLE(of, rb4xx_spi_dt_match);
196193

197194
static struct platform_driver rb4xx_spi_drv = {
198195
.probe = rb4xx_spi_probe,
199-
.remove = rb4xx_spi_remove,
200196
.driver = {
201197
.name = "rb4xx-spi",
202-
.of_match_table = of_match_ptr(rb4xx_spi_dt_match),
198+
.of_match_table = rb4xx_spi_dt_match,
203199
},
204200
};
205201

0 commit comments

Comments
 (0)