From: Pavel Cheblakov <[email protected]>

This patch makes the plx_pci driver in the BerliOS repo same as in 
net-next-2.6

Changes since previous revision (1120):
- Added some defines for static inline int plx_pci_check_sja1000(...)
- static struct pci_device_id plx_pci_tbl[] replaced by
   static DEFINE_PCI_DEVICE_TABLE(plx_pci_tbl)
- Typo fixed
- Changed order of device info to have the PCI devices in alphabetical
   order

Signed-off-by: Pavel Cheblakov <[email protected]>
---
Index: kernel/2.6/drivers/net/can/sja1000/plx_pci.c
===================================================================
--- kernel/2.6/drivers/net/can/sja1000/plx_pci.c        
(.../vendor/socketcan/1120)     (revision 219)
+++ kernel/2.6/drivers/net/can/sja1000/plx_pci.c        (.../socketcan/trunk)   
(revision 219)
@@ -6,7 +6,6 @@
   *    Copyright (C) 2008 Markus Plessing <[email protected]>
   *    Copyright (C) 2008 Sebastian Haas <[email protected]>
   *
- *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the version 2 of the GNU General Public License
   * as published by the Free Software Foundation
@@ -40,11 +39,11 @@
  #define DRV_NAME  "sja1000_plx_pci"

  MODULE_AUTHOR("Pavel Cheblakov <[email protected]>");
-MODULE_DESCRIPTION("Socket-CAN driver for the PLX90xx PCI-bridge cards with "
-                  "SJA1000 chips");
-MODULE_SUPPORTED_DEVICE("Marathon CAN-bus-PCI, "
-                       "Adlink PCI-7841/cPCI-7841, "
+MODULE_DESCRIPTION("Socket-CAN driver for PLX90xx PCI-bridge cards with "
+                  "the SJA1000 chips");
+MODULE_SUPPORTED_DEVICE("Adlink PCI-7841/cPCI-7841, "
                        "Adlink PCI-7841/cPCI-7841 SE, "
+                       "Marathon CAN-bus-PCI, "
                        "TEWS TECHNOLOGIES TPMC810");
  MODULE_LICENSE("GPL v2");

@@ -58,10 +57,8 @@

  #define PLX_PCI_CAN_CLOCK (16000000 / 2)

-/*
- * the PLX90xx registers
- */
-#define PLX_INTCSR     0x4c            /* Interrup Control/Status */
+/* PLX90xx registers */
+#define PLX_INTCSR     0x4c            /* Interrupt Control/Status */
  #define PLX_CNTRL     0x50            /* User I/O, Direct Slave Response,
                                         * Serial EEPROM, and Initialization
                                         * Control register
@@ -90,6 +87,20 @@
   */
  #define PLX_PCI_CDR                   (CDR_CBP | CDR_CLKOUT_MASK)

+/* SJA1000 Control Register in the BasicCAN Mode */
+#define REG_CR                         0x00
+
+/* States of some SJA1000 registers after hardware reset in the BasicCAN mode*/
+#define REG_CR_BASICCAN_INITIAL                0x21
+#define REG_CR_BASICCAN_INITIAL_MASK   0xa1
+#define REG_SR_BASICCAN_INITIAL                0x0c
+#define REG_IR_BASICCAN_INITIAL                0xe0
+
+/* States of some SJA1000 registers after hardware reset in the PeliCAN mode*/
+#define REG_MOD_PELICAN_INITIAL                0x01
+#define REG_SR_PELICAN_INITIAL         0x3c
+#define REG_IR_PELICAN_INITIAL         0x00
+
  #define ADLINK_PCI_VENDOR_ID          0x144A
  #define ADLINK_PCI_DEVICE_ID          0x7841

@@ -124,14 +135,6 @@
        void (*reset_func)(struct pci_dev *pdev);
  };

-static struct plx_pci_card_info plx_pci_card_info_marathon __devinitdata = {
-       "Marathon CAN-bus-PCI", 2,
-       PLX_PCI_CAN_CLOCK, PLX_PCI_OCR, PLX_PCI_CDR,
-       {0, 0x00, 0x00}, { {2, 0x00, 0x00}, {4, 0x00, 0x00} },
-       &plx_pci_reset_marathon
-       /* based on PLX9052 */
-};
-
  static struct plx_pci_card_info plx_pci_card_info_adlink __devinitdata = {
        "Adlink PCI-7841/cPCI-7841", 2,
        PLX_PCI_CAN_CLOCK, PLX_PCI_OCR, PLX_PCI_CDR,
@@ -148,6 +151,14 @@
        /* based on PLX9052 */
  };

+static struct plx_pci_card_info plx_pci_card_info_marathon __devinitdata = {
+       "Marathon CAN-bus-PCI", 2,
+       PLX_PCI_CAN_CLOCK, PLX_PCI_OCR, PLX_PCI_CDR,
+       {0, 0x00, 0x00}, { {2, 0x00, 0x00}, {4, 0x00, 0x00} },
+       &plx_pci_reset_marathon
+       /* based on PLX9052 */
+};
+
  static struct plx_pci_card_info plx_pci_card_info_tews __devinitdata = {
        "TEWS TECHNOLOGIES TPMC810", 2,
        PLX_PCI_CAN_CLOCK, PLX_PCI_OCR, PLX_PCI_CDR,
@@ -158,13 +169,6 @@

  static struct pci_device_id plx_pci_tbl[] = {
        {
-               /* Marathon CAN-bus-PCI card */
-               PCI_VENDOR_ID_PLX, MARATHON_PCI_DEVICE_ID,
-               PCI_ANY_ID, PCI_ANY_ID,
-               0, 0,
-               (kernel_ulong_t)&plx_pci_card_info_marathon
-       },
-       {
                /* Adlink PCI-7841/cPCI-7841 */
                ADLINK_PCI_VENDOR_ID, ADLINK_PCI_DEVICE_ID,
                PCI_ANY_ID, PCI_ANY_ID,
@@ -179,6 +183,13 @@
                (kernel_ulong_t)&plx_pci_card_info_adlink_se
        },
        {
+               /* Marathon CAN-bus-PCI card */
+               PCI_VENDOR_ID_PLX, MARATHON_PCI_DEVICE_ID,
+               PCI_ANY_ID, PCI_ANY_ID,
+               0, 0,
+               (kernel_ulong_t)&plx_pci_card_info_marathon
+       },
+       {
                /* TEWS TECHNOLOGIES TPMC810 card */
                TEWS_PCI_VENDOR_ID, TEWS_PCI_DEVICE_ID_TMPC810,
                PCI_ANY_ID, PCI_ANY_ID,
@@ -212,9 +223,10 @@
         * Check registers after hardware reset (the Basic mode)
         * See states on p. 10 of the Datasheet.
         */
-       if ((priv->read_reg(priv, REG_MOD) & 0xa1) == 0x21 &&
-           (priv->read_reg(priv, REG_SR) == 0x0c) &&
-           (priv->read_reg(priv, REG_IR) == 0xe0))
+       if ((priv->read_reg(priv, REG_CR) & REG_CR_BASICCAN_INITIAL_MASK) ==
+           REG_CR_BASICCAN_INITIAL &&
+           (priv->read_reg(priv, REG_SR) == REG_SR_BASICCAN_INITIAL) &&
+           (priv->read_reg(priv, REG_IR) == REG_IR_BASICCAN_INITIAL))
                flag = 1;

        /* Bring the SJA1000 into the PeliCAN mode*/
@@ -224,16 +236,16 @@
         * Check registers after reset in the PeliCAN mode.
         * See states on p. 23 of the Datasheet.
         */
-       if ((priv->read_reg(priv, REG_MOD) & 0xf1) == 0x01 &&
-           (priv->read_reg(priv, REG_SR) & 0x37) == 0x34 &&
-           (priv->read_reg(priv, REG_IR) & 0xfb) == 0x00)
+       if (priv->read_reg(priv, REG_MOD) == REG_MOD_PELICAN_INITIAL &&
+           priv->read_reg(priv, REG_SR) == REG_SR_PELICAN_INITIAL &&
+           priv->read_reg(priv, REG_IR) == REG_IR_PELICAN_INITIAL)
                return flag;

        return 0;
  }

  /*
- * The PLX90xx software reset
+ * PLX90xx software reset
   * Also LRESET# asserts and brings to reset device on the Local Bus (if 
wired).
   * For most cards it's enough for reset the SJA1000 chips.
   */
@@ -311,7 +323,7 @@
  }

  /*
- * Probe the PLX90xx based device for the SJA1000 chips and register each
+ * Probe PLX90xx based device for the SJA1000 chips and register each
   * available CAN channel to SJA1000 Socket-CAN subsystem.
   */
  static int __devinit plx_pci_add_card(struct pci_dev *pdev,
@@ -347,7 +359,7 @@

        card->channels = 0;

-       /* Remap the PLX90xx configuration space */
+       /* Remap PLX90xx configuration space */
        addr = pci_iomap(pdev, ci->conf_map.bar, ci->conf_map.size);
        if (!addr) {
                err = -ENOMEM;
@@ -466,4 +478,3 @@

  module_init(plx_pci_init);
  module_exit(plx_pci_exit);
-
Index: kernel/2.6/drivers/net/can/sja1000/Kconfig
===================================================================
--- kernel/2.6/drivers/net/can/sja1000/Kconfig  (.../vendor/socketcan/1120)     
(revision 219)
+++ kernel/2.6/drivers/net/can/sja1000/Kconfig  (.../socketcan/trunk)   
(revision 219)
@@ -83,14 +83,14 @@

  config CAN_PLX_PCI
        tristate "PLX90xx PCI-bridge based Cards"
-       depends on PCI && CAN_SJA1000
+       depends on PCI
        ---help---
          This driver is for CAN interface cards based on
          the PLX90xx PCI bridge.
          Driver supports now:
-          - Marathon CAN-bus-PCI card (http://www.marathon.ru/)
           - Adlink PCI-7841/cPCI-7841 card (http://www.adlinktech.com/)
           - Adlink PCI-7841/cPCI-7841 SE card
+          - Marathon CAN-bus-PCI card (http://www.marathon.ru/)
           - TEWS TECHNOLOGIES TPMC810 card (http://www.tews.com/)

  config CAN_PIPCAN
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core

Reply via email to