1#!/bin/sh
2
3if [ "$1" = "udc0" ]; then
4  function=$(cat /sys/class/udc/80401000.udc/function)
5  if [ "func-$function" != "func-" ]; then
6    echo "UDC0 owner is changed"
7    echo disconnect > /sys/class/udc/80401000.udc/soft_connect
8    sleep 3
9    echo connect > /sys/class/udc/80401000.udc/soft_connect
10  else
11    echo "UDC0 is not attached"
12  fi
13else
14 if [ "$1" = "udc1" ]; then
15  function=$(cat /sys/class/udc/80402000.udc/function)
16  if [ "func-$function" != "func-" ]; then
17    echo "UDC1 owner is changed"
18    echo disconnect > /sys/class/udc/80402000.udc/soft_connect
19    sleep 3
20    echo connect > /sys/class/udc/80402000.udc/soft_connect
21  else
22    echo "UDC1 is not attached"
23  fi
24 else
25  if [ "$1" = "udc2" ]; then
26  function=$(cat /sys/class/udc/80403000.udc/function)
27   if [ "func-$function" != "func-" ]; then
28    echo "UDC2 owner is changed"
29    echo disconnect > /sys/class/udc/80403000.udc/soft_connect
30    sleep 3
31    echo connect > /sys/class/udc/80403000.udc/soft_connect
32   else
33    echo "UDC2 is not attached"
34   fi
35  fi
36 fi
37fi
38