summaryrefslogtreecommitdiff
path: root/board/freescale/common/pq-mds-pib.c
blob: 6c72aa1a43f25e81bbaa3ee84f7fca180462dac7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * Copyright (C) 2007 Freescale Semiconductor, Inc.
 *
 * Tony Li <tony.li@freescale.com>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 */

#include <common.h>
#include <i2c.h>
#include <asm/io.h>

#include "pq-mds-pib.h"

int pib_init(void)
{
	u8 val8;
	u8 orig_i2c_bus;

	/* Switch temporarily to I2C bus #2 */
	orig_i2c_bus = i2c_get_bus_num();
	i2c_set_bus_num(1);

	val8 = 0;
#if defined(CONFIG_PCI) && !defined(CONFIG_PCISLAVE)
	/* Assign PIB PMC slot to desired PCI bus */
	i2c_write(0x23, 0x6, 1, &val8, 1);
	i2c_write(0x23, 0x7, 1, &val8, 1);
	val8 = 0xff;
	i2c_write(0x23, 0x2, 1, &val8, 1);
	i2c_write(0x23, 0x3, 1, &val8, 1);

	val8 = 0;
	i2c_write(0x26, 0x6, 1, &val8, 1);
	val8 = 0x34;
	i2c_write(0x26, 0x7, 1, &val8, 1);
#if defined(CONFIG_MPC832XEMDS)
	val8 = 0xf9;            /* PMC2, PMC3 slot to PCI bus */
#else
	val8 = 0xf3;		/* PMC1, PMC2, PMC3 slot to PCI bus */
#endif
	i2c_write(0x26, 0x2, 1, &val8, 1);
	val8 = 0xff;
	i2c_write(0x26, 0x3, 1, &val8, 1);

	val8 = 0;
	i2c_write(0x27, 0x6, 1, &val8, 1);
	i2c_write(0x27, 0x7, 1, &val8, 1);
	val8 = 0xff;
	i2c_write(0x27, 0x2, 1, &val8, 1);
	val8 = 0xef;
	i2c_write(0x27, 0x3, 1, &val8, 1);

	eieio();

#if defined(CONFIG_MPC832XEMDS)
	printf("PCI 32bit bus on PMC2 &PMC3\n");
#else
	printf("PCI 32bit bus on PMC1 & PMC2 &PMC3\n");
#endif
#endif

#if defined(CONFIG_PQ_MDS_PIB_ATM)
#if defined(CONFIG_MPC8360EMDS)
	val8 = 0;
	i2c_write(0x20, 0x6, 1, &val8, 1);
	i2c_write(0x20, 0x7, 1, &val8, 1);

	val8 = 0xdf;
	i2c_write(0x20, 0x2, 1, &val8, 1);
	val8 = 0xf7;
	i2c_write(0x20, 0x3, 1, &val8, 1);

	eieio();

	printf("QOC3 ATM card on PMC0\n");
#elif defined(CONFIG_MPC832XEMDS)
	val8 = 0;
	i2c_write(0x26, 0x7, 1, &val8, 1);
	val8 = 0xf7;
	i2c_write(0x26, 0x3, 1, &val8, 1);

	val8 = 0;
	i2c_write(0x21, 0x6, 1, &val8, 1);
	i2c_write(0x21, 0x7, 1, &val8, 1);

	val8 = 0xdf;
	i2c_write(0x21, 0x2, 1, &val8, 1);
	val8 = 0xef;
	i2c_write(0x21, 0x3, 1, &val8, 1);

	eieio();

	printf("QOC3 ATM card on PMC1\n");
#endif
#endif
	/* Reset to original I2C bus */
	i2c_set_bus_num(orig_i2c_bus);
	return 0;
}