1-wire

From Tinker Board Wiki
Revision as of 07:39, 21 November 2017 by WikiSysop (talk | contribs) (Created page with "<h1>1-wire</h1> <h2>Config for 1-wire Driver</h2> <strong>1.1 Add CONFIG_W1=y (<em>kernel/arch/arm/configs/miniarm-rk3288_defconfig</em>)</strong> <pre> CONFIG_W1=y </pre> <...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

1-wire

Config for 1-wire Driver

1.1 Add CONFIG_W1=y (kernel/arch/arm/configs/miniarm-rk3288_defconfig)

CONFIG_W1=y

Driver Source Code: kernel/drivers/w1/*.*
Result: Generate /sys/bus/w1

1.2 Add CONFIG_W1_MASTER_GPIO=y (kernel/arch/arm/configs/miniarm-rk3288_defconfig)

CONFIG_W1_MASTER_GPIO=y

Driver Source Code: kernel/drivers/w1/masters/w1-gpio.c
Result: Generate /sys/bus/w1/devices/w1_bus_master1

Device Tree Overlay

2.1 Add w1-gpio-overlay.dts (kernel/arch/arm/boot/dts/overlays/w1-gpio-overlay.dts)

/dts-v1/;
/plugin/;

/ {
    compatible = "rockchip,rk3288-miniarm", "rockchip,rk3288";
    fragment@0 {
        target-path = "/";
        __overlay__ {
            w1: onewire@0 {
                compatible = "w1-gpio";
                pinctrl-names = "default";
                pinctrl-0 = <&w1_pins>;
                gpios = <<span style="color:#ff0000;">&gpio5 19</span> 0>;
                status = "okay";
            };
        };
    };

    fragment@1 {
        target = <<span style="color:#ff0000;">&gpio5</span>>;
        __overlay__ {
            w1_pins: w1_pins@0 {
                rockchip,pins = <<span style="color:#ff0000;">5 19</span> 0 &pcfg_pull_up>;
            };
        };
    };
};
  • The dts file sets the gpio5-19(gpio 171) as w1-gpio's pin.

Gpio bank.png


2.2 Add w1-gpio.dtbo into Makefile (kernel/arch/arm/boot/dts/overlays/Makefile)

dtbo-$(CONFIG_ARCH_ROCKCHIP) += \
        ... \
        <span style="color:#ff0000;">w1-gpio.dtbo</span> \

hw_intf.conf

3.1 Add intf:dtoverlay=w1-gpio so that w1-gpio.dtbo is loaded. (/boot/hw_intf.conf)

intf:dtoverlay=w1-gpio

* Reboot tinkerboard and the /sys/bus/w1/devices/w1_bus_master1 is generated.

Note

Make sure that the cpu frequency is over 600,000 Hz. You can modify the MIN_SPEED to "600000" at the /etc/init.d/cpufrequtils to achieve this goal.