18 #include <linux/errno.h>
19 #include <linux/module.h>
26 #define DRV_NAME "spi_altera"
28 #define ALTERA_SPI_RXDATA 0
29 #define ALTERA_SPI_TXDATA 4
30 #define ALTERA_SPI_STATUS 8
31 #define ALTERA_SPI_CONTROL 12
32 #define ALTERA_SPI_SLAVE_SEL 20
34 #define ALTERA_SPI_STATUS_ROE_MSK 0x8
35 #define ALTERA_SPI_STATUS_TOE_MSK 0x10
36 #define ALTERA_SPI_STATUS_TMT_MSK 0x20
37 #define ALTERA_SPI_STATUS_TRDY_MSK 0x40
38 #define ALTERA_SPI_STATUS_RRDY_MSK 0x80
39 #define ALTERA_SPI_STATUS_E_MSK 0x100
41 #define ALTERA_SPI_CONTROL_IROE_MSK 0x8
42 #define ALTERA_SPI_CONTROL_ITOE_MSK 0x10
43 #define ALTERA_SPI_CONTROL_ITRDY_MSK 0x40
44 #define ALTERA_SPI_CONTROL_IRRDY_MSK 0x80
45 #define ALTERA_SPI_CONTROL_IE_MSK 0x100
46 #define ALTERA_SPI_CONTROL_SSO_MSK 0x400
61 const unsigned char *
tx;
67 return spi_master_get_devdata(sdev->
master);
111 static int altera_spi_setup(
struct spi_device *spi)
123 return (hw->
tx[count * 2]
124 | (hw->
tx[count * 2 + 1] << 8));
132 struct altera_spi *hw = altera_spi_to_hw(spi);
171 hw->
rx[hw->
count * 2 + 1] = rxd >> 8;
203 hw->
rx[hw->
count * 2 + 1] = rxd >> 8;
220 struct altera_spi_platform_data *platp = pdev->
dev.platform_data;
234 master->
setup = altera_spi_setup;
236 hw = spi_master_get_devdata(master);
237 platform_set_drvdata(pdev, hw);
240 hw->
bitbang.master = spi_master_get(master);
243 hw->
bitbang.setup_transfer = altera_spi_setupxfer;
244 hw->
bitbang.chipselect = altera_spi_chipsel;
245 hw->
bitbang.txrx_bufs = altera_spi_txrx;
267 init_completion(&hw->
done);
268 err = devm_request_irq(&pdev->
dev, hw->
irq, altera_spi_irq, 0,
275 hw->
bitbang.master->dev.of_node = pdev->
dev.of_node;
288 platform_set_drvdata(pdev,
NULL);
289 spi_master_put(master);
295 struct altera_spi *hw = platform_get_drvdata(dev);
299 platform_set_drvdata(dev,
NULL);
300 spi_master_put(master);
313 .probe = altera_spi_probe,