drivers/net/can/softing/softing.h

Source file repositories/reference/linux-study-clean/drivers/net/can/softing/softing.h

File Facts

System
Linux kernel
Corpus path
drivers/net/can/softing/softing.h
Extension
.h
Size
4513 bytes
Lines
169
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct softing_priv {
	struct can_priv can; /* must be the first member! */
	struct net_device *netdev;
	struct softing *card;
	struct {
		int pending;
		/* variables which hold the circular buffer */
		int echo_put;
		int echo_get;
	} tx;
	struct can_bittiming_const btr_const;
	int index;
	uint8_t output;
	uint16_t chip;
};
#define netdev2softing(netdev)	((struct softing_priv *)netdev_priv(netdev))

struct softing {
	const struct softing_platform_data *pdat;
	struct platform_device *pdev;
	struct net_device *net[2];
	spinlock_t spin; /* protect this structure & DPRAM access */
	ktime_t ts_ref;
	ktime_t ts_overflow; /* timestamp overflow value, in ktime */

	struct {
		/* indication of firmware status */
		int up;
		/* protection of the 'up' variable */
		struct mutex lock;
	} fw;
	struct {
		int nr;
		int requested;
		int svc_count;
		unsigned int dpram_position;
	} irq;
	struct {
		int pending;
		int last_bus;
		/*
		 * keep the bus that last tx'd a message,
		 * in order to let every netdev queue resume
		 */
	} tx;
	__iomem uint8_t *dpram;
	unsigned long dpram_phys;
	unsigned long dpram_size;
	struct {
		uint16_t fw_version, hw_version, license, serial;
		uint16_t chip[2];
		unsigned int freq; /* remote cpu's operating frequency */
	} id;
};

int softing_default_output(struct net_device *netdev);

ktime_t softing_raw2ktime(struct softing *card, u32 raw);

int softing_chip_poweron(struct softing *card);

int softing_bootloader_command(struct softing *card, int16_t cmd,
			       const char *msg);

/* Load firmware after reset */
int softing_load_fw(const char *file, struct softing *card,
		    __iomem uint8_t *virt, unsigned int size, int offset);

/* Load final application firmware after bootloader */
int softing_load_app_fw(const char *file, struct softing *card);

/*
 * enable or disable irq
 * only called with fw.lock locked
 */
int softing_enable_irq(struct softing *card, int enable);

/* start/stop 1 bus on card */
int softing_startstop(struct net_device *netdev, int up);

/* netif_rx() */
int softing_netdev_rx(struct net_device *netdev, const struct can_frame *msg,
		      ktime_t ktime);

/* SOFTING DPRAM mappings */
#define DPRAM_RX		0x0000
	#define DPRAM_RX_SIZE	32
	#define DPRAM_RX_CNT	16
#define DPRAM_RX_RD		0x0201	/* uint8_t */
#define DPRAM_RX_WR		0x0205	/* uint8_t */

Annotation

Implementation Notes