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

4.115
Last change on this file since 9b5fe743 was e570c313, checked in by Joel Sherrill <joel.sherrill@…>, on 01/24/11 at 15:32:04

2011-01-24 Joel Sherrill <joel.sherrill@…>

  • configure.ac, console/console-config.c, i2c/i2c_init.c, include/bsp.h, include/hwreg_vals.h, include/irq.h, include/tm27.h, include/tsec-config.h, irq/irq.c, network/network.c, spi/spi_init.c, startup/bspstart.c: Address some of the issues spotted by the check_bsp script.
  • 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 *  $Id$
22 */
23
24#include <mpc83xx/mpc83xx_i2cdrv.h>
25#include <libchip/i2c-2b-eeprom.h>
26#include <bsp/irq.h>
27#include <bsp.h>
28
29static mpc83xx_i2c_desc_t mpc83xx_i2c_bus_tbl[2] = {
30  /* first channel */
31  {
32    {/* public fields */
33      .ops = &mpc83xx_i2c_ops,
34      .size = sizeof(mpc83xx_i2c_bus_tbl[0]),
35    },
36    { /* our private fields */
37      .reg_ptr = &mpc83xx.i2c[0],
38      .initialized = FALSE,
39      .irq_number = BSP_IPIC_IRQ_I2C1,
40      .base_frq = 0 /* will be set during initiailization */
41    }
42  },
43  /* second channel */
44  {
45    { /* public fields */
46      .ops = &mpc83xx_i2c_ops,
47      .size = sizeof(mpc83xx_i2c_bus_tbl[1]),
48    },
49    { /* our private fields */
50      .reg_ptr = &mpc83xx.i2c[1],
51      .initialized = FALSE,
52      .irq_number = BSP_IPIC_IRQ_I2C2,
53      .base_frq = 0 /* will be set during initiailization */
54    }
55  }
56};
57
58rtems_libi2c_bus_t *mpc83xx_i2c_bus_descriptor[2] = {
59  &mpc83xx_i2c_bus_tbl[0].bus_desc,
60  &mpc83xx_i2c_bus_tbl[1].bus_desc
61};
62
63/*=========================================================================*\
64| Function:                                                                 |
65\*-------------------------------------------------------------------------*/
66rtems_status_code bsp_register_i2c
67(
68/*-------------------------------------------------------------------------*\
69| Purpose:                                                                  |
70|   register I2C busses and devices                                         |
71+---------------------------------------------------------------------------+
72| Input Parameters:                                                         |
73\*-------------------------------------------------------------------------*/
74 void                                    /* <none>                         */
75)
76/*-------------------------------------------------------------------------*\
77| Return Value:                                                             |
78|    0 or error code                                                        |
79\*=========================================================================*/
80
81{
82  int ret_code;
83  int i2c1_busno,i2c2_busno;
84
85  /*
86   * init I2C library (if not already done)
87   */
88  rtems_libi2c_initialize ();
89
90  /*
91   * update input frequency of I2c modules into descriptor
92   */
93  /*
94   * I2C1 is clocked with TSEC 1
95   */
96  if (((mpc83xx.clk.sccr >> (31-1)) & 0x03) > 0) {
97    mpc83xx_i2c_bus_tbl[0].softc.base_frq =
98      (BSP_bus_frequency
99       /((mpc83xx.clk.sccr >> (31-1)) & 0x03));
100  }
101
102  mpc83xx_i2c_bus_tbl[1].softc.base_frq = BSP_bus_frequency;
103  /*
104   * register first I2C bus
105   */
106  ret_code = rtems_libi2c_register_bus("/dev/i2c1",
107                                       mpc83xx_i2c_bus_descriptor[0]);
108  if (ret_code < 0) {
109    return -ret_code;
110  }
111  i2c1_busno = ret_code;
112  /*
113   * register second I2C bus
114   */
115  ret_code = rtems_libi2c_register_bus("/dev/i2c2",
116                                       mpc83xx_i2c_bus_descriptor[1]);
117  if (ret_code < 0) {
118    return -ret_code;
119  }
120  i2c2_busno = ret_code;
121
122#ifdef RTEMS_BSP_I2C_EEPROM_DEVICE_NAME
123
124  /*
125   * register EEPROM to bus 1, Address 0x50
126   */
127  ret_code = rtems_libi2c_register_drv(RTEMS_BSP_I2C_EEPROM_DEVICE_NAME,
128                                       i2c_2b_eeprom_driver_descriptor,
129                                       i2c1_busno,0x50);
130
131  if (ret_code < 0) {
132    return -ret_code;
133  }
134
135#endif /* RTEMS_BSP_I2C_EEPROM_DEVICE_NAME */
136
137  /*
138   * FIXME: register RTC driver, when available
139   */
140  return 0;
141}
Note: See TracBrowser for help on using the repository browser.