#!/bin/sh

. /usr/bin/scriptlib

HOTPLUS_STATUS=`rdcsman 0x8035500f u32`
WANTYPE=`rdcsman 0x00010003 u32`
OLDWANTYPE=0

hotplug_start()
{
	if [ $WANTYPE -eq 16 -o $HOTPLUS_STATUS -eq 0 ] ; then
		OLDWANTYPE=`rdcsman 0x00010003 u32`
		wrcsman "0x80355010 $OLDWANTYPE && \
				 0x00010003 0x12 && \
				 0x80010008 0x01 && \
				 0x80010009 0x01 && \
				 0x801e0d00 \"SWC-U200 && \
				 0x8035500f 0x01 && \
				 0x80355011 0x01"
		insmod /lib/cmc7xx_usb.ko
		wrcsman "0x8035500f 0x02"
	fi
}

hotplug_stop()
{
	if [ $HOTPLUS_STATUS -eq 2 ] ; then
		wrcsman  "0x8035500f 0x03 &&
				  0x00010003 0x10"
		jwcm-sh stop
		wrcsman  "0x8035500f 0x00 && \
				  0x80010008 0x01 && \
				  0x80010009 0x01"
		rmcsman  "0x801e0d00"
		rmcsman  "0x80355011"
	fi
}


# main ##########################################################


case "$1" in

    start)
        hotplug_start
        exit 0  
        ;;
    stop)
        hotplug_stop
		exit 0
        ;;
    *)
        exit 1
        ;;
esac    

exit 0        
            