96 lines
3.7 KiB
Plaintext
96 lines
3.7 KiB
Plaintext
# overlays fixup script
|
|
# implements (or rather substitutes) overlay arguments functionality
|
|
# using u-boot scripting, environment variables and "fdt" command
|
|
|
|
# setexpr test_var ${tmp_bank} - A
|
|
# works only for hex numbers (A-F)
|
|
|
|
setenv decompose_pin 'setexpr tmp_bank sub "P(B|C|D|H)\\d+" "\\1";
|
|
setexpr tmp_pin sub "P\\S(\\d+)" "\\1";
|
|
test "${tmp_bank}" = "B" && setenv tmp_bank 1;
|
|
test "${tmp_bank}" = "C" && setenv tmp_bank 2;
|
|
test "${tmp_bank}" = "D" && setenv tmp_bank 3;
|
|
test "${tmp_bank}" = "H" && setenv tmp_bank 7'
|
|
|
|
if test -n "${param_spinor_spi_bus}"; then
|
|
test "${param_spinor_spi_bus}" = "0" && setenv tmp_spi_path "spi@1c68000"
|
|
test "${param_spinor_spi_bus}" = "1" && setenv tmp_spi_path "spi@1c69000"
|
|
fdt set /soc/${tmp_spi_path} status "okay"
|
|
fdt set /soc/${tmp_spi_path}/spiflash@0 status "okay"
|
|
if test -n "${param_spinor_max_freq}"; then
|
|
fdt set /soc/${tmp_spi_path}/spiflash@0 spi-max-frequency "<${param_spinor_max_freq}>"
|
|
fi
|
|
if test "${param_spinor_spi_cs}" = "1"; then
|
|
fdt set /soc/${tmp_spi_path}/spiflash@0 reg "<1>";
|
|
fi
|
|
env delete tmp_spi_path
|
|
fi
|
|
|
|
if test -n "${param_spidev_spi_bus}"; then
|
|
test "${param_spidev_spi_bus}" = "0" && setenv tmp_spi_path "spi@1c68000"
|
|
test "${param_spidev_spi_bus}" = "1" && setenv tmp_spi_path "spi@1c69000"
|
|
fdt set /soc/${tmp_spi_path} status "okay"
|
|
fdt set /soc/${tmp_spi_path}/spidev status "okay"
|
|
if test -n "${param_spidev_max_freq}"; then
|
|
fdt set /soc/${tmp_spi_path}/spidev spi-max-frequency "<${param_spidev_max_freq}>"
|
|
fi
|
|
if test "${param_spidev_spi_cs}" = "1"; then
|
|
fdt set /soc/${tmp_spi_path}/spidev reg "<1>";
|
|
fi
|
|
fi
|
|
|
|
if test -n "${param_pps_pin}"; then
|
|
setenv tmp_bank "${param_pps_pin}"
|
|
setenv tmp_pin "${param_pps_pin}"
|
|
run decompose_pin
|
|
fdt set /soc/pinctrl@1c20800/pps_pins pins "${param_pps_pin}"
|
|
fdt get value tmp_phandle /soc/pinctrl@1c20800 phandle
|
|
fdt set /pps@0 gpios "<${tmp_phandle} ${tmp_bank} ${tmp_pin} 0>"
|
|
env delete tmp_pin tmp_bank tmp_phandle
|
|
fi
|
|
|
|
if test "${param_pps_falling_edge}" = "1"; then
|
|
fdt set /pps@0 assert-falling-edge
|
|
fi
|
|
|
|
if test -n "${param_w1_pin}"; then
|
|
setenv tmp_bank "${param_w1_pin}"
|
|
setenv tmp_pin "${param_w1_pin}"
|
|
run decompose_pin
|
|
fdt set /soc/pinctrl@1c20800/w1_pins pins "${param_w1_pin}"
|
|
fdt get value tmp_phandle /soc/pinctrl@1c20800 phandle
|
|
fdt set /onewire@0 gpios "<${tmp_phandle} ${tmp_bank} ${tmp_pin} 0>"
|
|
env delete tmp_pin tmp_bank tmp_phandle
|
|
fi
|
|
|
|
if test "${param_w1_pin_int_pullup}" = "1"; then
|
|
fdt set /soc/pinctrl@1c20800/w1_pins bias-pull-up
|
|
fi
|
|
|
|
if test "${param_uart1_rtscts}" = "1"; then
|
|
fdt get value tmp_phandle1 /soc/pinctrl@1c20800/uart1-pins phandle
|
|
fdt get value tmp_phandle2 /soc/pinctrl@1c20800/uart1-rts-cts-pins phandle
|
|
fdt set /soc/serial@1c28400 pinctrl-names "default" "default"
|
|
fdt set /soc/serial@1c28400 pinctrl-0 "<${tmp_phandle1}>"
|
|
fdt set /soc/serial@1c28400 pinctrl-1 "<${tmp_phandle2}>"
|
|
env delete tmp_phandle1 tmp_phandle2
|
|
fi
|
|
|
|
if test "${param_uart2_rtscts}" = "1"; then
|
|
fdt get value tmp_phandle1 /soc/pinctrl@1c20800/uart2-pins phandle
|
|
fdt get value tmp_phandle2 /soc/pinctrl@1c20800/uart2-rts-cts-pins phandle
|
|
fdt set /soc/serial@1c28800 pinctrl-names "default" "default"
|
|
fdt set /soc/serial@1c28800 pinctrl-0 "<${tmp_phandle1}>"
|
|
fdt set /soc/serial@1c28800 pinctrl-1 "<${tmp_phandle2}>"
|
|
env delete tmp_phandle1 tmp_phandle2
|
|
fi
|
|
|
|
if test "${param_uart4_rtscts}" = "1"; then
|
|
fdt get value tmp_phandle1 /soc/pinctrl@1c20800/uart4-pins phandle
|
|
fdt get value tmp_phandle2 /soc/pinctrl@1c20800/uart4-rts-cts-pins phandle
|
|
fdt set /soc/serial@1c29000 pinctrl-names "default" "default"
|
|
fdt set /soc/serial@1c29000 pinctrl-0 "<${tmp_phandle1}>"
|
|
fdt set /soc/serial@1c29000 pinctrl-1 "<${tmp_phandle2}>"
|
|
env delete tmp_phandle1 tmp_phandle2
|
|
fi
|