blob: 53723e6a5acbcbff726950575e06b410822b2c9e [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 */
Marc Jonesa67d4fd2007-05-04 19:05:36 +000015
Li-Ta Lo5d698962006-04-20 21:31:47 +000016#include <console/console.h>
17#include <device/device.h>
18#include <device/pci.h>
19#include <device/pci_ids.h>
20#include <device/pci_ops.h>
Li-Ta Loa910a3a2006-04-20 22:54:32 +000021#include "cs5536.h"
Li-Ta Lo5d698962006-04-20 21:31:47 +000022
Marc Jonesa67d4fd2007-05-04 19:05:36 +000023#define IDE_CFG 0x40
Jordan Crouse2a133f72007-05-10 18:43:57 +000024 #define CHANEN (1L << 1)
25 #define PWB (1L << 14)
26 #define CABLE (1L << 16)
Marc Jonesa67d4fd2007-05-04 19:05:36 +000027#define IDE_DTC 0x48
28#define IDE_CAST 0x4C
29#define IDE_ETC 0x50
30
Li-Ta Lo5d698962006-04-20 21:31:47 +000031static void ide_init(struct device *dev)
32{
Marc Jonesa67d4fd2007-05-04 19:05:36 +000033 uint32_t ide_cfg;
34
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000035 printk(BIOS_SPEW, "cs5536_ide: %s\n", __func__);
Marc Jonesa67d4fd2007-05-04 19:05:36 +000036 /* GPIO and IRQ setup are handled in the main chipset code. */
37
38 // Enable the channel and Post Write Buffer
39 // NOTE: Only 32-bit writes to the data buffer are allowed when PWB is set
40 ide_cfg = pci_read_config32(dev, IDE_CFG);
41 ide_cfg |= CHANEN | PWB;
Marc Jones9d9518f2008-05-06 16:56:47 +000042 pci_write_config32(dev, IDE_CFG, ide_cfg);
Li-Ta Lo5d698962006-04-20 21:31:47 +000043}
44
Li-Ta Lo5d698962006-04-20 21:31:47 +000045static struct device_operations ide_ops = {
Jordan Crouse2a133f72007-05-10 18:43:57 +000046 .read_resources = pci_dev_read_resources,
47 .set_resources = pci_dev_set_resources,
Li-Ta Lo5d698962006-04-20 21:31:47 +000048 .enable_resources = pci_dev_enable_resources,
Jordan Crouse2a133f72007-05-10 18:43:57 +000049 .init = ide_init,
50 .enable = 0,
Li-Ta Lo5d698962006-04-20 21:31:47 +000051};
52
Stefan Reinauerf1cf1f72007-10-24 09:08:58 +000053static const struct pci_driver ide_driver __pci_driver = {
Jordan Crouse2a133f72007-05-10 18:43:57 +000054 .ops = &ide_ops,
Li-Ta Loa910a3a2006-04-20 22:54:32 +000055 .vendor = PCI_VENDOR_ID_AMD,
Marc Jonesa909ee62007-05-10 23:12:18 +000056 .device = PCI_DEVICE_ID_AMD_CS5536_B0_IDE,
Li-Ta Lo5d698962006-04-20 21:31:47 +000057};