blob: 4651257056252d9f632d7103441e6c5a74b3b494 [file] [log] [blame]
Marc Jonesa67d4fd2007-05-04 19:05:36 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +00002 * This file is part of the coreboot project.
Uwe Hermann344e4572007-05-22 10:12:49 +00003 *
4 * Copyright (C) 2007 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 version 2 as
8 * published by the Free Software Foundation.
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
Paul Menzela8ae1c62013-02-20 13:21:20 +010012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Uwe Hermann344e4572007-05-22 10:12:49 +000013 * GNU General Public License for more details.
Uwe Hermann344e4572007-05-22 10:12:49 +000014 */
Li-Ta Lo5d698962006-04-20 21:31:47 +000015
16#include <arch/io.h>
Uwe Hermann74d1a6e2010-10-12 17:34:08 +000017#include <arch/ioapic.h>
Li-Ta Lo5d698962006-04-20 21:31:47 +000018#include <device/device.h>
19#include <device/pci.h>
20#include <device/pci_ops.h>
21#include <device/pci_ids.h>
Christian Gmeinerb5dfcae2012-07-20 10:21:29 +020022#include <device/smbus.h>
Li-Ta Lo5d698962006-04-20 21:31:47 +000023#include <console/console.h>
Marc Jonesa67d4fd2007-05-04 19:05:36 +000024#include <stdint.h>
25#include <pc80/isa-dma.h>
26#include <pc80/mc146818rtc.h>
Stefan Reinauerae762b52009-03-06 18:39:54 +000027#include <pc80/i8259.h>
Ronald G. Minnichcf120d12006-04-25 19:57:39 +000028#include <cpu/x86/msr.h>
Marc Jonesa67d4fd2007-05-04 19:05:36 +000029#include <cpu/amd/vr.h>
Carl-Daniel Hailfinger2ee67792008-10-01 12:52:52 +000030#include <stdlib.h>
Ronald G. Minnichcf120d12006-04-25 19:57:39 +000031#include "chip.h"
Marc Jonesa67d4fd2007-05-04 19:05:36 +000032#include "cs5536.h"
Christian Gmeinerb5dfcae2012-07-20 10:21:29 +020033#include "smbus.h"
Li-Ta Lo5d698962006-04-20 21:31:47 +000034
Marc Jonesa67d4fd2007-05-04 19:05:36 +000035struct msrinit {
Stefan Reinauer78b40332010-03-17 22:09:26 +000036 u32 msrnum;
Ronald G. Minnich5d573c22006-05-16 02:51:16 +000037 msr_t msr;
Marc Jonesa67d4fd2007-05-04 19:05:36 +000038};
Ronald G. Minnich5d573c22006-05-16 02:51:16 +000039
Marc Jonesa67d4fd2007-05-04 19:05:36 +000040/* Master Configuration Register for Bus Masters.*/
Stefan Reinauerba096952010-04-22 09:22:15 +000041static struct msrinit SB_MASTER_CONF_TABLE[] = {
Jordan Crouse2a133f72007-05-10 18:43:57 +000042 {USB2_SB_GLD_MSR_CONF, {.hi = 0,.lo = 0x00008f000}},
43 {ATA_SB_GLD_MSR_CONF, {.hi = 0,.lo = 0x00048f000}},
44 {AC97_SB_GLD_MSR_CONF, {.hi = 0,.lo = 0x00008f000}},
45 {MDD_SB_GLD_MSR_CONF, {.hi = 0,.lo = 0x00000f000}},
46 {0, {0, 0}}
Marc Jonesa67d4fd2007-05-04 19:05:36 +000047};
Ronald G. Minnich5d573c22006-05-16 02:51:16 +000048
Marc Jonesa67d4fd2007-05-04 19:05:36 +000049/* 5536 Clock Gating*/
Stefan Reinauerba096952010-04-22 09:22:15 +000050static struct msrinit CS5536_CLOCK_GATING_TABLE[] = {
Jordan Crouse2a133f72007-05-10 18:43:57 +000051 /* MSR Setting*/
52 {GLIU_SB_GLD_MSR_PM, {.hi = 0,.lo = 0x000000004}},
53 {GLPCI_SB_GLD_MSR_PM, {.hi = 0,.lo = 0x000000005}},
54 {GLCP_SB_GLD_MSR_PM, {.hi = 0,.lo = 0x000000004}},
55 {MDD_SB_GLD_MSR_PM, {.hi = 0,.lo = 0x050554111}}, /* SMBus clock gating errata (PBZ 2226 & SiBZ 3977) */
56 {ATA_SB_GLD_MSR_PM, {.hi = 0,.lo = 0x000000005}},
57 {AC97_SB_GLD_MSR_PM, {.hi = 0,.lo = 0x000000005}},
58 {0, {0, 0}}
Marc Jonesa67d4fd2007-05-04 19:05:36 +000059};
Ronald G. Minnich5d573c22006-05-16 02:51:16 +000060
Marc Jonesa67d4fd2007-05-04 19:05:36 +000061struct acpiinit {
Stefan Reinauer78b40332010-03-17 22:09:26 +000062 u16 ioreg;
63 u32 regdata;
Marc Jonesa67d4fd2007-05-04 19:05:36 +000064};
65
Stefan Reinauerba096952010-04-22 09:22:15 +000066static struct acpiinit acpi_init_table[] = {
Marc Jonesa67d4fd2007-05-04 19:05:36 +000067 {ACPI_IO_BASE + 0x00, 0x01000000},
68 {ACPI_IO_BASE + 0x08, 0},
69 {ACPI_IO_BASE + 0x0C, 0},
70 {ACPI_IO_BASE + 0x1C, 0},
71 {ACPI_IO_BASE + 0x18, 0x0FFFFFFFF},
72 {ACPI_IO_BASE + 0x00, 0x0000FFFF},
73 {PMS_IO_BASE + PM_SCLK, 0x000000E00},
Jordan Crouse2a133f72007-05-10 18:43:57 +000074 {PMS_IO_BASE + PM_SED, 0x000004601},
Marc Jonesa67d4fd2007-05-04 19:05:36 +000075 {PMS_IO_BASE + PM_SIDD, 0x000008C02},
Jordan Crouse2a133f72007-05-10 18:43:57 +000076 {PMS_IO_BASE + PM_WKD, 0x0000000A0},
Marc Jonesa67d4fd2007-05-04 19:05:36 +000077 {PMS_IO_BASE + PM_WKXD, 0x0000000A0},
Stefan Reinauer720297c2010-04-02 22:11:20 +000078 {0, 0}
Marc Jonesa67d4fd2007-05-04 19:05:36 +000079};
80
81struct FLASH_DEVICE {
Jordan Crouse2a133f72007-05-10 18:43:57 +000082 unsigned char fType; /* Flash type: NOR or NAND */
Marc Jonesa67d4fd2007-05-04 19:05:36 +000083 unsigned char fInterface; /* Flash interface: I/O or Memory */
Jordan Crouse2a133f72007-05-10 18:43:57 +000084 unsigned long fMask; /* Flash size/mask */
Marc Jonesa67d4fd2007-05-04 19:05:36 +000085};
86
Stefan Reinauerba096952010-04-22 09:22:15 +000087static struct FLASH_DEVICE FlashInitTable[] = {
Jordan Crouse2a133f72007-05-10 18:43:57 +000088 {FLASH_TYPE_NAND, FLASH_IF_MEM, FLASH_MEM_4K}, /* CS0, or Flash Device 0 */
89 {FLASH_TYPE_NONE, 0, 0}, /* CS1, or Flash Device 1 */
90 {FLASH_TYPE_NONE, 0, 0}, /* CS2, or Flash Device 2 */
91 {FLASH_TYPE_NONE, 0, 0}, /* CS3, or Flash Device 3 */
Marc Jonesa67d4fd2007-05-04 19:05:36 +000092};
93
Carl-Daniel Hailfinger2ee67792008-10-01 12:52:52 +000094#define FlashInitTableLen (ARRAY_SIZE(FlashInitTable))
Marc Jonesa67d4fd2007-05-04 19:05:36 +000095
Stefan Reinauerba096952010-04-22 09:22:15 +000096static u32 FlashPort[] = {
Marc Jonesa67d4fd2007-05-04 19:05:36 +000097 MDD_LBAR_FLSH0,
98 MDD_LBAR_FLSH1,
99 MDD_LBAR_FLSH2,
100 MDD_LBAR_FLSH3
Jordan Crouse2a133f72007-05-10 18:43:57 +0000101};
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000102
103/* ***************************************************************************/
104/* **/
105/* * pmChipsetInit*/
106/* **/
107/* * Program ACPI LBAR and initialize ACPI registers.*/
108/* **/
109/* ***************************************************************************/
Jordan Crouse2a133f72007-05-10 18:43:57 +0000110static void pmChipsetInit(void)
111{
Stefan Reinauer78b40332010-03-17 22:09:26 +0000112 u32 val = 0;
113 u16 port;
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000114
Jordan Crouse2a133f72007-05-10 18:43:57 +0000115 port = (PMS_IO_BASE + 0x010);
116 val = 0x0E00; /* 1ms */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000117 outl(val, port);
118
Jordan Crouse2a133f72007-05-10 18:43:57 +0000119 /* PM_WKXD */
120 /* Make sure bits[3:0]=0000b to clear the */
121 /* saved Sx state */
122 port = (PMS_IO_BASE + 0x034);
123 val = 0x0A0; /* 5ms */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000124 outl(val, port);
125
Jordan Crouse2a133f72007-05-10 18:43:57 +0000126 /* PM_WKD */
127 port = (PMS_IO_BASE + 0x030);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000128 outl(val, port);
129
Jordan Crouse2a133f72007-05-10 18:43:57 +0000130 /* PM_SED */
131 port = (PMS_IO_BASE + 0x014);
Marc Jonesddf845f2007-05-10 23:22:27 +0000132 val = 0x04601; /* 5ms, # of 3.57954MHz clock edges */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000133 outl(val, port);
134
Jordan Crouse2a133f72007-05-10 18:43:57 +0000135 /* PM_SIDD */
136 port = (PMS_IO_BASE + 0x020);
Marc Jonesddf845f2007-05-10 23:22:27 +0000137 val = 0x08C02; /* 10ms, # of 3.57954MHz clock edges */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000138 outl(val, port);
Ronald G. Minnich5d573c22006-05-16 02:51:16 +0000139}
140
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000141/***************************************************************************
142 *
143 * ChipsetFlashSetup
144 *
145 * Flash LBARs need to be setup before VSA init so the PCI BARs have
146 * correct size info. Call this routine only if flash needs to be
147 * configured (don't call it if you want IDE).
148 *
149 **************************************************************************/
Jordan Crouse2a133f72007-05-10 18:43:57 +0000150static void ChipsetFlashSetup(void)
151{
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000152 msr_t msr;
153 int i;
154 int numEnabled = 0;
155
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000156 printk(BIOS_DEBUG, "ChipsetFlashSetup: Start\n");
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000157 for (i = 0; i < FlashInitTableLen; i++) {
158 if (FlashInitTable[i].fType != FLASH_TYPE_NONE) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000159 printk(BIOS_DEBUG, "Enable CS%d\n", i);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000160 /* we need to configure the memory/IO mask */
161 msr = rdmsr(FlashPort[i]);
162 msr.hi = 0; /* start with the "enabled" bit clear */
163 if (FlashInitTable[i].fType == FLASH_TYPE_NAND)
164 msr.hi |= 0x00000002;
165 else
166 msr.hi &= ~0x00000002;
167 if (FlashInitTable[i].fInterface == FLASH_IF_MEM)
168 msr.hi |= 0x00000004;
169 else
170 msr.hi &= ~0x00000004;
171 msr.hi |= FlashInitTable[i].fMask;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000172 printk(BIOS_DEBUG, "MSR(0x%08X, %08X_%08X)\n", FlashPort[i],
Jordan Crouse2a133f72007-05-10 18:43:57 +0000173 msr.hi, msr.lo);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000174 wrmsr(FlashPort[i], msr);
175
176 /* now write-enable the device */
177 msr = rdmsr(MDD_NORF_CNTRL);
178 msr.lo |= (1 << i);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000179 printk(BIOS_DEBUG, "MSR(0x%08X, %08X_%08X)\n", MDD_NORF_CNTRL,
Jordan Crouse2a133f72007-05-10 18:43:57 +0000180 msr.hi, msr.lo);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000181 wrmsr(MDD_NORF_CNTRL, msr);
182
183 /* update the number enabled */
184 numEnabled++;
Ronald G. Minnich88fb1a62006-06-22 04:37:27 +0000185 }
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000186 }
187
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000188 printk(BIOS_DEBUG, "ChipsetFlashSetup: Finish\n");
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000189
190}
Jordan Crouse2a133f72007-05-10 18:43:57 +0000191
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000192/* ***************************************************************************/
193/* **/
194/* * enable_ide_nand_flash_header */
195/* Run after VSA init to enable the flash PCI device header */
196/* **/
197/* ***************************************************************************/
Stefan Reinauer720297c2010-04-02 22:11:20 +0000198static void enable_ide_nand_flash_header(void)
Jordan Crouse2a133f72007-05-10 18:43:57 +0000199{
200 /* Tell VSA to use FLASH PCI header. Not IDE header. */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000201 outl(0x80007A40, 0xCF8);
202 outl(0xDEADBEEF, 0xCFC);
203}
204
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000205#define RTC_CENTURY 0x32
206#define RTC_DOMA 0x3D
207#define RTC_MONA 0x3E
208
Jordan Crouse2a133f72007-05-10 18:43:57 +0000209static void lpc_init(struct southbridge_amd_cs5536_config *sb)
210{
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000211 msr_t msr;
212
213 if (sb->lpc_serirq_enable) {
214 msr.lo = sb->lpc_serirq_enable;
215 msr.hi = 0;
216 wrmsr(MDD_IRQM_LPC, msr);
217 if (sb->lpc_serirq_polarity) {
218 msr.lo = sb->lpc_serirq_polarity << 16;
Jordan Crouse2a133f72007-05-10 18:43:57 +0000219 msr.lo |= (sb->lpc_serirq_mode << 6) | (1 << 7); /* enable */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000220 msr.hi = 0;
221 wrmsr(MDD_LPC_SIRQ, msr);
222 }
223 }
224
225 /* Allow DMA from LPC */
226 msr = rdmsr(MDD_DMA_MAP);
227 msr.lo = 0x7777;
228 wrmsr(MDD_DMA_MAP, msr);
229
230 /* enable the RTC/CMOS century byte at address 32h */
231 msr = rdmsr(MDD_RTC_CENTURY_OFFSET);
232 msr.lo = RTC_CENTURY;
233 wrmsr(MDD_RTC_CENTURY_OFFSET, msr);
234
235 /* enable the RTC/CMOS day of month and month alarms */
236 msr = rdmsr(MDD_RTC_DOMA_IND);
237 msr.lo = RTC_DOMA;
238 wrmsr(MDD_RTC_DOMA_IND, msr);
239
240 msr = rdmsr(MDD_RTC_MONA_IND);
241 msr.lo = RTC_MONA;
242 wrmsr(MDD_RTC_MONA_IND, msr);
243
Gabe Blackb3f08c62014-04-30 17:12:25 -0700244 cmos_init(0);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000245
246 isa_dma_init();
247}
Stefan Reinauer14e22772010-04-27 06:56:47 +0000248
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000249
Edwin Beasante30db0e2010-02-09 10:22:33 +0000250/**
251 * Depending on settings in the config struct, enable COM1 or COM2 or both.
252 *
253 * If the enable is NOT set, the UARTs are explicitly disabled, which is
254 * required if (e.g.) there is a Super I/O attached that does COM1 or COM2.
255 *
256 * @param sb Southbridge config structure.
257 */
Jordan Crouse2a133f72007-05-10 18:43:57 +0000258static void uarts_init(struct southbridge_amd_cs5536_config *sb)
259{
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000260 msr_t msr;
Edwin Beasante30db0e2010-02-09 10:22:33 +0000261 u16 addr = 0;
262 u32 gpio_addr;
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000263 device_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000264
265 dev = dev_find_device(PCI_VENDOR_ID_AMD,
Jordan Crouse2a133f72007-05-10 18:43:57 +0000266 PCI_DEVICE_ID_AMD_CS5536_ISA, 0);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000267 gpio_addr = pci_read_config32(dev, PCI_BASE_ADDRESS_1);
Edwin Beasante30db0e2010-02-09 10:22:33 +0000268 gpio_addr &= ~1; /* Clear I/O bit */
269 printk(BIOS_DEBUG, "GPIO_ADDR: %08X\n", gpio_addr);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000270
Edwin Beasante30db0e2010-02-09 10:22:33 +0000271 /* This could be extended to support IR modes. */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000272
273 /* COM1 */
Jordan Crouse2a133f72007-05-10 18:43:57 +0000274 if (sb->com1_enable) {
Edwin Beasante30db0e2010-02-09 10:22:33 +0000275 printk(BIOS_SPEW, "uarts_init: enable COM1\n");
276 /* Set the address. */
Jordan Crouse2a133f72007-05-10 18:43:57 +0000277 switch (sb->com1_address) {
278 case 0x3F8:
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000279 addr = 7;
280 break;
Jordan Crouse2a133f72007-05-10 18:43:57 +0000281 case 0x3E8:
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000282 addr = 6;
283 break;
Jordan Crouse2a133f72007-05-10 18:43:57 +0000284 case 0x2F8:
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000285 addr = 5;
286 break;
Jordan Crouse2a133f72007-05-10 18:43:57 +0000287 case 0x2E8:
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000288 addr = 4;
289 break;
290 }
291 msr = rdmsr(MDD_LEG_IO);
292 msr.lo |= addr << 16;
Jordan Crouse2a133f72007-05-10 18:43:57 +0000293 wrmsr(MDD_LEG_IO, msr);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000294
Edwin Beasante30db0e2010-02-09 10:22:33 +0000295 /* Set the IRQ. */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000296 msr = rdmsr(MDD_IRQM_YHIGH);
297 msr.lo |= sb->com1_irq << 24;
298 wrmsr(MDD_IRQM_YHIGH, msr);
299
300 /* GPIO8 - UART1_TX */
Edwin Beasante30db0e2010-02-09 10:22:33 +0000301 /* Set: Output Enable (0x4) */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000302 outl(GPIOL_8_SET, gpio_addr + GPIOL_OUTPUT_ENABLE);
303 /* Set: OUTAUX1 Select (0x10) */
304 outl(GPIOL_8_SET, gpio_addr + GPIOL_OUT_AUX1_SELECT);
305
Stefan Reinauer5a559d42010-02-03 13:49:24 +0000306 /* GPIO9 - UART1_RX */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000307 /* Set: Input Enable (0x20) */
308 outl(GPIOL_9_SET, gpio_addr + GPIOL_INPUT_ENABLE);
Edwin Beasante30db0e2010-02-09 10:22:33 +0000309 /* Set: INAUX1 Select (0x34) */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000310 outl(GPIOL_9_SET, gpio_addr + GPIOL_IN_AUX1_SELECT);
311
Edwin Beasante30db0e2010-02-09 10:22:33 +0000312 /* Set: GPIO 8 + 9 Pull Up (0x18) */
Jordan Crouse2a133f72007-05-10 18:43:57 +0000313 outl(GPIOL_8_SET | GPIOL_9_SET,
314 gpio_addr + GPIOL_PULLUP_ENABLE);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000315
Edwin Beasante30db0e2010-02-09 10:22:33 +0000316 /* Enable COM1.
317 *
318 * Bit 1 = device enable
319 * Bit 4 = allow access to the upper banks
320 */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000321 msr.lo = (1 << 4) | (1 << 1);
322 msr.hi = 0;
323 wrmsr(MDD_UART1_CONF, msr);
Jordan Crouse2a133f72007-05-10 18:43:57 +0000324 } else {
Edwin Beasante30db0e2010-02-09 10:22:33 +0000325 /* Reset and disable COM1. */
326 printk(BIOS_SPEW, "uarts_init: disable COM1\n");
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000327 msr = rdmsr(MDD_UART1_CONF);
Edwin Beasante30db0e2010-02-09 10:22:33 +0000328 msr.lo = 1; /* Reset */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000329 wrmsr(MDD_UART1_CONF, msr);
Edwin Beasante30db0e2010-02-09 10:22:33 +0000330 msr.lo = 0; /* Disabled */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000331 wrmsr(MDD_UART1_CONF, msr);
332
Edwin Beasante30db0e2010-02-09 10:22:33 +0000333 /* Disable the IRQ. */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000334 msr = rdmsr(MDD_LEG_IO);
Marc Jonesf0272802007-06-02 23:55:17 +0000335 msr.lo &= ~(0xF << 16);
Jordan Crouse2a133f72007-05-10 18:43:57 +0000336 wrmsr(MDD_LEG_IO, msr);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000337 }
338
339 /* COM2 */
Jordan Crouse2a133f72007-05-10 18:43:57 +0000340 if (sb->com2_enable) {
Edwin Beasante30db0e2010-02-09 10:22:33 +0000341 printk(BIOS_SPEW, "uarts_init: enable COM2\n");
Jordan Crouse2a133f72007-05-10 18:43:57 +0000342 switch (sb->com2_address) {
343 case 0x3F8:
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000344 addr = 7;
345 break;
Jordan Crouse2a133f72007-05-10 18:43:57 +0000346 case 0x3E8:
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000347 addr = 6;
348 break;
Jordan Crouse2a133f72007-05-10 18:43:57 +0000349 case 0x2F8:
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000350 addr = 5;
351 break;
Jordan Crouse2a133f72007-05-10 18:43:57 +0000352 case 0x2E8:
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000353 addr = 4;
354 break;
355 }
356 msr = rdmsr(MDD_LEG_IO);
357 msr.lo |= addr << 20;
Jordan Crouse2a133f72007-05-10 18:43:57 +0000358 wrmsr(MDD_LEG_IO, msr);
Edwin Beasante30db0e2010-02-09 10:22:33 +0000359 printk(BIOS_SPEW, "uarts_init: wrote COM2 address 0x%x\n", sb->com2_address);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000360
Edwin Beasante30db0e2010-02-09 10:22:33 +0000361 /* Set the IRQ. */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000362 msr = rdmsr(MDD_IRQM_YHIGH);
363 msr.lo |= sb->com2_irq << 28;
364 wrmsr(MDD_IRQM_YHIGH, msr);
Edwin Beasante30db0e2010-02-09 10:22:33 +0000365 printk(BIOS_SPEW, "uarts_init: set COM2 irq\n");
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000366
Stefan Reinauer5a559d42010-02-03 13:49:24 +0000367 /* GPIO3 - UART2_RX */
Marc Jonesc72ff112007-06-19 22:07:16 +0000368 /* Set: Input Enable (0x20) */
369 outl(GPIOL_3_SET, gpio_addr + GPIOL_INPUT_ENABLE);
370 /* Set: INAUX1 Select (0x34) */
371 outl(GPIOL_3_SET, gpio_addr + GPIOL_IN_AUX1_SELECT);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000372
Stefan Reinauer5a559d42010-02-03 13:49:24 +0000373 /* GPIO4 - UART2_TX */
374 /* Set: Output Enable (0x4) */
375 outl(GPIOL_4_SET, gpio_addr + GPIOL_OUTPUT_ENABLE);
Edwin Beasante30db0e2010-02-09 10:22:33 +0000376 printk(BIOS_SPEW, "uarts_init: set output enable\n");
Stefan Reinauer5a559d42010-02-03 13:49:24 +0000377 /* Set: OUTAUX1 Select (0x10) */
378 outl(GPIOL_4_SET, gpio_addr + GPIOL_OUT_AUX1_SELECT);
Edwin Beasante30db0e2010-02-09 10:22:33 +0000379 printk(BIOS_SPEW, "uarts_init: set OUTAUX1\n");
Stefan Reinauer5a559d42010-02-03 13:49:24 +0000380
Edwin Beasante30db0e2010-02-09 10:22:33 +0000381 /* Set: GPIO 3 + 4 Pull Up (0x18) */
Jordan Crouse2a133f72007-05-10 18:43:57 +0000382 outl(GPIOL_3_SET | GPIOL_4_SET,
383 gpio_addr + GPIOL_PULLUP_ENABLE);
Edwin Beasante30db0e2010-02-09 10:22:33 +0000384 printk(BIOS_SPEW, "uarts_init: set pullup COM2\n");
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000385
Edwin Beasante30db0e2010-02-09 10:22:33 +0000386 /* Enable COM2.
387 *
388 * Bit 1 = device enable
389 * Bit 4 = allow access to the upper banks
390 */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000391 msr.lo = (1 << 4) | (1 << 1);
392 msr.hi = 0;
393 wrmsr(MDD_UART2_CONF, msr);
Edwin Beasante30db0e2010-02-09 10:22:33 +0000394 printk(BIOS_SPEW, "uarts_init: COM2 enabled\n");
Jordan Crouse2a133f72007-05-10 18:43:57 +0000395 } else {
Edwin Beasante30db0e2010-02-09 10:22:33 +0000396 printk(BIOS_SPEW, "uarts_init: disable COM2\n");
397 /* Reset and disable COM2. */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000398 msr = rdmsr(MDD_UART2_CONF);
Edwin Beasante30db0e2010-02-09 10:22:33 +0000399 msr.lo = 1; /* Reset */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000400 wrmsr(MDD_UART2_CONF, msr);
Edwin Beasante30db0e2010-02-09 10:22:33 +0000401 msr.lo = 0; /* Disabled */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000402 wrmsr(MDD_UART2_CONF, msr);
403
Edwin Beasante30db0e2010-02-09 10:22:33 +0000404 /* Disable the IRQ. */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000405 msr = rdmsr(MDD_LEG_IO);
Marc Jonesf0272802007-06-02 23:55:17 +0000406 msr.lo &= ~(0xF << 20);
Jordan Crouse2a133f72007-05-10 18:43:57 +0000407 wrmsr(MDD_LEG_IO, msr);
Ronald G. Minnich88fb1a62006-06-22 04:37:27 +0000408 }
409}
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000410
Edwin Beasante30db0e2010-02-09 10:22:33 +0000411
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000412#define HCCPARAMS 0x08
413#define IPREG04 0xA0
414 #define USB_HCCPW_SET (1 << 1)
415#define UOCCAP 0x00
416 #define APU_SET (1 << 15)
417#define UOCMUX 0x04
Jordan Crouse2a133f72007-05-10 18:43:57 +0000418#define PMUX_HOST 0x02
419#define PMUX_DEVICE 0x03
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000420 #define PUEN_SET (1 << 2)
421#define UDCDEVCTL 0x404
422 #define UDC_SD_SET (1 << 10)
423#define UOCCTL 0x0C
424 #define PADEN_SET (1 << 7)
425
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000426static void enable_USB_port4(struct southbridge_amd_cs5536_config *sb)
427{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800428 void *bar;
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000429 msr_t msr;
430 device_t dev;
431
Stefan Reinauer14e22772010-04-27 06:56:47 +0000432 dev = dev_find_device(PCI_VENDOR_ID_AMD,
Jordan Crouse2a133f72007-05-10 18:43:57 +0000433 PCI_DEVICE_ID_AMD_CS5536_EHCI, 0);
434 if (dev) {
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000435
436 /* Serial Short Detect Enable */
437 msr = rdmsr(USB2_SB_GLD_MSR_CONF);
438 msr.hi |= USB2_UPPER_SSDEN_SET;
439 wrmsr(USB2_SB_GLD_MSR_CONF, msr);
440
441 /* write to clear diag register */
Jordan Crouse2a133f72007-05-10 18:43:57 +0000442 wrmsr(USB2_SB_GLD_MSR_DIAG, rdmsr(USB2_SB_GLD_MSR_DIAG));
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000443
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800444 bar = (void *)pci_read_config32(dev, PCI_BASE_ADDRESS_0);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000445
Martin Roth55e31a92014-12-16 20:53:49 -0700446 /* Make HCCPARAMS writable */
Stefan Reinauer9fe4d792010-01-16 17:53:38 +0000447 write32(bar + IPREG04, read32(bar + IPREG04) | USB_HCCPW_SET);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000448
449 /* ; EECP=50h, IST=01h, ASPC=1 */
Stefan Reinauer9fe4d792010-01-16 17:53:38 +0000450 write32(bar + HCCPARAMS, 0x00005012);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000451 }
452
Stefan Reinauer14e22772010-04-27 06:56:47 +0000453 dev = dev_find_device(PCI_VENDOR_ID_AMD,
Jordan Crouse2a133f72007-05-10 18:43:57 +0000454 PCI_DEVICE_ID_AMD_CS5536_OTG, 0);
455 if (dev) {
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800456 bar = (void *)pci_read_config32(dev, PCI_BASE_ADDRESS_0);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000457
Stefan Reinauer9fe4d792010-01-16 17:53:38 +0000458 write32(bar + UOCMUX, read32(bar + UOCMUX) & PUEN_SET);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000459
460 /* Host or Device? */
461 if (sb->enable_USBP4_device) {
Stefan Reinauer9fe4d792010-01-16 17:53:38 +0000462 write32(bar + UOCMUX, read32(bar + UOCMUX) | PMUX_DEVICE);
Jordan Crouse2a133f72007-05-10 18:43:57 +0000463 } else {
Stefan Reinauer9fe4d792010-01-16 17:53:38 +0000464 write32(bar + UOCMUX, read32(bar + UOCMUX) | PMUX_HOST);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000465 }
466
467 /* Overcurrent configuration */
468 if (sb->enable_USBP4_overcurrent) {
Stefan Reinauer9fe4d792010-01-16 17:53:38 +0000469 write32(bar + UOCCAP, read32(bar + UOCCAP)
470 | sb->enable_USBP4_overcurrent);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000471 }
472 }
473
474 /* PBz#6466: If the UOC(OTG) device, port 4, is configured as a device,
Jordan Crouse2a133f72007-05-10 18:43:57 +0000475 * then perform the following sequence:
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000476 *
477 * - set SD bit in DEVCTRL udc register
478 * - set PADEN (former OTGPADEN) bit in uoc register
479 * - set APU bit in uoc register */
480 if (sb->enable_USBP4_device) {
Stefan Reinauer14e22772010-04-27 06:56:47 +0000481 dev = dev_find_device(PCI_VENDOR_ID_AMD,
Jordan Crouse2a133f72007-05-10 18:43:57 +0000482 PCI_DEVICE_ID_AMD_CS5536_UDC, 0);
483 if (dev) {
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800484 bar = (void *)pci_read_config32(dev,
485 PCI_BASE_ADDRESS_0);
Stefan Reinauer9fe4d792010-01-16 17:53:38 +0000486 write32(bar + UDCDEVCTL,
487 read32(bar + UDCDEVCTL) | UDC_SD_SET);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000488
489 }
490
Jordan Crouse2a133f72007-05-10 18:43:57 +0000491 dev = dev_find_device(PCI_VENDOR_ID_AMD,
492 PCI_DEVICE_ID_AMD_CS5536_OTG, 0);
493 if (dev) {
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800494 bar = (void *)pci_read_config32(dev,
495 PCI_BASE_ADDRESS_0);
Stefan Reinauer9fe4d792010-01-16 17:53:38 +0000496 write32(bar + UOCCTL, read32(bar + UOCCTL) | PADEN_SET);
497 write32(bar + UOCCAP, read32(bar + UOCCAP) | APU_SET);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000498 }
499 }
500
501 /* Disable virtual PCI UDC and OTG headers */
Stefan Reinauer14e22772010-04-27 06:56:47 +0000502 dev = dev_find_device(PCI_VENDOR_ID_AMD,
Jordan Crouse2a133f72007-05-10 18:43:57 +0000503 PCI_DEVICE_ID_AMD_CS5536_UDC, 0);
504 if (dev) {
Marc Jonesd03b7d42007-05-10 23:53:11 +0000505 pci_write_config32(dev, 0x7C, 0xDEADBEEF);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000506 }
507
Stefan Reinauer14e22772010-04-27 06:56:47 +0000508 dev = dev_find_device(PCI_VENDOR_ID_AMD,
Jordan Crouse2a133f72007-05-10 18:43:57 +0000509 PCI_DEVICE_ID_AMD_CS5536_OTG, 0);
510 if (dev) {
Marc Jonesd03b7d42007-05-10 23:53:11 +0000511 pci_write_config32(dev, 0x7C, 0xDEADBEEF);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000512 }
513}
514
Stefan Reinauerba096952010-04-22 09:22:15 +0000515/****************************************************************************
Stefan Reinauer14e22772010-04-27 06:56:47 +0000516 *
517 * ChipsetInit
Stefan Reinauerba096952010-04-22 09:22:15 +0000518 *
519 * Called from northbridge init (Pre-VSA).
520 *
Stefan Reinauerba096952010-04-22 09:22:15 +0000521 ****************************************************************************/
Jordan Crouse2a133f72007-05-10 18:43:57 +0000522void chipsetinit(void)
523{
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000524 device_t dev;
525 msr_t msr;
Stefan Reinauer78b40332010-03-17 22:09:26 +0000526 u32 msrnum;
Stefan Reinauer42926852010-04-22 10:44:08 +0000527 struct southbridge_amd_cs5536_config *sb;
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000528 struct msrinit *csi;
529
Peter Stugeae3f4b52010-05-23 04:50:41 +0000530 dev = dev_find_slot(0, PCI_DEVFN(0xf, 0));
Stefan Reinauer42926852010-04-22 10:44:08 +0000531
532 if (!dev) {
533 printk(BIOS_ERR, "CS5536 not found.\n");
534 return;
535 }
536
537 sb = (struct southbridge_amd_cs5536_config *)dev->chip_info;
538
539 if (!sb) {
540 printk(BIOS_ERR, "CS5536 configuration not found.\n");
541 return;
542 }
543
Marc Jonesd03b7d42007-05-10 23:53:11 +0000544 post_code(P80_CHIPSET_INIT);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000545
Stefan Reinauerf8ee1802008-01-18 15:08:58 +0000546 /* we hope NEVER to be in coreboot when S3 resumes
Jordan Crouse2a133f72007-05-10 18:43:57 +0000547 if (! IsS3Resume()) */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000548 {
549 struct acpiinit *aci = acpi_init_table;
Jordan Crouse2a133f72007-05-10 18:43:57 +0000550 for (; aci->ioreg; aci++) {
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000551 outl(aci->regdata, aci->ioreg);
552 inl(aci->ioreg);
553 }
554
555 pmChipsetInit();
556 }
557
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000558 /* set hd IRQ */
Jordan Crouse2a133f72007-05-10 18:43:57 +0000559 outl(GPIOL_2_SET, GPIO_IO_BASE + GPIOL_INPUT_ENABLE);
560 outl(GPIOL_2_SET, GPIO_IO_BASE + GPIOL_IN_AUX1_SELECT);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000561
Jordan Crouse2a133f72007-05-10 18:43:57 +0000562 /* Allow IO read and writes during a ATA DMA operation. */
563 /* This could be done in the HD rom but do it here for easier debugging. */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000564 msrnum = ATA_SB_GLD_MSR_ERR;
565 msr = rdmsr(msrnum);
566 msr.lo &= ~0x100;
567 wrmsr(msrnum, msr);
568
Jordan Crouse2a133f72007-05-10 18:43:57 +0000569 /* Enable Post Primary IDE. */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000570 msrnum = GLPCI_SB_CTRL;
571 msr = rdmsr(msrnum);
Jordan Crouse2a133f72007-05-10 18:43:57 +0000572 msr.lo |= GLPCI_CRTL_PPIDE_SET;
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000573 wrmsr(msrnum, msr);
574
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000575 csi = SB_MASTER_CONF_TABLE;
Jordan Crouse2a133f72007-05-10 18:43:57 +0000576 for (; csi->msrnum; csi++) {
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000577 msr.lo = csi->msr.lo;
578 msr.hi = csi->msr.hi;
Jordan Crouse2a133f72007-05-10 18:43:57 +0000579 wrmsr(csi->msrnum, msr); // MSR - see table above
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000580 }
581
Jordan Crouse2a133f72007-05-10 18:43:57 +0000582 /* Flash BAR size Setup */
Christian Gmeiner01c095f2013-05-29 20:30:18 +0000583 printk(BIOS_INFO, "%sDoing ChipsetFlashSetup()\n",
Jordan Crouse2a133f72007-05-10 18:43:57 +0000584 sb->enable_ide_nand_flash == 1 ? "" : "Not ");
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000585 if (sb->enable_ide_nand_flash == 1)
586 ChipsetFlashSetup();
587
588 /* */
Jordan Crouse2a133f72007-05-10 18:43:57 +0000589 /* Set up Hardware Clock Gating */
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000590 /* */
591 {
592 csi = CS5536_CLOCK_GATING_TABLE;
Jordan Crouse2a133f72007-05-10 18:43:57 +0000593 for (; csi->msrnum; csi++) {
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000594 msr.lo = csi->msr.lo;
595 msr.hi = csi->msr.hi;
596 wrmsr(csi->msrnum, msr); // MSR - see table above
597 }
598 }
599}
Ronald G. Minnich5d573c22006-05-16 02:51:16 +0000600
Ronald G. Minnichda7ee9f2006-07-21 19:21:38 +0000601static void southbridge_init(struct device *dev)
Li-Ta Lo5d698962006-04-20 21:31:47 +0000602{
Jordan Crouse2a133f72007-05-10 18:43:57 +0000603 struct southbridge_amd_cs5536_config *sb =
604 (struct southbridge_amd_cs5536_config *)dev->chip_info;
Ronald G. Minnichda7ee9f2006-07-21 19:21:38 +0000605 int i;
Ronald G. Minnichcf120d12006-04-25 19:57:39 +0000606 /*
607 * struct device *gpiodev;
608 * unsigned short gpiobase = MDD_GPIO;
609 */
Ronald G. Minnich1c2f49e2006-04-25 19:40:20 +0000610
Christian Gmeiner01c095f2013-05-29 20:30:18 +0000611 printk(BIOS_INFO, "cs5536: %s\n", __func__);
Stefan Reinauer42926852010-04-22 10:44:08 +0000612
613 if (!sb) {
614 printk(BIOS_ERR, "CS5536 configuration not found.\n");
615 return;
616 }
617
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000618 setup_i8259();
619 lpc_init(sb);
620 uarts_init(sb);
Ronald G. Minnichda7ee9f2006-07-21 19:21:38 +0000621
Jordan Crouse2a133f72007-05-10 18:43:57 +0000622 if (sb->enable_gpio_int_route) {
623 vrWrite((VRC_MISCELLANEOUS << 8) + PCI_INT_AB,
624 (sb->enable_gpio_int_route & 0xFFFF));
625 vrWrite((VRC_MISCELLANEOUS << 8) + PCI_INT_CD,
626 (sb->enable_gpio_int_route >> 16));
Ronald G. Minnich2d7bb592006-06-18 02:28:07 +0000627 }
628
Christian Gmeiner01c095f2013-05-29 20:30:18 +0000629 printk(BIOS_DEBUG, "cs5536: %s: enable_ide_nand_flash is %d\n", __func__,
Jordan Crouse2a133f72007-05-10 18:43:57 +0000630 sb->enable_ide_nand_flash);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000631 if (sb->enable_ide_nand_flash == 1) {
632 enable_ide_nand_flash_header();
Ronald G. Minnich88fb1a62006-06-22 04:37:27 +0000633 }
634
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000635 enable_USB_port4(sb);
Richard Smithbcd1f232006-08-28 16:18:32 +0000636
Ronald G. Minnichda7ee9f2006-07-21 19:21:38 +0000637 /* disable unwanted virtual PCI devices */
638 for (i = 0; (i < MAX_UNWANTED_VPCI) && (0 != sb->unwanted_vpci[i]); i++) {
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000639 printk(BIOS_DEBUG, "Disabling VPCI device: 0x%08X\n",
Jordan Crouse2a133f72007-05-10 18:43:57 +0000640 sb->unwanted_vpci[i]);
Ronald G. Minnichda7ee9f2006-07-21 19:21:38 +0000641 outl(sb->unwanted_vpci[i] + 0x7C, 0xCF8);
Jordan Crouse2a133f72007-05-10 18:43:57 +0000642 outl(0xDEADBEEF, 0xCFC);
Ronald G. Minnichda7ee9f2006-07-21 19:21:38 +0000643 }
Li-Ta Lo5d698962006-04-20 21:31:47 +0000644}
645
Myles Watson29cc9ed2009-07-02 18:56:24 +0000646static void cs5536_read_resources(device_t dev)
647{
648 struct resource *res;
649
650 pci_dev_read_resources(dev);
651
652 res = new_resource(dev, 1);
653 res->base = 0x0UL;
Myles Watson81af48e2010-06-07 15:39:04 +0000654 res->size = 0x1000UL;
Myles Watson29cc9ed2009-07-02 18:56:24 +0000655 res->limit = 0xffffUL;
Myles Watson81af48e2010-06-07 15:39:04 +0000656 res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
Myles Watson29cc9ed2009-07-02 18:56:24 +0000657
658 res = new_resource(dev, 3); /* IOAPIC */
Uwe Hermann74d1a6e2010-10-12 17:34:08 +0000659 res->base = IO_APIC_ADDR;
Myles Watson29cc9ed2009-07-02 18:56:24 +0000660 res->size = 0x00001000;
661 res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
662}
663
Ronald G. Minnichda7ee9f2006-07-21 19:21:38 +0000664static void southbridge_enable(struct device *dev)
665{
Christian Gmeiner01c095f2013-05-29 20:30:18 +0000666 printk(BIOS_DEBUG, "cs5536: %s: dev is %p\n", __func__, dev);
Marc Jonesa67d4fd2007-05-04 19:05:36 +0000667
668}
Ronald G. Minnichda7ee9f2006-07-21 19:21:38 +0000669
Christian Gmeinerb5dfcae2012-07-20 10:21:29 +0200670static int lsmbus_read_byte(device_t dev, u8 address)
671{
672 u16 device;
673 struct resource *res;
674 struct bus *pbus;
675
676 device = dev->path.i2c.device;
677 pbus = get_pbus_smbus(dev);
678 res = find_resource(pbus->dev, 0x10);
679
680 return do_smbus_read_byte(res->base, device, address);
681}
682
683static struct smbus_bus_operations lops_smbus_bus = {
684 .read_byte = lsmbus_read_byte,
685};
686
Kyösti Mälkki580e7222015-03-19 21:04:23 +0200687static void scan_lpc_smbus(device_t dev)
Kyösti Mälkkid0e212c2015-02-26 20:47:47 +0200688{
689 /* FIXME. Do we have mixed LPC/SMBus device node here. */
Kyösti Mälkki580e7222015-03-19 21:04:23 +0200690 scan_smbus(dev);
Kyösti Mälkkid0e212c2015-02-26 20:47:47 +0200691}
692
Li-Ta Lo5d698962006-04-20 21:31:47 +0000693static struct device_operations southbridge_ops = {
Myles Watson29cc9ed2009-07-02 18:56:24 +0000694 .read_resources = cs5536_read_resources,
Jordan Crouse2a133f72007-05-10 18:43:57 +0000695 .set_resources = pci_dev_set_resources,
Myles Watson7eac4452010-06-17 16:16:56 +0000696 .enable_resources = pci_dev_enable_resources,
Jordan Crouse2a133f72007-05-10 18:43:57 +0000697 .init = southbridge_init,
Kyösti Mälkkid0e212c2015-02-26 20:47:47 +0200698 .scan_bus = scan_lpc_smbus,
Christian Gmeinerb5dfcae2012-07-20 10:21:29 +0200699 .ops_smbus_bus = &lops_smbus_bus,
Li-Ta Lo5d698962006-04-20 21:31:47 +0000700};
701
Stefan Reinauerf1cf1f72007-10-24 09:08:58 +0000702static const struct pci_driver cs5536_pci_driver __pci_driver = {
Jordan Crouse2a133f72007-05-10 18:43:57 +0000703 .ops = &southbridge_ops,
Li-Ta Lo5d698962006-04-20 21:31:47 +0000704 .vendor = PCI_VENDOR_ID_AMD,
705 .device = PCI_DEVICE_ID_AMD_CS5536_ISA
706};
Ronald G. Minnichcf120d12006-04-25 19:57:39 +0000707
708struct chip_operations southbridge_amd_cs5536_ops = {
Uwe Hermanna7aa29b2006-11-05 18:50:49 +0000709 CHIP_NAME("AMD Geode CS5536 Southbridge")
Jordan Crouse2a133f72007-05-10 18:43:57 +0000710 /* This is only called when this device is listed in the
711 * static device tree.
712 */
713 .enable_dev = southbridge_enable,
Ronald G. Minnichcf120d12006-04-25 19:57:39 +0000714};