linux/include/pcmcia/ds.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * ds.h -- 16-bit PCMCIA core support
 *
 * The initial developer of the original code is David A. Hinds
 * <[email protected]>.  Portions created by David A. Hinds
 * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
 *
 * (C) 1999		David A. Hinds
 * (C) 2003 - 2008	Dominik Brodowski
 */

#ifndef _LINUX_DS_H
#define _LINUX_DS_H

#ifdef __KERNEL__
#include <linux/mod_devicetable.h>
#endif

#include <pcmcia/device_id.h>

#ifdef __KERNEL__
#include <linux/device.h>
#include <linux/interrupt.h>
#include <pcmcia/ss.h>
#include <linux/atomic.h>


/*
 * PCMCIA device drivers (16-bit cards only; 32-bit cards require CardBus
 * a.k.a. PCI drivers
 */
struct pcmcia_socket;
struct pcmcia_device;
struct config_t;
struct net_device;

/* dynamic device IDs for PCMCIA device drivers. See
 * Documentation/pcmcia/driver.rst for details.
*/
struct pcmcia_dynids {};

struct pcmcia_driver {};

/* driver registration */
int pcmcia_register_driver(struct pcmcia_driver *driver);
void pcmcia_unregister_driver(struct pcmcia_driver *driver);

/**
 * module_pcmcia_driver() - Helper macro for registering a pcmcia driver
 * @__pcmcia_driver: pcmcia_driver struct
 *
 * Helper macro for pcmcia drivers which do not do anything special in module
 * init/exit. This eliminates a lot of boilerplate. Each module may only use
 * this macro once, and calling it replaces module_init() and module_exit().
 */
#define module_pcmcia_driver(__pcmcia_driver)

/* for struct resource * array embedded in struct pcmcia_device */
enum {};

struct pcmcia_device {};

#define to_pcmcia_dev(n)
#define to_pcmcia_drv(n)


/*
 * CIS access.
 *
 * Please use the following functions to access CIS tuples:
 * - pcmcia_get_tuple()
 * - pcmcia_loop_tuple()
 * - pcmcia_get_mac_from_cis()
 *
 * To parse a tuple_t, pcmcia_parse_tuple() exists. Its interface
 * might change in future.
 */

/* get the very first CIS entry of type @code. Note that buf is pointer
 * to u8 *buf; and that you need to kfree(buf) afterwards. */
size_t pcmcia_get_tuple(struct pcmcia_device *p_dev, cisdata_t code,
			u8 **buf);

/* loop over CIS entries */
int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code,
		      int (*loop_tuple) (struct pcmcia_device *p_dev,
					 tuple_t *tuple,
					 void *priv_data),
		      void *priv_data);

/* get the MAC address from CISTPL_FUNCE */
int pcmcia_get_mac_from_cis(struct pcmcia_device *p_dev,
			    struct net_device *dev);


/* parse a tuple_t */
int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse);

/* loop CIS entries for valid configuration */
int pcmcia_loop_config(struct pcmcia_device *p_dev,
		       int	(*conf_check)	(struct pcmcia_device *p_dev,
						 void *priv_data),
		       void *priv_data);

/* is the device still there? */
struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *p_dev);

/* low-level interface reset */
int pcmcia_reset_card(struct pcmcia_socket *skt);

/* CIS config */
int pcmcia_read_config_byte(struct pcmcia_device *p_dev, off_t where, u8 *val);
int pcmcia_write_config_byte(struct pcmcia_device *p_dev, off_t where, u8 val);

/* device configuration */
int pcmcia_request_io(struct pcmcia_device *p_dev);

int __must_check pcmcia_request_irq(struct pcmcia_device *p_dev,
				irq_handler_t handler);

int pcmcia_enable_device(struct pcmcia_device *p_dev);

int pcmcia_request_window(struct pcmcia_device *p_dev, struct resource *res,
			unsigned int speed);
int pcmcia_release_window(struct pcmcia_device *p_dev, struct resource *res);
int pcmcia_map_mem_page(struct pcmcia_device *p_dev, struct resource *res,
			unsigned int offset);

int pcmcia_fixup_vpp(struct pcmcia_device *p_dev, unsigned char new_vpp);
int pcmcia_fixup_iowidth(struct pcmcia_device *p_dev);

void pcmcia_disable_device(struct pcmcia_device *p_dev);

/* IO ports */
#define IO_DATA_PATH_WIDTH
#define IO_DATA_PATH_WIDTH_8
#define IO_DATA_PATH_WIDTH_16
#define IO_DATA_PATH_WIDTH_AUTO

/* IO memory */
#define WIN_MEMORY_TYPE_CM
#define WIN_MEMORY_TYPE_AM
#define WIN_DATA_WIDTH_8
#define WIN_DATA_WIDTH_16
#define WIN_ENABLE
#define WIN_USE_WAIT

#define WIN_FLAGS_MAP
#define WIN_FLAGS_REQ

/* config_reg{ister}s present for this PCMCIA device */
#define PRESENT_OPTION
#define PRESENT_STATUS
#define PRESENT_PIN_REPLACE
#define PRESENT_COPY
#define PRESENT_EXT_STATUS
#define PRESENT_IOBASE_0
#define PRESENT_IOBASE_1
#define PRESENT_IOBASE_2
#define PRESENT_IOBASE_3
#define PRESENT_IOSIZE

/* flags to be passed to pcmcia_enable_device() */
#define CONF_ENABLE_IRQ
#define CONF_ENABLE_SPKR
#define CONF_ENABLE_PULSE_IRQ
#define CONF_ENABLE_ESR
#define CONF_ENABLE_IOCARD
#define CONF_ENABLE_ZVCARD

/* flags used by pcmcia_loop_config() autoconfiguration */
#define CONF_AUTO_CHECK_VCC
#define CONF_AUTO_SET_VPP
#define CONF_AUTO_AUDIO
#define CONF_AUTO_SET_IO
#define CONF_AUTO_SET_IOMEM

#endif /* __KERNEL__ */

#endif /* _LINUX_DS_H */