static struct rmi_control_handler_data *driver_ctl_attach(struct device *dev, void *data) { struct rmi_device *rmi_dev = to_rmi_device(dev); struct driver_ctl_data *ctl_data; int retval; struct rmi_driver_data *driver_data = dev_get_drvdata(&rmi_dev->dev); rmi_dev = to_rmi_device(dev); dev_dbg(dev, "%s called.\n", __func__); ctl_data = devm_kzalloc(dev, sizeof(struct driver_ctl_data), GFP_KERNEL); if (!ctl_data) return NULL; ctl_data->rmi_dev = rmi_dev; dev_dbg(dev, "Checking BSR.\n"); if (driver_data && driver_data->pdt_props.has_bsr) { retval = device_create_file(dev, &bsr_attribute); if (retval < 0) dev_warn(dev, "Failed to create sysfs file bsr.\n"); } #ifdef CONFIG_RMI4_DEBUG setup_debugfs(ctl_data); #endif return &ctl_data->hdata; }
static int __init olpc_init(void) { int r = 0; if (!olpc_ofw_present() || !platform_detect()) return 0; spin_lock_init(&ec_lock); /* assume B1 and above models always have a DCON */ if (olpc_board_at_least(olpc_board(0xb1))) olpc_platform_info.flags |= OLPC_F_DCON; /* get the EC revision */ olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0, (unsigned char *) &olpc_platform_info.ecver, 1); #ifdef CONFIG_PCI_OLPC /* If the VSA exists let it emulate PCI, if not emulate in kernel. * XO-1 only. */ if (olpc_platform_info.boardrev < olpc_board_pre(0xd0) && !cs5535_has_vsa2()) x86_init.pci.arch_init = pci_olpc_init; #endif /* EC version 0x5f adds support for wide SCI mask */ if (olpc_platform_info.ecver >= 0x5f) olpc_platform_info.flags |= OLPC_F_EC_WIDE_SCI; printk(KERN_INFO "OLPC board revision %s%X (EC=%x)\n", ((olpc_platform_info.boardrev & 0xf) < 8) ? "pre" : "", olpc_platform_info.boardrev >> 4, olpc_platform_info.ecver); if (olpc_platform_info.boardrev < olpc_board_pre(0xd0)) { /* XO-1 */ r = add_xo1_platform_devices(); if (r) return r; } register_syscore_ops(&olpc_syscore_ops); setup_debugfs(); return 0; }
int prcmu_debug_init(void) { ape_sh = kzalloc(sizeof(struct ape_state_history), GFP_KERNEL); if (ape_sh == NULL) { pr_err("prcmu debug: kzalloc failed\n"); return -ENOMEM; } ddr_sh = kzalloc(sizeof(struct ddr_state_history), GFP_KERNEL); if (ddr_sh == NULL) { pr_err("prcmu debug: kzalloc failed\n"); return -ENOMEM; } spin_lock_init(&ape_sh->lock); spin_lock_init(&ddr_sh->lock); ape_sh->start = ktime_get(); ddr_sh->start = ktime_get(); setup_debugfs(); return 0; }
static int __devinit rmi_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct rmi_phys_device *rmi_phys; struct rmi_i2c_data *data; struct rmi_device_platform_data *pdata = client->dev.platform_data; int retval; if (!pdata) { dev_err(&client->dev, "no platform data\n"); return -EINVAL; } dev_info(&client->dev, "Probing %s at %#02x (IRQ %d).\n", pdata->sensor_name ? pdata->sensor_name : "-no name-", client->addr, pdata->attn_gpio); if (pdata->gpio_config) { dev_info(&client->dev, "Configuring GPIOs.\n"); retval = pdata->gpio_config(pdata->gpio_data, true); if (retval < 0) { dev_err(&client->dev, "Failed to configure GPIOs, code: %d.\n", retval); return retval; } dev_info(&client->dev, "Done with GPIO configuration.\n"); } retval = i2c_check_functionality(client->adapter, I2C_FUNC_I2C); if (!retval) { dev_err(&client->dev, "i2c_check_functionality error %d.\n", retval); return retval; } rmi_phys = devm_kzalloc(&client->dev, sizeof(struct rmi_phys_device), GFP_KERNEL); if (!rmi_phys) return -ENOMEM; data = devm_kzalloc(&client->dev, sizeof(struct rmi_i2c_data), GFP_KERNEL); if (!data) return -ENOMEM; data->phys = rmi_phys; rmi_phys->data = data; rmi_phys->dev = &client->dev; rmi_phys->write_block = rmi_i2c_write_block; rmi_phys->read_block = rmi_i2c_read_block; rmi_phys->info.proto = phys_proto_name; mutex_init(&data->page_mutex); /* Setting the page to zero will (a) make sure the PSR is in a * known state, and (b) make sure we can talk to the device. */ retval = rmi_set_page(rmi_phys, 0); if (retval) { dev_err(&client->dev, "Failed to set page select to 0.\n"); return retval; } retval = rmi_register_phys_device(rmi_phys); if (retval) { dev_err(&client->dev, "failed to register physical driver at 0x%.2X.\n", client->addr); goto err_gpio; } i2c_set_clientdata(client, rmi_phys); if (IS_ENABLED(CONFIG_RMI4_DEBUG)) retval = setup_debugfs(rmi_phys->rmi_dev, data); dev_info(&client->dev, "registered rmi i2c driver at %#04x.\n", client->addr); return 0; err_gpio: if (pdata->gpio_config) pdata->gpio_config(pdata->gpio_data, false); return retval; }
static int __devinit rmi_smb_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct rmi_phys_device *rmi_phys; struct rmi_smb_data *data; struct rmi_device_platform_data *pdata = client->dev.platform_data; int retval; int smbus_version; if (!pdata) { dev_err(&client->dev, "no platform data\n"); return -EINVAL; } pr_info("%s: Probing %s (IRQ %d).\n", __func__, pdata->sensor_name ? pdata->sensor_name : "-no name-", pdata->attn_gpio); retval = i2c_check_functionality(client->adapter, I2C_FUNC_I2C); if (!retval) { dev_err(&client->dev, "i2c_check_functionality error %d.\n", retval); return retval; } rmi_phys = devm_kzalloc(&client->dev, sizeof(struct rmi_phys_device), GFP_KERNEL); if (!rmi_phys) return -ENOMEM; data = devm_kzalloc(&client->dev, sizeof(struct rmi_smb_data), GFP_KERNEL); if (!data) return -ENOMEM; data->enabled = true; /* We plan to come up enabled. */ data->phys = rmi_phys; rmi_phys->data = data; rmi_phys->dev = &client->dev; mutex_init(&data->page_mutex); mutex_init(&data->mappingtable_mutex); if (pdata->gpio_config) { retval = pdata->gpio_config(pdata->gpio_data, true); if (retval < 0) { dev_err(&client->dev, "failed to setup irq %d\n", pdata->attn_gpio); return retval; } } /* Check if for SMBus new version device by reading version byte. */ retval = i2c_smbus_read_byte_data(client, SMB_PROTOCOL_VERSION_ADDRESS); if (retval < 0) { dev_err(&client->dev, "failed to get SMBus version number!\n"); return retval; } smbus_version = retval + 1; dev_dbg(&client->dev, "Smbus version is %d", smbus_version); switch (smbus_version) { case 1: /* Setting the page to zero will (a) make sure the PSR is in a * known state, and (b) make sure we can talk to the device. */ retval = rmi_set_page(rmi_phys, 0); if (retval) { dev_err(&client->dev, "Failed to set page select to 0.\n"); return retval; } rmi_phys->write_block = rmi_smb_v1_write_block; rmi_phys->read_block = rmi_smb_v1_read_block; rmi_phys->info.proto = smb_v1_proto_name; break; case 2: /* SMBv2 */ retval = i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BLOCK_DATA); if (retval < 0) { dev_err(&client->dev, "client's adapter does not support the I2C_FUNC_SMBUS_READ_BLOCK_DATA functionality.\n"); return retval; } rmi_phys->write_block = rmi_smb_v2_write_block; rmi_phys->read_block = rmi_smb_v2_read_block; rmi_phys->info.proto = smb_v2_proto_name; break; default: dev_err(&client->dev, "Unrecognized SMB version %d.\n", smbus_version); retval = -ENODEV; return retval; } /* End check if this is an SMBus device */ retval = rmi_register_phys_device(rmi_phys); if (retval) { dev_err(&client->dev, "failed to register physical driver at 0x%.2X.\n", client->addr); return retval; } i2c_set_clientdata(client, rmi_phys); if (IS_ENABLED(CONFIG_RMI4_DEBUG)) retval = setup_debugfs(rmi_phys->rmi_dev, data); dev_info(&client->dev, "registered rmi smb driver at 0x%.2X.\n", client->addr); return 0; }
static int rmi_hid_probe(struct hid_device *hdev, const struct hid_device_id *id) { struct rmi_transport_device *xport = NULL; struct rmi_hid_data *data = NULL; unsigned int connect_mask = HID_CONNECT_HIDRAW | HID_CONNECT_HIDDEV; int ret; dev_dbg(&hdev->dev, "%s\n", __func__); xport = devm_kzalloc(&hdev->dev, sizeof(struct rmi_transport_device), GFP_KERNEL); if (!xport) { ret = -ENOMEM; goto err; } data = devm_kzalloc(&hdev->dev, sizeof(struct rmi_hid_data), GFP_KERNEL); if (!data) { ret =-ENOMEM; goto err; } data->xport = xport; xport->data = data; xport->dev = &hdev->dev; xport->write_block = rmi_hid_write_block; xport->read_block = rmi_hid_read_block; xport->info.proto_type = RMI_PROTOCOL_HID; xport->info.proto = transport_proto_name; xport->post_reset = rmi_hid_post_reset; hid_set_drvdata(hdev, xport); ret = hid_parse(hdev); if (ret) { hid_err(hdev, "parse failed\n"); goto err; } data->input_report_size = (hdev->report_enum[HID_INPUT_REPORT] .report_id_hash[RMI_ATTN_REPORT_ID]->size >> 3) + 1 /* report id */; data->output_report_size = (hdev->report_enum[HID_OUTPUT_REPORT] .report_id_hash[RMI_WRITE_REPORT_ID]->size >> 3) + 1 /* report id */; data->feature_report_size = (hdev->report_enum[HID_FEATURE_REPORT] .report_id_hash[RMI_SET_RMI_MODE_REPORT_ID]->size >> 3) + 1 /* report id */; dev_dbg(&hdev->dev, "input report size %d\n", data->input_report_size); dev_dbg(&hdev->dev, "output report size %d\n", data->output_report_size); dev_dbg(&hdev->dev, "feature report size %d\n", data->feature_report_size); data->input_queue = devm_kzalloc(&hdev->dev, data->input_report_size * RMI_HID_INPUT_REPORT_QUEUE_LEN, GFP_KERNEL); if (!data->input_queue) { ret = -ENOMEM; goto err; } data->writeReport = devm_kzalloc(&hdev->dev, data->output_report_size, GFP_KERNEL); if (!data->writeReport) { ret = -ENOMEM; goto err; } data->readReport = devm_kzalloc(&hdev->dev, data->input_report_size, GFP_KERNEL); if (!data->readReport) { ret = -ENOMEM; goto err; } data->attnReport = devm_kzalloc(&hdev->dev, data->input_report_size, GFP_KERNEL); if (!data->attnReport) { ret = -ENOMEM; goto err; } tp_platformdata.pm_data = hdev; xport->dev->platform_data = &tp_platformdata; #ifdef TOUCHPAD_WAKE_SYSTEM if (tp_platformdata.f11_sensor_data[0].sensor_type == rmi_sensor_touchpad) { device_init_wakeup(hdev->dev.parent, 1); } #endif spin_lock_init(&data->input_queue_consumer_lock); spin_lock_init(&data->input_queue_producer_lock); data->input_queue_head = 0; data->input_queue_tail = 0; INIT_WORK(&data->attn_report_work, rmi_hid_attn_report_work); INIT_WORK(&data->reset_work, rmi_hid_reset_work); init_waitqueue_head(&data->wait); mutex_init(&data->page_mutex); ret = hid_hw_start(hdev, connect_mask); if (ret) { hid_err(hdev, "hw start failed\n"); goto err; } dev_dbg(&hdev->dev, "Opening low level driver\n"); hdev->ll_driver->open(hdev); /* Allow incoming hid reports */ hid_device_io_start(hdev); ret = rmi_hid_set_mode(hdev, RMI_HID_MODE_ATTN_REPORTS); if (ret < 0) { dev_err(&hdev->dev, "failed to set rmi mode\n"); goto rmi_read_failed; } ret = rmi_set_page(xport, 0); if (ret < 0) { dev_err(&hdev->dev, "failed to set page select to 0.\n"); goto rmi_read_failed; } ret = rmi_register_transport_device(xport); if (ret) { dev_err(&hdev->dev, "failed to register transport device at %s\n", hdev->phys); goto rmi_read_failed; } if (!xport->probe_succeeded) { dev_err(&hdev->dev, "Probe failed in rmi_driver\n"); ret = -ENODEV; goto rmi_driver_probe_failed; } set_bit(RMI_HID_STARTED, &data->flags); if (IS_ENABLED(CONFIG_RMI4_DEBUG)) ret = setup_debugfs(xport->rmi_dev, data); dev_info(&hdev->dev, "registered rmi hid driver at %s\n", hdev->phys); return 0; rmi_driver_probe_failed: rmi_unregister_transport_device(xport); rmi_read_failed: hdev->ll_driver->close(hdev); hid_hw_stop(hdev); err: return ret; }