chrome platform changes for v5.1

1. SPDX identifier cleanup for platform/chrome
 2. Cleanup series between mfd and chrome/platform, moving
    cros-ec attributes from mfd/cros_ec_dev to sub-drivers in platform/chrome.
 3. Wilco EC driver
 4. Maintainership change to new group repository.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE6gYDF28Li+nEiKLaHwn1ewov5lgFAlyG4dIACgkQHwn1ewov
 5lhoqA//SXO5HU1qkhfvwUKyNsYxtIj4wDQF+j9tAPbVaOOaztq0b5D1PQgDGcEL
 SDl9FAXZtwhmPr5xiGPrPUxwn4JG+tUcgSSgIOCtClpA/SZUPt2wekAB64hLt1ui
 nkBRSgeRnXeeRE0nDh7EUrwAeaYj6yCg4AS8FMHmjWTG0tI6iivhuc39v/zDV8Br
 f4chOu/KEWS/EhItVlDBHE0mYDW2JGLSD3nqJR9MdujvYzbkN5WusJIXBDK6MOUl
 z1gqptVYyq/FQOQOCZ+vHjTNVYQ3N3NbPOnnQn4xAyYiqTQJVJv+x6dd7htncjVO
 567PFbbqbKzqrGWZOrdksxVa4JkIGfcgNG2mskRYKpEtHVOpMlHxwHqKv/93TQvw
 F0z4+43ZeAo0Fx2k+oOiDylpClDvUVOeH0z5suqIK15MZbpfWZF6d38Pz1Zwd8hY
 0TEldpyH83HiXylEuYabBwq3ABfj4VncYcMWfaW517LUrnH9nkJDNOlXQFreGTPt
 uHQPz+Xzfirk9wNwlEtfhqh3fjRWIfmiHc8bLmCB2XuJqavF0pozoQnJprw+72LR
 h4ALkUBr8laVfXYgG8SzNm/K4DlMjKqvJRY6m2b7AY8CTVgMur7ct0WJsvmECF+4
 2XDDvHwkQJt3XifVLpLgFRfR5YRlFxjwMNS8Zq0Bb/gjRqSSCo4=
 =2nC0
 -----END PGP SIGNATURE-----

Merge tag 'tag-chrome-platform-for-v5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux

Pull chrome platform updates from Benson Leung:

 - SPDX identifier cleanup for platform/chrome

 - Cleanup series between mfd and chrome/platform, moving cros-ec
   attributes from mfd/cros_ec_dev to sub-drivers in platform/chrome

 - Wilco EC driver

 - Maintainership change to new group repository

* tag 'tag-chrome-platform-for-v5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux:
  platform/chrome: fix wilco-ec dependencies
  platform/chrome: wilco_ec: Add RTC driver
  platform/chrome: wilco_ec: Add support for raw commands in debugfs
  platform/chrome: Add new driver for Wilco EC
  platform/chrome: cros_ec: Remove cros_ec dependency in lpc_mec
  MAINTAINERS: chrome-platform: change the git tree to a chrome-platform group git tree
  platform/chrome: cros_ec_sysfs: remove pr_fmt() define
  platform/chrome: cros_ec_lightbar: remove pr_fmt() define
  platform/chrome: cros_kbd_led_backlight: switch to SPDX identifier
  platform/chrome: cros_ec_spi: switch to SPDX identifier
  platform/chrome: cros_ec_proto: switch to SPDX identifier
  platform/chrome: cros_ec_lpc: switch to SPDX identifier
  platform/chrome: cros_ec_i2c: switch to SPDX identifier
  platform/chrome: cros_ec_vbc: switch to SPDX identifier
  platform/chrome: cros_ec_sysfs: switch to SPDX identifier
  platform/chrome: cros_ec_lightbar: switch to SPDX identifier
  platform/chrome: cros_ec_debugfs: switch to SPDX identifier
  platform/chrome: cromeos_pstore: switch to SPDX identifier
This commit is contained in:
Linus Torvalds 2019-03-12 09:46:32 -07:00
commit f47d633134
27 changed files with 1148 additions and 312 deletions

View file

@ -1864,4 +1864,15 @@ config RTC_DRV_GOLDFISH
Goldfish is a code name for the virtual platform developed by Google
for Android emulation.
config RTC_DRV_WILCO_EC
tristate "Wilco EC RTC"
depends on WILCO_EC
default m
help
If you say yes here, you get read/write support for the Real Time
Clock on the Wilco Embedded Controller (Wilco is a kind of Chromebook)
This can also be built as a module. If so, the module will
be named "rtc_wilco_ec".
endif # RTC_CLASS

View file

@ -177,6 +177,7 @@ obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o
obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o
obj-$(CONFIG_RTC_DRV_VRTC) += rtc-mrst.o
obj-$(CONFIG_RTC_DRV_VT8500) += rtc-vt8500.o
obj-$(CONFIG_RTC_DRV_WILCO_EC) += rtc-wilco-ec.o
obj-$(CONFIG_RTC_DRV_WM831X) += rtc-wm831x.o
obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o
obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o

177
drivers/rtc/rtc-wilco-ec.c Normal file
View file

@ -0,0 +1,177 @@
// SPDX-License-Identifier: GPL-2.0
/*
* RTC interface for Wilco Embedded Controller with R/W abilities
*
* Copyright 2018 Google LLC
*
* The corresponding platform device is typically registered in
* drivers/platform/chrome/wilco_ec/core.c
*/
#include <linux/bcd.h>
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/platform_data/wilco-ec.h>
#include <linux/rtc.h>
#include <linux/timekeeping.h>
#define EC_COMMAND_CMOS 0x7c
#define EC_CMOS_TOD_WRITE 0x02
#define EC_CMOS_TOD_READ 0x08
/**
* struct ec_rtc_read - Format of RTC returned by EC.
* @second: Second value (0..59)
* @minute: Minute value (0..59)
* @hour: Hour value (0..23)
* @day: Day value (1..31)
* @month: Month value (1..12)
* @year: Year value (full year % 100)
* @century: Century value (full year / 100)
*
* All values are presented in binary (not BCD).
*/
struct ec_rtc_read {
u8 second;
u8 minute;
u8 hour;
u8 day;
u8 month;
u8 year;
u8 century;
} __packed;
/**
* struct ec_rtc_write - Format of RTC sent to the EC.
* @param: EC_CMOS_TOD_WRITE
* @century: Century value (full year / 100)
* @year: Year value (full year % 100)
* @month: Month value (1..12)
* @day: Day value (1..31)
* @hour: Hour value (0..23)
* @minute: Minute value (0..59)
* @second: Second value (0..59)
* @weekday: Day of the week (0=Saturday)
*
* All values are presented in BCD.
*/
struct ec_rtc_write {
u8 param;
u8 century;
u8 year;
u8 month;
u8 day;
u8 hour;
u8 minute;
u8 second;
u8 weekday;
} __packed;
static int wilco_ec_rtc_read(struct device *dev, struct rtc_time *tm)
{
struct wilco_ec_device *ec = dev_get_drvdata(dev->parent);
u8 param = EC_CMOS_TOD_READ;
struct ec_rtc_read rtc;
struct wilco_ec_message msg = {
.type = WILCO_EC_MSG_LEGACY,
.flags = WILCO_EC_FLAG_RAW_RESPONSE,
.command = EC_COMMAND_CMOS,
.request_data = &param,
.request_size = sizeof(param),
.response_data = &rtc,
.response_size = sizeof(rtc),
};
int ret;
ret = wilco_ec_mailbox(ec, &msg);
if (ret < 0)
return ret;
tm->tm_sec = rtc.second;
tm->tm_min = rtc.minute;
tm->tm_hour = rtc.hour;
tm->tm_mday = rtc.day;
tm->tm_mon = rtc.month - 1;
tm->tm_year = rtc.year + (rtc.century * 100) - 1900;
tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year);
/* Don't compute day of week, we don't need it. */
tm->tm_wday = -1;
return 0;
}
static int wilco_ec_rtc_write(struct device *dev, struct rtc_time *tm)
{
struct wilco_ec_device *ec = dev_get_drvdata(dev->parent);
struct ec_rtc_write rtc;
struct wilco_ec_message msg = {
.type = WILCO_EC_MSG_LEGACY,
.flags = WILCO_EC_FLAG_RAW_RESPONSE,
.command = EC_COMMAND_CMOS,
.request_data = &rtc,
.request_size = sizeof(rtc),
};
int year = tm->tm_year + 1900;
/*
* Convert from 0=Sunday to 0=Saturday for the EC
* We DO need to set weekday because the EC controls battery charging
* schedules that depend on the day of the week.
*/
int wday = tm->tm_wday == 6 ? 0 : tm->tm_wday + 1;
int ret;
rtc.param = EC_CMOS_TOD_WRITE;
rtc.century = bin2bcd(year / 100);
rtc.year = bin2bcd(year % 100);
rtc.month = bin2bcd(tm->tm_mon + 1);
rtc.day = bin2bcd(tm->tm_mday);
rtc.hour = bin2bcd(tm->tm_hour);
rtc.minute = bin2bcd(tm->tm_min);
rtc.second = bin2bcd(tm->tm_sec);
rtc.weekday = bin2bcd(wday);
ret = wilco_ec_mailbox(ec, &msg);
if (ret < 0)
return ret;
return 0;
}
static const struct rtc_class_ops wilco_ec_rtc_ops = {
.read_time = wilco_ec_rtc_read,
.set_time = wilco_ec_rtc_write,
};
static int wilco_ec_rtc_probe(struct platform_device *pdev)
{
struct rtc_device *rtc;
rtc = devm_rtc_allocate_device(&pdev->dev);
if (IS_ERR(rtc))
return PTR_ERR(rtc);
rtc->ops = &wilco_ec_rtc_ops;
/* EC only supports this century */
rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
rtc->range_max = RTC_TIMESTAMP_END_2099;
rtc->owner = THIS_MODULE;
return rtc_register_device(rtc);
}
static struct platform_driver wilco_ec_rtc_driver = {
.driver = {
.name = "rtc-wilco-ec",
},
.probe = wilco_ec_rtc_probe,
};
module_platform_driver(wilco_ec_rtc_driver);
MODULE_ALIAS("platform:rtc-wilco-ec");
MODULE_AUTHOR("Nick Crews <[email protected]>");
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("Wilco EC RTC driver");