реклама на сайте
подробности

 
 
> Device Tree Source, подключение 1wire устройства к gpio
xor.kruger
сообщение Feb 20 2013, 10:34
Сообщение #1


Местный
***

Группа: Свой
Сообщений: 290
Регистрация: 17-08-08
Из: Чернигов
Пользователь №: 39 647



Доброго времени суток.

Интересует пример подключения (описания) любого устройства для однопроводной шине в файле DTS.
К сожалению в каталоге Documentation/devicetree о подключении 1 ни сказано ни слова sad.gif

В моем случае используется Microblaze, одноразрядная ipcore gpio и подключенный к ней датчик температуры DS18B20. Саму кору ядра находит без проблем, регистрирует драйвера для 1wire, а вот устройство не находит.
Вот как я пытался описать датчик:
Код
        xps_gpio_0: gpio@81460000 {
            compatible = "xlnx,xps-gpio-2.00.a", "xlnx,xps-gpio-1.00.a";
            interrupt-parent = <&xps_intc_0>;
            interrupts = < 10 2 >;
            reg = < 0x81460000 0x10000 >;
            xlnx,all-inputs = <0x0>;
            xlnx,all-inputs-2 = <0x0>;
            xlnx,dout-default = <0x0>;
            xlnx,dout-default-2 = <0x0>;
            xlnx,family = "spartan3adsp";
            xlnx,gpio-width = <0x1>;
            xlnx,gpio2-width = <0x20>;
            xlnx,interrupt-present = <0x1>;
            xlnx,is-dual = <0x0>;
            xlnx,tri-default = <0xffffffff>;
            xlnx,tri-default-2 = <0xffffffff>;
            #gpio-cells = <2>;
            gpio-controller;

            w1_therm@0 {  /*Смущает это мето*/
                compatible = "dallas,ds18b20";
            };
        };


Заранее благодарен за любой совет. rolleyes.gif
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
xor.kruger
сообщение Feb 21 2013, 14:16
Сообщение #2


Местный
***

Группа: Свой
Сообщений: 290
Регистрация: 17-08-08
Из: Чернигов
Пользователь №: 39 647



Сделав вывод о том, что 1-WIRE устройства не поддерживаются в DTS файлах решил пойти стандартным путём и добавить регистрацию в файл-платформ. Для архитектуры Microblaze он располагается в каталоге
Код
arch/microblaze/platform/platform.c

Был добавлен следующий код:
Код
static struct w1_gpio_platform_data w1_gpio_platform_data = {
    .pin                    = 235,
    .is_open_drain          = 0,
};

struct platform_device kruger_w1_gpio_device = {
    .name   = "w1-gpio",
    .id     = 1,
    .dev.platform_data = &w1_gpio_platform_data,

};

platform_device_register(&kruger_w1_gpio_device);

Пример считывания данных с датчика:
Код
/ # cat /sys/bus/w1/drivers/w1_slave_driver/28-0000020e3ae0/w1_slave
9e 01 4b 46 7f ff 02 10 56 : crc=56 YES
9e 01 4b 46 7f ff 02 10 56 t=25875

Go to the top of the page
 
+Quote Post
Tarbal
сообщение Sep 10 2013, 13:05
Сообщение #3


Профессионал
*****

Группа: Свой
Сообщений: 1 351
Регистрация: 21-05-10
Пользователь №: 57 439



Цитата(xor.kruger @ Feb 21 2013, 18:16) *
struct platform_device kruger_w1_gpio_device = {
.name = "w1-gpio",
.id = 1,
.dev.platform_data = &w1_gpio_platform_data,

};

Откуда вы взяли значение для поля .name = "w1-gpio"?
Если есть платформ драйвер с точно таким значением поля .name и он зарегистрирован в шине платформ, то единственной причиной почему драйвер не становится функция probe из драйвера вернула ошибку.
printk добавленные probe в помогут найти проблему.

Все места в кернеле 2.6.35, где упоминается 1-wire communication. Возможно найдете пример драйвера. Может какой и без изменений подойдет.


./Documentation/00-INDEX:352: - directory with documents regarding the 1-wire (w1) subsystem.
./Documentation/w1/masters/w1-gpio:10:GPIO 1-wire bus master driver. The driver uses the GPIO API to control the
./Documentation/w1/masters/omap-hdq:1:Kernel driver for omap HDQ/1-wire module.
./Documentation/w1/masters/omap-hdq:6: HDQ/1-wire controller on the TI OMAP 2430/3430 platforms.
./Documentation/w1/masters/omap-hdq:23:The controller supports operation in both HDQ and 1-wire mode. The essential
./Documentation/w1/masters/omap-hdq:24:difference between the HDQ and 1-wire mode is how the slave device responds to
./Documentation/w1/masters/00-INDEX:4: - The Maxim/Dallas Semiconductor DS2482 provides 1-wire busses.
./Documentation/w1/masters/00-INDEX:10: - GPIO 1-wire bus master driver.
./Documentation/w1/masters/ds2482:19:one (DS2482-100) or eight (DS2482-800) 1-wire busses.
./Documentation/w1/w1.generic:1:The 1-wire (w1) subsystem
./Documentation/w1/w1.generic:3:The 1-wire bus is a simple master-slave bus that communicates via a single
./Documentation/w1/w1.generic:70:Devices that support the 1-wire natively must provide the ability to write and
./Documentation/w1/00-INDEX:6: - Individual chips providing 1-wire busses.
./Documentation/w1/00-INDEX:8: - The 1-wire (w1) bus
./.config.old:1158:# 1-wire Bus Masters
./.config.old:1167:# 1-wire Slaves
./drivers/usb/serial/io_usbvend.h:162:// Watchport based on 3410 both 1-wire and binary products (16K I2C)
./drivers/usb/serial/io_usbvend.h:163:#define ION_DEVICE_ID_WP_UNSERIALIZED 0x300 // Watchport based on 3410 both 1-wire and binary products
./drivers/w1/w1.c:46:MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol.");
./drivers/w1/w1.c:853: * The 1-wire search is a simple binary tree search.
./drivers/w1/w1.c:860: * See "Application note 187 1-wire search algorithm" at www.maxim-ic.com
./drivers/w1/w1.c:885: * Reset bus and all 1-wire device state machines
./drivers/w1/w1.c:993: printk(KERN_INFO "Driver for 1-wire Dallas network protocol.\n");
./drivers/w1/masters/mxc_w1.c:165: * Reset bus and all 1-wire device state machines
./drivers/w1/masters/ds1wm.c:2: * 1-wire busmaster driver for DS1WM and ASICs with embedded DS1WMs
./drivers/w1/masters/ds1wm.c:37:#define DS1WM_CMD_1W_RESET (1 << 0) /* force reset on 1-wire bus */
./drivers/w1/masters/ds2482.c:6: * It is a I2C to 1-wire bridge.
./drivers/w1/masters/ds2482.c:7: * There are two variations: -100 and -800, which have 1 or 8 1-wire ports.
./drivers/w1/masters/ds2482.c:123: /* 1-wire interface(s) */
./drivers/w1/masters/ds2482.c:200: * Waits until the 1-wire interface is idle (not busy)
./drivers/w1/masters/ds2482.c:226: * The 1-wire interface must be idle before calling this function.
./drivers/w1/masters/ds2482.c:373: * Sends a reset on the 1-wire interface
./drivers/w1/masters/ds2482.c:459: /* Register 1-wire interface(s) */
./drivers/w1/masters/ds2482.c:497: /* Unregister the 1-wire bridge(s) */
./drivers/w1/masters/Makefile:2:# Makefile for 1-wire bus master drivers.
./drivers/w1/masters/omap_hdq.c:248: * HDQ might not obey truly the 1-wire spec.
./drivers/w1/masters/omap_hdq.c:724:MODULE_PARM_DESC(w1_id, "1-wire id for the slave detection");
./drivers/w1/masters/matrox_w1.c:43:MODULE_DESCRIPTION("Driver for transport(Dallas 1-wire prtocol) over VGA DDC(matrox gpio).");
./drivers/w1/masters/matrox_w1.c:211: dev_info(&pdev->dev, "Matrox G400 GPIO transport layer for 1-wire.\n");
./drivers/w1/masters/ds2490.c:251: printk(KERN_ERR "Failed to read 1-wire data from 0x%x: err=%d.\n", dev->ep[EP_STATUS], err);
./drivers/w1/masters/ds2490.c:277: ds_print_msg(buf, "1-wire speed", 1);
./drivers/w1/masters/ds2490.c:289: ds_print_msg(buf, "1-wire data output buffer status", 12);
./drivers/w1/masters/ds2490.c:290: ds_print_msg(buf, "1-wire data input buffer status", 13);
./drivers/w1/masters/ds2490.c:387: printk(KERN_ERR "Failed to write 1-wire data to ep0x%x: "
./drivers/w1/masters/Kconfig:2:# 1-wire bus master configuration
./drivers/w1/masters/Kconfig:5:menu "1-wire Bus Masters"
./drivers/w1/masters/Kconfig:8: tristate "Matrox G400 transport layer for 1-wire"
./drivers/w1/masters/Kconfig:11: Say Y here if you want to communicate with your 1-wire devices
./drivers/w1/masters/Kconfig:18: tristate "DS2490 USB <-> W1 transport layer for 1-wire"
./drivers/w1/masters/Kconfig:38: tristate "Freescale MXC 1-wire busmaster"
./drivers/w1/masters/Kconfig:41: Say Y here to enable MXC 1-wire host
./drivers/w1/masters/Kconfig:44: tristate "Maxim DS1WM 1-wire busmaster"
./drivers/w1/masters/Kconfig:47: Say Y here to enable the DS1WM 1-wire driver, such as that
./drivers/w1/masters/Kconfig:52: tristate "GPIO 1-wire busmaster"
./drivers/w1/masters/Kconfig:55: Say Y here if you want to communicate with your 1-wire devices using
./drivers/w1/masters/Kconfig:65: Say Y here if you want support for the 1-wire or HDQ Interface
./drivers/w1/w1.h:84: * be used with hardware that doesn't really support 1-wire operations,
./drivers/w1/w1.h:105: * support the 1-wire protocol.
./drivers/w1/Makefile:2:# Makefile for the Dallas's 1-wire bus.
./drivers/w1/slaves/w1_ds2760.c:240:MODULE_DESCRIPTION("1-wire Driver Dallas 2760 battery monitor chip");
./drivers/w1/slaves/w1_ds2438.c:188: pr_info("1-wire driver for the DS2438 smart battery monitor\n");
./drivers/w1/slaves/w1_ds2438.c:204:MODULE_DESCRIPTION("1-wire DS2438 family, smart battery monitor.");
Binary file ./drivers/w1/slaves/w1_ds2438.ko matches
./drivers/w1/slaves/w1_smem.c:36:MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, 64bit memory family.");
./drivers/w1/slaves/Makefile:2:# Makefile for the Dallas's 1-wire slaves.
./drivers/w1/slaves/w1_therm.c:38:MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, temperature family.");
Binary file ./drivers/w1/slaves/w1_ds2438.o matches
./drivers/w1/slaves/w1_bq27000.c:119:MODULE_PARM_DESC(F_ID, "1-wire slave FID for BQ device");
./drivers/w1/slaves/w1_bq27000.c:123:MODULE_DESCRIPTION("HDQ/1-wire slave driver bq27000 battery monitor chip");
./drivers/w1/slaves/Kconfig:2:# 1-wire slaves configuration
./drivers/w1/slaves/Kconfig:5:menu "1-wire Slaves"
./drivers/w1/slaves/Kconfig:10: Say Y here if you want to connect 1-wire thermal sensors to your
./drivers/w1/slaves/Kconfig:16: Say Y here if you want to connect 1-wire
./drivers/w1/slaves/Kconfig:22: Say Y here if you want to use a 1-wire
./drivers/w1/slaves/Kconfig:29: Say Y here if you want to use a 1-wire
./drivers/w1/slaves/Kconfig:44: Say Y here if you want to use a 1-wire
./drivers/w1/slaves/Kconfig:51: Say Y here if you want to use a 1-wire
Binary file ./drivers/w1/w1.o matches
./drivers/w1/Kconfig:2: tristate "Dallas's 1-wire support"
./drivers/w1/Kconfig:5: Dallas' 1-wire bus is useful to connect slow 1-pin devices
Binary file ./drivers/w1/wire.ko matches
./drivers/w1/w1_int.c:118: * controls 1-wire time frames are even expected to support a strong
Binary file ./drivers/w1/wire.o matches
./arch/alpha/defconfig:686:# Dallas's 1-wire bus
./arch/frv/defconfig:431:# Dallas's 1-wire bus
./arch/xtensa/configs/common_defconfig:476:# Dallas's 1-wire bus
./arch/xtensa/configs/iss_defconfig:341:# Dallas's 1-wire bus
./arch/powerpc/configs/ppc6xx_defconfig:1843:# 1-wire Bus Masters
./arch/powerpc/configs/ppc6xx_defconfig:1851:# 1-wire Slaves
./arch/ia64/configs/zx1_defconfig:859:# Dallas's 1-wire bus
./arch/ia64/configs/sim_defconfig:464:# Dallas's 1-wire bus
./arch/ia64/configs/bigsur_defconfig:772:# Dallas's 1-wire bus
./arch/ia64/configs/gensparse_defconfig:807:# Dallas's 1-wire bus
./arch/arm/configs/imx5_defconfig:1124:# 1-wire Bus Masters
./arch/arm/configs/imx5_defconfig:1133:# 1-wire Slaves
./arch/arm/configs/calabria_defconfig:1131:# 1-wire Bus Masters
./arch/arm/configs/calabria_defconfig:1140:# 1-wire Slaves
./arch/arm/configs/mx3_updater_defconfig:728:# 1-wire Bus Masters
./arch/arm/configs/mx3_updater_defconfig:736:# 1-wire Slaves
./arch/arm/configs/mx3_defconfig:892:# 1-wire Bus Masters
./arch/arm/configs/mx3_defconfig:900:# 1-wire Slaves
./arch/arm/mach-pxa/include/mach/pxa3xx-regs.h:202:#define CKEN_1WIRE 40 /* < 1-wire clock enable */
./arch/blackfin/configs/IP0X_defconfig:812:# Dallas's 1-wire bus
./arch/blackfin/configs/SRV1_defconfig:841:# Dallas's 1-wire bus
./arch/blackfin/configs/H8606_defconfig:765:# Dallas's 1-wire bus
./arch/mips/configs/rm200_defconfig:1138:# Dallas's 1-wire bus
./arch/mips/configs/rm200_defconfig:1144:# 1-wire Bus Masters
./arch/mips/configs/rm200_defconfig:1150:# 1-wire Slaves
./arch/mips/configs/jazz_defconfig:1018:# Dallas's 1-wire bus
./arch/mips/configs/jazz_defconfig:1024:# 1-wire Bus Masters
./arch/mips/configs/jazz_defconfig:1028:# 1-wire Slaves
./arch/mips/configs/markeins_defconfig:1014:# Dallas's 1-wire bus
./arch/mips/configs/pnx8550-stb810_defconfig:777:# Dallas's 1-wire bus
./arch/mips/configs/yosemite_defconfig:608:# Dallas's 1-wire bus
./arch/mips/configs/decstation_defconfig:607:# Dallas's 1-wire bus
./arch/mips/configs/msp71xx_defconfig:948:# Dallas's 1-wire bus
./arch/mips/configs/pnx8550-jbs_defconfig:787:# Dallas's 1-wire bus
./arch/mips/configs/wrppmc_defconfig:656:# Dallas's 1-wire bus
./arch/mips/configs/bcm47xx_defconfig:1313:# 1-wire Bus Masters
./arch/mips/configs/bcm47xx_defconfig:1320:# 1-wire Slaves
./.config:1154:# 1-wire Bus Masters
./.config:1163:# 1-wire Slaves

Цитата(xor.kruger @ Sep 10 2013, 11:55) *
Возращаясь к старой теме...
Тогда вывод, сделанный мной, был не правильный. Изучив внимательно документацию к ядру было найдено следующее:
Код
w1-gpio devicetree bindings

Required properties:

- compatible: "w1-gpio"
- gpios: one or two GPIO specs:
        - the first one is used as data I/O pin
        - the second one is optional. If specified, it is used as
          enable pin for an external pin pullup.

Optional properties:

- linux,open-drain: if specified, the data pin is considered in
             open-drain mode.

Examples:

    onewire@0 {
        compatible = "w1-gpio";
        gpios = <&gpio 126 0>, <&gpio 105 0>;
    };

что позволяет сделать все более красивее, лаконичней и по идеологии sm.gif



GPIO pin конечно надо активировать и настроить, но еще надо драйвер поставить. Имя пина никакого значения для устройства и драйвера не имеет.

Сообщение отредактировал Tarbal - Sep 10 2013, 13:16
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 30th July 2025 - 23:01
Рейтинг@Mail.ru


Страница сгенерированна за 0.01391 секунд с 7
ELECTRONIX ©2004-2016