diff options
| author | Koen Kooi <koen@openembedded.org> | 2009-01-10 10:44:13 +0100 |
|---|---|---|
| committer | Koen Kooi <koen@openembedded.org> | 2009-01-10 10:44:13 +0100 |
| commit | d076ad3dbeac4bf7a58a335348c1560dd23799a7 (patch) | |
| tree | f402fe30741bb8ea76d0f411a1179c6ac937be76 | |
| parent | 06af67f2e653d6b0d45117f9aaad0b25db1eaa67 (diff) | |
gumstix utils: add char-driver, gpio-event, i2c and microwindows
45 files changed, 6251 insertions, 38 deletions
diff --git a/packages/char-driver/char-driver.bb b/packages/char-driver/char-driver.bb new file mode 100644 index 0000000000..e6458b599b --- /dev/null +++ b/packages/char-driver/char-driver.bb @@ -0,0 +1,62 @@ +DESCRIPTION = "char-driver and userspace program" +PRIORITY = "optional" +SECTION = "base" +LICENSE = "GPL" +RDEPENDS = "kernel (${KERNEL_VERSION})" +DEPENDS = "virtual/kernel" + +PR = "r3" + +SRC_URI = "http://www.davehylands.com/gumstix-wiki/char-driver/char-driver-2.6.21.tar.gz \ + file://makefile.patch;patch=1 \ +# file://sysctl.patch;patch=1 \ + " + +S = "${WORKDIR}/char-driver" + +inherit module-base + +addtask builddir after do_fetch before do_unpack +addtask movesrc after do_unpack before do_patch + +EXTRA_OEMAKE = 'CROSS_COMPILE="${CROSS_COMPILE}" \ + KERNELDIR="${KERNEL_SOURCE}" \ + CC="${CC}" \ + ' + +PARALLEL_MAKE = "" + +do_builddir () { + mkdir -p ${S} +} + +do_movesrc () { + cd ${WORKDIR} + mv char-driver*.c sample.c char-driver*.h Makefile ${S} +} + +do_configure () { + echo "Nothing to configure for char-driver" +} + +do_compile () { + unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS + cd ${S} + oe_runmake +} + +do_install () { + # install programs to bindir + install -m 0755 -d ${D}${bindir} + install -m 0755 ${S}/sample ${D}${bindir} + + # kernel module installs with other modules + install -m 0755 -d ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra/ + # use cp instead of install so the driver doesn't get stripped + cp ${S}/char-driver.ko ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra/ +} + +PACKAGES = "${PN}" +FILES_${PN} = "${bindir}/sample" +FILES_${PN} += "${base_libdir}/modules/${KERNEL_VERSION}/extra/char-driver.ko" + diff --git a/packages/char-driver/char-driver/makefile.patch b/packages/char-driver/char-driver/makefile.patch new file mode 100644 index 0000000000..d2d8e3c705 --- /dev/null +++ b/packages/char-driver/char-driver/makefile.patch @@ -0,0 +1,26 @@ +--- char-driver/Makefile.orig 2008-03-09 14:38:02.000000000 -0600 ++++ char-driver/Makefile 2008-03-09 14:39:04.000000000 -0600 +@@ -19,10 +19,10 @@ +
+ PWD := $(shell pwd)
+
+-GUMSTIX_BUILDROOT = $(PWD)/../gumstix-buildroot
+-BUILD_ARM = $(wildcard $(GUMSTIX_BUILDROOT)/build_arm*)
+-KERNELDIR ?= $(wildcard $(BUILD_ARM)/linux-*)
+-CROSS_COMPILE = $(BUILD_ARM)/staging_dir/bin/arm-linux-
++#GUMSTIX_BUILDROOT = $(PWD)/../gumstix-buildroot
++#BUILD_ARM = $(wildcard $(GUMSTIX_BUILDROOT)/build_arm*)
++#KERNELDIR ?= $(wildcard $(BUILD_ARM)/linux-*)
++#CROSS_COMPILE = $(BUILD_ARM)/staging_dir/bin/arm-linux-
+
+ default: user-apps kernel-module
+
+@@ -31,7 +31,7 @@ + user-apps: sample
+
+ TARGET_ARCH=-Os -march=armv5te -mtune=xscale -Wa,-mcpu=xscale
+-CC = $(CROSS_COMPILE)gcc
++#CC = $(CROSS_COMPILE)gcc
+
+ sample: sample.c
+
diff --git a/packages/char-driver/char-driver/sysctl.patch b/packages/char-driver/char-driver/sysctl.patch new file mode 100644 index 0000000000..1c7a7600ba --- /dev/null +++ b/packages/char-driver/char-driver/sysctl.patch @@ -0,0 +1,34 @@ +--- char-driver/char-driver.c.orig 2008-03-09 13:05:30.000000000 -0600 ++++ char-driver/char-driver.c 2008-03-09 13:04:33.000000000 -0600 +@@ -26,7 +26,6 @@ + /* ---- Include Files ---------------------------------------------------- */ + + #include <linux/module.h> +-#include <linux/config.h> + #include <linux/init.h> + #include <linux/fs.h> + #include <linux/spinlock.h> +@@ -426,12 +425,17 @@ + printk( "sample driver allocated major:%d minor:%d\n", MAJOR( gSampleDevNum ), MINOR( gSampleDevNum )); + + // Register our proc entries. +- +- gSysCtlHeader = register_sysctl_table( gSysCtl, 0 ); +- if ( gSysCtlHeader != NULL ) +- { +- gSysCtlHeader->ctl_table->child->de->owner = THIS_MODULE; +- } ++#if USE_SYSCTL ++ #if ( LINUX_VERSION_CODE <= KERNEL_VERSION( 2, 6, 20 )) ++ gSysCtlHeader = register_sysctl_table( gSysCtl, 0 ); ++ if ( gSysCtlHeader != NULL ) ++ { ++ gSysCtlHeader->ctl_table->child->de->owner = THIS_MODULE; ++ } ++ #else ++ gSysCtlHeader = register_sysctl_table( gSysCtl ); ++ #endif ++#endif + + // Register our device. The device becomes "active" as soon as cdev_add + // is called. diff --git a/packages/gpio-event/gpio-event.bb b/packages/gpio-event/gpio-event.bb new file mode 100644 index 0000000000..afb2a77ac1 --- /dev/null +++ b/packages/gpio-event/gpio-event.bb @@ -0,0 +1,61 @@ +DESCRIPTION = "gpio-event driver and userspace program" +PRIORITY = "optional" +SECTION = "base" +LICENSE = "GPL" +RDEPENDS = "kernel (${KERNEL_VERSION})" +DEPENDS = "virtual/kernel" + +PR = "r4" + +SRC_URI = "http://davehylands.com/gumstix-wiki/gpio-event/gpio-event-2.6.21-1444-select.tar.gz \ + file://makefile.patch;patch=1 \ + " + +S = "${WORKDIR}/gpio-event" + +inherit module-base + +addtask builddir after do_fetch before do_unpack +addtask movesrc after do_unpack before do_patch + +EXTRA_OEMAKE = 'CROSS_COMPILE="${CROSS_COMPILE}" \ + KERNELDIR="${KERNEL_SOURCE}" \ + CC="${CC}" \ + ' + +PARALLEL_MAKE = "" + +do_builddir () { + mkdir -p ${S} +} + +do_movesrc () { + cd ${WORKDIR} + mv gpio-event*.c gpio-event*.h Makefile ${S} +} + +do_configure () { + echo "Nothing to configure for gpio-event" +} + +do_compile () { + unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS + cd ${S} + oe_runmake +} + +do_install () { + # install programs to bindir + install -m 0755 -d ${D}${bindir} + install -m 0755 ${S}/gpio-event ${D}${bindir} + + # kernel module installs with other modules + install -m 0755 -d ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra/ + # use cp instead of install so the driver doesn't get stripped + cp ${S}/gpio-event-drv.ko ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra/ +} + +PACKAGES = "${PN}" +FILES_${PN} = "${bindir}/gpio-event" +FILES_${PN} += "${base_libdir}/modules/${KERNEL_VERSION}/extra/gpio-event-drv.ko" + diff --git a/packages/gpio-event/gpio-event/makefile.patch b/packages/gpio-event/gpio-event/makefile.patch new file mode 100644 index 0000000000..e1b7fe31b9 --- /dev/null +++ b/packages/gpio-event/gpio-event/makefile.patch @@ -0,0 +1,26 @@ +--- gpio-event/Makefile.orig 2008-03-09 13:59:07.000000000 -0600 ++++ gpio-event/Makefile 2008-03-09 13:59:51.000000000 -0600 +@@ -19,10 +19,10 @@ +
+ PWD := $(shell pwd)
+
+-GUMSTIX_BUILDROOT = $(PWD)/../cx-1575
+-BUILD_ARM = $(wildcard $(GUMSTIX_BUILDROOT)/build_arm*)
+-KERNELDIR ?= $(wildcard $(BUILD_ARM)/linux-*)
+-CROSS_COMPILE = $(BUILD_ARM)/staging_dir/bin/arm-linux-
++#GUMSTIX_BUILDROOT = $(PWD)/../cx-1575
++#BUILD_ARM = $(wildcard $(GUMSTIX_BUILDROOT)/build_arm*)
++#KERNELDIR ?= $(wildcard $(BUILD_ARM)/linux-*)
++#CROSS_COMPILE = $(BUILD_ARM)/staging_dir/bin/arm-linux-
+
+ default: user-apps kernel-module
+
+@@ -31,7 +31,7 @@ + user-apps: gpio-event
+
+ TARGET_ARCH=-Os -march=armv5te -mtune=xscale -Wa,-mcpu=xscale
+-CC = $(CROSS_COMPILE)gcc
++#CC = $(CROSS_COMPILE)gcc
+
+ CPPFLAGS +=
+ CFLAGS += -Wall
diff --git a/packages/i2c/files/Config.h b/packages/i2c/files/Config.h new file mode 100644 index 0000000000..83bb46de84 --- /dev/null +++ b/packages/i2c/files/Config.h @@ -0,0 +1,41 @@ +/**************************************************************************** +* +* Copyright (c) 2006 Dave Hylands <dhylands@gmail.com> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* Alternatively, this software may be distributed under the terms of BSD +* license. +* +* See README and COPYING for more details. +* +****************************************************************************/ +/** +* +* @file Config.h +* +* @brief Global Configuration information. +* +****************************************************************************/ + +#if !defined( CONFIG_H ) +#define CONFIG_H /**< Include Guard */ + +/* ---- Include Files ---------------------------------------------------- */ + +/* ---- Constants and Types ---------------------------------------------- */ + +/** + * Sets Logging parameters + */ + +#define CFG_LOG_TO_BUFFER 0 + +#define CFG_CRC8BLOCK 1 + +/** @} */ + +#endif // CONFIG_H + diff --git a/packages/i2c/files/Crc8.c b/packages/i2c/files/Crc8.c new file mode 100644 index 0000000000..87dcf5c2f4 --- /dev/null +++ b/packages/i2c/files/Crc8.c @@ -0,0 +1,149 @@ +/**************************************************************************** +* +* Copyright (c) 2006 Dave Hylands <dhylands@gmail.com> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* Alternatively, this software may be distributed under the terms of BSD +* license. +* +* See README and COPYING for more details. +* +****************************************************************************/ +/** +* +* @file Crc8.c +* +* @brief This file contains the definition of the CRC-8 algorithim +* used by SMBus +* +* +*****************************************************************************/ + +/* ---- Include Files ----------------------------------------------------- */ + +#include "Config.h" + +#include "Crc8.h" + +#include "Log.h" + +/* ---- Public Variables -------------------------------------------------- */ +/* ---- Private Constants and Types --------------------------------------- */ +/* ---- Private Variables ------------------------------------------------- */ +/* ---- Private Function Prototypes --------------------------------------- */ +/* ---- Functions --------------------------------------------------------- */ + +/****************************************************************************/ +/** +* Calculates the CRC-8 used as part of SMBus. +* +* CRC-8 is defined to be x^8 + x^2 + x + 1 +* +* To use this function use the following template: +* +* crc = Crc8( crc, data ); +*/ + +#if 0 // Traditional implementation + +#define POLYNOMIAL (0x1070U << 3) + +unsigned char Crc8( unsigned char inCrc, unsigned char inData ) +{ + int i; + unsigned short data; + + data = inCrc ^ inData; + data <<= 8; + + for ( i = 0; i < 8; i++ ) + { + if (( data & 0x8000 ) != 0 ) + { + data = data ^ POLYNOMIAL; + } + data = data << 1; + } + +#if 0 +#if defined( LogBuf2 ) + LogBuf2( "Crc8: data:0x%02x crc:0x%02x\n", inData, (unsigned char)( data >> 8 )); +#else + + Log( "Crc8: data:0x%02x crc:0x%02x\n", inData, (unsigned char)( data >> 8 )); +#endif + +#endif + + + return (unsigned char)( data >> 8 ); + +} // Crc8 + +#else // Optimized for 8 bit CPUs (0x22 bytes on ATMega128 versus 0x30 for above version) + +unsigned char Crc8( unsigned char inCrc, unsigned char inData ) +{ + unsigned char i; + unsigned char data; + + data = inCrc ^ inData; + + for ( i = 0; i < 8; i++ ) + { + if (( data & 0x80 ) != 0 ) + { + data <<= 1; + data ^= 0x07; + } + else + { + data <<= 1; + } + } + +#if 0 +#if defined( LogBuf2 ) + LogBuf2( "Crc8: data:0x%02x crc:0x%02x\n", inData, data ); +#else + + Log( "Crc8: data:0x%02x crc:0x%02x\n", inData, data ); +#endif + +#endif + + + return data; + +} // Crc8 + +#endif + + +#if defined( CFG_CRC8BLOCK ) + +/****************************************************************************/ +/** +* Calculates the CRC-8 used as part of SMBus over a block of memory. +*/ + +uint8_t Crc8Block( uint8_t crc, uint8_t *data, uint8_t len ) +{ + while ( len > 0 ) + { + crc = Crc8( crc, *data++ ); + len--; + } + + return crc; + +} // Crc8Block + +#endif // CFG_CRC8BLOCK + +/** @} */ + + diff --git a/packages/i2c/files/Crc8.h b/packages/i2c/files/Crc8.h new file mode 100644 index 0000000000..2d1f74b82c --- /dev/null +++ b/packages/i2c/files/Crc8.h @@ -0,0 +1,54 @@ +/**************************************************************************** +* +* Copyright (c) 2006 Dave Hylands <dhylands@gmail.com> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* Alternatively, this software may be distributed under the terms of BSD +* license. +* +* See README and COPYING for more details. +* +****************************************************************************/ +/** +* +* @file Crc8.h +* +* @brief This file contains the definition of the CRC-8 algorithim +* used by SMBus +* +****************************************************************************/ + +#if !defined( CRC8_H ) +#define CRC_H ///< Include Guard + +/* ---- Include Files ----------------------------------------------------- */ + +#include <inttypes.h> + +#if defined( __cplusplus ) +extern "C" +{ +#endif + + +/* ---- Constants and Types ---------------------------------------------- */ +/* ---- Variable Externs ------------------------------------------------- */ +/* ---- Function Prototypes ---------------------------------------------- */ + +uint8_t Crc8( uint8_t crc, uint8_t data ); + +uint8_t Crc8Block( uint8_t crc, uint8_t *data, uint8_t len ); + + +#if defined( __cplusplus ) +} +#endif + + +/** @} */ + +#endif // CRC8_H + diff --git a/packages/i2c/files/DumpMem.c b/packages/i2c/files/DumpMem.c new file mode 100644 index 0000000000..e13e94b0f8 --- /dev/null +++ b/packages/i2c/files/DumpMem.c @@ -0,0 +1,93 @@ +/**************************************************************************** +* +* Copyright (c) 2006 Dave Hylands <dhylands@gmail.com> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* Alternatively, this software may be distributed under the terms of BSD +* license. +* +* See README and COPYING for more details. +* +****************************************************************************/ +/** +* +* @file DumpMem.c +* +* @brief Memmory dump routine +* +****************************************************************************/ + +// ---- Include Files ------------------------------------------------------- + +#include <inttypes.h> +#include "DumpMem.h" +#include "Log.h" + +// ---- Public Variables ---------------------------------------------------- +// ---- Private Constants and Types ----------------------------------------- +// ---- Private Variables --------------------------------------------------- +// ---- Private Function Prototypes ----------------------------------------- +// ---- Functions ----------------------------------------------------------- + +/**************************************************************************/ +/** +* Dumps a page of output for debugging purposes. +*/ + +void DumpMem( const char *prefix, unsigned address, const void *inData, unsigned numBytes ) +{ + const uint8_t *data = (const uint8_t *)inData; + unsigned byteOffset; + + if ( numBytes == 0 ) + { + Log( "%s: No data\n", prefix ); + return; + } + +#define LINE_WIDTH 16 + + for ( byteOffset = 0; byteOffset < numBytes; byteOffset += LINE_WIDTH ) + { + unsigned i; + + Log( "%s: %04x: ", prefix, address + byteOffset ); + + for ( i = 0; i < LINE_WIDTH; i++ ) + { + if (( byteOffset + i ) < numBytes ) + { + Log( "%02.2X ", data[ byteOffset + i ] ); + } + else + { + Log( " " ); + } + } + for ( i = 0; i < LINE_WIDTH; i++ ) + { + if (( byteOffset + i ) < numBytes ) + { + unsigned char ch = data[ byteOffset + i ]; + if (( ch < ' ' ) || ( ch > '~' )) + { + Log( "." ); + } + else + { + Log( "%c", ch ); + } + } + else + { + break; + } + } + Log( "\n" ); + } + +} // DumpMem + diff --git a/packages/i2c/files/DumpMem.h b/packages/i2c/files/DumpMem.h new file mode 100644 index 0000000000..5d536f49e8 --- /dev/null +++ b/packages/i2c/files/DumpMem.h @@ -0,0 +1,49 @@ +/**************************************************************************** +* +* Copyright (c) 2006 Dave Hylands <dhylands@gmail.com> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* Alternatively, this software may be distributed under the terms of BSD +* license. +* +* See README and COPYING for more details. +* +****************************************************************************/ +/** +* +* @file DumpMem.h +* +* @brief Debug routine for dumping memory +* +****************************************************************************/ + +#if !defined( DUMPMEM_H ) +#define DUMPMEM_H ///< Include Guard + +// ---- Include Files ------------------------------------------------------- + +/** + * @addtogroup Log + * @{ + */ + +#if defined( __cplusplus ) +extern "C" +{ +#endif + + +void DumpMem( const char *prefix, unsigned address, const void *data, unsigned numBytes ); + +#if defined( __cplusplus ) +} +#endif + + +/** @} */ + +#endif // DUMPMEM_H + diff --git a/packages/i2c/files/Log.c b/packages/i2c/files/Log.c new file mode 100644 index 0000000000..e32783391b --- /dev/null +++ b/packages/i2c/files/Log.c @@ -0,0 +1,335 @@ +/**************************************************************************** +* +* Copyright (c) 2006 Dave Hylands <dhylands@gmail.com> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* Alternatively, this software may be distributed under the terms of BSD +* license. +* +* See README and COPYING for more details. +* +****************************************************************************/ +/** +* +* @file Log.cpp +* +* @brief This file contains the implementation of the logging functions. +* +****************************************************************************/ + +// ---- Include Files ------------------------------------------------------- + +#include "Log.h" + +#if CFG_LOG_USE_STDIO +# include <stdio.h> +#else + +# include "Str.h" +# include "UART.h" +#endif + + +// ---- Public Variables ---------------------------------------------------- +// ---- Private Constants and Types ----------------------------------------- + +#if defined( AVR ) + +#undef Log +#undef LogError +#undef vLog + +#define Log Log_P +#define LogError LogError_P +#define vLog vLog_P +#define LogBuf LogBuf_P + +#define char prog_char + +#else + + +#define PSTR(str) str + +int gVerbose = 0; +int gDebug = 0; +int gQuiet = 0; + +#endif + + +#if CFG_LOG_TO_BUFFER + +volatile LOG_Buffer_t LOG_gBuffer; + +#endif + + +// ---- Private Variables --------------------------------------------------- + +#if CFG_LOG_USE_STDIO + +FILE *gLogFs = NULL; + +#endif + + +// ---- Private Function Prototypes ----------------------------------------- + +// ---- Functions ----------------------------------------------------------- + +/** + * @addtogroup Log + * @{ + */ + +#if !defined( AVR ) + +void DefaultLogFunc( int logLevel, const char *fmt, va_list args ) +{ + FILE *fs; + + if ( gQuiet && ( logLevel == LOG_LEVEL_NORMAL )) + { + return; + } + + if ( gLogFs == NULL ) + { + fs = stderr; + } + else + { + fs = gLogFs; + } + + if ( logLevel == LOG_LEVEL_ERROR ) + { + fprintf( fs, "ERROR: " ); + } + vfprintf( fs, fmt, args ); + fflush( fs ); + +} // DefaultLogFunc + +static LogFunc_t gLogFunc = DefaultLogFunc; + +void SetLogFunc( LogFunc_t logFunc ) +{ + + gLogFunc = logFunc; + +} // SetLogFunc + +#endif + + +//*************************************************************************** +/** +* Sets the logging stream +*/ + +#if CFG_LOG_USE_STDIO +void LogInit( FILE *logFs ) +{ + gLogFs = logFs; + +} // LogInit + +#else + + +static int LogToUartFunc( void *outParm, int ch ) +{ + UART0_PutChar( ch ); + + return 1; +} +#endif + |
