[coreboot-gerrit] Change in coreboot[master]: drivers/i2c/ck505: Add generic driver to configure clockgen

Arthur Heymans (Code Review) gerrit at coreboot.org
Tue Jun 6 09:48:31 CEST 2017


Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/20042


Change subject: drivers/i2c/ck505: Add generic driver to configure clockgen
......................................................................

drivers/i2c/ck505: Add generic driver to configure clockgen

Based on the ics/954309 driver but made more generic to accommodate
for clockgens with a different amount of registers.

Change-Id: Ie43c4de7891a39f2f443e78213ecd688134e68d7
Signed-off-by: Arthur Heymans <arthur at aheymans.xyz>
---
A src/drivers/i2c/ck505/Kconfig
A src/drivers/i2c/ck505/Makefile.inc
R src/drivers/i2c/ck505/chip.h
A src/drivers/i2c/ck505/ck505.c
D src/drivers/ics/954309/Kconfig
D src/drivers/ics/954309/Makefile.inc
D src/drivers/ics/954309/ics954309.c
M src/mainboard/lenovo/t60/Kconfig
M src/mainboard/lenovo/t60/devicetree.cb
M src/mainboard/lenovo/x60/Kconfig
M src/mainboard/lenovo/x60/devicetree.cb
11 files changed, 80 insertions(+), 112 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/42/20042/1

diff --git a/src/drivers/i2c/ck505/Kconfig b/src/drivers/i2c/ck505/Kconfig
new file mode 100644
index 0000000..f3fb22f
--- /dev/null
+++ b/src/drivers/i2c/ck505/Kconfig
@@ -0,0 +1,5 @@
+config DRIVERS_I2C_CK505
+	bool
+
+config CK505_NREGS
+	int
diff --git a/src/drivers/i2c/ck505/Makefile.inc b/src/drivers/i2c/ck505/Makefile.inc
new file mode 100644
index 0000000..5ccf4a8
--- /dev/null
+++ b/src/drivers/i2c/ck505/Makefile.inc
@@ -0,0 +1 @@
+ramstage-$(CONFIG_DRIVERS_I2C_CK505) += ck505.c
diff --git a/src/drivers/ics/954309/chip.h b/src/drivers/i2c/ck505/chip.h
similarity index 78%
rename from src/drivers/ics/954309/chip.h
rename to src/drivers/i2c/ck505/chip.h
index cc52857..7026abb 100644
--- a/src/drivers/ics/954309/chip.h
+++ b/src/drivers/i2c/ck505/chip.h
@@ -14,17 +14,13 @@
  * GNU General Public License for more details.
  */
 
-struct drivers_ics_954309_config {
-	u8 reg0;
-	u8 reg1;
-	u8 reg2;
-	u8 reg3;
-	u8 reg4;
-	u8 reg5;
-	u8 reg6;
-	u8 reg7;
-	u8 reg8;
-	u8 reg9;
-	u8 reg10;
-	u8 reg11;
+
+#ifndef DRIVERS_CK505_CHIP_H
+#define DRIVERS_CK505_CHIP_H
+
+struct drivers_i2c_ck505_config {
+	u8 nregs;
+	u8 regs[128];
 };
+
+#endif
diff --git a/src/drivers/i2c/ck505/ck505.c b/src/drivers/i2c/ck505/ck505.c
new file mode 100644
index 0000000..bf3942a
--- /dev/null
+++ b/src/drivers/i2c/ck505/ck505.c
@@ -0,0 +1,54 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2011 Sven Schnelle <svens at stackframe.org>
+ *
+ * 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; version 2 of
+ * the License.
+ *
+ * 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.
+ */
+
+#include <console/console.h>
+#include <device/device.h>
+#include <device/smbus.h>
+#include <device/pci.h>
+#include <device/pci_ids.h>
+#include <device/pci_ops.h>
+#include <cpu/x86/msr.h>
+#include "chip.h"
+#include <string.h>
+
+static void ck505_init(struct device *dev)
+{
+	struct drivers_i2c_ck505_config *config;
+
+	if (!dev->enabled || dev->path.type != DEVICE_PATH_I2C)
+		return;
+
+	config = dev->chip_info;
+
+	smbus_block_write(dev, 0, config->nregs, config->regs);
+}
+
+static struct device_operations ck505_operations = {
+	.read_resources		= DEVICE_NOOP,
+	.set_resources		= DEVICE_NOOP,
+	.enable_resources	= DEVICE_NOOP,
+	.init			= ck505_init,
+};
+
+static void enable_dev(struct device *dev)
+{
+	dev->ops = &ck505_operations;
+}
+
+struct chip_operations drivers_ics_ck505_ops = {
+	CHIP_NAME("CK505 Clock generator")
+	.enable_dev = enable_dev,
+};
diff --git a/src/drivers/ics/954309/Kconfig b/src/drivers/ics/954309/Kconfig
deleted file mode 100644
index 43840a3..0000000
--- a/src/drivers/ics/954309/Kconfig
+++ /dev/null
@@ -1,2 +0,0 @@
-config DRIVERS_ICS_954309
-	bool
diff --git a/src/drivers/ics/954309/Makefile.inc b/src/drivers/ics/954309/Makefile.inc
deleted file mode 100644
index 1c66a8c..0000000
--- a/src/drivers/ics/954309/Makefile.inc
+++ /dev/null
@@ -1 +0,0 @@
-ramstage-$(CONFIG_DRIVERS_ICS_954309) += ics954309.c
diff --git a/src/drivers/ics/954309/ics954309.c b/src/drivers/ics/954309/ics954309.c
deleted file mode 100644
index 5911609..0000000
--- a/src/drivers/ics/954309/ics954309.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2011 Sven Schnelle <svens at stackframe.org>
- *
- * 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; version 2 of
- * the License.
- *
- * 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.
- */
-
-#include <console/console.h>
-#include <device/device.h>
-#include <device/smbus.h>
-#include <device/pci.h>
-#include <device/pci_ids.h>
-#include <device/pci_ops.h>
-#include <cpu/x86/msr.h>
-#include "chip.h"
-#include <string.h>
-
-static void ics954309_init(struct device *dev)
-{
-	struct drivers_ics_954309_config *config;
-	u8 initdata[12];
-
-	if (!dev->enabled || dev->path.type != DEVICE_PATH_I2C)
-		return;
-
-	config = dev->chip_info;
-
-	initdata[0] = config->reg0;
-	initdata[1] = config->reg1;
-	initdata[2] = config->reg2;
-	initdata[3] = config->reg3;
-	initdata[4] = config->reg4;
-	initdata[5] = config->reg5;
-	initdata[6] = config->reg6;
-	initdata[7] = config->reg7;
-	initdata[8] = config->reg8;
-	initdata[9] = config->reg9;
-	initdata[10] = config->reg10;
-	initdata[11] = config->reg11;
-
-	smbus_block_write(dev, 0, 12, initdata);
-}
-
-static struct device_operations ics954309_operations = {
-        .read_resources   = DEVICE_NOOP,
-        .set_resources    = DEVICE_NOOP,
-        .enable_resources = DEVICE_NOOP,
-        .init             = ics954309_init,
-};
-
-static void enable_dev(struct device *dev)
-{
-	dev->ops = &ics954309_operations;
-}
-
-struct chip_operations drivers_ics_954309_ops = {
-	CHIP_NAME("ICS 954309 Clock generator")
-	.enable_dev = enable_dev,
-};
diff --git a/src/mainboard/lenovo/t60/Kconfig b/src/mainboard/lenovo/t60/Kconfig
index 3c77a8a..960be0e 100644
--- a/src/mainboard/lenovo/t60/Kconfig
+++ b/src/mainboard/lenovo/t60/Kconfig
@@ -12,7 +12,7 @@
 	select SOUTHBRIDGE_TI_PCI1X2X
 	select EC_LENOVO_PMH7
 	select EC_LENOVO_H8
-	select DRIVERS_ICS_954309
+	select DRIVERS_I2C_CK505
 	select HAVE_OPTION_TABLE
 	select INTEL_INT15
 	select HAVE_MP_TABLE
diff --git a/src/mainboard/lenovo/t60/devicetree.cb b/src/mainboard/lenovo/t60/devicetree.cb
index 6ad054c..72c64de 100644
--- a/src/mainboard/lenovo/t60/devicetree.cb
+++ b/src/mainboard/lenovo/t60/devicetree.cb
@@ -209,19 +209,10 @@
 			end
 			device pci 1f.3 on # SMBUS
 				subsystemid 0x17aa 0x200f
-				chip drivers/ics/954309
-					register "reg0" = "0x2e"
-					register "reg1" = "0xf7"
-					register "reg2" = "0x3c"
-					register "reg3" = "0x20"
-					register "reg4" = "0x01"
-					register "reg5" = "0x00"
-					register "reg6" = "0x1b"
-					register "reg7" = "0x01"
-					register "reg8" = "0x54"
-					register "reg9" = "0xff"
-					register "reg10" = "0xff"
-					register "reg11" = "0x07"
+					register "nregs" = "12"
+					register "regs" = "{ 0x2e, 0xf7, 0x3c,
+						 0x20, 0x01, 0x00, 0x1b, 0x01,
+						 0x54, 0xff, 0xff, 0x07 }"
 					device i2c 69 on end
 				end
 			        # eeprom, 8 virtual devices, same chip
diff --git a/src/mainboard/lenovo/x60/Kconfig b/src/mainboard/lenovo/x60/Kconfig
index 1d55f98..91cb9ea 100644
--- a/src/mainboard/lenovo/x60/Kconfig
+++ b/src/mainboard/lenovo/x60/Kconfig
@@ -12,7 +12,7 @@
 	select SUPERIO_NSC_PC87392
 	select EC_LENOVO_PMH7
 	select EC_LENOVO_H8
-	select DRIVERS_ICS_954309
+	select DRIVERS_I2C_CK505
 	select HAVE_OPTION_TABLE
 	select INTEL_INT15
 	select HAVE_CMOS_DEFAULT
diff --git a/src/mainboard/lenovo/x60/devicetree.cb b/src/mainboard/lenovo/x60/devicetree.cb
index 28b63d3..51b4ec8 100644
--- a/src/mainboard/lenovo/x60/devicetree.cb
+++ b/src/mainboard/lenovo/x60/devicetree.cb
@@ -191,19 +191,11 @@
 			end
 			device pci 1f.3 on # SMBUS
 				subsystemid 0x17aa 0x200f
-				chip drivers/ics/954309
-					register "reg0" = "0x2e"
-					register "reg1" = "0xf7"
-					register "reg2" = "0x3c"
-					register "reg3" = "0x20"
-					register "reg4" = "0x01"
-					register "reg5" = "0x00"
-					register "reg6" = "0x1b"
-					register "reg7" = "0x01"
-					register "reg8" = "0x54"
-					register "reg9" = "0xff"
-					register "reg10" = "0xff"
-					register "reg11" = "0x07"
+				chip drivers/i2c/ck505
+					register "nregs" = "12"
+					register "regs" = "{ 0x2e, 0xf7, 0x3c,
+						 0x20, 0x01, 0x00, 0x1b, 0x01,
+						 0x54, 0xff, 0xff, 0x07 }"
 					device i2c 69 on end
 				end
 			        # eeprom, 8 virtual devices, same chip

-- 
To view, visit https://review.coreboot.org/20042
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie43c4de7891a39f2f443e78213ecd688134e68d7
Gerrit-Change-Number: 20042
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur at aheymans.xyz>



More information about the coreboot-gerrit mailing list