+/* ----------------------------------------------------------------------- */
+/*
+ * The Adlink RTV-24 (aka Angelo) has some special initialisation to unlock
+ * it. This apparently involves the following procedure for each 878 chip:
+ *
+ * 1) write 0x00C3FEFF to the GPIO_OUT_EN register
+ *
+ * 2) write to GPIO_DATA
+ * - 0x0E
+ * - sleep 1ms
+ * - 0x10 + 0x0E
+ * - sleep 10ms
+ * - 0x0E
+ * read from GPIO_DATA into buf (uint_32)
+ * - if ( data>>18 & 0x01 != 0) || ( buf>>19 & 0x01 != 1 )
+ * error. ERROR_CPLD_Check_Failed stop.
+ *
+ * 3) write to GPIO_DATA
+ * - write 0x4400 + 0x0E
+ * - sleep 10ms
+ * - write 0x4410 + 0x0E
+ * - sleep 1ms
+ * - write 0x0E
+ * read from GPIO_DATA into buf (uint_32)
+ * - if ( buf>>18 & 0x01 ) || ( buf>>19 && 0x01 != 0 )
+ * error. ERROR_CPLD_Check_Failed.
+ */
+/* ----------------------------------------------------------------------- */
+void init_RTV24(struct bttv *btv)
+{
+ u32 dataread;
+ const long watchdog_value = 0x0E;
+
+ printk(KERN_INFO "bttv%d: Adlink RTV-24 initialisation in progress\n",
+ btv->c.nr);
+
+ btwrite(0x00c3feff, BT848_GPIO_OUT_EN);
+
+ btwrite(0 + watchdog_value, BT848_GPIO_DATA);
+ msleep(1);
+ btwrite(0x10 + watchdog_value, BT848_GPIO_DATA);
+ msleep( 10 );
+ btwrite(0 + watchdog_value, BT848_GPIO_DATA);
+
+ dataread = btread(BT848_GPIO_DATA);
+
+ if (((dataread >> 18) & 0x01) != 0 || ((dataread >> 19) & 0x01) != 1) {
+ printk(KERN_INFO "bttv%d: Adlink RTV-24 initialisation(1) "
+ "ERROR_CPLD_Check_Failed (read %d)\n",
+ btv->c.nr, dataread);
+ }
+
+ btwrite(0x4400 + watchdog_value, BT848_GPIO_DATA);
+ msleep(10);
+ btwrite(0x4410 + watchdog_value, BT848_GPIO_DATA);
+ msleep(1);
+ btwrite(watchdog_value, BT848_GPIO_DATA);
+ msleep(1);
+ dataread = btread(BT848_GPIO_DATA);
+
+ if (((dataread >> 18) & 0x01) != 0 || ((dataread >> 19) & 0x01) != 0) {
+ printk(KERN_INFO "bttv%d: Adlink RTV-24 initialisation(2) "
+ "ERROR_CPLD_Check_Failed (read %d)\n",
+ btv->c.nr, dataread);
+ return;
+ }
+
+ printk(KERN_INFO "bttv%d: Adlink RTV-24 initialisation complete.\n",
+ btv->c.nr);
+}