友人問︰理論、實務與應用能否使一氣貫通呢?故而特以實用為例 ,說此『自動組構』 automatic configuration 之事。且權充呼應 o4l 友人《音樂派初登場》之文矣。
PEANO 2.1 的 dts ︰
pi@raspberrypi:~/hats/example $ more allo-piano-dac-pcm512x-audio-overlay.dts
/*
* Definitions for Allo Piano DAC (2.0/2.1) boards
*
* NB. The Piano DAC 2.1 board contains 2x TI PCM5142 DAC’s. One DAC is stereo
* (left/right) and the other provides a subwoofer output, using DSP on the
* chip for digital high/low pass crossover.
* The initial support for this hardware, that doesn’t require any codec driver
* modifications, uses only one DAC chip for stereo (left/right) output, the
* chip with 0x4c slave address. The other chip at 0x4d is currently ignored!
*/
/dts-v1/;
/plugin/;
/ {
compatible = “brcm,bcm2708”;
fragment@0 {
target = <&i2s>;
__overlay__ {
status = “okay”;
};
};
fragment@1 {
target = <&i2c1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = “okay”;
pcm5142@4c {
#sound-dai-cells = <0>;
compatible = “ti,pcm5142”;
reg = <0x4c>;
status = “okay”;
};
};
};
fragment@2 {
target = <&sound>;
piano_dac: __overlay__ {
compatible = “allo,piano-dac”;
i2s-controller = <&i2s>;
status = “okay”;
};
};
__overrides__ {
24db_digital_gain =
<&piano_dac>,”allo,24db_digital_gain?”;
};
};
編譯︰
dtc -@ -I dts -O dtb -o allo-piano-dac-pcm512x-audio-overlay.dtbo allo-piano-dac-pcm512x-audio-overlay.dts
撰寫 40W GPIOs 之用途︰
pi@raspberrypi:~/hats/eepromutils $ cat eeprom_settings.txt
########################################################################
# EEPROM settings text file
#
# Edit this file for your particular board and run through eepmake tool,
# then use eepflash tool to write to attached HAT ID EEPROM
#
# Tools available:
# eepmake Parses EEPROM text file and creates binary .eep file
# eepdump Dumps a binary .eep file as human readable text (for debug)
# eepflash Write or read .eep binary image to/from HAT EEPROM
#
########################################################################
########################################################################
# Vendor info
# 128 bit UUID. If left at zero eepmake tool will auto-generate
# RFC 4122 compliant UUID
product_uuid 00000000-0000-0000-0000-000000000000
# 16 bit product id
product_id 0x0001
# 16 bit product version
product_ver 0x0001
# ASCII vendor string (max 255 characters)
vendor “www.freesandal.org”
# ASCII product string (max 255 characters)
product “ID EEPROM test”
########################################################################
# GPIO bank settings, set to nonzero to change from the default.
# NOTE these setting can only be set per BANK, uncommenting any of
# these will force the bank to use the custom setting.
# drive strength, 0=default, 1-8=2,4,6,8,10,12,14,16mA, 9-15=reserved
gpio_drive 0
# 0=default, 1=slew rate limiting, 2=no slew limiting, 3=reserved
gpio_slew 0
# 0=default, 1=hysteresis disabled, 2=hysteresis enabled, 3=reserved
gpio_hysteresis 0
# If board back-powers Pi via 5V GPIO header pins:
# 0 = board does not back-power
# 1 = board back-powers and can supply the Pi with a minimum of 1.3A
# 2 = board back-powers and can supply the Pi with a minimum of 2A
# 3 = reserved
# If back_power=2 then USB high current mode will be automatically
# enabled on the Pi
back_power 0
########################################################################
# GPIO pins, uncomment for GPIOs used on board
# Options for FUNCTION: INPUT, OUTPUT, ALT0-ALT5
# Options for PULL: DEFAULT, UP, DOWN, NONE
# NB GPIO0 and GPIO1 are reserved for ID EEPROM so cannot be set
# GPIO FUNCTION PULL
# —- ——– —-
setgpio 2 ALT0 UP
setgpio 3 ALT0 UP
#setgpio 4 INPUT DEFAULT
setgpio 5 INPUT DEFAULT
setgpio 6 INPUT DEFAULT
#setgpio 7 INPUT DEFAULT
#setgpio 8 INPUT DEFAULT
#setgpio 9 INPUT DEFAULT
#setgpio 10 INPUT DEFAULT
#setgpio 11 INPUT DEFAULT
#setgpio 12 INPUT DEFAULT
#setgpio 13 INPUT DEFAULT
#setgpio 14 INPUT DEFAULT
#setgpio 15 INPUT DEFAULT
#setgpio 16 INPUT DEFAULT
#setgpio 17 INPUT DEFAULT
setgpio 18 ALT0 DEFAULT
setgpio 19 ALT0 DEFAULT
setgpio 20 ALT0 DEFAULT
setgpio 21 ALT0 DEFAULT
#setgpio 22 INPUT DEFAULT
#setgpio 23 INPUT DEFAULT
#setgpio 24 INPUT DEFAULT
setgpio 25 INPUT DEFAULT
#setgpio 26 INPUT DEFAULT
#setgpio 27 INPUT DEFAULT
創建 .eep 檔案︰
pi@raspberrypi:~/hats/eepromutils
燒錄︰
pi@raspberrypi:~/hats/eepromutils cd /proc/device-tree pi@raspberrypi:/proc/device-tree cd hat pi@raspberrypi:/proc/device-tree/hat cat name hat pi@raspberrypi:/proc/device-tree/hat cat product_id 0x0001 pi@raspberrypi:/proc/device-tree/hat cat uuid c32cb482-ef8e-4d44-85d4-29f4f346b03b pi@raspberrypi:/proc/device-tree/hat