Skip to contentSkip to conversation

board: gateworks: venice: use common GSC driver

PATCH New Tim Harvey 1 participant 1 message Apr 14, 2022

Subsystems (3)
lore
Share & tools
lore

Tim Harvey

author
#0 lore raw

PATCH v4 1/1 board: gateworks: venice: use common GSC driver

Use the common GSC driver.

This allows us to do some additional cleanup:
- rename gsc{.c,.h} to eeprom{.c.h} for clarity
- collapse eeprom_get_dev
- remove unnecessary header files and alphabatize includes
- remove unnecessary check for clock-controller dt node

---
v4: rebase on top of v3 dm-serial patch and update commit log
v3: add to commit log about removing unnecessary check for
clock-controller dt node
v2: rebase on imx/master

---
 arch/arm/dts/imx8mm-venice-u-boot.dtsi     |   4 +
 arch/arm/dts/imx8mm-venice.dts             |   7 +
 arch/arm/dts/imx8mn-venice-u-boot.dtsi     |   4 +
 arch/arm/dts/imx8mn-venice.dts             |   7 +
 arch/arm/mach-imx/imx8m/Kconfig            |   4 +
 board/gateworks/venice/Makefile            |   2 +-
 board/gateworks/venice/eeprom.c            | 353 +++++++++++
 board/gateworks/venice/{gsc.h => eeprom.h} |  26 +-
 board/gateworks/venice/gsc.c               | 700 ---------------------
 board/gateworks/venice/spl.c               |  53 +-
 board/gateworks/venice/venice.c            |  27 +-
 configs/imx8mn_venice_defconfig            |   1 +
 12 files changed, 425 insertions(+), 763 deletions(-)
 create mode 100644 board/gateworks/venice/eeprom.c
 rename board/gateworks/venice/{gsc.h => eeprom.h} (55%)
 delete mode 100644 board/gateworks/venice/gsc.c
arch/arm/dts/imx8mm-venice-u-boot.dtsi +4 -0
index 42b2903f0409..c61c6de935fb 100644
@@ -57,6 +57,10 @@
 	u-boot,dm-spl;
 };
 
+&gsc {
+	u-boot,dm-spl;
+};
+
 &i2c2 {
 	u-boot,dm-spl;
 };
arch/arm/dts/imx8mm-venice.dts +7 -0
index 54505a03c6fa..39b030691e53 100644
@@ -27,6 +27,13 @@
 	pinctrl-0 = <&pinctrl_i2c1>;
 	status = "okay";
 
+	gsc: gsc@20 {
+		compatible = "gw,gsc";
+		reg = <0x20>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+	};
+
 	eeprom@51 {
 		compatible = "atmel,24c02";
 		reg = <0x51>;
arch/arm/dts/imx8mn-venice-u-boot.dtsi +4 -0
index 055406e77b30..4f23da356763 100644
@@ -94,6 +94,10 @@
 	u-boot,dm-spl;
 };
 
+&gsc {
+	u-boot,dm-spl;
+};
+
 &i2c2 {
 	u-boot,dm-spl;
 };
arch/arm/dts/imx8mn-venice.dts +7 -0
index e906a560581d..eeae225632d7 100644
@@ -27,6 +27,13 @@
 	pinctrl-0 = <&pinctrl_i2c1>;
 	status = "okay";
 
+	gsc: gsc@20 {
+		compatible = "gw,gsc";
+		reg = <0x20>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+	};
+
 	eeprom@51 {
 		compatible = "atmel,24c02";
 		reg = <0x51>;
arch/arm/mach-imx/imx8m/Kconfig +4 -0
index 55db25062a9b..1abf52611232 100644
@@ -97,6 +97,8 @@ config TARGET_IMX8MM_VENICE
 	select IMX8MM
 	select SUPPORT_SPL
 	select IMX8M_LPDDR4
+	select GATEWORKS_SC
+	select MISC
 
 config TARGET_KONTRON_MX8MM
 	bool "Kontron Electronics N80xx"
@@ -143,6 +145,8 @@ config TARGET_IMX8MN_VENICE
 	select IMX8MN
 	select SUPPORT_SPL
 	select IMX8M_LPDDR4
+	select GATEWORKS_SC
+	select MISC
 
 config TARGET_IMX8MP_EVK
 	bool "imx8mp LPDDR4 EVK board"
board/gateworks/venice/Makefile +1 -1
index b8b53fdc0e80..fbb716ee852d 100644
@@ -4,7 +4,7 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
-obj-y += venice.o gsc.o
+obj-y += venice.o eeprom.o
 
 ifdef CONFIG_SPL_BUILD
 obj-y += spl.o
board/gateworks/venice/eeprom.c new file +353 -0

353 lines not on this page · raw message

board/gateworks/venice/eeprom.h renamed from board/gateworks/venice/gsc.h +7 -19
similarity index 55%
rename from board/gateworks/venice/gsc.h
rename to board/gateworks/venice/eeprom.h
index b391b2e32684..37bfe76ad81e 100644
@@ -3,19 +3,8 @@
  * Copyright 2021 Gateworks Corporation
  */
 
-#ifndef _GSC_H_
-#define _GSC_H_
-
-/* I2C bus numbers */
-#define GSC_BUSNO			0
-#define BASEBOARD_EEPROM_BUSNO		1
-
-/* I2C slave addresses */
-#define GSC_SC_ADDR             0x20
-#define GSC_RTC_ADDR            0x68
-#define GSC_HWMON_ADDR          0x29
-#define GSC_EEPROM_ADDR         0x51
-#define BASEBOARD_EEPROM_ADDR	0x52
+#ifndef _VENICE_EEPROM_H_
+#define _VENICE_EEPROM_H_
 
 struct venice_board_info {
 	u8 mac[6];		/* 0x00: MAC base */
@@ -35,11 +24,10 @@ struct venice_board_info {
 	u8 chksum[2];	/* 0x4E */
 };
 
-int gsc_init(int quiet);
-int gsc_hwmon(void);
-const char *gsc_get_model(void);
-const char *gsc_get_dtb_name(int level, char *buf, int len);
-int gsc_getmac(int index, uint8_t *enetaddr);
-uint32_t gsc_get_serial(void);
+int eeprom_init(int quiet);
+const char *eeprom_get_model(void);
+const char *eeprom_get_dtb_name(int level, char *buf, int len);
+int eeprom_getmac(int index, uint8_t *enetaddr);
+uint32_t eeprom_get_serial(void);
 
 #endif
board/gateworks/venice/gsc.c deleted +0 -700

700 lines not on this page · raw message

board/gateworks/venice/spl.c +29 -24

101 lines not on this page · raw message

board/gateworks/venice/venice.c +8 -19
index 425c69056da5..b1828f4f187a 100644
@@ -3,21 +3,12 @@
  * Copyright 2021 Gateworks Corporation
  */
 
-#include <common.h>
 #include <init.h>
 #include <led.h>
-#include <linux/delay.h>
 #include <miiphy.h>
-#include <netdev.h>
-
-#include <asm/arch/clock.h>
 #include <asm/arch/sys_proto.h>
-#include <asm/io.h>
-#include <asm/unaligned.h>
-
-#include "gsc.h"
 
-DECLARE_GLOBAL_DATA_PTR;
+#include "eeprom.h"
 
 int board_phys_sdram_size(phys_size_t *size)
 {
@@ -37,7 +28,7 @@ int board_fit_config_name_match(const char *name)
 	char buf[32];
 
 	do {
-		dtb = gsc_get_dtb_name(i++, buf, sizeof(buf));
+		dtb = eeprom_get_dtb_name(i++, buf, sizeof(buf));
 		if (!strcmp(dtb, name)) {
 			if (!init++)
 				printf("DTB     : %s\n", name);
@@ -100,13 +91,11 @@ int board_phy_config(struct phy_device *phydev)
 
 int board_init(void)
 {
-	gsc_init(1);
+	eeprom_init(1);
 
 	if (IS_ENABLED(CONFIG_FEC_MXC))
 		setup_fec();
 
-	gsc_hwmon();
-
 	return 0;
 }
 
@@ -122,13 +111,13 @@ int board_late_init(void)
 
 	/* Set board serial/model */
 	if (!env_get("serial#"))
-		env_set_ulong("serial#", gsc_get_serial());
-	env_set("model", gsc_get_model());
+		env_set_ulong("serial#", eeprom_get_serial());
+	env_set("model", eeprom_get_model());
 
 	/* Set fdt_file vars */
 	i = 0;
 	do {
-		str = gsc_get_dtb_name(i, fdt, sizeof(fdt));
+		str = eeprom_get_dtb_name(i, fdt, sizeof(fdt));
 		if (str) {
 			sprintf(env, "fdt_file%d", i + 1);
 			strcat(fdt, ".dtb");
@@ -146,7 +135,7 @@ int board_late_init(void)
 			sprintf(env, "ethaddr");
 		str = env_get(env);
 		if (!str) {
-			ret = gsc_getmac(i, enetaddr);
+			ret = eeprom_getmac(i, enetaddr);
 			if (!ret)
 				eth_env_set_enetaddr(env, enetaddr);
 		}
@@ -166,7 +155,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 	int off;
 
 	/* set board model dt prop */
-	fdt_setprop_string(blob, 0, "board", gsc_get_model());
+	fdt_setprop_string(blob, 0, "board", eeprom_get_model());
 
 	/* update temp thresholds */
 	off = fdt_path_offset(blob, "/thermal-zones/cpu-thermal/trips");
configs/imx8mn_venice_defconfig +1 -0
index ff926dac0e18..d0fe56eacf26 100644
@@ -13,6 +13,7 @@ CONFIG_SPL_TEXT_BASE=0x912000
 CONFIG_TARGET_IMX8MN_VENICE=y
 CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y
+CONFIG_SPL_DRIVERS_MISC=y
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0xff8000
 CONFIG_SPL_IMX_ROMAPI_LOADADDR=0x48000000
Signature · 1 line
2.17.1