コード例 #1
0
/* int init_module(void) */
int can_init(void)
{
int i;
#if LDDK_USE_BLKREQUEST
  extern int Can_request ();
#endif

  DBGin("init_module");
  printk("Init can\n");
  
  //while(1);
  
#ifdef LDDK_USE_REGISTER
    if( register_chrdev(Can_major, "Can", &can_fops) ) {
	  printk("can't get Major %d\n", Can_major);
      return(-EIO);
    }
  

#endif
    {
        printk("CAN Driver for Open Cores CAN MAC (c) " __DATE__  " " __TIME__ "\n");
        //printk(__CAN_TYPE__ "CAN Driver " VERSION " (c) " __DATE__  " " __TIME__ "\n");
        printk(" H. Obereder (gleichmann)\n");
        /*   printk(" H.J. Oertel ([email protected])\n");*/
	/* printk(" C.Schroeter ([email protected]), H.D. Stich\n");  */
	    
    }

    /*
    initialize the variables layed down in /proc/sys/Can
    */
    for (i = 0; i < MAX_CHANNELS; i++) {
	IOModel[i]       = IO_MODEL;
	Baud[i]          = 500;

	AccCode[i]       = AccMask[i] =  STD_MASK;
	Timeout[i]       = 100;
	Outc[i]          = CAN_OUTC_VAL;
	IRQ_requested[i] = 0;
	Can_minors[i]    = i;		/* used as IRQ dev_id */

/*Byte access for LEON3 Sparc */
/*changed by hobe */

#define LEON3 1

#ifdef LEON3

        Base[i] = (0xFFFC0000);
	IRQ[i] = 13;
#endif
        
        
#if defined(MCF5282)
	/* we have a really fixed address here */
	Base[i] = (MCF_MBAR + 0x1c0000);
	/* Because the MCF FlexCAN is using more then 1 Interrupt vector,
	 * what should be specified here ?
	 * For information purpose let's only specify  the first used here
	 */
	IRQ[i] = 136;
#endif

#if defined(CCPC104)
        pc104_irqsetup();
        IRQ[i]           = 67;          /* The only possible vector on CTRLink's 5282 CPU */
        Base[i]          = 0x40000280;
#endif
    }
    /* after initializing channel based parameters
     * finisch some entries 
     * and do drivers specific initialization
     */
    IOModel[i] = '\0';

    /* CAN_register_dump(); */

#if CAN4LINUX_PCI
    /* make some sysctl entries read only
     * IRQ number
     * Base address
     * and access mode
     * are fixed and provided by the PCI BIOS
     */
    Can_sysctl_table[SYSCTL_IRQ - 1].mode = 0444;
    Can_sysctl_table[SYSCTL_BASE - 1].mode = 0444;
    /* printk("CAN pci test loaded\n"); */
    /* dbgMask = 0; */
    pcimod_scan();
#endif
#if defined(CCPC104)
    /* The only possible interrupt could be IRQ4 on the PC104 Board */
    Can_sysctl_table[SYSCTL_IRQ - 1].mode = 0444;
#endif
#if defined(MCF5282)
    Can_sysctl_table[SYSCTL_BASE - 1].mode = 0444;
#endif

/* #if LDDK_USE_PROCINFO */
/* #error procinfo */
    /* register_procinfo(); */
/* #endif */
/* #if LDDK_USE_SYSCTL */
    register_systables();
/* #endif */

#if LDDK_USE_BLKREQUEST
    blk_dev[Can_major].request_fn = Can_request ;
#endif

    DBGout();
    return 0;
}
コード例 #2
0
ファイル: can_core.c プロジェクト: robacklin/uclinux-linux
/* int init_module(void) */
static int __init can_init(void)
{
int i;
#if LDDK_USE_BLKREQUEST
  extern int Can_request ();
#endif

  DBGin("init_module");
#ifdef CONFIG_DEVFS_FS
    devfs_mk_cdev (MKDEV(Can_MAJOR, 0), S_IRUSR | S_IWUSR | S_IFCHR, "can0", 0);			
#endif
#if LDDK_USE_REGISTER
    if( register_chrdev(Can_major, "can", &can_fops) ) {
	  printk("can't get Major %d\n", Can_major);
      return(-EIO);
    }
#endif
    {
	printk(__CAN_TYPE__ "CAN Driver " VERSION " (c) " __DATE__  " " __TIME__ "\n");	    
    }
    /*
    initialize the variables layed down in /proc/sys/Can
    */
    for (i = 0; i < MAX_CHANNELS; i++) {
	IOModel[i]       = IO_MODEL;
	Baud[i]          = 125;

	AccCode[i]       = AccMask[i] =  STD_MASK;
	Timeout[i]       = 100;
	Outc[i]          = CAN_OUTC_VAL;
	IRQ_requested[i] = 0;
	Can_minors[i]    = i;		/* used as IRQ dev_id */

#if defined(CONFIG_FIRE_ENGINE)
	/* we have a really fixed address here */
	Base[i] = (MCF_MBAR + 0xa000 + CAN_MODULE*(0x0800));
	/* Because the MCF FlexCAN is using more then 1 Interrupt vector,
	 * what should be specified here ?
	 * For information purpose let's only specify  the first used here
	 */
	IRQ[i] = 64 + ISC_CANn_MBOR(CAN_MODULE);
#endif

#if defined(CONFIG_M528x)
	Base[i] = (MCF_MBAR + 0x1c0000);
	IRQ[i] = 136;
#endif

#if defined(CONFIG_M532x)
	/* we have a really fixed address here */
	Base[i] = MCF_FLEXCAN_BASEADDR(CAN_MODULE);
	/* Because the MCF FlexCAN is using more then 1 Interrupt vector,
	 * what should be specified here ?
	 * For information purpose let's only specify  the first used here
	 */
	IRQ[i] = 128;

	/* Enable GPIO pins for CANTX, CANRX */
#if defined(CONFIG_M5329EVB)
	/* On Freescale 5329 EVB CAN pins are muxed with I2C pins */
	MCF_GPIO_PAR_FECI2C &= 0xF0;
	MCF_GPIO_PAR_FECI2C |= MCF_GPIO_PAR_FECI2C_PAR_SDA(0x2) | MCF_GPIO_PAR_FECI2C_PAR_SCL(0x2);
#elif defined(CONFIG_UC532X) || defined(CONFIG_UC53281EVM)
#ifdef CONFIG_PAR_LCDDATA_FOR_CAN
	/* we may use these pins for CAN signal */
	MCF_GPIO_PAR_LCDDATA &= 0x0F;
	MCF_GPIO_PAR_LCDDATA |= MCF_GPIO_PAR_LCDDATA_PAR_LD17(0x2) | MCF_GPIO_PAR_LCDDATA_PAR_LD16(0x2);
#else
	MCF_GPIO_PAR_FECI2C &= 0xF0;
	MCF_GPIO_PAR_FECI2C |= MCF_GPIO_PAR_FECI2C_PAR_SDA(0x2) | MCF_GPIO_PAR_FECI2C_PAR_SCL(0x2);
#endif
#else
	/* Could be changed for other boards. Depends on board design */
	MCF_GPIO_PDDR_SSI = 0;
	MCF_GPIO_PAR_SSI = MCF_GPIO_PAR_SSI_PAR_RXD(0x1) | MCF_GPIO_PAR_SSI_PAR_TXD(0x1);
#endif
#endif

#if defined(CONFIG_M5253EVB)
	/* we have a really fixed address here */
	Base[i] = MCF_FLEXCAN_BASEADDR(i);
	/* Because the MCF FlexCAN is using more then 1 Interrupt vector,
	 * what should be specified here ?
	 * For information purpose let's only specify  the first used here
	 */
	IRQ[i] = 128 + i;
#endif
	
#if defined(CCPC104)
        pc104_irqsetup();
        IRQ[i]           = 67;          /* The only possible vector on CTRLink's 5282 CPU */
        Base[i]          = 0x40000280;
#endif
    }
    /* after initializing channel based parameters
     * finisch some entries 
     * and do drivers specific initialization
     */
    IOModel[i] = '\0';

    /* CAN_register_dump(); */

#if CAN4LINUX_PCI
    /* make some sysctl entries read only
     * IRQ number
     * Base address
     * and access mode
     * are fixed and provided by the PCI BIOS
     */
    Can_sysctl_table[SYSCTL_IRQ - 1].mode = 0444;
    Can_sysctl_table[SYSCTL_BASE - 1].mode = 0444;
    /* printk("CAN pci test loaded\n"); */
    /* dbgMask = 0; */
    pcimod_scan();
#endif
#if defined(CCPC104)
    /* The only possible interrupt could be IRQ4 on the PC104 Board */
    Can_sysctl_table[SYSCTL_IRQ - 1].mode = 0444;
#endif
#if defined(CONFIG_FIRE_ENGINE)
    Can_sysctl_table[SYSCTL_BASE - 1].mode = 0444;
#endif

#if defined(CONFIG_M532x) || defined(CONFIG_M5253) || defined(CONFIG_M528x)
    Can_sysctl_table[SYSCTL_BASE - 1].mode = 0444;
#endif

#if LDDK_USE_PROCINFO
/* #error procinfo */
     register_procinfo();
#endif
#if LDDK_USE_SYSCTL
    register_systables();
#endif 

#if LDDK_USE_BLKREQUEST
    blk_dev[Can_major].request_fn = Can_request;
#endif

    DBGout();
    return 0;
}