1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #define __SIMPLE_DEVICE__
5 #include <console/console.h>
7 #include <device/pci.h>
8 #include <device/pci_ids.h>
9 #include <device/pci_ops.h>
14 int pch_silicon_revision(void)
16 static int pch_revision_id
= 0;
19 pch_revision_id
= pci_read_config8(PCH_LPC_DEV
, PCI_REVISION_ID
);
21 return pch_revision_id
;
24 int pch_silicon_type(void)
26 static int pch_type
= 0;
29 pch_type
= pci_read_config8(PCH_LPC_DEV
, PCI_DEVICE_ID
+ 1);
34 bool pch_is_mobile(void)
36 const u16 devids
[] = {
37 PCI_DID_INTEL_6_SERIES_MOBILE_SFF
, PCI_DID_INTEL_6_SERIES_MOBILE
,
38 PCI_DID_INTEL_6_SERIES_UM67
, PCI_DID_INTEL_6_SERIES_HM65
,
39 PCI_DID_INTEL_6_SERIES_HM67
, PCI_DID_INTEL_6_SERIES_QS67
,
40 PCI_DID_INTEL_6_SERIES_QM67
,
41 PCI_DID_INTEL_7_SERIES_MOBILE
, PCI_DID_INTEL_7_SERIES_MOBILE_SFF
,
42 PCI_DID_INTEL_7_SERIES_QM77
, PCI_DID_INTEL_7_SERIES_QS77
,
43 PCI_DID_INTEL_7_SERIES_HM77
, PCI_DID_INTEL_7_SERIES_UM77
,
44 PCI_DID_INTEL_7_SERIES_HM76
, PCI_DID_INTEL_7_SERIES_HM75
,
45 PCI_DID_INTEL_7_SERIES_HM70
, PCI_DID_INTEL_7_SERIES_NM70
47 u16 devid
= pci_s_read_config16(PCH_LPC_DEV
, PCI_DEVICE_ID
);
49 for (size_t i
= 0; i
< ARRAY_SIZE(devids
); i
++)
50 if (devid
== devids
[i
])
55 int pch_silicon_supported(int type
, int rev
)
57 int cur_type
= pch_silicon_type();
58 int cur_rev
= pch_silicon_revision();
62 /* CougarPoint minimum revision */
63 if (cur_type
== PCH_TYPE_CPT
&& cur_rev
>= rev
)
65 /* PantherPoint any revision */
66 if (cur_type
== PCH_TYPE_PPT
)
71 /* PantherPoint minimum revision */
72 if (cur_type
== PCH_TYPE_PPT
&& cur_rev
>= rev
)
80 #define IOBP_RETRY 1000
81 static inline int iobp_poll(void)
83 unsigned int try = IOBP_RETRY
;
93 printk(BIOS_ERR
, "IOBP timeout\n");
97 void pch_iobp_update(u32 address
, u32 andvalue
, u32 orvalue
)
101 /* Set the address */
102 RCBA32(IOBPIRI
) = address
;
105 if (pch_silicon_supported(PCH_TYPE_CPT
, PCH_STEP_B0
))
106 RCBA32(IOBPS
) = IOBPS_RW_BX
;
108 RCBA32(IOBPS
) = IOBPS_READ_AX
;
113 data
= RCBA32(IOBPD
);
117 /* Check for successful transaction */
118 if ((RCBA32(IOBPS
) & 0x6) != 0) {
119 printk(BIOS_ERR
, "IOBP read 0x%08x failed\n", address
);
123 /* Update the data */
128 if (pch_silicon_supported(PCH_TYPE_CPT
, PCH_STEP_B0
))
129 RCBA32(IOBPS
) = IOBPS_RW_BX
;
131 RCBA32(IOBPS
) = IOBPS_WRITE_AX
;
135 /* Write IOBP data */
136 RCBA32(IOBPD
) = data
;