Either I'm blind, or the whole concept of device tree overlays is very badly documented. Here is what I've found:
Install prerequisites:
sudo apt-get update
sudo apt-get install raspi-gpio device-tree-compiler
Make a text file and call it something.dts (adapted from this).
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2708";
fragment@0 {
target = <&gpio>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&my_pins>;
my_pins: my_pins {
brcm,pins = <7>; /* GPIO7 */
brcm,function = <1>; /* Output */
};
};
};
};
This will make the GPIO pin to an output, but doesn't specify the output level (LOW or HIGH). According to this thread, there is no way to specify this, here. It seems like the default is LOW, at least for GPIO7.
If you are OK with a weak pull-up (i.e. when you don't have to supply a lot of current, then you can make the pin an input, by replacing the my_pins section with the following:
my_pins: my_pins {
brcm,pins = <7>; /* GPIO7 */
brcm,function = <0>; /* Input */
brcm,pull = <2>; /* Pull up */
};
Some pins have altenative functions, which allow you to cheat...
my_pins: my_pins {
brcm,pins = <7>; /* GPIO7 */
brcm,function = <4>; /* Alternative function 0 = SPI0 CE1 */
};
To test the pull-up strength, connect a resistor between GPIO7 and GND, and measure the voltage drop on the pin. With alt0, the voltage drops to 2.3V when I connect a 100 ohm resistor between GPIO7 and GND, which equates to a pull-up of about 43 ohms on that pin. A normal input with pull-up drops to 0.16V with a 2.6kOhm resistor, which means the pull-up is equivalent to about 51kOhm.
If you need even more drive strength, build an external logic buffer (a crude but effective one can be implemented with a single NPN BJT and one or two resistors).
Another options is to accept the low output on GPIO7, and use a logic inverter (can be done with a PNP BJT and one or two resistors).
Compile the dts file using dtc:
dtc -@ -I dts -O dtb -o something.dtb something.dts
Put it in /boot/overlays:
sudo cp something.dts /boot/overlays/something.dts
Add a line to /boot/config.txt:
dtoverlay=something
Reboot.
Check if it works using a multimeter on the relevant GPIO pin, and raspi-gpio:
raspi-gpio get 7
Example output:
GPIO 7: level=1 fsel=4 alt=0 func=SPI0_CE1_N