Lines Matching +full:active +full:- +full:semi
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2007 PA Semi, Inc
27 static const char driver_name[] = "electra-cf";
34 unsigned active:1; member
59 gpio = in_le32(cf->gpio_base+0x40); in electra_cf_present()
60 return !(gpio & (1 << cf->gpio_detect)); in electra_cf_present()
74 if (present != cf->present) { in electra_cf_timer()
75 cf->present = present; in electra_cf_timer()
76 pcmcia_parse_events(&cf->socket, SS_DETECT); in electra_cf_timer()
79 if (cf->active) in electra_cf_timer()
80 mod_timer(&cf->timer, jiffies + POLL_INTERVAL); in electra_cf_timer()
87 electra_cf_timer(&cf->timer); in electra_cf_irq()
96 return -EINVAL; in electra_cf_get_status()
104 s->pci_irq = cf->irq; in electra_cf_get_status()
120 vcc = (s->flags & SS_RESET) ? 0 : s->Vcc; in electra_cf_set_socket()
127 gpio = (1 << cf->gpio_3v); in electra_cf_set_socket()
130 gpio = (1 << cf->gpio_5v); in electra_cf_set_socket()
133 return -EINVAL; in electra_cf_set_socket()
136 gpio |= 1 << (cf->gpio_3v + 16); /* enwr */ in electra_cf_set_socket()
137 gpio |= 1 << (cf->gpio_5v + 16); /* enwr */ in electra_cf_set_socket()
138 out_le32(cf->gpio_base+0x90, gpio); in electra_cf_set_socket()
141 driver_name, s->Vcc, s->io_irq, s->flags, s->csc_mask); in electra_cf_set_socket()
157 if (map->card_start) in electra_cf_set_mem_map()
158 return -EINVAL; in electra_cf_set_mem_map()
160 map->static_start = cf->mem_phys; in electra_cf_set_mem_map()
161 map->flags &= MAP_ACTIVE|MAP_ATTRIB; in electra_cf_set_mem_map()
162 if (!(map->flags & MAP_ATTRIB)) in electra_cf_set_mem_map()
163 map->static_start += 0x800; in electra_cf_set_mem_map()
177 struct device *device = &ofdev->dev; in electra_cf_probe()
178 struct device_node *np = ofdev->dev.of_node; in electra_cf_probe()
181 int status = -ENOMEM; in electra_cf_probe()
187 return -EINVAL; in electra_cf_probe()
191 return -EINVAL; in electra_cf_probe()
195 return -ENOMEM; in electra_cf_probe()
197 timer_setup(&cf->timer, electra_cf_timer, 0); in electra_cf_probe()
198 cf->irq = 0; in electra_cf_probe()
200 cf->ofdev = ofdev; in electra_cf_probe()
201 cf->mem_phys = mem.start; in electra_cf_probe()
202 cf->mem_size = PAGE_ALIGN(resource_size(&mem)); in electra_cf_probe()
203 cf->mem_base = ioremap(cf->mem_phys, cf->mem_size); in electra_cf_probe()
204 if (!cf->mem_base) in electra_cf_probe()
206 cf->io_size = PAGE_ALIGN(resource_size(&io)); in electra_cf_probe()
207 cf->io_virt = ioremap_phb(io.start, cf->io_size); in electra_cf_probe()
208 if (!cf->io_virt) in electra_cf_probe()
211 cf->gpio_base = ioremap(0xfc103000, 0x1000); in electra_cf_probe()
212 if (!cf->gpio_base) in electra_cf_probe()
216 cf->io_base = (unsigned long)cf->io_virt - VMALLOC_END; in electra_cf_probe()
217 cf->iomem.start = (unsigned long)cf->mem_base; in electra_cf_probe()
218 cf->iomem.end = (unsigned long)cf->mem_base + (mem.end - mem.start); in electra_cf_probe()
219 cf->iomem.flags = IORESOURCE_MEM; in electra_cf_probe()
221 cf->irq = irq_of_parse_and_map(np, 0); in electra_cf_probe()
223 status = request_irq(cf->irq, electra_cf_irq, IRQF_SHARED, in electra_cf_probe()
230 cf->socket.pci_irq = cf->irq; in electra_cf_probe()
232 status = -EINVAL; in electra_cf_probe()
234 prop = of_get_property(np, "card-detect-gpio", NULL); in electra_cf_probe()
237 cf->gpio_detect = *prop; in electra_cf_probe()
239 prop = of_get_property(np, "card-vsense-gpio", NULL); in electra_cf_probe()
242 cf->gpio_vsense = *prop; in electra_cf_probe()
244 prop = of_get_property(np, "card-3v-gpio", NULL); in electra_cf_probe()
247 cf->gpio_3v = *prop; in electra_cf_probe()
249 prop = of_get_property(np, "card-5v-gpio", NULL); in electra_cf_probe()
252 cf->gpio_5v = *prop; in electra_cf_probe()
254 cf->socket.io_offset = cf->io_base; in electra_cf_probe()
256 /* reserve chip-select regions */ in electra_cf_probe()
257 if (!request_mem_region(cf->mem_phys, cf->mem_size, driver_name)) { in electra_cf_probe()
258 status = -ENXIO; in electra_cf_probe()
263 if (!request_region(cf->io_base, cf->io_size, driver_name)) { in electra_cf_probe()
264 status = -ENXIO; in electra_cf_probe()
269 cf->socket.owner = THIS_MODULE; in electra_cf_probe()
270 cf->socket.dev.parent = &ofdev->dev; in electra_cf_probe()
271 cf->socket.ops = &electra_cf_ops; in electra_cf_probe()
272 cf->socket.resource_ops = &pccard_static_ops; in electra_cf_probe()
273 cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP | in electra_cf_probe()
275 cf->socket.map_size = 0x800; in electra_cf_probe()
277 status = pcmcia_register_socket(&cf->socket); in electra_cf_probe()
284 cf->mem_phys, io.start, cf->irq); in electra_cf_probe()
286 cf->active = 1; in electra_cf_probe()
287 electra_cf_timer(&cf->timer); in electra_cf_probe()
291 release_region(cf->io_base, cf->io_size); in electra_cf_probe()
293 release_mem_region(cf->mem_phys, cf->mem_size); in electra_cf_probe()
295 if (cf->irq) in electra_cf_probe()
296 free_irq(cf->irq, cf); in electra_cf_probe()
298 iounmap(cf->gpio_base); in electra_cf_probe()
300 device_init_wakeup(&ofdev->dev, 0); in electra_cf_probe()
301 iounmap(cf->io_virt); in electra_cf_probe()
303 iounmap(cf->mem_base); in electra_cf_probe()
312 struct device *device = &ofdev->dev; in electra_cf_remove()
317 cf->active = 0; in electra_cf_remove()
318 pcmcia_unregister_socket(&cf->socket); in electra_cf_remove()
319 free_irq(cf->irq, cf); in electra_cf_remove()
320 timer_shutdown_sync(&cf->timer); in electra_cf_remove()
322 iounmap(cf->io_virt); in electra_cf_remove()
323 iounmap(cf->mem_base); in electra_cf_remove()
324 iounmap(cf->gpio_base); in electra_cf_remove()
325 release_mem_region(cf->mem_phys, cf->mem_size); in electra_cf_remove()
326 release_region(cf->io_base, cf->io_size); in electra_cf_remove()
333 .compatible = "electra-cf",
352 MODULE_DESCRIPTION("PA Semi Electra CF driver");