// SPDX-License-Identifier: GPL-2.0-only /* drivers/net/ethernet/micrel/ks8851.c * * Copyright 2009 Simtec Electronics * http://www.simtec.co.uk/ * Ben Dooks <[email protected]> */ #define pr_fmt(fmt) … #include <linux/interrupt.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/ethtool.h> #include <linux/iopoll.h> #include <linux/mii.h> #include <linux/platform_device.h> #include <linux/of_net.h> #include "ks8851.h" static int msg_enable; #define BE3 … #define BE2 … #define BE1 … #define BE0 … /** * struct ks8851_net_par - KS8851 Parallel driver private data * @ks8851: KS8851 driver common private data * @lock: Lock to ensure that the device is not accessed when busy. * @hw_addr : start address of data register. * @hw_addr_cmd : start address of command register. * @cmd_reg_cache : command register cached. * * The @lock ensures that the chip is protected when certain operations are * in progress. When the read or write packet transfer is in progress, most * of the chip registers are not accessible until the transfer is finished * and the DMA has been de-asserted. */ struct ks8851_net_par { … }; #define to_ks8851_par(ks) … /** * ks8851_lock_par - register access lock * @ks: The chip state * @flags: Spinlock flags * * Claim chip register access lock */ static void ks8851_lock_par(struct ks8851_net *ks, unsigned long *flags) { … } /** * ks8851_unlock_par - register access unlock * @ks: The chip state * @flags: Spinlock flags * * Release chip register access lock */ static void ks8851_unlock_par(struct ks8851_net *ks, unsigned long *flags) { … } /** * ks_check_endian - Check whether endianness of the bus is correct * @ks : The chip information * * The KS8851-16MLL EESK pin allows selecting the endianness of the 16bit * bus. To maintain optimum performance, the bus endianness should be set * such that it matches the endianness of the CPU. */ static int ks_check_endian(struct ks8851_net *ks) { … } /** * ks8851_wrreg16_par - write 16bit register value to chip * @ks: The chip state * @reg: The register address * @val: The value to write * * Issue a write to put the value @val into the register specified in @reg. */ static void ks8851_wrreg16_par(struct ks8851_net *ks, unsigned int reg, unsigned int val) { … } /** * ks8851_rdreg16_par - read 16 bit register from chip * @ks: The chip information * @reg: The register address * * Read a 16bit register from the chip, returning the result */ static unsigned int ks8851_rdreg16_par(struct ks8851_net *ks, unsigned int reg) { … } /** * ks8851_rdfifo_par - read data from the receive fifo * @ks: The device state. * @buff: The buffer address * @len: The length of the data to read * * Issue an RXQ FIFO read command and read the @len amount of data from * the FIFO into the buffer specified by @buff. */ static void ks8851_rdfifo_par(struct ks8851_net *ks, u8 *buff, unsigned int len) { … } /** * ks8851_wrfifo_par - write packet to TX FIFO * @ks: The device state. * @txp: The sk_buff to transmit. * @irq: IRQ on completion of the packet. * * Send the @txp to the chip. This means creating the relevant packet header * specifying the length of the packet and the other information the chip * needs, such as IRQ on completion. Send the header and the packet data to * the device. */ static void ks8851_wrfifo_par(struct ks8851_net *ks, struct sk_buff *txp, bool irq) { … } static unsigned int ks8851_rdreg16_par_txqcr(struct ks8851_net *ks) { … } /** * ks8851_start_xmit_par - transmit packet * @skb: The buffer to transmit * @dev: The device used to transmit the packet. * * Called by the network layer to transmit the @skb. Queue the packet for * the device and schedule the necessary work to transmit the packet when * it is free. * * We do this to firstly avoid sleeping with the network device locked, * and secondly so we can round up more than one packet to transmit which * means we can try and avoid generating too many transmit done interrupts. */ static netdev_tx_t ks8851_start_xmit_par(struct sk_buff *skb, struct net_device *dev) { … } static int ks8851_probe_par(struct platform_device *pdev) { … } static void ks8851_remove_par(struct platform_device *pdev) { … } static const struct of_device_id ks8851_match_table[] = …; MODULE_DEVICE_TABLE(of, ks8851_match_table); static struct platform_driver ks8851_driver = …; module_platform_driver(…) …; MODULE_DESCRIPTION(…) …; MODULE_AUTHOR(…) …; MODULE_LICENSE(…) …; module_param_named(message, msg_enable, int, 0); MODULE_PARM_DESC(…) …;