2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* ss.h
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LINUX_SS_H
|
|
|
|
#define _LINUX_SS_H
|
|
|
|
|
2005-06-28 07:28:50 +08:00
|
|
|
#include <linux/device.h>
|
2005-10-31 07:03:48 +08:00
|
|
|
#include <linux/sched.h> /* task_struct, completion */
|
2006-01-11 04:20:36 +08:00
|
|
|
#include <linux/mutex.h>
|
2005-06-28 07:28:50 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <pcmcia/cs_types.h>
|
|
|
|
#include <pcmcia/cs.h>
|
2005-08-22 13:29:26 +08:00
|
|
|
#ifdef CONFIG_CARDBUS
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Definitions for card status flags for GetStatus */
|
|
|
|
#define SS_WRPROT 0x0001
|
|
|
|
#define SS_CARDLOCK 0x0002
|
|
|
|
#define SS_EJECTION 0x0004
|
|
|
|
#define SS_INSERTION 0x0008
|
|
|
|
#define SS_BATDEAD 0x0010
|
|
|
|
#define SS_BATWARN 0x0020
|
|
|
|
#define SS_READY 0x0040
|
|
|
|
#define SS_DETECT 0x0080
|
|
|
|
#define SS_POWERON 0x0100
|
|
|
|
#define SS_GPI 0x0200
|
|
|
|
#define SS_STSCHG 0x0400
|
|
|
|
#define SS_CARDBUS 0x0800
|
|
|
|
#define SS_3VCARD 0x1000
|
|
|
|
#define SS_XVCARD 0x2000
|
|
|
|
#define SS_PENDING 0x4000
|
|
|
|
#define SS_ZVCARD 0x8000
|
|
|
|
|
|
|
|
/* InquireSocket capabilities */
|
|
|
|
#define SS_CAP_PAGE_REGS 0x0001
|
|
|
|
#define SS_CAP_VIRTUAL_BUS 0x0002
|
|
|
|
#define SS_CAP_MEM_ALIGN 0x0004
|
|
|
|
#define SS_CAP_STATIC_MAP 0x0008
|
|
|
|
#define SS_CAP_PCCARD 0x4000
|
|
|
|
#define SS_CAP_CARDBUS 0x8000
|
|
|
|
|
|
|
|
/* for GetSocket, SetSocket */
|
|
|
|
typedef struct socket_state_t {
|
2008-08-26 06:09:56 +08:00
|
|
|
u_int flags;
|
|
|
|
u_int csc_mask;
|
|
|
|
u_char Vcc, Vpp;
|
|
|
|
u_char io_irq;
|
2005-04-17 06:20:36 +08:00
|
|
|
} socket_state_t;
|
|
|
|
|
|
|
|
extern socket_state_t dead_socket;
|
|
|
|
|
|
|
|
/* Socket configuration flags */
|
|
|
|
#define SS_PWR_AUTO 0x0010
|
|
|
|
#define SS_IOCARD 0x0020
|
|
|
|
#define SS_RESET 0x0040
|
|
|
|
#define SS_DMA_MODE 0x0080
|
|
|
|
#define SS_SPKR_ENA 0x0100
|
|
|
|
#define SS_OUTPUT_ENA 0x0200
|
|
|
|
|
|
|
|
/* Flags for I/O port and memory windows */
|
|
|
|
#define MAP_ACTIVE 0x01
|
|
|
|
#define MAP_16BIT 0x02
|
|
|
|
#define MAP_AUTOSZ 0x04
|
|
|
|
#define MAP_0WS 0x08
|
|
|
|
#define MAP_WRPROT 0x10
|
|
|
|
#define MAP_ATTRIB 0x20
|
|
|
|
#define MAP_USE_WAIT 0x40
|
|
|
|
#define MAP_PREFETCH 0x80
|
|
|
|
|
|
|
|
/* Use this just for bridge windows */
|
|
|
|
#define MAP_IOSPACE 0x20
|
|
|
|
|
2005-06-23 15:10:12 +08:00
|
|
|
/* power hook operations */
|
|
|
|
#define HOOK_POWER_PRE 0x01
|
|
|
|
#define HOOK_POWER_POST 0x02
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
typedef struct pccard_io_map {
|
2008-08-26 06:09:56 +08:00
|
|
|
u_char map;
|
|
|
|
u_char flags;
|
|
|
|
u_short speed;
|
2009-06-17 00:35:00 +08:00
|
|
|
phys_addr_t start, stop;
|
2005-04-17 06:20:36 +08:00
|
|
|
} pccard_io_map;
|
|
|
|
|
|
|
|
typedef struct pccard_mem_map {
|
2008-08-26 06:09:56 +08:00
|
|
|
u_char map;
|
|
|
|
u_char flags;
|
|
|
|
u_short speed;
|
2009-06-17 00:35:00 +08:00
|
|
|
phys_addr_t static_start;
|
2008-08-26 06:09:56 +08:00
|
|
|
u_int card_start;
|
|
|
|
struct resource *res;
|
2005-04-17 06:20:36 +08:00
|
|
|
} pccard_mem_map;
|
|
|
|
|
|
|
|
typedef struct io_window_t {
|
2008-02-05 14:27:35 +08:00
|
|
|
u_int InUse, Config;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct resource *res;
|
|
|
|
} io_window_t;
|
|
|
|
|
|
|
|
/* Maximum number of IO windows per socket */
|
|
|
|
#define MAX_IO_WIN 2
|
|
|
|
|
|
|
|
/* Maximum number of memory windows per socket */
|
|
|
|
#define MAX_WIN 4
|
|
|
|
|
2008-08-26 06:09:56 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Socket operations.
|
|
|
|
*/
|
|
|
|
struct pcmcia_socket;
|
|
|
|
struct pccard_resource_ops;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct config_t;
|
|
|
|
struct pcmcia_callback;
|
2005-06-28 07:28:50 +08:00
|
|
|
struct user_info_t;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-08-26 06:09:56 +08:00
|
|
|
struct pccard_operations {
|
|
|
|
int (*init)(struct pcmcia_socket *s);
|
|
|
|
int (*suspend)(struct pcmcia_socket *s);
|
|
|
|
int (*get_status)(struct pcmcia_socket *s, u_int *value);
|
|
|
|
int (*set_socket)(struct pcmcia_socket *s, socket_state_t *state);
|
|
|
|
int (*set_io_map)(struct pcmcia_socket *s, struct pccard_io_map *io);
|
|
|
|
int (*set_mem_map)(struct pcmcia_socket *s, struct pccard_mem_map *mem);
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct pcmcia_socket {
|
|
|
|
struct module *owner;
|
|
|
|
spinlock_t lock;
|
|
|
|
socket_state_t socket;
|
|
|
|
u_int state;
|
|
|
|
u_short functions;
|
|
|
|
u_short lock_count;
|
|
|
|
pccard_mem_map cis_mem;
|
|
|
|
void __iomem *cis_virt;
|
|
|
|
struct {
|
|
|
|
u_int AssignedIRQ;
|
|
|
|
u_int Config;
|
|
|
|
} irq;
|
|
|
|
io_window_t io[MAX_IO_WIN];
|
2009-11-03 08:16:12 +08:00
|
|
|
pccard_mem_map win[MAX_WIN];
|
2005-04-17 06:20:36 +08:00
|
|
|
struct list_head cis_cache;
|
2008-07-29 01:44:05 +08:00
|
|
|
size_t fake_cis_len;
|
|
|
|
u8 *fake_cis;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
struct list_head socket_list;
|
|
|
|
struct completion socket_released;
|
|
|
|
|
|
|
|
/* deprecated */
|
|
|
|
unsigned int sock; /* socket number */
|
|
|
|
|
|
|
|
|
|
|
|
/* socket capabilities */
|
|
|
|
u_int features;
|
|
|
|
u_int irq_mask;
|
|
|
|
u_int map_size;
|
2008-02-05 14:27:35 +08:00
|
|
|
u_int io_offset;
|
2009-03-30 05:43:43 +08:00
|
|
|
u_int pci_irq;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct pci_dev * cb_dev;
|
|
|
|
|
|
|
|
|
2008-08-26 06:09:56 +08:00
|
|
|
/* socket setup is done so resources should be able to be allocated.
|
|
|
|
* Only if set to 1, calls to find_{io,mem}_region are handled, and
|
|
|
|
* insertio events are actually managed by the PCMCIA layer.*/
|
2005-04-17 06:20:36 +08:00
|
|
|
u8 resource_setup_done:1;
|
|
|
|
|
2008-08-26 06:09:56 +08:00
|
|
|
/* It's old if resource setup is done using adjust_resource_info() */
|
2005-04-17 06:20:36 +08:00
|
|
|
u8 resource_setup_old:1;
|
2005-06-28 07:28:46 +08:00
|
|
|
u8 resource_setup_new:1;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-06-28 07:28:46 +08:00
|
|
|
u8 reserved:5;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* socket operations */
|
|
|
|
struct pccard_operations * ops;
|
|
|
|
struct pccard_resource_ops * resource_ops;
|
|
|
|
void * resource_data;
|
|
|
|
|
|
|
|
/* Zoom video behaviour is so chip specific its not worth adding
|
|
|
|
this to _ops */
|
2008-08-26 06:09:56 +08:00
|
|
|
void (*zoom_video)(struct pcmcia_socket *,
|
|
|
|
int);
|
2005-06-23 15:10:12 +08:00
|
|
|
|
|
|
|
/* so is power hook */
|
|
|
|
int (*power_hook)(struct pcmcia_socket *sock, int operation);
|
2008-08-26 06:09:56 +08:00
|
|
|
|
2005-08-22 13:29:26 +08:00
|
|
|
/* allows tuning the CB bridge before loading driver for the CB card */
|
2008-08-26 06:09:56 +08:00
|
|
|
#ifdef CONFIG_CARDBUS
|
2005-08-22 13:29:26 +08:00
|
|
|
void (*tune_bridge)(struct pcmcia_socket *sock, struct pci_bus *bus);
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* state thread */
|
|
|
|
struct task_struct *thread;
|
|
|
|
struct completion thread_done;
|
|
|
|
unsigned int thread_events;
|
2008-08-26 06:09:56 +08:00
|
|
|
/* protects socket h/w state */
|
|
|
|
struct mutex skt_mutex;
|
|
|
|
/* protects thread_events */
|
|
|
|
spinlock_t thread_lock;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* pcmcia (16-bit) */
|
|
|
|
struct pcmcia_callback *callback;
|
|
|
|
|
2005-06-28 07:28:50 +08:00
|
|
|
#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
|
2008-08-26 06:09:56 +08:00
|
|
|
/* The following elements refer to 16-bit PCMCIA devices inserted
|
|
|
|
* into the socket */
|
|
|
|
struct list_head devices_list;
|
|
|
|
|
|
|
|
/* the number of devices, used only internally and subject to
|
|
|
|
* incorrectness and change */
|
|
|
|
u8 device_count;
|
2005-06-28 07:28:50 +08:00
|
|
|
|
2008-08-26 06:09:56 +08:00
|
|
|
/* 16-bit state: */
|
2005-06-28 07:28:50 +08:00
|
|
|
struct {
|
2008-08-26 06:09:56 +08:00
|
|
|
/* PCMCIA card is present in socket */
|
|
|
|
u8 present:1;
|
|
|
|
/* "master" ioctl is used */
|
|
|
|
u8 busy:1;
|
|
|
|
/* pcmcia module is being unloaded */
|
|
|
|
u8 dead:1;
|
|
|
|
/* a multifunction-device add event is pending */
|
|
|
|
u8 device_add_pending:1;
|
|
|
|
/* the pending event adds a mfc (1) or pfc (0) */
|
|
|
|
u8 mfc_pfc:1;
|
|
|
|
|
|
|
|
u8 reserved:3;
|
|
|
|
} pcmcia_state;
|
|
|
|
|
|
|
|
|
|
|
|
/* for adding further pseudo-multifunction devices */
|
|
|
|
struct work_struct device_add;
|
2005-06-28 07:28:50 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_PCMCIA_IOCTL
|
|
|
|
struct user_info_t *user;
|
|
|
|
wait_queue_head_t queue;
|
2008-08-26 06:09:56 +08:00
|
|
|
#endif /* CONFIG_PCMCIA_IOCTL */
|
|
|
|
#endif /* CONFIG_PCMCIA */
|
2005-06-28 07:28:50 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* cardbus (32-bit) */
|
|
|
|
#ifdef CONFIG_CARDBUS
|
|
|
|
struct resource * cb_cis_res;
|
|
|
|
void __iomem *cb_cis_virt;
|
2008-08-26 06:09:56 +08:00
|
|
|
#endif /* CONFIG_CARDBUS */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* socket device */
|
2006-09-12 23:00:10 +08:00
|
|
|
struct device dev;
|
2008-08-26 06:09:56 +08:00
|
|
|
/* data internal to the socket driver */
|
|
|
|
void *driver_data;
|
2009-11-03 17:54:58 +08:00
|
|
|
/* status of the card during resume from a system sleep state */
|
|
|
|
int resume_status;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-08-26 06:09:56 +08:00
|
|
|
/* socket drivers must define the resource operations type they use. There
|
|
|
|
* are three options:
|
|
|
|
* - pccard_static_ops iomem and ioport areas are assigned statically
|
|
|
|
* - pccard_iodyn_ops iomem areas is assigned statically, ioport
|
|
|
|
* areas dynamically
|
|
|
|
* - pccard_nonstatic_ops iomem and ioport areas are assigned dynamically.
|
|
|
|
* If this option is selected, use
|
|
|
|
* "select PCCARD_NONSTATIC" in Kconfig.
|
|
|
|
*/
|
|
|
|
extern struct pccard_resource_ops pccard_static_ops;
|
|
|
|
extern struct pccard_resource_ops pccard_iodyn_ops;
|
|
|
|
extern struct pccard_resource_ops pccard_nonstatic_ops;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-08-26 06:09:56 +08:00
|
|
|
/* socket drivers are expected to use these callbacks in their .drv struct */
|
2009-09-29 06:10:41 +08:00
|
|
|
extern int pcmcia_socket_dev_suspend(struct device *dev);
|
2009-11-03 17:54:58 +08:00
|
|
|
extern void pcmcia_socket_dev_early_resume(struct device *dev);
|
|
|
|
extern void pcmcia_socket_dev_late_resume(struct device *dev);
|
2008-08-26 06:09:56 +08:00
|
|
|
extern int pcmcia_socket_dev_resume(struct device *dev);
|
|
|
|
|
|
|
|
/* socket drivers use this callback in their IRQ handler */
|
|
|
|
extern void pcmcia_parse_events(struct pcmcia_socket *socket,
|
|
|
|
unsigned int events);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-08-26 06:09:56 +08:00
|
|
|
/* to register and unregister a socket */
|
2005-04-17 06:20:36 +08:00
|
|
|
extern int pcmcia_register_socket(struct pcmcia_socket *socket);
|
|
|
|
extern void pcmcia_unregister_socket(struct pcmcia_socket *socket);
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* _LINUX_SS_H */
|