Skip to content

Commit 6c52d5e

Browse files
dpenklergregkh
authored andcommitted
staging: gpib: Add common include files for GPIB drivers
Common include files used only by the drivers. Signed-off-by: Dave Penkler <dpenkler@gmail.com> Link: https://lore.kernel.org/r/20240918121908.19366-4-dpenkler@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f11192a commit 6c52d5e

File tree

13 files changed

+1530
-0
lines changed

13 files changed

+1530
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
/***************************************************************************
4+
* Header for amcc5920 pci chip
5+
*
6+
* copyright : (C) 2002 by Frank Mori Hess
7+
***************************************************************************/
8+
9+
// plx pci chip registers and bits
10+
enum amcc_registers {
11+
AMCC_INTCS_REG = 0x38,
12+
AMCC_PASS_THRU_REG = 0x60,
13+
};
14+
15+
enum amcc_incsr_bits {
16+
AMCC_ADDON_INTR_ENABLE_BIT = 0x2000,
17+
AMCC_ADDON_INTR_ACTIVE_BIT = 0x400000,
18+
AMCC_INTR_ACTIVE_BIT = 0x800000,
19+
};
20+
21+
static const int bits_per_region = 8;
22+
23+
static inline uint32_t amcc_wait_state_bits(unsigned int region, unsigned int num_wait_states)
24+
{
25+
return (num_wait_states & 0x7) << (-region * bits_per_region);
26+
};
27+
28+
enum amcc_prefetch_bits {
29+
PREFETCH_DISABLED = 0x0,
30+
PREFETCH_SMALL = 0x8,
31+
PREFETCH_MEDIUM = 0x10,
32+
PREFETCH_LARGE = 0x18,
33+
};
34+
35+
static inline uint32_t amcc_prefetch_bits(unsigned int region, enum amcc_prefetch_bits prefetch)
36+
{
37+
return prefetch << (--region * bits_per_region);
38+
};
39+
40+
static inline uint32_t amcc_PTADR_mode_bit(unsigned int region)
41+
{
42+
return 0x80 << (--region * bits_per_region);
43+
};
44+
45+
static inline uint32_t amcc_disable_write_fifo_bit(unsigned int region)
46+
{
47+
return 0x20 << (--region * bits_per_region);
48+
};
49+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
/***************************************************************************
4+
* Registers and bits for amccs5933 pci chip
5+
* copyright : (C) 2002 by Frank Mori Hess
6+
***************************************************************************/
7+
8+
// register offsets
9+
enum {
10+
MBEF_REG = 0x34, // mailbux empty/full
11+
INTCSR_REG = 0x38, // interrupt control and status
12+
BMCSR_REG = 0x3c, // bus master control and status
13+
};
14+
15+
// incoming mailbox 0-3 register offsets
16+
extern inline int INCOMING_MAILBOX_REG(unsigned int mailbox)
17+
{
18+
return (0x10 + 4 * mailbox);
19+
};
20+
21+
// bit definitions
22+
23+
// INTCSR bits
24+
enum {
25+
OUTBOX_EMPTY_INTR_BIT = 0x10, // enable outbox empty interrupt
26+
INBOX_FULL_INTR_BIT = 0x1000, // enable inbox full interrupt
27+
INBOX_INTR_CS_BIT = 0x20000, // read, or write clear inbox full interrupt
28+
INTR_ASSERTED_BIT = 0x800000, // read only, interrupt asserted
29+
};
30+
31+
// select byte 0 to 3 of incoming mailbox
32+
extern inline int INBOX_BYTE_BITS(unsigned int byte)
33+
{
34+
return (byte & 0x3) << 8;
35+
};
36+
37+
// select incoming mailbox 0 to 3
38+
extern inline int INBOX_SELECT_BITS(unsigned int mailbox)
39+
{
40+
return (mailbox & 0x3) << 10;
41+
};
42+
43+
// select byte 0 to 3 of outgoing mailbox
44+
extern inline int OUTBOX_BYTE_BITS(unsigned int byte)
45+
{
46+
return (byte & 0x3);
47+
};
48+
49+
// select outgoing mailbox 0 to 3
50+
extern inline int OUTBOX_SELECT_BITS(unsigned int mailbox)
51+
{
52+
return (mailbox & 0x3) << 2;
53+
};
54+
55+
//BMCSR bits
56+
enum {
57+
MBOX_FLAGS_RESET_BIT = 0x08000000, // resets mailbox empty/full flags
58+
};
59+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
/***************************************************************************
4+
* copyright : (C) 2002,2003 by Frank Mori Hess
5+
***************************************************************************/
6+
7+
#ifndef _GPIB_P_H
8+
#define _GPIB_P_H
9+
10+
#include <linux/types.h>
11+
12+
#include "gpib_types.h"
13+
#include "gpib_proto.h"
14+
#include "gpib_user.h"
15+
#include "gpib_ioctl.h"
16+
17+
#include <linux/fs.h>
18+
#include <linux/interrupt.h>
19+
20+
void gpib_register_driver(gpib_interface_t *interface, struct module *mod);
21+
void gpib_unregister_driver(gpib_interface_t *interface);
22+
struct pci_dev *gpib_pci_get_device(const gpib_board_config_t *config, unsigned int vendor_id,
23+
unsigned int device_id, struct pci_dev *from);
24+
struct pci_dev *gpib_pci_get_subsys(const gpib_board_config_t *config, unsigned int vendor_id,
25+
unsigned int device_id, unsigned int ss_vendor,
26+
unsigned int ss_device, struct pci_dev *from);
27+
unsigned int num_gpib_events(const gpib_event_queue_t *queue);
28+
int push_gpib_event(gpib_board_t *board, short event_type);
29+
int pop_gpib_event(gpib_event_queue_t *queue, short *event_type);
30+
int gpib_request_pseudo_irq(gpib_board_t *board, irqreturn_t (*handler)(int, void *));
31+
void gpib_free_pseudo_irq(gpib_board_t *board);
32+
int gpib_match_device_path(struct device *dev, const char *device_path_in);
33+
34+
extern gpib_board_t board_array[GPIB_MAX_NUM_BOARDS];
35+
36+
extern struct list_head registered_drivers;
37+
38+
#ifdef GPIB_DEBUG
39+
#define GPIB_DPRINTK(format, args...) pr_info("gpib debug: " format, ## args)
40+
#else
41+
#define GPIB_DPRINTK(arg...)
42+
#endif
43+
44+
#include <linux/io.h>
45+
46+
void writeb_wrapper(unsigned int value, void *address);
47+
unsigned int readb_wrapper(void *address);
48+
void outb_wrapper(unsigned int value, void *address);
49+
unsigned int inb_wrapper(void *address);
50+
void writew_wrapper(unsigned int value, void *address);
51+
unsigned int readw_wrapper(void *address);
52+
void outw_wrapper(unsigned int value, void *address);
53+
unsigned int inw_wrapper(void *address);
54+
55+
#endif // _GPIB_P_H
56+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
#ifndef __GPIB_PCI_IDS_H
4+
#define __GPIB_LINUX_PCI_IDS_H
5+
6+
#ifndef PCI_VENDOR_ID_AMCC
7+
#define PCI_VENDOR_ID_AMCC 0x10e8
8+
#endif
9+
10+
#ifndef PCI_VENDOR_ID_CBOARDS
11+
#define PCI_VENDOR_ID_CBOARDS 0x1307
12+
#endif
13+
14+
#ifndef PCI_VENDOR_ID_QUANCOM
15+
#define PCI_VENDOR_ID_QUANCOM 0x8008
16+
#endif
17+
18+
#ifndef PCI_DEVICE_ID_QUANCOM_GPIB
19+
#define PCI_DEVICE_ID_QUANCOM_GPIB 0x3302
20+
#endif
21+
22+
#endif // __GPIB_PCI_IDS_H
23+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
#ifndef GPIB_PROTO_INCLUDED
4+
#define GPIB_PROTO_INCLUDED
5+
6+
#include <linux/fs.h>
7+
8+
int ibopen(struct inode *inode, struct file *filep);
9+
int ibclose(struct inode *inode, struct file *file);
10+
long ibioctl(struct file *filep, unsigned int cmd, unsigned long arg);
11+
int osInit(void);
12+
void osReset(void);
13+
void os_start_timer(gpib_board_t *board, unsigned int usec_timeout);
14+
void os_remove_timer(gpib_board_t *board);
15+
void osSendEOI(void);
16+
void osSendEOI(void);
17+
void init_gpib_board(gpib_board_t *board);
18+
static inline unsigned long usec_to_jiffies(unsigned int usec)
19+
{
20+
unsigned long usec_per_jiffy = 1000000 / HZ;
21+
22+
return 1 + (usec + usec_per_jiffy - 1) / usec_per_jiffy;
23+
};
24+
25+
int serial_poll_all(gpib_board_t *board, unsigned int usec_timeout);
26+
void init_gpib_descriptor(gpib_descriptor_t *desc);
27+
int dvrsp(gpib_board_t *board, unsigned int pad, int sad,
28+
unsigned int usec_timeout, uint8_t *result);
29+
int ibAPWait(gpib_board_t *board, int pad);
30+
int ibAPrsp(gpib_board_t *board, int padsad, char *spb);
31+
void ibAPE(gpib_board_t *board, int pad, int v);
32+
int ibcac(gpib_board_t *board, int sync, int fallback_to_async);
33+
int ibcmd(gpib_board_t *board, uint8_t *buf, size_t length, size_t *bytes_written);
34+
int ibgts(gpib_board_t *board);
35+
int ibonline(gpib_board_t *board);
36+
int iboffline(gpib_board_t *board);
37+
int iblines(const gpib_board_t *board, short *lines);
38+
int ibrd(gpib_board_t *board, uint8_t *buf, size_t length, int *end_flag, size_t *bytes_read);
39+
int ibrpp(gpib_board_t *board, uint8_t *buf);
40+
int ibrsv2(gpib_board_t *board, uint8_t status_byte, int new_reason_for_service);
41+
void ibrsc(gpib_board_t *board, int request_control);
42+
int ibsic(gpib_board_t *board, unsigned int usec_duration);
43+
int ibsre(gpib_board_t *board, int enable);
44+
int ibpad(gpib_board_t *board, unsigned int addr);
45+
int ibsad(gpib_board_t *board, int addr);
46+
int ibeos(gpib_board_t *board, int eos, int eosflags);
47+
int ibwait(gpib_board_t *board, int wait_mask, int clear_mask, int set_mask,
48+
int *status, unsigned long usec_timeout, gpib_descriptor_t *desc);
49+
int ibwrt(gpib_board_t *board, uint8_t *buf, size_t cnt, int send_eoi, size_t *bytes_written);
50+
int ibstatus(gpib_board_t *board);
51+
int general_ibstatus(gpib_board_t *board, const gpib_status_queue_t *device,
52+
int clear_mask, int set_mask, gpib_descriptor_t *desc);
53+
int io_timed_out(gpib_board_t *board);
54+
int ibppc(gpib_board_t *board, uint8_t configuration);
55+
56+
#endif /* GPIB_PROTO_INCLUDED */
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
/***************************************************************************
4+
* copyright : (C) 2006 by Frank Mori Hess
5+
***************************************************************************/
6+
7+
#ifndef _GPIB_STATE_MACHINES_H
8+
#define _GPIB_STATE_MACHINES_H
9+
10+
enum talker_function_state {
11+
talker_idle,
12+
talker_addressed,
13+
talker_active,
14+
serial_poll_active
15+
};
16+
17+
enum listener_function_state {
18+
listener_idle,
19+
listener_addressed,
20+
listener_active
21+
};
22+
23+
#endif // _GPIB_STATE_MACHINES_H

0 commit comments

Comments
 (0)