Path: blob/master/drivers/isdn/hardware/mISDN/hfc_multi_8xx.h
15112 views
/*1* For License see notice in hfc_multi.c2*3* special IO and init functions for the embedded XHFC board4* from Speech Design5*6*/78#include <asm/8xx_immap.h>910/* Change this to the value used by your board */11#ifndef IMAP_ADDR12#define IMAP_ADDR 0xFFF0000013#endif1415static void16#ifdef HFC_REGISTER_DEBUG17HFC_outb_embsd(struct hfc_multi *hc, u_char reg, u_char val,18const char *function, int line)19#else20HFC_outb_embsd(struct hfc_multi *hc, u_char reg, u_char val)21#endif22{23hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;24writeb(reg, hc->xhfc_memaddr);25hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);26writeb(val, hc->xhfc_memdata);27}28static u_char29#ifdef HFC_REGISTER_DEBUG30HFC_inb_embsd(struct hfc_multi *hc, u_char reg, const char *function, int line)31#else32HFC_inb_embsd(struct hfc_multi *hc, u_char reg)33#endif34{35hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;36writeb(reg, hc->xhfc_memaddr);37hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);38return readb(hc->xhfc_memdata);39}40static u_short41#ifdef HFC_REGISTER_DEBUG42HFC_inw_embsd(struct hfc_multi *hc, u_char reg, const char *function, int line)43#else44HFC_inw_embsd(struct hfc_multi *hc, u_char reg)45#endif46{47hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;48writeb(reg, hc->xhfc_memaddr);49hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);50return readb(hc->xhfc_memdata);51}52static void53#ifdef HFC_REGISTER_DEBUG54HFC_wait_embsd(struct hfc_multi *hc, const char *function, int line)55#else56HFC_wait_embsd(struct hfc_multi *hc)57#endif58{59hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;60writeb(R_STATUS, hc->xhfc_memaddr);61hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);62while (readb(hc->xhfc_memdata) & V_BUSY)63cpu_relax();64}6566/* write fifo data (EMBSD) */67void68write_fifo_embsd(struct hfc_multi *hc, u_char *data, int len)69{70hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;71*hc->xhfc_memaddr = A_FIFO_DATA0;72hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);73while (len) {74*hc->xhfc_memdata = *data;75data++;76len--;77}78}7980/* read fifo data (EMBSD) */81void82read_fifo_embsd(struct hfc_multi *hc, u_char *data, int len)83{84hc->immap->im_ioport.iop_padat |= PA_XHFC_A0;85*hc->xhfc_memaddr = A_FIFO_DATA0;86hc->immap->im_ioport.iop_padat &= ~(PA_XHFC_A0);87while (len) {88*data = (u_char)(*hc->xhfc_memdata);89data++;90len--;91}92}9394static int95setup_embedded(struct hfc_multi *hc, struct hm_map *m)96{97printk(KERN_INFO98"HFC-multi: card manufacturer: '%s' card name: '%s' clock: %s\n",99m->vendor_name, m->card_name, m->clock2 ? "double" : "normal");100101hc->pci_dev = NULL;102if (m->clock2)103test_and_set_bit(HFC_CHIP_CLOCK2, &hc->chip);104105hc->leds = m->leds;106hc->ledstate = 0xAFFEAFFE;107hc->opticalsupport = m->opticalsupport;108109hc->pci_iobase = 0;110hc->pci_membase = 0;111hc->xhfc_membase = NULL;112hc->xhfc_memaddr = NULL;113hc->xhfc_memdata = NULL;114115/* set memory access methods */116if (m->io_mode) /* use mode from card config */117hc->io_mode = m->io_mode;118switch (hc->io_mode) {119case HFC_IO_MODE_EMBSD:120test_and_set_bit(HFC_CHIP_EMBSD, &hc->chip);121hc->slots = 128; /* required */122/* fall through */123hc->HFC_outb = HFC_outb_embsd;124hc->HFC_inb = HFC_inb_embsd;125hc->HFC_inw = HFC_inw_embsd;126hc->HFC_wait = HFC_wait_embsd;127hc->read_fifo = read_fifo_embsd;128hc->write_fifo = write_fifo_embsd;129hc->xhfc_origmembase = XHFC_MEMBASE + XHFC_OFFSET * hc->id;130hc->xhfc_membase = (u_char *)ioremap(hc->xhfc_origmembase,131XHFC_MEMSIZE);132if (!hc->xhfc_membase) {133printk(KERN_WARNING134"HFC-multi: failed to remap xhfc address space. "135"(internal error)\n");136return -EIO;137}138hc->xhfc_memaddr = (u_long *)(hc->xhfc_membase + 4);139hc->xhfc_memdata = (u_long *)(hc->xhfc_membase);140printk(KERN_INFO141"HFC-multi: xhfc_membase:%#lx xhfc_origmembase:%#lx "142"xhfc_memaddr:%#lx xhfc_memdata:%#lx\n",143(u_long)hc->xhfc_membase, hc->xhfc_origmembase,144(u_long)hc->xhfc_memaddr, (u_long)hc->xhfc_memdata);145break;146default:147printk(KERN_WARNING "HFC-multi: Invalid IO mode.\n");148return -EIO;149}150151/* Prepare the MPC8XX PortA 10 as output (address/data selector) */152hc->immap = (struct immap *)(IMAP_ADDR);153hc->immap->im_ioport.iop_papar &= ~(PA_XHFC_A0);154hc->immap->im_ioport.iop_paodr &= ~(PA_XHFC_A0);155hc->immap->im_ioport.iop_padir |= PA_XHFC_A0;156157/* Prepare the MPC8xx PortB __X__ as input (ISDN__X__IRQ) */158hc->pb_irqmsk = (PB_XHFC_IRQ1 << hc->id);159hc->immap->im_cpm.cp_pbpar &= ~(hc->pb_irqmsk);160hc->immap->im_cpm.cp_pbodr &= ~(hc->pb_irqmsk);161hc->immap->im_cpm.cp_pbdir &= ~(hc->pb_irqmsk);162163/* At this point the needed config is done */164/* fifos are still not enabled */165return 0;166}167168169