Lines Matching defs:smc
76 apple_smc_attach(struct apple_smc_tag *smc)
79 mutex_init(&smc->smc_io_lock, MUTEX_DEFAULT, IPL_NONE);
81 apple_smc_sysctl_setup(smc);
85 (void)apple_smc_rescan(smc, NULL, NULL);
89 apple_smc_detach(struct apple_smc_tag *smc, int flags)
94 error = config_detach_children(smc->smc_dev, flags);
99 sysctl_teardown(&smc->smc_log);
101 mutex_destroy(&smc->smc_io_lock);
107 apple_smc_rescan(struct apple_smc_tag *smc, const char *ifattr,
112 config_search(smc->smc_dev, smc,
120 struct apple_smc_tag *const smc = aux;
152 asa.asa_smc = smc;
159 apple_smc_child_detached(struct apple_smc_tag *smc __unused,
167 apple_smc_bus_read_1(struct apple_smc_tag *smc, bus_size_t reg)
170 return bus_space_read_1(smc->smc_bst, smc->smc_bsh, reg);
174 apple_smc_bus_write_1(struct apple_smc_tag *smc, bus_size_t reg, uint8_t v)
177 bus_space_write_1(smc->smc_bst, smc->smc_bsh, reg, v);
186 apple_smc_read_data(struct apple_smc_tag *smc, uint8_t *byte)
191 KASSERT(mutex_owned(&smc->smc_io_lock));
198 status = apple_smc_bus_read_1(smc, APPLE_SMC_CSR);
200 *byte = apple_smc_bus_read_1(smc, APPLE_SMC_DATA);
210 apple_smc_write(struct apple_smc_tag *smc, bus_size_t reg, uint8_t byte)
215 KASSERT(mutex_owned(&smc->smc_io_lock));
221 apple_smc_bus_write_1(smc, reg, byte);
223 status = apple_smc_bus_read_1(smc, APPLE_SMC_CSR);
230 apple_smc_bus_write_1(smc, reg, byte);
237 apple_smc_write_cmd(struct apple_smc_tag *smc, uint8_t cmd)
240 return apple_smc_write(smc, APPLE_SMC_CSR, cmd);
244 apple_smc_write_data(struct apple_smc_tag *smc, uint8_t data)
247 return apple_smc_write(smc, APPLE_SMC_DATA, data);
252 apple_smc_begin(struct apple_smc_tag *smc, uint8_t cmd, const char *key,
258 KASSERT(mutex_owned(&smc->smc_io_lock));
261 error = apple_smc_write_cmd(smc, cmd);
267 error = apple_smc_write_data(smc, key[i]);
273 error = apple_smc_write_data(smc, size);
281 apple_smc_input(struct apple_smc_tag *smc, uint8_t cmd, const char *key,
288 /* Grab the SMC I/O lock. */
289 mutex_enter(&smc->smc_io_lock);
292 error = apple_smc_begin(smc, cmd, key, size);
298 error = apple_smc_read_data(smc, &bytes[i]);
306 out: mutex_exit(&smc->smc_io_lock);
311 apple_smc_output(struct apple_smc_tag *smc, uint8_t cmd, const char *key,
318 /* Grab the SMC I/O lock. */
319 mutex_enter(&smc->smc_io_lock);
322 error = apple_smc_begin(smc, cmd, key, size);
328 error = apple_smc_write_data(smc, bytes[i]);
336 out: mutex_exit(&smc->smc_io_lock);
364 apple_smc_nkeys(struct apple_smc_tag *smc)
367 return smc->smc_nkeys;
371 apple_smc_nth_key(struct apple_smc_tag *smc, uint32_t index,
385 key->ask_smc = smc;
388 /* Ask the SMC what the name of the key by this number is. */
390 error = apple_smc_input(smc, APPLE_SMC_CMD_NTH_KEY, index_be.name,
398 /* Ask the SMC for a description of this key by name. */
400 error = apple_smc_input(smc, APPLE_SMC_CMD_KEY_DESC, key->ask_name,
420 apple_smc_named_key(struct apple_smc_tag *smc, const char name[4 + 1],
438 key->ask_smc = smc;
445 /* Ask the SMC for a description of this key by name. */
447 error = apple_smc_input(smc, APPLE_SMC_CMD_KEY_DESC, key->ask_name,
467 apple_smc_release_key(struct apple_smc_tag *smc, struct apple_smc_key *key)
471 /* Make sure the caller didn't mix up SMC tags. */
472 if (key->ask_smc != smc)
473 aprint_error_dev(smc->smc_dev,
475 smc, key->ask_smc);
483 apple_smc_key_search(struct apple_smc_tag *smc, const char name[4 + 1],
487 uint32_t start = 0, end = apple_smc_nkeys(smc), median;
491 /* Do a binary search on the SMC's key space. */
494 error = apple_smc_nth_key(smc, median, NULL, &key);
506 apple_smc_release_key(smc, key);
516 apple_smc_read_key(struct apple_smc_tag *smc, const struct apple_smc_key *key,
529 return apple_smc_input(smc, APPLE_SMC_CMD_READ_KEY, key->ask_name,
534 apple_smc_read_key_1(struct apple_smc_tag *smc,
538 return apple_smc_read_key(smc, key, p, 1);
542 apple_smc_read_key_2(struct apple_smc_tag *smc,
549 error = apple_smc_read_key(smc, key, &be, 2);
561 apple_smc_read_key_4(struct apple_smc_tag *smc,
568 error = apple_smc_read_key(smc, key, &be, 4);
580 apple_smc_write_key(struct apple_smc_tag *smc, const struct apple_smc_key *key,
593 return apple_smc_output(smc, APPLE_SMC_CMD_WRITE_KEY, key->ask_name,
598 apple_smc_write_key_1(struct apple_smc_tag *smc,
602 return apple_smc_write_key(smc, key, &v, 1);
606 apple_smc_write_key_2(struct apple_smc_tag *smc,
613 return apple_smc_write_key(smc, key, &v_be, 2);
617 apple_smc_write_key_4(struct apple_smc_tag *smc,
624 return apple_smc_write_key(smc, key, &v_be, 4);