]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/include/mpc5200.h
Added distinguish mechanism between full MPC5200 (used on RYU board) and original...
[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
40 /* MPC5200 has two CAN controlers
41  * however MIDAM board uses only one controler
42  * RYU board uses both
43  */
44 #ifdef MSCAN_MIDAM
45         #define NR_MSCAN        1
46 #else
47         #define NR_MSCAN        2
48 #endif /* MSCAN_MIDAM */
49
50
51 #define NR_82527        0
52 #define NR_SJA1000      0
53 #define NR_ALL          (NR_82527 + NR_SJA1000 + NR_MSCAN)
54
55
56 /* IRQ is read from OpenFirmware nodes */
57
58 #define MPC5200_CAN_CHIP_OFFSET         0x80
59 #define IO_RANGE                        0x80
60
61
62 /* Clock frequency - used for baudrate */
63 #define MPC5200_SHARK_SYS_XTAL_FREQ     396000000       /* 396 MHz */
64 #define MPC5200_SHARK_IPB_FREQ          132000000       /* derived from XTAL by dividing: 132 MHz */
65 /* got from /proc/device-tree/cpus/PowerPC,5200@0/ bus-frequency and system-frequency */
66
67 /* Determine which clock source to use */
68 /* 0 - use IP Bus clock                */
69 /* 1 - use SYS_XTAL_IN frequency       */
70 #define MPC5200_CLKSRC          1
71
72 #if MPC5200_CLKSRC
73         #define MPC5200_CLK_FREQ        (MPC5200_SHARK_SYS_XTAL_FREQ/12)        /* 33MHz */
74 #else
75         #define MPC5200_CLK_FREQ        (MPC5200_SHARK_IPB_FREQ/4)              /* 33MHz */
76 #endif
77
78 /* ----------- Debugging options for MPC5200 ----------- */
79
80 #define MPC5200_DBG 0
81
82 #if MPC5200_DBG
83         /* standard LinCAN core debug - used only for MPC5200 driver part */
84         #define DEBUGMSG(fmt,args...) can_printk(KERN_ERR "lincan (debug): " fmt,##args)
85 #endif  /* MPC5200_DBG */
86
87
88 int mpc5200_request_io(struct candevice_t *candev);
89 int mpc5200_release_io(struct candevice_t *candev);
90 int mpc5200_reset(struct candevice_t *candev); 
91 int mpc5200_init_hw_data(struct candevice_t *candev);
92 int mpc5200_init_chip_data(struct candevice_t *candev, int chipnr);
93 int mpc5200_init_obj_data(struct canchip_t *chip, int objnr);
94 int mpc5200_program_irq(struct candevice_t *candev);
95 void mpc5200_write_register(unsigned data, can_ioptr_t address);
96 unsigned mpc5200_read_register(can_ioptr_t address);
97
98 #endif /* LINCAN_MPC5200_H */