• «
  • 1
  • 2
  • »
  • Pages: 1/2     Go
主题 : spi片选的问题!!!!!求救救 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 16814
精华: 0
发帖: 11
金钱: 55 两
威望: 11 点
综合积分: 22 分
注册时间: 2010-03-22
最后登录: 2011-07-08
楼主  发表于: 2010-04-08 13:44

 spi片选的问题!!!!!求救救

我现在研究spi驱动,在2.6.29内核里,有一个问题想问你,就是
    /* setup any gpio we can */

    if (!pdata->set_cs) {
        if (pdata->pin_cs < 0) {
            dev_err(&pdev->dev, "No chipselect pin\n");
            goto err_register;
        }

        err = gpio_request(pdata->pin_cs, dev_name(&pdev->dev));
        if (err) {
            dev_err(&pdev->dev, "Failed to get gpio for cs\n");
            goto err_register;
        }

        hw->set_cs = s3c24xx_spi_gpiocs;
        gpio_direction_output(pdata->pin_cs, 1);
    } else
        hw->set_cs = pdata->set_cs;

上面代码是不是设置片选呢?为什么我设置的不对(我的不是三星的芯片),快崩溃了,望回复!!感激不尽

我板子上电时的错误:
<3>s3c2410-spi s3c2410-spi.0: Failed to get gpio for cs
s3c2410-spi s3c2410-spi.0: Failed to get gpio for cs
<4>s3c2410-spi: probe of s3c2410-spi.0 failed with error -38
s3c2410-spi: probe of s3c2410-spi.0 failed with error -38

为什么会失败呢???怎么解决??望指点。。。
如果我上面得if里的注释掉,会有部分乱码,但别的都对。也能注册。。好奇怪
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2010-04-08 15:56
err = gpio_request(pdata->pin_cs, dev_name(&pdev->dev));
        if (err) {
            dev_err(&pdev->dev, "Failed to get gpio for cs\n");
            goto err_register;
        }

代码就在那里,看不懂吗?
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 16814
精华: 0
发帖: 11
金钱: 55 两
威望: 11 点
综合积分: 22 分
注册时间: 2010-03-22
最后登录: 2011-07-08
2楼  发表于: 2010-04-08 16:50
恩,你知道 gpio_request调用的是什么吗??为什么没调用gpiolib.c下的呢????通过跟踪,调用的是linux/include/gpio.h里的static inline int gpio_request(unsigned gpio, const char *label)
{
    return -ENOSYS;
}
这个好像不对啊????为什么??
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
3楼  发表于: 2010-04-08 16:58
如果你的内核用的是这个gpio_request(),说明内核配置不支持generic gpio,查你用的内核配置里是否有CONFIG_GENERIC_GPIO
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 16814
精华: 0
发帖: 11
金钱: 55 两
威望: 11 点
综合积分: 22 分
注册时间: 2010-03-22
最后登录: 2011-07-08
4楼  发表于: 2010-04-09 09:47

 回 3楼(kasim) 的帖子

内核里看了,
# CONFIG_GENERIC_GPIO is not set
我用的是27的内核,29的spi驱动,是不是不支持呢??
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
5楼  发表于: 2010-04-09 10:05
对于S3C24xx来说,2.6.27的内核就可以支持generic gpio,配置内核的时候选中“GPIO Support”这个选项就可以了。
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 16814
精华: 0
发帖: 11
金钱: 55 两
威望: 11 点
综合积分: 22 分
注册时间: 2010-03-22
最后登录: 2011-07-08
6楼  发表于: 2010-04-09 14:23
版主,请问怎么测试spi?看到网上说是
内核编译完成后进入/root/linux-2.6.27/Documentation/spi
执行:arm-linux-gcc -I/root/linux-2.6.27/include  spidev_test.c
后会生成a.out的spi测试程序;
我执行后报错啊??

[root@localhost spi]# arm-linux-gcc -I/root/linux-2.6.27/include  spidev_test.c
spidev_test.c:22:30: linux/spi/spidev.h: No such file or directory
spidev_test.c: In function `transfer':
spidev_test.c:51: error: variable `tr' has initializer but incomplete type
spidev_test.c:52: error: unknown field `tx_buf' specified in initializer
spidev_test.c:52: warning: excess elements in struct initializer
spidev_test.c:52: warning: (near initialization for `tr')
spidev_test.c:53: error: unknown field `rx_buf' specified in initializer
spidev_test.c:53: warning: excess elements in struct initializer
spidev_test.c:53: warning: (near initialization for `tr')
spidev_test.c:54: error: unknown field `len' specified in initializer
spidev_test.c:54: warning: excess elements in struct initializer
spidev_test.c:54: warning: (near initialization for `tr')
spidev_test.c:55: error: unknown field `delay_usecs' specified in initializer
spidev_test.c:55: warning: excess elements in struct initializer
spidev_test.c:55: warning: (near initialization for `tr')
spidev_test.c:56: error: unknown field `speed_hz' specified in initializer
spidev_test.c:56: warning: excess elements in struct initializer
spidev_test.c:56: warning: (near initialization for `tr')
spidev_test.c:57: error: unknown field `bits_per_word' specified in initializer
spidev_test.c:57: warning: excess elements in struct initializer
spidev_test.c:57: warning: (near initialization for `tr')
spidev_test.c:51: error: storage size of 'tr' isn't known
spidev_test.c: In function `parse_opts':
spidev_test.c:125: error: `SPI_LOOP' undeclared (first use in this function)
spidev_test.c:125: error: (Each undeclared identifier is reported only once
spidev_test.c:125: error: for each function it appears in.)
spidev_test.c:128: error: `SPI_CPHA' undeclared (first use in this function)
spidev_test.c:131: error: `SPI_CPOL' undeclared (first use in this function)
spidev_test.c:134: error: `SPI_LSB_FIRST' undeclared (first use in this function)
spidev_test.c:137: error: `SPI_CS_HIGH' undeclared (first use in this function)
spidev_test.c:140: error: `SPI_3WIRE' undeclared (first use in this function)
spidev_test.c: In function `main':
spidev_test.c:163: error: `SPI_IOC_WR_MODE' undeclared (first use in this function)
spidev_test.c:167: error: `SPI_IOC_RD_MODE' undeclared (first use in this function)
spidev_test.c:174: error: `SPI_IOC_WR_BITS_PER_WORD' undeclared (first use in this function)
spidev_test.c:178: error: `SPI_IOC_RD_BITS_PER_WORD' undeclared (first use in this function)
spidev_test.c:185: error: `SPI_IOC_WR_MAX_SPEED_HZ' undeclared (first use in this function)
spidev_test.c:189: error: `SPI_IOC_RD_MAX_SPEED_HZ' undeclared (first use in this function)
[root@localhost spi]#
什么原因??怎么解决??
级别: 新手上路
UID: 16814
精华: 0
发帖: 11
金钱: 55 两
威望: 11 点
综合积分: 22 分
注册时间: 2010-03-22
最后登录: 2011-07-08
7楼  发表于: 2010-04-09 14:24
我在linux/spi/spidev.h 有这个文件啊???好奇怪啊??哪里需要配置?
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
8楼  发表于: 2010-04-09 15:43
[root@localhost spi]# arm-linux-gcc -I/root/linux-2.6.27/include  spidev_test.c
spidev_test.c:22:30: linux/spi/spidev.h: No such file or directory

执行"ls -l /root/linux-2.6.27/include/linux/spi/spidev.h"看看
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
9楼  发表于: 2010-04-09 15:47
呵呵,问题又神奇的解决了?
http://aiothome.net/read.php?tid-5591-page-e.html#a
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
  • «
  • 1
  • 2
  • »
  • Pages: 1/2     Go