summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/powerpc/mpc55xxevb/i2c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2010-12-22 14:21:03 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2010-12-22 14:21:03 +0000
commitdbb3211a29ee258a58e853f5c0fe9274907d8642 (patch)
treef78fb6a34d9a5920fa4e8b36144e1d52b8b40f14 /c/src/lib/libbsp/powerpc/mpc55xxevb/i2c
parent2010-12-22 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff)
downloadrtems-dbb3211a29ee258a58e853f5c0fe9274907d8642.tar.bz2
2010-12-22 Sebastian Huber <sebastian.huber@embedded-brains.de>
* configure.ac: Added I2C options. Fixed eMIOS prescaler. Use standard linker command file support. * include/bsp.h: Declare I2C initialization function. * i2c/i2c_init.c: Implementation. * make/custom/gwlcfm.cfg, make/custom/mpc5566evb.cfg, make/custom/mpc55xx.inc: Use standard linker command file support. * startup/bspstart.c: More board specific settings. * Makefile.am, preinstall.am: Reflect changes above.
Diffstat (limited to 'c/src/lib/libbsp/powerpc/mpc55xxevb/i2c')
-rw-r--r--c/src/lib/libbsp/powerpc/mpc55xxevb/i2c/i2c_init.c126
1 files changed, 42 insertions, 84 deletions
diff --git a/c/src/lib/libbsp/powerpc/mpc55xxevb/i2c/i2c_init.c b/c/src/lib/libbsp/powerpc/mpc55xxevb/i2c/i2c_init.c
index db07b67948..8bbda36058 100644
--- a/c/src/lib/libbsp/powerpc/mpc55xxevb/i2c/i2c_init.c
+++ b/c/src/lib/libbsp/powerpc/mpc55xxevb/i2c/i2c_init.c
@@ -16,97 +16,55 @@
+-----------------------------------------------------------------+
| this file contains the low level MPC5516 I2C driver parameters |
\*===============================================================*/
-#if 0 /* FIXME: make this work... */
-#include <mpc55xx/mpc55xx_i2cdrv.h>
+
#include <libchip/i2c-2b-eeprom.h>
-#include <bsp/irq.h>
+
#include <bsp.h>
+#include <bsp/irq.h>
+#include <bsp/mpc83xx_i2cdrv.h>
-static mpc55xx_i2c_desc_t mpc55xx_i2c_bus_tbl[] = {
- /* first channel */
- {
- {/* public fields */
- .ops = &mpc55xx_i2c_ops,
- .size = sizeof(mpc55xx_i2c_bus_tbl[0]),
+#ifdef MPC55XX_IRQ_I2C
+ static mpc83xx_i2c_desc_t mpc55xx_i2c_bus = {
+ .bus_desc = {
+ .ops = &mpc83xx_i2c_ops,
+ .size = sizeof(mpc55xx_i2c_bus),
},
- { /* our private fields */
- .reg_ptr = &mpc55xx.i2c[0],
+ .softc = {
+ .reg_ptr = (m83xxI2CRegisters_t *) 0xfff88000,
.initialized = FALSE,
- .irq_number = BSP_IPIC_IRQ_I2C1,
- .base_frq = 0 /* will be set during initiailization */
+ .irq_number = MPC55XX_IRQ_I2C,
+ .base_frq = 0
}
- }
-};
-
-rtems_libi2c_bus_t *mpc55xx_i2c_bus_descriptor[] = {
- &mpc55xx_i2c_bus_tbl[0].bus_desc
-};
-
-/*=========================================================================*\
-| Function: |
-\*-------------------------------------------------------------------------*/
-rtems_status_code bsp_register_i2c
-(
-/*-------------------------------------------------------------------------*\
-| Purpose: |
-| register I2C busses and devices |
-+---------------------------------------------------------------------------+
-| Input Parameters: |
-\*-------------------------------------------------------------------------*/
- void /* <none> */
-)
-/*-------------------------------------------------------------------------*\
-| Return Value: |
-| 0 or error code |
-\*=========================================================================*/
-
-{
- int ret_code;
- int i2c1_busno,i2c2_busno;
+ };
- /*
- * init I2C library (if not already done)
- */
- rtems_libi2c_initialize ();
+ rtems_status_code bsp_register_i2c(void)
+ {
+ int rv = 0;
+ int busno = 0;
+
+ rtems_libi2c_initialize ();
+
+ mpc55xx_i2c_bus.softc.base_frq = bsp_clock_speed;
+ busno = rtems_libi2c_register_bus(
+ "/dev/i2c1",
+ &mpc55xx_i2c_bus.bus_desc
+ );
+ if (busno < 0) {
+ return RTEMS_IO_ERROR;
+ }
- /*
- * FIXME: update input frequency of I2c modules into descriptor
- */
-#if 0
- /*
- * I2C1 is clocked with TSEC 1
- */
- if (((mpc55xx.clk.sccr >> (31-1)) & 0x03) > 0) {
- mpc55xx_i2c_bus_tbl[0].softc.base_frq =
- (BSP_bus_frequency
- /((mpc55xx.clk.sccr >> (31-1)) & 0x03));
+ #ifdef RTEMS_BSP_I2C_EEPROM_DEVICE_NAME
+ rv = rtems_libi2c_register_drv(
+ RTEMS_BSP_I2C_EEPROM_DEVICE_NAME,
+ i2c_2b_eeprom_driver_descriptor,
+ busno,
+ 0x51
+ );
+ if (rv < 0) {
+ return RTEMS_IO_ERROR;
+ }
+ #endif
+
+ return RTEMS_SUCCESSFUL;
}
#endif
- mpc55xx_i2c_bus_tbl[1].softc.base_frq = BSP_bus_frequency;
- /*
- * register first I2C bus
- */
- ret_code = rtems_libi2c_register_bus("/dev/i2c1",
- mpc55xx_i2c_bus_descriptor[0]);
- if (ret_code < 0) {
- return -ret_code;
- }
- i2c1_busno = ret_code;
-
-#ifdef RTEMS_BSP_I2C_EEPROM_DEVICE_NAME
-
- /*
- * register EEPROM to bus 1, Address 0x50
- */
- ret_code = rtems_libi2c_register_drv(RTEMS_BSP_I2C_EEPROM_DEVICE_NAME,
- i2c_2b_eeprom_driver_descriptor,
- i2c1_busno,0x50);
-
- if (ret_code < 0) {
- return -ret_code;
- }
-
-#endif /* RTEMS_BSP_I2C_EEPROM_DEVICE_NAME */
- return 0;
-}
-#endif /* 0 */