/* power control */ switch (state->Vcc) { case 0:
gpio_set_value(GPIO_POWER, 1); /* power off */ break; case 33:
gpio_set_value(GPIO_POWER, 0); /* power on */ break; case 50: default: return -EINVAL;
}
changed = state->flags ^ sock->old_flags;
if (changed & SS_RESET) { if (state->flags & SS_RESET) {
gpio_set_value(GPIO_RESET, 1); /* assert reset */
gpio_set_value(GPIO_OUTEN, 1); /* buffers off */
} else {
gpio_set_value(GPIO_RESET, 0); /* deassert reset */
gpio_set_value(GPIO_OUTEN, 0); /* buffers on */
msleep(500);
}
}
/* check carddetects: GPIO[0:1] must both be low */ if (!gpio_get_value(GPIO_CDA) && !gpio_get_value(GPIO_CDB))
status |= SS_DETECT;
/* determine card voltage: GPIO[208:209] binary value */
i = (!!gpio_get_value(GPIO_VSL)) | ((!!gpio_get_value(GPIO_VSH)) << 1);
switch (i) { case 0: case 1: case 2:
status |= SS_3VCARD; /* 3V card */ break; case 3: /* 5V card, unsupported */ default:
status |= SS_XVCARD; /* treated as unsupported in core */
}
/* GPIO214: low active power switch */
status |= gpio_get_value(GPIO_POWER) ? 0 : SS_POWERON;
/* GPIO204: high-active reset line */
status |= gpio_get_value(GPIO_RESET) ? SS_RESET : SS_READY;
/* other stuff */
status |= gpio_get_value(GPIO_BATTDEAD) ? 0 : SS_BATDEAD;
status |= gpio_get_value(GPIO_BATTWARN) ? 0 : SS_BATWARN;
sock = kzalloc(sizeof(struct xxs1500_pcmcia_sock), GFP_KERNEL); if (!sock) return -ENOMEM;
ret = -ENODEV;
/* 36bit PCMCIA Attribute area address */
r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pcmcia-attr"); if (!r) {
dev_err(&pdev->dev, "missing 'pcmcia-attr' resource!\n"); goto out0;
}
sock->phys_attr = r->start;
/* 36bit PCMCIA Memory area address */
r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pcmcia-mem"); if (!r) {
dev_err(&pdev->dev, "missing 'pcmcia-mem' resource!\n"); goto out0;
}
sock->phys_mem = r->start;
/* 36bit PCMCIA IO area address */
r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pcmcia-io"); if (!r) {
dev_err(&pdev->dev, "missing 'pcmcia-io' resource!\n"); goto out0;
}
sock->phys_io = r->start;
/* * PCMCIA client drivers use the inb/outb macros to access * the IO registers. Since mips_io_port_base is added * to the access address of the mips implementation of * inb/outb, we need to subtract it here because we want * to access the I/O or MEM address directly, without * going through this "mips_io_port_base" mechanism.
*/
sock->virt_io = (void *)(ioremap(sock->phys_io, IO_MAP_SIZE) -
mips_io_port_base);
if (!sock->virt_io) {
dev_err(&pdev->dev, "cannot remap IO area\n");
ret = -ENOMEM; goto out0;
}
/* setup carddetect irq: use one of the 2 GPIOs as an * edge detector.
*/
irq = gpio_to_irq(GPIO_CDA);
irq_set_irq_type(irq, IRQ_TYPE_EDGE_BOTH);
ret = request_irq(irq, cdirq, 0, "pcmcia_carddetect", sock); if (ret) {
dev_err(&pdev->dev, "cannot setup cd irq\n"); goto out1;
}
ret = pcmcia_register_socket(&sock->socket); if (ret) {
dev_err(&pdev->dev, "failed to register\n"); goto out2;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.