obj-$(CONFIG_SPI_ATMEL) += atmel_spi.o
obj-$(CONFIG_SPI_ATH79) += ath79_spi.o
obj-$(CONFIG_SPI_BFIN) += spi_bfin5xx.o
-obj-$(CONFIG_SPI_BFIN_SPORT) += spi_bfin_sport.o
+obj-$(CONFIG_SPI_BFIN_SPORT) += spi_bfin_sport.o
obj-$(CONFIG_SPI_BITBANG) += spi_bitbang.o
obj-$(CONFIG_SPI_AU1550) += au1550_spi.o
obj-$(CONFIG_SPI_BUTTERFLY) += spi_butterfly.o
-obj-$(CONFIG_SPIM_RK29) += rk29_spim.o
-obj-$(CONFIG_SPI_COLDFIRE_QSPI) += coldfire_qspi.o
+obj-$(CONFIG_SPIM_RK29) += rk29_spim.o
+obj-$(CONFIG_RK_SPIM_TEST) += spi_test.o
+obj-$(CONFIG_SPI_COLDFIRE_QSPI) += coldfire_qspi.o
obj-$(CONFIG_SPI_DAVINCI) += davinci_spi.o
-obj-$(CONFIG_SPI_DESIGNWARE) += dw_spi.o
+obj-$(CONFIG_SPI_DESIGNWARE) += dw_spi.o
obj-$(CONFIG_SPI_DW_PCI) += dw_spi_midpci.o
dw_spi_midpci-objs := dw_spi_pci.o dw_spi_mid.o
obj-$(CONFIG_SPI_DW_MMIO) += dw_spi_mmio.o
--- /dev/null
+/*drivers/serial/spi_test.c -spi test driver\r
+ *\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ */\r
+\r
+#include <linux/dma-mapping.h>\r
+#include <linux/interrupt.h>\r
+#include <linux/highmem.h>\r
+#include <linux/delay.h>\r
+#include <linux/slab.h>\r
+#include <linux/platform_device.h>\r
+#include <linux/clk.h>\r
+#include <linux/cpufreq.h>\r
+#include <mach/gpio.h>\r
+#include <mach/irqs.h>\r
+#include <linux/miscdevice.h>\r
+#include <asm/dma.h>\r
+#include <linux/preempt.h>\r
+#include "rk29_spim.h"\r
+#include <linux/spi/spi.h>\r
+#include <mach/board.h>\r
+\r
+struct spi_test_data {\r
+ struct device *dev;\r
+ struct spi_device *spi; \r
+ char *rx_buf;\r
+ int rx_len; \r
+ char *tx_buf;\r
+ int tx_len; \r
+};\r
+static struct spi_test_data *g_spi_test_data;\r
+\r
+\r
+static struct rk29xx_spi_chip spi_test_chip = {\r
+ //.poll_mode = 1,\r
+ .enable_dma = 1,\r
+};\r
+ \r
+static struct spi_board_info board_spi_test_devices[] = { \r
+ {\r
+ .modalias = "spi_test",\r
+ .bus_num = 0, //0 or 1\r
+ .max_speed_hz = 12*1000*1000,\r
+ .chip_select = 0, \r
+ .controller_data = &spi_test_chip,\r
+ }, \r
+ \r
+};\r
+\r
+static ssize_t spi_test_write(struct file *file, \r
+ const char __user *buf, size_t count, loff_t *offset)\r
+{\r
+ char nr_buf[8];\r
+ int nr = 0, ret;\r
+ int i = 0;\r
+ struct spi_device *spi = g_spi_test_data->spi;\r
+ char txbuf[256],rxbuf[256];\r
+\r
+ if(count > 3)\r
+ return -EFAULT;\r
+ ret = copy_from_user(nr_buf, buf, count);\r
+ if(ret < 0)\r
+ return -EFAULT;\r
+\r
+ sscanf(nr_buf, "%d", &nr);\r
+ if(nr >= 2 || nr < 0)\r
+ {\r
+ printk("%s:data is error\n",__func__);\r
+ return -EFAULT;\r
+ }\r
+ \r
+ for(i=0; i<256; i++)\r
+ txbuf[i] = i;\r
+\r
+ switch(nr)\r
+ {\r
+ case 0:\r
+ spi->chip_select = 0;\r
+ break;\r
+ case 1:\r
+ spi->chip_select = 1;\r
+ break;\r
+\r
+ default:\r
+ break;\r
+\r
+ }\r
+\r
+ for(i=0; i<10; i++)\r
+ {\r
+ ret = spi_write(spi, txbuf, 256);\r
+ ret = spi_read(spi, rxbuf, 256);\r
+ ret = spi_write_then_read(spi,txbuf,256,rxbuf,256);\r
+ printk("%s:test %d times\n\n",__func__,i+1);\r
+ }\r
+ \r
+ if(!ret)\r
+ printk("%s:ok\n",__func__);\r
+ else\r
+ printk("%s:error\n",__func__);\r
+ \r
+ return count;\r
+}\r
+\r
+\r
+static const struct file_operations spi_test_fops = {\r
+ .write = spi_test_write,\r
+};\r
+\r
+static struct miscdevice spi_test_misc = {\r
+ .minor = MISC_DYNAMIC_MINOR,\r
+ .name = "spi_misc_test",\r
+ .fops = &spi_test_fops,\r
+};\r
+\r
+static int __devinit spi_test_probe(struct spi_device *spi)\r
+{ \r
+ struct spi_test_data *spi_test_data;\r
+ int ret;\r
+ \r
+ spi_test_data = (struct spi_test_data *)kzalloc(sizeof(struct spi_test_data), GFP_KERNEL);\r
+ if(!spi_test_data){\r
+ dev_err(&spi->dev, "ERR: no memory for spi_test_data\n");\r
+ return -ENOMEM;
+ }\r
+\r
+ spi->bits_per_word = 8;\r
+ spi->mode = SPI_MODE_0;\r
+ \r
+ spi_test_data->spi = spi;\r
+ spi_test_data->dev = &spi->dev;\r
+ ret = spi_setup(spi);\r
+ if (ret < 0){\r
+ dev_err(spi_test_data->dev, "ERR: fail to setup spi\n");\r
+ return -1;\r
+ } \r
+\r
+ g_spi_test_data = spi_test_data;\r
+\r
+ printk("%s:bus_num=%d,ok\n",__func__,spi->bus_num);\r
+\r
+ return ret;\r
+\r
+}\r
+\r
+\r
+static struct spi_driver spi_test_driver = {\r
+ .driver = {\r
+ .name = "spi_test",\r
+ .bus = &spi_bus_type,\r
+ .owner = THIS_MODULE,\r
+ },\r
+\r
+ .probe = spi_test_probe,\r
+};\r
+\r
+static int __init spi_test_init(void)\r
+{ \r
+ spi_register_board_info(board_spi_test_devices, ARRAY_SIZE(board_spi_test_devices));\r
+ misc_register(&spi_test_misc);\r
+ return spi_register_driver(&spi_test_driver);\r
+}\r
+\r
+static void __exit spi_test_exit(void)\r
+{\r
+ misc_deregister(&spi_test_misc);\r
+ return spi_unregister_driver(&spi_test_driver);\r
+}\r
+module_init(spi_test_init);\r
+module_exit(spi_test_exit);\r
+\r