1 // SPDX-License-Identifier: GPL-2.0-only
2 /* drivers/net/ethernet/micrel/ks8851.c
4 * Copyright 2009 Simtec Electronics
5 * http://www.simtec.co.uk/
6 * Ben Dooks <ben@simtec.co.uk>
9 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13 #include <linux/interrupt.h>
14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/netdevice.h>
17 #include <linux/etherdevice.h>
18 #include <linux/ethtool.h>
19 #include <linux/cache.h>
20 #include <linux/crc32.h>
21 #include <linux/mii.h>
22 #include <linux/eeprom_93cx6.h>
23 #include <linux/regulator/consumer.h>
25 #include <linux/spi/spi.h>
26 #include <linux/gpio.h>
27 #include <linux/of_gpio.h>
28 #include <linux/of_net.h>
33 * struct ks8851_rxctrl - KS8851 driver rx control
34 * @mchash: Multicast hash-table data.
35 * @rxcr1: KS_RXCR1 register setting
36 * @rxcr2: KS_RXCR2 register setting
38 * Representation of the settings needs to control the receive filtering
39 * such as the multicast hash-filter and the receive register settings. This
40 * is used to make the job of working out if the receive settings change and
41 * then issuing the new settings to the worker that will send the necessary
44 struct ks8851_rxctrl {
51 * union ks8851_tx_hdr - tx header data
52 * @txb: The header as bytes
53 * @txw: The header as 16bit, little-endian words
55 * A dual representation of the tx header data to allow
56 * access to individual bytes, and to allow 16bit accesses
57 * with 16bit alignment.
65 * struct ks8851_net - KS8851 driver private data
66 * @netdev: The network device we're bound to
67 * @statelock: Lock on this structure for tx list.
68 * @mii: The MII state information for the mii calls.
69 * @rxctrl: RX settings for @rxctrl_work.
70 * @rxctrl_work: Work queue for updating RX mode and multicast lists
71 * @txq: Queue of packets for transmission.
72 * @txh: Space for generating packet TX header in DMA-able data
73 * @rxd: Space for receiving SPI data, in DMA-able space.
74 * @txd: Space for transmitting SPI data, in DMA-able space.
75 * @msg_enable: The message flags controlling driver output (see ethtool).
76 * @fid: Incrementing frame id tag.
77 * @rc_ier: Cached copy of KS_IER.
78 * @rc_ccr: Cached copy of KS_CCR.
79 * @rc_rxqcr: Cached copy of KS_RXQCR.
80 * @eeprom: 93CX6 EEPROM state for accessing on-board EEPROM.
81 * @vdd_reg: Optional regulator supplying the chip
82 * @vdd_io: Optional digital power supply for IO
83 * @gpio: Optional reset_n gpio
85 * The @statelock is used to protect information in the structure which may
86 * need to be accessed via several sources, such as the network driver layer
87 * or one of the work queues.
89 * We align the buffers we may use for rx/tx to ensure that if the SPI driver
90 * wants to DMA map them, it will not have any problems with data the driver
94 struct net_device *netdev;
97 union ks8851_tx_hdr txh ____cacheline_aligned;
101 u32 msg_enable ____cacheline_aligned;
109 struct mii_if_info mii;
110 struct ks8851_rxctrl rxctrl;
112 struct work_struct rxctrl_work;
114 struct sk_buff_head txq;
116 struct eeprom_93cx6 eeprom;
117 struct regulator *vdd_reg;
118 struct regulator *vdd_io;
123 * struct ks8851_net_spi - KS8851 SPI driver private data
124 * @ks8851: KS8851 driver common private data
125 * @lock: Lock to ensure that the device is not accessed when busy.
126 * @tx_work: Work queue for tx packets
127 * @spidev: The spi device we're bound to.
128 * @spi_msg1: pre-setup SPI transfer with one message, @spi_xfer1.
129 * @spi_msg2: pre-setup SPI transfer with two messages, @spi_xfer2.
131 * The @lock ensures that the chip is protected when certain operations are
132 * in progress. When the read or write packet transfer is in progress, most
133 * of the chip registers are not ccessible until the transfer is finished and
134 * the DMA has been de-asserted.
136 struct ks8851_net_spi {
137 struct ks8851_net ks8851;
139 struct work_struct tx_work;
140 struct spi_device *spidev;
141 struct spi_message spi_msg1;
142 struct spi_message spi_msg2;
143 struct spi_transfer spi_xfer1;
144 struct spi_transfer spi_xfer2[2];
147 #define to_ks8851_spi(ks) container_of((ks), struct ks8851_net_spi, ks8851)
149 static int msg_enable;
151 /* SPI frame opcodes */
152 #define KS_SPIOP_RD (0x00)
153 #define KS_SPIOP_WR (0x40)
154 #define KS_SPIOP_RXFIFO (0x80)
155 #define KS_SPIOP_TXFIFO (0xC0)
157 /* shift for byte-enable data */
158 #define BYTE_EN(_x) ((_x) << 2)
160 /* turn register number and byte-enable mask into data for start of packet */
161 #define MK_OP(_byteen, _reg) (BYTE_EN(_byteen) | (_reg) << (8+2) | (_reg) >> 6)
164 * ks8851_lock - register access lock
165 * @ks: The chip state
166 * @flags: Spinlock flags
168 * Claim chip register access lock
170 static void ks8851_lock(struct ks8851_net *ks, unsigned long *flags)
172 struct ks8851_net_spi *kss = to_ks8851_spi(ks);
174 mutex_lock(&kss->lock);
178 * ks8851_unlock - register access unlock
179 * @ks: The chip state
180 * @flags: Spinlock flags
182 * Release chip register access lock
184 static void ks8851_unlock(struct ks8851_net *ks, unsigned long *flags)
186 struct ks8851_net_spi *kss = to_ks8851_spi(ks);
188 mutex_unlock(&kss->lock);
191 /* SPI register read/write calls.
193 * All these calls issue SPI transactions to access the chip's registers. They
194 * all require that the necessary lock is held to prevent accesses when the
195 * chip is busy transferring packet data (RX/TX FIFO accesses).
199 * ks8851_wrreg16 - write 16bit register value to chip
200 * @ks: The chip state
201 * @reg: The register address
202 * @val: The value to write
204 * Issue a write to put the value @val into the register specified in @reg.
206 static void ks8851_wrreg16(struct ks8851_net *ks, unsigned reg, unsigned val)
208 struct ks8851_net_spi *kss = to_ks8851_spi(ks);
209 struct spi_transfer *xfer = &kss->spi_xfer1;
210 struct spi_message *msg = &kss->spi_msg1;
214 txb[0] = cpu_to_le16(MK_OP(reg & 2 ? 0xC : 0x03, reg) | KS_SPIOP_WR);
215 txb[1] = cpu_to_le16(val);
221 ret = spi_sync(kss->spidev, msg);
223 netdev_err(ks->netdev, "spi_sync() failed\n");
227 * ks8851_rdreg - issue read register command and return the data
228 * @ks: The device state
229 * @op: The register address and byte enables in message format.
230 * @rxb: The RX buffer to return the result into
231 * @rxl: The length of data expected.
233 * This is the low level read call that issues the necessary spi message(s)
234 * to read data from the register specified in @op.
236 static void ks8851_rdreg(struct ks8851_net *ks, unsigned op,
237 u8 *rxb, unsigned rxl)
239 struct ks8851_net_spi *kss = to_ks8851_spi(ks);
240 struct spi_transfer *xfer;
241 struct spi_message *msg;
242 __le16 *txb = (__le16 *)ks->txd;
246 txb[0] = cpu_to_le16(op | KS_SPIOP_RD);
248 if (kss->spidev->master->flags & SPI_MASTER_HALF_DUPLEX) {
249 msg = &kss->spi_msg2;
250 xfer = kss->spi_xfer2;
261 msg = &kss->spi_msg1;
262 xfer = &kss->spi_xfer1;
269 ret = spi_sync(kss->spidev, msg);
271 netdev_err(ks->netdev, "read: spi_sync() failed\n");
272 else if (kss->spidev->master->flags & SPI_MASTER_HALF_DUPLEX)
273 memcpy(rxb, trx, rxl);
275 memcpy(rxb, trx + 2, rxl);
279 * ks8851_rdreg16 - read 16 bit register from device
280 * @ks: The chip information
281 * @reg: The register address
283 * Read a 16bit register from the chip, returning the result
285 static unsigned ks8851_rdreg16(struct ks8851_net *ks, unsigned reg)
289 ks8851_rdreg(ks, MK_OP(reg & 2 ? 0xC : 0x3, reg), (u8 *)&rx, 2);
290 return le16_to_cpu(rx);
294 * ks8851_soft_reset - issue one of the soft reset to the device
295 * @ks: The device state.
296 * @op: The bit(s) to set in the GRR
298 * Issue the relevant soft-reset command to the device's GRR register
301 * Note, the delays are in there as a caution to ensure that the reset
302 * has time to take effect and then complete. Since the datasheet does
303 * not currently specify the exact sequence, we have chosen something
304 * that seems to work with our device.
306 static void ks8851_soft_reset(struct ks8851_net *ks, unsigned op)
308 ks8851_wrreg16(ks, KS_GRR, op);
309 mdelay(1); /* wait a short time to effect reset */
310 ks8851_wrreg16(ks, KS_GRR, 0);
311 mdelay(1); /* wait for condition to clear */
315 * ks8851_set_powermode - set power mode of the device
316 * @ks: The device state
317 * @pwrmode: The power mode value to write to KS_PMECR.
319 * Change the power mode of the chip.
321 static void ks8851_set_powermode(struct ks8851_net *ks, unsigned pwrmode)
325 netif_dbg(ks, hw, ks->netdev, "setting power mode %d\n", pwrmode);
327 pmecr = ks8851_rdreg16(ks, KS_PMECR);
328 pmecr &= ~PMECR_PM_MASK;
331 ks8851_wrreg16(ks, KS_PMECR, pmecr);
335 * ks8851_write_mac_addr - write mac address to device registers
336 * @dev: The network device
338 * Update the KS8851 MAC address registers from the address in @dev.
340 * This call assumes that the chip is not running, so there is no need to
341 * shutdown the RXQ process whilst setting this.
343 static int ks8851_write_mac_addr(struct net_device *dev)
345 struct ks8851_net *ks = netdev_priv(dev);
350 ks8851_lock(ks, &flags);
353 * Wake up chip in case it was powered off when stopped; otherwise,
354 * the first write to the MAC address does not take effect.
356 ks8851_set_powermode(ks, PMECR_PM_NORMAL);
358 for (i = 0; i < ETH_ALEN; i += 2) {
359 val = (dev->dev_addr[i] << 8) | dev->dev_addr[i + 1];
360 ks8851_wrreg16(ks, KS_MAR(i), val);
363 if (!netif_running(dev))
364 ks8851_set_powermode(ks, PMECR_PM_SOFTDOWN);
366 ks8851_unlock(ks, &flags);
372 * ks8851_read_mac_addr - read mac address from device registers
373 * @dev: The network device
375 * Update our copy of the KS8851 MAC address from the registers of @dev.
377 static void ks8851_read_mac_addr(struct net_device *dev)
379 struct ks8851_net *ks = netdev_priv(dev);
384 ks8851_lock(ks, &flags);
386 for (i = 0; i < ETH_ALEN; i += 2) {
387 reg = ks8851_rdreg16(ks, KS_MAR(i));
388 dev->dev_addr[i] = reg >> 8;
389 dev->dev_addr[i + 1] = reg & 0xff;
392 ks8851_unlock(ks, &flags);
396 * ks8851_init_mac - initialise the mac address
397 * @ks: The device structure
398 * @np: The device node pointer
400 * Get or create the initial mac address for the device and then set that
401 * into the station address register. A mac address supplied in the device
402 * tree takes precedence. Otherwise, if there is an EEPROM present, then
403 * we try that. If no valid mac address is found we use eth_random_addr()
404 * to create a new one.
406 static void ks8851_init_mac(struct ks8851_net *ks, struct device_node *np)
408 struct net_device *dev = ks->netdev;
411 mac_addr = of_get_mac_address(np);
412 if (!IS_ERR(mac_addr)) {
413 ether_addr_copy(dev->dev_addr, mac_addr);
414 ks8851_write_mac_addr(dev);
418 if (ks->rc_ccr & CCR_EEPROM) {
419 ks8851_read_mac_addr(dev);
420 if (is_valid_ether_addr(dev->dev_addr))
423 netdev_err(ks->netdev, "invalid mac address read %pM\n",
427 eth_hw_addr_random(dev);
428 ks8851_write_mac_addr(dev);
432 * ks8851_rdfifo - read data from the receive fifo
433 * @ks: The device state.
434 * @buff: The buffer address
435 * @len: The length of the data to read
437 * Issue an RXQ FIFO read command and read the @len amount of data from
438 * the FIFO into the buffer specified by @buff.
440 static void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned len)
442 struct ks8851_net_spi *kss = to_ks8851_spi(ks);
443 struct spi_transfer *xfer = kss->spi_xfer2;
444 struct spi_message *msg = &kss->spi_msg2;
448 netif_dbg(ks, rx_status, ks->netdev,
449 "%s: %d@%p\n", __func__, len, buff);
451 /* set the operation we're issuing */
452 txb[0] = KS_SPIOP_RXFIFO;
463 ret = spi_sync(kss->spidev, msg);
465 netdev_err(ks->netdev, "%s: spi_sync() failed\n", __func__);
469 * ks8851_dbg_dumpkkt - dump initial packet contents to debug
470 * @ks: The device state
471 * @rxpkt: The data for the received packet
473 * Dump the initial data from the packet to dev_dbg().
475 static void ks8851_dbg_dumpkkt(struct ks8851_net *ks, u8 *rxpkt)
477 netdev_dbg(ks->netdev,
478 "pkt %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x\n",
479 rxpkt[4], rxpkt[5], rxpkt[6], rxpkt[7],
480 rxpkt[8], rxpkt[9], rxpkt[10], rxpkt[11],
481 rxpkt[12], rxpkt[13], rxpkt[14], rxpkt[15]);
485 * ks8851_rx_skb - receive skbuff
488 static void ks8851_rx_skb(struct sk_buff *skb)
494 * ks8851_rx_pkts - receive packets from the host
495 * @ks: The device information.
497 * This is called from the IRQ work queue when the system detects that there
498 * are packets in the receive queue. Find out how many packets there are and
499 * read them from the FIFO.
501 static void ks8851_rx_pkts(struct ks8851_net *ks)
509 rxfc = (ks8851_rdreg16(ks, KS_RXFCTR) >> 8) & 0xff;
511 netif_dbg(ks, rx_status, ks->netdev,
512 "%s: %d packets\n", __func__, rxfc);
514 /* Currently we're issuing a read per packet, but we could possibly
515 * improve the code by issuing a single read, getting the receive
516 * header, allocating the packet and then reading the packet data
519 * This form of operation would require us to hold the SPI bus'
520 * chipselect low during the entie transaction to avoid any
521 * reset to the data stream coming from the chip.
524 for (; rxfc != 0; rxfc--) {
525 rxstat = ks8851_rdreg16(ks, KS_RXFHSR);
526 rxlen = ks8851_rdreg16(ks, KS_RXFHBCR) & RXFHBCR_CNT_MASK;
528 netif_dbg(ks, rx_status, ks->netdev,
529 "rx: stat 0x%04x, len 0x%04x\n", rxstat, rxlen);
531 /* the length of the packet includes the 32bit CRC */
533 /* set dma read address */
534 ks8851_wrreg16(ks, KS_RXFDPR, RXFDPR_RXFPAI | 0x00);
536 /* start DMA access */
537 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA);
540 unsigned int rxalign;
543 rxalign = ALIGN(rxlen, 4);
544 skb = netdev_alloc_skb_ip_align(ks->netdev, rxalign);
547 /* 4 bytes of status header + 4 bytes of
548 * garbage: we put them before ethernet
549 * header, so that they are copied,
553 rxpkt = skb_put(skb, rxlen) - 8;
555 ks8851_rdfifo(ks, rxpkt, rxalign + 8);
557 if (netif_msg_pktdata(ks))
558 ks8851_dbg_dumpkkt(ks, rxpkt);
560 skb->protocol = eth_type_trans(skb, ks->netdev);
563 ks->netdev->stats.rx_packets++;
564 ks->netdev->stats.rx_bytes += rxlen;
568 /* end DMA access and dequeue packet */
569 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_RRXEF);
574 * ks8851_irq - IRQ handler for dealing with interrupt requests
578 * This handler is invoked when the IRQ line asserts to find out what happened.
579 * As we cannot allow ourselves to sleep in HARDIRQ context, this handler runs
582 * Read the interrupt status, work out what needs to be done and then clear
583 * any of the interrupts that are not needed.
585 static irqreturn_t ks8851_irq(int irq, void *_ks)
587 struct ks8851_net *ks = _ks;
588 unsigned handled = 0;
592 ks8851_lock(ks, &flags);
594 status = ks8851_rdreg16(ks, KS_ISR);
596 netif_dbg(ks, intr, ks->netdev,
597 "%s: status 0x%04x\n", __func__, status);
599 if (status & IRQ_LCI)
602 if (status & IRQ_LDI) {
603 u16 pmecr = ks8851_rdreg16(ks, KS_PMECR);
604 pmecr &= ~PMECR_WKEVT_MASK;
605 ks8851_wrreg16(ks, KS_PMECR, pmecr | PMECR_WKEVT_LINK);
610 if (status & IRQ_RXPSI)
611 handled |= IRQ_RXPSI;
613 if (status & IRQ_TXI) {
616 /* no lock here, tx queue should have been stopped */
618 /* update our idea of how much tx space is available to the
620 ks->tx_space = ks8851_rdreg16(ks, KS_TXMIR);
622 netif_dbg(ks, intr, ks->netdev,
623 "%s: txspace %d\n", __func__, ks->tx_space);
626 if (status & IRQ_RXI)
629 if (status & IRQ_SPIBEI) {
630 netdev_err(ks->netdev, "%s: spi bus error\n", __func__);
631 handled |= IRQ_SPIBEI;
634 ks8851_wrreg16(ks, KS_ISR, handled);
636 if (status & IRQ_RXI) {
637 /* the datasheet says to disable the rx interrupt during
638 * packet read-out, however we're masking the interrupt
639 * from the device so do not bother masking just the RX
640 * from the device. */
645 /* if something stopped the rx process, probably due to wanting
646 * to change the rx settings, then do something about restarting
648 if (status & IRQ_RXPSI) {
649 struct ks8851_rxctrl *rxc = &ks->rxctrl;
651 /* update the multicast hash table */
652 ks8851_wrreg16(ks, KS_MAHTR0, rxc->mchash[0]);
653 ks8851_wrreg16(ks, KS_MAHTR1, rxc->mchash[1]);
654 ks8851_wrreg16(ks, KS_MAHTR2, rxc->mchash[2]);
655 ks8851_wrreg16(ks, KS_MAHTR3, rxc->mchash[3]);
657 ks8851_wrreg16(ks, KS_RXCR2, rxc->rxcr2);
658 ks8851_wrreg16(ks, KS_RXCR1, rxc->rxcr1);
661 ks8851_unlock(ks, &flags);
663 if (status & IRQ_LCI)
664 mii_check_link(&ks->mii);
666 if (status & IRQ_TXI)
667 netif_wake_queue(ks->netdev);
673 * calc_txlen - calculate size of message to send packet
674 * @len: Length of data
676 * Returns the size of the TXFIFO message needed to send
679 static inline unsigned calc_txlen(unsigned len)
681 return ALIGN(len + 4, 4);
685 * ks8851_wrpkt - write packet to TX FIFO
686 * @ks: The device state.
687 * @txp: The sk_buff to transmit.
688 * @irq: IRQ on completion of the packet.
690 * Send the @txp to the chip. This means creating the relevant packet header
691 * specifying the length of the packet and the other information the chip
692 * needs, such as IRQ on completion. Send the header and the packet data to
695 static void ks8851_wrpkt(struct ks8851_net *ks, struct sk_buff *txp, bool irq)
697 struct ks8851_net_spi *kss = to_ks8851_spi(ks);
698 struct spi_transfer *xfer = kss->spi_xfer2;
699 struct spi_message *msg = &kss->spi_msg2;
703 netif_dbg(ks, tx_queued, ks->netdev, "%s: skb %p, %d@%p, irq %d\n",
704 __func__, txp, txp->len, txp->data, irq);
707 fid &= TXFR_TXFID_MASK;
710 fid |= TXFR_TXIC; /* irq on completion */
712 /* start header at txb[1] to align txw entries */
713 ks->txh.txb[1] = KS_SPIOP_TXFIFO;
714 ks->txh.txw[1] = cpu_to_le16(fid);
715 ks->txh.txw[2] = cpu_to_le16(txp->len);
717 xfer->tx_buf = &ks->txh.txb[1];
722 xfer->tx_buf = txp->data;
724 xfer->len = ALIGN(txp->len, 4);
726 ret = spi_sync(kss->spidev, msg);
728 netdev_err(ks->netdev, "%s: spi_sync() failed\n", __func__);
732 * ks8851_done_tx - update and then free skbuff after transmitting
733 * @ks: The device state
734 * @txb: The buffer transmitted
736 static void ks8851_done_tx(struct ks8851_net *ks, struct sk_buff *txb)
738 struct net_device *dev = ks->netdev;
740 dev->stats.tx_bytes += txb->len;
741 dev->stats.tx_packets++;
747 * ks8851_tx_work - process tx packet(s)
748 * @work: The work strucutre what was scheduled.
750 * This is called when a number of packets have been scheduled for
751 * transmission and need to be sent to the device.
753 static void ks8851_tx_work(struct work_struct *work)
755 struct ks8851_net_spi *kss;
756 struct ks8851_net *ks;
761 kss = container_of(work, struct ks8851_net_spi, tx_work);
763 last = skb_queue_empty(&ks->txq);
765 ks8851_lock(ks, &flags);
768 txb = skb_dequeue(&ks->txq);
769 last = skb_queue_empty(&ks->txq);
772 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA);
773 ks8851_wrpkt(ks, txb, last);
774 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr);
775 ks8851_wrreg16(ks, KS_TXQCR, TXQCR_METFE);
777 ks8851_done_tx(ks, txb);
781 ks8851_unlock(ks, &flags);
785 * ks8851_flush_tx_work - flush outstanding TX work
786 * @ks: The device state
788 static void ks8851_flush_tx_work(struct ks8851_net *ks)
790 struct ks8851_net_spi *kss = to_ks8851_spi(ks);
792 flush_work(&kss->tx_work);
796 * ks8851_net_open - open network device
797 * @dev: The network device being opened.
799 * Called when the network device is marked active, such as a user executing
800 * 'ifconfig up' on the device.
802 static int ks8851_net_open(struct net_device *dev)
804 struct ks8851_net *ks = netdev_priv(dev);
808 ret = request_threaded_irq(dev->irq, NULL, ks8851_irq,
809 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
812 netdev_err(dev, "failed to get irq\n");
816 /* lock the card, even if we may not actually be doing anything
817 * else at the moment */
818 ks8851_lock(ks, &flags);
820 netif_dbg(ks, ifup, ks->netdev, "opening\n");
822 /* bring chip out of any power saving mode it was in */
823 ks8851_set_powermode(ks, PMECR_PM_NORMAL);
825 /* issue a soft reset to the RX/TX QMU to put it into a known
827 ks8851_soft_reset(ks, GRR_QMU);
829 /* setup transmission parameters */
831 ks8851_wrreg16(ks, KS_TXCR, (TXCR_TXE | /* enable transmit process */
832 TXCR_TXPE | /* pad to min length */
833 TXCR_TXCRC | /* add CRC */
834 TXCR_TXFCE)); /* enable flow control */
836 /* auto-increment tx data, reset tx pointer */
837 ks8851_wrreg16(ks, KS_TXFDPR, TXFDPR_TXFPAI);
839 /* setup receiver control */
841 ks8851_wrreg16(ks, KS_RXCR1, (RXCR1_RXPAFMA | /* from mac filter */
842 RXCR1_RXFCE | /* enable flow control */
843 RXCR1_RXBE | /* broadcast enable */
844 RXCR1_RXUE | /* unicast enable */
845 RXCR1_RXE)); /* enable rx block */
847 /* transfer entire frames out in one go */
848 ks8851_wrreg16(ks, KS_RXCR2, RXCR2_SRDBL_FRAME);
850 /* set receive counter timeouts */
851 ks8851_wrreg16(ks, KS_RXDTTR, 1000); /* 1ms after first frame to IRQ */
852 ks8851_wrreg16(ks, KS_RXDBCTR, 4096); /* >4Kbytes in buffer to IRQ */
853 ks8851_wrreg16(ks, KS_RXFCTR, 10); /* 10 frames to IRQ */
855 ks->rc_rxqcr = (RXQCR_RXFCTE | /* IRQ on frame count exceeded */
856 RXQCR_RXDBCTE | /* IRQ on byte count exceeded */
857 RXQCR_RXDTTE); /* IRQ on time exceeded */
859 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr);
861 /* clear then enable interrupts */
863 #define STD_IRQ (IRQ_LCI | /* Link Change */ \
864 IRQ_TXI | /* TX done */ \
865 IRQ_RXI | /* RX done */ \
866 IRQ_SPIBEI | /* SPI bus error */ \
867 IRQ_TXPSI | /* TX process stop */ \
868 IRQ_RXPSI) /* RX process stop */
870 ks->rc_ier = STD_IRQ;
871 ks8851_wrreg16(ks, KS_ISR, STD_IRQ);
872 ks8851_wrreg16(ks, KS_IER, STD_IRQ);
874 netif_start_queue(ks->netdev);
876 netif_dbg(ks, ifup, ks->netdev, "network device up\n");
878 ks8851_unlock(ks, &flags);
879 mii_check_link(&ks->mii);
884 * ks8851_net_stop - close network device
885 * @dev: The device being closed.
887 * Called to close down a network device which has been active. Cancell any
888 * work, shutdown the RX and TX process and then place the chip into a low
889 * power state whilst it is not being used.
891 static int ks8851_net_stop(struct net_device *dev)
893 struct ks8851_net *ks = netdev_priv(dev);
896 netif_info(ks, ifdown, dev, "shutting down\n");
898 netif_stop_queue(dev);
900 ks8851_lock(ks, &flags);
901 /* turn off the IRQs and ack any outstanding */
902 ks8851_wrreg16(ks, KS_IER, 0x0000);
903 ks8851_wrreg16(ks, KS_ISR, 0xffff);
904 ks8851_unlock(ks, &flags);
906 /* stop any outstanding work */
907 ks8851_flush_tx_work(ks);
908 flush_work(&ks->rxctrl_work);
910 ks8851_lock(ks, &flags);
911 /* shutdown RX process */
912 ks8851_wrreg16(ks, KS_RXCR1, 0x0000);
914 /* shutdown TX process */
915 ks8851_wrreg16(ks, KS_TXCR, 0x0000);
917 /* set powermode to soft power down to save power */
918 ks8851_set_powermode(ks, PMECR_PM_SOFTDOWN);
919 ks8851_unlock(ks, &flags);
921 /* ensure any queued tx buffers are dumped */
922 while (!skb_queue_empty(&ks->txq)) {
923 struct sk_buff *txb = skb_dequeue(&ks->txq);
925 netif_dbg(ks, ifdown, ks->netdev,
926 "%s: freeing txb %p\n", __func__, txb);
931 free_irq(dev->irq, ks);
937 * ks8851_start_xmit - transmit packet
938 * @skb: The buffer to transmit
939 * @dev: The device used to transmit the packet.
941 * Called by the network layer to transmit the @skb. Queue the packet for
942 * the device and schedule the necessary work to transmit the packet when
945 * We do this to firstly avoid sleeping with the network device locked,
946 * and secondly so we can round up more than one packet to transmit which
947 * means we can try and avoid generating too many transmit done interrupts.
949 static netdev_tx_t ks8851_start_xmit(struct sk_buff *skb,
950 struct net_device *dev)
952 struct ks8851_net *ks = netdev_priv(dev);
953 unsigned needed = calc_txlen(skb->len);
954 netdev_tx_t ret = NETDEV_TX_OK;
955 struct ks8851_net_spi *kss;
957 kss = to_ks8851_spi(ks);
959 netif_dbg(ks, tx_queued, ks->netdev,
960 "%s: skb %p, %d@%p\n", __func__, skb, skb->len, skb->data);
962 spin_lock(&ks->statelock);
964 if (needed > ks->tx_space) {
965 netif_stop_queue(dev);
966 ret = NETDEV_TX_BUSY;
968 ks->tx_space -= needed;
969 skb_queue_tail(&ks->txq, skb);
972 spin_unlock(&ks->statelock);
973 schedule_work(&kss->tx_work);
979 * ks8851_rxctrl_work - work handler to change rx mode
980 * @work: The work structure this belongs to.
982 * Lock the device and issue the necessary changes to the receive mode from
983 * the network device layer. This is done so that we can do this without
984 * having to sleep whilst holding the network device lock.
986 * Since the recommendation from Micrel is that the RXQ is shutdown whilst the
987 * receive parameters are programmed, we issue a write to disable the RXQ and
988 * then wait for the interrupt handler to be triggered once the RXQ shutdown is
989 * complete. The interrupt handler then writes the new values into the chip.
991 static void ks8851_rxctrl_work(struct work_struct *work)
993 struct ks8851_net *ks = container_of(work, struct ks8851_net, rxctrl_work);
996 ks8851_lock(ks, &flags);
998 /* need to shutdown RXQ before modifying filter parameters */
999 ks8851_wrreg16(ks, KS_RXCR1, 0x00);
1001 ks8851_unlock(ks, &flags);
1004 static void ks8851_set_rx_mode(struct net_device *dev)
1006 struct ks8851_net *ks = netdev_priv(dev);
1007 struct ks8851_rxctrl rxctrl;
1009 memset(&rxctrl, 0, sizeof(rxctrl));
1011 if (dev->flags & IFF_PROMISC) {
1012 /* interface to receive everything */
1014 rxctrl.rxcr1 = RXCR1_RXAE | RXCR1_RXINVF;
1015 } else if (dev->flags & IFF_ALLMULTI) {
1016 /* accept all multicast packets */
1018 rxctrl.rxcr1 = (RXCR1_RXME | RXCR1_RXAE |
1019 RXCR1_RXPAFMA | RXCR1_RXMAFMA);
1020 } else if (dev->flags & IFF_MULTICAST && !netdev_mc_empty(dev)) {
1021 struct netdev_hw_addr *ha;
1024 /* accept some multicast */
1026 netdev_for_each_mc_addr(ha, dev) {
1027 crc = ether_crc(ETH_ALEN, ha->addr);
1028 crc >>= (32 - 6); /* get top six bits */
1030 rxctrl.mchash[crc >> 4] |= (1 << (crc & 0xf));
1033 rxctrl.rxcr1 = RXCR1_RXME | RXCR1_RXPAFMA;
1035 /* just accept broadcast / unicast */
1036 rxctrl.rxcr1 = RXCR1_RXPAFMA;
1039 rxctrl.rxcr1 |= (RXCR1_RXUE | /* unicast enable */
1040 RXCR1_RXBE | /* broadcast enable */
1041 RXCR1_RXE | /* RX process enable */
1042 RXCR1_RXFCE); /* enable flow control */
1044 rxctrl.rxcr2 |= RXCR2_SRDBL_FRAME;
1046 /* schedule work to do the actual set of the data if needed */
1048 spin_lock(&ks->statelock);
1050 if (memcmp(&rxctrl, &ks->rxctrl, sizeof(rxctrl)) != 0) {
1051 memcpy(&ks->rxctrl, &rxctrl, sizeof(ks->rxctrl));
1052 schedule_work(&ks->rxctrl_work);
1055 spin_unlock(&ks->statelock);
1058 static int ks8851_set_mac_address(struct net_device *dev, void *addr)
1060 struct sockaddr *sa = addr;
1062 if (netif_running(dev))
1065 if (!is_valid_ether_addr(sa->sa_data))
1066 return -EADDRNOTAVAIL;
1068 memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN);
1069 return ks8851_write_mac_addr(dev);
1072 static int ks8851_net_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
1074 struct ks8851_net *ks = netdev_priv(dev);
1076 if (!netif_running(dev))
1079 return generic_mii_ioctl(&ks->mii, if_mii(req), cmd, NULL);
1082 static const struct net_device_ops ks8851_netdev_ops = {
1083 .ndo_open = ks8851_net_open,
1084 .ndo_stop = ks8851_net_stop,
1085 .ndo_do_ioctl = ks8851_net_ioctl,
1086 .ndo_start_xmit = ks8851_start_xmit,
1087 .ndo_set_mac_address = ks8851_set_mac_address,
1088 .ndo_set_rx_mode = ks8851_set_rx_mode,
1089 .ndo_validate_addr = eth_validate_addr,
1092 /* ethtool support */
1094 static void ks8851_get_drvinfo(struct net_device *dev,
1095 struct ethtool_drvinfo *di)
1097 strlcpy(di->driver, "KS8851", sizeof(di->driver));
1098 strlcpy(di->version, "1.00", sizeof(di->version));
1099 strlcpy(di->bus_info, dev_name(dev->dev.parent), sizeof(di->bus_info));
1102 static u32 ks8851_get_msglevel(struct net_device *dev)
1104 struct ks8851_net *ks = netdev_priv(dev);
1105 return ks->msg_enable;
1108 static void ks8851_set_msglevel(struct net_device *dev, u32 to)
1110 struct ks8851_net *ks = netdev_priv(dev);
1111 ks->msg_enable = to;
1114 static int ks8851_get_link_ksettings(struct net_device *dev,
1115 struct ethtool_link_ksettings *cmd)
1117 struct ks8851_net *ks = netdev_priv(dev);
1119 mii_ethtool_get_link_ksettings(&ks->mii, cmd);
1124 static int ks8851_set_link_ksettings(struct net_device *dev,
1125 const struct ethtool_link_ksettings *cmd)
1127 struct ks8851_net *ks = netdev_priv(dev);
1128 return mii_ethtool_set_link_ksettings(&ks->mii, cmd);
1131 static u32 ks8851_get_link(struct net_device *dev)
1133 struct ks8851_net *ks = netdev_priv(dev);
1134 return mii_link_ok(&ks->mii);
1137 static int ks8851_nway_reset(struct net_device *dev)
1139 struct ks8851_net *ks = netdev_priv(dev);
1140 return mii_nway_restart(&ks->mii);
1143 /* EEPROM support */
1145 static void ks8851_eeprom_regread(struct eeprom_93cx6 *ee)
1147 struct ks8851_net *ks = ee->data;
1150 val = ks8851_rdreg16(ks, KS_EEPCR);
1152 ee->reg_data_out = (val & EEPCR_EESB) ? 1 : 0;
1153 ee->reg_data_clock = (val & EEPCR_EESCK) ? 1 : 0;
1154 ee->reg_chip_select = (val & EEPCR_EECS) ? 1 : 0;
1157 static void ks8851_eeprom_regwrite(struct eeprom_93cx6 *ee)
1159 struct ks8851_net *ks = ee->data;
1160 unsigned val = EEPCR_EESA; /* default - eeprom access on */
1163 val |= EEPCR_EESRWA;
1164 if (ee->reg_data_in)
1166 if (ee->reg_data_clock)
1168 if (ee->reg_chip_select)
1171 ks8851_wrreg16(ks, KS_EEPCR, val);
1175 * ks8851_eeprom_claim - claim device EEPROM and activate the interface
1176 * @ks: The network device state.
1178 * Check for the presence of an EEPROM, and then activate software access
1181 static int ks8851_eeprom_claim(struct ks8851_net *ks)
1183 /* start with clock low, cs high */
1184 ks8851_wrreg16(ks, KS_EEPCR, EEPCR_EESA | EEPCR_EECS);
1189 * ks8851_eeprom_release - release the EEPROM interface
1190 * @ks: The device state
1192 * Release the software access to the device EEPROM
1194 static void ks8851_eeprom_release(struct ks8851_net *ks)
1196 unsigned val = ks8851_rdreg16(ks, KS_EEPCR);
1198 ks8851_wrreg16(ks, KS_EEPCR, val & ~EEPCR_EESA);
1201 #define KS_EEPROM_MAGIC (0x00008851)
1203 static int ks8851_set_eeprom(struct net_device *dev,
1204 struct ethtool_eeprom *ee, u8 *data)
1206 struct ks8851_net *ks = netdev_priv(dev);
1207 int offset = ee->offset;
1208 unsigned long flags;
1212 /* currently only support byte writing */
1216 if (ee->magic != KS_EEPROM_MAGIC)
1219 if (!(ks->rc_ccr & CCR_EEPROM))
1222 ks8851_lock(ks, &flags);
1224 ks8851_eeprom_claim(ks);
1226 eeprom_93cx6_wren(&ks->eeprom, true);
1228 /* ethtool currently only supports writing bytes, which means
1229 * we have to read/modify/write our 16bit EEPROMs */
1231 eeprom_93cx6_read(&ks->eeprom, offset/2, &tmp);
1241 eeprom_93cx6_write(&ks->eeprom, offset/2, tmp);
1242 eeprom_93cx6_wren(&ks->eeprom, false);
1244 ks8851_eeprom_release(ks);
1245 ks8851_unlock(ks, &flags);
1250 static int ks8851_get_eeprom(struct net_device *dev,
1251 struct ethtool_eeprom *ee, u8 *data)
1253 struct ks8851_net *ks = netdev_priv(dev);
1254 int offset = ee->offset;
1255 unsigned long flags;
1258 /* must be 2 byte aligned */
1259 if (len & 1 || offset & 1)
1262 if (!(ks->rc_ccr & CCR_EEPROM))
1265 ks8851_lock(ks, &flags);
1267 ks8851_eeprom_claim(ks);
1269 ee->magic = KS_EEPROM_MAGIC;
1271 eeprom_93cx6_multiread(&ks->eeprom, offset/2, (__le16 *)data, len/2);
1272 ks8851_eeprom_release(ks);
1273 ks8851_unlock(ks, &flags);
1278 static int ks8851_get_eeprom_len(struct net_device *dev)
1280 struct ks8851_net *ks = netdev_priv(dev);
1282 /* currently, we assume it is an 93C46 attached, so return 128 */
1283 return ks->rc_ccr & CCR_EEPROM ? 128 : 0;
1286 static const struct ethtool_ops ks8851_ethtool_ops = {
1287 .get_drvinfo = ks8851_get_drvinfo,
1288 .get_msglevel = ks8851_get_msglevel,
1289 .set_msglevel = ks8851_set_msglevel,
1290 .get_link = ks8851_get_link,
1291 .nway_reset = ks8851_nway_reset,
1292 .get_eeprom_len = ks8851_get_eeprom_len,
1293 .get_eeprom = ks8851_get_eeprom,
1294 .set_eeprom = ks8851_set_eeprom,
1295 .get_link_ksettings = ks8851_get_link_ksettings,
1296 .set_link_ksettings = ks8851_set_link_ksettings,
1299 /* MII interface controls */
1302 * ks8851_phy_reg - convert MII register into a KS8851 register
1303 * @reg: MII register number.
1305 * Return the KS8851 register number for the corresponding MII PHY register
1306 * if possible. Return zero if the MII register has no direct mapping to the
1307 * KS8851 register set.
1309 static int ks8851_phy_reg(int reg)
1330 * ks8851_phy_read - MII interface PHY register read.
1331 * @dev: The network device the PHY is on.
1332 * @phy_addr: Address of PHY (ignored as we only have one)
1333 * @reg: The register to read.
1335 * This call reads data from the PHY register specified in @reg. Since the
1336 * device does not support all the MII registers, the non-existent values
1337 * are always returned as zero.
1339 * We return zero for unsupported registers as the MII code does not check
1340 * the value returned for any error status, and simply returns it to the
1341 * caller. The mii-tool that the driver was tested with takes any -ve error
1342 * as real PHY capabilities, thus displaying incorrect data to the user.
1344 static int ks8851_phy_read(struct net_device *dev, int phy_addr, int reg)
1346 struct ks8851_net *ks = netdev_priv(dev);
1347 unsigned long flags;
1351 ksreg = ks8851_phy_reg(reg);
1353 return 0x0; /* no error return allowed, so use zero */
1355 ks8851_lock(ks, &flags);
1356 result = ks8851_rdreg16(ks, ksreg);
1357 ks8851_unlock(ks, &flags);
1362 static void ks8851_phy_write(struct net_device *dev,
1363 int phy, int reg, int value)
1365 struct ks8851_net *ks = netdev_priv(dev);
1366 unsigned long flags;
1369 ksreg = ks8851_phy_reg(reg);
1371 ks8851_lock(ks, &flags);
1372 ks8851_wrreg16(ks, ksreg, value);
1373 ks8851_unlock(ks, &flags);
1378 * ks8851_read_selftest - read the selftest memory info.
1379 * @ks: The device state
1381 * Read and check the TX/RX memory selftest information.
1383 static int ks8851_read_selftest(struct ks8851_net *ks)
1385 unsigned both_done = MBIR_TXMBF | MBIR_RXMBF;
1389 rd = ks8851_rdreg16(ks, KS_MBIR);
1391 if ((rd & both_done) != both_done) {
1392 netdev_warn(ks->netdev, "Memory selftest not finished\n");
1396 if (rd & MBIR_TXMBFA) {
1397 netdev_err(ks->netdev, "TX memory selftest fail\n");
1401 if (rd & MBIR_RXMBFA) {
1402 netdev_err(ks->netdev, "RX memory selftest fail\n");
1409 /* driver bus management functions */
1411 #ifdef CONFIG_PM_SLEEP
1413 static int ks8851_suspend(struct device *dev)
1415 struct ks8851_net *ks = dev_get_drvdata(dev);
1416 struct net_device *netdev = ks->netdev;
1418 if (netif_running(netdev)) {
1419 netif_device_detach(netdev);
1420 ks8851_net_stop(netdev);
1426 static int ks8851_resume(struct device *dev)
1428 struct ks8851_net *ks = dev_get_drvdata(dev);
1429 struct net_device *netdev = ks->netdev;
1431 if (netif_running(netdev)) {
1432 ks8851_net_open(netdev);
1433 netif_device_attach(netdev);
1440 static SIMPLE_DEV_PM_OPS(ks8851_pm_ops, ks8851_suspend, ks8851_resume);
1442 static int ks8851_probe_common(struct net_device *netdev, struct device *dev,
1445 struct ks8851_net *ks = netdev_priv(netdev);
1450 ks->netdev = netdev;
1451 ks->tx_space = 6144;
1453 gpio = of_get_named_gpio_flags(dev->of_node, "reset-gpios", 0, NULL);
1454 if (gpio == -EPROBE_DEFER)
1458 if (gpio_is_valid(gpio)) {
1459 ret = devm_gpio_request_one(dev, gpio,
1460 GPIOF_OUT_INIT_LOW, "ks8851_rst_n");
1462 dev_err(dev, "reset gpio request failed\n");
1467 ks->vdd_io = devm_regulator_get(dev, "vdd-io");
1468 if (IS_ERR(ks->vdd_io)) {
1469 ret = PTR_ERR(ks->vdd_io);
1473 ret = regulator_enable(ks->vdd_io);
1475 dev_err(dev, "regulator vdd_io enable fail: %d\n", ret);
1479 ks->vdd_reg = devm_regulator_get(dev, "vdd");
1480 if (IS_ERR(ks->vdd_reg)) {
1481 ret = PTR_ERR(ks->vdd_reg);
1485 ret = regulator_enable(ks->vdd_reg);
1487 dev_err(dev, "regulator vdd enable fail: %d\n", ret);
1491 if (gpio_is_valid(gpio)) {
1492 usleep_range(10000, 11000);
1493 gpio_set_value(gpio, 1);
1496 spin_lock_init(&ks->statelock);
1498 INIT_WORK(&ks->rxctrl_work, ks8851_rxctrl_work);
1500 /* setup EEPROM state */
1501 ks->eeprom.data = ks;
1502 ks->eeprom.width = PCI_EEPROM_WIDTH_93C46;
1503 ks->eeprom.register_read = ks8851_eeprom_regread;
1504 ks->eeprom.register_write = ks8851_eeprom_regwrite;
1506 /* setup mii state */
1507 ks->mii.dev = netdev;
1509 ks->mii.phy_id_mask = 1;
1510 ks->mii.reg_num_mask = 0xf;
1511 ks->mii.mdio_read = ks8851_phy_read;
1512 ks->mii.mdio_write = ks8851_phy_write;
1514 dev_info(dev, "message enable is %d\n", msg_en);
1516 /* set the default message enable */
1517 ks->msg_enable = netif_msg_init(msg_en, NETIF_MSG_DRV |
1521 skb_queue_head_init(&ks->txq);
1523 netdev->ethtool_ops = &ks8851_ethtool_ops;
1524 SET_NETDEV_DEV(netdev, dev);
1526 dev_set_drvdata(dev, ks);
1528 netif_carrier_off(ks->netdev);
1529 netdev->if_port = IF_PORT_100BASET;
1530 netdev->netdev_ops = &ks8851_netdev_ops;
1532 /* issue a global soft reset to reset the device. */
1533 ks8851_soft_reset(ks, GRR_GSR);
1535 /* simple check for a valid chip being connected to the bus */
1536 cider = ks8851_rdreg16(ks, KS_CIDER);
1537 if ((cider & ~CIDER_REV_MASK) != CIDER_ID) {
1538 dev_err(dev, "failed to read device ID\n");
1543 /* cache the contents of the CCR register for EEPROM, etc. */
1544 ks->rc_ccr = ks8851_rdreg16(ks, KS_CCR);
1546 ks8851_read_selftest(ks);
1547 ks8851_init_mac(ks, dev->of_node);
1549 ret = register_netdev(netdev);
1551 dev_err(dev, "failed to register network device\n");
1555 netdev_info(netdev, "revision %d, MAC %pM, IRQ %d, %s EEPROM\n",
1556 CIDER_REV_GET(cider), netdev->dev_addr, netdev->irq,
1557 ks->rc_ccr & CCR_EEPROM ? "has" : "no");
1563 if (gpio_is_valid(gpio))
1564 gpio_set_value(gpio, 0);
1565 regulator_disable(ks->vdd_reg);
1567 regulator_disable(ks->vdd_io);
1572 static int ks8851_remove_common(struct device *dev)
1574 struct ks8851_net *priv = dev_get_drvdata(dev);
1576 if (netif_msg_drv(priv))
1577 dev_info(dev, "remove\n");
1579 unregister_netdev(priv->netdev);
1580 if (gpio_is_valid(priv->gpio))
1581 gpio_set_value(priv->gpio, 0);
1582 regulator_disable(priv->vdd_reg);
1583 regulator_disable(priv->vdd_io);
1588 static int ks8851_probe(struct spi_device *spi)
1590 struct device *dev = &spi->dev;
1591 struct ks8851_net_spi *kss;
1592 struct net_device *netdev;
1593 struct ks8851_net *ks;
1595 netdev = devm_alloc_etherdev(dev, sizeof(struct ks8851_net_spi));
1599 spi->bits_per_word = 8;
1601 ks = netdev_priv(netdev);
1602 kss = to_ks8851_spi(ks);
1605 mutex_init(&kss->lock);
1606 INIT_WORK(&kss->tx_work, ks8851_tx_work);
1608 /* initialise pre-made spi transfer messages */
1609 spi_message_init(&kss->spi_msg1);
1610 spi_message_add_tail(&kss->spi_xfer1, &kss->spi_msg1);
1612 spi_message_init(&kss->spi_msg2);
1613 spi_message_add_tail(&kss->spi_xfer2[0], &kss->spi_msg2);
1614 spi_message_add_tail(&kss->spi_xfer2[1], &kss->spi_msg2);
1616 netdev->irq = spi->irq;
1618 return ks8851_probe_common(netdev, dev, msg_enable);
1621 static int ks8851_remove(struct spi_device *spi)
1623 return ks8851_remove_common(&spi->dev);
1626 static const struct of_device_id ks8851_match_table[] = {
1627 { .compatible = "micrel,ks8851" },
1630 MODULE_DEVICE_TABLE(of, ks8851_match_table);
1632 static struct spi_driver ks8851_driver = {
1635 .of_match_table = ks8851_match_table,
1636 .pm = &ks8851_pm_ops,
1638 .probe = ks8851_probe,
1639 .remove = ks8851_remove,
1641 module_spi_driver(ks8851_driver);
1643 MODULE_DESCRIPTION("KS8851 Network driver");
1644 MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
1645 MODULE_LICENSE("GPL");
1647 module_param_named(message, msg_enable, int, 0);
1648 MODULE_PARM_DESC(message, "Message verbosity level (0=none, 31=all)");
1649 MODULE_ALIAS("spi:ks8851");