Skip to content
Snippets Groups Projects
Commit 2d2ad6f7 authored by mb's avatar mb
Browse files

Update gpiommc to use configfs

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@11887 3c298f89-4303-0410-b956-a3cf2f4a3e73
parent 4fccf1d3
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ include $(INCLUDE_DIR)/package.mk
define KernelPackage/mmc-over-gpio
SUBMENU:=Other modules
DEPENDS:=@GPIO_SUPPORT +kmod-mmc-spi +kmod-spi-gpio
KCONFIG:=CONFIG_GPIOMMC
KCONFIG:=CONFIG_GPIOMMC CONFIG_CONFIGFS_FS=y
TITLE:=MMC/SD card over GPIO support
FILES:=$(LINUX_DIR)/drivers/mmc/host/gpiommc.$(LINUX_KMOD_SUFFIX)
AUTOLOAD:=$(call AutoLoad,93,spi_gpio gpiommc)
......
......@@ -2,20 +2,59 @@
# Copyright (C) 2008 OpenWrt.org
START=90
SYSFS="/sys"
SYSFS_DRIVERDIR="$SYSFS/bus/platform/drivers/gpiommc"
CONFIGFS_DIR="/config/gpiommc"
# add_device(name, DI_pin, DO_pin, CLK_pin, CS_pin, mode)
add_device() {
echo -n "$1" "$2" "$3" "$4" "$5" "$6" > $SYSFS_DRIVERDIR/add
local dir="$CONFIGFS_DIR/$1"
mkdir $dir
[ $? -eq 0 ] || return 1
echo $2 > $dir/gpio_data_in
[ $? -eq 0 ] || return 1
echo $3 > $dir/gpio_data_out
[ $? -eq 0 ] || return 1
echo $4 > $dir/gpio_clock
[ $? -eq 0 ] || return 1
echo $5 > $dir/gpio_chipselect
[ $? -eq 0 ] || return 1
echo $6 > $dir/spi_mode
[ $? -eq 0 ] || return 1
# XXX We have more config options available. Use defaults for now.
echo 1 > $dir/register
[ $? -eq 0 ] || return 1
return 0
}
# remove_device(name)
remove_device() {
echo -n "$1" > $SYSFS_DRIVERDIR/remove
local dir="$CONFIGFS_DIR/$1"
rmdir $dir
}
mount_configfs() {
# FIXME: This should probably be done somewhere else.
mount | grep configfs
if [ $? -eq 0 ]; then
# already mounted
return 0
fi
mkdir -p /config
[ $? -eq 0 ] || return 1
mount configfs -t configfs /config
[ $? -eq 0 ] || return 1
return 0
}
start() {
# Make sure configfs is mounted
mount_configfs
[ $? -eq 0 ] || return 1
#FIXME we should use a config file, but I dunno how that parser works.
add_device "default" 5 4 3 7 0
}
......
Add gpio_is_valid() for bcm47xx
Index: linux-2.6.25.10/arch/mips/bcm47xx/gpio.c
===================================================================
--- linux-2.6.25.10.orig/arch/mips/bcm47xx/gpio.c 2008-07-20 20:48:44.000000000 +0200
+++ linux-2.6.25.10/arch/mips/bcm47xx/gpio.c 2008-07-20 20:57:55.000000000 +0200
@@ -77,3 +77,15 @@ int bcm47xx_gpio_direction_output(unsign
}
EXPORT_SYMBOL_GPL(bcm47xx_gpio_direction_output);
+int bcm47xx_gpio_is_valid(int gpio)
+{
+ if (ssb_bcm47xx.chipco.dev) {
+ if (gpio >= 0 && gpio < BCM47XX_CHIPCO_GPIO_LINES)
+ return 1;
+ } else if (ssb_bcm47xx.extif.dev) {
+ if (gpio >= 0 && gpio < BCM47XX_EXTIF_GPIO_LINES)
+ return 1;
+ }
+ return 0;
+}
+EXPORT_SYMBOL_GPL(bcm47xx_gpio_is_valid);
Index: linux-2.6.25.10/include/asm-mips/mach-bcm47xx/gpio.h
===================================================================
--- linux-2.6.25.10.orig/include/asm-mips/mach-bcm47xx/gpio.h 2008-07-20 20:48:44.000000000 +0200
+++ linux-2.6.25.10/include/asm-mips/mach-bcm47xx/gpio.h 2008-07-20 20:49:20.000000000 +0200
@@ -17,6 +17,7 @@ extern int bcm47xx_gpio_get_value(unsign
extern void bcm47xx_gpio_set_value(unsigned gpio, int value);
extern int bcm47xx_gpio_direction_input(unsigned gpio);
extern int bcm47xx_gpio_direction_output(unsigned gpio, int value);
+extern int bcm47xx_gpio_is_valid(int gpio);
static inline int gpio_request(unsigned gpio, const char *label)
{
@@ -52,6 +53,10 @@ static inline int gpio_direction_output(
return bcm47xx_gpio_direction_output(gpio, value);
}
+static inline int gpio_is_valid(int gpio)
+{
+ return bcm47xx_gpio_is_valid(gpio);
+}
/* cansleep wrappers */
#include <asm-generic/gpio.h>
Backport gpio_is_valid() for gpiolib from linux-2.6.26
Index: linux-2.6.25.10/include/asm-generic/gpio.h
===================================================================
--- linux-2.6.25.10.orig/include/asm-generic/gpio.h 2008-07-03 05:46:47.000000000 +0200
+++ linux-2.6.25.10/include/asm-generic/gpio.h 2008-07-20 20:32:12.000000000 +0200
@@ -16,6 +16,12 @@
#define ARCH_NR_GPIOS 256
#endif
+static inline int gpio_is_valid(int number)
+{
+ /* only some non-negative numbers are valid */
+ return ((unsigned)number) < ARCH_NR_GPIOS;
+}
+
struct seq_file;
/**
Index: linux-2.6.25.10/include/linux/spi/spi_gpio.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.25.10/include/linux/spi/spi_gpio.h 2008-07-18 18:19:56.000000000 +0200
@@ -0,0 +1,67 @@
+++ linux-2.6.25.10/include/linux/spi/spi_gpio.h 2008-07-20 20:10:21.000000000 +0200
@@ -0,0 +1,73 @@
+/*
+ * spi_gpio interface to platform code
+ *
......@@ -20,7 +20,9 @@ Index: linux-2.6.25.10/include/linux/spi/spi_gpio.h
+#include <linux/spi/spi.h>
+
+
+/** struct spi_gpio_platform_data - Data definitions for a SPI-GPIO device.
+/**
+ * struct spi_gpio_platform_data - Data definitions for a SPI-GPIO device.
+ *
+ * This structure holds information about a GPIO-based SPI device.
+ *
+ * @pin_clk: The GPIO pin number of the CLOCK pin.
......@@ -56,13 +58,17 @@ Index: linux-2.6.25.10/include/linux/spi/spi_gpio.h
+ void *boardinfo_setup_data;
+};
+
+/** SPI_GPIO_PLATDEV_NAME - The platform device name string.
+/**
+ * SPI_GPIO_PLATDEV_NAME - The platform device name string.
+ *
+ * The name string that has to be used for platform_device_alloc
+ * when allocating a spi-gpio device.
+ */
+#define SPI_GPIO_PLATDEV_NAME "spi-gpio"
+
+/** spi_gpio_next_id - Get another platform device ID number.
+/**
+ * spi_gpio_next_id - Get another platform device ID number.
+ *
+ * This returns the next platform device ID number that has to be used
+ * for platform_device_alloc. The ID is opaque and should not be used for
+ * anything else.
......@@ -73,7 +79,7 @@ Index: linux-2.6.25.10/include/linux/spi/spi_gpio.h
Index: linux-2.6.25.10/drivers/spi/spi_gpio.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.25.10/drivers/spi/spi_gpio.c 2008-07-18 18:19:56.000000000 +0200
+++ linux-2.6.25.10/drivers/spi/spi_gpio.c 2008-07-20 20:10:21.000000000 +0200
@@ -0,0 +1,251 @@
+/*
+ * Bitbanging SPI bus driver using GPIO API
......@@ -328,8 +334,8 @@ Index: linux-2.6.25.10/drivers/spi/spi_gpio.c
+MODULE_LICENSE("GPL v2");
Index: linux-2.6.25.10/drivers/spi/Kconfig
===================================================================
--- linux-2.6.25.10.orig/drivers/spi/Kconfig 2008-07-18 18:19:43.000000000 +0200
+++ linux-2.6.25.10/drivers/spi/Kconfig 2008-07-18 18:19:56.000000000 +0200
--- linux-2.6.25.10.orig/drivers/spi/Kconfig 2008-07-20 20:09:48.000000000 +0200
+++ linux-2.6.25.10/drivers/spi/Kconfig 2008-07-20 20:11:48.000000000 +0200
@@ -100,6 +100,19 @@ config SPI_BUTTERFLY
inexpensive battery powered microcontroller evaluation board.
This same cable can be used to flash new firmware.
......@@ -341,7 +347,7 @@ Index: linux-2.6.25.10/drivers/spi/Kconfig
+ help
+ This is a platform driver that can be used for bitbanging
+ an SPI bus over GPIO pins.
+ Select this, if you have any SPI device that is connected via
+ Select this if you have any SPI device that is connected via
+ GPIO pins.
+ The module will be called spi_gpio.
+
......@@ -352,8 +358,8 @@ Index: linux-2.6.25.10/drivers/spi/Kconfig
depends on SPI_MASTER && ARCH_IMX && EXPERIMENTAL
Index: linux-2.6.25.10/drivers/spi/Makefile
===================================================================
--- linux-2.6.25.10.orig/drivers/spi/Makefile 2008-07-18 18:19:43.000000000 +0200
+++ linux-2.6.25.10/drivers/spi/Makefile 2008-07-18 18:19:56.000000000 +0200
--- linux-2.6.25.10.orig/drivers/spi/Makefile 2008-07-20 20:09:48.000000000 +0200
+++ linux-2.6.25.10/drivers/spi/Makefile 2008-07-20 20:10:21.000000000 +0200
@@ -16,6 +16,7 @@ obj-$(CONFIG_SPI_BFIN) += spi_bfin5xx.
obj-$(CONFIG_SPI_BITBANG) += spi_bitbang.o
obj-$(CONFIG_SPI_AU1550) += au1550_spi.o
......@@ -364,8 +370,8 @@ Index: linux-2.6.25.10/drivers/spi/Makefile
obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o
Index: linux-2.6.25.10/MAINTAINERS
===================================================================
--- linux-2.6.25.10.orig/MAINTAINERS 2008-07-03 05:46:47.000000000 +0200
+++ linux-2.6.25.10/MAINTAINERS 2008-07-18 18:20:28.000000000 +0200
--- linux-2.6.25.10.orig/MAINTAINERS 2008-07-20 20:09:48.000000000 +0200
+++ linux-2.6.25.10/MAINTAINERS 2008-07-20 20:10:59.000000000 +0200
@@ -3685,6 +3685,11 @@ M: dbrownell@users.sourceforge.net
L: spi-devel-general@lists.sourceforge.net
S: Maintained
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment