diff options
-rw-r--r-- | packages/linux/gumstix-kernel-2.6.21/smc91x-fail-if-no-chip.patch | 2 | ||||
-rw-r--r-- | packages/linux/gumstix-kernel-2.6.21/tsc2003.c | 260 | ||||
-rw-r--r-- | packages/linux/gumstix-kernel_2.6.21.bb | 2 | ||||
-rw-r--r-- | packages/linux/gumstix-linux.inc | 31 |
4 files changed, 139 insertions, 156 deletions
diff --git a/packages/linux/gumstix-kernel-2.6.21/smc91x-fail-if-no-chip.patch b/packages/linux/gumstix-kernel-2.6.21/smc91x-fail-if-no-chip.patch index 0d4425412c..17ead87f12 100644 --- a/packages/linux/gumstix-kernel-2.6.21/smc91x-fail-if-no-chip.patch +++ b/packages/linux/gumstix-kernel-2.6.21/smc91x-fail-if-no-chip.patch @@ -52,7 +52,7 @@ -proceed: +proceed1: -+ printk(KERN_ERR "%s: found %d smc91x chip(s)\n", __FUNCTION__); ++ printk(KERN_ERR "%s: found %d smc91x chip(s)\n", __FUNCTION__,num_devices); pxa_gpio_mode(GPIO15_nCS_1_MD); if(smc91x_devices[1]) pxa_gpio_mode(GPIO_GUMSTIX_ETH1_RST_MD); diff --git a/packages/linux/gumstix-kernel-2.6.21/tsc2003.c b/packages/linux/gumstix-kernel-2.6.21/tsc2003.c index a4a68b756d..8836537b77 100644 --- a/packages/linux/gumstix-kernel-2.6.21/tsc2003.c +++ b/packages/linux/gumstix-kernel-2.6.21/tsc2003.c @@ -3,7 +3,8 @@ * * Copyright (C) 2005 Bill Gatliff <bgat at billgatliff.com> * Changes for 2.6.20 kernel by Nicholas Chen <nchen at cs.umd.edu> - * Changes for 2.6.21 kernel by Chris Dollar <chris.dollar at gmail.com> + * Changes to poll for events rather than use penirq by + * Chris Dollar <chris.dollar at 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 @@ -12,7 +13,6 @@ * Driver for TI's TSC2003 I2C Touch Screen Controller */ -//#include <linux/config.h> #include <linux/module.h> #include <linux/init.h> #include <linux/slab.h> @@ -21,10 +21,8 @@ #include <linux/bcd.h> #include <linux/list.h> #include <linux/device.h> -#include <linux/interrupt.h> #include <linux/input.h> #include <linux/delay.h> -#include <asm-arm/arch-pxa/irqs.h> #define DRIVER_NAME "tsc2003" #define TSC2003_CMD(cn,pdn,m) (((cn) << 4) | ((pdn) << 2) | ((m) << 1)) @@ -37,10 +35,10 @@ static unsigned short normal_i2c[] = { 0x48, I2C_CLIENT_END }; I2C_CLIENT_INSMOD_1(tsc2003); enum tsc2003_pd { - PD_POWERDOWN = 0, /* penirq */ - PD_IREFOFF_ADCON = 1, /* no penirq */ - PD_IREFON_ADCOFF = 2, /* penirq */ - PD_IREFON_ADCON = 3, /* no penirq */ + PD_POWERDOWN = 0, + PD_IREFOFF_ADCON = 1, + PD_IREFON_ADCOFF = 2, + PD_IREFON_ADCON = 3, PD_PENIRQ_ARM = PD_IREFON_ADCOFF, PD_PENIRQ_DISARM = PD_IREFON_ADCON, }; @@ -70,14 +68,10 @@ struct tsc2003_data { struct i2c_client client; struct device_driver driver; struct input_dev *idev; - struct semaphore sem; struct task_struct *tstask; struct completion tstask_completion; - struct completion penirq_completion; enum tsc2003_pd pd; enum tsc2003_m m; - int penirq; - int vbat1; int vbat2; int temp0; @@ -86,11 +80,12 @@ struct tsc2003_data { int in2; }; -static int - tsc2003_i2c_detect(struct i2c_adapter *adapter, int address, int kind); +static int tsc2003_i2c_detect(struct i2c_adapter *adapter, int address, + int kind); static int tsc2003_read(struct tsc2003_data *data, enum tsc2003_cmd cmd, - enum tsc2003_pd pd, int *val) { + enum tsc2003_pd pd, int *val) +{ char c; char d[2]; int ret; @@ -101,7 +96,8 @@ static int tsc2003_read(struct tsc2003_data *data, enum tsc2003_cmd cmd, goto err; udelay(20); - ret = i2c_master_recv(&data->client, d, data->m == M_12BIT ? 2 : 1); + ret = + i2c_master_recv(&data->client, d, data->m == M_12BIT ? 2 : 1); if (ret <= 0) goto err; @@ -111,70 +107,80 @@ static int tsc2003_read(struct tsc2003_data *data, enum tsc2003_cmd cmd, if (data->m == M_12BIT) *val += (d[1] >> 4); } - #if defined(CONFIG_I2C_DEBUG_CHIP) printk(KERN_ERR "%s: val[%x] = %d\n", - __FUNCTION__, cmd, (((int)d[0]) << 8) + d[1]); + __FUNCTION__, cmd, (((int) d[0]) << 8) + d[1]); #endif return 0; - err: if (!ret) + err:if (!ret) ret = -ENODEV; return ret; } static inline int tsc2003_read_temp0(struct tsc2003_data *d, enum -tsc2003_pd pd, int *t) { + tsc2003_pd pd, int *t) +{ return tsc2003_read(d, MEAS_TEMP0, pd, t); } static inline int tsc2003_read_temp1(struct tsc2003_data *d, enum -tsc2003_pd pd, int *t) { + tsc2003_pd pd, int *t) +{ return tsc2003_read(d, MEAS_TEMP1, pd, t); } static inline int tsc2003_read_xpos(struct tsc2003_data *d, enum -tsc2003_pd pd, int *x) { + tsc2003_pd pd, int *x) +{ return tsc2003_read(d, MEAS_XPOS, pd, x); } static inline int tsc2003_read_ypos(struct tsc2003_data *d, enum -tsc2003_pd pd, int *y) { + tsc2003_pd pd, int *y) +{ return tsc2003_read(d, MEAS_YPOS, pd, y); } static inline int tsc2003_read_pressure(struct tsc2003_data *d, enum -tsc2003_pd pd, int *p) { + tsc2003_pd pd, int *p) +{ return tsc2003_read(d, MEAS_Z1POS, pd, p); } static inline int tsc2003_read_in1(struct tsc2003_data *d, enum -tsc2003_pd pd, int *t) { + tsc2003_pd pd, int *t) +{ return tsc2003_read(d, MEAS_IN1, pd, t); } static inline int tsc2003_read_in2(struct tsc2003_data *d, enum -tsc2003_pd pd, int *t) { + tsc2003_pd pd, int *t) +{ return tsc2003_read(d, MEAS_IN2, pd, t); } static inline int tsc2003_read_vbat1(struct tsc2003_data *d, enum -tsc2003_pd pd, int *t) { + tsc2003_pd pd, int *t) +{ return tsc2003_read(d, MEAS_VBAT1, pd, t); } static inline int tsc2003_read_vbat2(struct tsc2003_data *d, enum -tsc2003_pd pd, int *t) { + tsc2003_pd pd, int *t) +{ return tsc2003_read(d, MEAS_VBAT2, pd, t); } -static inline int tsc2003_powerdown(struct tsc2003_data *d) { +static inline int tsc2003_powerdown(struct tsc2003_data *d) +{ /* we don't have a distinct powerdown command, - so do a benign read with the PD bits cleared */ + so do a benign read with the PD bits cleared */ return tsc2003_read(d, MEAS_IN1, PD_POWERDOWN, 0); } -void tsc2003_init_client(struct i2c_client *client) { +void tsc2003_init_client(struct i2c_client *client) +{ struct tsc2003_data *data = i2c_get_clientdata(client); data->pd = PD_PENIRQ_DISARM; @@ -182,34 +188,10 @@ void tsc2003_init_client(struct i2c_client *client) { return; } -static irqreturn_t tsc2003_penirq(int irq, void *v) { - struct tsc2003_data *d = v; - - printk(KERN_INFO "penirq: %Ld\n", jiffies); - - // disable the penirq while we take the sample - disable_irq_nosync(d->penirq); - - complete(&d->penirq_completion); - return IRQ_HANDLED; -} - -static void tsc2003_pen_up(unsigned long v) { - printk(KERN_INFO "tsc2003_pen_up - re-enable irq now\n"); - struct tsc2003_data *d = (struct tsc2003_data *)v; - - enable_irq(d->penirq); - - input_report_abs(d->idev, ABS_PRESSURE, 0); - input_sync(d->idev); - return; -} - -static int tsc2003ts_thread(void *v) { +static int tsc2003ts_thread(void *v) +{ struct tsc2003_data *d = v; struct task_struct *tsk = current; - int ret; - int err = 0; d->tstask = tsk; @@ -220,56 +202,47 @@ static int tsc2003ts_thread(void *v) { #if defined(CONFIG_I2C_DEBUG_CHIP) printk(KERN_INFO "%s: address 0x%x\n", - __FUNCTION__, d->client.addr); -#endif - - do { - unsigned int x, y, p, fp; - int pen_is_up = 0; - - down(&d->sem); + __FUNCTION__, d->client.addr); +#endif - // take the sample - d->pd = PD_PENIRQ_DISARM; - tsc2003_read_xpos(d, PD_PENIRQ_DISARM, &x); - tsc2003_read_ypos(d, PD_PENIRQ_DISARM, &y); - tsc2003_read_pressure(d, PD_PENIRQ_DISARM, &p); + do { + unsigned int x, y, p; + int pen_is_up = 0; - if (p < 64) { - p=0; - } + d->pd = PD_PENIRQ_DISARM; + tsc2003_read_xpos(d, PD_PENIRQ_DISARM, &x); + tsc2003_read_ypos(d, PD_PENIRQ_DISARM, &y); + tsc2003_read_pressure(d, PD_PENIRQ_DISARM, &p); + if (p < 64) { + p = 0; + } #if defined(CONFIG_I2C_DEBUG_CHIP) - printk(KERN_INFO "TSD X: %d Y: %d P: %d\n", x, y, p); -#endif - - if (!pen_is_up) { - // report our touch to the input layer - input_report_abs(d->idev, ABS_X, 4096 - x); - input_report_abs(d->idev, ABS_Y, 4096 - y); - input_report_abs(d->idev, ABS_PRESSURE, p); - input_sync(d->idev); - } - - if(p == 0) { + printk(KERN_INFO "TSD X: %d Y: %d P: %d\n", x, y, p); +#endif + + if (!pen_is_up) { + input_report_abs(d->idev, ABS_X, 4096 - x); + input_report_abs(d->idev, ABS_Y, 4096 - y); + input_report_abs(d->idev, ABS_PRESSURE, p); + input_sync(d->idev); + } + + if (p == 0) { #if defined(CONFIG_I2C_DEBUG_CHIP) - printk(KERN_INFO "No pressure - pen is up!\n"); -#endif - // set our pen as up - pen_is_up = 1; - } - else { + printk(KERN_INFO "No pressure - pen is up!\n"); +#endif + pen_is_up = 1; + } else { #if defined(CONFIG_I2C_DEBUG_CHIP) - printk(KERN_INFO "Pen is still down - sleeping and will re-sample!\n"); -#endif - // set our pen as down - pen_is_up = 0; - } - - // sleep for 3 jiffies to give us about 30 updates/sec - msleep (3); + printk(KERN_INFO + "Pen is still down - sleeping and will re-sample!\n"); +#endif + pen_is_up = 0; + } - up(&d->sem); + // sleep for 3 jiffies to give us about 30 updates/sec + msleep(3); } while (!signal_pending(tsk)); @@ -277,13 +250,11 @@ static int tsc2003ts_thread(void *v) { complete_and_exit(&d->tstask_completion, 0); } -static int tsc2003_idev_open(struct input_dev *idev) { +static int tsc2003_idev_open(struct input_dev *idev) +{ struct tsc2003_data *d = idev->private; int ret = 0; - if (down_interruptible(&d->sem)) - return -EINTR; - if (d->tstask) panic(DRIVER_NAME "tsd already running (!). abort."); @@ -293,50 +264,26 @@ static int tsc2003_idev_open(struct input_dev *idev) { ret = 0; } - up(&d->sem); return ret; } -static void tsc2003_idev_close(struct input_dev *idev) { +static void tsc2003_idev_close(struct input_dev *idev) +{ struct tsc2003_data *d = idev->private; - down_interruptible(&d->sem); if (d->tstask) { send_sig(SIGKILL, d->tstask, 1); wait_for_completion(&d->tstask_completion); } - up(&d->sem); return; } -static int tsc2003_detect_irq(struct tsc2003_data *d) { - d->penirq = IRQ_GPIO(16); //PWM0 GPIO - return 0; -} - -static int tsc2003_driver_register(struct tsc2003_data *data) { +static int tsc2003_driver_register(struct tsc2003_data *data) +{ struct input_dev *idev; int ret = 0; - int error; - - init_MUTEX(&data->sem); - error = tsc2003_detect_irq(data); - if (error) { - printk(KERN_ERR "TSC2003: IRQ probe failed\n"); - } - - if (data->penirq) { - ret = request_irq(data->penirq, tsc2003_penirq, SA_INTERRUPT | IRQF_TRIGGER_LOW, - DRIVER_NAME, data); - if (!ret) { - printk(KERN_INFO "%s: irq %d\n", __FUNCTION__, data->penirq); - init_completion(&data->tstask_completion); - init_completion(&data->penirq_completion); - } else { - printk(KERN_ERR "%s: cannot grab irq %d\n", __FUNCTION__, data->penirq); - } - } + init_completion(&data->tstask_completion); idev = input_allocate_device(); data->idev = idev; @@ -361,19 +308,21 @@ static int tsc2003_driver_register(struct tsc2003_data *data) { return ret; } -static int tsc2003_i2c_attach_adapter(struct i2c_adapter *adapter) { +static int tsc2003_i2c_attach_adapter(struct i2c_adapter *adapter) +{ printk(KERN_INFO "tsc2003 i2c touch screen controller\n"); +#if defined(CONFIG_I2C_DEBUG_CHIP) printk(KERN_INFO "Bill Gatliff <bgat at billgatliff.com\n"); - printk(KERN_INFO "Nicholas Chen <nchen at cs.umd.edu>\n"); - - return i2c_probe(adapter, &addr_data, tsc2003_i2c_detect); + printk(KERN_INFO "Nicholas Chen <nchen at cs.umd.edu>\n"); +#endif + return i2c_probe(adapter, &addr_data, tsc2003_i2c_detect); } -static int tsc2003_i2c_detach_client(struct i2c_client *client) { +static int tsc2003_i2c_detach_client(struct i2c_client *client) +{ int err; struct tsc2003_data *d = i2c_get_clientdata(client); - free_irq(d->penirq, d); input_unregister_device(d->idev); if ((err = i2c_detach_client(client))) { @@ -385,16 +334,18 @@ static int tsc2003_i2c_detach_client(struct i2c_client *client) { return 0; } -static struct i2c_driver tsc2003_driver = { - .driver = { - .owner = THIS_MODULE, - .name = DRIVER_NAME, - }, - .attach_adapter = tsc2003_i2c_attach_adapter, - .detach_client = tsc2003_i2c_detach_client, +static struct i2c_driver tsc2003_driver = { + .driver = { + .owner = THIS_MODULE, + .name = DRIVER_NAME, + }, + .attach_adapter = tsc2003_i2c_attach_adapter, + .detach_client = tsc2003_i2c_detach_client, }; -static int tsc2003_i2c_detect(struct i2c_adapter *adapter, int address, int kind) { +static int tsc2003_i2c_detect(struct i2c_adapter *adapter, int address, + int kind) +{ struct i2c_client *new_client; struct tsc2003_data *data; @@ -402,7 +353,8 @@ static int tsc2003_i2c_detect(struct i2c_adapter *adapter, int address, int kind const char *name = ""; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA - | I2C_FUNC_I2C | I2C_FUNC_SMBUS_WORD_DATA)) + | I2C_FUNC_I2C | + I2C_FUNC_SMBUS_WORD_DATA)) goto exit; data = kcalloc(1, sizeof(*data), GFP_KERNEL); @@ -419,16 +371,16 @@ static int tsc2003_i2c_detect(struct i2c_adapter *adapter, int address, int kind new_client->flags = 0; /* TODO: I'm pretty sure I'm not dealing with kind correctly */ - if (kind == 0 /* identification */|| kind < 0 /* detection */) + if (kind == 0 /* identification */ || kind < 0 /* detection */ ) kind = tsc2003; if (kind == tsc2003) name = DRIVER_NAME; /* try a command, see if we get an ack; - if we do, assume it's our device */ + if we do, assume it's our device */ printk(KERN_INFO "%s: probing address 0x%x\n", - __FUNCTION__, address); + __FUNCTION__, address); err = tsc2003_powerdown(data); if (err >= 0) { strlcpy(new_client->name, name, I2C_NAME_SIZE); @@ -443,15 +395,15 @@ static int tsc2003_i2c_detect(struct i2c_adapter *adapter, int address, int kind goto exit_free; printk(KERN_INFO "%s: device address 0x%x attached.\n", - __FUNCTION__, address); + __FUNCTION__, address); return 0; } /* failure to detect when everything else is ok isn't an error */ else err = 0; - exit_free: kfree(new_client); - exit: return err; + exit_free:kfree(new_client); + exit:return err; } static int __init tsc2003_init(void) diff --git a/packages/linux/gumstix-kernel_2.6.21.bb b/packages/linux/gumstix-kernel_2.6.21.bb index d1664e8763..e71c972053 100644 --- a/packages/linux/gumstix-kernel_2.6.21.bb +++ b/packages/linux/gumstix-kernel_2.6.21.bb @@ -1,4 +1,4 @@ -require linux.inc +require gumstix-linux.inc SRC_URI = "${KERNELORG_MIRROR}/pub/linux/kernel/v2.6/linux-${PV}.tar.bz2 \ file://defconfig \ diff --git a/packages/linux/gumstix-linux.inc b/packages/linux/gumstix-linux.inc index 76fd15d95a..50111cb545 100644 --- a/packages/linux/gumstix-linux.inc +++ b/packages/linux/gumstix-linux.inc @@ -9,7 +9,10 @@ DEPENDS += " \ u-boot-mkimage-openmoko-native \ " +KERNEL_IMAGE_BASE_NAME = ${KERNEL_IMAGETYPE}-${PV}-${PR}-${MACHINE} + S = "${WORKDIR}/linux-${PV}" +do_deploy[dirs] = "${S}" do_configure_prepend() { echo "" > ${S}/.config @@ -32,6 +35,16 @@ do_configure_prepend() { yes '' | oe_runmake oldconfig } +do_sizecheck() { + if [ ! -z "${KERNEL_IMAGE_MAXSIZE}" ]; then + size=`ls -l arch/${ARCH}/boot/${KERNEL_IMAGETYPE} | awk '{ print $5}'` + if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then + rm arch/${ARCH}/boot/${KERNEL_IMAGETYPE} + die "This kernel (size=$size) is too big for your device. Please reduce the size of the kernel by making more of it modular." + fi + fi +} + do_install_prepend() { if test -e arch/${ARCH}/boot/Image ; then ln -f arch/${ARCH}/boot/Image arch/${ARCH}/boot/uImage @@ -41,3 +54,21 @@ do_install_prepend() { ln -f arch/${ARCH}/boot/images/uImage arch/${ARCH}/boot/uImage fi } + +do_deploy() { + install -d ${DEPLOY_DIR_IMAGE} + install -m 0644 arch/${ARCH}/boot/${KERNEL_IMAGETYPE} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.bin + tar -cvzf ${DEPLOY_DIR_IMAGE}/modules-${KERNEL_RELEASE}-${PR}-${MACHINE}.tgz -C ${D} lib + + if test "x${KERNEL_IMAGETYPE}" = "xuImage" ; then + ${OBJCOPY} -O binary -R .note -R .comment -S arch/${ARCH}/boot/compressed/vmlinux linux.bin + uboot-mkimage -A ${ARCH} -O linux -T kernel -C none -a ${UBOOT_ENTRYPOINT} -e ${UBOOT_ENTRYPOINT} -n "${DISTRO_NAME}/${PV}/${MACHINE}" -d linux.bin ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.bin + rm -f linux.bin + + fi +} + +addtask sizecheck before do_install after do_compile +addtask deploy before do_package after do_install + + |