3 * Copyright (C) 2008-2009 coresystems GmbH
4 * Copyright (C) 2012 The Chromium OS Authors.
6 * SPDX-License-Identifier: GPL-2.0
12 #include <asm/arch/pch.h>
14 static int pch_revision_id = -1;
15 static int pch_type = -1;
17 int pch_silicon_revision(void)
23 if (pch_revision_id < 0)
24 pch_revision_id = x86_pci_read_config8(dev, PCI_REVISION_ID);
25 return pch_revision_id;
28 int pch_silicon_type(void)
35 pch_type = x86_pci_read_config8(dev, PCI_DEVICE_ID + 1);
39 int pch_silicon_supported(int type, int rev)
41 int cur_type = pch_silicon_type();
42 int cur_rev = pch_silicon_revision();
46 /* CougarPoint minimum revision */
47 if (cur_type == PCH_TYPE_CPT && cur_rev >= rev)
49 /* PantherPoint any revision */
50 if (cur_type == PCH_TYPE_PPT)
55 /* PantherPoint minimum revision */
56 if (cur_type == PCH_TYPE_PPT && cur_rev >= rev)
64 #define IOBP_RETRY 1000
65 static inline int iobp_poll(void)
67 unsigned try = IOBP_RETRY;
71 data = readl(RCB_REG(IOBPS));
77 printf("IOBP timeout\n");
81 void pch_iobp_update(u32 address, u32 andvalue, u32 orvalue)
86 writel(address, RCB_REG(IOBPIRI));
89 if (pch_silicon_supported(PCH_TYPE_CPT, PCH_STEP_B0))
90 writel(IOBPS_RW_BX, RCB_REG(IOBPS));
92 writel(IOBPS_READ_AX, RCB_REG(IOBPS));
97 data = readl(RCB_REG(IOBPD));
101 /* Check for successful transaction */
102 if ((readl(RCB_REG(IOBPS)) & 0x6) != 0) {
103 printf("IOBP read 0x%08x failed\n", address);
107 /* Update the data */
112 if (pch_silicon_supported(PCH_TYPE_CPT, PCH_STEP_B0))
113 writel(IOBPS_RW_BX, RCB_REG(IOBPS));
115 writel(IOBPS_WRITE_AX, RCB_REG(IOBPS));
119 /* Write IOBP data */
120 writel(data, RCB_REG(IOBPD));