coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ide.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <device/device.h>
5 #include <device/pci.h>
6 #include <device/pci_ids.h>
7 #include <device/pci_ops.h>
8 #include "chip.h"
9 #include "i82801dx.h"
10 
12 
13 static void ide_init(struct device *dev)
14 {
15  /* Get the chip configuration */
16  config_t *config = dev->chip_info;
17 
18  /* Enable IDE devices so the Linux IDE driver will work. */
19  uint16_t ideTimingConfig;
20 
21  ideTimingConfig = pci_read_config16(dev, IDE_TIM_PRI);
22  ideTimingConfig &= ~IDE_DECODE_ENABLE;
23  if (!config || config->ide0_enable) {
24  /* Enable primary IDE interface. */
25  ideTimingConfig |= IDE_DECODE_ENABLE;
26  printk(BIOS_DEBUG, "IDE0: Primary IDE interface is enabled\n");
27  } else {
28  printk(BIOS_INFO, "IDE0: Primary IDE interface is disabled\n");
29  }
30  pci_write_config16(dev, IDE_TIM_PRI, ideTimingConfig);
31 
32  ideTimingConfig = pci_read_config16(dev, IDE_TIM_SEC);
33  ideTimingConfig &= ~IDE_DECODE_ENABLE;
34  if (!config || config->ide1_enable) {
35  /* Enable secondary IDE interface. */
36  ideTimingConfig |= IDE_DECODE_ENABLE;
37  printk(BIOS_DEBUG, "IDE1: Secondary IDE interface is enabled\n");
38  } else {
39  printk(BIOS_INFO, "IDE1: Secondary IDE interface is disabled\n");
40  }
41  pci_write_config16(dev, IDE_TIM_SEC, ideTimingConfig);
42 }
43 
44 static struct device_operations ide_ops = {
46  .set_resources = pci_dev_set_resources,
47  .enable_resources = pci_dev_enable_resources,
48  .init = ide_init,
49  .enable = i82801dx_enable,
50 };
51 
52 /* 82801DB */
53 static const struct pci_driver i82801db_ide __pci_driver = {
54  .ops = &ide_ops,
55  .vendor = PCI_VID_INTEL,
56  .device = 0x24cb,
57 };
58 
59 /* 82801DBM */
60 static const struct pci_driver i82801dbm_ide __pci_driver = {
61  .ops = &ide_ops,
62  .vendor = PCI_VID_INTEL,
63  .device = 0x24ca,
64 };
#define printk(level,...)
Definition: stdlib.h:16
void i82801dx_enable(struct device *dev)
Definition: i82801dx.c:8
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
Definition: pci_ops.h:52
static __always_inline void pci_write_config16(const struct device *dev, u16 reg, u16 val)
Definition: pci_ops.h:70
static struct device_operations ide_ops
Definition: ide.c:44
static void ide_init(struct device *dev)
Definition: ide.c:13
static const struct pci_driver i82801db_ide __pci_driver
Definition: ide.c:53
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
enum board_config config
Definition: memory.c:448
void pci_dev_enable_resources(struct device *dev)
Definition: pci_device.c:721
void pci_dev_read_resources(struct device *dev)
Definition: pci_device.c:534
void pci_dev_set_resources(struct device *dev)
Definition: pci_device.c:691
#define PCI_VID_INTEL
Definition: pci_ids.h:2157
#define IDE_TIM_PRI
Definition: sata.h:34
#define IDE_TIM_SEC
Definition: sata.h:52
#define IDE_DECODE_ENABLE
Definition: sata.h:35
unsigned short uint16_t
Definition: stdint.h:11
void(* read_resources)(struct device *dev)
Definition: device.h:39
Definition: device.h:107
DEVTREE_CONST void * chip_info
Definition: device.h:164