* [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3
@ 2023-01-19 15:45 Gerhard Uttenthaler
2023-01-19 15:45 ` [PATCH 1/8] can: ems_pci: Fixed code style, copyright and email address Gerhard Uttenthaler
` (9 more replies)
0 siblings, 10 replies; 15+ messages in thread
From: Gerhard Uttenthaler @ 2023-01-19 15:45 UTC (permalink / raw)
To: mkl, linux-can; +Cc: wg, Gerhard Uttenthaler
The CPC-PCIe v3 uses a Asix AX99100 instead of the discontinued
PLX PCI9030 bridge chip. This patch series adds support for this
card version and cleaned some code styling issues.
Gerhard Uttenthaler (8):
Fixed code style, copyright and email address
Added Asix AX99100 definitions
Initialize BAR registers
Added read/write register and post irq functions
Initialize CAN controller base addresses
Added IRQ enable
Deassert hardware reset
Added MODULE_AUTHOR
drivers/net/can/sja1000/ems_pci.c | 152 ++++++++++++++++++++++--------
1 file changed, 113 insertions(+), 39 deletions(-)
--
2.35.3
--
EMS Dr. Thomas Wuensche e.K.
Sonnenhang 3
85304 Ilmmuenster
HR Ingolstadt, HRA 170106
Phone: +49-8441-490260
Fax : +49-8441-81860
http://www.ems-wuensche.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/8] can: ems_pci: Fixed code style, copyright and email address
2023-01-19 15:45 [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3 Gerhard Uttenthaler
@ 2023-01-19 15:45 ` Gerhard Uttenthaler
2023-01-19 23:48 ` Vincent Mailhol
2023-01-19 15:45 ` [PATCH 2/8] can: ems_pci: Added Asix AX99100 definitions Gerhard Uttenthaler
` (8 subsequent siblings)
9 siblings, 1 reply; 15+ messages in thread
From: Gerhard Uttenthaler @ 2023-01-19 15:45 UTC (permalink / raw)
To: mkl, linux-can; +Cc: wg, Gerhard Uttenthaler
Fix code style complained by checkpatch.pl, added Copyright and
fixed email address
Signed-off-by: Gerhard Uttenthaler <uttenthaler@ems-wuensche.com>
---
drivers/net/can/sja1000/ems_pci.c | 43 +++++++++++++------------------
1 file changed, 18 insertions(+), 25 deletions(-)
diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
index 4ab91759a5c6..8071ff4708dc 100644
--- a/drivers/net/can/sja1000/ems_pci.c
+++ b/drivers/net/can/sja1000/ems_pci.c
@@ -3,6 +3,7 @@
* Copyright (C) 2007 Wolfgang Grandegger <wg@grandegger.com>
* Copyright (C) 2008 Markus Plessing <plessing@ems-wuensche.com>
* Copyright (C) 2008 Sebastian Haas <haas@ems-wuensche.com>
+ * Copyright (C) 2023 EMS Dr. Thomas Wuensche
*/
#include <linux/kernel.h>
@@ -19,7 +20,7 @@
#define DRV_NAME "ems_pci"
-MODULE_AUTHOR("Sebastian Haas <haas@ems-wuenche.com>");
+MODULE_AUTHOR("Sebastian Haas <support@ems-wuenche.com>");
MODULE_DESCRIPTION("Socket-CAN driver for EMS CPC-PCI/PCIe/104P CAN cards");
MODULE_LICENSE("GPL v2");
@@ -40,8 +41,7 @@ struct ems_pci_card {
#define EMS_PCI_CAN_CLOCK (16000000 / 2)
-/*
- * Register definitions and descriptions are from LinCAN 0.3.3.
+/* Register definitions and descriptions are from LinCAN 0.3.3.
*
* PSB4610 PITA-2 bridge control registers
*/
@@ -52,8 +52,7 @@ struct ems_pci_card {
#define PITA2_MISC 0x1c /* Miscellaneous Register */
#define PITA2_MISC_CONFIG 0x04000000 /* Multiplexed parallel interface */
-/*
- * Register definitions for the PLX 9030
+/* Register definitions for the PLX 9030
*/
#define PLX_ICSR 0x4c /* Interrupt Control/Status register */
#define PLX_ICSR_LINTI1_ENA 0x0001 /* LINTi1 Enable */
@@ -62,8 +61,7 @@ struct ems_pci_card {
#define PLX_ICSR_ENA_CLR (PLX_ICSR_LINTI1_ENA | PLX_ICSR_PCIINT_ENA | \
PLX_ICSR_LINTI1_CLR)
-/*
- * The board configuration is probably following:
+/* The board configuration is probably following:
* RX1 is connected to ground.
* TX1 is not connected.
* CLKO is not connected.
@@ -72,8 +70,7 @@ struct ems_pci_card {
*/
#define EMS_PCI_OCR (OCR_TX0_PUSHPULL | OCR_TX1_PUSHPULL)
-/*
- * In the CDR register, you should set CBP to 1.
+/* In the CDR register, you should set CBP to 1.
* You will probably also want to set the clock divider value to 7
* (meaning direct oscillator output) because the second SJA1000 chip
* is driven by the first one CLKOUT output.
@@ -100,8 +97,7 @@ static const struct pci_device_id ems_pci_tbl[] = {
};
MODULE_DEVICE_TABLE(pci, ems_pci_tbl);
-/*
- * Helper to read internal registers from card logic (not CAN)
+/* Helper to read internal registers from card logic (not CAN)
*/
static u8 ems_pci_v1_readb(struct ems_pci_card *card, unsigned int port)
{
@@ -146,8 +142,7 @@ static void ems_pci_v2_post_irq(const struct sja1000_priv *priv)
writel(PLX_ICSR_ENA_CLR, card->conf_addr + PLX_ICSR);
}
-/*
- * Check if a CAN controller is present at the specified location
+/* Check if a CAN controller is present at the specified location
* by trying to set 'em into the PeliCAN mode
*/
static inline int ems_pci_check_chan(const struct sja1000_priv *priv)
@@ -185,10 +180,10 @@ static void ems_pci_del_card(struct pci_dev *pdev)
free_sja1000dev(dev);
}
- if (card->base_addr != NULL)
+ if (card->base_addr)
pci_iounmap(card->pci_dev, card->base_addr);
- if (card->conf_addr != NULL)
+ if (card->conf_addr)
pci_iounmap(card->pci_dev, card->conf_addr);
kfree(card);
@@ -202,8 +197,7 @@ static void ems_pci_card_reset(struct ems_pci_card *card)
writeb(0, card->base_addr);
}
-/*
- * Probe PCI device for EMS CAN signature and register each available
+/* Probe PCI device for EMS CAN signature and register each available
* CAN channel to SJA1000 Socket-CAN subsystem.
*/
static int ems_pci_add_card(struct pci_dev *pdev,
@@ -222,8 +216,8 @@ static int ems_pci_add_card(struct pci_dev *pdev,
}
/* Allocating card structures to hold addresses, ... */
- card = kzalloc(sizeof(struct ems_pci_card), GFP_KERNEL);
- if (card == NULL) {
+ card = kzalloc(sizeof(*card), GFP_KERNEL);
+ if (!card) {
pci_disable_device(pdev);
return -ENOMEM;
}
@@ -248,13 +242,13 @@ static int ems_pci_add_card(struct pci_dev *pdev,
/* Remap configuration space and controller memory area */
card->conf_addr = pci_iomap(pdev, 0, conf_size);
- if (card->conf_addr == NULL) {
+ if (!card->conf_addr) {
err = -ENOMEM;
goto failure_cleanup;
}
card->base_addr = pci_iomap(pdev, base_bar, EMS_PCI_BASE_SIZE);
- if (card->base_addr == NULL) {
+ if (!card->base_addr) {
err = -ENOMEM;
goto failure_cleanup;
}
@@ -281,7 +275,7 @@ static int ems_pci_add_card(struct pci_dev *pdev,
/* Detect available channels */
for (i = 0; i < max_chan; i++) {
dev = alloc_sja1000dev(0);
- if (dev == NULL) {
+ if (!dev) {
err = -ENOMEM;
goto failure_cleanup;
}
@@ -325,8 +319,7 @@ static int ems_pci_add_card(struct pci_dev *pdev,
/* Register SJA1000 device */
err = register_sja1000dev(dev);
if (err) {
- dev_err(&pdev->dev, "Registering device failed "
- "(err=%d)\n", err);
+ dev_err(&pdev->dev, "Registering device failed (err=%d)\n", err);
free_sja1000dev(dev);
goto failure_cleanup;
}
@@ -334,7 +327,7 @@ static int ems_pci_add_card(struct pci_dev *pdev,
card->channels++;
dev_info(&pdev->dev, "Channel #%d at 0x%p, irq %d\n",
- i + 1, priv->reg_base, dev->irq);
+ i + 1, priv->reg_base, dev->irq);
} else {
free_sja1000dev(dev);
}
--
2.35.3
--
EMS Dr. Thomas Wuensche e.K.
Sonnenhang 3
85304 Ilmmuenster
HR Ingolstadt, HRA 170106
Phone: +49-8441-490260
Fax : +49-8441-81860
http://www.ems-wuensche.com
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/8] can: ems_pci: Added Asix AX99100 definitions
2023-01-19 15:45 [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3 Gerhard Uttenthaler
2023-01-19 15:45 ` [PATCH 1/8] can: ems_pci: Fixed code style, copyright and email address Gerhard Uttenthaler
@ 2023-01-19 15:45 ` Gerhard Uttenthaler
2023-01-19 15:45 ` [PATCH 3/8] can: ems_pci: Initialize BAR registers Gerhard Uttenthaler
` (7 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Gerhard Uttenthaler @ 2023-01-19 15:45 UTC (permalink / raw)
To: mkl, linux-can; +Cc: wg, Gerhard Uttenthaler
Added Asix AX99100 PCI IDs and added the v3 to the ems_pci_tbl.
Add define for maximum CAN channel count
Signed-off-by: Gerhard Uttenthaler <uttenthaler@ems-wuensche.com>
---
drivers/net/can/sja1000/ems_pci.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
index 8071ff4708dc..216ebc14f243 100644
--- a/drivers/net/can/sja1000/ems_pci.c
+++ b/drivers/net/can/sja1000/ems_pci.c
@@ -26,6 +26,7 @@ MODULE_LICENSE("GPL v2");
#define EMS_PCI_V1_MAX_CHAN 2
#define EMS_PCI_V2_MAX_CHAN 4
+#define EMS_PCI_V3_MAX_CHAN 4
#define EMS_PCI_MAX_CHAN EMS_PCI_V2_MAX_CHAN
struct ems_pci_card {
@@ -61,6 +62,15 @@ struct ems_pci_card {
#define PLX_ICSR_ENA_CLR (PLX_ICSR_LINTI1_ENA | PLX_ICSR_PCIINT_ENA | \
PLX_ICSR_LINTI1_CLR)
+/* Register definitions for the ASIX99100
+ */
+#define ASIX_LINTSR 0x28 /* Interrupt Control/Status register */
+#define ASIX_LINTSR_INT0AC BIT(0) /* Writing 1 enables or clears interrupt */
+
+#define ASIX_LIEMR 0x24 /* Local Interrupt Enable / Miscellaneous Register */
+#define ASIX_LIEMR_L0EINTEN BIT(16) /* Local INT0 input assertion enable */
+#define ASIX_LIEMR_LRST BIT(14) /* Local Reset assert */
+
/* The board configuration is probably following:
* RX1 is connected to ground.
* TX1 is not connected.
@@ -86,6 +96,13 @@ struct ems_pci_card {
#define EMS_PCI_BASE_SIZE 4096 /* size of controller area */
+#ifndef PCI_VENDOR_ID_ASIX
+#define PCI_VENDOR_ID_ASIX 0x125b
+#define PCI_DEVICE_ID_ASIX_9110 0x9110
+#define PCI_SUBVENDOR_ID_ASIX 0xa000
+#endif
+#define PCI_SUBDEVICE_ID_EMS 0x4010
+
static const struct pci_device_id ems_pci_tbl[] = {
/* CPC-PCI v1 */
{PCI_VENDOR_ID_SIEMENS, 0x2104, PCI_ANY_ID, PCI_ANY_ID,},
@@ -93,6 +110,8 @@ static const struct pci_device_id ems_pci_tbl[] = {
{PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030, PCI_VENDOR_ID_PLX, 0x4000},
/* CPC-104P v2 */
{PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030, PCI_VENDOR_ID_PLX, 0x4002},
+ /* CPC-PCIe v3 */
+ {PCI_VENDOR_ID_ASIX, PCI_DEVICE_ID_ASIX_9110, PCI_SUBVENDOR_ID_ASIX, PCI_SUBDEVICE_ID_EMS},
{0,}
};
MODULE_DEVICE_TABLE(pci, ems_pci_tbl);
--
2.35.3
--
EMS Dr. Thomas Wuensche e.K.
Sonnenhang 3
85304 Ilmmuenster
HR Ingolstadt, HRA 170106
Phone: +49-8441-490260
Fax : +49-8441-81860
http://www.ems-wuensche.com
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 3/8] can: ems_pci: Initialize BAR registers
2023-01-19 15:45 [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3 Gerhard Uttenthaler
2023-01-19 15:45 ` [PATCH 1/8] can: ems_pci: Fixed code style, copyright and email address Gerhard Uttenthaler
2023-01-19 15:45 ` [PATCH 2/8] can: ems_pci: Added Asix AX99100 definitions Gerhard Uttenthaler
@ 2023-01-19 15:45 ` Gerhard Uttenthaler
2023-01-19 15:45 ` [PATCH 4/8] can: ems_pci: Added read/write register and post irq functions Gerhard Uttenthaler
` (6 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Gerhard Uttenthaler @ 2023-01-19 15:45 UTC (permalink / raw)
To: mkl, linux-can; +Cc: wg, Gerhard Uttenthaler
Fix the base register defines and their usage for all three card versions
Signed-off-by: Gerhard Uttenthaler <uttenthaler@ems-wuensche.com>
---
drivers/net/can/sja1000/ems_pci.c | 37 +++++++++++++++++++++++--------
1 file changed, 28 insertions(+), 9 deletions(-)
diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
index 216ebc14f243..be61d39149c4 100644
--- a/drivers/net/can/sja1000/ems_pci.c
+++ b/drivers/net/can/sja1000/ems_pci.c
@@ -87,12 +87,23 @@ struct ems_pci_card {
*/
#define EMS_PCI_CDR (CDR_CBP | CDR_CLKOUT_MASK)
-#define EMS_PCI_V1_BASE_BAR 1
-#define EMS_PCI_V1_CONF_SIZE 4096 /* size of PITA control area */
-#define EMS_PCI_V2_BASE_BAR 2
-#define EMS_PCI_V2_CONF_SIZE 128 /* size of PLX control area */
-#define EMS_PCI_CAN_BASE_OFFSET 0x400 /* offset where the controllers starts */
-#define EMS_PCI_CAN_CTRL_SIZE 0x200 /* memory size for each controller */
+#define EMS_PCI_V1_BASE_BAR 1
+#define EMS_PCI_V1_CONF_BAR 0
+#define EMS_PCI_V1_CONF_SIZE 4096 /* size of PITA control area */
+#define EMS_PCI_V1_CAN_BASE_OFFSET 0x400 /* offset where the controllers start */
+#define EMS_PCI_V1_CAN_CTRL_SIZE 0x200 /* memory size for each controller */
+
+#define EMS_PCI_V2_BASE_BAR 2
+#define EMS_PCI_V2_CONF_BAR 0
+#define EMS_PCI_V2_CONF_SIZE 128 /* size of PLX control area */
+#define EMS_PCI_V2_CAN_BASE_OFFSET 0x400 /* offset where the controllers start */
+#define EMS_PCI_V2_CAN_CTRL_SIZE 0x200 /* memory size for each controller */
+
+#define EMS_PCI_V3_BASE_BAR 0
+#define EMS_PCI_V3_CONF_BAR 5
+#define EMS_PCI_V3_CONF_SIZE 128 /* size of ASIX control area */
+#define EMS_PCI_V3_CAN_BASE_OFFSET 0x00 /* offset where the controllers starts */
+#define EMS_PCI_V3_CAN_CTRL_SIZE 0x100 /* memory size for each controller */
#define EMS_PCI_BASE_SIZE 4096 /* size of controller area */
@@ -225,7 +236,7 @@ static int ems_pci_add_card(struct pci_dev *pdev,
struct sja1000_priv *priv;
struct net_device *dev;
struct ems_pci_card *card;
- int max_chan, conf_size, base_bar;
+ int max_chan, conf_size, base_bar, conf_bar;
int err, i;
/* Enabling PCI device */
@@ -247,20 +258,28 @@ static int ems_pci_add_card(struct pci_dev *pdev,
card->channels = 0;
- if (pdev->vendor == PCI_VENDOR_ID_PLX) {
+ if (pdev->vendor == PCI_VENDOR_ID_ASIX) {
+ card->version = 3; /* CPC-PCI v3 */
+ max_chan = EMS_PCI_V3_MAX_CHAN;
+ base_bar = EMS_PCI_V3_BASE_BAR;
+ conf_bar = EMS_PCI_V3_CONF_BAR;
+ conf_size = EMS_PCI_V3_CONF_SIZE;
+ } else if (pdev->vendor == PCI_VENDOR_ID_PLX) {
card->version = 2; /* CPC-PCI v2 */
max_chan = EMS_PCI_V2_MAX_CHAN;
base_bar = EMS_PCI_V2_BASE_BAR;
+ conf_bar = EMS_PCI_V2_CONF_BAR;
conf_size = EMS_PCI_V2_CONF_SIZE;
} else {
card->version = 1; /* CPC-PCI v1 */
max_chan = EMS_PCI_V1_MAX_CHAN;
base_bar = EMS_PCI_V1_BASE_BAR;
+ conf_bar = EMS_PCI_V1_CONF_BAR;
conf_size = EMS_PCI_V1_CONF_SIZE;
}
/* Remap configuration space and controller memory area */
- card->conf_addr = pci_iomap(pdev, 0, conf_size);
+ card->conf_addr = pci_iomap(pdev, conf_bar, conf_size);
if (!card->conf_addr) {
err = -ENOMEM;
goto failure_cleanup;
--
2.35.3
--
EMS Dr. Thomas Wuensche e.K.
Sonnenhang 3
85304 Ilmmuenster
HR Ingolstadt, HRA 170106
Phone: +49-8441-490260
Fax : +49-8441-81860
http://www.ems-wuensche.com
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 4/8] can: ems_pci: Added read/write register and post irq functions
2023-01-19 15:45 [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3 Gerhard Uttenthaler
` (2 preceding siblings ...)
2023-01-19 15:45 ` [PATCH 3/8] can: ems_pci: Initialize BAR registers Gerhard Uttenthaler
@ 2023-01-19 15:45 ` Gerhard Uttenthaler
2023-01-19 23:35 ` Vincent Mailhol
2023-01-19 15:45 ` [PATCH 5/8] can: ems_pci: Initialize CAN controller base addresses Gerhard Uttenthaler
` (5 subsequent siblings)
9 siblings, 1 reply; 15+ messages in thread
From: Gerhard Uttenthaler @ 2023-01-19 15:45 UTC (permalink / raw)
To: mkl, linux-can; +Cc: wg, Gerhard Uttenthaler
Added functions to read and write SJA1000 registers and also the
post irq routine
Signed-off-by: Gerhard Uttenthaler <uttenthaler@ems-wuensche.com>
---
drivers/net/can/sja1000/ems_pci.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
index be61d39149c4..338233a5d337 100644
--- a/drivers/net/can/sja1000/ems_pci.c
+++ b/drivers/net/can/sja1000/ems_pci.c
@@ -172,6 +172,24 @@ static void ems_pci_v2_post_irq(const struct sja1000_priv *priv)
writel(PLX_ICSR_ENA_CLR, card->conf_addr + PLX_ICSR);
}
+static u8 ems_pci_v3_read_reg(const struct sja1000_priv *priv, int port)
+{
+ return readb(priv->reg_base + port);
+}
+
+static void ems_pci_v3_write_reg(const struct sja1000_priv *priv,
+ int port, u8 val)
+{
+ writeb(val, priv->reg_base + port);
+}
+
+static void ems_pci_v3_post_irq(const struct sja1000_priv *priv)
+{
+ struct ems_pci_card *card = (struct ems_pci_card *)priv->priv;
+
+ writel(ASIX_LINTSR_INT0AC, card->conf_addr + ASIX_LINTSR);
+}
+
/* Check if a CAN controller is present at the specified location
* by trying to set 'em into the PeliCAN mode
*/
@@ -265,6 +283,7 @@ static int ems_pci_add_card(struct pci_dev *pdev,
conf_bar = EMS_PCI_V3_CONF_BAR;
conf_size = EMS_PCI_V3_CONF_SIZE;
} else if (pdev->vendor == PCI_VENDOR_ID_PLX) {
+
card->version = 2; /* CPC-PCI v2 */
max_chan = EMS_PCI_V2_MAX_CHAN;
base_bar = EMS_PCI_V2_BASE_BAR;
@@ -330,10 +349,14 @@ static int ems_pci_add_card(struct pci_dev *pdev,
priv->read_reg = ems_pci_v1_read_reg;
priv->write_reg = ems_pci_v1_write_reg;
priv->post_irq = ems_pci_v1_post_irq;
- } else {
+ } else if (card->version == 2) {
priv->read_reg = ems_pci_v2_read_reg;
priv->write_reg = ems_pci_v2_write_reg;
priv->post_irq = ems_pci_v2_post_irq;
+ } else {
+ priv->read_reg = ems_pci_v3_read_reg;
+ priv->write_reg = ems_pci_v3_write_reg;
+ priv->post_irq = ems_pci_v3_post_irq;
}
/* Check if channel is present */
--
2.35.3
--
EMS Dr. Thomas Wuensche e.K.
Sonnenhang 3
85304 Ilmmuenster
HR Ingolstadt, HRA 170106
Phone: +49-8441-490260
Fax : +49-8441-81860
http://www.ems-wuensche.com
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 5/8] can: ems_pci: Initialize CAN controller base addresses
2023-01-19 15:45 [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3 Gerhard Uttenthaler
` (3 preceding siblings ...)
2023-01-19 15:45 ` [PATCH 4/8] can: ems_pci: Added read/write register and post irq functions Gerhard Uttenthaler
@ 2023-01-19 15:45 ` Gerhard Uttenthaler
2023-01-19 15:45 ` [PATCH 6/8] can: ems_pci: Added IRQ enable Gerhard Uttenthaler
` (4 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Gerhard Uttenthaler @ 2023-01-19 15:45 UTC (permalink / raw)
To: mkl, linux-can; +Cc: wg, Gerhard Uttenthaler
Added CAN controller base registers
Signed-off-by: Gerhard Uttenthaler <uttenthaler@ems-wuensche.com>
---
drivers/net/can/sja1000/ems_pci.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
index 338233a5d337..c32f4c7e8844 100644
--- a/drivers/net/can/sja1000/ems_pci.c
+++ b/drivers/net/can/sja1000/ems_pci.c
@@ -343,20 +343,25 @@ static int ems_pci_add_card(struct pci_dev *pdev,
priv->irq_flags = IRQF_SHARED;
dev->irq = pdev->irq;
- priv->reg_base = card->base_addr + EMS_PCI_CAN_BASE_OFFSET
- + (i * EMS_PCI_CAN_CTRL_SIZE);
+
if (card->version == 1) {
priv->read_reg = ems_pci_v1_read_reg;
priv->write_reg = ems_pci_v1_write_reg;
priv->post_irq = ems_pci_v1_post_irq;
+ priv->reg_base = card->base_addr + EMS_PCI_V1_CAN_BASE_OFFSET
+ + (i * EMS_PCI_V1_CAN_CTRL_SIZE);
} else if (card->version == 2) {
priv->read_reg = ems_pci_v2_read_reg;
priv->write_reg = ems_pci_v2_write_reg;
priv->post_irq = ems_pci_v2_post_irq;
+ priv->reg_base = card->base_addr + EMS_PCI_V2_CAN_BASE_OFFSET
+ + (i * EMS_PCI_V2_CAN_CTRL_SIZE);
} else {
priv->read_reg = ems_pci_v3_read_reg;
priv->write_reg = ems_pci_v3_write_reg;
priv->post_irq = ems_pci_v3_post_irq;
+ priv->reg_base = card->base_addr + EMS_PCI_V3_CAN_BASE_OFFSET
+ + (i * EMS_PCI_V3_CAN_CTRL_SIZE);
}
/* Check if channel is present */
--
2.35.3
--
EMS Dr. Thomas Wuensche e.K.
Sonnenhang 3
85304 Ilmmuenster
HR Ingolstadt, HRA 170106
Phone: +49-8441-490260
Fax : +49-8441-81860
http://www.ems-wuensche.com
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 6/8] can: ems_pci: Added IRQ enable
2023-01-19 15:45 [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3 Gerhard Uttenthaler
` (4 preceding siblings ...)
2023-01-19 15:45 ` [PATCH 5/8] can: ems_pci: Initialize CAN controller base addresses Gerhard Uttenthaler
@ 2023-01-19 15:45 ` Gerhard Uttenthaler
2023-01-19 15:45 ` [PATCH 7/8] can: ems_pci: Deassert hardware reset Gerhard Uttenthaler
` (3 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Gerhard Uttenthaler @ 2023-01-19 15:45 UTC (permalink / raw)
To: mkl, linux-can; +Cc: wg, Gerhard Uttenthaler
Added IRQ enable
Signed-off-by: Gerhard Uttenthaler <uttenthaler@ems-wuensche.com>
---
drivers/net/can/sja1000/ems_pci.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
index c32f4c7e8844..dddbf290c98e 100644
--- a/drivers/net/can/sja1000/ems_pci.c
+++ b/drivers/net/can/sja1000/ems_pci.c
@@ -373,14 +373,20 @@ static int ems_pci_add_card(struct pci_dev *pdev,
SET_NETDEV_DEV(dev, &pdev->dev);
dev->dev_id = i;
- if (card->version == 1)
+ if (card->version == 1) {
/* reset int flag of pita */
writel(PITA2_ICR_INT0_EN | PITA2_ICR_INT0,
card->conf_addr + PITA2_ICR);
- else
+ } else if (card->version == 2)
/* enable IRQ in PLX 9030 */
writel(PLX_ICSR_ENA_CLR,
card->conf_addr + PLX_ICSR);
+ } else {
+ /* Enable IRQ in AX99100 */
+ writel(ASIX_LINTSR_INT0AC, card->conf_addr + ASIX_LINTSR);
+ /* Enable local INT0 input enable */
+ writel(readl(card->conf_addr + ASIX_LIEMR) | ASIX_LIEMR_L0EINTEN, card->conf_addr + ASIX_LIEMR);
+ }
/* Register SJA1000 device */
err = register_sja1000dev(dev);
--
2.35.3
--
EMS Dr. Thomas Wuensche e.K.
Sonnenhang 3
85304 Ilmmuenster
HR Ingolstadt, HRA 170106
Phone: +49-8441-490260
Fax : +49-8441-81860
http://www.ems-wuensche.com
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 7/8] can: ems_pci: Deassert hardware reset
2023-01-19 15:45 [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3 Gerhard Uttenthaler
` (5 preceding siblings ...)
2023-01-19 15:45 ` [PATCH 6/8] can: ems_pci: Added IRQ enable Gerhard Uttenthaler
@ 2023-01-19 15:45 ` Gerhard Uttenthaler
2023-01-19 15:45 ` [PATCH 8/8] can: ems_pci: Added MODULE_AUTHOR Gerhard Uttenthaler
` (2 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Gerhard Uttenthaler @ 2023-01-19 15:45 UTC (permalink / raw)
To: mkl, linux-can; +Cc: wg, Gerhard Uttenthaler
The reset line from the Asix chip to the SJA1000 is asserted after boot up
until it is deasserted by a register write
Signed-off-by: Gerhard Uttenthaler <uttenthaler@ems-wuensche.com>
---
drivers/net/can/sja1000/ems_pci.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
index dddbf290c98e..68fdead6ad74 100644
--- a/drivers/net/can/sja1000/ems_pci.c
+++ b/drivers/net/can/sja1000/ems_pci.c
@@ -327,6 +327,13 @@ static int ems_pci_add_card(struct pci_dev *pdev,
}
}
+ if (card->version == 3) {
+ /* ASIX chip asserts local reset to CAN controllers
+ * after bootup until it is deasserted
+ */
+ writel(readl(card->conf_addr + ASIX_LIEMR) & ~ASIX_LIEMR_LRST, card->conf_addr + ASIX_LIEMR);
+ }
+
ems_pci_card_reset(card);
/* Detect available channels */
--
2.35.3
--
EMS Dr. Thomas Wuensche e.K.
Sonnenhang 3
85304 Ilmmuenster
HR Ingolstadt, HRA 170106
Phone: +49-8441-490260
Fax : +49-8441-81860
http://www.ems-wuensche.com
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 8/8] can: ems_pci: Added MODULE_AUTHOR
2023-01-19 15:45 [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3 Gerhard Uttenthaler
` (6 preceding siblings ...)
2023-01-19 15:45 ` [PATCH 7/8] can: ems_pci: Deassert hardware reset Gerhard Uttenthaler
@ 2023-01-19 15:45 ` Gerhard Uttenthaler
2023-01-19 23:33 ` Vincent Mailhol
2023-01-19 16:29 ` [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3 Gerhard Uttenthaler
2023-01-19 23:28 ` Vincent Mailhol
9 siblings, 1 reply; 15+ messages in thread
From: Gerhard Uttenthaler @ 2023-01-19 15:45 UTC (permalink / raw)
To: mkl, linux-can; +Cc: wg, Gerhard Uttenthaler
Added myself ass module author and fix three code style issues
Signed-off-by: Gerhard Uttenthaler <uttenthaler@ems-wuensche.com>
---
drivers/net/can/sja1000/ems_pci.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
index 68fdead6ad74..5c2f4afba2d0 100644
--- a/drivers/net/can/sja1000/ems_pci.c
+++ b/drivers/net/can/sja1000/ems_pci.c
@@ -21,6 +21,7 @@
#define DRV_NAME "ems_pci"
MODULE_AUTHOR("Sebastian Haas <support@ems-wuenche.com>");
+MODULE_AUTHOR("Gerhard Uttenthaler <uttenthaler@ems-wuenche.com>");
MODULE_DESCRIPTION("Socket-CAN driver for EMS CPC-PCI/PCIe/104P CAN cards");
MODULE_LICENSE("GPL v2");
@@ -283,7 +284,6 @@ static int ems_pci_add_card(struct pci_dev *pdev,
conf_bar = EMS_PCI_V3_CONF_BAR;
conf_size = EMS_PCI_V3_CONF_SIZE;
} else if (pdev->vendor == PCI_VENDOR_ID_PLX) {
-
card->version = 2; /* CPC-PCI v2 */
max_chan = EMS_PCI_V2_MAX_CHAN;
base_bar = EMS_PCI_V2_BASE_BAR;
@@ -331,7 +331,8 @@ static int ems_pci_add_card(struct pci_dev *pdev,
/* ASIX chip asserts local reset to CAN controllers
* after bootup until it is deasserted
*/
- writel(readl(card->conf_addr + ASIX_LIEMR) & ~ASIX_LIEMR_LRST, card->conf_addr + ASIX_LIEMR);
+ writel(readl(card->conf_addr + ASIX_LIEMR) & ~ASIX_LIEMR_LRST,
+ card->conf_addr + ASIX_LIEMR);
}
ems_pci_card_reset(card);
@@ -392,7 +393,8 @@ static int ems_pci_add_card(struct pci_dev *pdev,
/* Enable IRQ in AX99100 */
writel(ASIX_LINTSR_INT0AC, card->conf_addr + ASIX_LINTSR);
/* Enable local INT0 input enable */
- writel(readl(card->conf_addr + ASIX_LIEMR) | ASIX_LIEMR_L0EINTEN, card->conf_addr + ASIX_LIEMR);
+ writel(readl(card->conf_addr + ASIX_LIEMR) | ASIX_LIEMR_L0EINTEN,
+ card->conf_addr + ASIX_LIEMR);
}
/* Register SJA1000 device */
--
2.35.3
--
EMS Dr. Thomas Wuensche e.K.
Sonnenhang 3
85304 Ilmmuenster
HR Ingolstadt, HRA 170106
Phone: +49-8441-490260
Fax : +49-8441-81860
http://www.ems-wuensche.com
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3
2023-01-19 15:45 [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3 Gerhard Uttenthaler
` (7 preceding siblings ...)
2023-01-19 15:45 ` [PATCH 8/8] can: ems_pci: Added MODULE_AUTHOR Gerhard Uttenthaler
@ 2023-01-19 16:29 ` Gerhard Uttenthaler
2023-01-19 23:28 ` Vincent Mailhol
9 siblings, 0 replies; 15+ messages in thread
From: Gerhard Uttenthaler @ 2023-01-19 16:29 UTC (permalink / raw)
To: mkl, linux-can; +Cc: wg
Urgh, I missed a "{" and the patched driver does not compile. Be sure I
successfully tested it yesterday with all three versions of the card.
But when creating the patch series today I somehow introduced that bug.
I will send the correct patches tomorrow.
BTW: scripts/checkpatch.pl -f
/usr/src/linux/drivers/net/can/sja1000/ems_pci.c did not complain
Sorry for the noise
Gerhard
Am 19.01.23 um 16:45 schrieb Gerhard Uttenthaler:
> The CPC-PCIe v3 uses a Asix AX99100 instead of the discontinued
> PLX PCI9030 bridge chip. This patch series adds support for this
> card version and cleaned some code styling issues.
>
> Gerhard Uttenthaler (8):
> Fixed code style, copyright and email address
> Added Asix AX99100 definitions
> Initialize BAR registers
> Added read/write register and post irq functions
> Initialize CAN controller base addresses
> Added IRQ enable
> Deassert hardware reset
> Added MODULE_AUTHOR
>
> drivers/net/can/sja1000/ems_pci.c | 152 ++++++++++++++++++++++--------
> 1 file changed, 113 insertions(+), 39 deletions(-)
>
--
EMS Dr. Thomas Wuensche e.K.
Sonnenhang 3
85304 Ilmmuenster
HR Ingolstadt, HRA 170106
Phone: +49-8441-490260
Fax : +49-8441-81860
http://www.ems-wuensche.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3
2023-01-19 15:45 [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3 Gerhard Uttenthaler
` (8 preceding siblings ...)
2023-01-19 16:29 ` [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3 Gerhard Uttenthaler
@ 2023-01-19 23:28 ` Vincent Mailhol
2023-01-20 10:10 ` Gerhard Uttenthaler
9 siblings, 1 reply; 15+ messages in thread
From: Vincent Mailhol @ 2023-01-19 23:28 UTC (permalink / raw)
To: Gerhard Uttenthaler; +Cc: mkl, linux-can, wg
Hi Gerhard,
I had a quick look at your series. I have a couple of nitpicks. The
rest looks good.
On Fri. 20 Jan. 2023 at 01:02, Gerhard Uttenthaler
<uttenthaler@ems-wuensche.com> wrote:
> The CPC-PCIe v3 uses a Asix AX99100 instead of the discontinued
> PLX PCI9030 bridge chip. This patch series adds support for this
> card version and cleaned some code styling issues.
>
> Gerhard Uttenthaler (8):
> Fixed code style, copyright and email address
> Added Asix AX99100 definitions
> Initialize BAR registers
> Added read/write register and post irq functions
> Initialize CAN controller base addresses
> Added IRQ enable
> Deassert hardware reset
> Added MODULE_AUTHOR
> Fixed code style, copyright and email address
^^^^^
> Added Asix AX99100 definitions
^^^^^
> Initialize BAR registers
> Added read/write register and post irq functions
^^^^^
> Initialize CAN controller base addresses
> Added IRQ enable
^^^^^
> Deassert hardware reset
> Added MODULE_AUTHOR
^^^^^
For the titles, please use imperative (e.g. add) instead of past
tense (e.g. Added). This also applies to the description.
>
> drivers/net/can/sja1000/ems_pci.c | 152 ++++++++++++++++++++++--------
> 1 file changed, 113 insertions(+), 39 deletions(-)
>
> --
> 2.35.3
>
> --
> EMS Dr. Thomas Wuensche e.K.
> Sonnenhang 3
> 85304 Ilmmuenster
> HR Ingolstadt, HRA 170106
>
> Phone: +49-8441-490260
> Fax : +49-8441-81860
> http://www.ems-wuensche.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 8/8] can: ems_pci: Added MODULE_AUTHOR
2023-01-19 15:45 ` [PATCH 8/8] can: ems_pci: Added MODULE_AUTHOR Gerhard Uttenthaler
@ 2023-01-19 23:33 ` Vincent Mailhol
0 siblings, 0 replies; 15+ messages in thread
From: Vincent Mailhol @ 2023-01-19 23:33 UTC (permalink / raw)
To: Gerhard Uttenthaler; +Cc: mkl, linux-can, wg
On Fri. 20 Jan 2023 at 01:15, Gerhard Uttenthaler
<uttenthaler@ems-wuensche.com> wrote:
>
> Added myself ass module author and fix three code style issues
^^^
A self esteem lapsus? :)
>
> Signed-off-by: Gerhard Uttenthaler <uttenthaler@ems-wuensche.com>
> ---
> drivers/net/can/sja1000/ems_pci.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
> index 68fdead6ad74..5c2f4afba2d0 100644
> --- a/drivers/net/can/sja1000/ems_pci.c
> +++ b/drivers/net/can/sja1000/ems_pci.c
> @@ -21,6 +21,7 @@
> #define DRV_NAME "ems_pci"
>
> MODULE_AUTHOR("Sebastian Haas <support@ems-wuenche.com>");
> +MODULE_AUTHOR("Gerhard Uttenthaler <uttenthaler@ems-wuenche.com>");
> MODULE_DESCRIPTION("Socket-CAN driver for EMS CPC-PCI/PCIe/104P CAN cards");
> MODULE_LICENSE("GPL v2");
>
> @@ -283,7 +284,6 @@ static int ems_pci_add_card(struct pci_dev *pdev,
> conf_bar = EMS_PCI_V3_CONF_BAR;
> conf_size = EMS_PCI_V3_CONF_SIZE;
> } else if (pdev->vendor == PCI_VENDOR_ID_PLX) {
> -
This line was inadvertently added in PATCH 4/8 and is now removed
here. Fix please.
> card->version = 2; /* CPC-PCI v2 */
> max_chan = EMS_PCI_V2_MAX_CHAN;
> base_bar = EMS_PCI_V2_BASE_BAR;
> @@ -331,7 +331,8 @@ static int ems_pci_add_card(struct pci_dev *pdev,
> /* ASIX chip asserts local reset to CAN controllers
> * after bootup until it is deasserted
> */
> - writel(readl(card->conf_addr + ASIX_LIEMR) & ~ASIX_LIEMR_LRST, card->conf_addr + ASIX_LIEMR);
> + writel(readl(card->conf_addr + ASIX_LIEMR) & ~ASIX_LIEMR_LRST,
> + card->conf_addr + ASIX_LIEMR);
> }
>
> ems_pci_card_reset(card);
> @@ -392,7 +393,8 @@ static int ems_pci_add_card(struct pci_dev *pdev,
> /* Enable IRQ in AX99100 */
> writel(ASIX_LINTSR_INT0AC, card->conf_addr + ASIX_LINTSR);
> /* Enable local INT0 input enable */
> - writel(readl(card->conf_addr + ASIX_LIEMR) | ASIX_LIEMR_L0EINTEN, card->conf_addr + ASIX_LIEMR);
> + writel(readl(card->conf_addr + ASIX_LIEMR) | ASIX_LIEMR_L0EINTEN,
> + card->conf_addr + ASIX_LIEMR);
> }
>
> /* Register SJA1000 device */
> --
> 2.35.3
>
> --
> EMS Dr. Thomas Wuensche e.K.
> Sonnenhang 3
> 85304 Ilmmuenster
> HR Ingolstadt, HRA 170106
>
> Phone: +49-8441-490260
> Fax : +49-8441-81860
> http://www.ems-wuensche.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 4/8] can: ems_pci: Added read/write register and post irq functions
2023-01-19 15:45 ` [PATCH 4/8] can: ems_pci: Added read/write register and post irq functions Gerhard Uttenthaler
@ 2023-01-19 23:35 ` Vincent Mailhol
0 siblings, 0 replies; 15+ messages in thread
From: Vincent Mailhol @ 2023-01-19 23:35 UTC (permalink / raw)
To: Gerhard Uttenthaler; +Cc: mkl, linux-can, wg
On Fri. 20 Jan 2023 at 01:15, Gerhard Uttenthaler
<uttenthaler@ems-wuensche.com> wrote:
> Added functions to read and write SJA1000 registers and also the
> post irq routine
>
> Signed-off-by: Gerhard Uttenthaler <uttenthaler@ems-wuensche.com>
> ---
> drivers/net/can/sja1000/ems_pci.c | 25 ++++++++++++++++++++++++-
> 1 file changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
> index be61d39149c4..338233a5d337 100644
> --- a/drivers/net/can/sja1000/ems_pci.c
> +++ b/drivers/net/can/sja1000/ems_pci.c
> @@ -172,6 +172,24 @@ static void ems_pci_v2_post_irq(const struct sja1000_priv *priv)
> writel(PLX_ICSR_ENA_CLR, card->conf_addr + PLX_ICSR);
> }
>
> +static u8 ems_pci_v3_read_reg(const struct sja1000_priv *priv, int port)
> +{
> + return readb(priv->reg_base + port);
> +}
> +
> +static void ems_pci_v3_write_reg(const struct sja1000_priv *priv,
> + int port, u8 val)
> +{
> + writeb(val, priv->reg_base + port);
> +}
> +
> +static void ems_pci_v3_post_irq(const struct sja1000_priv *priv)
> +{
> + struct ems_pci_card *card = (struct ems_pci_card *)priv->priv;
> +
> + writel(ASIX_LINTSR_INT0AC, card->conf_addr + ASIX_LINTSR);
> +}
> +
> /* Check if a CAN controller is present at the specified location
> * by trying to set 'em into the PeliCAN mode
> */
> @@ -265,6 +283,7 @@ static int ems_pci_add_card(struct pci_dev *pdev,
> conf_bar = EMS_PCI_V3_CONF_BAR;
> conf_size = EMS_PCI_V3_CONF_SIZE;
> } else if (pdev->vendor == PCI_VENDOR_ID_PLX) {
> +
No newline here. I see that you fix it in PATCH 8/8, so this is an
obvious squash issue.
> card->version = 2; /* CPC-PCI v2 */
> max_chan = EMS_PCI_V2_MAX_CHAN;
> base_bar = EMS_PCI_V2_BASE_BAR;
> @@ -330,10 +349,14 @@ static int ems_pci_add_card(struct pci_dev *pdev,
> priv->read_reg = ems_pci_v1_read_reg;
> priv->write_reg = ems_pci_v1_write_reg;
> priv->post_irq = ems_pci_v1_post_irq;
> - } else {
> + } else if (card->version == 2) {
> priv->read_reg = ems_pci_v2_read_reg;
> priv->write_reg = ems_pci_v2_write_reg;
> priv->post_irq = ems_pci_v2_post_irq;
> + } else {
> + priv->read_reg = ems_pci_v3_read_reg;
> + priv->write_reg = ems_pci_v3_write_reg;
> + priv->post_irq = ems_pci_v3_post_irq;
> }
>
> /* Check if channel is present */
> --
> 2.35.3
>
> --
> EMS Dr. Thomas Wuensche e.K.
> Sonnenhang 3
> 85304 Ilmmuenster
> HR Ingolstadt, HRA 170106
>
> Phone: +49-8441-490260
> Fax : +49-8441-81860
> http://www.ems-wuensche.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/8] can: ems_pci: Fixed code style, copyright and email address
2023-01-19 15:45 ` [PATCH 1/8] can: ems_pci: Fixed code style, copyright and email address Gerhard Uttenthaler
@ 2023-01-19 23:48 ` Vincent Mailhol
0 siblings, 0 replies; 15+ messages in thread
From: Vincent Mailhol @ 2023-01-19 23:48 UTC (permalink / raw)
To: Gerhard Uttenthaler; +Cc: mkl, linux-can, wg
On Fri. 20 Jan 2023 at 01:02, Gerhard Uttenthaler
<uttenthaler@ems-wuensche.com> wrote:
> Fix code style complained by checkpatch.pl, added Copyright and
> fixed email address
>
> Signed-off-by: Gerhard Uttenthaler <uttenthaler@ems-wuensche.com>
> ---
> drivers/net/can/sja1000/ems_pci.c | 43 +++++++++++++------------------
> 1 file changed, 18 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
> index 4ab91759a5c6..8071ff4708dc 100644
> --- a/drivers/net/can/sja1000/ems_pci.c
> +++ b/drivers/net/can/sja1000/ems_pci.c
> @@ -3,6 +3,7 @@
> * Copyright (C) 2007 Wolfgang Grandegger <wg@grandegger.com>
> * Copyright (C) 2008 Markus Plessing <plessing@ems-wuensche.com>
> * Copyright (C) 2008 Sebastian Haas <haas@ems-wuensche.com>
> + * Copyright (C) 2023 EMS Dr. Thomas Wuensche
> */
>
> #include <linux/kernel.h>
> @@ -19,7 +20,7 @@
>
> #define DRV_NAME "ems_pci"
>
> -MODULE_AUTHOR("Sebastian Haas <haas@ems-wuenche.com>");
> +MODULE_AUTHOR("Sebastian Haas <support@ems-wuenche.com>");
> MODULE_DESCRIPTION("Socket-CAN driver for EMS CPC-PCI/PCIe/104P CAN cards");
> MODULE_LICENSE("GPL v2");
>
> @@ -40,8 +41,7 @@ struct ems_pci_card {
>
> #define EMS_PCI_CAN_CLOCK (16000000 / 2)
>
> -/*
> - * Register definitions and descriptions are from LinCAN 0.3.3.
> +/* Register definitions and descriptions are from LinCAN 0.3.3.
> *
> * PSB4610 PITA-2 bridge control registers
> */
> @@ -52,8 +52,7 @@ struct ems_pci_card {
> #define PITA2_MISC 0x1c /* Miscellaneous Register */
> #define PITA2_MISC_CONFIG 0x04000000 /* Multiplexed parallel interface */
>
> -/*
> - * Register definitions for the PLX 9030
> +/* Register definitions for the PLX 9030
> */
> #define PLX_ICSR 0x4c /* Interrupt Control/Status register */
> #define PLX_ICSR_LINTI1_ENA 0x0001 /* LINTi1 Enable */
> @@ -62,8 +61,7 @@ struct ems_pci_card {
> #define PLX_ICSR_ENA_CLR (PLX_ICSR_LINTI1_ENA | PLX_ICSR_PCIINT_ENA | \
> PLX_ICSR_LINTI1_CLR)
>
> -/*
> - * The board configuration is probably following:
> +/* The board configuration is probably following:
> * RX1 is connected to ground.
> * TX1 is not connected.
> * CLKO is not connected.
> @@ -72,8 +70,7 @@ struct ems_pci_card {
> */
> #define EMS_PCI_OCR (OCR_TX0_PUSHPULL | OCR_TX1_PUSHPULL)
>
> -/*
> - * In the CDR register, you should set CBP to 1.
> +/* In the CDR register, you should set CBP to 1.
> * You will probably also want to set the clock divider value to 7
> * (meaning direct oscillator output) because the second SJA1000 chip
> * is driven by the first one CLKOUT output.
> @@ -100,8 +97,7 @@ static const struct pci_device_id ems_pci_tbl[] = {
> };
> MODULE_DEVICE_TABLE(pci, ems_pci_tbl);
>
> -/*
> - * Helper to read internal registers from card logic (not CAN)
> +/* Helper to read internal registers from card logic (not CAN)
> */
> static u8 ems_pci_v1_readb(struct ems_pci_card *card, unsigned int port)
> {
> @@ -146,8 +142,7 @@ static void ems_pci_v2_post_irq(const struct sja1000_priv *priv)
> writel(PLX_ICSR_ENA_CLR, card->conf_addr + PLX_ICSR);
> }
>
> -/*
> - * Check if a CAN controller is present at the specified location
> +/* Check if a CAN controller is present at the specified location
> * by trying to set 'em into the PeliCAN mode
> */
> static inline int ems_pci_check_chan(const struct sja1000_priv *priv)
> @@ -185,10 +180,10 @@ static void ems_pci_del_card(struct pci_dev *pdev)
> free_sja1000dev(dev);
> }
>
> - if (card->base_addr != NULL)
> + if (card->base_addr)
> pci_iounmap(card->pci_dev, card->base_addr);
>
> - if (card->conf_addr != NULL)
> + if (card->conf_addr)
> pci_iounmap(card->pci_dev, card->conf_addr);
>
> kfree(card);
> @@ -202,8 +197,7 @@ static void ems_pci_card_reset(struct ems_pci_card *card)
> writeb(0, card->base_addr);
> }
>
> -/*
> - * Probe PCI device for EMS CAN signature and register each available
> +/* Probe PCI device for EMS CAN signature and register each available
> * CAN channel to SJA1000 Socket-CAN subsystem.
> */
> static int ems_pci_add_card(struct pci_dev *pdev,
> @@ -222,8 +216,8 @@ static int ems_pci_add_card(struct pci_dev *pdev,
> }
>
> /* Allocating card structures to hold addresses, ... */
> - card = kzalloc(sizeof(struct ems_pci_card), GFP_KERNEL);
> - if (card == NULL) {
> + card = kzalloc(sizeof(*card), GFP_KERNEL);
> + if (!card) {
> pci_disable_device(pdev);
> return -ENOMEM;
> }
> @@ -248,13 +242,13 @@ static int ems_pci_add_card(struct pci_dev *pdev,
>
> /* Remap configuration space and controller memory area */
> card->conf_addr = pci_iomap(pdev, 0, conf_size);
> - if (card->conf_addr == NULL) {
> + if (!card->conf_addr) {
> err = -ENOMEM;
> goto failure_cleanup;
> }
>
> card->base_addr = pci_iomap(pdev, base_bar, EMS_PCI_BASE_SIZE);
> - if (card->base_addr == NULL) {
> + if (!card->base_addr) {
> err = -ENOMEM;
> goto failure_cleanup;
> }
> @@ -281,7 +275,7 @@ static int ems_pci_add_card(struct pci_dev *pdev,
> /* Detect available channels */
> for (i = 0; i < max_chan; i++) {
> dev = alloc_sja1000dev(0);
> - if (dev == NULL) {
> + if (!dev) {
> err = -ENOMEM;
> goto failure_cleanup;
> }
> @@ -325,8 +319,7 @@ static int ems_pci_add_card(struct pci_dev *pdev,
> /* Register SJA1000 device */
> err = register_sja1000dev(dev);
> if (err) {
> - dev_err(&pdev->dev, "Registering device failed "
> - "(err=%d)\n", err);
> + dev_err(&pdev->dev, "Registering device failed (err=%d)\n", err);
^^^^^^^^
Remove the brackets. Ref:
https://www.kernel.org/doc/html/latest/process/coding-style.html#printing-kernel-messages
Printing numbers in parentheses (%d) adds no value and should be avoided.
Optional for your series, but if you like, you can consider to print
the mnemotechnic instead of the error value:
dev_err(&pdev->dev,
"Registering device failed: %pe\n",
ERR_PTR(err));
> free_sja1000dev(dev);
> goto failure_cleanup;
> }
> @@ -334,7 +327,7 @@ static int ems_pci_add_card(struct pci_dev *pdev,
> card->channels++;
>
> dev_info(&pdev->dev, "Channel #%d at 0x%p, irq %d\n",
> - i + 1, priv->reg_base, dev->irq);
> + i + 1, priv->reg_base, dev->irq);
> } else {
> free_sja1000dev(dev);
> }
> --
> 2.35.3
>
> --
> EMS Dr. Thomas Wuensche e.K.
> Sonnenhang 3
> 85304 Ilmmuenster
> HR Ingolstadt, HRA 170106
>
> Phone: +49-8441-490260
> Fax : +49-8441-81860
> http://www.ems-wuensche.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3
2023-01-19 23:28 ` Vincent Mailhol
@ 2023-01-20 10:10 ` Gerhard Uttenthaler
0 siblings, 0 replies; 15+ messages in thread
From: Gerhard Uttenthaler @ 2023-01-20 10:10 UTC (permalink / raw)
To: Vincent Mailhol; +Cc: mkl, linux-can, wg
Hi Vincent,
Thank you for your comments! I will send a v2 series soon.
Gerhard
Am 20.01.23 um 00:28 schrieb Vincent Mailhol:
> Hi Gerhard,
>
> I had a quick look at your series. I have a couple of nitpicks. The
> rest looks good.
>
> On Fri. 20 Jan. 2023 at 01:02, Gerhard Uttenthaler
> <uttenthaler@ems-wuensche.com> wrote:
>> The CPC-PCIe v3 uses a Asix AX99100 instead of the discontinued
>> PLX PCI9030 bridge chip. This patch series adds support for this
>> card version and cleaned some code styling issues.
>>
>> Gerhard Uttenthaler (8):
>> Fixed code style, copyright and email address
>> Added Asix AX99100 definitions
>> Initialize BAR registers
>> Added read/write register and post irq functions
>> Initialize CAN controller base addresses
>> Added IRQ enable
>> Deassert hardware reset
>> Added MODULE_AUTHOR
>
>> Fixed code style, copyright and email address
> ^^^^^
>> Added Asix AX99100 definitions
> ^^^^^
>> Initialize BAR registers
>> Added read/write register and post irq functions
> ^^^^^
>> Initialize CAN controller base addresses
>> Added IRQ enable
> ^^^^^
>> Deassert hardware reset
>> Added MODULE_AUTHOR
> ^^^^^
>
> For the titles, please use imperative (e.g. add) instead of past
> tense (e.g. Added). This also applies to the description.
>
>>
>> drivers/net/can/sja1000/ems_pci.c | 152 ++++++++++++++++++++++--------
>> 1 file changed, 113 insertions(+), 39 deletions(-)
>>
>> --
>> 2.35.3
>>
>> --
>> EMS Dr. Thomas Wuensche e.K.
>> Sonnenhang 3
>> 85304 Ilmmuenster
>> HR Ingolstadt, HRA 170106
>>
>> Phone: +49-8441-490260
>> Fax : +49-8441-81860
>> http://www.ems-wuensche.com
> -- --
>
--
EMS Dr. Thomas Wuensche e.K.
Sonnenhang 3
85304 Ilmmuenster
HR Ingolstadt, HRA 170106
Phone: +49-8441-490260
Fax : +49-8441-81860
http://www.ems-wuensche.com
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2023-01-20 10:10 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-19 15:45 [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3 Gerhard Uttenthaler
2023-01-19 15:45 ` [PATCH 1/8] can: ems_pci: Fixed code style, copyright and email address Gerhard Uttenthaler
2023-01-19 23:48 ` Vincent Mailhol
2023-01-19 15:45 ` [PATCH 2/8] can: ems_pci: Added Asix AX99100 definitions Gerhard Uttenthaler
2023-01-19 15:45 ` [PATCH 3/8] can: ems_pci: Initialize BAR registers Gerhard Uttenthaler
2023-01-19 15:45 ` [PATCH 4/8] can: ems_pci: Added read/write register and post irq functions Gerhard Uttenthaler
2023-01-19 23:35 ` Vincent Mailhol
2023-01-19 15:45 ` [PATCH 5/8] can: ems_pci: Initialize CAN controller base addresses Gerhard Uttenthaler
2023-01-19 15:45 ` [PATCH 6/8] can: ems_pci: Added IRQ enable Gerhard Uttenthaler
2023-01-19 15:45 ` [PATCH 7/8] can: ems_pci: Deassert hardware reset Gerhard Uttenthaler
2023-01-19 15:45 ` [PATCH 8/8] can: ems_pci: Added MODULE_AUTHOR Gerhard Uttenthaler
2023-01-19 23:33 ` Vincent Mailhol
2023-01-19 16:29 ` [PATCH 0/8] can: ems_pci: Add support for CPC-PCIe v3 Gerhard Uttenthaler
2023-01-19 23:28 ` Vincent Mailhol
2023-01-20 10:10 ` Gerhard Uttenthaler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).