/*
- * ss.h 1.28 2000/06/12 21:55:40
+ * ss.h
*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License
- * at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and
- * limitations under the License.
+ * 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.
*
- * Alternatively, the contents of this file may be used under the
- * terms of the GNU General Public License version 2 (the "GPL"), in which
- * case the provisions of the GPL are applicable instead of the
- * above. If you wish to allow the use of your version of this file
- * only under the terms of the GPL and not to allow others to use
- * your version of this file under the MPL, indicate your decision by
- * deleting the provisions above and replace them with the notice and
- * other provisions required by the GPL. If you do not delete the
- * provisions above, a recipient may use your version of this file
- * under either the MPL or the GPL.
+ * (C) 1999 David A. Hinds
*/
#ifndef _LINUX_SS_H
#define _LINUX_SS_H
+#include <linux/config.h>
+#include <linux/device.h>
+#include <linux/sched.h> /* task_struct, completion */
+#include <linux/mutex.h>
+
#include <pcmcia/cs_types.h>
#include <pcmcia/cs.h>
#include <pcmcia/bulkmem.h>
-#include <linux/device.h>
+#ifdef CONFIG_CARDBUS
+#include <linux/pci.h>
+#endif
/* Definitions for card status flags for GetStatus */
#define SS_WRPROT 0x0001
/* Use this just for bridge windows */
#define MAP_IOSPACE 0x20
+/* power hook operations */
+#define HOOK_POWER_PRE 0x01
+#define HOOK_POWER_POST 0x02
+
+
typedef struct pccard_io_map {
u_char map;
u_char flags;
u_short speed;
- ioaddr_t start, stop;
+ kio_addr_t start, stop;
} pccard_io_map;
typedef struct pccard_mem_map {
struct pccard_operations {
int (*init)(struct pcmcia_socket *sock);
int (*suspend)(struct pcmcia_socket *sock);
- int (*register_callback)(struct pcmcia_socket *sock, void (*handler)(void *, unsigned int), void * info);
int (*get_status)(struct pcmcia_socket *sock, u_int *value);
- int (*get_socket)(struct pcmcia_socket *sock, socket_state_t *state);
int (*set_socket)(struct pcmcia_socket *sock, socket_state_t *state);
int (*set_io_map)(struct pcmcia_socket *sock, struct pccard_io_map *io);
int (*set_mem_map)(struct pcmcia_socket *sock, struct pccard_mem_map *mem);
};
+struct pccard_resource_ops {
+ int (*validate_mem) (struct pcmcia_socket *s);
+ int (*adjust_io_region) (struct resource *res,
+ unsigned long r_start,
+ unsigned long r_end,
+ struct pcmcia_socket *s);
+ struct resource* (*find_io) (unsigned long base, int num,
+ unsigned long align,
+ struct pcmcia_socket *s);
+ struct resource* (*find_mem) (unsigned long base, unsigned long num,
+ unsigned long align, int low,
+ struct pcmcia_socket *s);
+ int (*adjust_resource) (struct pcmcia_socket *s,
+ adjust_t *adj);
+ int (*init) (struct pcmcia_socket *s);
+ void (*exit) (struct pcmcia_socket *s);
+};
+/* SS_CAP_STATIC_MAP */
+extern struct pccard_resource_ops pccard_static_ops;
+/* !SS_CAP_STATIC_MAP */
+extern struct pccard_resource_ops pccard_nonstatic_ops;
+
+/* static mem, dynamic IO sockets */
+extern struct pccard_resource_ops pccard_iodyn_ops;
+
/*
* Calls to set up low-level "Socket Services" drivers
*/
struct pcmcia_socket;
typedef struct io_window_t {
- u_int Attributes;
- ioaddr_t BasePort, NumPorts;
- ioaddr_t InUse, Config;
+ kio_addr_t InUse, Config;
struct resource *res;
} io_window_t;
typedef struct window_t {
u_short magic;
u_short index;
- client_handle_t handle;
+ struct pcmcia_device *handle;
struct pcmcia_socket *sock;
pccard_mem_map ctl;
} window_t;
#define MAX_WIN 4
struct config_t;
-struct region_t;
+struct pcmcia_callback;
+struct user_info_t;
struct pcmcia_socket {
struct module *owner;
u_int state;
u_short functions;
u_short lock_count;
- client_handle_t clients;
pccard_mem_map cis_mem;
void __iomem *cis_virt;
- struct config_t *config;
struct {
u_int AssignedIRQ;
u_int Config;
} irq;
io_window_t io[MAX_IO_WIN];
window_t win[MAX_WIN];
- struct region_t *c_region, *a_region;
struct list_head cis_cache;
u_int fake_cis_len;
char *fake_cis;
u_int features;
u_int irq_mask;
u_int map_size;
- ioaddr_t io_offset;
+ kio_addr_t io_offset;
u_char pci_irq;
struct pci_dev * cb_dev;
+
+ /* 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 insertion
+ * events are actually managed by the PCMCIA layer.*/
+ u8 resource_setup_done:1;
+
+ /* is set to one if resource setup is done using adjust_resource_info() */
+ u8 resource_setup_old:1;
+ u8 resource_setup_new:1;
+
+ u8 reserved:5;
+
/* 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 */
void (*zoom_video)(struct pcmcia_socket *, int);
-
+
+ /* so is power hook */
+ int (*power_hook)(struct pcmcia_socket *sock, int operation);
+#ifdef CONFIG_CARDBUS
+ /* allows tuning the CB bridge before loading driver for the CB card */
+ void (*tune_bridge)(struct pcmcia_socket *sock, struct pci_bus *bus);
+#endif
+
/* state thread */
- struct semaphore skt_sem; /* protects socket h/w state */
+ struct mutex skt_mutex; /* protects socket h/w state */
struct task_struct *thread;
struct completion thread_done;
unsigned int thread_events;
/* pcmcia (16-bit) */
- struct pcmcia_bus_socket *pcmcia;
+ struct pcmcia_callback *callback;
+
+#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
+ struct list_head devices_list; /* PCMCIA devices */
+ u8 device_count; /* the number of devices, used
+ * only internally and subject
+ * to incorrectness and change */
+
+ struct {
+ u8 present:1, /* PCMCIA card is present in socket */
+ busy:1, /* "master" ioctl is used */
+ dead:1, /* pcmcia module is being unloaded */
+ device_add_pending:1, /* a pseudo-multifunction-device
+ * add event is pending */
+ reserved:4;
+ } pcmcia_state;
+
+ struct work_struct device_add; /* for adding further pseudo-multifunction
+ * devices */
+
+#ifdef CONFIG_PCMCIA_IOCTL
+ struct user_info_t *user;
+ wait_queue_head_t queue;
+#endif
+#endif
/* cardbus (32-bit) */
#ifdef CONFIG_CARDBUS
extern struct class pcmcia_socket_class;
/* socket drivers are expected to use these callbacks in their .drv struct */
-extern int pcmcia_socket_dev_suspend(struct device *dev, u32 state);
+extern int pcmcia_socket_dev_suspend(struct device *dev, pm_message_t state);
extern int pcmcia_socket_dev_resume(struct device *dev);
#endif /* _LINUX_SS_H */