Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Commit dbd5f5d

Browse files
committed
Merge tag 'linux-can-fixes-for-5.18-20220514' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can
Marc Kleine-Budde says: ==================== pull-request: can 2022-05-14 this is a pull request of 2 patches for net/master. Changes to linux-can-fixes-for-5.18-20220513: - adjusted Fixes: Tag on "Revert "can: m_can: pci: use custom bit timings for Elkhart Lake"" (Thanks Jakub) Both patches are by Jarkko Nikula, target the m_can PCI driver bindings, and fix usage of wrong bit timing constants for the Elkhart Lake platform. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 9500acc + d6da788 commit dbd5f5d

File tree

3 files changed

+10
-65
lines changed

3 files changed

+10
-65
lines changed

drivers/net/can/m_can/m_can.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,34 +1495,22 @@ static int m_can_dev_setup(struct m_can_classdev *cdev)
14951495
err = can_set_static_ctrlmode(dev, CAN_CTRLMODE_FD_NON_ISO);
14961496
if (err)
14971497
return err;
1498-
cdev->can.bittiming_const = cdev->bit_timing ?
1499-
cdev->bit_timing : &m_can_bittiming_const_30X;
1500-
1501-
cdev->can.data_bittiming_const = cdev->data_timing ?
1502-
cdev->data_timing :
1503-
&m_can_data_bittiming_const_30X;
1498+
cdev->can.bittiming_const = &m_can_bittiming_const_30X;
1499+
cdev->can.data_bittiming_const = &m_can_data_bittiming_const_30X;
15041500
break;
15051501
case 31:
15061502
/* CAN_CTRLMODE_FD_NON_ISO is fixed with M_CAN IP v3.1.x */
15071503
err = can_set_static_ctrlmode(dev, CAN_CTRLMODE_FD_NON_ISO);
15081504
if (err)
15091505
return err;
1510-
cdev->can.bittiming_const = cdev->bit_timing ?
1511-
cdev->bit_timing : &m_can_bittiming_const_31X;
1512-
1513-
cdev->can.data_bittiming_const = cdev->data_timing ?
1514-
cdev->data_timing :
1515-
&m_can_data_bittiming_const_31X;
1506+
cdev->can.bittiming_const = &m_can_bittiming_const_31X;
1507+
cdev->can.data_bittiming_const = &m_can_data_bittiming_const_31X;
15161508
break;
15171509
case 32:
15181510
case 33:
15191511
/* Support both MCAN version v3.2.x and v3.3.0 */
1520-
cdev->can.bittiming_const = cdev->bit_timing ?
1521-
cdev->bit_timing : &m_can_bittiming_const_31X;
1522-
1523-
cdev->can.data_bittiming_const = cdev->data_timing ?
1524-
cdev->data_timing :
1525-
&m_can_data_bittiming_const_31X;
1512+
cdev->can.bittiming_const = &m_can_bittiming_const_31X;
1513+
cdev->can.data_bittiming_const = &m_can_data_bittiming_const_31X;
15261514

15271515
cdev->can.ctrlmode_supported |=
15281516
(m_can_niso_supported(cdev) ?

drivers/net/can/m_can/m_can.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ struct m_can_classdev {
8585
struct sk_buff *tx_skb;
8686
struct phy *transceiver;
8787

88-
const struct can_bittiming_const *bit_timing;
89-
const struct can_bittiming_const *data_timing;
90-
9188
struct m_can_ops *ops;
9289

9390
int version;

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)