source: rtems/c/src/lib/libbsp/powerpc/gen83xx/i2c/i2c_init.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 4.5 KB
Line 
1/*===============================================================*\
2| Project: RTEMS support for MPC83xx                              |
3+-----------------------------------------------------------------+
4|                    Copyright (c) 2007                           |
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 MPC83xx I2C driver parameters  |
18\*===============================================================*/
19
20
21#include <mpc83xx/mpc83xx_i2cdrv.h>
22#include <libchip/i2c-2b-eeprom.h>
23#include <bsp/irq.h>
24#include <bsp.h>
25
26static mpc83xx_i2c_desc_t mpc83xx_i2c_bus_tbl[2] = {
27  /* first channel */
28  {
29    {/* public fields */
30      .ops = &mpc83xx_i2c_ops,
31      .size = sizeof(mpc83xx_i2c_bus_tbl[0]),
32    },
33    { /* our private fields */
34      .reg_ptr = &mpc83xx.i2c[0],
35      .initialized = FALSE,
36      .irq_number = BSP_IPIC_IRQ_I2C1,
37      .base_frq = 0 /* will be set during initiailization */
38    }
39  },
40  /* second channel */
41  {
42    { /* public fields */
43      .ops = &mpc83xx_i2c_ops,
44      .size = sizeof(mpc83xx_i2c_bus_tbl[1]),
45    },
46    { /* our private fields */
47      .reg_ptr = &mpc83xx.i2c[1],
48      .initialized = FALSE,
49      .irq_number = BSP_IPIC_IRQ_I2C2,
50      .base_frq = 0 /* will be set during initiailization */
51    }
52  }
53};
54
55rtems_libi2c_bus_t *mpc83xx_i2c_bus_descriptor[2] = {
56  &mpc83xx_i2c_bus_tbl[0].bus_desc,
57  &mpc83xx_i2c_bus_tbl[1].bus_desc
58};
59
60/*=========================================================================*\
61| Function:                                                                 |
62\*-------------------------------------------------------------------------*/
63rtems_status_code bsp_register_i2c
64(
65/*-------------------------------------------------------------------------*\
66| Purpose:                                                                  |
67|   register I2C busses and devices                                         |
68+---------------------------------------------------------------------------+
69| Input Parameters:                                                         |
70\*-------------------------------------------------------------------------*/
71 void                                    /* <none>                         */
72)
73/*-------------------------------------------------------------------------*\
74| Return Value:                                                             |
75|    0 or error code                                                        |
76\*=========================================================================*/
77
78{
79  int ret_code;
80  int i2c1_busno,i2c2_busno;
81
82  /*
83   * init I2C library (if not already done)
84   */
85  rtems_libi2c_initialize ();
86
87  /*
88   * update input frequency of I2c modules into descriptor
89   */
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));
97  }
98
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;
107  }
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
132#endif /* RTEMS_BSP_I2C_EEPROM_DEVICE_NAME */
133
134  /*
135   * FIXME: register RTC driver, when available
136   */
137  return 0;
138}
Note: See TracBrowser for help on using the repository browser.