2019-06-04 16:11:33 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2008-08-26 05:18:20 +08:00
|
|
|
* cs_internal.h -- definitions internal to the PCMCIA core modules
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* The initial developer of the original code is David A. Hinds
|
|
|
|
* <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
|
|
|
|
* are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* (C) 1999 David A. Hinds
|
2010-07-11 16:26:53 +08:00
|
|
|
* (C) 2003 - 2010 Dominik Brodowski
|
2008-08-26 05:18:20 +08:00
|
|
|
*
|
|
|
|
* This file contains definitions _only_ needed by the PCMCIA core modules.
|
|
|
|
* It must not be included by PCMCIA socket drivers or by PCMCIA device
|
|
|
|
* drivers.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LINUX_CS_INTERNAL_H
|
|
|
|
#define _LINUX_CS_INTERNAL_H
|
|
|
|
|
2006-01-11 03:50:39 +08:00
|
|
|
#include <linux/kref.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Flags in client state */
|
2006-03-02 07:09:29 +08:00
|
|
|
#define CLIENT_WIN_REQ(i) (0x1<<(i))
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-07-24 23:43:10 +08:00
|
|
|
/* Flag to access all functions */
|
|
|
|
#define BIND_FN_ALL 0xff
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Each card function gets one of these guys */
|
|
|
|
typedef struct config_t {
|
2006-01-11 03:50:39 +08:00
|
|
|
struct kref ref;
|
2008-08-26 05:18:20 +08:00
|
|
|
unsigned int state;
|
2010-07-24 19:14:44 +08:00
|
|
|
|
|
|
|
struct resource io[MAX_IO_WIN]; /* io ports */
|
2010-07-25 01:03:02 +08:00
|
|
|
struct resource mem[MAX_WIN]; /* mem areas */
|
2005-04-17 06:20:36 +08:00
|
|
|
} config_t;
|
|
|
|
|
2008-08-26 05:18:20 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct cis_cache_entry {
|
|
|
|
struct list_head node;
|
|
|
|
unsigned int addr;
|
|
|
|
unsigned int len;
|
|
|
|
unsigned int attr;
|
|
|
|
unsigned char cache[0];
|
|
|
|
};
|
|
|
|
|
2008-08-26 06:09:56 +08:00
|
|
|
struct pccard_resource_ops {
|
|
|
|
int (*validate_mem) (struct pcmcia_socket *s);
|
2010-03-20 20:10:47 +08:00
|
|
|
int (*find_io) (struct pcmcia_socket *s,
|
|
|
|
unsigned int attr,
|
|
|
|
unsigned int *base,
|
|
|
|
unsigned int num,
|
2010-07-25 19:10:22 +08:00
|
|
|
unsigned int align,
|
|
|
|
struct resource **parent);
|
2008-08-26 06:09:56 +08:00
|
|
|
struct resource* (*find_mem) (unsigned long base, unsigned long num,
|
|
|
|
unsigned long align, int low,
|
|
|
|
struct pcmcia_socket *s);
|
|
|
|
int (*init) (struct pcmcia_socket *s);
|
|
|
|
void (*exit) (struct pcmcia_socket *s);
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Flags in config state */
|
|
|
|
#define CONFIG_LOCKED 0x01
|
|
|
|
#define CONFIG_IRQ_REQ 0x02
|
|
|
|
#define CONFIG_IO_REQ 0x04
|
|
|
|
|
|
|
|
/* Flags in socket state */
|
|
|
|
#define SOCKET_PRESENT 0x0008
|
|
|
|
#define SOCKET_INUSE 0x0010
|
2018-02-21 20:24:16 +08:00
|
|
|
#define SOCKET_IN_RESUME 0x0040
|
2005-04-17 06:20:36 +08:00
|
|
|
#define SOCKET_SUSPEND 0x0080
|
|
|
|
#define SOCKET_WIN_REQ(i) (0x0100<<(i))
|
|
|
|
#define SOCKET_CARDBUS 0x8000
|
|
|
|
#define SOCKET_CARDBUS_CONFIG 0x10000
|
|
|
|
|
2008-08-26 05:18:20 +08:00
|
|
|
|
2010-03-07 23:41:57 +08:00
|
|
|
/*
|
|
|
|
* Stuff internal to module "pcmcia_rsrc":
|
|
|
|
*/
|
|
|
|
extern int static_init(struct pcmcia_socket *s);
|
2014-12-10 23:05:38 +08:00
|
|
|
extern struct resource *pcmcia_make_resource(resource_size_t start,
|
|
|
|
resource_size_t end,
|
|
|
|
unsigned long flags, const char *name);
|
2010-03-07 23:41:57 +08:00
|
|
|
|
2008-08-26 05:18:20 +08:00
|
|
|
/*
|
|
|
|
* Stuff internal to module "pcmcia_core":
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* socket_sysfs.c */
|
|
|
|
extern int pccard_sysfs_add_socket(struct device *dev);
|
|
|
|
extern void pccard_sysfs_remove_socket(struct device *dev);
|
|
|
|
|
|
|
|
/* cardbus.c */
|
|
|
|
int cb_alloc(struct pcmcia_socket *s);
|
|
|
|
void cb_free(struct pcmcia_socket *s);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stuff exported by module "pcmcia_core" to module "pcmcia"
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct pcmcia_callback{
|
|
|
|
struct module *owner;
|
2010-07-11 16:26:53 +08:00
|
|
|
int (*add) (struct pcmcia_socket *s);
|
|
|
|
int (*remove) (struct pcmcia_socket *s);
|
2010-01-18 02:30:53 +08:00
|
|
|
void (*requery) (struct pcmcia_socket *s);
|
2010-01-06 20:57:43 +08:00
|
|
|
int (*validate) (struct pcmcia_socket *s, unsigned int *i);
|
2008-08-26 05:18:20 +08:00
|
|
|
int (*suspend) (struct pcmcia_socket *s);
|
2010-07-11 16:26:53 +08:00
|
|
|
int (*early_resume) (struct pcmcia_socket *s);
|
2008-08-26 05:18:20 +08:00
|
|
|
int (*resume) (struct pcmcia_socket *s);
|
|
|
|
};
|
|
|
|
|
|
|
|
/* cs.c */
|
|
|
|
extern struct rw_semaphore pcmcia_socket_list_rwsem;
|
|
|
|
extern struct list_head pcmcia_socket_list;
|
2008-08-26 06:09:56 +08:00
|
|
|
extern struct class pcmcia_socket_class;
|
|
|
|
|
2008-08-26 05:18:20 +08:00
|
|
|
int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c);
|
2008-08-26 06:09:56 +08:00
|
|
|
struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr);
|
2008-08-26 05:18:20 +08:00
|
|
|
|
2010-01-18 01:13:31 +08:00
|
|
|
void pcmcia_parse_uevents(struct pcmcia_socket *socket, unsigned int events);
|
|
|
|
#define PCMCIA_UEVENT_EJECT 0x0001
|
|
|
|
#define PCMCIA_UEVENT_INSERT 0x0002
|
|
|
|
#define PCMCIA_UEVENT_SUSPEND 0x0004
|
|
|
|
#define PCMCIA_UEVENT_RESUME 0x0008
|
2010-01-18 02:30:53 +08:00
|
|
|
#define PCMCIA_UEVENT_REQUERY 0x0010
|
2008-08-31 21:20:26 +08:00
|
|
|
|
|
|
|
struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt);
|
|
|
|
void pcmcia_put_socket(struct pcmcia_socket *skt);
|
|
|
|
|
2010-01-06 20:57:43 +08:00
|
|
|
/*
|
|
|
|
* Stuff internal to module "pcmcia".
|
|
|
|
*/
|
|
|
|
/* ds.c */
|
|
|
|
extern struct bus_type pcmcia_bus_type;
|
|
|
|
|
2010-07-11 15:51:14 +08:00
|
|
|
struct pcmcia_device;
|
|
|
|
|
2010-01-06 20:57:43 +08:00
|
|
|
/* pcmcia_resource.c */
|
|
|
|
extern int pcmcia_release_configuration(struct pcmcia_device *p_dev);
|
2010-01-06 21:03:03 +08:00
|
|
|
extern int pcmcia_validate_mem(struct pcmcia_socket *s);
|
|
|
|
extern struct resource *pcmcia_find_mem_region(u_long base,
|
|
|
|
u_long num,
|
|
|
|
u_long align,
|
|
|
|
int low,
|
|
|
|
struct pcmcia_socket *s);
|
|
|
|
|
2010-04-09 02:33:16 +08:00
|
|
|
void pcmcia_cleanup_irq(struct pcmcia_socket *s);
|
|
|
|
int pcmcia_setup_irq(struct pcmcia_device *p_dev);
|
2010-01-06 20:57:43 +08:00
|
|
|
|
2008-08-26 05:18:20 +08:00
|
|
|
/* cistpl.c */
|
2017-10-01 00:59:54 +08:00
|
|
|
extern const struct bin_attribute pccard_cis_attr;
|
2010-01-06 20:57:43 +08:00
|
|
|
|
2008-08-26 05:18:20 +08:00
|
|
|
int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr,
|
|
|
|
u_int addr, u_int len, void *ptr);
|
2010-07-24 18:23:21 +08:00
|
|
|
int pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr,
|
|
|
|
u_int addr, u_int len, void *ptr);
|
2008-08-26 05:18:20 +08:00
|
|
|
void release_cis_mem(struct pcmcia_socket *s);
|
|
|
|
void destroy_cis_cache(struct pcmcia_socket *s);
|
|
|
|
int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function,
|
|
|
|
cisdata_t code, void *parse);
|
2008-08-31 21:20:26 +08:00
|
|
|
int pcmcia_replace_cis(struct pcmcia_socket *s,
|
|
|
|
const u8 *data, const size_t len);
|
2009-10-19 05:51:09 +08:00
|
|
|
int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *count);
|
2010-01-06 20:57:43 +08:00
|
|
|
int verify_cis_cache(struct pcmcia_socket *s);
|
2008-08-26 05:18:20 +08:00
|
|
|
|
2009-10-19 05:32:33 +08:00
|
|
|
int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function,
|
|
|
|
cisdata_t code, cisparse_t *parse, void *priv_data,
|
|
|
|
int (*loop_tuple) (tuple_t *tuple,
|
|
|
|
cisparse_t *parse,
|
|
|
|
void *priv_data));
|
|
|
|
|
2009-10-19 06:07:39 +08:00
|
|
|
int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function,
|
|
|
|
tuple_t *tuple);
|
|
|
|
|
|
|
|
int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function,
|
|
|
|
tuple_t *tuple);
|
|
|
|
|
|
|
|
int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* _LINUX_CS_INTERNAL_H */
|