linux/include/linux/pnp.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Linux Plug and Play Support
 * Copyright by Adam Belay <[email protected]>
 * Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
 *	Bjorn Helgaas <[email protected]>
 */

#ifndef _LINUX_PNP_H
#define _LINUX_PNP_H

#include <linux/device.h>
#include <linux/list.h>
#include <linux/errno.h>
#include <linux/mod_devicetable.h>
#include <linux/console.h>

#define PNP_NAME_LEN

struct pnp_protocol;
struct pnp_dev;

/*
 * Resource Management
 */
#ifdef CONFIG_PNP
struct resource *pnp_get_resource(struct pnp_dev *dev, unsigned long type,
				unsigned int num);
#else
static inline struct resource *pnp_get_resource(struct pnp_dev *dev,
			unsigned long type, unsigned int num)
{
	return NULL;
}
#endif

static inline int pnp_resource_valid(struct resource *res)
{}

static inline int pnp_resource_enabled(struct resource *res)
{}

static inline resource_size_t pnp_resource_len(struct resource *res)
{}


static inline resource_size_t pnp_port_start(struct pnp_dev *dev,
					     unsigned int bar)
{}

static inline resource_size_t pnp_port_end(struct pnp_dev *dev,
					   unsigned int bar)
{}

static inline unsigned long pnp_port_flags(struct pnp_dev *dev,
					   unsigned int bar)
{}

static inline int pnp_port_valid(struct pnp_dev *dev, unsigned int bar)
{}

static inline resource_size_t pnp_port_len(struct pnp_dev *dev,
					   unsigned int bar)
{}


static inline resource_size_t pnp_mem_start(struct pnp_dev *dev,
					    unsigned int bar)
{}

static inline resource_size_t pnp_mem_end(struct pnp_dev *dev,
					  unsigned int bar)
{}

static inline unsigned long pnp_mem_flags(struct pnp_dev *dev, unsigned int bar)
{}

static inline int pnp_mem_valid(struct pnp_dev *dev, unsigned int bar)
{}

static inline resource_size_t pnp_mem_len(struct pnp_dev *dev,
					  unsigned int bar)
{}


static inline resource_size_t pnp_irq(struct pnp_dev *dev, unsigned int bar)
{}

static inline unsigned long pnp_irq_flags(struct pnp_dev *dev, unsigned int bar)
{}

static inline int pnp_irq_valid(struct pnp_dev *dev, unsigned int bar)
{}


static inline resource_size_t pnp_dma(struct pnp_dev *dev, unsigned int bar)
{}

static inline unsigned long pnp_dma_flags(struct pnp_dev *dev, unsigned int bar)
{}

static inline int pnp_dma_valid(struct pnp_dev *dev, unsigned int bar)
{}


/*
 * Device Management
 */

struct pnp_card {};

#define global_to_pnp_card(n)
#define protocol_to_pnp_card(n)
#define to_pnp_card(n)
#define pnp_for_each_card(card)

struct pnp_card_link {};

static inline void *pnp_get_card_drvdata(struct pnp_card_link *pcard)
{}

static inline void pnp_set_card_drvdata(struct pnp_card_link *pcard, void *data)
{}

struct pnp_dev {};

#define global_to_pnp_dev(n)
#define card_to_pnp_dev(n)
#define protocol_to_pnp_dev(n)
#define to_pnp_dev(n)
#define pnp_for_each_dev(dev)
#define card_for_each_dev(card, dev)
#define pnp_dev_name(dev)

static inline void *pnp_get_drvdata(struct pnp_dev *pdev)
{}

static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
{}

struct pnp_fixup {};

/* config parameters */
#define PNP_CONFIG_NORMAL
#define PNP_CONFIG_FORCE

/* capabilities */
#define PNP_READ
#define PNP_WRITE
#define PNP_DISABLE
#define PNP_CONFIGURABLE
#define PNP_REMOVABLE
#define PNP_CONSOLE

#define pnp_can_read(dev)
#define pnp_can_write(dev)
#define pnp_can_disable(dev)
#define pnp_can_configure(dev)
#define pnp_can_suspend(dev)


#ifdef CONFIG_ISAPNP
extern struct pnp_protocol isapnp_protocol;
#define pnp_device_is_isapnp(dev)
#else
#define pnp_device_is_isapnp
#endif
extern struct mutex pnp_res_mutex;

#ifdef CONFIG_PNPBIOS
extern struct pnp_protocol pnpbios_protocol;
extern bool arch_pnpbios_disabled(void);
#define pnp_device_is_pnpbios
#else
#define pnp_device_is_pnpbios(dev)
#define arch_pnpbios_disabled()
#endif

#ifdef CONFIG_PNPACPI
extern struct pnp_protocol pnpacpi_protocol;

static inline struct acpi_device *pnp_acpi_device(struct pnp_dev *dev)
{}
#else
#define pnp_acpi_device
#endif

/* status */
#define PNP_READY
#define PNP_ATTACHED
#define PNP_BUSY
#define PNP_FAULTY

/* isapnp specific macros */

#define isapnp_card_number(dev)
#define isapnp_csn_number(dev)

/*
 * Driver Management
 */

struct pnp_id {};

struct pnp_driver {};

#define to_pnp_driver(drv)

struct pnp_card_driver {};

#define to_pnp_card_driver(drv)

/* pnp driver flags */
#define PNP_DRIVER_RES_DO_NOT_CHANGE
#define PNP_DRIVER_RES_DISABLE

/*
 * Protocol Management
 */

struct pnp_protocol {};

#define to_pnp_protocol(n)
#define protocol_for_each_card(protocol, card)
#define protocol_for_each_dev(protocol, dev)

#if defined(CONFIG_PNP)

/* device management */
int pnp_device_attach(struct pnp_dev *pnp_dev);
void pnp_device_detach(struct pnp_dev *pnp_dev);
extern struct list_head pnp_global;
extern int pnp_platform_devices;

/* multidevice card support */
struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
					const char *id, struct pnp_dev *from);
void pnp_release_card_device(struct pnp_dev *dev);
int pnp_register_card_driver(struct pnp_card_driver *drv);
void pnp_unregister_card_driver(struct pnp_card_driver *drv);
extern struct list_head pnp_cards;

/* resource management */
int pnp_possible_config(struct pnp_dev *dev, int type, resource_size_t base,
			resource_size_t size);
int pnp_auto_config_dev(struct pnp_dev *dev);
int pnp_start_dev(struct pnp_dev *dev);
int pnp_stop_dev(struct pnp_dev *dev);
int pnp_activate_dev(struct pnp_dev *dev);
int pnp_disable_dev(struct pnp_dev *dev);
int pnp_range_reserved(resource_size_t start, resource_size_t end);

/* protocol helpers */
int pnp_is_active(struct pnp_dev *dev);
int compare_pnp_id(struct pnp_id *pos, const char *id);
int pnp_register_driver(struct pnp_driver *drv);
void pnp_unregister_driver(struct pnp_driver *drv);

bool dev_is_pnp(const struct device *dev);

#else

/* device management */
static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; }
static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { }

#define pnp_platform_devices

/* multidevice card support */
static inline struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, const char *id, struct pnp_dev *from) { return NULL; }
static inline void pnp_release_card_device(struct pnp_dev *dev) { }
static inline int pnp_register_card_driver(struct pnp_card_driver *drv) { return -ENODEV; }
static inline void pnp_unregister_card_driver(struct pnp_card_driver *drv) { }

/* resource management */
static inline int pnp_possible_config(struct pnp_dev *dev, int type,
				      resource_size_t base,
				      resource_size_t size) { return 0; }
static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; }
static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; }
static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; }
static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; }
static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; }
static inline int pnp_range_reserved(resource_size_t start, resource_size_t end) { return 0; }

/* protocol helpers */
static inline int pnp_is_active(struct pnp_dev *dev) { return 0; }
static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -ENODEV; }
static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; }
static inline void pnp_unregister_driver(struct pnp_driver *drv) { }

static inline bool dev_is_pnp(const struct device *dev) { return false; }

#endif /* CONFIG_PNP */

/**
 * module_pnp_driver() - Helper macro for registering a PnP driver
 * @__pnp_driver: pnp_driver struct
 *
 * Helper macro for PnP 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_pnp_driver(__pnp_driver)

#endif /* _LINUX_PNP_H */