aboutsummaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorWerner Zeh <werner.zeh@siemens.com>2020-11-05 10:41:26 +0100
committerWerner Zeh <werner.zeh@siemens.com>2020-11-12 12:46:35 +0000
commitb64db833d6db452c28e410f869f6527fd6971228 (patch)
tree7dbabeeac718b6bdcbad4ad118548d54b2475581 /src/drivers
parent81547dd5460ad220e398c531b5d43fd9e8b90c73 (diff)
drivers/i2c/rx6110sa: Add basic ACPI support
This patch adds basic ACPI support for the RTC so that the OS is able to use this RTC via the ACPI interface. If the Linux kernel is able to find the RTC in ACPI scope, you should see the following lines in dmesg, where [n] is an enumerated number: rx6110 i2c-RX6110SA:00: rtc core: registered RX6110SA:00 as rtc[n] rtc rtc[n]: Update timer was detected Change-Id: I9b319e3088e6511592075b055f8fa3e2aedaa209 Signed-off-by: Werner Zeh <werner.zeh@siemens.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/47235 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/i2c/rx6110sa/chip.h1
-rw-r--r--src/drivers/i2c/rx6110sa/rx6110sa.c67
-rw-r--r--src/drivers/i2c/rx6110sa/rx6110sa.h4
3 files changed, 70 insertions, 2 deletions
diff --git a/src/drivers/i2c/rx6110sa/chip.h b/src/drivers/i2c/rx6110sa/chip.h
index 46ef7f1e3a..4df95806ac 100644
--- a/src/drivers/i2c/rx6110sa/chip.h
+++ b/src/drivers/i2c/rx6110sa/chip.h
@@ -3,6 +3,7 @@
#include "rx6110sa.h"
struct drivers_i2c_rx6110sa_config {
+ unsigned int bus_speed; /* Bus clock in Hz (default 400 kHz)*/
/* The day (of the week) is indicated by 7 bits, bit 0 to bit 6. */
unsigned char user_weekday; /* User day of the week to set */
unsigned char user_day; /* User day to set */
diff --git a/src/drivers/i2c/rx6110sa/rx6110sa.c b/src/drivers/i2c/rx6110sa/rx6110sa.c
index ca39bdb1bc..2b8b9b28f0 100644
--- a/src/drivers/i2c/rx6110sa/rx6110sa.c
+++ b/src/drivers/i2c/rx6110sa/rx6110sa.c
@@ -1,7 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0-only */
-#include <device/i2c_bus.h>
+#include <acpi/acpi_device.h>
+#include <acpi/acpigen.h>
#include <device/device.h>
+#include <device/i2c.h>
+#include <device/i2c_bus.h>
#include <version.h>
#include <console/console.h>
#include <bcd.h>
@@ -163,11 +166,71 @@ static void rx6110sa_init(struct device *dev)
rx6110sa_write(dev, CTRL_REG, reg);
}
+#if CONFIG(HAVE_ACPI_TABLES)
+static void rx6110sa_fill_ssdt(const struct device *dev)
+{
+ struct drivers_i2c_rx6110sa_config *config = dev->chip_info;
+ const char *scope = acpi_device_scope(dev);
+ enum i2c_speed bus_speed;
+
+ if (!scope)
+ return;
+
+ switch (config->bus_speed) {
+ case I2C_SPEED_STANDARD:
+ case I2C_SPEED_FAST:
+ bus_speed = config->bus_speed;
+ break;
+ default:
+ printk(BIOS_INFO, "%s: Bus speed unsupported, fall back to %d kHz!\n",
+ dev_path(dev), I2C_SPEED_STANDARD / 1000);
+ bus_speed = I2C_SPEED_STANDARD;
+ break;
+ }
+
+ struct acpi_i2c i2c = {
+ .address = dev->path.i2c.device,
+ .mode_10bit = dev->path.i2c.mode_10bit,
+ .speed = bus_speed,
+ .resource = scope,
+ };
+
+ /* Device */
+ acpigen_write_scope(scope);
+ acpigen_write_device(acpi_device_name(dev));
+ acpigen_write_name_string("_HID", RX6110SA_HID_NAME);
+ acpigen_write_name_string("_DDN", RX6110SA_HID_DESC);
+ acpigen_write_STA(acpi_device_status(dev));
+
+ /* Resources */
+ acpigen_write_name("_CRS");
+ acpigen_write_resourcetemplate_header();
+ acpi_device_write_i2c(&i2c);
+
+ acpigen_write_resourcetemplate_footer();
+
+ acpigen_pop_len(); /* Device */
+ acpigen_pop_len(); /* Scope */
+
+ printk(BIOS_INFO, "%s: %s at %s\n", acpi_device_path(dev),
+ dev->chip_ops->name, dev_path(dev));
+}
+
+static const char *rx6110sa_acpi_name(const struct device *dev)
+{
+ return RX6110SA_ACPI_NAME;
+}
+#endif
+
static struct device_operations rx6110sa_ops = {
.read_resources = noop_read_resources,
.set_resources = noop_set_resources,
.init = rx6110sa_init,
- .final = rx6110sa_final
+ .final = rx6110sa_final,
+#if CONFIG(HAVE_ACPI_TABLES)
+ .acpi_name = rx6110sa_acpi_name,
+ .acpi_fill_ssdt = rx6110sa_fill_ssdt,
+#endif
};
static void rx6110sa_enable(struct device *dev)
diff --git a/src/drivers/i2c/rx6110sa/rx6110sa.h b/src/drivers/i2c/rx6110sa/rx6110sa.h
index 187bad424f..73f43b3a5b 100644
--- a/src/drivers/i2c/rx6110sa/rx6110sa.h
+++ b/src/drivers/i2c/rx6110sa/rx6110sa.h
@@ -7,6 +7,10 @@
#define RX6110SA_SLAVE_ADR 0x32
#define RX6110SA_I2C_CONTROLLER 0
+#define RX6110SA_ACPI_NAME "ERX6"
+#define RX6110SA_HID_NAME "RX6110SA"
+#define RX6110SA_HID_DESC "Real Time Clock"
+
/* Register layout */
#define SECOND_REG 0x10
#define MINUTE_REG 0x11