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: |
| 63 | res = find_resource(dev, PNP_IDX_IO0); |
| 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); |
| 153 | char *tmp_name; |
| 154 | |
| 155 | /* Scope */ |
| 156 | acpigen_write_scope(name); |
| 157 | |
| 158 | acpigen_emit_ext_op(OPREGION_OP); |
| 159 | acpigen_emit_namestring("SWCR"); |
| 160 | acpigen_emit_byte(SYSTEMIO); |
| 161 | acpigen_emit_namestring("IO0B"); |
| 162 | acpigen_emit_namestring("IO0S"); |
| 163 | |
| 164 | struct fieldlist l1[] = { |
| 165 | FIELDLIST_OFFSET(0), |
| 166 | FIELDLIST_NAMESTR("LEDC", 8), |
| 167 | FIELDLIST_NAMESTR("SWCC", 8), |
| 168 | }; |
| 169 | |
| 170 | acpigen_write_field("SWCR", l1, ARRAY_SIZE(l1), FIELD_BYTEACC | |
| 171 | FIELD_NOLOCK | FIELD_PRESERVE); |
| 172 | |
| 173 | acpigen_emit_ext_op(OPREGION_OP); |
| 174 | acpigen_emit_namestring("RNTR"); |
| 175 | acpigen_emit_byte(SYSTEMIO); |
| 176 | acpigen_emit_namestring("IO1B"); |
| 177 | acpigen_emit_namestring("IO1S"); |
| 178 | |
| 179 | struct fieldlist l2[] = { |
| 180 | FIELDLIST_OFFSET(0), |
| 181 | FIELDLIST_NAMESTR("GPES", 8), |
| 182 | FIELDLIST_NAMESTR("GPEE", 8), |
| 183 | FIELDLIST_OFFSET(8), |
| 184 | FIELDLIST_NAMESTR("GPS0", 8), |
| 185 | FIELDLIST_NAMESTR("GPS1", 8), |
| 186 | FIELDLIST_NAMESTR("GPS2", 8), |
| 187 | FIELDLIST_NAMESTR("GPS3", 8), |
| 188 | FIELDLIST_NAMESTR("GPE0", 8), |
| 189 | FIELDLIST_NAMESTR("GPE1", 8), |
| 190 | FIELDLIST_NAMESTR("GPE2", 8), |
| 191 | FIELDLIST_NAMESTR("GPE3", 8), |
| 192 | }; |
| 193 | |
| 194 | acpigen_write_field("RNTR", l2, ARRAY_SIZE(l2), FIELD_BYTEACC | |
| 195 | FIELD_NOLOCK | FIELD_PRESERVE); |
| 196 | |
| 197 | /* Method (SIOW, 1, NotSerialized) */ |
| 198 | acpigen_write_method("SIOW", 1); |
| 199 | acpigen_write_store(); |
| 200 | acpigen_emit_namestring("^GPS2"); |
| 201 | acpigen_emit_namestring("^^PMFG"); |
| 202 | |
| 203 | acpigen_write_store(); |
| 204 | acpigen_emit_byte(ZERO_OP); |
| 205 | acpigen_emit_namestring("^GPEE"); |
| 206 | |
| 207 | acpigen_write_store(); |
| 208 | acpigen_emit_byte(ZERO_OP); |
| 209 | acpigen_emit_namestring("^GPE0"); |
| 210 | |
| 211 | acpigen_write_store(); |
| 212 | acpigen_emit_byte(ZERO_OP); |
| 213 | acpigen_emit_namestring("^GPE1"); |
| 214 | |
| 215 | acpigen_emit_byte(AND_OP); |
| 216 | acpigen_emit_namestring("^LEDC"); |
| 217 | acpigen_write_integer(0xE0); |
| 218 | acpigen_emit_byte(LOCAL0_OP); |
| 219 | |
| 220 | acpigen_emit_byte(OR_OP); |
| 221 | acpigen_emit_byte(LOCAL0_OP); |
| 222 | acpigen_write_integer(0x1E); |
| 223 | acpigen_emit_namestring("^LEDC"); |
| 224 | |
| 225 | acpigen_emit_byte(AND_OP); |
| 226 | acpigen_emit_namestring("^SWCC"); |
| 227 | acpigen_write_integer(0xBF); |
| 228 | acpigen_emit_namestring("^SWCC"); |
| 229 | |
| 230 | acpigen_pop_len(); /* SIOW method */ |
| 231 | |
| 232 | /* Method (SIOS, 1, NotSerialized) */ |
| 233 | acpigen_write_method("SIOS", 1); |
| 234 | |
| 235 | acpigen_write_if(); |
| 236 | acpigen_emit_byte(LNOT_OP); |
| 237 | acpigen_emit_byte(LEQUAL_OP); |
| 238 | acpigen_emit_byte(ARG0_OP); |
| 239 | acpigen_write_integer(5); |
| 240 | |
| 241 | acpigen_write_if(); |
| 242 | acpigen_emit_byte(LEQUAL_OP); |
| 243 | acpigen_emit_namestring("^^KBFG"); |
| 244 | acpigen_emit_byte(ONE_OP); |
| 245 | |
| 246 | acpigen_emit_byte(OR_OP); |
| 247 | acpigen_emit_namestring("^GPE2"); |
| 248 | acpigen_write_integer(0xE8); |
| 249 | acpigen_emit_namestring("^GPE2"); |
| 250 | |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 251 | acpigen_write_else(); |
| 252 | |
| 253 | acpigen_emit_byte(AND_OP); |
| 254 | acpigen_emit_namestring("^GPE2"); |
| 255 | acpigen_write_integer(0x17); |
| 256 | acpigen_emit_namestring("^GPE2"); |
| 257 | |
| 258 | acpigen_pop_len(); /* Pop Else */ |
| 259 | |
| 260 | acpigen_write_if(); |
| 261 | acpigen_emit_byte(LEQUAL_OP); |
| 262 | acpigen_emit_namestring("^^MSFG"); |
| 263 | acpigen_emit_byte(ONE_OP); |
| 264 | |
| 265 | acpigen_emit_byte(OR_OP); |
| 266 | acpigen_emit_namestring("^GPE2"); |
| 267 | acpigen_write_integer(0x10); |
| 268 | acpigen_emit_namestring("^GPE2"); |
| 269 | |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 270 | acpigen_write_else(); |
| 271 | |
| 272 | acpigen_emit_byte(AND_OP); |
| 273 | acpigen_emit_namestring("^GPE2"); |
| 274 | acpigen_write_integer(0xEF); |
| 275 | acpigen_emit_namestring("^GPE2"); |
| 276 | |
| 277 | acpigen_pop_len(); /* Pop Else */ |
| 278 | |
| 279 | /* Enable wake on GPE */ |
| 280 | acpigen_write_store(); |
| 281 | acpigen_emit_byte(ONE_OP); |
| 282 | acpigen_emit_namestring("^GPEE"); |
| 283 | |
| 284 | acpigen_write_if(); |
| 285 | acpigen_emit_byte(LEQUAL_OP); |
| 286 | acpigen_emit_byte(ARG0_OP); |
| 287 | acpigen_write_integer(3); |
| 288 | |
| 289 | acpigen_emit_byte(AND_OP); |
| 290 | acpigen_emit_namestring("^LEDC"); |
| 291 | acpigen_write_integer(0xE0); |
| 292 | acpigen_emit_byte(LOCAL0_OP); |
| 293 | |
| 294 | acpigen_emit_byte(OR_OP); |
| 295 | acpigen_emit_byte(LOCAL0_OP); |
| 296 | acpigen_write_integer(0x1C); |
| 297 | acpigen_emit_namestring("^LEDC"); |
| 298 | |
| 299 | acpigen_emit_byte(AND_OP); |
| 300 | acpigen_emit_namestring("^SWCC"); |
| 301 | acpigen_write_integer(0xBF); |
| 302 | acpigen_emit_byte(LOCAL0_OP); |
| 303 | |
| 304 | acpigen_emit_byte(OR_OP); |
| 305 | acpigen_emit_byte(LOCAL0_OP); |
| 306 | acpigen_write_integer(0x40); |
| 307 | acpigen_emit_namestring("^SWCC"); |
| 308 | |
| 309 | acpigen_pop_len(); /* Pop If */ |
| 310 | |
| 311 | acpigen_pop_len(); /* Pop If */ |
| 312 | |
| 313 | acpigen_write_store(); |
| 314 | acpigen_write_integer(0x10); |
| 315 | acpigen_emit_namestring("^GPE0"); |
| 316 | |
| 317 | acpigen_write_store(); |
| 318 | acpigen_write_integer(0x20); |
| 319 | acpigen_emit_namestring("^GPE1"); |
| 320 | |
| 321 | acpigen_pop_len(); /* Pop SIOS method */ |
| 322 | |
| 323 | acpigen_pop_len(); /* Pop Scope */ |
| 324 | |
| 325 | /* Inject into parent: */ |
John Zhao | 8f5fbb0 | 2020-06-26 10:38:42 -0700 | [diff] [blame] | 326 | if (!scope) { |
| 327 | printk(BIOS_ERR, "%s: Missing ACPI path/scope\n", dev_path(dev)); |
| 328 | return; |
| 329 | } |
| 330 | acpigen_write_scope(scope); |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 331 | |
| 332 | acpigen_write_name_integer("MSFG", 1); |
| 333 | acpigen_write_name_integer("KBFG", 1); |
| 334 | acpigen_write_name_integer("PMFG", 0); |
| 335 | |
| 336 | /* DSDT must call SIOW on _WAK */ |
| 337 | /* Method (SIOW, 1, NotSerialized) */ |
| 338 | acpigen_write_method("SIOW", 1); |
| 339 | acpigen_emit_byte(RETURN_OP); |
| 340 | tmp_name = strconcat(name, ".SIOW"); |
| 341 | acpigen_emit_namestring(tmp_name); |
| 342 | free(tmp_name); |
| 343 | |
| 344 | acpigen_emit_byte(ARG0_OP); |
| 345 | acpigen_pop_len(); |
| 346 | |
| 347 | /* DSDT must call SIOS on _PTS */ |
| 348 | /* Method (SIOS, 1, NotSerialized) */ |
| 349 | acpigen_write_method("SIOS", 1); |
| 350 | acpigen_emit_byte(RETURN_OP); |
| 351 | tmp_name = strconcat(name, ".SIOS"); |
| 352 | acpigen_emit_namestring(tmp_name); |
| 353 | free(tmp_name); |
| 354 | acpigen_emit_byte(ARG0_OP); |
| 355 | acpigen_pop_len(); /* Pop Method */ |
| 356 | |
| 357 | acpigen_pop_len(); /* Scope */ |
| 358 | |
| 359 | acpigen_write_scope("\\_GPE"); |
| 360 | |
| 361 | /* Method (SIOH, 0, NotSerialized) */ |
| 362 | acpigen_write_method("_L08", 0); |
| 363 | acpigen_emit_byte(AND_OP); |
| 364 | tmp_name = strconcat(scope, ".PMFG"); |
| 365 | acpigen_emit_namestring(tmp_name); |
| 366 | free(tmp_name); |
| 367 | acpigen_write_integer(0xE8); |
| 368 | acpigen_emit_byte(LOCAL0_OP); |
| 369 | |
| 370 | acpigen_write_if(); |
| 371 | acpigen_emit_byte(LGREATER_OP); |
| 372 | acpigen_emit_byte(LOCAL0_OP); |
| 373 | acpigen_emit_byte(ZERO_OP); |
| 374 | |
| 375 | acpigen_emit_byte(NOTIFY_OP); |
| 376 | tmp_name = strconcat(scope, ".L060"); |
| 377 | acpigen_emit_namestring(tmp_name); |
| 378 | free(tmp_name); |
| 379 | acpigen_write_integer(2); |
| 380 | |
| 381 | acpigen_pop_len(); /* Pop If */ |
| 382 | |
| 383 | acpigen_emit_byte(AND_OP); |
| 384 | tmp_name = strconcat(scope, ".PMFG"); |
| 385 | acpigen_emit_namestring(tmp_name); |
| 386 | free(tmp_name); |
| 387 | acpigen_write_integer(0x10); |
| 388 | acpigen_emit_byte(LOCAL0_OP); |
| 389 | |
| 390 | acpigen_write_if(); |
| 391 | acpigen_emit_byte(LGREATER_OP); |
| 392 | acpigen_emit_byte(LOCAL0_OP); |
| 393 | acpigen_emit_byte(ZERO_OP); |
| 394 | |
| 395 | acpigen_emit_byte(NOTIFY_OP); |
| 396 | tmp_name = strconcat(scope, ".L050"); |
| 397 | acpigen_emit_namestring(tmp_name); |
| 398 | free(tmp_name); |
| 399 | acpigen_write_integer(2); |
| 400 | acpigen_pop_len(); /* Pop If */ |
| 401 | |
| 402 | acpigen_pop_len(); /* Pop Method */ |
| 403 | |
| 404 | acpigen_pop_len(); /* Scope */ |
| 405 | } |
| 406 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 407 | static void npcd378_fill_ssdt_generator(const struct device *dev) |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 408 | { |
John Zhao | 8f5fbb0 | 2020-06-26 10:38:42 -0700 | [diff] [blame] | 409 | if (!dev) |
| 410 | return; |
| 411 | |
Patrick Rudolph | e1498ce | 2020-02-12 15:23:05 +0100 | [diff] [blame] | 412 | superio_common_fill_ssdt_generator(dev); |
| 413 | |
| 414 | switch (dev->path.pnp.device) { |
| 415 | case NPCD378_PWR: |
| 416 | npcd378_ssdt_pwr(dev); |
| 417 | break; |
| 418 | case NPCD378_AUX: |
| 419 | npcd378_ssdt_aux(dev); |
| 420 | break; |
| 421 | case NPCD378_KBC: |
| 422 | npcd378_ssdt_kbc(dev); |
| 423 | break; |
| 424 | } |
Patrick Rudolph | 9ae150a | 2018-07-17 11:41:10 +0200 | [diff] [blame] | 425 | } |
| 426 | #endif |
| 427 | |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 428 | static struct device_operations ops = { |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 429 | .read_resources = pnp_read_resources, |
| 430 | .set_resources = pnp_set_resources, |
| 431 | .enable_resources = pnp_enable_resources, |
| 432 | .enable = pnp_alt_enable, |
| 433 | .init = npcd378_init, |
| 434 | .ops_pnp_mode = &pnp_conf_mode_8787_aa, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 435 | #if CONFIG(HAVE_ACPI_TABLES) |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 436 | .acpi_fill_ssdt = npcd378_fill_ssdt_generator, |
| 437 | .acpi_name = superio_common_ldn_acpi_name, |
| 438 | .acpi_hid = npcd378_acpi_hid, |
Patrick Rudolph | 9ae150a | 2018-07-17 11:41:10 +0200 | [diff] [blame] | 439 | #endif |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 440 | }; |
| 441 | |
| 442 | static struct pnp_info pnp_dev_info[] = { |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 443 | { NULL, NPCD378_FDC, PNP_IO0|PNP_IRQ0|PNP_DRQ0, 0x0ff8, }, |
| 444 | { NULL, NPCD378_PP, PNP_IO0|PNP_IRQ0|PNP_DRQ0, 0x0ff8, }, |
| 445 | { NULL, NPCD378_SP1, PNP_IO0|PNP_IRQ0, 0x0ff8, }, |
| 446 | { NULL, NPCD378_SP2, PNP_IO0|PNP_IRQ0, 0x0ff8, }, |
| 447 | { NULL, NPCD378_PWR, PNP_IO0|PNP_IO1|PNP_IRQ0|PNP_MSC0| |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 448 | PNP_MSC1|PNP_MSC2|PNP_MSC3|PNP_MSC4|PNP_MSC5|PNP_MSC6|PNP_MSC7| |
| 449 | 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] | 450 | 0x0ff8, 0x0ff0}, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 451 | { NULL, NPCD378_AUX, PNP_IRQ0, 0x0fff, 0x0fff, }, |
| 452 | { NULL, NPCD378_KBC, PNP_IO0|PNP_IO1|PNP_IRQ0, |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 453 | 0x0fff, 0x0fff, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 454 | { NULL, NPCD378_WDT1, PNP_IO0|PNP_MSC8|PNP_MSC9| |
Patrick Rudolph | 61c3b59 | 2018-07-17 11:36:15 +0200 | [diff] [blame] | 455 | PNP_MSCA|PNP_MSCB|PNP_MSCC|PNP_MSCD|PNP_MSCE, 0x0fe0}, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 456 | { 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] | 457 | PNP_MSC4|PNP_MSC5|PNP_MSC6|PNP_MSC7|PNP_IRQ0, 0x0f00}, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 458 | { 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] | 459 | PNP_MSC4|PNP_MSC5|PNP_MSC6|PNP_MSC7|PNP_MSC8|PNP_MSC9|PNP_MSCA| |
| 460 | PNP_MSCB|PNP_MSCC|PNP_MSCD|PNP_MSCE}, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 461 | { NULL, NPCD378_I2C, PNP_IO0|PNP_IO1|PNP_IRQ0|PNP_MSC0| |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 462 | PNP_MSC1|PNP_MSC2|PNP_MSC3|PNP_MSC4|PNP_MSC5|PNP_MSC6|PNP_MSC7| |
| 463 | 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] | 464 | 0x0ff0, 0x0ff0}, |
| 465 | { NULL, NPCD378_SUSPEND, PNP_IO0, 0x0fe0 }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 466 | { 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] | 467 | PNP_MSC4, 0x0fe0}, |
Patrick Rudolph | 4576600 | 2018-03-27 15:58:38 +0200 | [diff] [blame] | 468 | }; |
| 469 | |
| 470 | static void enable_dev(struct device *dev) |
| 471 | { |
| 472 | pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
| 473 | } |
| 474 | |
| 475 | struct chip_operations superio_nuvoton_npcd378_ops = { |
| 476 | CHIP_NAME("NUVOTON NPCD378 Super I/O") |
| 477 | .enable_dev = enable_dev, |
| 478 | }; |