summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/cx18/cx18-gpio.c
diff options
context:
space:
mode:
authorAndy Walls <awalls@radix.net>2008-07-13 15:30:15 -0400
committerAndy Walls <awalls@radix.net>2008-07-13 15:30:15 -0400
commit686cc1c1d15e11ccb0bd3687091cd989974d9e91 (patch)
tree09dd11a2687dec57bedb87e0db4c8e307449f8b6 /linux/drivers/media/video/cx18/cx18-gpio.c
parentbd7892e6fc1c78809e6b71abec98ebc62d1e6aa5 (diff)
downloadmediapointer-dvb-s2-686cc1c1d15e11ccb0bd3687091cd989974d9e91.tar.gz
mediapointer-dvb-s2-686cc1c1d15e11ccb0bd3687091cd989974d9e91.tar.bz2
cx18: Suport external reset of the Z8F0811 IR controller on HVR-1600 for lirc
From: Andy Walls <awalls@radix.net> cx18: added in cx18_ir_reset_gpio function for lirc_pvr150 like module. Also added the ability to reset the IR chip via ioctl like ivtv. This needs the mutex to protect gpio_dir and gpio_val in struct cx18 as gpio changes can come from a few different asynchronous sources now. Signed-off-by: Andy Walls <awalls@radix.net>
Diffstat (limited to 'linux/drivers/media/video/cx18/cx18-gpio.c')
-rw-r--r--linux/drivers/media/video/cx18/cx18-gpio.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/linux/drivers/media/video/cx18/cx18-gpio.c b/linux/drivers/media/video/cx18/cx18-gpio.c
index d753a4097..3d495dba4 100644
--- a/linux/drivers/media/video/cx18/cx18-gpio.c
+++ b/linux/drivers/media/video/cx18/cx18-gpio.c
@@ -83,6 +83,47 @@ void cx18_reset_i2c_slaves_gpio(struct cx18 *cx)
mutex_unlock(&cx->gpio_lock);
}
+void cx18_reset_ir_gpio(void *data)
+{
+ struct cx18 *cx = ((struct cx18_i2c_algo_callback_data *)data)->cx;
+ const struct cx18_gpio_i2c_slave_reset *p;
+
+ p = &cx->card->gpio_i2c_slave_reset;
+
+ if (p->ir_reset_mask == 0)
+ return;
+
+ CX18_DEBUG_INFO("Resetting IR microcontroller\n");
+
+ /*
+ Assert timing for the Z8F0811 on HVR-1600 boards:
+ 1. Assert RESET for min of 4 clock cycles at 18.432 MHz to initiate
+ 2. Reset then takes 66 WDT cycles at 10 kHz + 16 xtal clock cycles
+ (6,601,085 nanoseconds ~= 7 milliseconds)
+ 3. DBG pin must be high before chip exits reset for normal operation.
+ DBG is open drain and hopefully pulled high since we don't
+ normally drive it (GPIO 1?) for the HVR-1600
+ 4. Z8F0811 won't exit reset until RESET is deasserted
+ */
+ mutex_lock(&cx->gpio_lock);
+ cx->gpio_val = cx->gpio_val & ~p->ir_reset_mask;
+ gpio_write(cx);
+ mutex_unlock(&cx->gpio_lock);
+ schedule_timeout_uninterruptible(msecs_to_jiffies(p->msecs_asserted));
+
+ /*
+ Zilog comes out of reset, loads reset vector address and executes
+ from there. Required recovery delay unknown.
+ */
+ mutex_lock(&cx->gpio_lock);
+ cx->gpio_val = cx->gpio_val | p->ir_reset_mask;
+ gpio_write(cx);
+ mutex_unlock(&cx->gpio_lock);
+ schedule_timeout_uninterruptible(msecs_to_jiffies(p->msecs_recovery));
+}
+EXPORT_SYMBOL(cx18_reset_ir_gpio);
+/* This symbol is exported for use by an infrared module for the IR-blaster */
+
void cx18_gpio_init(struct cx18 *cx)
{
mutex_lock(&cx->gpio_lock);