Ignore:
Timestamp:
Dec 22, 2010, 2:21:03 PM (9 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
6d9059f
Parents:
b591952
Message:

2010-12-22 Sebastian Huber <sebastian.huber@…>

  • 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/mpc55xxevb/i2c/i2c_init.c

    rb591952 rdbb3211a  
    1717| this file contains the low level MPC5516 I2C driver parameters  |
    1818\*===============================================================*/
    19 #if 0 /* FIXME: make this work... */
    20 #include <mpc55xx/mpc55xx_i2cdrv.h>
     19
    2120#include <libchip/i2c-2b-eeprom.h>
     21
     22#include <bsp.h>
    2223#include <bsp/irq.h>
    23 #include <bsp.h>
     24#include <bsp/mpc83xx_i2cdrv.h>
    2425
    25 static mpc55xx_i2c_desc_t mpc55xx_i2c_bus_tbl[] = {
    26   /* first channel */
     26#ifdef MPC55XX_IRQ_I2C
     27  static mpc83xx_i2c_desc_t mpc55xx_i2c_bus = {
     28    .bus_desc = {
     29      .ops = &mpc83xx_i2c_ops,
     30      .size = sizeof(mpc55xx_i2c_bus),
     31    },
     32    .softc = {
     33      .reg_ptr = (m83xxI2CRegisters_t *) 0xfff88000,
     34      .initialized = FALSE,
     35      .irq_number = MPC55XX_IRQ_I2C,
     36      .base_frq = 0
     37    }
     38  };
     39
     40  rtems_status_code bsp_register_i2c(void)
    2741  {
    28     {/* public fields */
    29       .ops = &mpc55xx_i2c_ops,
    30       .size = sizeof(mpc55xx_i2c_bus_tbl[0]),
    31     },
    32     { /* our private fields */
    33       .reg_ptr = &mpc55xx.i2c[0],
    34       .initialized = FALSE,
    35       .irq_number = BSP_IPIC_IRQ_I2C1,
    36       .base_frq = 0 /* will be set during initiailization */
     42    int rv = 0;
     43    int busno = 0;
     44 
     45    rtems_libi2c_initialize ();
     46 
     47    mpc55xx_i2c_bus.softc.base_frq = bsp_clock_speed;
     48    busno = rtems_libi2c_register_bus(
     49      "/dev/i2c1",
     50      &mpc55xx_i2c_bus.bus_desc
     51    );
     52    if (busno < 0) {
     53      return RTEMS_IO_ERROR;
    3754    }
    38   }
    39 };
    4055
    41 rtems_libi2c_bus_t *mpc55xx_i2c_bus_descriptor[] = {
    42   &mpc55xx_i2c_bus_tbl[0].bus_desc
    43 };
    44 
    45 /*=========================================================================*\
    46 | Function:                                                                 |
    47 \*-------------------------------------------------------------------------*/
    48 rtems_status_code bsp_register_i2c
    49 (
    50 /*-------------------------------------------------------------------------*\
    51 | Purpose:                                                                  |
    52 |   register I2C busses and devices                                         |
    53 +---------------------------------------------------------------------------+
    54 | Input Parameters:                                                         |
    55 \*-------------------------------------------------------------------------*/
    56  void                                    /* <none>                         */
    57 )
    58 /*-------------------------------------------------------------------------*\
    59 | Return Value:                                                             |
    60 |    0 or error code                                                        |
    61 \*=========================================================================*/
    62 
    63 {
    64   int ret_code;
    65   int i2c1_busno,i2c2_busno;
    66 
    67   /*
    68    * init I2C library (if not already done)
    69    */
    70   rtems_libi2c_initialize ();
    71 
    72   /*
    73    * FIXME: update input frequency of I2c modules into descriptor
    74    */
    75 #if 0
    76   /*
    77    * I2C1 is clocked with TSEC 1
    78    */
    79   if (((mpc55xx.clk.sccr >> (31-1)) & 0x03) > 0) {
    80     mpc55xx_i2c_bus_tbl[0].softc.base_frq =
    81       (BSP_bus_frequency
    82        /((mpc55xx.clk.sccr >> (31-1)) & 0x03));
     56    #ifdef RTEMS_BSP_I2C_EEPROM_DEVICE_NAME
     57      rv = rtems_libi2c_register_drv(
     58        RTEMS_BSP_I2C_EEPROM_DEVICE_NAME,
     59        i2c_2b_eeprom_driver_descriptor,
     60        busno,
     61        0x51
     62      );
     63      if (rv < 0) {
     64        return RTEMS_IO_ERROR;
     65      }
     66    #endif
     67 
     68    return RTEMS_SUCCESSFUL;
    8369  }
    8470#endif
    85   mpc55xx_i2c_bus_tbl[1].softc.base_frq = BSP_bus_frequency;
    86   /*
    87    * register first I2C bus
    88    */
    89   ret_code = rtems_libi2c_register_bus("/dev/i2c1",
    90                                        mpc55xx_i2c_bus_descriptor[0]);
    91   if (ret_code < 0) {
    92     return -ret_code;
    93   }
    94   i2c1_busno = ret_code;
    95 
    96 #ifdef RTEMS_BSP_I2C_EEPROM_DEVICE_NAME
    97 
    98   /*
    99    * register EEPROM to bus 1, Address 0x50
    100    */
    101   ret_code = rtems_libi2c_register_drv(RTEMS_BSP_I2C_EEPROM_DEVICE_NAME,
    102                                        i2c_2b_eeprom_driver_descriptor,
    103                                        i2c1_busno,0x50);
    104 
    105   if (ret_code < 0) {
    106     return -ret_code;
    107   }
    108 
    109 #endif /* RTEMS_BSP_I2C_EEPROM_DEVICE_NAME */
    110   return 0;
    111 }
    112 #endif /* 0 */
Note: See TracChangeset for help on using the changeset viewer.