Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'linux-can-next-for-6.19-20251017' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next

Marc Kleine-Budde says:

====================
pull-request: can-next 2025-10-17

The first patch is by me and adds support for an optional reset to the
m_can drivers.

Vincent Mailhol's patch targets all drivers and removes the
can_change_mtu() function, since the netdev's min and max MTU are
populated.

Markus Schneider-Pargmann contributes 4 patches to the m_can driver to
add am62 wakeup support.

The last 7 patches are by me and provide various cleanups to the m_can
driver.

* tag 'linux-can-next-for-6.19-20251017' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next:
can: m_can: m_can_get_berr_counter(): don't wake up controller if interface is down
can: m_can: m_can_tx_submit(): remove unneeded sanity checks
can: m_can: m_can_class_register(): remove error message in case devm_kzalloc() fails
can: m_can: m_can_interrupt_enable(): use m_can_write() instead of open coding it
net: m_can: convert dev_{dbg,info,err} -> netdev_{dbg,info,err}
can: m_can: hrtimer_callback(): rename to m_can_polling_timer()
can: m_can: m_can_init_ram(): make static
can: m_can: Support pinctrl wakeup state
can: m_can: Return ERR_PTR on error in allocation
can: m_can: Map WoL to device_set_wakeup_enable
dt-bindings: can: m_can: Add wakeup properties
can: treewide: remove can_change_mtu()
can: m_can: add support for optional reset
====================

Link: https://patch.msgid.link/20251017150819.1415685-1-mkl@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+222 -152
+25
Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
··· 109 109 maximum: 32 110 110 minItems: 1 111 111 112 + pinctrl-0: 113 + description: Default pinctrl state 114 + 115 + pinctrl-1: 116 + description: Can be "sleep" or "wakeup" pinctrl state 117 + 118 + pinctrl-2: 119 + description: Can be "sleep" or "wakeup" pinctrl state 120 + 121 + pinctrl-names: 122 + description: 123 + When present should contain at least "default" describing the default pin 124 + states. Other states are "sleep" which describes the pinstate when 125 + sleeping and "wakeup" describing the pins if wakeup is enabled. 126 + minItems: 1 127 + items: 128 + - const: default 129 + - enum: [ sleep, wakeup ] 130 + - const: wakeup 131 + 112 132 power-domains: 113 133 description: 114 134 Power domain provider node and an args specifier containing ··· 144 124 access-controllers: 145 125 minItems: 1 146 126 maxItems: 2 127 + 128 + wakeup-source: 129 + $ref: /schemas/types.yaml#/definitions/phandle-array 130 + description: 131 + List of phandles to system idle states in which mcan can wakeup the system. 147 132 148 133 required: 149 134 - compatible
-1
drivers/net/can/at91_can.c
··· 948 948 .ndo_open = at91_open, 949 949 .ndo_stop = at91_close, 950 950 .ndo_start_xmit = at91_start_xmit, 951 - .ndo_change_mtu = can_change_mtu, 952 951 }; 953 952 954 953 static const struct ethtool_ops at91_ethtool_ops = {
-1
drivers/net/can/bxcan.c
··· 881 881 .ndo_open = bxcan_open, 882 882 .ndo_stop = bxcan_stop, 883 883 .ndo_start_xmit = bxcan_start_xmit, 884 - .ndo_change_mtu = can_change_mtu, 885 884 }; 886 885 887 886 static const struct ethtool_ops bxcan_ethtool_ops = {
-1
drivers/net/can/c_can/c_can_main.c
··· 1362 1362 .ndo_open = c_can_open, 1363 1363 .ndo_stop = c_can_close, 1364 1364 .ndo_start_xmit = c_can_start_xmit, 1365 - .ndo_change_mtu = can_change_mtu, 1366 1365 }; 1367 1366 1368 1367 int register_c_can_dev(struct net_device *dev)
-1
drivers/net/can/can327.c
··· 849 849 .ndo_open = can327_netdev_open, 850 850 .ndo_stop = can327_netdev_close, 851 851 .ndo_start_xmit = can327_netdev_start_xmit, 852 - .ndo_change_mtu = can_change_mtu, 853 852 }; 854 853 855 854 static const struct ethtool_ops can327_ethtool_ops = {
-1
drivers/net/can/cc770/cc770.c
··· 834 834 .ndo_open = cc770_open, 835 835 .ndo_stop = cc770_close, 836 836 .ndo_start_xmit = cc770_start_xmit, 837 - .ndo_change_mtu = can_change_mtu, 838 837 }; 839 838 840 839 static const struct ethtool_ops cc770_ethtool_ops = {
-1
drivers/net/can/ctucanfd/ctucanfd_base.c
··· 1301 1301 .ndo_open = ctucan_open, 1302 1302 .ndo_stop = ctucan_close, 1303 1303 .ndo_start_xmit = ctucan_start_xmit, 1304 - .ndo_change_mtu = can_change_mtu, 1305 1304 }; 1306 1305 1307 1306 static const struct ethtool_ops ctucan_ethtool_ops = {
-38
drivers/net/can/dev/dev.c
··· 359 359 } 360 360 } 361 361 362 - /* changing MTU and control mode for CAN/CANFD devices */ 363 - int can_change_mtu(struct net_device *dev, int new_mtu) 364 - { 365 - struct can_priv *priv = netdev_priv(dev); 366 - u32 ctrlmode_static = can_get_static_ctrlmode(priv); 367 - 368 - /* Do not allow changing the MTU while running */ 369 - if (dev->flags & IFF_UP) 370 - return -EBUSY; 371 - 372 - /* allow change of MTU according to the CANFD ability of the device */ 373 - switch (new_mtu) { 374 - case CAN_MTU: 375 - /* 'CANFD-only' controllers can not switch to CAN_MTU */ 376 - if (ctrlmode_static & CAN_CTRLMODE_FD) 377 - return -EINVAL; 378 - 379 - priv->ctrlmode &= ~CAN_CTRLMODE_FD; 380 - break; 381 - 382 - case CANFD_MTU: 383 - /* check for potential CANFD ability */ 384 - if (!(priv->ctrlmode_supported & CAN_CTRLMODE_FD) && 385 - !(ctrlmode_static & CAN_CTRLMODE_FD)) 386 - return -EINVAL; 387 - 388 - priv->ctrlmode |= CAN_CTRLMODE_FD; 389 - break; 390 - 391 - default: 392 - return -EINVAL; 393 - } 394 - 395 - WRITE_ONCE(dev->mtu, new_mtu); 396 - return 0; 397 - } 398 - EXPORT_SYMBOL_GPL(can_change_mtu); 399 - 400 362 /* helper to define static CAN controller features at device creation time */ 401 363 int can_set_static_ctrlmode(struct net_device *dev, u32 static_mode) 402 364 {
-1
drivers/net/can/esd/esd_402_pci-core.c
··· 86 86 .ndo_open = acc_open, 87 87 .ndo_stop = acc_close, 88 88 .ndo_start_xmit = acc_start_xmit, 89 - .ndo_change_mtu = can_change_mtu, 90 89 .ndo_eth_ioctl = can_eth_ioctl_hwts, 91 90 }; 92 91
-1
drivers/net/can/flexcan/flexcan-core.c
··· 1867 1867 .ndo_open = flexcan_open, 1868 1868 .ndo_stop = flexcan_close, 1869 1869 .ndo_start_xmit = flexcan_start_xmit, 1870 - .ndo_change_mtu = can_change_mtu, 1871 1870 }; 1872 1871 1873 1872 static int register_flexcandev(struct net_device *dev)
-1
drivers/net/can/grcan.c
··· 1561 1561 .ndo_open = grcan_open, 1562 1562 .ndo_stop = grcan_close, 1563 1563 .ndo_start_xmit = grcan_start_xmit, 1564 - .ndo_change_mtu = can_change_mtu, 1565 1564 }; 1566 1565 1567 1566 static const struct ethtool_ops grcan_ethtool_ops = {
-1
drivers/net/can/ifi_canfd/ifi_canfd.c
··· 944 944 .ndo_open = ifi_canfd_open, 945 945 .ndo_stop = ifi_canfd_close, 946 946 .ndo_start_xmit = ifi_canfd_start_xmit, 947 - .ndo_change_mtu = can_change_mtu, 948 947 }; 949 948 950 949 static const struct ethtool_ops ifi_canfd_ethtool_ops = {
-1
drivers/net/can/janz-ican3.c
··· 1752 1752 .ndo_open = ican3_open, 1753 1753 .ndo_stop = ican3_stop, 1754 1754 .ndo_start_xmit = ican3_xmit, 1755 - .ndo_change_mtu = can_change_mtu, 1756 1755 }; 1757 1756 1758 1757 static const struct ethtool_ops ican3_ethtool_ops = {
-1
drivers/net/can/kvaser_pciefd/kvaser_pciefd_core.c
··· 904 904 .ndo_stop = kvaser_pciefd_stop, 905 905 .ndo_eth_ioctl = can_eth_ioctl_hwts, 906 906 .ndo_start_xmit = kvaser_pciefd_start_xmit, 907 - .ndo_change_mtu = can_change_mtu, 908 907 }; 909 908 910 909 static int kvaser_pciefd_set_phys_id(struct net_device *netdev,
+187 -69
drivers/net/can/m_can/m_can.c
··· 23 23 #include <linux/pinctrl/consumer.h> 24 24 #include <linux/platform_device.h> 25 25 #include <linux/pm_runtime.h> 26 + #include <linux/reset.h> 26 27 27 28 #include "m_can.h" 28 29 ··· 387 386 size_t tries = 10; 388 387 389 388 if (!(mask & CCCR_INIT) && !(val_before & CCCR_INIT)) { 390 - dev_err(cdev->dev, 391 - "refusing to configure device when in normal mode\n"); 389 + netdev_err(cdev->net, 390 + "refusing to configure device when in normal mode\n"); 392 391 return -EBUSY; 393 392 } 394 393 ··· 452 451 { 453 452 if (cdev->active_interrupts == interrupts) 454 453 return; 455 - cdev->ops->write_reg(cdev, M_CAN_IE, interrupts); 454 + m_can_write(cdev, M_CAN_IE, interrupts); 456 455 cdev->active_interrupts = interrupts; 457 456 } 458 457 ··· 470 469 static inline void m_can_enable_all_interrupts(struct m_can_classdev *cdev) 471 470 { 472 471 if (!cdev->net->irq) { 473 - dev_dbg(cdev->dev, "Start hrtimer\n"); 472 + netdev_dbg(cdev->net, "Start hrtimer\n"); 474 473 hrtimer_start(&cdev->hrtimer, 475 474 ms_to_ktime(HRTIMER_POLL_INTERVAL_MS), 476 475 HRTIMER_MODE_REL_PINNED); ··· 486 485 m_can_write(cdev, M_CAN_ILE, 0x0); 487 486 488 487 if (!cdev->net->irq) { 489 - dev_dbg(cdev->dev, "Stop hrtimer\n"); 488 + netdev_dbg(cdev->net, "Stop hrtimer\n"); 490 489 hrtimer_try_to_cancel(&cdev->hrtimer); 491 490 } 492 491 } ··· 790 789 { 791 790 struct m_can_classdev *cdev = netdev_priv(dev); 792 791 int err; 792 + 793 + /* Avoid waking up the controller if the interface is down */ 794 + if (!(dev->flags & IFF_UP)) 795 + return 0; 793 796 794 797 err = m_can_clk_start(cdev); 795 798 if (err) ··· 1384 1379 .brp_inc = 1, 1385 1380 }; 1386 1381 1382 + static int m_can_init_ram(struct m_can_classdev *cdev) 1383 + { 1384 + int end, i, start; 1385 + int err = 0; 1386 + 1387 + /* initialize the entire Message RAM in use to avoid possible 1388 + * ECC/parity checksum errors when reading an uninitialized buffer 1389 + */ 1390 + start = cdev->mcfg[MRAM_SIDF].off; 1391 + end = cdev->mcfg[MRAM_TXB].off + 1392 + cdev->mcfg[MRAM_TXB].num * TXB_ELEMENT_SIZE; 1393 + 1394 + for (i = start; i < end; i += 4) { 1395 + err = m_can_fifo_write_no_off(cdev, i, 0x0); 1396 + if (err) 1397 + break; 1398 + } 1399 + 1400 + return err; 1401 + } 1402 + 1387 1403 static int m_can_set_bittiming(struct net_device *dev) 1388 1404 { 1389 1405 struct m_can_classdev *cdev = netdev_priv(dev); ··· 1490 1464 1491 1465 err = m_can_init_ram(cdev); 1492 1466 if (err) { 1493 - dev_err(cdev->dev, "Message RAM configuration failed\n"); 1467 + netdev_err(dev, "Message RAM configuration failed\n"); 1494 1468 return err; 1495 1469 } 1496 1470 ··· 1720 1694 /* Then clear the it again. */ 1721 1695 ret = m_can_cccr_update_bits(cdev, CCCR_NISO, 0); 1722 1696 if (ret) { 1723 - dev_err(cdev->dev, "failed to revert the NON-ISO bit in CCCR\n"); 1697 + netdev_err(cdev->net, "failed to revert the NON-ISO bit in CCCR\n"); 1724 1698 return ret; 1725 1699 } 1726 1700 ··· 1739 1713 m_can_version = m_can_check_core_release(cdev); 1740 1714 /* return if unsupported version */ 1741 1715 if (!m_can_version) { 1742 - dev_err(cdev->dev, "Unsupported version number: %2d", 1743 - m_can_version); 1716 + netdev_err(cdev->net, "Unsupported version number: %2d", 1717 + m_can_version); 1744 1718 return -EINVAL; 1745 1719 } 1746 1720 ··· 1798 1772 cdev->can.ctrlmode_supported |= CAN_CTRLMODE_FD_NON_ISO; 1799 1773 break; 1800 1774 default: 1801 - dev_err(cdev->dev, "Unsupported version number: %2d", 1802 - cdev->version); 1775 + netdev_err(cdev->net, "Unsupported version number: %2d", 1776 + cdev->version); 1803 1777 return -EINVAL; 1804 1778 } 1805 1779 ··· 1853 1827 1854 1828 close_candev(dev); 1855 1829 1830 + reset_control_assert(cdev->rst); 1856 1831 m_can_clk_stop(cdev); 1857 1832 phy_power_off(cdev->transceiver); 1858 1833 ··· 1977 1950 1978 1951 static void m_can_tx_submit(struct m_can_classdev *cdev) 1979 1952 { 1980 - if (cdev->version == 30) 1981 - return; 1982 - if (!cdev->is_peripheral) 1983 - return; 1984 - 1985 1953 m_can_write(cdev, M_CAN_TXBAR, cdev->tx_peripheral_submit); 1986 1954 cdev->tx_peripheral_submit = 0; 1987 1955 } ··· 2057 2035 return ret; 2058 2036 } 2059 2037 2060 - static enum hrtimer_restart hrtimer_callback(struct hrtimer *timer) 2038 + static enum hrtimer_restart m_can_polling_timer(struct hrtimer *timer) 2061 2039 { 2062 2040 struct m_can_classdev *cdev = container_of(timer, struct 2063 2041 m_can_classdev, hrtimer); ··· 2091 2069 if (err) 2092 2070 goto out_phy_power_off; 2093 2071 2072 + err = reset_control_deassert(cdev->rst); 2073 + if (err) 2074 + goto exit_disable_clks; 2075 + 2094 2076 /* open the can device */ 2095 2077 err = open_candev(dev); 2096 2078 if (err) { 2097 2079 netdev_err(dev, "failed to open can device\n"); 2098 - goto exit_disable_clks; 2080 + goto out_reset_control_assert; 2099 2081 } 2100 2082 2101 2083 if (cdev->is_peripheral) ··· 2155 2129 else 2156 2130 napi_disable(&cdev->napi); 2157 2131 close_candev(dev); 2132 + out_reset_control_assert: 2133 + reset_control_assert(cdev->rst); 2158 2134 exit_disable_clks: 2159 2135 m_can_clk_stop(cdev); 2160 2136 out_phy_power_off: ··· 2168 2140 .ndo_open = m_can_open, 2169 2141 .ndo_stop = m_can_close, 2170 2142 .ndo_start_xmit = m_can_start_xmit, 2171 - .ndo_change_mtu = can_change_mtu, 2172 2143 }; 2173 2144 2174 2145 static int m_can_get_coalesce(struct net_device *dev, ··· 2258 2231 return 0; 2259 2232 } 2260 2233 2234 + static void m_can_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 2235 + { 2236 + struct m_can_classdev *cdev = netdev_priv(dev); 2237 + 2238 + wol->supported = device_can_wakeup(cdev->dev) ? WAKE_PHY : 0; 2239 + wol->wolopts = device_may_wakeup(cdev->dev) ? WAKE_PHY : 0; 2240 + } 2241 + 2242 + static int m_can_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 2243 + { 2244 + struct m_can_classdev *cdev = netdev_priv(dev); 2245 + bool wol_enable = !!(wol->wolopts & WAKE_PHY); 2246 + int ret; 2247 + 2248 + if (wol->wolopts & ~WAKE_PHY) 2249 + return -EINVAL; 2250 + 2251 + if (wol_enable == device_may_wakeup(cdev->dev)) 2252 + return 0; 2253 + 2254 + ret = device_set_wakeup_enable(cdev->dev, wol_enable); 2255 + if (ret) { 2256 + netdev_err(cdev->net, "Failed to set wakeup enable %pE\n", 2257 + ERR_PTR(ret)); 2258 + return ret; 2259 + } 2260 + 2261 + if (!IS_ERR_OR_NULL(cdev->pinctrl_state_wakeup)) { 2262 + if (wol_enable) 2263 + ret = pinctrl_select_state(cdev->pinctrl, cdev->pinctrl_state_wakeup); 2264 + else 2265 + ret = pinctrl_pm_select_default_state(cdev->dev); 2266 + 2267 + if (ret) { 2268 + netdev_err(cdev->net, "Failed to select pinctrl state %pE\n", 2269 + ERR_PTR(ret)); 2270 + goto err_wakeup_enable; 2271 + } 2272 + } 2273 + 2274 + return 0; 2275 + 2276 + err_wakeup_enable: 2277 + /* Revert wakeup enable */ 2278 + device_set_wakeup_enable(cdev->dev, !wol_enable); 2279 + 2280 + return ret; 2281 + } 2282 + 2261 2283 static const struct ethtool_ops m_can_ethtool_ops_coalescing = { 2262 2284 .supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS_IRQ | 2263 2285 ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ | ··· 2316 2240 .get_ts_info = ethtool_op_get_ts_info, 2317 2241 .get_coalesce = m_can_get_coalesce, 2318 2242 .set_coalesce = m_can_set_coalesce, 2243 + .get_wol = m_can_get_wol, 2244 + .set_wol = m_can_set_wol, 2319 2245 }; 2320 2246 2321 2247 static const struct ethtool_ops m_can_ethtool_ops = { 2322 2248 .get_ts_info = ethtool_op_get_ts_info, 2249 + .get_wol = m_can_get_wol, 2250 + .set_wol = m_can_set_wol, 2323 2251 }; 2324 2252 2325 2253 static int register_m_can_dev(struct m_can_classdev *cdev) ··· 2347 2267 total_size = cdev->mcfg[MRAM_TXB].off - cdev->mcfg[MRAM_SIDF].off + 2348 2268 cdev->mcfg[MRAM_TXB].num * TXB_ELEMENT_SIZE; 2349 2269 if (total_size > mram_max_size) { 2350 - dev_err(cdev->dev, "Total size of mram config(%u) exceeds mram(%u)\n", 2351 - total_size, mram_max_size); 2270 + netdev_err(cdev->net, "Total size of mram config(%u) exceeds mram(%u)\n", 2271 + total_size, mram_max_size); 2352 2272 return -EINVAL; 2353 2273 } 2354 2274 ··· 2383 2303 cdev->mcfg[MRAM_TXB].num = mram_config_vals[7] & 2384 2304 FIELD_MAX(TXBC_NDTB_MASK); 2385 2305 2386 - dev_dbg(cdev->dev, 2387 - "sidf 0x%x %d xidf 0x%x %d rxf0 0x%x %d rxf1 0x%x %d rxb 0x%x %d txe 0x%x %d txb 0x%x %d\n", 2388 - cdev->mcfg[MRAM_SIDF].off, cdev->mcfg[MRAM_SIDF].num, 2389 - cdev->mcfg[MRAM_XIDF].off, cdev->mcfg[MRAM_XIDF].num, 2390 - cdev->mcfg[MRAM_RXF0].off, cdev->mcfg[MRAM_RXF0].num, 2391 - cdev->mcfg[MRAM_RXF1].off, cdev->mcfg[MRAM_RXF1].num, 2392 - cdev->mcfg[MRAM_RXB].off, cdev->mcfg[MRAM_RXB].num, 2393 - cdev->mcfg[MRAM_TXE].off, cdev->mcfg[MRAM_TXE].num, 2394 - cdev->mcfg[MRAM_TXB].off, cdev->mcfg[MRAM_TXB].num); 2306 + netdev_dbg(cdev->net, 2307 + "sidf 0x%x %d xidf 0x%x %d rxf0 0x%x %d rxf1 0x%x %d rxb 0x%x %d txe 0x%x %d txb 0x%x %d\n", 2308 + cdev->mcfg[MRAM_SIDF].off, cdev->mcfg[MRAM_SIDF].num, 2309 + cdev->mcfg[MRAM_XIDF].off, cdev->mcfg[MRAM_XIDF].num, 2310 + cdev->mcfg[MRAM_RXF0].off, cdev->mcfg[MRAM_RXF0].num, 2311 + cdev->mcfg[MRAM_RXF1].off, cdev->mcfg[MRAM_RXF1].num, 2312 + cdev->mcfg[MRAM_RXB].off, cdev->mcfg[MRAM_RXB].num, 2313 + cdev->mcfg[MRAM_TXE].off, cdev->mcfg[MRAM_TXE].num, 2314 + cdev->mcfg[MRAM_TXB].off, cdev->mcfg[MRAM_TXB].num); 2395 2315 } 2396 - 2397 - int m_can_init_ram(struct m_can_classdev *cdev) 2398 - { 2399 - int end, i, start; 2400 - int err = 0; 2401 - 2402 - /* initialize the entire Message RAM in use to avoid possible 2403 - * ECC/parity checksum errors when reading an uninitialized buffer 2404 - */ 2405 - start = cdev->mcfg[MRAM_SIDF].off; 2406 - end = cdev->mcfg[MRAM_TXB].off + 2407 - cdev->mcfg[MRAM_TXB].num * TXB_ELEMENT_SIZE; 2408 - 2409 - for (i = start; i < end; i += 4) { 2410 - err = m_can_fifo_write_no_off(cdev, i, 0x0); 2411 - if (err) 2412 - break; 2413 - } 2414 - 2415 - return err; 2416 - } 2417 - EXPORT_SYMBOL_GPL(m_can_init_ram); 2418 2316 2419 2317 int m_can_class_get_clocks(struct m_can_classdev *cdev) 2420 2318 { ··· 2402 2344 cdev->cclk = devm_clk_get(cdev->dev, "cclk"); 2403 2345 2404 2346 if (IS_ERR(cdev->hclk) || IS_ERR(cdev->cclk)) { 2405 - dev_err(cdev->dev, "no clock found\n"); 2347 + netdev_err(cdev->net, "no clock found\n"); 2406 2348 ret = -ENODEV; 2407 2349 } 2408 2350 2409 2351 return ret; 2410 2352 } 2411 2353 EXPORT_SYMBOL_GPL(m_can_class_get_clocks); 2354 + 2355 + static bool m_can_class_wakeup_pinctrl_enabled(struct m_can_classdev *class_dev) 2356 + { 2357 + return device_may_wakeup(class_dev->dev) && class_dev->pinctrl_state_wakeup; 2358 + } 2359 + 2360 + static int m_can_class_parse_pinctrl(struct m_can_classdev *class_dev) 2361 + { 2362 + struct device *dev = class_dev->dev; 2363 + int ret; 2364 + 2365 + class_dev->pinctrl = devm_pinctrl_get(dev); 2366 + if (IS_ERR(class_dev->pinctrl)) { 2367 + ret = PTR_ERR(class_dev->pinctrl); 2368 + class_dev->pinctrl = NULL; 2369 + 2370 + if (ret == -ENODEV) 2371 + return 0; 2372 + 2373 + return dev_err_probe(dev, ret, "Failed to get pinctrl\n"); 2374 + } 2375 + 2376 + class_dev->pinctrl_state_wakeup = 2377 + pinctrl_lookup_state(class_dev->pinctrl, "wakeup"); 2378 + if (IS_ERR(class_dev->pinctrl_state_wakeup)) { 2379 + ret = PTR_ERR(class_dev->pinctrl_state_wakeup); 2380 + class_dev->pinctrl_state_wakeup = NULL; 2381 + 2382 + if (ret == -ENODEV) 2383 + return 0; 2384 + 2385 + return dev_err_probe(dev, ret, "Failed to lookup pinctrl wakeup state\n"); 2386 + } 2387 + 2388 + return 0; 2389 + } 2412 2390 2413 2391 struct m_can_classdev *m_can_class_allocate_dev(struct device *dev, 2414 2392 int sizeof_priv) ··· 2461 2367 sizeof(mram_config_vals) / 4); 2462 2368 if (ret) { 2463 2369 dev_err(dev, "Could not get Message RAM configuration."); 2464 - goto out; 2370 + return ERR_PTR(ret); 2465 2371 } 2372 + 2373 + if (dev->of_node && of_property_read_bool(dev->of_node, "wakeup-source")) 2374 + device_set_wakeup_capable(dev, true); 2466 2375 2467 2376 /* Get TX FIFO size 2468 2377 * Defines the total amount of echo buffers for loopback ··· 2476 2379 net_dev = alloc_candev(sizeof_priv, tx_fifo_size); 2477 2380 if (!net_dev) { 2478 2381 dev_err(dev, "Failed to allocate CAN device"); 2479 - goto out; 2382 + return ERR_PTR(-ENOMEM); 2480 2383 } 2481 2384 2482 2385 class_dev = netdev_priv(net_dev); ··· 2486 2389 2487 2390 m_can_of_parse_mram(class_dev, mram_config_vals); 2488 2391 spin_lock_init(&class_dev->tx_handling_spinlock); 2489 - out: 2392 + 2393 + ret = m_can_class_parse_pinctrl(class_dev); 2394 + if (ret) 2395 + goto err_free_candev; 2396 + 2490 2397 return class_dev; 2398 + 2399 + err_free_candev: 2400 + free_candev(net_dev); 2401 + return ERR_PTR(ret); 2491 2402 } 2492 2403 EXPORT_SYMBOL_GPL(m_can_class_allocate_dev); 2493 2404 ··· 2516 2411 devm_kzalloc(cdev->dev, 2517 2412 cdev->tx_fifo_size * sizeof(*cdev->tx_ops), 2518 2413 GFP_KERNEL); 2519 - if (!cdev->tx_ops) { 2520 - dev_err(cdev->dev, "Failed to allocate tx_ops for workqueue\n"); 2414 + if (!cdev->tx_ops) 2521 2415 return -ENOMEM; 2522 - } 2523 2416 } 2417 + 2418 + cdev->rst = devm_reset_control_get_optional_shared(cdev->dev, NULL); 2419 + if (IS_ERR(cdev->rst)) 2420 + return dev_err_probe(cdev->dev, PTR_ERR(cdev->rst), 2421 + "Failed to get reset line\n"); 2524 2422 2525 2423 ret = m_can_clk_start(cdev); 2526 2424 if (ret) 2527 2425 return ret; 2528 2426 2427 + ret = reset_control_deassert(cdev->rst); 2428 + if (ret) 2429 + goto clk_disable; 2430 + 2529 2431 if (cdev->is_peripheral) { 2530 2432 ret = can_rx_offload_add_manual(cdev->net, &cdev->offload, 2531 2433 NAPI_POLL_WEIGHT); 2532 2434 if (ret) 2533 - goto clk_disable; 2435 + goto out_reset_control_assert; 2534 2436 } 2535 2437 2536 2438 if (!cdev->net->irq) { 2537 - dev_dbg(cdev->dev, "Polling enabled, initialize hrtimer"); 2538 - hrtimer_setup(&cdev->hrtimer, &hrtimer_callback, CLOCK_MONOTONIC, 2439 + netdev_dbg(cdev->net, "Polling enabled, initialize hrtimer"); 2440 + hrtimer_setup(&cdev->hrtimer, m_can_polling_timer, CLOCK_MONOTONIC, 2539 2441 HRTIMER_MODE_REL_PINNED); 2540 2442 } else { 2541 2443 hrtimer_setup(&cdev->hrtimer, m_can_coalescing_timer, CLOCK_MONOTONIC, ··· 2555 2443 2556 2444 ret = register_m_can_dev(cdev); 2557 2445 if (ret) { 2558 - dev_err(cdev->dev, "registering %s failed (err=%d)\n", 2559 - cdev->net->name, ret); 2446 + netdev_err(cdev->net, "registering %s failed (err=%d)\n", 2447 + cdev->net->name, ret); 2560 2448 goto rx_offload_del; 2561 2449 } 2562 2450 2563 2451 of_can_transceiver(cdev->net); 2564 2452 2565 - dev_info(cdev->dev, "%s device registered (irq=%d, version=%d)\n", 2566 - KBUILD_MODNAME, cdev->net->irq, cdev->version); 2453 + netdev_info(cdev->net, "device registered (irq=%d, version=%d)\n", 2454 + cdev->net->irq, cdev->version); 2567 2455 2568 2456 /* Probe finished 2569 - * Stop clocks. They will be reactivated once the M_CAN device is opened 2457 + * Assert reset and stop clocks. 2458 + * They will be reactivated once the M_CAN device is opened 2570 2459 */ 2460 + reset_control_assert(cdev->rst); 2571 2461 m_can_clk_stop(cdev); 2572 2462 2573 2463 return 0; ··· 2577 2463 rx_offload_del: 2578 2464 if (cdev->is_peripheral) 2579 2465 can_rx_offload_del(&cdev->offload); 2466 + out_reset_control_assert: 2467 + reset_control_assert(cdev->rst); 2580 2468 clk_disable: 2581 2469 m_can_clk_stop(cdev); 2582 2470 ··· 2622 2506 cdev->can.state = CAN_STATE_SLEEPING; 2623 2507 } 2624 2508 2625 - pinctrl_pm_select_sleep_state(dev); 2509 + if (!m_can_class_wakeup_pinctrl_enabled(cdev)) 2510 + pinctrl_pm_select_sleep_state(dev); 2626 2511 2627 2512 return ret; 2628 2513 } ··· 2635 2518 struct net_device *ndev = cdev->net; 2636 2519 int ret = 0; 2637 2520 2638 - pinctrl_pm_select_default_state(dev); 2521 + if (!m_can_class_wakeup_pinctrl_enabled(cdev)) 2522 + pinctrl_pm_select_default_state(dev); 2639 2523 2640 2524 if (netif_running(ndev)) { 2641 2525 ret = m_can_clk_start(cdev);
+4 -1
drivers/net/can/m_can/m_can.h
··· 86 86 struct device *dev; 87 87 struct clk *hclk; 88 88 struct clk *cclk; 89 + struct reset_control *rst; 89 90 90 91 struct workqueue_struct *tx_wq; 91 92 struct phy *transceiver; ··· 129 128 struct mram_cfg mcfg[MRAM_CFG_NUM]; 130 129 131 130 struct hrtimer hrtimer; 131 + 132 + struct pinctrl *pinctrl; 133 + struct pinctrl_state *pinctrl_state_wakeup; 132 134 }; 133 135 134 136 struct m_can_classdev *m_can_class_allocate_dev(struct device *dev, int sizeof_priv); ··· 139 135 int m_can_class_register(struct m_can_classdev *cdev); 140 136 void m_can_class_unregister(struct m_can_classdev *cdev); 141 137 int m_can_class_get_clocks(struct m_can_classdev *cdev); 142 - int m_can_init_ram(struct m_can_classdev *priv); 143 138 int m_can_check_mram_cfg(struct m_can_classdev *cdev, u32 mram_max_size); 144 139 145 140 int m_can_class_suspend(struct device *dev);
+2 -2
drivers/net/can/m_can/m_can_pci.c
··· 111 111 112 112 mcan_class = m_can_class_allocate_dev(&pci->dev, 113 113 sizeof(struct m_can_pci_priv)); 114 - if (!mcan_class) 115 - return -ENOMEM; 114 + if (IS_ERR(mcan_class)) 115 + return PTR_ERR(mcan_class); 116 116 117 117 priv = cdev_to_priv(mcan_class); 118 118
+2 -2
drivers/net/can/m_can/m_can_platform.c
··· 87 87 88 88 mcan_class = m_can_class_allocate_dev(&pdev->dev, 89 89 sizeof(struct m_can_plat_priv)); 90 - if (!mcan_class) 91 - return -ENOMEM; 90 + if (IS_ERR(mcan_class)) 91 + return PTR_ERR(mcan_class); 92 92 93 93 priv = cdev_to_priv(mcan_class); 94 94
+2 -2
drivers/net/can/m_can/tcan4x5x-core.c
··· 416 416 417 417 mcan_class = m_can_class_allocate_dev(&spi->dev, 418 418 sizeof(struct tcan4x5x_priv)); 419 - if (!mcan_class) 420 - return -ENOMEM; 419 + if (IS_ERR(mcan_class)) 420 + return PTR_ERR(mcan_class); 421 421 422 422 ret = m_can_check_mram_cfg(mcan_class, TCAN4X5X_MRAM_SIZE); 423 423 if (ret)
-1
drivers/net/can/mscan/mscan.c
··· 607 607 .ndo_open = mscan_open, 608 608 .ndo_stop = mscan_close, 609 609 .ndo_start_xmit = mscan_start_xmit, 610 - .ndo_change_mtu = can_change_mtu, 611 610 }; 612 611 613 612 static const struct ethtool_ops mscan_ethtool_ops = {
-1
drivers/net/can/peak_canfd/peak_canfd.c
··· 773 773 .ndo_stop = peak_canfd_close, 774 774 .ndo_eth_ioctl = peak_eth_ioctl, 775 775 .ndo_start_xmit = peak_canfd_start_xmit, 776 - .ndo_change_mtu = can_change_mtu, 777 776 }; 778 777 779 778 static int peak_get_ts_info(struct net_device *dev,
-1
drivers/net/can/rcar/rcar_can.c
··· 635 635 .ndo_open = rcar_can_open, 636 636 .ndo_stop = rcar_can_close, 637 637 .ndo_start_xmit = rcar_can_start_xmit, 638 - .ndo_change_mtu = can_change_mtu, 639 638 }; 640 639 641 640 static const struct ethtool_ops rcar_can_ethtool_ops = {
-1
drivers/net/can/rcar/rcar_canfd.c
··· 1818 1818 .ndo_open = rcar_canfd_open, 1819 1819 .ndo_stop = rcar_canfd_close, 1820 1820 .ndo_start_xmit = rcar_canfd_start_xmit, 1821 - .ndo_change_mtu = can_change_mtu, 1822 1821 }; 1823 1822 1824 1823 static const struct ethtool_ops rcar_canfd_ethtool_ops = {
-1
drivers/net/can/rockchip/rockchip_canfd-core.c
··· 761 761 .ndo_open = rkcanfd_open, 762 762 .ndo_stop = rkcanfd_stop, 763 763 .ndo_start_xmit = rkcanfd_start_xmit, 764 - .ndo_change_mtu = can_change_mtu, 765 764 }; 766 765 767 766 static int __maybe_unused rkcanfd_runtime_suspend(struct device *dev)
-1
drivers/net/can/sja1000/sja1000.c
··· 697 697 .ndo_open = sja1000_open, 698 698 .ndo_stop = sja1000_close, 699 699 .ndo_start_xmit = sja1000_start_xmit, 700 - .ndo_change_mtu = can_change_mtu, 701 700 }; 702 701 703 702 static const struct ethtool_ops sja1000_ethtool_ops = {
-1
drivers/net/can/slcan/slcan-core.c
··· 774 774 .ndo_open = slcan_netdev_open, 775 775 .ndo_stop = slcan_netdev_close, 776 776 .ndo_start_xmit = slcan_netdev_xmit, 777 - .ndo_change_mtu = can_change_mtu, 778 777 }; 779 778 780 779 /******************************************
-1
drivers/net/can/softing/softing_main.c
··· 609 609 .ndo_open = softing_netdev_open, 610 610 .ndo_stop = softing_netdev_stop, 611 611 .ndo_start_xmit = softing_netdev_start_xmit, 612 - .ndo_change_mtu = can_change_mtu, 613 612 }; 614 613 615 614 static const struct ethtool_ops softing_ethtool_ops = {
-1
drivers/net/can/spi/hi311x.c
··· 799 799 .ndo_open = hi3110_open, 800 800 .ndo_stop = hi3110_stop, 801 801 .ndo_start_xmit = hi3110_hard_start_xmit, 802 - .ndo_change_mtu = can_change_mtu, 803 802 }; 804 803 805 804 static const struct ethtool_ops hi3110_ethtool_ops = {
-1
drivers/net/can/spi/mcp251x.c
··· 1270 1270 .ndo_open = mcp251x_open, 1271 1271 .ndo_stop = mcp251x_stop, 1272 1272 .ndo_start_xmit = mcp251x_hard_start_xmit, 1273 - .ndo_change_mtu = can_change_mtu, 1274 1273 }; 1275 1274 1276 1275 static const struct ethtool_ops mcp251x_ethtool_ops = {
-1
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
··· 1715 1715 .ndo_stop = mcp251xfd_stop, 1716 1716 .ndo_start_xmit = mcp251xfd_start_xmit, 1717 1717 .ndo_eth_ioctl = can_eth_ioctl_hwts, 1718 - .ndo_change_mtu = can_change_mtu, 1719 1718 }; 1720 1719 1721 1720 static void
-1
drivers/net/can/sun4i_can.c
··· 768 768 .ndo_open = sun4ican_open, 769 769 .ndo_stop = sun4ican_close, 770 770 .ndo_start_xmit = sun4ican_start_xmit, 771 - .ndo_change_mtu = can_change_mtu, 772 771 }; 773 772 774 773 static const struct ethtool_ops sun4ican_ethtool_ops = {
-1
drivers/net/can/ti_hecc.c
··· 829 829 .ndo_open = ti_hecc_open, 830 830 .ndo_stop = ti_hecc_close, 831 831 .ndo_start_xmit = ti_hecc_xmit, 832 - .ndo_change_mtu = can_change_mtu, 833 832 }; 834 833 835 834 static const struct ethtool_ops ti_hecc_ethtool_ops = {
-1
drivers/net/can/usb/ems_usb.c
··· 885 885 .ndo_open = ems_usb_open, 886 886 .ndo_stop = ems_usb_close, 887 887 .ndo_start_xmit = ems_usb_start_xmit, 888 - .ndo_change_mtu = can_change_mtu, 889 888 }; 890 889 891 890 static const struct ethtool_ops ems_usb_ethtool_ops = {
-1
drivers/net/can/usb/esd_usb.c
··· 1011 1011 .ndo_open = esd_usb_open, 1012 1012 .ndo_stop = esd_usb_close, 1013 1013 .ndo_start_xmit = esd_usb_start_xmit, 1014 - .ndo_change_mtu = can_change_mtu, 1015 1014 }; 1016 1015 1017 1016 static const struct ethtool_ops esd_usb_ethtool_ops = {
-1
drivers/net/can/usb/etas_es58x/es58x_core.c
··· 1977 1977 .ndo_stop = es58x_stop, 1978 1978 .ndo_start_xmit = es58x_start_xmit, 1979 1979 .ndo_eth_ioctl = can_eth_ioctl_hwts, 1980 - .ndo_change_mtu = can_change_mtu, 1981 1980 }; 1982 1981 1983 1982 static const struct ethtool_ops es58x_ethtool_ops = {
-1
drivers/net/can/usb/f81604.c
··· 1052 1052 .ndo_open = f81604_open, 1053 1053 .ndo_stop = f81604_close, 1054 1054 .ndo_start_xmit = f81604_start_xmit, 1055 - .ndo_change_mtu = can_change_mtu, 1056 1055 }; 1057 1056 1058 1057 static const struct can_bittiming_const f81604_bittiming_const = {
-1
drivers/net/can/usb/gs_usb.c
··· 1101 1101 .ndo_open = gs_can_open, 1102 1102 .ndo_stop = gs_can_close, 1103 1103 .ndo_start_xmit = gs_can_start_xmit, 1104 - .ndo_change_mtu = can_change_mtu, 1105 1104 .ndo_eth_ioctl = gs_can_eth_ioctl, 1106 1105 }; 1107 1106
-1
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
··· 786 786 .ndo_stop = kvaser_usb_close, 787 787 .ndo_eth_ioctl = can_eth_ioctl_hwts, 788 788 .ndo_start_xmit = kvaser_usb_start_xmit, 789 - .ndo_change_mtu = can_change_mtu, 790 789 }; 791 790 792 791 static const struct ethtool_ops kvaser_usb_ethtool_ops = {
-1
drivers/net/can/usb/mcba_usb.c
··· 761 761 .ndo_open = mcba_usb_open, 762 762 .ndo_stop = mcba_usb_close, 763 763 .ndo_start_xmit = mcba_usb_start_xmit, 764 - .ndo_change_mtu = can_change_mtu, 765 764 }; 766 765 767 766 static const struct ethtool_ops mcba_ethtool_ops = {
-1
drivers/net/can/usb/nct6694_canfd.c
··· 690 690 .ndo_open = nct6694_canfd_open, 691 691 .ndo_stop = nct6694_canfd_close, 692 692 .ndo_start_xmit = nct6694_canfd_start_xmit, 693 - .ndo_change_mtu = can_change_mtu, 694 693 }; 695 694 696 695 static const struct ethtool_ops nct6694_canfd_ethtool_ops = {
-1
drivers/net/can/usb/peak_usb/pcan_usb_core.c
··· 814 814 .ndo_stop = peak_usb_ndo_stop, 815 815 .ndo_eth_ioctl = peak_eth_ioctl, 816 816 .ndo_start_xmit = peak_usb_ndo_start_xmit, 817 - .ndo_change_mtu = can_change_mtu, 818 817 }; 819 818 820 819 /* CAN-USB devices generally handle 32-bit CAN channel IDs.
-1
drivers/net/can/usb/ucan.c
··· 1233 1233 .ndo_open = ucan_open, 1234 1234 .ndo_stop = ucan_close, 1235 1235 .ndo_start_xmit = ucan_start_xmit, 1236 - .ndo_change_mtu = can_change_mtu, 1237 1236 }; 1238 1237 1239 1238 static const struct ethtool_ops ucan_ethtool_ops = {
-1
drivers/net/can/usb/usb_8dev.c
··· 868 868 .ndo_open = usb_8dev_open, 869 869 .ndo_stop = usb_8dev_close, 870 870 .ndo_start_xmit = usb_8dev_start_xmit, 871 - .ndo_change_mtu = can_change_mtu, 872 871 }; 873 872 874 873 static const struct ethtool_ops usb_8dev_ethtool_ops = {
-1
drivers/net/can/xilinx_can.c
··· 1702 1702 .ndo_open = xcan_open, 1703 1703 .ndo_stop = xcan_close, 1704 1704 .ndo_start_xmit = xcan_start_xmit, 1705 - .ndo_change_mtu = can_change_mtu, 1706 1705 }; 1707 1706 1708 1707 static const struct ethtool_ops xcan_ethtool_ops = {
-1
include/linux/can/dev.h
··· 127 127 int open_candev(struct net_device *dev); 128 128 void close_candev(struct net_device *dev); 129 129 void can_set_default_mtu(struct net_device *dev); 130 - int can_change_mtu(struct net_device *dev, int new_mtu); 131 130 int __must_check can_set_static_ctrlmode(struct net_device *dev, 132 131 u32 static_mode); 133 132 int can_eth_ioctl_hwts(struct net_device *netdev, struct ifreq *ifr, int cmd);