]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/include/mpc5200.h
Merge branch 'master' into can-usb1
[lincan.git] / lincan / include / mpc5200.h
diff --git a/lincan/include/mpc5200.h b/lincan/include/mpc5200.h
new file mode 100644 (file)
index 0000000..e709699
--- /dev/null
@@ -0,0 +1,93 @@
+/**************************************************************************/
+/* File: mpc5200.h - Freescale MPC5200 MSCAN controller support           */
+/*                                                                        */
+/* LinCAN - (Not only) Linux CAN bus driver                               */
+/* Copyright (C) 2002-2009 DCE FEE CTU Prague <http://dce.felk.cvut.cz>   */
+/* Copyright (C) 2002-2009 Pavel Pisa <pisa@cmp.felk.cvut.cz>             */
+/* Copyright (C) 2007-2008 Martin Petera <peterm4@fel.cvut.cz>            */
+/* Funded by OCERA and FRESCOR IST projects                               */
+/* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl>      */
+/*                                                                        */
+/* LinCAN is free software; you can redistribute it and/or modify it      */
+/* under terms of the GNU General Public License as published by the      */
+/* Free Software Foundation; either version 2, or (at your option) any    */
+/* later version.  LinCAN is distributed in the hope that it will be      */
+/* useful, but WITHOUT ANY WARRANTY; without even the implied warranty    */
+/* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU    */
+/* General Public License for more details. You should have received a    */
+/* copy of the GNU General Public License along with LinCAN; see file     */
+/* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,  */
+/* Cambridge, MA 02139, USA.                                              */
+/*                                                                        */
+/* To allow use of LinCAN in the compact embedded systems firmware        */
+/* and RT-executives (RTEMS for example), main authors agree with next    */
+/* special exception:                                                     */
+/*                                                                        */
+/* Including LinCAN header files in a file, instantiating LinCAN generics */
+/* or templates, or linking other files with LinCAN objects to produce    */
+/* an application image/executable, does not by itself cause the          */
+/* resulting application image/executable to be covered by                */
+/* the GNU General Public License.                                        */
+/* This exception does not however invalidate any other reasons           */
+/* why the executable file might be covered by the GNU Public License.    */
+/* Publication of enhanced or derived LinCAN files is required although.  */
+/**************************************************************************/
+
+#ifndef LINCAN_MPC5200_H
+#define LINCAN_MPC5200_H
+
+
+/* MPC5200 has two CAN controlers
+ * however MIDAM board uses only one controler
+ * RYU board uses both
+ */
+#define NR_82527       0
+#define NR_SJA1000     0
+#define NR_ALL         (NR_82527 + NR_SJA1000 + 2)
+#define NR_ALL_MIDAM   (NR_ALL - 1)
+
+
+
+/* IRQ is read from OpenFirmware nodes */
+
+#define MPC5200_CAN_CHIP_OFFSET                0x80
+#define IO_RANGE                       0x80
+
+
+/* Clock frequency - used for baudrate */
+#define MPC5200_SHARK_SYS_XTAL_FREQ    396000000       /* 396 MHz */
+#define MPC5200_SHARK_IPB_FREQ         132000000       /* derived from XTAL by dividing: 132 MHz */
+/* got from /proc/device-tree/cpus/PowerPC,5200@0/ bus-frequency and system-frequency */
+
+/* Determine which clock source to use */
+/* 0 - use IP Bus clock                */
+/* 1 - use SYS_XTAL_IN frequency       */
+#define MPC5200_CLKSRC         1
+
+#if MPC5200_CLKSRC
+       #define MPC5200_CLK_FREQ        (MPC5200_SHARK_SYS_XTAL_FREQ/12)        /* 33MHz */
+#else
+       #define MPC5200_CLK_FREQ        (MPC5200_SHARK_IPB_FREQ/4)              /* 33MHz */
+#endif
+
+/* ----------- Debugging options for MPC5200 ----------- */
+
+#define MPC5200_DBG 0
+
+#if MPC5200_DBG
+       /* standard LinCAN core debug - used only for MPC5200 driver part */
+       #define DEBUGMSG(fmt,args...) can_printk(KERN_ERR "lincan (debug): " fmt,##args)
+#endif /* MPC5200_DBG */
+
+
+int mpc5200_request_io(struct candevice_t *candev);
+int mpc5200_release_io(struct candevice_t *candev);
+int mpc5200_reset(struct candevice_t *candev); 
+int mpc5200_init_hw_data(struct candevice_t *candev);
+int mpc5200_init_chip_data(struct candevice_t *candev, int chipnr);
+int mpc5200_init_obj_data(struct canchip_t *chip, int objnr);
+int mpc5200_program_irq(struct candevice_t *candev);
+void mpc5200_write_register(unsigned data, can_ioptr_t address);
+unsigned mpc5200_read_register(can_ioptr_t address);
+
+#endif /* LINCAN_MPC5200_H */