mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-19 21:21:09 +00:00
powerpc updates for 3.19
Some nice cleanups like removing bootmem, and removal of __get_cpu_var(). There is one patch to mm/gup.c. This is the generic GUP implementation, but is only used by us and arm(64). We have an ack from Steve Capper, and although we didn't get an ack from Andrew he told us to take the patch through the powerpc tree. There's one cxl patch. This is in drivers/misc, but Greg said he was happy for us to manage fixes for it. There is an infrastructure patch to support an IPMI driver for OPAL. That patch also appears in Corey Minyard's IPMI tree, you may see a conflict there. There is also an RTC driver for OPAL. We weren't able to get any response from the RTC maintainer, Alessandro Zummo, so in the end we just merged the driver. The usual batch of Freescale updates from Scott. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJUiSTSAAoJEFHr6jzI4aWAirQP/3rIEng0LzLu5kW2zkGylIaM SNDum1vze3mHiTFl+CFcSIGpC1UEULoB49HA+2oE/ExKpIceG6lpL2LP+wNh2FW5 mozjMjS6mZt4w1Fu1D2ZtgQc3O1T1pxkqsnZmPa8gVf5k5d5IQNPY6yB0pgVWwbV gwBKxe4VwPAzJjppE9i9MDhNTJwmHZq0lI8XuoTXOOU/f+4G1WxmjrbyveQ7cRP5 i/sq2cKjxpWA+KDeIXo0GR0DpXR7qMeAvFX5xXY7oKuUJIFDM4kSHfmMYP6qLf5c 2vlsJqHVqfOgQdve41z1ooaPzNtg7ezVo+VqqguSgtSgwy2JUo/uHpnzz3gD1Olo AP5+6xj8LZac0rTPxF4n4Hoyrp7AaaFjEFt1zqT9PWniZW4B41wtia0QORBNUf1S UEmKAC9T3WZJ47mH7WMSadtOPF9E3Yd/zuiPD4udtptCNKPbr6/k1MpJPIW2D4Rn BJ0QZTRd7V0yRofXxZtHxaMxq8pWd/Tip7J/zr/ghz+ulnH8BuFamuhCCLuJlESU +A2PMfuseyTMpH9sMAmmTwSGPDKjaUFWvmFvY/n88NZL7r2LlomNrDWFSSQOIHUP FxjYmjUMpZeexsfyRdgFV/INhYC3o3cso2fRGO45YK6nkxNnjNFEBS6WhQLvNLBu sknd1WjXkuJtoMC15SrQ =jvyT -----END PGP SIGNATURE----- Merge tag 'powerpc-3.19-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux Pull powerpc updates from Michael Ellerman: "Some nice cleanups like removing bootmem, and removal of __get_cpu_var(). There is one patch to mm/gup.c. This is the generic GUP implementation, but is only used by us and arm(64). We have an ack from Steve Capper, and although we didn't get an ack from Andrew he told us to take the patch through the powerpc tree. There's one cxl patch. This is in drivers/misc, but Greg said he was happy for us to manage fixes for it. There is an infrastructure patch to support an IPMI driver for OPAL. There is also an RTC driver for OPAL. We weren't able to get any response from the RTC maintainer, Alessandro Zummo, so in the end we just merged the driver. The usual batch of Freescale updates from Scott" * tag 'powerpc-3.19-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux: (101 commits) powerpc/powernv: Return to cpu offline loop when finished in KVM guest powerpc/book3s: Fix partial invalidation of TLBs in MCE code. powerpc/mm: don't do tlbie for updatepp request with NO HPTE fault powerpc/xmon: Cleanup the breakpoint flags powerpc/xmon: Enable HW instruction breakpoint on POWER8 powerpc/mm/thp: Use tlbiel if possible powerpc/mm/thp: Remove code duplication powerpc/mm/hugetlb: Sanity check gigantic hugepage count powerpc/oprofile: Disable pagefaults during user stack read powerpc/mm: Check for matching hpte without taking hpte lock powerpc: Drop useless warning in eeh_init() powerpc/powernv: Cleanup unused MCE definitions/declarations. powerpc/eeh: Dump PHB diag-data early powerpc/eeh: Recover EEH error on ownership change for BCM5719 powerpc/eeh: Set EEH_PE_RESET on PE reset powerpc/eeh: Refactor eeh_reset_pe() powerpc: Remove more traces of bootmem powerpc/pseries: Initialise nvram_pstore_info's buf_lock cxl: Name interrupts in /proc/interrupt cxl: Return error to PSL if IRQ demultiplexing fails & print clearer warning ...
This commit is contained in:
commit
140cd7fb04
205 changed files with 3244 additions and 2175 deletions
|
@ -987,6 +987,17 @@ config RTC_DRV_NUC900
|
|||
If you say yes here you get support for the RTC subsystem of the
|
||||
NUC910/NUC920 used in embedded systems.
|
||||
|
||||
config RTC_DRV_OPAL
|
||||
tristate "IBM OPAL RTC driver"
|
||||
depends on PPC_POWERNV
|
||||
default y
|
||||
help
|
||||
If you say yes here you get support for the PowerNV platform RTC
|
||||
driver based on OPAL interfaces.
|
||||
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called rtc-opal.
|
||||
|
||||
comment "on-CPU RTC drivers"
|
||||
|
||||
config RTC_DRV_DAVINCI
|
||||
|
|
|
@ -92,6 +92,7 @@ obj-$(CONFIG_RTC_DRV_MSM6242) += rtc-msm6242.o
|
|||
obj-$(CONFIG_RTC_DRV_MPC5121) += rtc-mpc5121.o
|
||||
obj-$(CONFIG_RTC_DRV_MV) += rtc-mv.o
|
||||
obj-$(CONFIG_RTC_DRV_NUC900) += rtc-nuc900.o
|
||||
obj-$(CONFIG_RTC_DRV_OPAL) += rtc-opal.o
|
||||
obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o
|
||||
obj-$(CONFIG_RTC_DRV_PALMAS) += rtc-palmas.o
|
||||
obj-$(CONFIG_RTC_DRV_PCAP) += rtc-pcap.o
|
||||
|
|
261
drivers/rtc/rtc-opal.c
Normal file
261
drivers/rtc/rtc-opal.c
Normal file
|
@ -0,0 +1,261 @@
|
|||
/*
|
||||
* IBM OPAL RTC driver
|
||||
* Copyright (C) 2014 IBM
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
|
||||
#define DRVNAME "rtc-opal"
|
||||
#define pr_fmt(fmt) DRVNAME ": " fmt
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/rtc.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/bcd.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/of.h>
|
||||
#include <asm/opal.h>
|
||||
#include <asm/firmware.h>
|
||||
|
||||
static void opal_to_tm(u32 y_m_d, u64 h_m_s_ms, struct rtc_time *tm)
|
||||
{
|
||||
tm->tm_year = ((bcd2bin(y_m_d >> 24) * 100) +
|
||||
bcd2bin((y_m_d >> 16) & 0xff)) - 1900;
|
||||
tm->tm_mon = bcd2bin((y_m_d >> 8) & 0xff) - 1;
|
||||
tm->tm_mday = bcd2bin(y_m_d & 0xff);
|
||||
tm->tm_hour = bcd2bin((h_m_s_ms >> 56) & 0xff);
|
||||
tm->tm_min = bcd2bin((h_m_s_ms >> 48) & 0xff);
|
||||
tm->tm_sec = bcd2bin((h_m_s_ms >> 40) & 0xff);
|
||||
|
||||
GregorianDay(tm);
|
||||
}
|
||||
|
||||
static void tm_to_opal(struct rtc_time *tm, u32 *y_m_d, u64 *h_m_s_ms)
|
||||
{
|
||||
*y_m_d |= ((u32)bin2bcd((tm->tm_year + 1900) / 100)) << 24;
|
||||
*y_m_d |= ((u32)bin2bcd((tm->tm_year + 1900) % 100)) << 16;
|
||||
*y_m_d |= ((u32)bin2bcd((tm->tm_mon + 1))) << 8;
|
||||
*y_m_d |= ((u32)bin2bcd(tm->tm_mday));
|
||||
|
||||
*h_m_s_ms |= ((u64)bin2bcd(tm->tm_hour)) << 56;
|
||||
*h_m_s_ms |= ((u64)bin2bcd(tm->tm_min)) << 48;
|
||||
*h_m_s_ms |= ((u64)bin2bcd(tm->tm_sec)) << 40;
|
||||
}
|
||||
|
||||
static int opal_get_rtc_time(struct device *dev, struct rtc_time *tm)
|
||||
{
|
||||
long rc = OPAL_BUSY;
|
||||
u32 y_m_d;
|
||||
u64 h_m_s_ms;
|
||||
__be32 __y_m_d;
|
||||
__be64 __h_m_s_ms;
|
||||
|
||||
while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
|
||||
rc = opal_rtc_read(&__y_m_d, &__h_m_s_ms);
|
||||
if (rc == OPAL_BUSY_EVENT)
|
||||
opal_poll_events(NULL);
|
||||
else
|
||||
msleep(10);
|
||||
}
|
||||
|
||||
if (rc != OPAL_SUCCESS)
|
||||
return -EIO;
|
||||
|
||||
y_m_d = be32_to_cpu(__y_m_d);
|
||||
h_m_s_ms = be64_to_cpu(__h_m_s_ms);
|
||||
opal_to_tm(y_m_d, h_m_s_ms, tm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int opal_set_rtc_time(struct device *dev, struct rtc_time *tm)
|
||||
{
|
||||
long rc = OPAL_BUSY;
|
||||
u32 y_m_d = 0;
|
||||
u64 h_m_s_ms = 0;
|
||||
|
||||
tm_to_opal(tm, &y_m_d, &h_m_s_ms);
|
||||
while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
|
||||
rc = opal_rtc_write(y_m_d, h_m_s_ms);
|
||||
if (rc == OPAL_BUSY_EVENT)
|
||||
opal_poll_events(NULL);
|
||||
else
|
||||
msleep(10);
|
||||
}
|
||||
|
||||
return rc == OPAL_SUCCESS ? 0 : -EIO;
|
||||
}
|
||||
|
||||
/*
|
||||
* TPO Timed Power-On
|
||||
*
|
||||
* TPO get/set OPAL calls care about the hour and min and to make it consistent
|
||||
* with the rtc utility time conversion functions, we use the 'u64' to store
|
||||
* its value and perform bit shift by 32 before use..
|
||||
*/
|
||||
static int opal_get_tpo_time(struct device *dev, struct rtc_wkalrm *alarm)
|
||||
{
|
||||
__be32 __y_m_d, __h_m;
|
||||
struct opal_msg msg;
|
||||
int rc, token;
|
||||
u64 h_m_s_ms;
|
||||
u32 y_m_d;
|
||||
|
||||
token = opal_async_get_token_interruptible();
|
||||
if (token < 0) {
|
||||
if (token != -ERESTARTSYS)
|
||||
pr_err("Failed to get the async token\n");
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
rc = opal_tpo_read(token, &__y_m_d, &__h_m);
|
||||
if (rc != OPAL_ASYNC_COMPLETION) {
|
||||
rc = -EIO;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
rc = opal_async_wait_response(token, &msg);
|
||||
if (rc) {
|
||||
rc = -EIO;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
rc = be64_to_cpu(msg.params[1]);
|
||||
if (rc != OPAL_SUCCESS) {
|
||||
rc = -EIO;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
y_m_d = be32_to_cpu(__y_m_d);
|
||||
h_m_s_ms = ((u64)be32_to_cpu(__h_m) << 32);
|
||||
opal_to_tm(y_m_d, h_m_s_ms, &alarm->time);
|
||||
|
||||
exit:
|
||||
opal_async_release_token(token);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Set Timed Power-On */
|
||||
static int opal_set_tpo_time(struct device *dev, struct rtc_wkalrm *alarm)
|
||||
{
|
||||
u64 h_m_s_ms = 0, token;
|
||||
struct opal_msg msg;
|
||||
u32 y_m_d = 0;
|
||||
int rc;
|
||||
|
||||
tm_to_opal(&alarm->time, &y_m_d, &h_m_s_ms);
|
||||
|
||||
token = opal_async_get_token_interruptible();
|
||||
if (token < 0) {
|
||||
if (token != -ERESTARTSYS)
|
||||
pr_err("Failed to get the async token\n");
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
/* TPO, we care about hour and minute */
|
||||
rc = opal_tpo_write(token, y_m_d,
|
||||
(u32)((h_m_s_ms >> 32) & 0xffff0000));
|
||||
if (rc != OPAL_ASYNC_COMPLETION) {
|
||||
rc = -EIO;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
rc = opal_async_wait_response(token, &msg);
|
||||
if (rc) {
|
||||
rc = -EIO;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
rc = be64_to_cpu(msg.params[1]);
|
||||
if (rc != OPAL_SUCCESS)
|
||||
rc = -EIO;
|
||||
|
||||
exit:
|
||||
opal_async_release_token(token);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static const struct rtc_class_ops opal_rtc_ops = {
|
||||
.read_time = opal_get_rtc_time,
|
||||
.set_time = opal_set_rtc_time,
|
||||
.read_alarm = opal_get_tpo_time,
|
||||
.set_alarm = opal_set_tpo_time,
|
||||
};
|
||||
|
||||
static int opal_rtc_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct rtc_device *rtc;
|
||||
|
||||
if (pdev->dev.of_node && of_get_property(pdev->dev.of_node, "has-tpo",
|
||||
NULL))
|
||||
device_set_wakeup_capable(&pdev->dev, true);
|
||||
|
||||
rtc = devm_rtc_device_register(&pdev->dev, DRVNAME, &opal_rtc_ops,
|
||||
THIS_MODULE);
|
||||
if (IS_ERR(rtc))
|
||||
return PTR_ERR(rtc);
|
||||
|
||||
rtc->uie_unsupported = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id opal_rtc_match[] = {
|
||||
{
|
||||
.compatible = "ibm,opal-rtc",
|
||||
},
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, opal_rtc_match);
|
||||
|
||||
static const struct platform_device_id opal_rtc_driver_ids[] = {
|
||||
{
|
||||
.name = "opal-rtc",
|
||||
},
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(platform, opal_rtc_driver_ids);
|
||||
|
||||
static struct platform_driver opal_rtc_driver = {
|
||||
.probe = opal_rtc_probe,
|
||||
.id_table = opal_rtc_driver_ids,
|
||||
.driver = {
|
||||
.name = DRVNAME,
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = opal_rtc_match,
|
||||
},
|
||||
};
|
||||
|
||||
static int __init opal_rtc_init(void)
|
||||
{
|
||||
if (!firmware_has_feature(FW_FEATURE_OPAL))
|
||||
return -ENODEV;
|
||||
|
||||
return platform_driver_register(&opal_rtc_driver);
|
||||
}
|
||||
|
||||
static void __exit opal_rtc_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&opal_rtc_driver);
|
||||
}
|
||||
|
||||
MODULE_AUTHOR("Neelesh Gupta <neelegup@linux.vnet.ibm.com>");
|
||||
MODULE_DESCRIPTION("IBM OPAL RTC driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
module_init(opal_rtc_init);
|
||||
module_exit(opal_rtc_exit);
|
Loading…
Add table
Add a link
Reference in a new issue