Marc Jones | a67d4fd | 2007-05-04 19:05:36 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 7e61e45 | 2008-01-18 10:35:56 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Uwe Hermann | 344e457 | 2007-05-22 10:12:49 +0000 | [diff] [blame] | 3 | * |
| 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 Menzel | a8ae1c6 | 2013-02-20 13:21:20 +0100 | [diff] [blame] | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Uwe Hermann | 344e457 | 2007-05-22 10:12:49 +0000 | [diff] [blame] | 13 | * GNU General Public License for more details. |
Uwe Hermann | 344e457 | 2007-05-22 10:12:49 +0000 | [diff] [blame] | 14 | */ |
Marc Jones | a67d4fd | 2007-05-04 19:05:36 +0000 | [diff] [blame] | 15 | |
Li-Ta Lo | 5d69896 | 2006-04-20 21:31:47 +0000 | [diff] [blame] | 16 | #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 Lo | a910a3a | 2006-04-20 22:54:32 +0000 | [diff] [blame] | 21 | #include "cs5536.h" |
Li-Ta Lo | 5d69896 | 2006-04-20 21:31:47 +0000 | [diff] [blame] | 22 | |
Marc Jones | a67d4fd | 2007-05-04 19:05:36 +0000 | [diff] [blame] | 23 | #define IDE_CFG 0x40 |
Jordan Crouse | 2a133f7 | 2007-05-10 18:43:57 +0000 | [diff] [blame] | 24 | #define CHANEN (1L << 1) |
| 25 | #define PWB (1L << 14) |
| 26 | #define CABLE (1L << 16) |
Marc Jones | a67d4fd | 2007-05-04 19:05:36 +0000 | [diff] [blame] | 27 | #define IDE_DTC 0x48 |
| 28 | #define IDE_CAST 0x4C |
| 29 | #define IDE_ETC 0x50 |
| 30 | |
Li-Ta Lo | 5d69896 | 2006-04-20 21:31:47 +0000 | [diff] [blame] | 31 | static void ide_init(struct device *dev) |
| 32 | { |
Marc Jones | a67d4fd | 2007-05-04 19:05:36 +0000 | [diff] [blame] | 33 | uint32_t ide_cfg; |
| 34 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 35 | printk(BIOS_SPEW, "cs5536_ide: %s\n", __func__); |
Marc Jones | a67d4fd | 2007-05-04 19:05:36 +0000 | [diff] [blame] | 36 | /* 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 Jones | 9d9518f | 2008-05-06 16:56:47 +0000 | [diff] [blame] | 42 | pci_write_config32(dev, IDE_CFG, ide_cfg); |
Li-Ta Lo | 5d69896 | 2006-04-20 21:31:47 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Li-Ta Lo | 5d69896 | 2006-04-20 21:31:47 +0000 | [diff] [blame] | 45 | static struct device_operations ide_ops = { |
Jordan Crouse | 2a133f7 | 2007-05-10 18:43:57 +0000 | [diff] [blame] | 46 | .read_resources = pci_dev_read_resources, |
| 47 | .set_resources = pci_dev_set_resources, |
Li-Ta Lo | 5d69896 | 2006-04-20 21:31:47 +0000 | [diff] [blame] | 48 | .enable_resources = pci_dev_enable_resources, |
Jordan Crouse | 2a133f7 | 2007-05-10 18:43:57 +0000 | [diff] [blame] | 49 | .init = ide_init, |
| 50 | .enable = 0, |
Li-Ta Lo | 5d69896 | 2006-04-20 21:31:47 +0000 | [diff] [blame] | 51 | }; |
| 52 | |
Stefan Reinauer | f1cf1f7 | 2007-10-24 09:08:58 +0000 | [diff] [blame] | 53 | static const struct pci_driver ide_driver __pci_driver = { |
Jordan Crouse | 2a133f7 | 2007-05-10 18:43:57 +0000 | [diff] [blame] | 54 | .ops = &ide_ops, |
Li-Ta Lo | a910a3a | 2006-04-20 22:54:32 +0000 | [diff] [blame] | 55 | .vendor = PCI_VENDOR_ID_AMD, |
Marc Jones | a909ee6 | 2007-05-10 23:12:18 +0000 | [diff] [blame] | 56 | .device = PCI_DEVICE_ID_AMD_CS5536_B0_IDE, |
Li-Ta Lo | 5d69896 | 2006-04-20 21:31:47 +0000 | [diff] [blame] | 57 | }; |