source: rtems/c/src/lib/libbsp/powerpc/mpc55xxevb/i2c/i2c_init.c @ 1f4db180

4.104.115
Last change on this file since 1f4db180 was 2f5435a4, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 03/25/10 at 20:26:00

add support for mpc551x based GW_LCFM system

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*===============================================================*\
2| Project: RTEMS support for GWLCFM                               |
3+-----------------------------------------------------------------+
4|                    Copyright (c) 2010                           |
5|                    Embedded Brains GmbH                         |
6|                    Obere Lagerstr. 30                           |
7|                    D-82178 Puchheim                             |
8|                    Germany                                      |
9|                    rtems@embedded-brains.de                     |
10+-----------------------------------------------------------------+
11| The license and distribution terms for this file may be         |
12| found in the file LICENSE in this distribution or at            |
13|                                                                 |
14| http://www.rtems.com/license/LICENSE.                           |
15|                                                                 |
16+-----------------------------------------------------------------+
17| this file contains the low level MPC5516 I2C driver parameters  |
18\*===============================================================*/
19#if 0 /* FIXME: make this work... */
20#include <mpc55xx/mpc55xx_i2cdrv.h>
21#include <libchip/i2c-2b-eeprom.h>
22#include <bsp/irq.h>
23#include <bsp.h>
24
25static mpc55xx_i2c_desc_t mpc55xx_i2c_bus_tbl[] = {
26  /* first channel */
27  {
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 */
37    }
38  }
39};
40
41rtems_libi2c_bus_t *mpc55xx_i2c_bus_descriptor[] = {
42  &mpc55xx_i2c_bus_tbl[0].bus_desc
43};
44
45/*=========================================================================*\
46| Function:                                                                 |
47\*-------------------------------------------------------------------------*/
48rtems_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));
83  }
84#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 TracBrowser for help on using the repository browser.