From 4f1f672d9e5c0fb26f3d54f31ae76b93580efcc0 Mon Sep 17 00:00:00 2001
From: Gabor Juhos <juhosg@openwrt.org>
Date: Wed, 26 Jan 2011 20:35:46 +0000
Subject: generic: rtl8366s: allow initial register values to be passed via
 platform_data

SVN-Revision: 25120
---
 target/linux/generic/files/drivers/net/phy/rtl8366s.c | 11 +++++++++++
 target/linux/generic/files/include/linux/rtl8366s.h   |  7 +++++++
 2 files changed, 18 insertions(+)

(limited to 'target')

diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366s.c b/target/linux/generic/files/drivers/net/phy/rtl8366s.c
index 3b7fcce329..7e72164131 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366s.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366s.c
@@ -251,8 +251,19 @@ static int rtl8366s_reset_chip(struct rtl8366_smi *smi)
 
 static int rtl8366s_hw_init(struct rtl8366_smi *smi)
 {
+	struct rtl8366s_platform_data *pdata;
 	int err;
 
+	pdata = smi->parent->platform_data;
+	if (pdata->num_initvals && pdata->initvals) {
+		unsigned i;
+
+		dev_info(smi->parent, "applying initvals\n");
+		for (i = 0; i < pdata->num_initvals; i++)
+			REG_WR(smi, pdata->initvals[i].reg,
+			       pdata->initvals[i].val);
+	}
+
 	/* set maximum packet length to 1536 bytes */
 	REG_RMW(smi, RTL8366S_SGCR, RTL8366S_SGCR_MAX_LENGTH_MASK,
 		RTL8366S_SGCR_MAX_LENGTH_1536);
diff --git a/target/linux/generic/files/include/linux/rtl8366s.h b/target/linux/generic/files/include/linux/rtl8366s.h
index 09173ec200..7d5daa4817 100644
--- a/target/linux/generic/files/include/linux/rtl8366s.h
+++ b/target/linux/generic/files/include/linux/rtl8366s.h
@@ -13,9 +13,16 @@
 
 #define RTL8366S_DRIVER_NAME	"rtl8366s"
 
+struct rtl8366s_initval {
+	unsigned	reg;
+	u16		val;
+};
+
 struct rtl8366s_platform_data {
 	unsigned	gpio_sda;
 	unsigned	gpio_sck;
+	unsigned	num_initvals;
+	struct rtl8366s_initval *initvals;
 };
 
 #endif /*  _RTL8366_SMI_H */
-- 
cgit v1.2.3