10 #include <linux/module.h>
11 #include <linux/kernel.h>
12 #include <linux/device.h>
18 #include <linux/slab.h>
33 #define DMA_TEST_SIZE 2048
50 u8 txbuf[14] = {0xDE, 0xAD, 0xBE, 0xEF, 0x2B, 0xAD,
51 0xCA, 0xFE, 0xBA, 0xBE, 0xB1, 0x05,
61 if (bigtxbuf_virtual ==
NULL) {
79 pr_info(
"Simple test 1: write 0xAA byte, read back garbage byte "
81 status = spi_w8r8(spi, 0xAA);
83 pr_warning(
"Siple test 1: FAILURE: spi_write_then_read "
84 "failed with status %d\n", status);
86 pr_info(
"Simple test 1: SUCCESS!\n");
88 pr_info(
"Simple test 2: write 8 bytes, read back 8 bytes garbage "
89 "in 8bit mode (full FIFO)\n");
92 pr_warning(
"Simple test 2: FAILURE: spi_write_then_read() "
93 "failed with status %d\n", status);
95 pr_info(
"Simple test 2: SUCCESS!\n");
97 pr_info(
"Simple test 3: write 14 bytes, read back 14 bytes garbage "
98 "in 8bit mode (see if we overflow FIFO)\n");
101 pr_warning(
"Simple test 3: FAILURE: failed with status %d "
102 "(probably FIFO overrun)\n", status);
104 pr_info(
"Simple test 3: SUCCESS!\n");
106 pr_info(
"Simple test 4: write 8 bytes with spi_write(), read 8 "
107 "bytes garbage with spi_read() in 8bit mode\n");
108 status = spi_write(spi, &txbuf[0], 8);
110 pr_warning(
"Simple test 4 step 1: FAILURE: spi_write() "
111 "failed with status %d\n", status);
113 pr_info(
"Simple test 4 step 1: SUCCESS!\n");
114 status = spi_read(spi, &rxbuf[0], 8);
116 pr_warning(
"Simple test 4 step 2: FAILURE: spi_read() "
117 "failed with status %d\n", status);
119 pr_info(
"Simple test 4 step 2: SUCCESS!\n");
121 pr_info(
"Simple test 5: write 14 bytes with spi_write(), read "
122 "14 bytes garbage with spi_read() in 8bit mode\n");
123 status = spi_write(spi, &txbuf[0], 14);
125 pr_warning(
"Simple test 5 step 1: FAILURE: spi_write() "
126 "failed with status %d (probably FIFO overrun)\n",
129 pr_info(
"Simple test 5 step 1: SUCCESS!\n");
130 status = spi_read(spi, &rxbuf[0], 14);
132 pr_warning(
"Simple test 5 step 2: FAILURE: spi_read() "
133 "failed with status %d (probably FIFO overrun)\n",
136 pr_info(
"Simple test 5: SUCCESS!\n");
138 pr_info(
"Simple test 6: write %d bytes with spi_write(), "
139 "read %d bytes garbage with spi_read() in 8bit mode\n",
141 status = spi_write(spi, &bigtxbuf_virtual[0],
DMA_TEST_SIZE);
143 pr_warning(
"Simple test 6 step 1: FAILURE: spi_write() "
144 "failed with status %d (probably FIFO overrun)\n",
147 pr_info(
"Simple test 6 step 1: SUCCESS!\n");
150 pr_warning(
"Simple test 6 step 2: FAILURE: spi_read() "
151 "failed with status %d (probably FIFO overrun)\n",
154 pr_info(
"Simple test 6: SUCCESS!\n");
165 pr_info(
"Simple test 7: write 0xAA byte, read back garbage byte "
166 "in 16bit bus mode\n");
167 status = spi_w8r8(spi, 0xAA);
169 pr_info(
"Simple test 7: SUCCESS! (expected failure with "
172 pr_warning(
"Siple test 7: FAILURE: spi_write_then_read "
173 "failed with status %d\n", status);
175 pr_warning(
"Siple test 7: FAILURE: spi_write_then_read "
176 "succeeded but it was expected to fail!\n");
178 pr_info(
"Simple test 8: write 8 bytes, read back 8 bytes garbage "
179 "in 16bit mode (full FIFO)\n");
182 pr_warning(
"Simple test 8: FAILURE: spi_write_then_read() "
183 "failed with status %d\n", status);
185 pr_info(
"Simple test 8: SUCCESS!\n");
187 pr_info(
"Simple test 9: write 14 bytes, read back 14 bytes garbage "
188 "in 16bit mode (see if we overflow FIFO)\n");
191 pr_warning(
"Simple test 9: FAILURE: failed with status %d "
192 "(probably FIFO overrun)\n", status);
194 pr_info(
"Simple test 9: SUCCESS!\n");
196 pr_info(
"Simple test 10: write %d bytes with spi_write(), "
197 "read %d bytes garbage with spi_read() in 16bit mode\n",
199 status = spi_write(spi, &bigtxbuf_virtual[0],
DMA_TEST_SIZE);
201 pr_warning(
"Simple test 10 step 1: FAILURE: spi_write() "
202 "failed with status %d (probably FIFO overrun)\n",
205 pr_info(
"Simple test 10 step 1: SUCCESS!\n");
209 pr_warning(
"Simple test 10 step 2: FAILURE: spi_read() "
210 "failed with status %d (probably FIFO overrun)\n",
213 pr_info(
"Simple test 10: SUCCESS!\n");
215 status =
sprintf(buf,
"loop test complete\n");
216 kfree(bigrxbuf_virtual);
217 kfree(bigtxbuf_virtual);
227 struct dummy *p_dummy;
232 p_dummy = kzalloc(
sizeof *p_dummy,
GFP_KERNEL);
242 dev_dbg(&spi->
dev,
"device_create_file looptest failure.\n");
243 goto out_dev_create_looptest_failed;
248 out_dev_create_looptest_failed:
258 dev_info(&spi->
dev,
"removing dummy SPI device\n");
266 static struct spi_driver pl022_dummy_driver = {
271 .probe = pl022_dummy_probe,
275 static int __init pl022_init_dummy(
void)
280 static void __exit pl022_exit_dummy(
void)
282 spi_unregister_driver(&pl022_dummy_driver);