1717 spi_test@00 {
1818 compatible = "rockchip,spi_test_bus0_cs0";
1919 reg = <0>; //chip select 0:cs0 1:cs1
20+ id = <0>;
2021 spi-max-frequency = <24000000>; //spi output clock
2122 //spi-cpha; not support
2223 //spi-cpol; //if the property is here it is 1:clk is high, else 0:clk is low when idle
2526 spi_test@01 {
2627 compatible = "rockchip,spi_test_bus0_cs1";
2728 reg = <1>;
29+ id = <1>;
2830 spi-max-frequency = <24000000>;
2931 spi-cpha;
3032 spi-cpol;
3638* echo write 0 10 255 > /dev/spi_misc_test
3739* echo write 0 10 255 init.rc > /dev/spi_misc_test
3840* echo read 0 10 255 > /dev/spi_misc_test
41+ * echo loop 0 10 255 > /dev/spi_misc_test
3942* echo setspeed 0 1000000 > /dev/spi_misc_test
4043*/
4144
6164#include <linux/platform_data/spi-rockchip.h>
6265#include <asm/uaccess.h>
6366#include <linux/syscalls.h>
64- #include "spi-rockchip-core.h"
6567
6668#define MAX_SPI_DEV_NUM 6
6769#define SPI_MAX_SPEED_HZ 12000000
@@ -314,9 +316,11 @@ static ssize_t spi_test_write(struct file *file,
314316 kfree (txbuf );
315317 kfree (rxbuf );
316318 } else {
319+ printk ("echo id number size > /dev/spi_misc_test\n" );
317320 printk ("echo write 0 10 255 > /dev/spi_misc_test\n" );
318321 printk ("echo write 0 10 255 init.rc > /dev/spi_misc_test\n" );
319322 printk ("echo read 0 10 255 > /dev/spi_misc_test\n" );
323+ printk ("echo loop 0 10 255 > /dev/spi_misc_test\n" );
320324 printk ("echo setspeed 0 1000000 > /dev/spi_misc_test\n" );
321325 }
322326
@@ -333,60 +337,10 @@ static struct miscdevice spi_test_misc = {
333337 .fops = & spi_test_fops ,
334338};
335339
336- #ifdef CONFIG_OF
337- static struct dw_spi_chip * rockchip_spi_parse_dt (struct device * dev )
338- {
339- u32 temp ;
340- struct dw_spi_chip * spi_chip_data ;
341-
342- spi_chip_data = devm_kzalloc (dev , sizeof (* spi_chip_data ), GFP_KERNEL );
343- if (!spi_chip_data ) {
344- dev_err (dev , "memory allocation for spi_chip_data failed\n" );
345- return ERR_PTR (- ENOMEM );
346- }
347-
348- if (of_property_read_u32 (dev -> of_node , "poll_mode" , & temp )) {
349- dev_warn (dev , "fail to get poll_mode, default set 0\n" );
350- spi_chip_data -> poll_mode = 0 ;
351- } else {
352- spi_chip_data -> poll_mode = temp ;
353- }
354-
355- if (of_property_read_u32 (dev -> of_node , "type" , & temp )) {
356- dev_warn (dev , "fail to get type, default set 0\n" );
357- spi_chip_data -> type = 0 ;
358- } else {
359- spi_chip_data -> type = temp ;
360- }
361-
362- if (of_property_read_u32 (dev -> of_node , "enable_dma" , & temp )) {
363- dev_warn (dev , "fail to get enable_dma, default set 0\n" );
364- spi_chip_data -> enable_dma = 0 ;
365- } else {
366- spi_chip_data -> enable_dma = temp ;
367- }
368- #if 0
369- if (of_property_read_u32 (dev -> of_node , "slave-enable" , & temp )) {
370- dev_warn (dev , "fail to get slave-enable, default set 0\n" );
371- spi_chip_data -> slave_enable = 0 ;
372- } else {
373- spi_chip_data -> slave_enable = temp ;
374- }
375- #endif
376- return spi_chip_data ;
377- }
378- #else
379- static struct spi_board_info * rockchip_spi_parse_dt (struct device * dev )
380- {
381- return dev -> platform_data ;
382- }
383- #endif
384-
385340static int rockchip_spi_test_probe (struct spi_device * spi )
386341{
387342 int ret ;
388343 int id = 0 ;
389- struct dw_spi_chip * spi_chip_data = NULL ;
390344 struct spi_test_data * spi_test_data = NULL ;
391345
392346 if (!spi )
@@ -395,17 +349,12 @@ static int rockchip_spi_test_probe(struct spi_device *spi)
395349 if (!spi -> dev .of_node )
396350 return - ENOMEM ;
397351
398- spi_chip_data = rockchip_spi_parse_dt (& spi -> dev );
399- if (IS_ERR (spi_chip_data ))
400- return - ENOMEM ;
401-
402352 spi_test_data = (struct spi_test_data * )kzalloc (sizeof (struct spi_test_data ), GFP_KERNEL );
403353 if (!spi_test_data ) {
404354 dev_err (& spi -> dev , "ERR: no memory for spi_test_data\n" );
405355 return - ENOMEM ;
406356 }
407357 spi -> bits_per_word = 8 ;
408- spi -> controller_data = spi_chip_data ;
409358
410359 spi_test_data -> spi = spi ;
411360 spi_test_data -> dev = & spi -> dev ;
@@ -425,7 +374,6 @@ static int rockchip_spi_test_probe(struct spi_device *spi)
425374
426375 printk ("%s:name=%s,bus_num=%d,cs=%d,mode=%d,speed=%d\n" , __func__ , spi -> modalias , spi -> master -> bus_num , spi -> chip_select , spi -> mode , spi -> max_speed_hz );
427376
428- printk ("%s:poll_mode=%d, type=%d, enable_dma=%d\n" , __func__ , spi_chip_data -> poll_mode , spi_chip_data -> type , spi_chip_data -> enable_dma );
429377 return ret ;
430378}
431379
0 commit comments