blob: d79f2eb2e82ba5eac3e598e9ed1f7331f1296402 [file] [log] [blame]
Tony Lic8b57f12007-08-17 10:35:59 +08001/*
2 * Copyright (C) 2007 Freescale Semiconductor, Inc.
3 *
4 * Tony Li <tony.li@freescale.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation;
9 */
10
11#include <common.h>
12#include <i2c.h>
13#include <asm/io.h>
14
Kim Phillips53b34982007-08-21 17:00:17 -050015#ifdef CONFIG_PQ_MDS_PIB
16
Tony Lic8b57f12007-08-17 10:35:59 +080017#include "pq-mds-pib.h"
18
19int pib_init(void)
20{
21 u8 val8;
22 u8 orig_i2c_bus;
23
24 /* Switch temporarily to I2C bus #2 */
25 orig_i2c_bus = i2c_get_bus_num();
26 i2c_set_bus_num(1);
Kim Phillips7c667142007-08-16 22:52:59 -050027
28 val8 = 0;
Tony Lic8b57f12007-08-17 10:35:59 +080029#if defined(CONFIG_PCI) && !defined(CONFIG_PCISLAVE)
30 /* Assign PIB PMC slot to desired PCI bus */
Tony Lic8b57f12007-08-17 10:35:59 +080031 i2c_write(0x23, 0x6, 1, &val8, 1);
32 i2c_write(0x23, 0x7, 1, &val8, 1);
33 val8 = 0xff;
34 i2c_write(0x23, 0x2, 1, &val8, 1);
35 i2c_write(0x23, 0x3, 1, &val8, 1);
36
37 val8 = 0;
38 i2c_write(0x26, 0x6, 1, &val8, 1);
39 val8 = 0x34;
40 i2c_write(0x26, 0x7, 1, &val8, 1);
41#if defined(CONFIG_MPC832XEMDS)
42 val8 = 0xf9; /* PMC2, PMC3 slot to PCI bus */
43#else
44 val8 = 0xf3; /* PMC1, PMC2, PMC3 slot to PCI bus */
45#endif
46 i2c_write(0x26, 0x2, 1, &val8, 1);
47 val8 = 0xff;
48 i2c_write(0x26, 0x3, 1, &val8, 1);
49
50 val8 = 0;
51 i2c_write(0x27, 0x6, 1, &val8, 1);
52 i2c_write(0x27, 0x7, 1, &val8, 1);
53 val8 = 0xff;
54 i2c_write(0x27, 0x2, 1, &val8, 1);
55 val8 = 0xef;
56 i2c_write(0x27, 0x3, 1, &val8, 1);
57
58 eieio();
59
60#if defined(CONFIG_MPC832XEMDS)
61 printf("PCI 32bit bus on PMC2 &PMC3\n");
62#else
63 printf("PCI 32bit bus on PMC1 & PMC2 &PMC3\n");
64#endif
65#endif
66
67#if defined(CONFIG_PQ_MDS_PIB_ATM)
68#if defined(CONFIG_MPC8360EMDS)
69 val8 = 0;
70 i2c_write(0x20, 0x6, 1, &val8, 1);
71 i2c_write(0x20, 0x7, 1, &val8, 1);
72
73 val8 = 0xdf;
74 i2c_write(0x20, 0x2, 1, &val8, 1);
75 val8 = 0xf7;
76 i2c_write(0x20, 0x3, 1, &val8, 1);
77
78 eieio();
79
80 printf("QOC3 ATM card on PMC0\n");
81#elif defined(CONFIG_MPC832XEMDS)
82 val = 0;
83 i2c_write(0x26, 0x7, 1, &val, 1);
84 val = 0xf7;
85 i2c_write(0x26, 0x3, 1, &val, 1);
86
87 val = 0;
88 i2c_write(0x21, 0x6, 1, &val, 1);
89 i2c_write(0x21, 0x7, 1, &val, 1);
90
91 val = 0xdf;
92 i2c_write(0x21, 0x2, 1, &val, 1);
93 val = 0xef;
94 i2c_write(0x21, 0x3, 1, &val, 1);
95
96 eieio();
97
98 printf("QOC3 ATM card on PMC1\n");
99#endif
100#endif
101 /* Reset to original I2C bus */
102 i2c_set_bus_num(orig_i2c_bus);
103 return 0;
104}
Kim Phillips53b34982007-08-21 17:00:17 -0500105#endif /* CONFIG_PQ_MDS_PIB */