初级会员
- 积分
- 88
- 金钱
- 88
- 注册时间
- 2019-3-23
- 在线时间
- 25 小时
|
3金钱
使用I.MX6ULL主芯片,硬件使用ECSPI4连接一个AD7173,在dts文件中配置如下:
pinctrl_ecspi4: ecspi4grp {
fsl,pins = <
MX6UL_PAD_ENET2_TX_CLK__ECSPI4_MISO 0x100b1
MX6UL_PAD_ENET2_TX_EN__ECSPI4_MOSI 0x100b1
MX6UL_PAD_ENET2_TX_DATA1__ECSPI4_SCLK 0x100b1
>;
};
pinctrl_ecspi4_cs: ecspi4cs {
fsl,pins = <
MX6UL_PAD_ENET2_TX_EN__GPIO2_IO13 0x80000000
>;
};
&ecspi4 {
compatible = "fsl,imx6ul-ecspi";
fsl,spi-num-chipselects = <1>;
cs-gpios = <&gpio2 13 0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi4 &pinctrl_ecspi4_cs>;
status = "okay";
ad7173:ad7173@0 {
compatible = "adi,ad7173";
reg = <0x0>;
#address-cells = <1>;
#size-cells = <1>;
spi-cpol;
spi-cpha;
spi-max-frequency = <20000000>;
adi,channels {
#address-cells = <2>;
#size-cells = <0>;
channel@0,1 {
reg = <0 1>;
adi,bipolar;
};
channel@2,3 {
reg = <2 3>;
adi,bipolar;
};
};
};
};
AD7173的驱动
static const struct of_device_id ad7173_of_match[] = {
{ .compatible = "adi,ad7173" },
{.compatible = "adi,ad7173-8" },
{},
};
static const struct spi_device_id ad7173_id_table[] = {
{ "ad7172-2", ID_AD7172_2 },
{ "ad7173-8", ID_AD7173_8 },
{ "ad7175-2", ID_AD7175_2 },
{ "ad7176-2", ID_AD7176_2 },
{}
};
MODULE_DEVICE_TABLE(spi, ad7173_id_table);
static struct spi_driver ad7173_driver = {
.driver = {
.name = "ad7173",
.owner = THIS_MODULE,
.of_match_table = ad7173_of_match,
},
.probe = ad7173_probe,
.remove = ad7173_remove,
.id_table = ad7173_id_table,
};
module_spi_driver(ad7173_driver);
系统启动后可以检测到设备,但是驱动程序在probe函数中报错,
static int ad7173_probe(struct spi_device *spi)
{
const struct spi_device_id *id;
struct ad7173_state *st;
struct iio_dev *indio_dev;
int ret;
printk(KERN_ALERT "ad7173_probe start\n");
if (!spi->irq) {
dev_err(&spi->dev, "No IRQ specified\n");
return -ENODEV;
}
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (indio_dev == NULL){
printk(KERN_ALERT "indio_dev is null\n");
return -ENOMEM;
}
st = iio_priv(indio_dev);
id = spi_get_device_id(spi);
st->info = &ad7173_device_info[id->driver_data];
ad_sd_init(&st->sd, indio_dev, spi, &ad7173_sigma_delta_info);
st->sd.num_slots = st->info->num_configs;
spi_set_drvdata(spi, indio_dev);
indio_dev->dev.parent = &spi->dev;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &ad7173_info;
ret = ad7173_of_parse_channel_config(indio_dev, spi->dev.of_node);
if (ret){
dev_err(&spi->dev, "ad7173_of_parse_channel_config failed\n");
return ret;
}
ret = ad_sd_setup_buffer_and_trigger(indio_dev);
if (ret){
dev_err(&spi->dev, "ad_sd_setup_buffer_and_trigger failed\n");
goto error_disable_reg;
}
ret = ad7173_setup(indio_dev);
if (ret){
dev_err(&spi->dev, "ad7173_setup failed\n");
goto error_remove_trigger;
}
ret = iio_device_register(indio_dev);
if (ret){
dev_err(&spi->dev, "iio_device_register failed\n");
goto error_remove_trigger;
}
return ad7173_gpio_init(st);
error_remove_trigger:
ad_sd_cleanup_buffer_and_trigger(indio_dev);
error_disable_reg:
return ret;
}
内核打印
<1>ad7173_probe start
<3>ad7173 spi3.0: No IRQ specified
请问这是我dts文件配置的问题还是驱动程序的问题?
|
|