--- /dev/null
+#
+# 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))
--- /dev/null
+#!/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
--- /dev/null
+#!/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
--- /dev/null
+#!/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;
+}
--- /dev/null
+#!/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;
+}