]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/include/mpc5200.h
79dbc300d7e3cc204c090d5562c26c751422de46
[lincan.git] / lincan / include / mpc5200.h
1 /**************************************************************************/
2 /* File: mpc5200.h - Freescale MPC5200 MSCAN controller support           */
3 /*                                                                        */
4 /* LinCAN - (Not only) Linux CAN bus driver                               */
5 /* Copyright (C) 2002-2009 DCE FEE CTU Prague <http://dce.felk.cvut.cz>   */
6 /* Copyright (C) 2002-2009 Pavel Pisa <pisa@cmp.felk.cvut.cz>             */
7 /* Copyright (C) 2007-2008 Martin Petera <peterm4@fel.cvut.cz>            */
8 /* Funded by OCERA and FRESCOR IST projects                               */
9 /* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl>      */
10 /*                                                                        */
11 /* LinCAN is free software; you can redistribute it and/or modify it      */
12 /* under terms of the GNU General Public License as published by the      */
13 /* Free Software Foundation; either version 2, or (at your option) any    */
14 /* later version.  LinCAN is distributed in the hope that it will be      */
15 /* useful, but WITHOUT ANY WARRANTY; without even the implied warranty    */
16 /* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU    */
17 /* General Public License for more details. You should have received a    */
18 /* copy of the GNU General Public License along with LinCAN; see file     */
19 /* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,  */
20 /* Cambridge, MA 02139, USA.                                              */
21 /*                                                                        */
22 /* To allow use of LinCAN in the compact embedded systems firmware        */
23 /* and RT-executives (RTEMS for example), main authors agree with next    */
24 /* special exception:                                                     */
25 /*                                                                        */
26 /* Including LinCAN header files in a file, instantiating LinCAN generics */
27 /* or templates, or linking other files with LinCAN objects to produce    */
28 /* an application image/executable, does not by itself cause the          */
29 /* resulting application image/executable to be covered by                */
30 /* the GNU General Public License.                                        */
31 /* This exception does not however invalidate any other reasons           */
32 /* why the executable file might be covered by the GNU Public License.    */
33 /* Publication of enhanced or derived LinCAN files is required although.  */
34 /**************************************************************************/
35
36 #ifndef LINCAN_MPC5200_H
37 #define LINCAN_MPC5200_H
38
39 /* Change this to distinguish between original MIDAM board and CTU daughterboard aka RYU */
40 #define MSCAN_MIDAM     2
41
42
43 /* MPC5200 has two CAN controlers
44  * however MIDAM board uses only one controler
45  * RYU board uses both
46  */
47 #ifdef MSCAN_MIDAM
48         #define NR_MSCAN        1
49 #else
50         #ifdef MSCAN_RYU
51                 #define NR_MSCAN        2
52         #else
53                 #define NR_MSCAN        0
54         #endif /* MSCAN_RYU */
55 #endif /* MSCAN_MIDAM */
56
57
58 #define NR_82527        0
59 #define NR_SJA1000      0
60 #define NR_ALL          (NR_82527 + NR_SJA1000 + NR_MSCAN)
61
62
63 /* IRQ is read from OpenFirmware nodes */
64
65 #define MPC5200_CAN_CHIP_OFFSET         0x80
66 #define IO_RANGE                        0x80
67
68
69 /* Clock frequency - used for baudrate */
70 #define MPC5200_SHARK_SYS_XTAL_FREQ     396000000       /* 396 MHz */
71 #define MPC5200_SHARK_IPB_FREQ          132000000       /* derived from XTAL by dividing: 132 MHz */
72 /* got from /proc/device-tree/cpus/PowerPC,5200@0/ bus-frequency and system-frequency */
73
74 /* Determine which clock source to use */
75 /* 0 - use IP Bus clock                */
76 /* 1 - use SYS_XTAL_IN frequency       */
77 #define MPC5200_CLKSRC          1
78
79 #if MPC5200_CLKSRC
80         #define MPC5200_CLK_FREQ        (MPC5200_SHARK_SYS_XTAL_FREQ/12)        /* 33MHz */
81 #else
82         #define MPC5200_CLK_FREQ        (MPC5200_SHARK_IPB_FREQ/4)              /* 33MHz */
83 #endif
84
85 /* ----------- Debugging options for MPC5200 ----------- */
86
87 #define MPC5200_DBG 0
88
89 #if MPC5200_DBG
90         /* standard LinCAN core debug - used only for MPC5200 driver part */
91         #define DEBUGMSG(fmt,args...) can_printk(KERN_ERR "lincan (debug): " fmt,##args)
92 #endif  /* MPC5200_DBG */
93
94
95 int mpc5200_request_io(struct candevice_t *candev);
96 int mpc5200_release_io(struct candevice_t *candev);
97 int mpc5200_reset(struct candevice_t *candev); 
98 int mpc5200_init_hw_data(struct candevice_t *candev);
99 int mpc5200_init_chip_data(struct candevice_t *candev, int chipnr);
100 int mpc5200_init_obj_data(struct canchip_t *chip, int objnr);
101 int mpc5200_program_irq(struct candevice_t *candev);
102 void mpc5200_write_register(unsigned data, can_ioptr_t address);
103 unsigned mpc5200_read_register(can_ioptr_t address);
104
105 #endif /* LINCAN_MPC5200_H */