]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ibm_newemac: Introduce mal_has_feature
authorJosh Boyer <jwboyer@linux.vnet.ibm.com>
Thu, 4 Sep 2008 04:03:45 +0000 (04:03 +0000)
committerJosh Boyer <jwboyer@linux.vnet.ibm.com>
Tue, 30 Sep 2008 13:23:04 +0000 (09:23 -0400)
There are some PowerPC SoCs that do odd things with the MAL handling.  In
order to accommodate them, we need to introduce a feature mechanism that is
similar to the existing emac_has_feature function.

This adds a feature variable to the mal_instance structure, and adds a
mal_has_feature function.  Two features are defined and are guarded
by Kconfig options that are selected by the affected platforms.

MAL_FTR_CLEAR_ICINSTAT is used for platforms that need to clear the
interrupt bits in the ICINTSTAT SDR for txeob/rxeob.  This is common
on MAL implementations that have interrupt coalescing.

MAL_FTR_COMMON_ERR_INT is used for platforms that have SERR, TXDE,
and RXDE OR'd into a single interrupt bit.

Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>
drivers/net/ibm_newemac/Kconfig
drivers/net/ibm_newemac/mal.h

index dfb6547c37cb69a1300819fbba7633c9b8ef064c..44e5a0e9922ad0032bf33476b5b3a84a1e3379b6 100644 (file)
@@ -66,3 +66,11 @@ config IBM_NEW_EMAC_EMAC4
 config IBM_NEW_EMAC_NO_FLOW_CTRL
        bool
        default n
+
+config IBM_NEW_EMAC_MAL_CLR_ICINTSTAT
+       bool
+       default n
+
+config IBM_NEW_EMAC_MAL_COMMON_ERR
+       bool
+       default n
index eaa7262dc079373fa7693d6b75630723d0249343..0b2413839b78e15001a521dfddc8dd3241dde844 100644 (file)
@@ -213,6 +213,8 @@ struct mal_instance {
        struct of_device        *ofdev;
        int                     index;
        spinlock_t              lock;
+
+       unsigned int features;
 };
 
 static inline u32 get_mal_dcrn(struct mal_instance *mal, int reg)
@@ -225,6 +227,38 @@ static inline void set_mal_dcrn(struct mal_instance *mal, int reg, u32 val)
        dcr_write(mal->dcr_host, reg, val);
 }
 
+/* Features of various MAL implementations */
+
+/* Set if you have interrupt coalescing and you have to clear the SDR
+ * register for TXEOB and RXEOB interrupts to work
+ */
+#define MAL_FTR_CLEAR_ICINTSTAT        0x00000001
+
+/* Set if your MAL has SERR, TXDE, and RXDE OR'd into a single UIC
+ * interrupt
+ */
+#define MAL_FTR_COMMON_ERR_INT 0x00000002
+
+enum {
+       MAL_FTRS_ALWAYS = 0,
+
+       MAL_FTRS_POSSIBLE =
+#ifdef CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT
+               MAL_FTR_CLEAR_ICINTSTAT |
+#endif
+#ifdef CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR
+               MAL_FTR_COMMON_ERR_INT |
+#endif
+               0,
+};
+
+static inline int mal_has_feature(struct mal_instance *dev,
+               unsigned long feature)
+{
+       return (MAL_FTRS_ALWAYS & feature) ||
+               (MAL_FTRS_POSSIBLE & dev->features & feature);
+}
+
 /* Register MAL devices */
 int mal_init(void);
 void mal_exit(void);