/* * The board configuration is probably following: * RX1 is connected to ground. * TX1 is not connected. * CLKO is not connected. * Setting the OCR register to 0xDA is a good idea. * This means normal output mode , push-pull and the correct polarity.
*/ #define EMS_PCMCIA_OCR (OCR_TX0_PUSHPULL | OCR_TX1_PUSHPULL)
/* * In the CDR register, you should set CBP to 1. * You will probably also want to set the clock divider value to 7 * (meaning direct oscillator output) because the second SJA1000 chip * is driven by the first one CLKOUT output.
*/ #define EMS_PCMCIA_CDR (CDR_CBP | CDR_CLKOUT_MASK) #define EMS_PCMCIA_MEM_SIZE 4096 /* Size of the remapped io-memory */ #define EMS_PCMCIA_CAN_BASE_OFFSET 0x100 /* Offset where controllers starts */ #define EMS_PCMCIA_CAN_CTRL_SIZE 0x80 /* Memory size for each controller */
#define EMS_CMD_RESET 0x00 /* Perform a reset of the card */ #define EMS_CMD_MAP 0x03 /* Map CAN controllers into card' memory */ #define EMS_CMD_UMAP 0x02 /* Unmap CAN controllers from card' memory */
/* Card not present */ if (readw(card->base_addr) != 0xAA55) return IRQ_HANDLED;
do {
again = 0;
/* Check interrupt for each channel */ for (i = 0; i < card->channels; i++) {
dev = card->net_dev[i]; if (!dev) continue;
if (sja1000_interrupt(irq, dev) == IRQ_HANDLED)
again = 1;
} /* At least one channel handled the interrupt */ if (again)
retval = IRQ_HANDLED;
} while (again);
return retval;
}
/* * Check if a CAN controller is present at the specified location * by trying to set 'em into the PeliCAN mode
*/ staticinlineint ems_pcmcia_check_chan(struct sja1000_priv *priv)
{ /* Make sure SJA1000 is in reset mode */
ems_pcmcia_write_reg(priv, SJA1000_MOD, 1);
ems_pcmcia_write_reg(priv, SJA1000_CDR, CDR_PELICAN);
/* * Probe PCI device for EMS CAN signature and register each available * CAN channel to SJA1000 Socket-CAN subsystem.
*/ staticint ems_pcmcia_add_card(struct pcmcia_device *pdev, unsignedlong base)
{ struct sja1000_priv *priv; struct net_device *dev; struct ems_pcmcia_card *card; int err, i;
/* Allocating card structures to hold addresses, ... */
card = kzalloc(sizeof(struct ems_pcmcia_card), GFP_KERNEL); if (!card) return -ENOMEM;
/* Make sure CAN controllers are mapped into card's memory space */
writeb(EMS_CMD_MAP, card->base_addr);
/* Detect available channels */ for (i = 0; i < EMS_PCMCIA_MAX_CHAN; i++) {
dev = alloc_sja1000dev(0); if (!dev) {
err = -ENOMEM; goto failure_cleanup;
}
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.