blob: 36742aa31c5af0764300a88fb24362fb57ed85b7 [file] [log] [blame]
zbao246e84b2012-07-13 18:47:03 +08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2010 Advanced Micro Devices, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <console/console.h>
21#include <device/device.h>
22#include <device/pci.h>
23#include <device/pci_ids.h>
24#include <device/pci_ops.h>
25#include <device/smbus.h>
26#include <pc80/mc146818rtc.h>
27#include <bitops.h>
28#include <arch/io.h>
29#include <cpu/x86/lapic.h>
30#include <arch/ioapic.h>
31#include <stdlib.h>
32#include "hudson.h"
33#include "smbus.c"
34
35#define NMI_OFF 0
36
37#define MAINBOARD_POWER_OFF 0
38#define MAINBOARD_POWER_ON 1
39
40#ifndef CONFIG_MAINBOARD_POWER_ON_AFTER_POWER_FAIL
41#define CONFIG_MAINBOARD_POWER_ON_AFTER_POWER_FAIL MAINBOARD_POWER_ON
42#endif
43
44#define BIT0 (1 << 0)
45#define BIT1 (1 << 1)
46#define BIT2 (1 << 2)
47#define BIT3 (1 << 3)
48#define BIT4 (1 << 4)
49#define BIT5 (1 << 5)
50#define BIT6 (1 << 6)
51#define BIT7 (1 << 7)
52
53#define BIT8 (1 << 8 )
54#define BIT9 (1 << 9 )
55#define BIT10 (1 << 10)
56#define BIT11 (1 << 11)
57#define BIT12 (1 << 12)
58#define BIT13 (1 << 13)
59#define BIT14 (1 << 14)
60#define BIT15 (1 << 15)
61
62#define BIT16 (1 << 16)
63#define BIT17 (1 << 17)
64#define BIT18 (1 << 18)
65#define BIT19 (1 << 19)
66#define BIT20 (1 << 20)
67#define BIT21 (1 << 21)
68#define BIT22 (1 << 22)
69#define BIT23 (1 << 23)
70#define BIT24 (1 << 24)
71#define BIT25 (1 << 25)
72#define BIT26 (1 << 26)
73#define BIT27 (1 << 27)
74#define BIT28 (1 << 28)
75#define BIT29 (1 << 29)
76#define BIT30 (1 << 30)
77#define BIT31 (1 << 31)
78
79/*
80* HUDSON enables all USB controllers by default in SMBUS Control.
81* HUDSON enables SATA by default in SMBUS Control.
82*/
83
84static void sm_init(device_t dev)
85{
86}
87
88static int lsmbus_recv_byte(device_t dev)
89{
90 u32 device;
91 struct resource *res;
92 struct bus *pbus;
93
94 device = dev->path.i2c.device;
95 pbus = get_pbus_smbus(dev);
96
97 res = find_resource(pbus->dev, 0x90);
98
99 return do_smbus_recv_byte(res->base, device);
100}
101
102static int lsmbus_send_byte(device_t dev, u8 val)
103{
104 u32 device;
105 struct resource *res;
106 struct bus *pbus;
107
108 device = dev->path.i2c.device;
109 pbus = get_pbus_smbus(dev);
110
111 res = find_resource(pbus->dev, 0x90);
112
113 return do_smbus_send_byte(res->base, device, val);
114}
115
116static int lsmbus_read_byte(device_t dev, u8 address)
117{
118 u32 device;
119 struct resource *res;
120 struct bus *pbus;
121
122 device = dev->path.i2c.device;
123 pbus = get_pbus_smbus(dev);
124
125 res = find_resource(pbus->dev, 0x90);
126
127 return do_smbus_read_byte(res->base, device, address);
128}
129
130static int lsmbus_write_byte(device_t dev, u8 address, u8 val)
131{
132 u32 device;
133 struct resource *res;
134 struct bus *pbus;
135
136 device = dev->path.i2c.device;
137 pbus = get_pbus_smbus(dev);
138
139 res = find_resource(pbus->dev, 0x90);
140
141 return do_smbus_write_byte(res->base, device, address, val);
142}
143static struct smbus_bus_operations lops_smbus_bus = {
144 .recv_byte = lsmbus_recv_byte,
145 .send_byte = lsmbus_send_byte,
146 .read_byte = lsmbus_read_byte,
147 .write_byte = lsmbus_write_byte,
148};
149
150static void hudson_sm_read_resources(device_t dev)
151{
152}
153
154static void hudson_sm_set_resources(struct device *dev)
155{
156}
157
158static struct pci_operations lops_pci = {
159 .set_subsystem = pci_dev_set_subsystem,
160};
161static struct device_operations smbus_ops = {
162 .read_resources = hudson_sm_read_resources,
163 .set_resources = hudson_sm_set_resources,
164 .enable_resources = pci_dev_enable_resources,
165 .init = sm_init,
166 .scan_bus = scan_static_bus,
167 .ops_pci = &lops_pci,
168 .ops_smbus_bus = &lops_smbus_bus,
169};
170static const struct pci_driver smbus_driver __pci_driver = {
171 .ops = &smbus_ops,
172 .vendor = PCI_VENDOR_ID_AMD,
173 .device = PCI_DEVICE_ID_ATI_SB900_SM,
174};