Add pcmciautils, thanks sn9
authorFlorian Fainelli <florian@openwrt.org>
Mon, 3 Nov 2008 21:38:32 +0000 (21:38 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Mon, 3 Nov 2008 21:38:32 +0000 (21:38 +0000)
SVN-Revision: 13113

utils/pcmciautils/Makefile [new file with mode: 0644]
utils/pcmciautils/files/etc/hotplug.d/pcmcia/pcmcia.agent [new file with mode: 0644]
utils/pcmciautils/files/etc/hotplug.d/pcmcia_socket/pcmcia_socket.agent [new file with mode: 0644]
utils/pcmciautils/files/etc/init.d/pcmcia [new file with mode: 0644]
utils/pcmciautils/files/etc/init.d/pcmcia_socket [new file with mode: 0644]

diff --git a/utils/pcmciautils/Makefile b/utils/pcmciautils/Makefile
new file mode 100644 (file)
index 0000000..ea60ce9
--- /dev/null
@@ -0,0 +1,49 @@
+# 
+# Copyright (C) 2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=pcmciautils
+PKG_VERSION:=015
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://www.kernel.org/pub/linux/utils/kernel/pcmcia/
+PKG_MD5SUM:=9e12435c8b6cf7bf59894e90e480b4aa
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/pcmciautils
+  SECTION:=utils
+  CATEGORY:=Utilities
+  DEPENDS:=+sysfsutils @LINUX_2_6 @PCMCIA_SUPPORT
+  TITLE:=PCMCIA Utilities
+  URL:=http://www.kernel.org/pub/linux/utils/kernel/pcmcia/pcmcia.html
+endef
+
+define Build/Compile
+       rm -rf "$(PKG_INSTALL_DIR)"
+       mkdir -p "$(PKG_INSTALL_DIR)"
+       $(call Build/Compile/Default, \
+               LD="$(TARGET_CC)" UDEV=false \
+               CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS) \
+               -DPCMCIAUTILS_VERSION=$(PKG_VERSION)" \
+               prefix=/usr all \
+       )
+endef
+
+define Package/pcmciautils/install
+       $(INSTALL_DIR) $(1)/usr/sbin/
+       $(CP) $(PKG_BUILD_DIR)/pccardctl $(1)/usr/sbin/
+       $(CP) $(PKG_BUILD_DIR)/pcmcia-check-broken-cis $(1)/usr/sbin/
+       $(CP) $(PKG_BUILD_DIR)/pcmcia-socket-startup $(1)/usr/sbin/
+       ln -s pccardctl $(1)/usr/sbin/lspcmcia
+       $(INSTALL_DIR) $(1)/etc/pcmcia/
+       $(CP) $(PKG_BUILD_DIR)/config/config.opts $(1)/etc/pcmcia/
+       $(CP) files/* $(1)/
+endef
+$(eval $(call BuildPackage,pcmciautils))
diff --git a/utils/pcmciautils/files/etc/hotplug.d/pcmcia/pcmcia.agent b/utils/pcmciautils/files/etc/hotplug.d/pcmcia/pcmcia.agent
new file mode 100644 (file)
index 0000000..537c50a
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Copyright (C) 2008 OpenWrt.org
+
+case "$ACTION" in
+       add)
+               SYSFS=/sys/bus/pcmcia/devices/
+               DEVPATH=$SOCKET_NO.$((0x$DEVICE_NO))
+
+               # check whether the CIS is completely broken
+               if [ ! -h $SYSFS$DEVPATH/driver ]; then
+                       CISFILE=$(/usr/sbin/pcmcia-check-broken-cis $SOCKET_NO)
+                       echo PCMCIA: $CISFILE;
+                       if [ ! -z $CISFILE ]; then
+                               if [ -f /lib/firmware/$CISFILE ]; then
+                                       cat /lib/firmware/$CISFILE > $SYSFS/class/pcmcia_socket/pcmcia_socket$(SOCKET_NO)/cis
+                               fi;
+                       fi;
+               fi;
+
+               # allow a match solely based on the "function ID" field
+               if [ ! -h $SYSFS$DEVPATH/driver ]; then
+                       if [ -w $SYSFS$DEVPATH/allow_func_id_match ]; then
+                               echo PCMCIA: allowing func_id based match for PCMCIA device $SOCKET_NO.$DEVICE_NO
+                               echo -n "42" > $SYSFS$DEVPATH/allow_func_id_match;
+                       fi;
+               fi;
+               ;;
+esac
diff --git a/utils/pcmciautils/files/etc/hotplug.d/pcmcia_socket/pcmcia_socket.agent b/utils/pcmciautils/files/etc/hotplug.d/pcmcia_socket/pcmcia_socket.agent
new file mode 100644 (file)
index 0000000..79b3524
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+# Copyright (C) 2008 OpenWrt.org
+
+case "$ACTION" in
+       add)
+               echo PCMCIA: socket number: $SOCKET_NO
+
+               sleep 1;
+               /usr/sbin/pcmcia-socket-startup $SOCKET_NO
+               DONE_FILE=/sys/class/pcmcia_socket/pcmcia_socket$SOCKET_NO/available_resources_setup_done
+               if [ -f  $DONE_FILE ]; then
+                       if [ -w $DONE_FILE ]; then
+                               echo -n "42" > $DONE_FILE
+                       fi;
+               fi;
+               ;;
+
+esac
diff --git a/utils/pcmciautils/files/etc/init.d/pcmcia b/utils/pcmciautils/files/etc/init.d/pcmcia
new file mode 100644 (file)
index 0000000..16f2276
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008 OpenWrt.org 
+
+START=42
+start() {
+       if [ -d /sys/bus/pcmcia/devices/ ]; then
+               # 2.6 kernels
+               cd /sys/bus/pcmcia/devices/
+               for PCMCIA_DEVICE in *; do
+                       if [ $PCMCIA_DEVICE == \* ]; then
+                               continue;
+                       fi;
+                       MODALIAS=$(cat $PCMCIA_DEVICE/modalias)
+                       echo PCMCIA: $MODALIAS $PCMCIA_DEVICE
+                       if [ -z $MODALIAS ]; then
+                               continue;
+                       fi;
+                       ACTION=add
+                       SOCKET_NO=$(echo $PCMCIA_DEVICE | cut -d. -f1)
+                       DEVICE_NO=$(echo $MODALIAS | sed 's/.*pfn\(..\).*/\1/')
+                       export MODALIAS ACTION SOCKET_NO DEVICE_NO
+                       /sbin/hotplug-call pcmcia
+               done;
+       fi;
+}
diff --git a/utils/pcmciautils/files/etc/init.d/pcmcia_socket b/utils/pcmciautils/files/etc/init.d/pcmcia_socket
new file mode 100644 (file)
index 0000000..fdd0b8c
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008 OpenWrt.org 
+
+START=41
+start() {
+       if [ -d /sys/class/pcmcia_socket/ ]; then
+               # 2.6 kernels
+               cd /sys/class/pcmcia_socket/
+               for PCMCIA_SOCKET in *; do
+                       if [ $PCMCIA_SOCKET == \* ]; then
+                               continue;
+                       fi;
+                       SOCKET_NO=$(echo $PCMCIA_SOCKET | cut -b14-)
+                       ACTION=add
+                       export SOCKET_NO ACTION
+                       /sbin/hotplug-call pcmcia_socket
+               done;
+       fi;
+}