Changeset aeff597 in rtems


Ignore:
Timestamp:
Jan 9, 2013, 12:17:18 PM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
fb070e05
Parents:
339646e
git-author:
Sebastian Huber <sebastian.huber@…> (01/09/13 12:17:18)
git-committer:
Sebastian Huber <sebastian.huber@…> (01/09/13 15:45:25)
Message:

bsps/powerpc: Add probe handler to I2C driver

Location:
c/src/lib
Files:
3 edited

Legend:

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

    r339646e raeff597  
    2424#include <bsp.h>
    2525
    26 static mpc83xx_i2c_desc_t mpc83xx_i2c_bus_tbl[2] = {
     26static void i2c1_probe(mpc83xx_i2c_softc_t *self)
     27{
     28#if MPC83XX_CHIP_TYPE != 8309
     29  if (((mpc83xx.clk.sccr >> (31-1)) & 0x03) > 0) {
     30    self->base_frq =
     31      (BSP_bus_frequency
     32       /((mpc83xx.clk.sccr >> (31-1)) & 0x03));
     33  }
     34#else /* MPC83XX_CHIP_TYPE != 8309 */
     35  self->base_frq = BSP_bus_frequency;
     36#endif /* MPC83XX_CHIP_TYPE != 8309 */
     37}
     38
     39#ifndef MPC83XX_BOARD_BR_UID
     40static void i2c2_probe(mpc83xx_i2c_softc_t *self)
     41{
     42  self->base_frq = BSP_bus_frequency;
     43}
     44#endif /* MPC83XX_BOARD_BR_UID */
     45
     46static mpc83xx_i2c_desc_t mpc83xx_i2c_bus_tbl[] = {
    2747  /* first channel */
    2848  {
     
    3555      .initialized = FALSE,
    3656      .irq_number = BSP_IPIC_IRQ_I2C1,
    37       .base_frq = 0 /* will be set during initiailization */
     57      .base_frq = 0, /* will be set during probe */
     58      .probe = i2c1_probe
    3859    }
    39   },
     60  }
     61#ifndef MPC83XX_BOARD_BR_UID
    4062  /* second channel */
    41   {
     63  , {
    4264    { /* public fields */
    4365      .ops = &mpc83xx_i2c_ops,
    44       .size = sizeof(mpc83xx_i2c_bus_tbl[1]),
     66      .size = sizeof(mpc83xx_i2c_bus_tbl[0]),
    4567    },
    4668    { /* our private fields */
     
    4870      .initialized = FALSE,
    4971      .irq_number = BSP_IPIC_IRQ_I2C2,
    50       .base_frq = 0 /* will be set during initiailization */
     72      .base_frq = 0, /* will be set during probe */
     73      .probe = i2c2_probe
    5174    }
    5275  }
    53 };
    54 
    55 rtems_libi2c_bus_t *mpc83xx_i2c_bus_descriptor[2] = {
    56   &mpc83xx_i2c_bus_tbl[0].bus_desc,
    57   &mpc83xx_i2c_bus_tbl[1].bus_desc
     76#endif /* MPC83XX_BOARD_BR_UID */
    5877};
    5978
     
    7796
    7897{
    79   int ret_code;
    80   int i2c1_busno,i2c2_busno;
     98  char device_path[] = "/dev/i2c?";
     99  size_t n = RTEMS_ARRAY_SIZE(mpc83xx_i2c_bus_tbl);
     100  size_t i;
     101  int i2c_busno[n];
    81102
    82103  /*
     
    86107
    87108  /*
    88    * update input frequency of I2c modules into descriptor
     109   * init I2C buses
    89110   */
    90   /*
    91    * I2C1 is clocked with TSEC 1
    92    */
    93   if (((mpc83xx.clk.sccr >> (31-1)) & 0x03) > 0) {
    94     mpc83xx_i2c_bus_tbl[0].softc.base_frq =
    95       (BSP_bus_frequency
    96        /((mpc83xx.clk.sccr >> (31-1)) & 0x03));
     111  for (i = 0; i < n; ++i) {
     112    mpc83xx_i2c_desc_t *desc = &mpc83xx_i2c_bus_tbl[i];
     113
     114    (*desc->softc.probe)(&desc->softc);
     115    device_path[sizeof(device_path) - 2] = (char) ('1' + i);
     116    i2c_busno[i] = rtems_libi2c_register_bus(device_path, &desc->bus_desc);
    97117  }
    98118
    99   mpc83xx_i2c_bus_tbl[1].softc.base_frq = BSP_bus_frequency;
    100   /*
    101    * register first I2C bus
    102    */
    103   ret_code = rtems_libi2c_register_bus("/dev/i2c1",
    104                                        mpc83xx_i2c_bus_descriptor[0]);
    105   if (ret_code < 0) {
    106     return -ret_code;
     119#ifdef RTEMS_BSP_I2C_EEPROM_DEVICE_NAME
     120  if (n > 0) {
     121    /*
     122     * register EEPROM to bus 1, Address 0x50
     123     */
     124    rtems_libi2c_register_drv(RTEMS_BSP_I2C_EEPROM_DEVICE_NAME,
     125                 i2c_2b_eeprom_driver_descriptor,
     126                 i2c_busno[0],0x50);
    107127  }
    108   i2c1_busno = ret_code;
    109   /*
    110    * register second I2C bus
    111    */
    112   ret_code = rtems_libi2c_register_bus("/dev/i2c2",
    113                                        mpc83xx_i2c_bus_descriptor[1]);
    114   if (ret_code < 0) {
    115     return -ret_code;
    116   }
    117   i2c2_busno = ret_code;
    118 
    119 #ifdef RTEMS_BSP_I2C_EEPROM_DEVICE_NAME
    120 
    121   /*
    122    * register EEPROM to bus 1, Address 0x50
    123    */
    124   ret_code = rtems_libi2c_register_drv(RTEMS_BSP_I2C_EEPROM_DEVICE_NAME,
    125                                        i2c_2b_eeprom_driver_descriptor,
    126                                        i2c1_busno,0x50);
    127 
    128   if (ret_code < 0) {
    129     return -ret_code;
    130   }
    131 
    132128#endif /* RTEMS_BSP_I2C_EEPROM_DEVICE_NAME */
    133129
     
    135131   * FIXME: register RTC driver, when available
    136132   */
    137   return 0;
     133
     134  return RTEMS_SUCCESSFUL;
    138135}
  • c/src/lib/libbsp/powerpc/mpc55xxevb/i2c/i2c_init.c

    r339646e raeff597  
    2525
    2626#if MPC55XX_CHIP_FAMILY == 551
     27  static void i2c_probe(mpc83xx_i2c_softc_t *self)
     28  {
     29    self->base_frq = bsp_clock_speed;
     30  }
     31
    2732  static mpc83xx_i2c_desc_t mpc55xx_i2c_bus = {
    2833    .bus_desc = {
     
    3439      .initialized = FALSE,
    3540      .irq_number = MPC55XX_IRQ_I2C(0),
    36       .base_frq = 0
     41      .base_frq = 0,
     42      .probe = i2c_probe
    3743    }
    3844  };
     
    4551    rtems_libi2c_initialize ();
    4652
    47     mpc55xx_i2c_bus.softc.base_frq = bsp_clock_speed;
    4853    busno = rtems_libi2c_register_bus(
    4954      "/dev/i2c1",
  • c/src/lib/libcpu/powerpc/mpc83xx/i2c/mpc83xx_i2cdrv.h

    r339646e raeff597  
    5050  uint32_t             base_frq;    /* input frq for baud rate divider */
    5151  rtems_id             irq_sema_id; /* SEMA used for IRQ signalling    */
     52  void               (*probe)(struct mpc83xx_i2c_softc *self);
    5253} mpc83xx_i2c_softc_t ;
    5354
Note: See TracChangeset for help on using the changeset viewer.