ipq806x.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/sh
  2. #
  3. # Copyright (c) 2014 The Linux Foundation. All rights reserved.
  4. # Copyright (C) 2011 OpenWrt.org
  5. #
  6. IPQ806X_BOARD_NAME=
  7. IPQ806X_MODEL=
  8. ipq806x_board_detect() {
  9. local machine
  10. local name
  11. machine=$(cat /proc/device-tree/model)
  12. case "$machine" in
  13. *"AP148")
  14. name="ap148"
  15. ;;
  16. *"C2600")
  17. name="c2600"
  18. ;;
  19. *"D7800")
  20. name="d7800"
  21. ;;
  22. *"DB149")
  23. name="db149"
  24. ;;
  25. *"NBG6817")
  26. name="nbg6817"
  27. ;;
  28. *"R7500")
  29. name="r7500"
  30. ;;
  31. *"R7500v2")
  32. name="r7500v2"
  33. ;;
  34. *"Linksys EA8500"*)
  35. name="ea8500"
  36. ;;
  37. *"R7800")
  38. name="r7800"
  39. ;;
  40. *"VR2600v")
  41. name="vr2600v"
  42. ;;
  43. esac
  44. [ -z "$name" ] && name="unknown"
  45. [ -z "$IPQ806X_BOARD_NAME" ] && IPQ806X_BOARD_NAME="$name"
  46. [ -z "$IPQ806X_MODEL" ] && IPQ806X_MODEL="$machine"
  47. [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
  48. echo "$IPQ806X_BOARD_NAME" > /tmp/sysinfo/board_name
  49. echo "$IPQ806X_MODEL" > /tmp/sysinfo/model
  50. }
  51. ipq806x_board_name() {
  52. local name
  53. [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
  54. [ -z "$name" ] && name="unknown"
  55. echo "$name"
  56. }
  57. ipq806x_get_dt_led() {
  58. local label
  59. local ledpath
  60. local basepath="/sys/firmware/devicetree/base"
  61. local nodepath="$basepath/aliases/led-$1"
  62. [ -f "$nodepath" ] && ledpath=$(cat "$nodepath")
  63. [ -n "$ledpath" ] && label=$(cat "$basepath$ledpath/label")
  64. echo "$label"
  65. }