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 | #include <mpc83xx/mpc83xx_i2cdrv.h> |
---|
20 | #include <libchip/i2c-2b-eeprom.h> |
---|
21 | #include <bsp/irq.h> |
---|
22 | #include <bsp.h> |
---|
23 | |
---|
24 | static mpc83xx_i2c_desc_t mpc83xx_i2c_bus_tbl[2] = { |
---|
25 | /* first channel */ |
---|
26 | { |
---|
27 | {/* public fields */ |
---|
28 | ops: &mpc83xx_i2c_ops, |
---|
29 | size: sizeof(mpc83xx_i2c_bus_tbl[0]), |
---|
30 | }, |
---|
31 | { /* our private fields */ |
---|
32 | reg_ptr: &mpc83xx.i2c[0], |
---|
33 | initialized: FALSE, |
---|
34 | irq_number: BSP_IPIC_IRQ_I2C1 |
---|
35 | } |
---|
36 | }, |
---|
37 | /* second channel */ |
---|
38 | { |
---|
39 | { /* public fields */ |
---|
40 | ops: &mpc83xx_i2c_ops, |
---|
41 | size: sizeof(mpc83xx_i2c_bus_tbl[1]), |
---|
42 | }, |
---|
43 | { /* our private fields */ |
---|
44 | reg_ptr: &mpc83xx.i2c[1], |
---|
45 | initialized: FALSE, |
---|
46 | irq_number: BSP_IPIC_IRQ_I2C2 |
---|
47 | } |
---|
48 | } |
---|
49 | }; |
---|
50 | |
---|
51 | rtems_libi2c_bus_t *mpc83xx_i2c_bus_descriptor[2] = { |
---|
52 | &mpc83xx_i2c_bus_tbl[0].bus_desc, |
---|
53 | &mpc83xx_i2c_bus_tbl[1].bus_desc |
---|
54 | }; |
---|
55 | |
---|
56 | /*=========================================================================*\ |
---|
57 | | Function: | |
---|
58 | \*-------------------------------------------------------------------------*/ |
---|
59 | rtems_status_code bsp_register_i2c |
---|
60 | ( |
---|
61 | /*-------------------------------------------------------------------------*\ |
---|
62 | | Purpose: | |
---|
63 | | register I2C busses and devices | |
---|
64 | +---------------------------------------------------------------------------+ |
---|
65 | | Input Parameters: | |
---|
66 | \*-------------------------------------------------------------------------*/ |
---|
67 | void /* <none> */ |
---|
68 | ) |
---|
69 | /*-------------------------------------------------------------------------*\ |
---|
70 | | Return Value: | |
---|
71 | | 0 or error code | |
---|
72 | \*=========================================================================*/ |
---|
73 | |
---|
74 | { |
---|
75 | int ret_code; |
---|
76 | |
---|
77 | /* |
---|
78 | * init I2C library |
---|
79 | */ |
---|
80 | rtems_libi2c_initialize (); |
---|
81 | |
---|
82 | /* |
---|
83 | * register first I2C bus |
---|
84 | */ |
---|
85 | ret_code = rtems_libi2c_register_bus("/dev/i2c1", |
---|
86 | mpc83xx_i2c_bus_descriptor[0]); |
---|
87 | if (ret_code < 0) { |
---|
88 | return -ret_code; |
---|
89 | } |
---|
90 | /* |
---|
91 | * register second I2C bus |
---|
92 | */ |
---|
93 | ret_code = rtems_libi2c_register_bus("/dev/i2c2", |
---|
94 | mpc83xx_i2c_bus_descriptor[1]); |
---|
95 | if (ret_code < 0) { |
---|
96 | return -ret_code; |
---|
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 | 0,0x50); |
---|
104 | if (ret_code < 0) { |
---|
105 | return -ret_code; |
---|
106 | } |
---|
107 | /* |
---|
108 | * FIXME: register RTC driver, when available |
---|
109 | */ |
---|
110 | return 0; |
---|
111 | } |
---|