Felix Held | 3f3eca9 | 2020-01-23 17:12:32 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 2 | |
| 3 | #include <arch/io.h> |
Patrick Rudolph | 9bd6015 | 2018-05-04 09:01:38 +0200 | [diff] [blame] | 4 | #include <console/console.h> |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 5 | #include <device/device.h> |
| 6 | #include <device/pnp.h> |
Patrick Rudolph | 9bd6015 | 2018-05-04 09:01:38 +0200 | [diff] [blame] | 7 | #include <option.h> |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 8 | #include <pc80/keyboard.h> |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 9 | #include <superio/conf_mode.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 10 | #include <acpi/acpi.h> |
| 11 | #include <acpi/acpigen.h> |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 12 | #include <superio/common/ssdt.h> |
| 13 | #include <stdlib.h> |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 14 | |
| 15 | #include "npcd378.h" |
| 16 | |
Patrick Rudolph | 9bd6015 | 2018-05-04 09:01:38 +0200 | [diff] [blame] | 17 | uint8_t npcd378_hwm_read(const uint16_t iobase, const uint16_t reg) |
| 18 | { |
| 19 | outb((reg >> 8) & 0xf, iobase + 0xff); |
| 20 | uint8_t reg8 = inb(iobase + (reg & 0xff)); |
| 21 | if (reg8 == 0xff) |
| 22 | reg8 = inb(iobase + (reg & 0xff)); |
| 23 | |
| 24 | outb(0, iobase + 0xff); |
| 25 | return reg8; |
| 26 | } |
| 27 | |
Elyes HAOUAS | 7774de5 | 2020-03-30 16:46:18 +0200 | [diff] [blame] | 28 | void npcd378_hwm_write(const uint16_t iobase, const uint16_t reg, const uint8_t val) |
Patrick Rudolph | 9bd6015 | 2018-05-04 09:01:38 +0200 | [diff] [blame] | 29 | { |
| 30 | outb((reg >> 8) & 0xf, iobase + 0xff); |
| 31 | outb(val, iobase + (reg & 0xff)); |
| 32 | |
| 33 | outb(0, iobase + 0xff); |
| 34 | } |
| 35 | |
| 36 | void npcd378_hwm_write_start(const uint16_t iobase) |
| 37 | { |
| 38 | u8 reg8 = npcd378_hwm_read(iobase, NPCD837_HWM_WRITE_LOCK_CTRL); |
| 39 | reg8 &= ~NPCD837_HWM_WRITE_LOCK_BIT; |
| 40 | npcd378_hwm_write(iobase, NPCD837_HWM_WRITE_LOCK_CTRL, reg8); |
| 41 | } |
| 42 | |
| 43 | void npcd378_hwm_write_finished(const uint16_t iobase) |
| 44 | { |
| 45 | u8 reg8 = npcd378_hwm_read(iobase, NPCD837_HWM_WRITE_LOCK_CTRL); |
| 46 | reg8 |= NPCD837_HWM_WRITE_LOCK_BIT; |
| 47 | npcd378_hwm_write(iobase, NPCD837_HWM_WRITE_LOCK_CTRL, reg8); |
| 48 | } |
| 49 | |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 50 | static void npcd378_init(struct device *dev) |
| 51 | { |
Patrick Rudolph | 9bd6015 | 2018-05-04 09:01:38 +0200 | [diff] [blame] | 52 | struct resource *res; |
Patrick Rudolph | 9bd6015 | 2018-05-04 09:01:38 +0200 | [diff] [blame] | 53 | |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 54 | if (!dev->enabled) |
| 55 | return; |
| 56 | |
| 57 | switch (dev->path.pnp.device) { |
Patrick Rudolph | 9bd6015 | 2018-05-04 09:01:38 +0200 | [diff] [blame] | 58 | /* TODO: Might potentially need code for FDC etc. */ |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 59 | case NPCD378_KBC: |
| 60 | pc_keyboard_init(PROBE_AUX_DEVICE); |
| 61 | break; |
Patrick Rudolph | 9bd6015 | 2018-05-04 09:01:38 +0200 | [diff] [blame] | 62 | case NPCD378_HWM: |
Angel Pons | c167b74 | 2021-11-03 13:25:02 +0100 | [diff] [blame] | 63 | res = probe_resource(dev, PNP_IDX_IO0); |
Patrick Rudolph | 9bd6015 | 2018-05-04 09:01:38 +0200 | [diff] [blame] | 64 | if (!res || !res->base) { |
Elyes HAOUAS | 7774de5 | 2020-03-30 16:46:18 +0200 | [diff] [blame] | 65 | printk(BIOS_ERR, "NPCD378: LDN%u IOBASE not set.\n", NPCD378_HWM); |
Patrick Rudolph | 9bd6015 | 2018-05-04 09:01:38 +0200 | [diff] [blame] | 66 | break; |
| 67 | } |
| 68 | |
| 69 | npcd378_hwm_write_start(res->base); |
| 70 | |
Angel Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 71 | unsigned int fan_lvl = get_uint_option("psu_fan_lvl", 3); |
Angel Pons | a35f181 | 2021-04-26 16:49:40 +0200 | [diff] [blame] | 72 | if (fan_lvl > 7) |
Patrick Rudolph | 9bd6015 | 2018-05-04 09:01:38 +0200 | [diff] [blame] | 73 | fan_lvl = 3; |
| 74 | |
Angel Pons | 5a19f7e | 2021-04-19 15:04:22 +0200 | [diff] [blame] | 75 | uint8_t pwm = NPCD378_HWM_PSU_FAN_MIN + |
Patrick Rudolph | 9bd6015 | 2018-05-04 09:01:38 +0200 | [diff] [blame] | 76 | (NPCD378_HWM_PSU_FAN_MAX - NPCD378_HWM_PSU_FAN_MIN) * |
| 77 | fan_lvl / 7; |
| 78 | |
| 79 | /* Set PSU fan PWM lvl */ |
| 80 | npcd378_hwm_write(res->base, NPCD378_HWM_PSU_FAN_PWM_CTRL, pwm); |
| 81 | printk(BIOS_INFO, "NPCD378: PSU fan PWM 0x%02x\n", pwm); |
| 82 | |
| 83 | npcd378_hwm_write_finished(res->base); |
| 84 | break; |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 85 | } |
| 86 | } |
| 87 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 88 | #if CONFIG(HAVE_ACPI_TABLES) |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 89 | /* Provide ACPI HIDs for generic Super I/O SSDT */ |
| 90 | static const char *npcd378_acpi_hid(const struct device *dev) |
Patrick Rudolph | 9ae150a | 2018-07-17 11:41:10 +0200 | [diff] [blame] | 91 | { |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 92 | /* Sanity checks */ |
| 93 | if (dev->path.type != DEVICE_PATH_PNP) |
| 94 | return NULL; |
| 95 | if (dev->path.pnp.port == 0) |
| 96 | return NULL; |
| 97 | if ((dev->path.pnp.device & 0xff) > NPCD378_GPIOA) |
| 98 | return NULL; |
Patrick Rudolph | 9ae150a | 2018-07-17 11:41:10 +0200 | [diff] [blame] | 99 | |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 100 | switch (dev->path.pnp.device & 0xff) { |
| 101 | case NPCD378_FDC: |
| 102 | return ACPI_HID_FDC; |
| 103 | case NPCD378_PP: |
| 104 | return ACPI_HID_LPT; |
| 105 | case NPCD378_SP1: /* fallthrough */ |
| 106 | case NPCD378_SP2: |
| 107 | return ACPI_HID_COM; |
| 108 | case NPCD378_AUX: |
| 109 | return ACPI_HID_MOUSE; |
| 110 | case NPCD378_KBC: |
| 111 | return ACPI_HID_KEYBOARD; |
| 112 | default: |
| 113 | return ACPI_HID_PNP; |
Patrick Rudolph | 9ae150a | 2018-07-17 11:41:10 +0200 | [diff] [blame] | 114 | } |
| 115 | } |
| 116 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 117 | static void npcd378_ssdt_aux(const struct device *dev) |
Patrick Rudolph | 9ae150a | 2018-07-17 11:41:10 +0200 | [diff] [blame] | 118 | { |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 119 | /* Scope */ |
| 120 | acpigen_write_scope(acpi_device_path(dev)); |
| 121 | |
| 122 | acpigen_write_method("_PSW", 1); |
| 123 | acpigen_write_store(); |
| 124 | acpigen_emit_byte(ARG0_OP); |
| 125 | acpigen_emit_namestring("^^MSFG"); |
| 126 | acpigen_pop_len(); /* Pop Method */ |
| 127 | |
| 128 | acpigen_write_PRW(8, 3); |
| 129 | |
| 130 | acpigen_pop_len(); /* Pop Scope */ |
| 131 | } |
| 132 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 133 | static void npcd378_ssdt_kbc(const struct device *dev) |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 134 | { |
| 135 | /* Scope */ |
| 136 | acpigen_write_scope(acpi_device_path(dev)); |
| 137 | |
| 138 | acpigen_write_method("_PSW", 1); |
| 139 | acpigen_write_store(); |
| 140 | acpigen_emit_byte(ARG0_OP); |
| 141 | acpigen_emit_namestring("^^KBFG"); |
| 142 | acpigen_pop_len(); /* Pop Method */ |
| 143 | |
| 144 | acpigen_write_PRW(8, 3); |
| 145 | |
| 146 | acpigen_pop_len(); /* Pop Scope */ |
| 147 | } |
| 148 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 149 | static void npcd378_ssdt_pwr(const struct device *dev) |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 150 | { |
| 151 | const char *name = acpi_device_path(dev); |
| 152 | const char *scope = acpi_device_scope(dev); |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 153 | |
| 154 | /* Scope */ |
| 155 | acpigen_write_scope(name); |
| 156 | |
| 157 | acpigen_emit_ext_op(OPREGION_OP); |
| 158 | acpigen_emit_namestring("SWCR"); |
| 159 | acpigen_emit_byte(SYSTEMIO); |
| 160 | acpigen_emit_namestring("IO0B"); |
| 161 | acpigen_emit_namestring("IO0S"); |
| 162 | |
| 163 | struct fieldlist l1[] = { |
| 164 | FIELDLIST_OFFSET(0), |
| 165 | FIELDLIST_NAMESTR("LEDC", 8), |
| 166 | FIELDLIST_NAMESTR("SWCC", 8), |
| 167 | }; |
| 168 | |
| 169 | acpigen_write_field("SWCR", l1, ARRAY_SIZE(l1), FIELD_BYTEACC | |
| 170 | FIELD_NOLOCK | FIELD_PRESERVE); |
| 171 | |
| 172 | acpigen_emit_ext_op(OPREGION_OP); |
| 173 | acpigen_emit_namestring("RNTR"); |
| 174 | acpigen_emit_byte(SYSTEMIO); |
| 175 | acpigen_emit_namestring("IO1B"); |
| 176 | acpigen_emit_namestring("IO1S"); |
| 177 | |
| 178 | struct fieldlist l2[] = { |
| 179 | FIELDLIST_OFFSET(0), |
| 180 | FIELDLIST_NAMESTR("GPES", 8), |
| 181 | FIELDLIST_NAMESTR("GPEE", 8), |
| 182 | FIELDLIST_OFFSET(8), |
| 183 | FIELDLIST_NAMESTR("GPS0", 8), |
| 184 | FIELDLIST_NAMESTR("GPS1", 8), |
| 185 | FIELDLIST_NAMESTR("GPS2", 8), |
| 186 | FIELDLIST_NAMESTR("GPS3", 8), |
| 187 | FIELDLIST_NAMESTR("GPE0", 8), |
| 188 | FIELDLIST_NAMESTR("GPE1", 8), |
| 189 | FIELDLIST_NAMESTR("GPE2", 8), |
| 190 | FIELDLIST_NAMESTR("GPE3", 8), |
| 191 | }; |
| 192 | |
| 193 | acpigen_write_field("RNTR", l2, ARRAY_SIZE(l2), FIELD_BYTEACC | |
| 194 | FIELD_NOLOCK | FIELD_PRESERVE); |
| 195 | |
| 196 | /* Method (SIOW, 1, NotSerialized) */ |
| 197 | acpigen_write_method("SIOW", 1); |
| 198 | acpigen_write_store(); |
| 199 | acpigen_emit_namestring("^GPS2"); |
| 200 | acpigen_emit_namestring("^^PMFG"); |
| 201 | |
| 202 | acpigen_write_store(); |
| 203 | acpigen_emit_byte(ZERO_OP); |
| 204 | acpigen_emit_namestring("^GPEE"); |
| 205 | |
| 206 | acpigen_write_store(); |
| 207 | acpigen_emit_byte(ZERO_OP); |
| 208 | acpigen_emit_namestring("^GPE0"); |
| 209 | |
| 210 | acpigen_write_store(); |
| 211 | acpigen_emit_byte(ZERO_OP); |
| 212 | acpigen_emit_namestring("^GPE1"); |
| 213 | |
| 214 | acpigen_emit_byte(AND_OP); |
| 215 | acpigen_emit_namestring("^LEDC"); |
| 216 | acpigen_write_integer(0xE0); |
| 217 | acpigen_emit_byte(LOCAL0_OP); |
| 218 | |
| 219 | acpigen_emit_byte(OR_OP); |
| 220 | acpigen_emit_byte(LOCAL0_OP); |
| 221 | acpigen_write_integer(0x1E); |
| 222 | acpigen_emit_namestring("^LEDC"); |
| 223 | |
| 224 | acpigen_emit_byte(AND_OP); |
| 225 | acpigen_emit_namestring("^SWCC"); |
| 226 | acpigen_write_integer(0xBF); |
| 227 | acpigen_emit_namestring("^SWCC"); |
| 228 | |
| 229 | acpigen_pop_len(); /* SIOW method */ |
| 230 | |
| 231 | /* Method (SIOS, 1, NotSerialized) */ |
| 232 | acpigen_write_method("SIOS", 1); |
| 233 | |
| 234 | acpigen_write_if(); |
| 235 | acpigen_emit_byte(LNOT_OP); |
| 236 | acpigen_emit_byte(LEQUAL_OP); |
| 237 | acpigen_emit_byte(ARG0_OP); |
| 238 | acpigen_write_integer(5); |
| 239 | |
| 240 | acpigen_write_if(); |
| 241 | acpigen_emit_byte(LEQUAL_OP); |
| 242 | acpigen_emit_namestring("^^KBFG"); |
| 243 | acpigen_emit_byte(ONE_OP); |
| 244 | |
| 245 | acpigen_emit_byte(OR_OP); |
| 246 | acpigen_emit_namestring("^GPE2"); |
| 247 | acpigen_write_integer(0xE8); |
| 248 | acpigen_emit_namestring("^GPE2"); |
| 249 | |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 250 | acpigen_write_else(); |
| 251 | |
| 252 | acpigen_emit_byte(AND_OP); |
| 253 | acpigen_emit_namestring("^GPE2"); |
| 254 | acpigen_write_integer(0x17); |
| 255 | acpigen_emit_namestring("^GPE2"); |
| 256 | |
| 257 | acpigen_pop_len(); /* Pop Else */ |
| 258 | |
| 259 | acpigen_write_if(); |
| 260 | acpigen_emit_byte(LEQUAL_OP); |
| 261 | acpigen_emit_namestring("^^MSFG"); |
| 262 | acpigen_emit_byte(ONE_OP); |
| 263 | |
| 264 | acpigen_emit_byte(OR_OP); |
| 265 | acpigen_emit_namestring("^GPE2"); |
| 266 | acpigen_write_integer(0x10); |
| 267 | acpigen_emit_namestring("^GPE2"); |
| 268 | |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 269 | acpigen_write_else(); |
| 270 | |
| 271 | acpigen_emit_byte(AND_OP); |
| 272 | acpigen_emit_namestring("^GPE2"); |
| 273 | acpigen_write_integer(0xEF); |
| 274 | acpigen_emit_namestring("^GPE2"); |
| 275 | |
| 276 | acpigen_pop_len(); /* Pop Else */ |
| 277 | |
| 278 | /* Enable wake on GPE */ |
| 279 | acpigen_write_store(); |
| 280 | acpigen_emit_byte(ONE_OP); |
| 281 | acpigen_emit_namestring("^GPEE"); |
| 282 | |
| 283 | acpigen_write_if(); |
| 284 | acpigen_emit_byte(LEQUAL_OP); |
| 285 | acpigen_emit_byte(ARG0_OP); |
| 286 | acpigen_write_integer(3); |
| 287 | |
| 288 | acpigen_emit_byte(AND_OP); |
| 289 | acpigen_emit_namestring("^LEDC"); |
| 290 | acpigen_write_integer(0xE0); |
| 291 | acpigen_emit_byte(LOCAL0_OP); |
| 292 | |
| 293 | acpigen_emit_byte(OR_OP); |
| 294 | acpigen_emit_byte(LOCAL0_OP); |
| 295 | acpigen_write_integer(0x1C); |
| 296 | acpigen_emit_namestring("^LEDC"); |
| 297 | |
| 298 | acpigen_emit_byte(AND_OP); |
| 299 | acpigen_emit_namestring("^SWCC"); |
| 300 | acpigen_write_integer(0xBF); |
| 301 | acpigen_emit_byte(LOCAL0_OP); |
| 302 | |
| 303 | acpigen_emit_byte(OR_OP); |
| 304 | acpigen_emit_byte(LOCAL0_OP); |
| 305 | acpigen_write_integer(0x40); |
| 306 | acpigen_emit_namestring("^SWCC"); |
| 307 | |
| 308 | acpigen_pop_len(); /* Pop If */ |
| 309 | |
| 310 | acpigen_pop_len(); /* Pop If */ |
| 311 | |
| 312 | acpigen_write_store(); |
| 313 | acpigen_write_integer(0x10); |
| 314 | acpigen_emit_namestring("^GPE0"); |
| 315 | |
| 316 | acpigen_write_store(); |
| 317 | acpigen_write_integer(0x20); |
| 318 | acpigen_emit_namestring("^GPE1"); |
| 319 | |
| 320 | acpigen_pop_len(); /* Pop SIOS method */ |
| 321 | |
| 322 | acpigen_pop_len(); /* Pop Scope */ |
| 323 | |
| 324 | /* Inject into parent: */ |
John Zhao | 8f5fbb0 | 2020-06-26 10:38:42 -0700 | [diff] [blame] | 325 | if (!scope) { |
| 326 | printk(BIOS_ERR, "%s: Missing ACPI path/scope\n", dev_path(dev)); |
| 327 | return; |
| 328 | } |
| 329 | acpigen_write_scope(scope); |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 330 | |
| 331 | acpigen_write_name_integer("MSFG", 1); |
| 332 | acpigen_write_name_integer("KBFG", 1); |
| 333 | acpigen_write_name_integer("PMFG", 0); |
| 334 | |
| 335 | /* DSDT must call SIOW on _WAK */ |
| 336 | /* Method (SIOW, 1, NotSerialized) */ |
| 337 | acpigen_write_method("SIOW", 1); |
| 338 | acpigen_emit_byte(RETURN_OP); |
Arthur Heymans | 0a0945c | 2023-11-07 11:01:34 +0100 | [diff] [blame] | 339 | acpigen_emit_namestring(acpi_device_path_join(dev, "SIOW")); |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 340 | |
| 341 | acpigen_emit_byte(ARG0_OP); |
| 342 | acpigen_pop_len(); |
| 343 | |
| 344 | /* DSDT must call SIOS on _PTS */ |
| 345 | /* Method (SIOS, 1, NotSerialized) */ |
| 346 | acpigen_write_method("SIOS", 1); |
| 347 | acpigen_emit_byte(RETURN_OP); |
Arthur Heymans | 0a0945c | 2023-11-07 11:01:34 +0100 | [diff] [blame] | 348 | acpigen_emit_namestring(acpi_device_path_join(dev, "SIOS")); |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 349 | acpigen_emit_byte(ARG0_OP); |
| 350 | acpigen_pop_len(); /* Pop Method */ |
| 351 | |
| 352 | acpigen_pop_len(); /* Scope */ |
| 353 | |
| 354 | acpigen_write_scope("\\_GPE"); |
| 355 | |
| 356 | /* Method (SIOH, 0, NotSerialized) */ |
| 357 | acpigen_write_method("_L08", 0); |
| 358 | acpigen_emit_byte(AND_OP); |
Riku Viitanen | 5eb95ee3 | 2023-12-15 22:46:20 +0200 | [diff] [blame^] | 359 | acpigen_emit_namestring(acpi_device_path_join(dev->bus->dev, "PMFG")); |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 360 | acpigen_write_integer(0xE8); |
| 361 | acpigen_emit_byte(LOCAL0_OP); |
| 362 | |
| 363 | acpigen_write_if(); |
| 364 | acpigen_emit_byte(LGREATER_OP); |
| 365 | acpigen_emit_byte(LOCAL0_OP); |
| 366 | acpigen_emit_byte(ZERO_OP); |
| 367 | |
| 368 | acpigen_emit_byte(NOTIFY_OP); |
Riku Viitanen | 5eb95ee3 | 2023-12-15 22:46:20 +0200 | [diff] [blame^] | 369 | acpigen_emit_namestring(acpi_device_path_join(dev->bus->dev, "L060")); |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 370 | acpigen_write_integer(2); |
| 371 | |
| 372 | acpigen_pop_len(); /* Pop If */ |
| 373 | |
| 374 | acpigen_emit_byte(AND_OP); |
Riku Viitanen | 5eb95ee3 | 2023-12-15 22:46:20 +0200 | [diff] [blame^] | 375 | acpigen_emit_namestring(acpi_device_path_join(dev->bus->dev, "PMFG")); |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 376 | acpigen_write_integer(0x10); |
| 377 | acpigen_emit_byte(LOCAL0_OP); |
| 378 | |
| 379 | acpigen_write_if(); |
| 380 | acpigen_emit_byte(LGREATER_OP); |
| 381 | acpigen_emit_byte(LOCAL0_OP); |
| 382 | acpigen_emit_byte(ZERO_OP); |
| 383 | |
| 384 | acpigen_emit_byte(NOTIFY_OP); |
Riku Viitanen | 5eb95ee3 | 2023-12-15 22:46:20 +0200 | [diff] [blame^] | 385 | acpigen_emit_namestring(acpi_device_path_join(dev->bus->dev, "L050")); |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 386 | acpigen_write_integer(2); |
| 387 | acpigen_pop_len(); /* Pop If */ |
| 388 | |
| 389 | acpigen_pop_len(); /* Pop Method */ |
| 390 | |
| 391 | acpigen_pop_len(); /* Scope */ |
| 392 | } |
| 393 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 394 | static void npcd378_fill_ssdt_generator(const struct device *dev) |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 395 | { |
John Zhao | 8f5fbb0 | 2020-06-26 10:38:42 -0700 | [diff] [blame] | 396 | if (!dev) |
| 397 | return; |
| 398 | |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 399 | superio_common_fill_ssdt_generator(dev); |
| 400 | |
| 401 | switch (dev->path.pnp.device) { |
| 402 | case NPCD378_PWR: |
| 403 | npcd378_ssdt_pwr(dev); |
| 404 | break; |
| 405 | case NPCD378_AUX: |
| 406 | npcd378_ssdt_aux(dev); |
| 407 | break; |
| 408 | case NPCD378_KBC: |
| 409 | npcd378_ssdt_kbc(dev); |
| 410 | break; |
| 411 | } |
Patrick Rudolph | 9ae150a | 2018-07-17 11:41:10 +0200 | [diff] [blame] | 412 | } |
| 413 | #endif |
| 414 | |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 415 | static struct device_operations ops = { |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 416 | .read_resources = pnp_read_resources, |
| 417 | .set_resources = pnp_set_resources, |
| 418 | .enable_resources = pnp_enable_resources, |
| 419 | .enable = pnp_alt_enable, |
| 420 | .init = npcd378_init, |
| 421 | .ops_pnp_mode = &pnp_conf_mode_8787_aa, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 422 | #if CONFIG(HAVE_ACPI_TABLES) |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 423 | .acpi_fill_ssdt = npcd378_fill_ssdt_generator, |
| 424 | .acpi_name = superio_common_ldn_acpi_name, |
| 425 | .acpi_hid = npcd378_acpi_hid, |
Patrick Rudolph | 9ae150a | 2018-07-17 11:41:10 +0200 | [diff] [blame] | 426 | #endif |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 427 | }; |
| 428 | |
| 429 | static struct pnp_info pnp_dev_info[] = { |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 430 | { NULL, NPCD378_FDC, PNP_IO0|PNP_IRQ0|PNP_DRQ0, 0x0ff8, }, |
| 431 | { NULL, NPCD378_PP, PNP_IO0|PNP_IRQ0|PNP_DRQ0, 0x0ff8, }, |
| 432 | { NULL, NPCD378_SP1, PNP_IO0|PNP_IRQ0, 0x0ff8, }, |
| 433 | { NULL, NPCD378_SP2, PNP_IO0|PNP_IRQ0, 0x0ff8, }, |
| 434 | { NULL, NPCD378_PWR, PNP_IO0|PNP_IO1|PNP_IRQ0|PNP_MSC0| |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 435 | PNP_MSC1|PNP_MSC2|PNP_MSC3|PNP_MSC4|PNP_MSC5|PNP_MSC6|PNP_MSC7| |
| 436 | PNP_MSC8|PNP_MSC9|PNP_MSCA|PNP_MSCB|PNP_MSCC|PNP_MSCD|PNP_MSCE, |
Patrick Rudolph | 61c3b59 | 2018-07-17 11:36:15 +0200 | [diff] [blame] | 437 | 0x0ff8, 0x0ff0}, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 438 | { NULL, NPCD378_AUX, PNP_IRQ0, 0x0fff, 0x0fff, }, |
| 439 | { NULL, NPCD378_KBC, PNP_IO0|PNP_IO1|PNP_IRQ0, |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 440 | 0x0fff, 0x0fff, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 441 | { NULL, NPCD378_WDT1, PNP_IO0|PNP_MSC8|PNP_MSC9| |
Patrick Rudolph | 61c3b59 | 2018-07-17 11:36:15 +0200 | [diff] [blame] | 442 | PNP_MSCA|PNP_MSCB|PNP_MSCC|PNP_MSCD|PNP_MSCE, 0x0fe0}, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 443 | { NULL, NPCD378_HWM, PNP_IO0|PNP_MSC0|PNP_MSC1|PNP_MSC2|PNP_MSC3| |
Patrick Rudolph | 61c3b59 | 2018-07-17 11:36:15 +0200 | [diff] [blame] | 444 | PNP_MSC4|PNP_MSC5|PNP_MSC6|PNP_MSC7|PNP_IRQ0, 0x0f00}, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 445 | { NULL, NPCD378_GPIO_PP_OD, PNP_MSC0|PNP_MSC1|PNP_MSC2|PNP_MSC3| |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 446 | PNP_MSC4|PNP_MSC5|PNP_MSC6|PNP_MSC7|PNP_MSC8|PNP_MSC9|PNP_MSCA| |
| 447 | PNP_MSCB|PNP_MSCC|PNP_MSCD|PNP_MSCE}, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 448 | { NULL, NPCD378_I2C, PNP_IO0|PNP_IO1|PNP_IRQ0|PNP_MSC0| |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 449 | PNP_MSC1|PNP_MSC2|PNP_MSC3|PNP_MSC4|PNP_MSC5|PNP_MSC6|PNP_MSC7| |
| 450 | PNP_MSC8|PNP_MSC9|PNP_MSCA|PNP_MSCB|PNP_MSCC|PNP_MSCD|PNP_MSCE, |
Patrick Rudolph | 61c3b59 | 2018-07-17 11:36:15 +0200 | [diff] [blame] | 451 | 0x0ff0, 0x0ff0}, |
| 452 | { NULL, NPCD378_SUSPEND, PNP_IO0, 0x0fe0 }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 453 | { NULL, NPCD378_GPIOA, PNP_IO0|PNP_MSC0|PNP_MSC1|PNP_MSC2|PNP_MSC3| |
Patrick Rudolph | 61c3b59 | 2018-07-17 11:36:15 +0200 | [diff] [blame] | 454 | PNP_MSC4, 0x0fe0}, |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 455 | }; |
| 456 | |
| 457 | static void enable_dev(struct device *dev) |
| 458 | { |
| 459 | pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
| 460 | } |
| 461 | |
| 462 | struct chip_operations superio_nuvoton_npcd378_ops = { |
| 463 | CHIP_NAME("NUVOTON NPCD378 Super I/O") |
| 464 | .enable_dev = enable_dev, |
| 465 | }; |