~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/loongson64/loongson-3/acpi_init.c

Version: ~ [ linux-5.5 ] ~ [ linux-5.4.15 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.98 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.167 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.211 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.211 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.81 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 #include <linux/io.h>
  3 #include <linux/init.h>
  4 #include <linux/ioport.h>
  5 #include <linux/export.h>
  6 
  7 #define SBX00_ACPI_IO_BASE 0x800
  8 #define SBX00_ACPI_IO_SIZE 0x100
  9 
 10 #define ACPI_PM_EVT_BLK         (SBX00_ACPI_IO_BASE + 0x00) /* 4 bytes */
 11 #define ACPI_PM_CNT_BLK         (SBX00_ACPI_IO_BASE + 0x04) /* 2 bytes */
 12 #define ACPI_PMA_CNT_BLK        (SBX00_ACPI_IO_BASE + 0x0F) /* 1 byte */
 13 #define ACPI_PM_TMR_BLK         (SBX00_ACPI_IO_BASE + 0x18) /* 4 bytes */
 14 #define ACPI_GPE0_BLK           (SBX00_ACPI_IO_BASE + 0x10) /* 8 bytes */
 15 #define ACPI_END                (SBX00_ACPI_IO_BASE + 0x80)
 16 
 17 #define PM_INDEX        0xCD6
 18 #define PM_DATA         0xCD7
 19 #define PM2_INDEX       0xCD0
 20 #define PM2_DATA        0xCD1
 21 
 22 /*
 23  * SCI interrupt need acpi space, allocate here
 24  */
 25 
 26 static int __init register_acpi_resource(void)
 27 {
 28         request_region(SBX00_ACPI_IO_BASE, SBX00_ACPI_IO_SIZE, "acpi");
 29         return 0;
 30 }
 31 
 32 static void pmio_write_index(u16 index, u8 reg, u8 value)
 33 {
 34         outb(reg, index);
 35         outb(value, index + 1);
 36 }
 37 
 38 static u8 pmio_read_index(u16 index, u8 reg)
 39 {
 40         outb(reg, index);
 41         return inb(index + 1);
 42 }
 43 
 44 void pm_iowrite(u8 reg, u8 value)
 45 {
 46         pmio_write_index(PM_INDEX, reg, value);
 47 }
 48 EXPORT_SYMBOL(pm_iowrite);
 49 
 50 u8 pm_ioread(u8 reg)
 51 {
 52         return pmio_read_index(PM_INDEX, reg);
 53 }
 54 EXPORT_SYMBOL(pm_ioread);
 55 
 56 void pm2_iowrite(u8 reg, u8 value)
 57 {
 58         pmio_write_index(PM2_INDEX, reg, value);
 59 }
 60 EXPORT_SYMBOL(pm2_iowrite);
 61 
 62 u8 pm2_ioread(u8 reg)
 63 {
 64         return pmio_read_index(PM2_INDEX, reg);
 65 }
 66 EXPORT_SYMBOL(pm2_ioread);
 67 
 68 static void acpi_hw_clear_status(void)
 69 {
 70         u16 value;
 71 
 72         /* PMStatus: Clear WakeStatus/PwrBtnStatus */
 73         value = inw(ACPI_PM_EVT_BLK);
 74         value |= (1 << 8 | 1 << 15);
 75         outw(value, ACPI_PM_EVT_BLK);
 76 
 77         /* GPEStatus: Clear all generated events */
 78         outl(inl(ACPI_GPE0_BLK), ACPI_GPE0_BLK);
 79 }
 80 
 81 void acpi_registers_setup(void)
 82 {
 83         u32 value;
 84 
 85         /* PM Status Base */
 86         pm_iowrite(0x20, ACPI_PM_EVT_BLK & 0xff);
 87         pm_iowrite(0x21, ACPI_PM_EVT_BLK >> 8);
 88 
 89         /* PM Control Base */
 90         pm_iowrite(0x22, ACPI_PM_CNT_BLK & 0xff);
 91         pm_iowrite(0x23, ACPI_PM_CNT_BLK >> 8);
 92 
 93         /* GPM Base */
 94         pm_iowrite(0x28, ACPI_GPE0_BLK & 0xff);
 95         pm_iowrite(0x29, ACPI_GPE0_BLK >> 8);
 96 
 97         /* ACPI End */
 98         pm_iowrite(0x2e, ACPI_END & 0xff);
 99         pm_iowrite(0x2f, ACPI_END >> 8);
100 
101         /* IO Decode: When AcpiDecodeEnable set, South-Bridge uses the contents
102          * of the PM registers at index 0x20~0x2B to decode ACPI I/O address. */
103         pm_iowrite(0x0e, 1 << 3);
104 
105         /* SCI_EN set */
106         outw(1, ACPI_PM_CNT_BLK);
107 
108         /* Enable to generate SCI */
109         pm_iowrite(0x10, pm_ioread(0x10) | 1);
110 
111         /* GPM3/GPM9 enable */
112         value = inl(ACPI_GPE0_BLK + 4);
113         outl(value | (1 << 14) | (1 << 22), ACPI_GPE0_BLK + 4);
114 
115         /* Set GPM9 as input */
116         pm_iowrite(0x8d, pm_ioread(0x8d) & (~(1 << 1)));
117 
118         /* Set GPM9 as non-output */
119         pm_iowrite(0x94, pm_ioread(0x94) | (1 << 3));
120 
121         /* GPM3 config ACPI trigger SCIOUT */
122         pm_iowrite(0x33, pm_ioread(0x33) & (~(3 << 4)));
123 
124         /* GPM9 config ACPI trigger SCIOUT */
125         pm_iowrite(0x3d, pm_ioread(0x3d) & (~(3 << 2)));
126 
127         /* GPM3 config falling edge trigger */
128         pm_iowrite(0x37, pm_ioread(0x37) & (~(1 << 6)));
129 
130         /* No wait for STPGNT# in ACPI Sx state */
131         pm_iowrite(0x7c, pm_ioread(0x7c) | (1 << 6));
132 
133         /* Set GPM3 pull-down enable */
134         value = pm2_ioread(0xf6);
135         value |= ((1 << 7) | (1 << 3));
136         pm2_iowrite(0xf6, value);
137 
138         /* Set GPM9 pull-down enable */
139         value = pm2_ioread(0xf8);
140         value |= ((1 << 5) | (1 << 1));
141         pm2_iowrite(0xf8, value);
142 }
143 
144 int __init sbx00_acpi_init(void)
145 {
146         register_acpi_resource();
147         acpi_registers_setup();
148         acpi_hw_clear_status();
149 
150         return 0;
151 }
152 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp