pcmcia: Implement CLKRUN protocol disabling for Ricoh bridges
[sfrench/cifs-2.6.git] / drivers / pcmcia / ricoh.h
index 01098c841f877c81ab1c539a2b19f309bc3749e8..8ac7b138c094865f3f94cc41ba8824f430b76a22 100644 (file)
 #define  RL5C4XX_MISC_CONTROL           0x2F /* 8 bit */
 #define  RL5C4XX_ZV_ENABLE              0x08
 
+/* Misc Control 3 Register */
+#define RL5C4XX_MISC3                  0x00A2 /* 16 bit */
+#define  RL5C47X_MISC3_CB_CLKRUN_DIS   BIT(1)
+
 #ifdef __YENTA_H
 
 #define rl_misc(socket)                ((socket)->private[0])
@@ -156,6 +160,35 @@ static void ricoh_set_zv(struct yenta_socket *socket)
         }
 }
 
+static void ricoh_set_clkrun(struct yenta_socket *socket, bool quiet)
+{
+       u16 misc3;
+
+       /*
+        * RL5C475II likely has this setting, too, however no datasheet
+        * is publicly available for this chip
+        */
+       if (socket->dev->device != PCI_DEVICE_ID_RICOH_RL5C476 &&
+           socket->dev->device != PCI_DEVICE_ID_RICOH_RL5C478)
+               return;
+
+       if (socket->dev->revision < 0x80)
+               return;
+
+       misc3 = config_readw(socket, RL5C4XX_MISC3);
+       if (misc3 & RL5C47X_MISC3_CB_CLKRUN_DIS) {
+               if (!quiet)
+                       dev_dbg(&socket->dev->dev,
+                               "CLKRUN feature already disabled\n");
+       } else if (disable_clkrun) {
+               if (!quiet)
+                       dev_info(&socket->dev->dev,
+                                "Disabling CLKRUN feature\n");
+               misc3 |= RL5C47X_MISC3_CB_CLKRUN_DIS;
+               config_writew(socket, RL5C4XX_MISC3, misc3);
+       }
+}
+
 static void ricoh_save_state(struct yenta_socket *socket)
 {
        rl_misc(socket) = config_readw(socket, RL5C4XX_MISC);
@@ -172,6 +205,7 @@ static void ricoh_restore_state(struct yenta_socket *socket)
        config_writew(socket, RL5C4XX_16BIT_IO_0, rl_io(socket));
        config_writew(socket, RL5C4XX_16BIT_MEM_0, rl_mem(socket));
        config_writew(socket, RL5C4XX_CONFIG, rl_config(socket));
+       ricoh_set_clkrun(socket, true);
 }
 
 
@@ -197,6 +231,7 @@ static int ricoh_override(struct yenta_socket *socket)
        config_writew(socket, RL5C4XX_CONFIG, config);
 
        ricoh_set_zv(socket);
+       ricoh_set_clkrun(socket, false);
 
        return 0;
 }