blob: 7ecb8df2ab20aca5e0b78759acaa02c1885770e3 [file] [log] [blame]
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +03001/*
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.
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030014 */
15
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030016#include <device/device.h>
17#include <device/pci.h>
18#include <device/pci_ids.h>
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030019#include <device/smbus.h>
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030020#include <cpu/x86/lapic.h>
21#include <arch/ioapic.h>
Elyes HAOUAS400f9ca2019-06-23 07:01:22 +020022
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030023#include "hudson.h"
24#include "smbus.c"
25
26#define NMI_OFF 0
27
28#define MAINBOARD_POWER_OFF 0
29#define MAINBOARD_POWER_ON 1
30
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030031/*
32* HUDSON enables all USB controllers by default in SMBUS Control.
33* HUDSON enables SATA by default in SMBUS Control.
34*/
35
Elyes HAOUASd9ef5462018-05-19 17:08:23 +020036static void sm_init(struct device *dev)
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030037{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080038 setup_ioapic(VIO_APIC_VADDR, CONFIG_MAX_CPUS);
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030039}
40
Elyes HAOUASd9ef5462018-05-19 17:08:23 +020041static int lsmbus_recv_byte(struct device *dev)
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030042{
43 u32 device;
44 struct resource *res;
45 struct bus *pbus;
46
47 device = dev->path.i2c.device;
48 pbus = get_pbus_smbus(dev);
49
50 res = find_resource(pbus->dev, 0x90);
51
52 return do_smbus_recv_byte(res->base, device);
53}
54
Elyes HAOUASd9ef5462018-05-19 17:08:23 +020055static int lsmbus_send_byte(struct device *dev, u8 val)
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030056{
57 u32 device;
58 struct resource *res;
59 struct bus *pbus;
60
61 device = dev->path.i2c.device;
62 pbus = get_pbus_smbus(dev);
63
64 res = find_resource(pbus->dev, 0x90);
65
66 return do_smbus_send_byte(res->base, device, val);
67}
68
Elyes HAOUASd9ef5462018-05-19 17:08:23 +020069static int lsmbus_read_byte(struct device *dev, u8 address)
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030070{
71 u32 device;
72 struct resource *res;
73 struct bus *pbus;
74
75 device = dev->path.i2c.device;
76 pbus = get_pbus_smbus(dev);
77
78 res = find_resource(pbus->dev, 0x90);
79
80 return do_smbus_read_byte(res->base, device, address);
81}
82
Elyes HAOUASd9ef5462018-05-19 17:08:23 +020083static int lsmbus_write_byte(struct device *dev, u8 address, u8 val)
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +030084{
85 u32 device;
86 struct resource *res;
87 struct bus *pbus;
88
89 device = dev->path.i2c.device;
90 pbus = get_pbus_smbus(dev);
91
92 res = find_resource(pbus->dev, 0x90);
93
94 return do_smbus_write_byte(res->base, device, address, val);
95}
96static struct smbus_bus_operations lops_smbus_bus = {
97 .recv_byte = lsmbus_recv_byte,
98 .send_byte = lsmbus_send_byte,
99 .read_byte = lsmbus_read_byte,
100 .write_byte = lsmbus_write_byte,
101};
102
Elyes HAOUASd9ef5462018-05-19 17:08:23 +0200103static void hudson_sm_read_resources(struct device *dev)
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +0300104{
105}
106
107static void hudson_sm_set_resources(struct device *dev)
108{
109}
110
111static struct pci_operations lops_pci = {
112 .set_subsystem = pci_dev_set_subsystem,
113};
114static struct device_operations smbus_ops = {
115 .read_resources = hudson_sm_read_resources,
116 .set_resources = hudson_sm_set_resources,
117 .enable_resources = pci_dev_enable_resources,
118 .init = sm_init,
Kyösti Mälkkid0e212c2015-02-26 20:47:47 +0200119 .scan_bus = scan_smbus,
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +0300120 .ops_pci = &lops_pci,
121 .ops_smbus_bus = &lops_smbus_bus,
122};
123static const struct pci_driver smbus_driver __pci_driver = {
124 .ops = &smbus_ops,
125 .vendor = PCI_VENDOR_ID_AMD,
Kyösti Mälkki9d9a5522016-11-19 22:14:59 +0200126 .device = PCI_DEVICE_ID_AMD_SB900_SM,
Kyösti Mälkkie8b4da22014-10-21 18:22:32 +0300127};