18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* drivers/net/ethernet/micrel/ks8851.c 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright 2009 Simtec Electronics 58c2ecf20Sopenharmony_ci * http://www.simtec.co.uk/ 68c2ecf20Sopenharmony_ci * Ben Dooks <ben@simtec.co.uk> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#define DEBUG 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 148c2ecf20Sopenharmony_ci#include <linux/module.h> 158c2ecf20Sopenharmony_ci#include <linux/kernel.h> 168c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 178c2ecf20Sopenharmony_ci#include <linux/etherdevice.h> 188c2ecf20Sopenharmony_ci#include <linux/ethtool.h> 198c2ecf20Sopenharmony_ci#include <linux/iopoll.h> 208c2ecf20Sopenharmony_ci#include <linux/mii.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 238c2ecf20Sopenharmony_ci#include <linux/of_net.h> 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#include "ks8851.h" 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistatic int msg_enable; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define BE3 0x8000 /* Byte Enable 3 */ 308c2ecf20Sopenharmony_ci#define BE2 0x4000 /* Byte Enable 2 */ 318c2ecf20Sopenharmony_ci#define BE1 0x2000 /* Byte Enable 1 */ 328c2ecf20Sopenharmony_ci#define BE0 0x1000 /* Byte Enable 0 */ 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/** 358c2ecf20Sopenharmony_ci * struct ks8851_net_par - KS8851 Parallel driver private data 368c2ecf20Sopenharmony_ci * @ks8851: KS8851 driver common private data 378c2ecf20Sopenharmony_ci * @lock: Lock to ensure that the device is not accessed when busy. 388c2ecf20Sopenharmony_ci * @hw_addr : start address of data register. 398c2ecf20Sopenharmony_ci * @hw_addr_cmd : start address of command register. 408c2ecf20Sopenharmony_ci * @cmd_reg_cache : command register cached. 418c2ecf20Sopenharmony_ci * 428c2ecf20Sopenharmony_ci * The @lock ensures that the chip is protected when certain operations are 438c2ecf20Sopenharmony_ci * in progress. When the read or write packet transfer is in progress, most 448c2ecf20Sopenharmony_ci * of the chip registers are not accessible until the transfer is finished 458c2ecf20Sopenharmony_ci * and the DMA has been de-asserted. 468c2ecf20Sopenharmony_ci */ 478c2ecf20Sopenharmony_cistruct ks8851_net_par { 488c2ecf20Sopenharmony_ci struct ks8851_net ks8851; 498c2ecf20Sopenharmony_ci spinlock_t lock; 508c2ecf20Sopenharmony_ci void __iomem *hw_addr; 518c2ecf20Sopenharmony_ci void __iomem *hw_addr_cmd; 528c2ecf20Sopenharmony_ci u16 cmd_reg_cache; 538c2ecf20Sopenharmony_ci}; 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#define to_ks8851_par(ks) container_of((ks), struct ks8851_net_par, ks8851) 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci/** 588c2ecf20Sopenharmony_ci * ks8851_lock_par - register access lock 598c2ecf20Sopenharmony_ci * @ks: The chip state 608c2ecf20Sopenharmony_ci * @flags: Spinlock flags 618c2ecf20Sopenharmony_ci * 628c2ecf20Sopenharmony_ci * Claim chip register access lock 638c2ecf20Sopenharmony_ci */ 648c2ecf20Sopenharmony_cistatic void ks8851_lock_par(struct ks8851_net *ks, unsigned long *flags) 658c2ecf20Sopenharmony_ci{ 668c2ecf20Sopenharmony_ci struct ks8851_net_par *ksp = to_ks8851_par(ks); 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci spin_lock_irqsave(&ksp->lock, *flags); 698c2ecf20Sopenharmony_ci} 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci/** 728c2ecf20Sopenharmony_ci * ks8851_unlock_par - register access unlock 738c2ecf20Sopenharmony_ci * @ks: The chip state 748c2ecf20Sopenharmony_ci * @flags: Spinlock flags 758c2ecf20Sopenharmony_ci * 768c2ecf20Sopenharmony_ci * Release chip register access lock 778c2ecf20Sopenharmony_ci */ 788c2ecf20Sopenharmony_cistatic void ks8851_unlock_par(struct ks8851_net *ks, unsigned long *flags) 798c2ecf20Sopenharmony_ci{ 808c2ecf20Sopenharmony_ci struct ks8851_net_par *ksp = to_ks8851_par(ks); 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&ksp->lock, *flags); 838c2ecf20Sopenharmony_ci} 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci/** 868c2ecf20Sopenharmony_ci * ks_check_endian - Check whether endianness of the bus is correct 878c2ecf20Sopenharmony_ci * @ks : The chip information 888c2ecf20Sopenharmony_ci * 898c2ecf20Sopenharmony_ci * The KS8851-16MLL EESK pin allows selecting the endianness of the 16bit 908c2ecf20Sopenharmony_ci * bus. To maintain optimum performance, the bus endianness should be set 918c2ecf20Sopenharmony_ci * such that it matches the endianness of the CPU. 928c2ecf20Sopenharmony_ci */ 938c2ecf20Sopenharmony_cistatic int ks_check_endian(struct ks8851_net *ks) 948c2ecf20Sopenharmony_ci{ 958c2ecf20Sopenharmony_ci struct ks8851_net_par *ksp = to_ks8851_par(ks); 968c2ecf20Sopenharmony_ci u16 cider; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci /* 998c2ecf20Sopenharmony_ci * Read CIDER register first, however read it the "wrong" way around. 1008c2ecf20Sopenharmony_ci * If the endian strap on the KS8851-16MLL in incorrect and the chip 1018c2ecf20Sopenharmony_ci * is operating in different endianness than the CPU, then the meaning 1028c2ecf20Sopenharmony_ci * of BE[3:0] byte-enable bits is also swapped such that: 1038c2ecf20Sopenharmony_ci * BE[3,2,1,0] becomes BE[1,0,3,2] 1048c2ecf20Sopenharmony_ci * 1058c2ecf20Sopenharmony_ci * Luckily for us, the byte-enable bits are the top four MSbits of 1068c2ecf20Sopenharmony_ci * the address register and the CIDER register is at offset 0xc0. 1078c2ecf20Sopenharmony_ci * Hence, by reading address 0xc0c0, which is not impacted by endian 1088c2ecf20Sopenharmony_ci * swapping, we assert either BE[3:2] or BE[1:0] while reading the 1098c2ecf20Sopenharmony_ci * CIDER register. 1108c2ecf20Sopenharmony_ci * 1118c2ecf20Sopenharmony_ci * If the bus configuration is correct, reading 0xc0c0 asserts 1128c2ecf20Sopenharmony_ci * BE[3:2] and this read returns 0x0000, because to read register 1138c2ecf20Sopenharmony_ci * with bottom two LSbits of address set to 0, BE[1:0] must be 1148c2ecf20Sopenharmony_ci * asserted. 1158c2ecf20Sopenharmony_ci * 1168c2ecf20Sopenharmony_ci * If the bus configuration is NOT correct, reading 0xc0c0 asserts 1178c2ecf20Sopenharmony_ci * BE[1:0] and this read returns non-zero 0x8872 value. 1188c2ecf20Sopenharmony_ci */ 1198c2ecf20Sopenharmony_ci iowrite16(BE3 | BE2 | KS_CIDER, ksp->hw_addr_cmd); 1208c2ecf20Sopenharmony_ci cider = ioread16(ksp->hw_addr); 1218c2ecf20Sopenharmony_ci if (!cider) 1228c2ecf20Sopenharmony_ci return 0; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci netdev_err(ks->netdev, "incorrect EESK endian strap setting\n"); 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci return -EINVAL; 1278c2ecf20Sopenharmony_ci} 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci/** 1308c2ecf20Sopenharmony_ci * ks8851_wrreg16_par - write 16bit register value to chip 1318c2ecf20Sopenharmony_ci * @ks: The chip state 1328c2ecf20Sopenharmony_ci * @reg: The register address 1338c2ecf20Sopenharmony_ci * @val: The value to write 1348c2ecf20Sopenharmony_ci * 1358c2ecf20Sopenharmony_ci * Issue a write to put the value @val into the register specified in @reg. 1368c2ecf20Sopenharmony_ci */ 1378c2ecf20Sopenharmony_cistatic void ks8851_wrreg16_par(struct ks8851_net *ks, unsigned int reg, 1388c2ecf20Sopenharmony_ci unsigned int val) 1398c2ecf20Sopenharmony_ci{ 1408c2ecf20Sopenharmony_ci struct ks8851_net_par *ksp = to_ks8851_par(ks); 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci ksp->cmd_reg_cache = (u16)reg | ((BE1 | BE0) << (reg & 0x02)); 1438c2ecf20Sopenharmony_ci iowrite16(ksp->cmd_reg_cache, ksp->hw_addr_cmd); 1448c2ecf20Sopenharmony_ci iowrite16(val, ksp->hw_addr); 1458c2ecf20Sopenharmony_ci} 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci/** 1488c2ecf20Sopenharmony_ci * ks8851_rdreg16_par - read 16 bit register from chip 1498c2ecf20Sopenharmony_ci * @ks: The chip information 1508c2ecf20Sopenharmony_ci * @reg: The register address 1518c2ecf20Sopenharmony_ci * 1528c2ecf20Sopenharmony_ci * Read a 16bit register from the chip, returning the result 1538c2ecf20Sopenharmony_ci */ 1548c2ecf20Sopenharmony_cistatic unsigned int ks8851_rdreg16_par(struct ks8851_net *ks, unsigned int reg) 1558c2ecf20Sopenharmony_ci{ 1568c2ecf20Sopenharmony_ci struct ks8851_net_par *ksp = to_ks8851_par(ks); 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci ksp->cmd_reg_cache = (u16)reg | ((BE1 | BE0) << (reg & 0x02)); 1598c2ecf20Sopenharmony_ci iowrite16(ksp->cmd_reg_cache, ksp->hw_addr_cmd); 1608c2ecf20Sopenharmony_ci return ioread16(ksp->hw_addr); 1618c2ecf20Sopenharmony_ci} 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci/** 1648c2ecf20Sopenharmony_ci * ks8851_rdfifo_par - read data from the receive fifo 1658c2ecf20Sopenharmony_ci * @ks: The device state. 1668c2ecf20Sopenharmony_ci * @buff: The buffer address 1678c2ecf20Sopenharmony_ci * @len: The length of the data to read 1688c2ecf20Sopenharmony_ci * 1698c2ecf20Sopenharmony_ci * Issue an RXQ FIFO read command and read the @len amount of data from 1708c2ecf20Sopenharmony_ci * the FIFO into the buffer specified by @buff. 1718c2ecf20Sopenharmony_ci */ 1728c2ecf20Sopenharmony_cistatic void ks8851_rdfifo_par(struct ks8851_net *ks, u8 *buff, unsigned int len) 1738c2ecf20Sopenharmony_ci{ 1748c2ecf20Sopenharmony_ci struct ks8851_net_par *ksp = to_ks8851_par(ks); 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci netif_dbg(ks, rx_status, ks->netdev, 1778c2ecf20Sopenharmony_ci "%s: %d@%p\n", __func__, len, buff); 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci ioread16_rep(ksp->hw_addr, (u16 *)buff + 1, len / 2); 1808c2ecf20Sopenharmony_ci} 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci/** 1838c2ecf20Sopenharmony_ci * ks8851_wrfifo_par - write packet to TX FIFO 1848c2ecf20Sopenharmony_ci * @ks: The device state. 1858c2ecf20Sopenharmony_ci * @txp: The sk_buff to transmit. 1868c2ecf20Sopenharmony_ci * @irq: IRQ on completion of the packet. 1878c2ecf20Sopenharmony_ci * 1888c2ecf20Sopenharmony_ci * Send the @txp to the chip. This means creating the relevant packet header 1898c2ecf20Sopenharmony_ci * specifying the length of the packet and the other information the chip 1908c2ecf20Sopenharmony_ci * needs, such as IRQ on completion. Send the header and the packet data to 1918c2ecf20Sopenharmony_ci * the device. 1928c2ecf20Sopenharmony_ci */ 1938c2ecf20Sopenharmony_cistatic void ks8851_wrfifo_par(struct ks8851_net *ks, struct sk_buff *txp, 1948c2ecf20Sopenharmony_ci bool irq) 1958c2ecf20Sopenharmony_ci{ 1968c2ecf20Sopenharmony_ci struct ks8851_net_par *ksp = to_ks8851_par(ks); 1978c2ecf20Sopenharmony_ci unsigned int len = ALIGN(txp->len, 4); 1988c2ecf20Sopenharmony_ci unsigned int fid = 0; 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci netif_dbg(ks, tx_queued, ks->netdev, "%s: skb %p, %d@%p, irq %d\n", 2018c2ecf20Sopenharmony_ci __func__, txp, txp->len, txp->data, irq); 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci fid = ks->fid++; 2048c2ecf20Sopenharmony_ci fid &= TXFR_TXFID_MASK; 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci if (irq) 2078c2ecf20Sopenharmony_ci fid |= TXFR_TXIC; /* irq on completion */ 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci iowrite16(fid, ksp->hw_addr); 2108c2ecf20Sopenharmony_ci iowrite16(txp->len, ksp->hw_addr); 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci iowrite16_rep(ksp->hw_addr, txp->data, len / 2); 2138c2ecf20Sopenharmony_ci} 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci/** 2168c2ecf20Sopenharmony_ci * ks8851_rx_skb_par - receive skbuff 2178c2ecf20Sopenharmony_ci * @ks: The device state. 2188c2ecf20Sopenharmony_ci * @skb: The skbuff 2198c2ecf20Sopenharmony_ci */ 2208c2ecf20Sopenharmony_cistatic void ks8851_rx_skb_par(struct ks8851_net *ks, struct sk_buff *skb) 2218c2ecf20Sopenharmony_ci{ 2228c2ecf20Sopenharmony_ci netif_rx(skb); 2238c2ecf20Sopenharmony_ci} 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_cistatic unsigned int ks8851_rdreg16_par_txqcr(struct ks8851_net *ks) 2268c2ecf20Sopenharmony_ci{ 2278c2ecf20Sopenharmony_ci return ks8851_rdreg16_par(ks, KS_TXQCR); 2288c2ecf20Sopenharmony_ci} 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci/** 2318c2ecf20Sopenharmony_ci * ks8851_start_xmit_par - transmit packet 2328c2ecf20Sopenharmony_ci * @skb: The buffer to transmit 2338c2ecf20Sopenharmony_ci * @dev: The device used to transmit the packet. 2348c2ecf20Sopenharmony_ci * 2358c2ecf20Sopenharmony_ci * Called by the network layer to transmit the @skb. Queue the packet for 2368c2ecf20Sopenharmony_ci * the device and schedule the necessary work to transmit the packet when 2378c2ecf20Sopenharmony_ci * it is free. 2388c2ecf20Sopenharmony_ci * 2398c2ecf20Sopenharmony_ci * We do this to firstly avoid sleeping with the network device locked, 2408c2ecf20Sopenharmony_ci * and secondly so we can round up more than one packet to transmit which 2418c2ecf20Sopenharmony_ci * means we can try and avoid generating too many transmit done interrupts. 2428c2ecf20Sopenharmony_ci */ 2438c2ecf20Sopenharmony_cistatic netdev_tx_t ks8851_start_xmit_par(struct sk_buff *skb, 2448c2ecf20Sopenharmony_ci struct net_device *dev) 2458c2ecf20Sopenharmony_ci{ 2468c2ecf20Sopenharmony_ci struct ks8851_net *ks = netdev_priv(dev); 2478c2ecf20Sopenharmony_ci netdev_tx_t ret = NETDEV_TX_OK; 2488c2ecf20Sopenharmony_ci unsigned long flags; 2498c2ecf20Sopenharmony_ci unsigned int txqcr; 2508c2ecf20Sopenharmony_ci u16 txmir; 2518c2ecf20Sopenharmony_ci int err; 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_ci netif_dbg(ks, tx_queued, ks->netdev, 2548c2ecf20Sopenharmony_ci "%s: skb %p, %d@%p\n", __func__, skb, skb->len, skb->data); 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_ci ks8851_lock_par(ks, &flags); 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci txmir = ks8851_rdreg16_par(ks, KS_TXMIR) & 0x1fff; 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci if (likely(txmir >= skb->len + 12)) { 2618c2ecf20Sopenharmony_ci ks8851_wrreg16_par(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA); 2628c2ecf20Sopenharmony_ci ks8851_wrfifo_par(ks, skb, false); 2638c2ecf20Sopenharmony_ci ks8851_wrreg16_par(ks, KS_RXQCR, ks->rc_rxqcr); 2648c2ecf20Sopenharmony_ci ks8851_wrreg16_par(ks, KS_TXQCR, TXQCR_METFE); 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci err = readx_poll_timeout_atomic(ks8851_rdreg16_par_txqcr, ks, 2678c2ecf20Sopenharmony_ci txqcr, !(txqcr & TXQCR_METFE), 2688c2ecf20Sopenharmony_ci 5, 1000000); 2698c2ecf20Sopenharmony_ci if (err) 2708c2ecf20Sopenharmony_ci ret = NETDEV_TX_BUSY; 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci ks8851_done_tx(ks, skb); 2738c2ecf20Sopenharmony_ci } else { 2748c2ecf20Sopenharmony_ci ret = NETDEV_TX_BUSY; 2758c2ecf20Sopenharmony_ci } 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci ks8851_unlock_par(ks, &flags); 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_ci return ret; 2808c2ecf20Sopenharmony_ci} 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_cistatic int ks8851_probe_par(struct platform_device *pdev) 2838c2ecf20Sopenharmony_ci{ 2848c2ecf20Sopenharmony_ci struct device *dev = &pdev->dev; 2858c2ecf20Sopenharmony_ci struct ks8851_net_par *ksp; 2868c2ecf20Sopenharmony_ci struct net_device *netdev; 2878c2ecf20Sopenharmony_ci struct ks8851_net *ks; 2888c2ecf20Sopenharmony_ci int ret; 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci netdev = devm_alloc_etherdev(dev, sizeof(struct ks8851_net_par)); 2918c2ecf20Sopenharmony_ci if (!netdev) 2928c2ecf20Sopenharmony_ci return -ENOMEM; 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci ks = netdev_priv(netdev); 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_ci ks->lock = ks8851_lock_par; 2978c2ecf20Sopenharmony_ci ks->unlock = ks8851_unlock_par; 2988c2ecf20Sopenharmony_ci ks->rdreg16 = ks8851_rdreg16_par; 2998c2ecf20Sopenharmony_ci ks->wrreg16 = ks8851_wrreg16_par; 3008c2ecf20Sopenharmony_ci ks->rdfifo = ks8851_rdfifo_par; 3018c2ecf20Sopenharmony_ci ks->wrfifo = ks8851_wrfifo_par; 3028c2ecf20Sopenharmony_ci ks->start_xmit = ks8851_start_xmit_par; 3038c2ecf20Sopenharmony_ci ks->rx_skb = ks8851_rx_skb_par; 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_ci#define STD_IRQ (IRQ_LCI | /* Link Change */ \ 3068c2ecf20Sopenharmony_ci IRQ_RXI | /* RX done */ \ 3078c2ecf20Sopenharmony_ci IRQ_RXPSI) /* RX process stop */ 3088c2ecf20Sopenharmony_ci ks->rc_ier = STD_IRQ; 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci ksp = to_ks8851_par(ks); 3118c2ecf20Sopenharmony_ci spin_lock_init(&ksp->lock); 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci ksp->hw_addr = devm_platform_ioremap_resource(pdev, 0); 3148c2ecf20Sopenharmony_ci if (IS_ERR(ksp->hw_addr)) 3158c2ecf20Sopenharmony_ci return PTR_ERR(ksp->hw_addr); 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci ksp->hw_addr_cmd = devm_platform_ioremap_resource(pdev, 1); 3188c2ecf20Sopenharmony_ci if (IS_ERR(ksp->hw_addr_cmd)) 3198c2ecf20Sopenharmony_ci return PTR_ERR(ksp->hw_addr_cmd); 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_ci ret = ks_check_endian(ks); 3228c2ecf20Sopenharmony_ci if (ret) 3238c2ecf20Sopenharmony_ci return ret; 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ci netdev->irq = platform_get_irq(pdev, 0); 3268c2ecf20Sopenharmony_ci if (netdev->irq < 0) 3278c2ecf20Sopenharmony_ci return netdev->irq; 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ci return ks8851_probe_common(netdev, dev, msg_enable); 3308c2ecf20Sopenharmony_ci} 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_cistatic int ks8851_remove_par(struct platform_device *pdev) 3338c2ecf20Sopenharmony_ci{ 3348c2ecf20Sopenharmony_ci return ks8851_remove_common(&pdev->dev); 3358c2ecf20Sopenharmony_ci} 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_cistatic const struct of_device_id ks8851_match_table[] = { 3388c2ecf20Sopenharmony_ci { .compatible = "micrel,ks8851-mll" }, 3398c2ecf20Sopenharmony_ci { } 3408c2ecf20Sopenharmony_ci}; 3418c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, ks8851_match_table); 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_cistatic struct platform_driver ks8851_driver = { 3448c2ecf20Sopenharmony_ci .driver = { 3458c2ecf20Sopenharmony_ci .name = "ks8851", 3468c2ecf20Sopenharmony_ci .of_match_table = ks8851_match_table, 3478c2ecf20Sopenharmony_ci .pm = &ks8851_pm_ops, 3488c2ecf20Sopenharmony_ci }, 3498c2ecf20Sopenharmony_ci .probe = ks8851_probe_par, 3508c2ecf20Sopenharmony_ci .remove = ks8851_remove_par, 3518c2ecf20Sopenharmony_ci}; 3528c2ecf20Sopenharmony_cimodule_platform_driver(ks8851_driver); 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("KS8851 Network driver"); 3558c2ecf20Sopenharmony_ciMODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); 3568c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 3578c2ecf20Sopenharmony_ci 3588c2ecf20Sopenharmony_cimodule_param_named(message, msg_enable, int, 0); 3598c2ecf20Sopenharmony_ciMODULE_PARM_DESC(message, "Message verbosity level (0=none, 31=all)"); 360