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