Lines Matching +full:mem +full:- +full:io

1 // SPDX-License-Identifier: GPL-2.0-only
3 * PCMCIA high-level CIS access functions
10 * Copyright (C) 2004-2010 Dominik Brodowski
27 * pccard_read_tuple() - internal CIS tuple access
44 dev_warn(&s->dev, "no memory to read tuple\n"); in pccard_read_tuple()
45 return -ENOMEM; in pccard_read_tuple()
68 * pccard_loop_tuple() - loop over tuples in the CIS
94 dev_warn(&s->dev, "no memory to read tuple\n"); in pccard_loop_tuple()
95 return -ENOMEM; in pccard_loop_tuple()
127 * pcmcia_io_cfg_data_width() - convert cfgtable to data path width parameter
148 * pcmcia_do_loop_config() - internal helper for pcmcia_loop_config()
157 struct pcmcia_device *p_dev = cfg_mem->p_dev; in pcmcia_do_loop_config()
158 cistpl_cftable_entry_t *cfg = &parse->cftable_entry; in pcmcia_do_loop_config()
159 cistpl_cftable_entry_t *dflt = &cfg_mem->dflt; in pcmcia_do_loop_config()
160 unsigned int flags = p_dev->config_flags; in pcmcia_do_loop_config()
161 unsigned int vcc = p_dev->socket->socket.Vcc; in pcmcia_do_loop_config()
163 dev_dbg(&p_dev->dev, "testing configuration %x, autoconf %x\n", in pcmcia_do_loop_config()
164 cfg->index, flags); in pcmcia_do_loop_config()
167 cfg_mem->p_dev->config_index = cfg->index; in pcmcia_do_loop_config()
168 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) in pcmcia_do_loop_config()
169 cfg_mem->dflt = *cfg; in pcmcia_do_loop_config()
173 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { in pcmcia_do_loop_config()
174 if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) in pcmcia_do_loop_config()
175 return -ENODEV; in pcmcia_do_loop_config()
176 } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { in pcmcia_do_loop_config()
177 if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) in pcmcia_do_loop_config()
178 return -ENODEV; in pcmcia_do_loop_config()
184 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) in pcmcia_do_loop_config()
185 p_dev->vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; in pcmcia_do_loop_config()
186 else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) in pcmcia_do_loop_config()
187 p_dev->vpp = in pcmcia_do_loop_config()
188 dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; in pcmcia_do_loop_config()
192 if ((flags & CONF_AUTO_AUDIO) && (cfg->flags & CISTPL_CFTABLE_AUDIO)) in pcmcia_do_loop_config()
193 p_dev->config_flags |= CONF_ENABLE_SPKR; in pcmcia_do_loop_config()
196 /* IO window settings? */ in pcmcia_do_loop_config()
198 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; in pcmcia_do_loop_config() local
201 p_dev->resource[0]->start = p_dev->resource[0]->end = 0; in pcmcia_do_loop_config()
202 p_dev->resource[1]->start = p_dev->resource[1]->end = 0; in pcmcia_do_loop_config()
203 if (io->nwin == 0) in pcmcia_do_loop_config()
204 return -ENODEV; in pcmcia_do_loop_config()
206 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; in pcmcia_do_loop_config()
207 p_dev->resource[0]->flags |= in pcmcia_do_loop_config()
208 pcmcia_io_cfg_data_width(io->flags); in pcmcia_do_loop_config()
209 if (io->nwin > 1) { in pcmcia_do_loop_config()
213 i = (io->win[1].len > io->win[0].len); in pcmcia_do_loop_config()
214 p_dev->resource[1]->flags = p_dev->resource[0]->flags; in pcmcia_do_loop_config()
215 p_dev->resource[1]->start = io->win[1-i].base; in pcmcia_do_loop_config()
216 p_dev->resource[1]->end = io->win[1-i].len; in pcmcia_do_loop_config()
218 p_dev->resource[0]->start = io->win[i].base; in pcmcia_do_loop_config()
219 p_dev->resource[0]->end = io->win[i].len; in pcmcia_do_loop_config()
220 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK; in pcmcia_do_loop_config()
223 /* MEM window settings? */ in pcmcia_do_loop_config()
226 cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; in pcmcia_do_loop_config() local
228 p_dev->resource[2]->start = p_dev->resource[2]->end = 0; in pcmcia_do_loop_config()
229 if (mem->nwin == 0) in pcmcia_do_loop_config()
230 return -ENODEV; in pcmcia_do_loop_config()
232 p_dev->resource[2]->start = mem->win[0].host_addr; in pcmcia_do_loop_config()
233 p_dev->resource[2]->end = mem->win[0].len; in pcmcia_do_loop_config()
234 if (p_dev->resource[2]->end < 0x1000) in pcmcia_do_loop_config()
235 p_dev->resource[2]->end = 0x1000; in pcmcia_do_loop_config()
236 p_dev->card_addr = mem->win[0].card_addr; in pcmcia_do_loop_config()
239 dev_dbg(&p_dev->dev, in pcmcia_do_loop_config()
241 p_dev->config_index, p_dev->resource[0], p_dev->resource[1], in pcmcia_do_loop_config()
242 p_dev->resource[2], p_dev->io_lines); in pcmcia_do_loop_config()
244 return cfg_mem->conf_check(p_dev, cfg_mem->priv_data); in pcmcia_do_loop_config()
248 * pcmcia_loop_config() - loop over configuration options
256 * the driver-specific conf_check() for each one, checking whether
269 return -ENOMEM; in pcmcia_loop_config()
271 cfg_mem->p_dev = p_dev; in pcmcia_loop_config()
272 cfg_mem->conf_check = conf_check; in pcmcia_loop_config()
273 cfg_mem->priv_data = priv_data; in pcmcia_loop_config()
275 ret = pccard_loop_tuple(p_dev->socket, p_dev->func, in pcmcia_loop_config()
276 CISTPL_CFTABLE_ENTRY, &cfg_mem->parse, in pcmcia_loop_config()
294 * pcmcia_do_loop_tuple() - internal helper for pcmcia_loop_config()
304 return loop->loop_tuple(loop->p_dev, tuple, loop->priv_data); in pcmcia_do_loop_tuple()
308 * pcmcia_loop_tuple() - loop over tuples in the CIS
330 return pccard_loop_tuple(p_dev->socket, p_dev->func, code, NULL, in pcmcia_loop_tuple()
342 * pcmcia_do_get_tuple() - internal helper for pcmcia_get_tuple()
355 *get->buf = kzalloc(tuple->TupleDataLen, GFP_KERNEL); in pcmcia_do_get_tuple()
356 if (*get->buf) { in pcmcia_do_get_tuple()
357 get->len = tuple->TupleDataLen; in pcmcia_do_get_tuple()
358 memcpy(*get->buf, tuple->TupleData, tuple->TupleDataLen); in pcmcia_do_get_tuple()
360 dev_dbg(&p_dev->dev, "do_get_tuple: out of memory\n"); in pcmcia_do_get_tuple()
365 * pcmcia_get_tuple() - get first tuple from CIS
391 * pcmcia_do_get_mac() - internal helper for pcmcia_get_mac_from_cis()
396 * to struct net_device->dev_addr[i].
403 if (tuple->TupleData[0] != CISTPL_FUNCE_LAN_NODE_ID) in pcmcia_do_get_mac()
404 return -EINVAL; in pcmcia_do_get_mac()
405 if (tuple->TupleDataLen < ETH_ALEN + 2) { in pcmcia_do_get_mac()
406 dev_warn(&p_dev->dev, "Invalid CIS tuple length for " in pcmcia_do_get_mac()
408 return -EINVAL; in pcmcia_do_get_mac()
411 if (tuple->TupleData[1] != ETH_ALEN) { in pcmcia_do_get_mac()
412 dev_warn(&p_dev->dev, "Invalid header for LAN_NODE_ID\n"); in pcmcia_do_get_mac()
413 return -EINVAL; in pcmcia_do_get_mac()
415 eth_hw_addr_set(dev, &tuple->TupleData[2]); in pcmcia_do_get_mac()
420 * pcmcia_get_mac_from_cis() - read out MAC address from CISTPL_FUNCE
425 * CISTPL_FUNCE and stores it into struct net_device *dev->dev_addr which