Skip to content

Commit 14ea4a4

Browse files
jhnikulamarckleinebudde
authored andcommitted
Revert "can: m_can: pci: use custom bit timings for Elkhart Lake"
This reverts commit 0e8ffdf. Commit 0e8ffdf ("can: m_can: pci: use custom bit timings for Elkhart Lake") broke the test case using bitrate switching. | ip link set can0 up type can bitrate 500000 dbitrate 4000000 fd on | ip link set can1 up type can bitrate 500000 dbitrate 4000000 fd on | candump can0 & | cangen can1 -I 0x800 -L 64 -e -fb \ | -D 11223344deadbeef55667788feedf00daabbccdd44332211 -n 1 -v -v Above commit does everything correctly according to the datasheet. However datasheet wasn't correct. I got confirmation from hardware engineers that the actual CAN hardware on Intel Elkhart Lake is based on M_CAN version v3.2.0. Datasheet was mirroring values from an another specification which was based on earlier M_CAN version leading to wrong bit timings. Therefore revert the commit and switch back to common bit timings. Fixes: ea4c178 ("can: m_can: pci: use custom bit timings for Elkhart Lake") Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Jarkko Nikula <[email protected]> Reported-by: Chee Hou Ong <[email protected]> Reported-by: Aman Kumar <[email protected]> Reported-by: Pallavi Kumari <[email protected]> Cc: <[email protected]> # v5.16+ Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent f3f19f9 commit 14ea4a4

File tree

1 file changed

+4
-44
lines changed

1 file changed

+4
-44
lines changed

drivers/net/can/m_can/m_can_pci.c

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,9 @@
1818

1919
#define M_CAN_PCI_MMIO_BAR 0
2020

21+
#define M_CAN_CLOCK_FREQ_EHL 200000000
2122
#define CTL_CSR_INT_CTL_OFFSET 0x508
2223

23-
struct m_can_pci_config {
24-
const struct can_bittiming_const *bit_timing;
25-
const struct can_bittiming_const *data_timing;
26-
unsigned int clock_freq;
27-
};
28-
2924
struct m_can_pci_priv {
3025
struct m_can_classdev cdev;
3126

@@ -89,40 +84,9 @@ static struct m_can_ops m_can_pci_ops = {
8984
.read_fifo = iomap_read_fifo,
9085
};
9186

92-
static const struct can_bittiming_const m_can_bittiming_const_ehl = {
93-
.name = KBUILD_MODNAME,
94-
.tseg1_min = 2, /* Time segment 1 = prop_seg + phase_seg1 */
95-
.tseg1_max = 64,
96-
.tseg2_min = 1, /* Time segment 2 = phase_seg2 */
97-
.tseg2_max = 128,
98-
.sjw_max = 128,
99-
.brp_min = 1,
100-
.brp_max = 512,
101-
.brp_inc = 1,
102-
};
103-
104-
static const struct can_bittiming_const m_can_data_bittiming_const_ehl = {
105-
.name = KBUILD_MODNAME,
106-
.tseg1_min = 2, /* Time segment 1 = prop_seg + phase_seg1 */
107-
.tseg1_max = 16,
108-
.tseg2_min = 1, /* Time segment 2 = phase_seg2 */
109-
.tseg2_max = 8,
110-
.sjw_max = 4,
111-
.brp_min = 1,
112-
.brp_max = 32,
113-
.brp_inc = 1,
114-
};
115-
116-
static const struct m_can_pci_config m_can_pci_ehl = {
117-
.bit_timing = &m_can_bittiming_const_ehl,
118-
.data_timing = &m_can_data_bittiming_const_ehl,
119-
.clock_freq = 200000000,
120-
};
121-
12287
static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
12388
{
12489
struct device *dev = &pci->dev;
125-
const struct m_can_pci_config *cfg;
12690
struct m_can_classdev *mcan_class;
12791
struct m_can_pci_priv *priv;
12892
void __iomem *base;
@@ -150,8 +114,6 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
150114
if (!mcan_class)
151115
return -ENOMEM;
152116

153-
cfg = (const struct m_can_pci_config *)id->driver_data;
154-
155117
priv = cdev_to_priv(mcan_class);
156118

157119
priv->base = base;
@@ -163,9 +125,7 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
163125
mcan_class->dev = &pci->dev;
164126
mcan_class->net->irq = pci_irq_vector(pci, 0);
165127
mcan_class->pm_clock_support = 1;
166-
mcan_class->bit_timing = cfg->bit_timing;
167-
mcan_class->data_timing = cfg->data_timing;
168-
mcan_class->can.clock.freq = cfg->clock_freq;
128+
mcan_class->can.clock.freq = id->driver_data;
169129
mcan_class->ops = &m_can_pci_ops;
170130

171131
pci_set_drvdata(pci, mcan_class);
@@ -218,8 +178,8 @@ static SIMPLE_DEV_PM_OPS(m_can_pci_pm_ops,
218178
m_can_pci_suspend, m_can_pci_resume);
219179

220180
static const struct pci_device_id m_can_pci_id_table[] = {
221-
{ PCI_VDEVICE(INTEL, 0x4bc1), (kernel_ulong_t)&m_can_pci_ehl, },
222-
{ PCI_VDEVICE(INTEL, 0x4bc2), (kernel_ulong_t)&m_can_pci_ehl, },
181+
{ PCI_VDEVICE(INTEL, 0x4bc1), M_CAN_CLOCK_FREQ_EHL, },
182+
{ PCI_VDEVICE(INTEL, 0x4bc2), M_CAN_CLOCK_FREQ_EHL, },
223183
{ } /* Terminating Entry */
224184
};
225185
MODULE_DEVICE_TABLE(pci, m_can_pci_id_table);

0 commit comments

Comments
 (0)