Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 3 | * cs_internal.h -- definitions internal to the PCMCIA core modules |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * The initial developer of the original code is David A. Hinds |
| 6 | * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds |
| 7 | * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. |
| 8 | * |
| 9 | * (C) 1999 David A. Hinds |
Dominik Brodowski | 7b24e79 | 2010-07-11 10:26:53 +0200 | [diff] [blame] | 10 | * (C) 2003 - 2010 Dominik Brodowski |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 11 | * |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 12 | * This file contains definitions _only_ needed by the PCMCIA core modules. |
| 13 | * It must not be included by PCMCIA socket drivers or by PCMCIA device |
| 14 | * drivers. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #ifndef _LINUX_CS_INTERNAL_H |
| 18 | #define _LINUX_CS_INTERNAL_H |
| 19 | |
Dominik Brodowski | 360b65b | 2006-01-10 20:50:39 +0100 | [diff] [blame] | 20 | #include <linux/kref.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | /* Flags in client state */ |
Dominik Brodowski | e2d4096 | 2006-03-02 00:09:29 +0100 | [diff] [blame] | 23 | #define CLIENT_WIN_REQ(i) (0x1<<(i)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
Dominik Brodowski | a3d0d4d | 2010-07-24 17:43:10 +0200 | [diff] [blame] | 25 | /* Flag to access all functions */ |
| 26 | #define BIND_FN_ALL 0xff |
| 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | /* Each card function gets one of these guys */ |
| 29 | typedef struct config_t { |
Dominik Brodowski | 360b65b | 2006-01-10 20:50:39 +0100 | [diff] [blame] | 30 | struct kref ref; |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 31 | unsigned int state; |
Dominik Brodowski | 2ce4905 | 2010-07-24 13:14:44 +0200 | [diff] [blame] | 32 | |
| 33 | struct resource io[MAX_IO_WIN]; /* io ports */ |
Dominik Brodowski | 0ca724d3 | 2010-07-24 19:03:02 +0200 | [diff] [blame] | 34 | struct resource mem[MAX_WIN]; /* mem areas */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | } config_t; |
| 36 | |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | struct cis_cache_entry { |
| 39 | struct list_head node; |
| 40 | unsigned int addr; |
| 41 | unsigned int len; |
| 42 | unsigned int attr; |
Gustavo A. R. Silva | 1e6709b | 2020-03-20 17:12:42 -0500 | [diff] [blame] | 43 | unsigned char cache[]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | }; |
| 45 | |
Dominik Brodowski | c23889c | 2008-08-26 00:09:56 +0200 | [diff] [blame] | 46 | struct pccard_resource_ops { |
| 47 | int (*validate_mem) (struct pcmcia_socket *s); |
Dominik Brodowski | b19a727 | 2010-03-20 13:10:47 +0100 | [diff] [blame] | 48 | int (*find_io) (struct pcmcia_socket *s, |
| 49 | unsigned int attr, |
| 50 | unsigned int *base, |
| 51 | unsigned int num, |
Dominik Brodowski | ad0c7be | 2010-07-25 13:10:22 +0200 | [diff] [blame] | 52 | unsigned int align, |
| 53 | struct resource **parent); |
Dominik Brodowski | c23889c | 2008-08-26 00:09:56 +0200 | [diff] [blame] | 54 | struct resource* (*find_mem) (unsigned long base, unsigned long num, |
| 55 | unsigned long align, int low, |
| 56 | struct pcmcia_socket *s); |
Dominik Brodowski | c23889c | 2008-08-26 00:09:56 +0200 | [diff] [blame] | 57 | int (*init) (struct pcmcia_socket *s); |
| 58 | void (*exit) (struct pcmcia_socket *s); |
| 59 | }; |
| 60 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | /* Flags in config state */ |
| 62 | #define CONFIG_LOCKED 0x01 |
| 63 | #define CONFIG_IRQ_REQ 0x02 |
| 64 | #define CONFIG_IO_REQ 0x04 |
| 65 | |
| 66 | /* Flags in socket state */ |
| 67 | #define SOCKET_PRESENT 0x0008 |
| 68 | #define SOCKET_INUSE 0x0010 |
Rafael J. Wysocki | dbdd0f5 | 2018-02-21 13:24:16 +0100 | [diff] [blame] | 69 | #define SOCKET_IN_RESUME 0x0040 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | #define SOCKET_SUSPEND 0x0080 |
| 71 | #define SOCKET_WIN_REQ(i) (0x0100<<(i)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | #define SOCKET_CARDBUS 0x8000 |
| 73 | #define SOCKET_CARDBUS_CONFIG 0x10000 |
| 74 | |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 75 | |
| 76 | /* |
Dominik Brodowski | 49b1153 | 2010-03-07 16:41:57 +0100 | [diff] [blame] | 77 | * Stuff internal to module "pcmcia_rsrc": |
| 78 | */ |
| 79 | extern int static_init(struct pcmcia_socket *s); |
Alan Cox | a6c6193 | 2014-12-10 15:05:38 +0000 | [diff] [blame] | 80 | extern struct resource *pcmcia_make_resource(resource_size_t start, |
| 81 | resource_size_t end, |
| 82 | unsigned long flags, const char *name); |
Dominik Brodowski | 49b1153 | 2010-03-07 16:41:57 +0100 | [diff] [blame] | 83 | |
| 84 | /* |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 85 | * Stuff internal to module "pcmcia_core": |
| 86 | */ |
| 87 | |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 88 | /* socket_sysfs.c */ |
| 89 | extern int pccard_sysfs_add_socket(struct device *dev); |
| 90 | extern void pccard_sysfs_remove_socket(struct device *dev); |
| 91 | |
| 92 | /* cardbus.c */ |
| 93 | int cb_alloc(struct pcmcia_socket *s); |
| 94 | void cb_free(struct pcmcia_socket *s); |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 95 | |
| 96 | |
| 97 | |
| 98 | /* |
| 99 | * Stuff exported by module "pcmcia_core" to module "pcmcia" |
| 100 | */ |
| 101 | |
| 102 | struct pcmcia_callback{ |
| 103 | struct module *owner; |
Dominik Brodowski | 7b24e79 | 2010-07-11 10:26:53 +0200 | [diff] [blame] | 104 | int (*add) (struct pcmcia_socket *s); |
| 105 | int (*remove) (struct pcmcia_socket *s); |
Dominik Brodowski | af461fc | 2010-01-17 19:30:53 +0100 | [diff] [blame] | 106 | void (*requery) (struct pcmcia_socket *s); |
Dominik Brodowski | 6e7b51a | 2010-01-06 13:57:43 +0100 | [diff] [blame] | 107 | int (*validate) (struct pcmcia_socket *s, unsigned int *i); |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 108 | int (*suspend) (struct pcmcia_socket *s); |
Dominik Brodowski | 7b24e79 | 2010-07-11 10:26:53 +0200 | [diff] [blame] | 109 | int (*early_resume) (struct pcmcia_socket *s); |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 110 | int (*resume) (struct pcmcia_socket *s); |
| 111 | }; |
| 112 | |
| 113 | /* cs.c */ |
| 114 | extern struct rw_semaphore pcmcia_socket_list_rwsem; |
| 115 | extern struct list_head pcmcia_socket_list; |
Dominik Brodowski | c23889c | 2008-08-26 00:09:56 +0200 | [diff] [blame] | 116 | extern struct class pcmcia_socket_class; |
| 117 | |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 118 | int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); |
Dominik Brodowski | c23889c | 2008-08-26 00:09:56 +0200 | [diff] [blame] | 119 | struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr); |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 120 | |
Dominik Brodowski | f971dbd | 2010-01-17 18:13:31 +0100 | [diff] [blame] | 121 | void pcmcia_parse_uevents(struct pcmcia_socket *socket, unsigned int events); |
| 122 | #define PCMCIA_UEVENT_EJECT 0x0001 |
| 123 | #define PCMCIA_UEVENT_INSERT 0x0002 |
| 124 | #define PCMCIA_UEVENT_SUSPEND 0x0004 |
| 125 | #define PCMCIA_UEVENT_RESUME 0x0008 |
Dominik Brodowski | af461fc | 2010-01-17 19:30:53 +0100 | [diff] [blame] | 126 | #define PCMCIA_UEVENT_REQUERY 0x0010 |
Dominik Brodowski | 994917f | 2008-08-31 15:20:26 +0200 | [diff] [blame] | 127 | |
| 128 | struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt); |
| 129 | void pcmcia_put_socket(struct pcmcia_socket *skt); |
| 130 | |
Dominik Brodowski | b60a5ed | 2008-08-25 23:32:37 +0200 | [diff] [blame] | 131 | /* |
| 132 | * Stuff internal to module "pcmcia". |
| 133 | */ |
| 134 | /* ds.c */ |
| 135 | extern struct bus_type pcmcia_bus_type; |
| 136 | |
Dominik Brodowski | 5716d41 | 2010-07-11 09:51:14 +0200 | [diff] [blame] | 137 | struct pcmcia_device; |
| 138 | |
Dominik Brodowski | b60a5ed | 2008-08-25 23:32:37 +0200 | [diff] [blame] | 139 | /* pcmcia_resource.c */ |
| 140 | extern int pcmcia_release_configuration(struct pcmcia_device *p_dev); |
Dominik Brodowski | a3ac9af | 2010-01-06 14:03:03 +0100 | [diff] [blame] | 141 | extern int pcmcia_validate_mem(struct pcmcia_socket *s); |
| 142 | extern struct resource *pcmcia_find_mem_region(u_long base, |
| 143 | u_long num, |
| 144 | u_long align, |
| 145 | int low, |
| 146 | struct pcmcia_socket *s); |
| 147 | |
Dominik Brodowski | 6f0f38c | 2010-04-08 20:33:16 +0200 | [diff] [blame] | 148 | void pcmcia_cleanup_irq(struct pcmcia_socket *s); |
| 149 | int pcmcia_setup_irq(struct pcmcia_device *p_dev); |
Dominik Brodowski | b60a5ed | 2008-08-25 23:32:37 +0200 | [diff] [blame] | 150 | |
Dominik Brodowski | 6e7b51a | 2010-01-06 13:57:43 +0100 | [diff] [blame] | 151 | /* cistpl.c */ |
Bhumika Goyal | c151206 | 2017-09-30 22:29:54 +0530 | [diff] [blame] | 152 | extern const struct bin_attribute pccard_cis_attr; |
Dominik Brodowski | 6e7b51a | 2010-01-06 13:57:43 +0100 | [diff] [blame] | 153 | |
| 154 | int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, |
| 155 | u_int addr, u_int len, void *ptr); |
Dominik Brodowski | 1d5cc19 | 2010-07-24 12:23:21 +0200 | [diff] [blame] | 156 | int pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, |
| 157 | u_int addr, u_int len, void *ptr); |
Dominik Brodowski | 6e7b51a | 2010-01-06 13:57:43 +0100 | [diff] [blame] | 158 | void release_cis_mem(struct pcmcia_socket *s); |
| 159 | void destroy_cis_cache(struct pcmcia_socket *s); |
| 160 | int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, |
| 161 | cisdata_t code, void *parse); |
| 162 | int pcmcia_replace_cis(struct pcmcia_socket *s, |
| 163 | const u8 *data, const size_t len); |
| 164 | int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *count); |
| 165 | int verify_cis_cache(struct pcmcia_socket *s); |
| 166 | |
Dominik Brodowski | 6e7b51a | 2010-01-06 13:57:43 +0100 | [diff] [blame] | 167 | int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, |
| 168 | tuple_t *tuple); |
| 169 | |
| 170 | int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, |
| 171 | tuple_t *tuple); |
| 172 | |
| 173 | int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple); |
| 174 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | #endif /* _LINUX_CS_INTERNAL_H */ |