Commit 62f42a11 authored by David S. Miller's avatar David S. Miller

Merge tag 'linux-can-fixes-for-5.2-20190607' of...

Merge tag 'linux-can-fixes-for-5.2-20190607' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can

Marc Kleine-Budde says:

====================
pull-request: can 2019-06-07

this is a pull reqeust of 9 patches for net/master.

The first patch is by Alexander Dahl and removes a duplicate menu entry from
the Kconfig. The next patch by Joakim Zhang fixes the timeout in the flexcan
driver when setting small bit rates. Anssi Hannula's patch for the xilinx_can
driver fixes the bittiming_const for CAN FD core. The two patches by Sean
Nyekjaer bring mcp25625 to the existing mcp251x driver. The patch by Eugen
Hristev implements an errata for the m_can driver. YueHaibing's patch fixes the
error handling ing can_init(). The patch by Fabio Estevam for the flexcan
driver removes an unneeded registration message during flexcan_probe(). And the
last patch is by Willem de Bruijn and adds the missing purging the  socket
error queue on sock destruct.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 2f3f7d1f fd704bd5
...@@ -4,6 +4,7 @@ Required properties: ...@@ -4,6 +4,7 @@ Required properties:
- compatible: Should be one of the following: - compatible: Should be one of the following:
- "microchip,mcp2510" for MCP2510. - "microchip,mcp2510" for MCP2510.
- "microchip,mcp2515" for MCP2515. - "microchip,mcp2515" for MCP2515.
- "microchip,mcp25625" for MCP25625.
- reg: SPI chip select. - reg: SPI chip select.
- clocks: The clock feeding the CAN controller. - clocks: The clock feeding the CAN controller.
- interrupts: Should contain IRQ line for the CAN controller. - interrupts: Should contain IRQ line for the CAN controller.
......
...@@ -166,7 +166,7 @@ ...@@ -166,7 +166,7 @@
#define FLEXCAN_MB_CNT_LENGTH(x) (((x) & 0xf) << 16) #define FLEXCAN_MB_CNT_LENGTH(x) (((x) & 0xf) << 16)
#define FLEXCAN_MB_CNT_TIMESTAMP(x) ((x) & 0xffff) #define FLEXCAN_MB_CNT_TIMESTAMP(x) ((x) & 0xffff)
#define FLEXCAN_TIMEOUT_US (50) #define FLEXCAN_TIMEOUT_US (250)
/* FLEXCAN hardware feature flags /* FLEXCAN hardware feature flags
* *
...@@ -1583,9 +1583,6 @@ static int flexcan_probe(struct platform_device *pdev) ...@@ -1583,9 +1583,6 @@ static int flexcan_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "failed to setup stop-mode\n"); dev_dbg(&pdev->dev, "failed to setup stop-mode\n");
} }
dev_info(&pdev->dev, "device registered (reg_base=%p, irq=%d)\n",
priv->regs, dev->irq);
return 0; return 0;
failed_register: failed_register:
......
...@@ -822,6 +822,27 @@ static int m_can_poll(struct napi_struct *napi, int quota) ...@@ -822,6 +822,27 @@ static int m_can_poll(struct napi_struct *napi, int quota)
if (!irqstatus) if (!irqstatus)
goto end; goto end;
/* Errata workaround for issue "Needless activation of MRAF irq"
* During frame reception while the MCAN is in Error Passive state
* and the Receive Error Counter has the value MCAN_ECR.REC = 127,
* it may happen that MCAN_IR.MRAF is set although there was no
* Message RAM access failure.
* If MCAN_IR.MRAF is enabled, an interrupt to the Host CPU is generated
* The Message RAM Access Failure interrupt routine needs to check
* whether MCAN_ECR.RP = ’1’ and MCAN_ECR.REC = 127.
* In this case, reset MCAN_IR.MRAF. No further action is required.
*/
if ((priv->version <= 31) && (irqstatus & IR_MRAF) &&
(m_can_read(priv, M_CAN_ECR) & ECR_RP)) {
struct can_berr_counter bec;
__m_can_get_berr_counter(dev, &bec);
if (bec.rxerr == 127) {
m_can_write(priv, M_CAN_IR, IR_MRAF);
irqstatus &= ~IR_MRAF;
}
}
psr = m_can_read(priv, M_CAN_PSR); psr = m_can_read(priv, M_CAN_PSR);
if (irqstatus & IR_ERR_STATE) if (irqstatus & IR_ERR_STATE)
work_done += m_can_handle_state_errors(dev, psr); work_done += m_can_handle_state_errors(dev, psr);
......
...@@ -9,9 +9,10 @@ config CAN_HI311X ...@@ -9,9 +9,10 @@ config CAN_HI311X
Driver for the Holt HI311x SPI CAN controllers. Driver for the Holt HI311x SPI CAN controllers.
config CAN_MCP251X config CAN_MCP251X
tristate "Microchip MCP251x SPI CAN controllers" tristate "Microchip MCP251x and MCP25625 SPI CAN controllers"
depends on HAS_DMA depends on HAS_DMA
---help--- ---help---
Driver for the Microchip MCP251x SPI CAN controllers. Driver for the Microchip MCP251x and MCP25625 SPI CAN
controllers.
endmenu endmenu
/* /*
* CAN bus driver for Microchip 251x CAN Controller with SPI Interface * CAN bus driver for Microchip 251x/25625 CAN Controller with SPI Interface
* *
* MCP2510 support and bug fixes by Christian Pellegrin * MCP2510 support and bug fixes by Christian Pellegrin
* <chripell@evolware.org> * <chripell@evolware.org>
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
* static struct spi_board_info spi_board_info[] = { * static struct spi_board_info spi_board_info[] = {
* { * {
* .modalias = "mcp2510", * .modalias = "mcp2510",
* // or "mcp2515" depending on your controller * // "mcp2515" or "mcp25625" depending on your controller
* .platform_data = &mcp251x_info, * .platform_data = &mcp251x_info,
* .irq = IRQ_EINT13, * .irq = IRQ_EINT13,
* .max_speed_hz = 2*1000*1000, * .max_speed_hz = 2*1000*1000,
...@@ -238,6 +238,7 @@ static const struct can_bittiming_const mcp251x_bittiming_const = { ...@@ -238,6 +238,7 @@ static const struct can_bittiming_const mcp251x_bittiming_const = {
enum mcp251x_model { enum mcp251x_model {
CAN_MCP251X_MCP2510 = 0x2510, CAN_MCP251X_MCP2510 = 0x2510,
CAN_MCP251X_MCP2515 = 0x2515, CAN_MCP251X_MCP2515 = 0x2515,
CAN_MCP251X_MCP25625 = 0x25625,
}; };
struct mcp251x_priv { struct mcp251x_priv {
...@@ -280,7 +281,6 @@ static inline int mcp251x_is_##_model(struct spi_device *spi) \ ...@@ -280,7 +281,6 @@ static inline int mcp251x_is_##_model(struct spi_device *spi) \
} }
MCP251X_IS(2510); MCP251X_IS(2510);
MCP251X_IS(2515);
static void mcp251x_clean(struct net_device *net) static void mcp251x_clean(struct net_device *net)
{ {
...@@ -639,7 +639,7 @@ static int mcp251x_hw_reset(struct spi_device *spi) ...@@ -639,7 +639,7 @@ static int mcp251x_hw_reset(struct spi_device *spi)
/* Wait for oscillator startup timer after reset */ /* Wait for oscillator startup timer after reset */
mdelay(MCP251X_OST_DELAY_MS); mdelay(MCP251X_OST_DELAY_MS);
reg = mcp251x_read_reg(spi, CANSTAT); reg = mcp251x_read_reg(spi, CANSTAT);
if ((reg & CANCTRL_REQOP_MASK) != CANCTRL_REQOP_CONF) if ((reg & CANCTRL_REQOP_MASK) != CANCTRL_REQOP_CONF)
return -ENODEV; return -ENODEV;
...@@ -820,9 +820,8 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id) ...@@ -820,9 +820,8 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
/* receive buffer 0 */ /* receive buffer 0 */
if (intf & CANINTF_RX0IF) { if (intf & CANINTF_RX0IF) {
mcp251x_hw_rx(spi, 0); mcp251x_hw_rx(spi, 0);
/* /* Free one buffer ASAP
* Free one buffer ASAP * (The MCP2515/25625 does this automatically.)
* (The MCP2515 does this automatically.)
*/ */
if (mcp251x_is_2510(spi)) if (mcp251x_is_2510(spi))
mcp251x_write_bits(spi, CANINTF, CANINTF_RX0IF, 0x00); mcp251x_write_bits(spi, CANINTF, CANINTF_RX0IF, 0x00);
...@@ -831,7 +830,7 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id) ...@@ -831,7 +830,7 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
/* receive buffer 1 */ /* receive buffer 1 */
if (intf & CANINTF_RX1IF) { if (intf & CANINTF_RX1IF) {
mcp251x_hw_rx(spi, 1); mcp251x_hw_rx(spi, 1);
/* the MCP2515 does this automatically */ /* The MCP2515/25625 does this automatically. */
if (mcp251x_is_2510(spi)) if (mcp251x_is_2510(spi))
clear_intf |= CANINTF_RX1IF; clear_intf |= CANINTF_RX1IF;
} }
...@@ -1006,6 +1005,10 @@ static const struct of_device_id mcp251x_of_match[] = { ...@@ -1006,6 +1005,10 @@ static const struct of_device_id mcp251x_of_match[] = {
.compatible = "microchip,mcp2515", .compatible = "microchip,mcp2515",
.data = (void *)CAN_MCP251X_MCP2515, .data = (void *)CAN_MCP251X_MCP2515,
}, },
{
.compatible = "microchip,mcp25625",
.data = (void *)CAN_MCP251X_MCP25625,
},
{ } { }
}; };
MODULE_DEVICE_TABLE(of, mcp251x_of_match); MODULE_DEVICE_TABLE(of, mcp251x_of_match);
...@@ -1019,6 +1022,10 @@ static const struct spi_device_id mcp251x_id_table[] = { ...@@ -1019,6 +1022,10 @@ static const struct spi_device_id mcp251x_id_table[] = {
.name = "mcp2515", .name = "mcp2515",
.driver_data = (kernel_ulong_t)CAN_MCP251X_MCP2515, .driver_data = (kernel_ulong_t)CAN_MCP251X_MCP2515,
}, },
{
.name = "mcp25625",
.driver_data = (kernel_ulong_t)CAN_MCP251X_MCP25625,
},
{ } { }
}; };
MODULE_DEVICE_TABLE(spi, mcp251x_id_table); MODULE_DEVICE_TABLE(spi, mcp251x_id_table);
...@@ -1259,5 +1266,5 @@ module_spi_driver(mcp251x_can_driver); ...@@ -1259,5 +1266,5 @@ module_spi_driver(mcp251x_can_driver);
MODULE_AUTHOR("Chris Elston <celston@katalix.com>, " MODULE_AUTHOR("Chris Elston <celston@katalix.com>, "
"Christian Pellegrin <chripell@evolware.org>"); "Christian Pellegrin <chripell@evolware.org>");
MODULE_DESCRIPTION("Microchip 251x CAN driver"); MODULE_DESCRIPTION("Microchip 251x/25625 CAN driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
...@@ -102,12 +102,6 @@ config CAN_PEAK_USB ...@@ -102,12 +102,6 @@ config CAN_PEAK_USB
(see also http://www.peak-system.com). (see also http://www.peak-system.com).
config CAN_MCBA_USB
tristate "Microchip CAN BUS Analyzer interface"
---help---
This driver supports the CAN BUS Analyzer interface
from Microchip (http://www.microchip.com/development-tools/).
config CAN_UCAN config CAN_UCAN
tristate "Theobroma Systems UCAN interface" tristate "Theobroma Systems UCAN interface"
---help--- ---help---
......
...@@ -1435,7 +1435,7 @@ static const struct xcan_devtype_data xcan_canfd_data = { ...@@ -1435,7 +1435,7 @@ static const struct xcan_devtype_data xcan_canfd_data = {
XCAN_FLAG_RXMNF | XCAN_FLAG_RXMNF |
XCAN_FLAG_TX_MAILBOXES | XCAN_FLAG_TX_MAILBOXES |
XCAN_FLAG_RX_FIFO_MULTI, XCAN_FLAG_RX_FIFO_MULTI,
.bittiming_const = &xcan_bittiming_const, .bittiming_const = &xcan_bittiming_const_canfd,
.btr_ts2_shift = XCAN_BTR_TS2_SHIFT_CANFD, .btr_ts2_shift = XCAN_BTR_TS2_SHIFT_CANFD,
.btr_sjw_shift = XCAN_BTR_SJW_SHIFT_CANFD, .btr_sjw_shift = XCAN_BTR_SJW_SHIFT_CANFD,
.bus_clk_name = "s_axi_aclk", .bus_clk_name = "s_axi_aclk",
......
...@@ -99,6 +99,7 @@ EXPORT_SYMBOL(can_ioctl); ...@@ -99,6 +99,7 @@ EXPORT_SYMBOL(can_ioctl);
static void can_sock_destruct(struct sock *sk) static void can_sock_destruct(struct sock *sk)
{ {
skb_queue_purge(&sk->sk_receive_queue); skb_queue_purge(&sk->sk_receive_queue);
skb_queue_purge(&sk->sk_error_queue);
} }
static const struct can_proto *can_get_proto(int protocol) static const struct can_proto *can_get_proto(int protocol)
...@@ -952,6 +953,8 @@ static struct pernet_operations can_pernet_ops __read_mostly = { ...@@ -952,6 +953,8 @@ static struct pernet_operations can_pernet_ops __read_mostly = {
static __init int can_init(void) static __init int can_init(void)
{ {
int err;
/* check for correct padding to be able to use the structs similarly */ /* check for correct padding to be able to use the structs similarly */
BUILD_BUG_ON(offsetof(struct can_frame, can_dlc) != BUILD_BUG_ON(offsetof(struct can_frame, can_dlc) !=
offsetof(struct canfd_frame, len) || offsetof(struct canfd_frame, len) ||
...@@ -965,15 +968,31 @@ static __init int can_init(void) ...@@ -965,15 +968,31 @@ static __init int can_init(void)
if (!rcv_cache) if (!rcv_cache)
return -ENOMEM; return -ENOMEM;
register_pernet_subsys(&can_pernet_ops); err = register_pernet_subsys(&can_pernet_ops);
if (err)
goto out_pernet;
/* protocol register */ /* protocol register */
sock_register(&can_family_ops); err = sock_register(&can_family_ops);
register_netdevice_notifier(&can_netdev_notifier); if (err)
goto out_sock;
err = register_netdevice_notifier(&can_netdev_notifier);
if (err)
goto out_notifier;
dev_add_pack(&can_packet); dev_add_pack(&can_packet);
dev_add_pack(&canfd_packet); dev_add_pack(&canfd_packet);
return 0; return 0;
out_notifier:
sock_unregister(PF_CAN);
out_sock:
unregister_pernet_subsys(&can_pernet_ops);
out_pernet:
kmem_cache_destroy(rcv_cache);
return err;
} }
static __exit void can_exit(void) static __exit void can_exit(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment