| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Support for OLPC XO-1 System Control Interrupts (SCI) |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2010 One Laptop per Child |
|---|
| 5 | 6 | * Copyright (C) 2006 Red Hat, Inc. |
|---|
| 6 | 7 | * Copyright (C) 2006 Advanced Micro Devices, Inc. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 9 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 10 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 11 | | - * (at your option) any later version. |
|---|
| 12 | 8 | */ |
|---|
| 13 | 9 | |
|---|
| 14 | 10 | #include <linux/cs5535.h> |
|---|
| .. | .. |
|---|
| 19 | 15 | #include <linux/platform_device.h> |
|---|
| 20 | 16 | #include <linux/pm.h> |
|---|
| 21 | 17 | #include <linux/pm_wakeup.h> |
|---|
| 22 | | -#include <linux/mfd/core.h> |
|---|
| 23 | 18 | #include <linux/power_supply.h> |
|---|
| 24 | 19 | #include <linux/suspend.h> |
|---|
| 25 | 20 | #include <linux/workqueue.h> |
|---|
| .. | .. |
|---|
| 57 | 52 | |
|---|
| 58 | 53 | static void battery_status_changed(void) |
|---|
| 59 | 54 | { |
|---|
| 60 | | - struct power_supply *psy = power_supply_get_by_name("olpc-battery"); |
|---|
| 55 | + struct power_supply *psy = power_supply_get_by_name("olpc_battery"); |
|---|
| 61 | 56 | |
|---|
| 62 | 57 | if (psy) { |
|---|
| 63 | 58 | power_supply_changed(psy); |
|---|
| .. | .. |
|---|
| 67 | 62 | |
|---|
| 68 | 63 | static void ac_status_changed(void) |
|---|
| 69 | 64 | { |
|---|
| 70 | | - struct power_supply *psy = power_supply_get_by_name("olpc-ac"); |
|---|
| 65 | + struct power_supply *psy = power_supply_get_by_name("olpc_ac"); |
|---|
| 71 | 66 | |
|---|
| 72 | 67 | if (psy) { |
|---|
| 73 | 68 | power_supply_changed(psy); |
|---|
| .. | .. |
|---|
| 85 | 80 | return; |
|---|
| 86 | 81 | } |
|---|
| 87 | 82 | |
|---|
| 88 | | - if (!!test_bit(SW_TABLET_MODE, ebook_switch_idev->sw) == state) |
|---|
| 83 | + if (test_bit(SW_TABLET_MODE, ebook_switch_idev->sw) == !!state) |
|---|
| 89 | 84 | return; /* Nothing new to report. */ |
|---|
| 90 | 85 | |
|---|
| 91 | 86 | input_report_switch(ebook_switch_idev, SW_TABLET_MODE, state); |
|---|
| .. | .. |
|---|
| 109 | 104 | * the edge detector hookup on the gpio inputs on the geode is |
|---|
| 110 | 105 | * odd, to say the least. See http://dev.laptop.org/ticket/5703 |
|---|
| 111 | 106 | * for details, but in a nutshell: we don't use the edge |
|---|
| 112 | | - * detectors. instead, we make use of an anomoly: with the both |
|---|
| 107 | + * detectors. instead, we make use of an anomaly: with the both |
|---|
| 113 | 108 | * edge detectors turned off, we still get an edge event on a |
|---|
| 114 | 109 | * positive edge transition. to take advantage of this, we use the |
|---|
| 115 | 110 | * front-end inverter to ensure that that's the edge we're always |
|---|
| .. | .. |
|---|
| 160 | 155 | } |
|---|
| 161 | 156 | static DEVICE_ATTR(lid_wake_mode, S_IWUSR | S_IRUGO, lid_wake_mode_show, |
|---|
| 162 | 157 | lid_wake_mode_set); |
|---|
| 158 | + |
|---|
| 159 | +static struct attribute *lid_attrs[] = { |
|---|
| 160 | + &dev_attr_lid_wake_mode.attr, |
|---|
| 161 | + NULL, |
|---|
| 162 | +}; |
|---|
| 163 | +ATTRIBUTE_GROUPS(lid); |
|---|
| 163 | 164 | |
|---|
| 164 | 165 | /* |
|---|
| 165 | 166 | * Process all items in the EC's SCI queue. |
|---|
| .. | .. |
|---|
| 514 | 515 | goto err_register; |
|---|
| 515 | 516 | } |
|---|
| 516 | 517 | |
|---|
| 517 | | - r = device_create_file(&lid_switch_idev->dev, &dev_attr_lid_wake_mode); |
|---|
| 518 | | - if (r) { |
|---|
| 519 | | - dev_err(&pdev->dev, "failed to create wake mode attr: %d\n", r); |
|---|
| 520 | | - goto err_create_attr; |
|---|
| 521 | | - } |
|---|
| 522 | | - |
|---|
| 523 | 518 | return 0; |
|---|
| 524 | 519 | |
|---|
| 525 | | -err_create_attr: |
|---|
| 526 | | - input_unregister_device(lid_switch_idev); |
|---|
| 527 | | - lid_switch_idev = NULL; |
|---|
| 528 | 520 | err_register: |
|---|
| 529 | 521 | input_free_device(lid_switch_idev); |
|---|
| 530 | 522 | return r; |
|---|
| .. | .. |
|---|
| 532 | 524 | |
|---|
| 533 | 525 | static void free_lid_switch(void) |
|---|
| 534 | 526 | { |
|---|
| 535 | | - device_remove_file(&lid_switch_idev->dev, &dev_attr_lid_wake_mode); |
|---|
| 536 | 527 | input_unregister_device(lid_switch_idev); |
|---|
| 537 | 528 | } |
|---|
| 538 | 529 | |
|---|
| .. | .. |
|---|
| 544 | 535 | /* don't run on non-XOs */ |
|---|
| 545 | 536 | if (!machine_is_olpc()) |
|---|
| 546 | 537 | return -ENODEV; |
|---|
| 547 | | - |
|---|
| 548 | | - r = mfd_cell_enable(pdev); |
|---|
| 549 | | - if (r) |
|---|
| 550 | | - return r; |
|---|
| 551 | 538 | |
|---|
| 552 | 539 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
|---|
| 553 | 540 | if (!res) { |
|---|
| .. | .. |
|---|
| 613 | 600 | |
|---|
| 614 | 601 | static int xo1_sci_remove(struct platform_device *pdev) |
|---|
| 615 | 602 | { |
|---|
| 616 | | - mfd_cell_disable(pdev); |
|---|
| 617 | 603 | free_irq(sci_irq, pdev); |
|---|
| 618 | 604 | cancel_work_sync(&sci_work); |
|---|
| 619 | 605 | free_ec_sci(); |
|---|
| .. | .. |
|---|
| 628 | 614 | static struct platform_driver xo1_sci_driver = { |
|---|
| 629 | 615 | .driver = { |
|---|
| 630 | 616 | .name = "olpc-xo1-sci-acpi", |
|---|
| 617 | + .dev_groups = lid_groups, |
|---|
| 631 | 618 | }, |
|---|
| 632 | 619 | .probe = xo1_sci_probe, |
|---|
| 633 | 620 | .remove = xo1_sci_remove, |
|---|