Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * This is a good place to put board specific reboot fixups.
0004  *
0005  * List of supported fixups:
0006  * geode-gx1/cs5530a - Jaya Kumar <jayalk@intworks.biz>
0007  * geode-gx/lx/cs5536 - Andres Salomon <dilinger@debian.org>
0008  *
0009  */
0010 
0011 #include <asm/delay.h>
0012 #include <linux/pci.h>
0013 #include <linux/interrupt.h>
0014 #include <asm/reboot_fixups.h>
0015 #include <asm/msr.h>
0016 #include <linux/cs5535.h>
0017 
0018 static void cs5530a_warm_reset(struct pci_dev *dev)
0019 {
0020     /* writing 1 to the reset control register, 0x44 causes the
0021     cs5530a to perform a system warm reset */
0022     pci_write_config_byte(dev, 0x44, 0x1);
0023     udelay(50); /* shouldn't get here but be safe and spin-a-while */
0024     return;
0025 }
0026 
0027 static void cs5536_warm_reset(struct pci_dev *dev)
0028 {
0029     /* writing 1 to the LSB of this MSR causes a hard reset */
0030     wrmsrl(MSR_DIVIL_SOFT_RESET, 1ULL);
0031     udelay(50); /* shouldn't get here but be safe and spin a while */
0032 }
0033 
0034 static void rdc321x_reset(struct pci_dev *dev)
0035 {
0036     unsigned i;
0037     /* Voluntary reset the watchdog timer */
0038     outl(0x80003840, 0xCF8);
0039     /* Generate a CPU reset on next tick */
0040     i = inl(0xCFC);
0041     /* Use the minimum timer resolution */
0042     i |= 0x1600;
0043     outl(i, 0xCFC);
0044     outb(1, 0x92);
0045 }
0046 
0047 static void ce4100_reset(struct pci_dev *dev)
0048 {
0049     int i;
0050 
0051     for (i = 0; i < 10; i++) {
0052         outb(0x2, 0xcf9);
0053         udelay(50);
0054     }
0055 }
0056 
0057 struct device_fixup {
0058     unsigned int vendor;
0059     unsigned int device;
0060     void (*reboot_fixup)(struct pci_dev *);
0061 };
0062 
0063 /*
0064  * PCI ids solely used for fixups_table go here
0065  */
0066 #define PCI_DEVICE_ID_INTEL_CE4100  0x0708
0067 
0068 static const struct device_fixup fixups_table[] = {
0069 { PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_LEGACY, cs5530a_warm_reset },
0070 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA, cs5536_warm_reset },
0071 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SC1100_BRIDGE, cs5530a_warm_reset },
0072 { PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030, rdc321x_reset },
0073 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CE4100, ce4100_reset },
0074 };
0075 
0076 /*
0077  * we see if any fixup is available for our current hardware. if there
0078  * is a fixup, we call it and we expect to never return from it. if we
0079  * do return, we keep looking and then eventually fall back to the
0080  * standard mach_reboot on return.
0081  */
0082 void mach_reboot_fixups(void)
0083 {
0084     const struct device_fixup *cur;
0085     struct pci_dev *dev;
0086     int i;
0087 
0088     /* we can be called from sysrq-B code. In such a case it is
0089      * prohibited to dig PCI */
0090     if (in_interrupt())
0091         return;
0092 
0093     for (i=0; i < ARRAY_SIZE(fixups_table); i++) {
0094         cur = &(fixups_table[i]);
0095         dev = pci_get_device(cur->vendor, cur->device, NULL);
0096         if (!dev)
0097             continue;
0098 
0099         cur->reboot_fixup(dev);
0100         pci_dev_put(dev);
0101     }
0102 }
0103