diff options
author | Thomas Doerfler <Thomas.Doerfler@embedded-brains.de> | 2007-08-10 08:15:58 +0000 |
---|---|---|
committer | Thomas Doerfler <Thomas.Doerfler@embedded-brains.de> | 2007-08-10 08:15:58 +0000 |
commit | e35c6965bfe665ceea960ac3bec54eb64fa5d174 (patch) | |
tree | 32c00f3881033a49b69750a715535980b5a3d898 /c/src/lib/libbsp/powerpc/gen83xx/i2c/i2c_init.c | |
parent | applied patch from Robert Grimes to correctly set the link speed to 100MBit (diff) | |
download | rtems-e35c6965bfe665ceea960ac3bec54eb64fa5d174.tar.bz2 |
added BSP hsc_cm01
Diffstat (limited to 'c/src/lib/libbsp/powerpc/gen83xx/i2c/i2c_init.c')
-rw-r--r-- | c/src/lib/libbsp/powerpc/gen83xx/i2c/i2c_init.c | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/powerpc/gen83xx/i2c/i2c_init.c b/c/src/lib/libbsp/powerpc/gen83xx/i2c/i2c_init.c new file mode 100644 index 0000000000..c64d8e45f0 --- /dev/null +++ b/c/src/lib/libbsp/powerpc/gen83xx/i2c/i2c_init.c @@ -0,0 +1,111 @@ +/*===============================================================*\ +| Project: RTEMS support for MPC83xx | ++-----------------------------------------------------------------+ +| Copyright (c) 2007 | +| Embedded Brains GmbH | +| Obere Lagerstr. 30 | +| D-82178 Puchheim | +| Germany | +| rtems@embedded-brains.de | ++-----------------------------------------------------------------+ +| The license and distribution terms for this file may be | +| found in the file LICENSE in this distribution or at | +| | +| http://www.rtems.com/license/LICENSE. | +| | ++-----------------------------------------------------------------+ +| this file contains the low level MPC83xx I2C driver parameters | +\*===============================================================*/ +#include <mpc83xx/mpc83xx_i2cdrv.h> +#include <libchip/i2c-2b-eeprom.h> +#include <bsp/irq.h> +#include <bsp.h> + +static mpc83xx_i2c_desc_t mpc83xx_i2c_bus_tbl[2] = { + /* first channel */ + { + {/* public fields */ + ops: &mpc83xx_i2c_ops, + size: sizeof(mpc83xx_i2c_bus_tbl[0]), + }, + { /* our private fields */ + reg_ptr: &mpc83xx.i2c[0], + initialized: FALSE, + irq_number: BSP_IPIC_IRQ_I2C1 + } + }, + /* second channel */ + { + { /* public fields */ + ops: &mpc83xx_i2c_ops, + size: sizeof(mpc83xx_i2c_bus_tbl[1]), + }, + { /* our private fields */ + reg_ptr: &mpc83xx.i2c[1], + initialized: FALSE, + irq_number: BSP_IPIC_IRQ_I2C2 + } + } +}; + +rtems_libi2c_bus_t *mpc83xx_i2c_bus_descriptor[2] = { + &mpc83xx_i2c_bus_tbl[0].bus_desc, + &mpc83xx_i2c_bus_tbl[1].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; + + /* + * init I2C library + */ + rtems_libi2c_initialize (); + + /* + * register first I2C bus + */ + ret_code = rtems_libi2c_register_bus("/dev/i2c1", + mpc83xx_i2c_bus_descriptor[0]); + if (ret_code < 0) { + return -ret_code; + } + /* + * register second I2C bus + */ + ret_code = rtems_libi2c_register_bus("/dev/i2c2", + mpc83xx_i2c_bus_descriptor[1]); + if (ret_code < 0) { + return -ret_code; + } + /* + * register EEPROM to bus 1, Address 0x50 + */ + ret_code = rtems_libi2c_register_drv(RTEMS_BSP_I2C_EEPROM_DEVICE_NAME, + i2c_2b_eeprom_driver_descriptor, + 0,0x50); + if (ret_code < 0) { + return -ret_code; + } + /* + * FIXME: register RTC driver, when available + */ + return 0; +} |