static int acpi_ec_probe(device_t dev) { ACPI_BUFFER buf; ACPI_HANDLE h; ACPI_OBJECT *obj; ACPI_STATUS status; device_t peer; char desc[64]; int ecdt; int ret; struct acpi_ec_params *params; static char *ec_ids[] = { "PNP0C09", NULL }; /* Check that this is a device and that EC is not disabled. */ if (acpi_get_type(dev) != ACPI_TYPE_DEVICE || acpi_disabled("ec")) return (ENXIO); /* * If probed via ECDT, set description and continue. Otherwise, * we can access the namespace and make sure this is not a * duplicate probe. */ ret = ENXIO; ecdt = 0; buf.Pointer = NULL; buf.Length = ACPI_ALLOCATE_BUFFER; params = acpi_get_private(dev); if (params != NULL) { ecdt = 1; ret = 0; } else if (ACPI_ID_PROBE(device_get_parent(dev), dev, ec_ids)) { params = kmalloc(sizeof(struct acpi_ec_params), M_TEMP, M_WAITOK | M_ZERO); h = acpi_get_handle(dev); /* * Read the unit ID to check for duplicate attach and the * global lock value to see if we should acquire it when * accessing the EC. */ status = acpi_GetInteger(h, "_UID", ¶ms->uid); if (ACPI_FAILURE(status)) params->uid = 0; status = acpi_GetInteger(h, "_GLK", ¶ms->glk); if (ACPI_FAILURE(status)) params->glk = 0; /* * Evaluate the _GPE method to find the GPE bit used by the EC to * signal status (SCI). If it's a package, it contains a reference * and GPE bit, similar to _PRW. */ status = AcpiEvaluateObject(h, "_GPE", NULL, &buf); if (ACPI_FAILURE(status)) { device_printf(dev, "can't evaluate _GPE - %s\n", AcpiFormatException(status)); goto out; } obj = (ACPI_OBJECT *)buf.Pointer; if (obj == NULL) goto out; switch (obj->Type) { case ACPI_TYPE_INTEGER: params->gpe_handle = NULL; params->gpe_bit = obj->Integer.Value; break; case ACPI_TYPE_PACKAGE: if (!ACPI_PKG_VALID(obj, 2)) goto out; params->gpe_handle = acpi_GetReference(NULL, &obj->Package.Elements[0]); if (params->gpe_handle == NULL || acpi_PkgInt32(obj, 1, ¶ms->gpe_bit) != 0) goto out; break; default: device_printf(dev, "_GPE has invalid type %d\n", obj->Type); goto out; } /* Store the values we got from the namespace for attach. */ acpi_set_private(dev, params); /* * Check for a duplicate probe. This can happen when a probe * via ECDT succeeded already. If this is a duplicate, disable * this device. */ peer = devclass_get_device(acpi_ec_devclass, params->uid); if (peer == NULL || !device_is_alive(peer)) ret = 0; else device_disable(dev); } out: if (ret == 0) { ksnprintf(desc, sizeof(desc), "Embedded Controller: GPE %#x%s%s", params->gpe_bit, (params->glk) ? ", GLK" : "", ecdt ? ", ECDT" : ""); device_set_desc_copy(dev, desc); } if (ret > 0 && params) kfree(params, M_TEMP); if (buf.Pointer) AcpiOsFree(buf.Pointer); return (ret); }
static int atkbdc_ebus_probe(device_t dev) { struct resource *port0, *port1; u_long count, start; int error, rid; if (strcmp(ofw_bus_get_name(dev), "8042") != 0) return (ENXIO); /* * On AXi and AXmp boards the NS16550 (used to connect keyboard/ * mouse) share their IRQ lines with the i8042. Any IRQ activity * (typically during attach) of the NS16550 used to connect the * keyboard when actually the PS/2 keyboard is selected in OFW * causes interaction with the OBP i8042 driver resulting in a * hang and vice versa. As RS232 keyboards and mice obviously * aren't meant to be used in parallel with PS/2 ones on these * boards don't attach to the i8042 in case the PS/2 keyboard * isn't selected in order to prevent such hangs. * Note that it's not sufficient here to rely on the '8042' node * only showing up when a PS/2 keyboard is actually connected as * the user still might have adjusted the 'keyboard' alias to * point to the RS232 keyboard. */ if ((!strcmp(sparc64_model, "SUNW,UltraAX-MP") || !strcmp(sparc64_model, "SUNW,UltraSPARC-IIi-Engine")) && OF_finddevice("keyboard") != ofw_bus_get_node(dev)) { device_disable(dev); return (ENXIO); } device_set_desc(dev, "Keyboard controller (i8042)"); /* * The '8042' node has two identical 8 addresses wide resources * which are apparently meant to be used one for the keyboard * half and the other one for the mouse half. To simplify matters * we use one for the command/data port resource and the other * one for the status port resource as the atkbdc(4) back-end * expects two struct resource rather than two bus space handles. */ rid = 0; if (bus_get_resource(dev, SYS_RES_MEMORY, rid, &start, &count) != 0) { device_printf(dev, "cannot determine command/data port resource\n"); return (ENXIO); } port0 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, start, start, 1, RF_ACTIVE); if (port0 == NULL) { device_printf(dev, "cannot allocate command/data port resource\n"); return (ENXIO); } rid = 1; if (bus_get_resource(dev, SYS_RES_MEMORY, rid, &start, &count) != 0) { device_printf(dev, "cannot determine status port resource\n"); error = ENXIO; goto fail_port0; } start += KBD_STATUS_PORT; port1 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, start, start, 1, RF_ACTIVE); if (port1 == NULL) { device_printf(dev, "cannot allocate status port resource\n"); error = ENXIO; goto fail_port0; } error = atkbdc_probe_unit(device_get_unit(dev), port0, port1); if (error != 0) device_printf(dev, "atkbdc_porbe_unit failed\n"); bus_release_resource(dev, SYS_RES_MEMORY, 1, port1); fail_port0: bus_release_resource(dev, SYS_RES_MEMORY, 0, port0); return (error); }
int fpc_init() { int ret = 0; ALOGE("INIT FPC TZ APP\n"); open_handle(); if (open_handle() < 1) { ALOGE("Qseecom Lib Not Open !\n"); return -1; } if (device_enable() < 0) { ALOGE("Error starting device\n"); return -1; } if (qsee_load_trustlet(&mHandle, FP_TZAPP_PATH, FP_TZAPP_NAME, 1024) < 0) return -1; if (qsee_load_trustlet(&mHandle, KM_TZAPP_PATH, KM_TZAPP_NAME, 1024) < 0) return -1; // Start creating one off command to get cert from keymaster fpc_send_std_cmd_t *req = (fpc_send_std_cmd_t *) mHdl->ion_sbuffer; req->cmd_id = 0x205; req->ret_val = 0x02; void * send_buf = mHdl->ion_sbuffer; void * rec_buf = mHdl->ion_sbuffer + 64; if (send_cmd_fn(mHdl, send_buf, 64, rec_buf, 1024-64) < 0) { return -1; } //Send command to keymaster fpc_send_std_cmd_t* ret_data = (fpc_send_std_cmd_t*) rec_buf; ALOGE("Keymaster Response Code : %u\n", ret_data->ret_val); ALOGE("Keymaster Response Length : %u\n", ret_data->length); void * data_buff = &ret_data->length + 1; if (send_modified_command_to_tz(FPC_SET_INIT_DATA,mHandle,data_buff,ret_data->length) < 0) { ALOGE("Error sending data to tz\n"); return -1; } if (send_normal_command(FPC_INIT,0,mHandle) != 0) { ALOGE("Error sending FPC_INIT to tz\n"); return -1; } if (send_normal_command(FPC_GET_INIT_STATE,0,mHandle) != 0) { ALOGE("Error sending FPC_GET_INIT_STATE to tz\n"); return -1; } if (send_normal_command(FPC_INIT_UNK_1,0,mHandle) != 12) { ALOGE("Error sending FPC_INIT_UNK_1 to tz\n"); return -1; } if (device_enable() < 0) { ALOGE("Error starting device\n"); return -1; } if (send_normal_command(FPC_INIT_UNK_2,0,mHandle) != 0) { ALOGE("Error sending FPC_INIT_UNK_2 to tz\n"); return -1; } int fpc_info = send_normal_command(FPC_INIT_UNK_0,0,mHandle); ALOGI("Got device data : %d \n", fpc_info); if (device_disable() < 0) { ALOGE("Error stopping device\n"); return -1; } set_bandwidth_fn(mHandle,true); if (send_normal_command(FPC_INIT_NEW_DB,0,mHandle) != 0) { ALOGE("Error sending FPC_INIT_NEW_DB to tz\n"); return -1; } if (send_normal_command(FPC_SET_FP_STORE,0,mHandle) != 0) { ALOGE("Error sending FPC_SET_FP_STORE to tz\n"); return -1; } set_bandwidth_fn(mHandle,false); return 1; }