From 09e8fb0200e5ec4c8bc122e69cc42d778b246bb5 Mon Sep 17 00:00:00 2001
From: FUKAUMI Naoki <naobsd@gmail.com>
Date: Sat, 18 Oct 2014 01:38:11 +0900
Subject: [PATCH] Hotack T031

---
 kernel/arch/arm/boot/dts/rk3288-box.dts            | 24 +++++------
 ...box_defconfig => rockchip_box_ap6330_defconfig} |  4 +-
 kernel/arch/arm/configs/rockchip_box_defconfig     |  2 +-
 kernel/drivers/input/remotectl/rkxx_remotectl.c    | 46 ++++++++++++++++++++++
 kernel/drivers/net/ethernet/rockchip/eth_mac.c     |  2 -
 .../net/ethernet/rockchip/gmac/stmmac_main.c       |  2 +
 kernel/drivers/regulator/act8846.c                 | 26 ++++++++++++
 kernel/include/linux/regulator/act8846.h           |  1 +
 8 files changed, 90 insertions(+), 17 deletions(-)
 copy kernel/arch/arm/configs/{rockchip_box_defconfig => rockchip_box_ap6330_defconfig} (99%)
 mode change 100755 => 100644
 mode change 100755 => 100644 kernel/arch/arm/configs/rockchip_box_defconfig

diff --git a/kernel/arch/arm/boot/dts/rk3288-box.dts b/kernel/arch/arm/boot/dts/rk3288-box.dts
index 02d26b4..dbffd0b 100755
--- a/kernel/arch/arm/boot/dts/rk3288-box.dts
+++ b/kernel/arch/arm/boot/dts/rk3288-box.dts
@@ -130,8 +130,8 @@
 
 	rkxx-remotectl{
 		compatible = "rockchip,remotectl";
-		module-gpios = <&gpio0 GPIO_A6 GPIO_ACTIVE_LOW>;
-		status = "disabled";
+		module-gpios = <&gpio7 GPIO_A0 GPIO_ACTIVE_LOW>,<&gpio0 GPIO_B5 GPIO_ACTIVE_HIGH>;
+		status = "okay";
 	};
 
 	usb_control {
@@ -153,15 +153,15 @@
 	phy-mode = "rgmii";
 	clock_in_out = "input";
 	tx_delay = <0x30>;
-	rx_delay = <0x10>;
+	rx_delay = <0x18>;
 };
 
 &pinctrl {
 	//used for init some gpio
 	
-	init-gpios = <&gpio8 GPIO_A1 GPIO_ACTIVE_HIGH
+	/*init-gpios = <&gpio8 GPIO_A1 GPIO_ACTIVE_HIGH
 		&gpio7 GPIO_B1 GPIO_ACTIVE_HIGH		
-		&gpio4 GPIO_B0 GPIO_ACTIVE_HIGH>;
+		&gpio4 GPIO_B0 GPIO_ACTIVE_HIGH>;*/
 	gpio0_gpio {
 			gpio0_c2: gpio0-c2 {
 				rockchip,pins = <GPIO0_C2>;
@@ -504,13 +504,13 @@
 };
 
 &adc {
-	status = "disabled";
+	status = "okay";
 
 	key {
 		compatible = "rockchip,key";
-		/*
-		io-channels = <&adc 1>;
 		
+		io-channels = <&adc 1>;
+		/*
 		vol-up-key {
 			linux,code = <115>;
 			label = "volume up";
@@ -606,7 +606,7 @@
 		200000 1075000
 		300000 1075000		
 		456000 1125000
-		533000 1150000
+		456000 1150000
 		>;
 
 	freq-table = <
@@ -615,7 +615,7 @@
 		SYS_STATUS_SUSPEND	200000
 		//SYS_STATUS_VIDEO_1080P  240000
 		SYS_STATUS_VIDEO_4K     456000
-		SYS_STATUS_PERFORMANCE  533000
+		SYS_STATUS_PERFORMANCE  456000
 		//SYS_STATUS_BOOST	324000
 		//SYS_STATUS_ISP		400000
 		>;
@@ -623,14 +623,14 @@
 		240000
 		324000
 		456000
-		528000
+		456000
 		>;
 	auto-freq=<0>;
 	status="okay";
 };
 /include/ "act8846.dtsi"
 &act8846 {
-	gpios =<&gpio7 GPIO_A1 GPIO_ACTIVE_LOW>,<&gpio0 GPIO_B2 GPIO_ACTIVE_HIGH>;
+	gpios =<&gpio7 GPIO_A1 GPIO_ACTIVE_LOW>,<&gpio7 GPIO_A2 GPIO_ACTIVE_HIGH>,<&gpio7 GPIO_B6 GPIO_ACTIVE_HIGH>;
 	act8846,system-power-controller;
 
 	regulators {
diff --git a/kernel/arch/arm/configs/rockchip_box_defconfig b/kernel/arch/arm/configs/rockchip_box_ap6330_defconfig
old mode 100755
new mode 100644
similarity index 99%
copy from kernel/arch/arm/configs/rockchip_box_defconfig
copy to kernel/arch/arm/configs/rockchip_box_ap6330_defconfig
index bab3f6e..ff71445
--- a/kernel/arch/arm/configs/rockchip_box_defconfig
+++ b/kernel/arch/arm/configs/rockchip_box_ap6330_defconfig
@@ -270,8 +270,9 @@ CONFIG_USB_HSO=y
 CONFIG_USB_NET_INT51X1=y
 CONFIG_USB_IPHETH=y
 CONFIG_USB_SIERRA_NET=y
+# CONFIG_RTL_WIRELESS_SOLUTION is not set
 CONFIG_RKWIFI=y
-CONFIG_AP6335=y
+CONFIG_AP6330=y
 # CONFIG_INPUT_MOUSEDEV is not set
 CONFIG_INPUT_EVDEV=y
 CONFIG_INPUT_KEYRESET=y
@@ -381,7 +382,6 @@ CONFIG_SND_VERBOSE_PRINTK=y
 CONFIG_SND_USB_AUDIO=y
 CONFIG_SND_SOC=y
 CONFIG_SND_RK_SOC=y
-CONFIG_SND_RK_SOC_HDMI_I2S=y
 CONFIG_SND_RK_SOC_RK1000=y
 CONFIG_HID_BATTERY_STRENGTH=y
 CONFIG_HIDRAW=y
diff --git a/kernel/arch/arm/configs/rockchip_box_defconfig b/kernel/arch/arm/configs/rockchip_box_defconfig
old mode 100755
new mode 100644
index bab3f6e..b0205c7
--- a/kernel/arch/arm/configs/rockchip_box_defconfig
+++ b/kernel/arch/arm/configs/rockchip_box_defconfig
@@ -270,6 +270,7 @@ CONFIG_USB_HSO=y
 CONFIG_USB_NET_INT51X1=y
 CONFIG_USB_IPHETH=y
 CONFIG_USB_SIERRA_NET=y
+# CONFIG_RTL_WIRELESS_SOLUTION is not set
 CONFIG_RKWIFI=y
 CONFIG_AP6335=y
 # CONFIG_INPUT_MOUSEDEV is not set
@@ -381,7 +382,6 @@ CONFIG_SND_VERBOSE_PRINTK=y
 CONFIG_SND_USB_AUDIO=y
 CONFIG_SND_SOC=y
 CONFIG_SND_RK_SOC=y
-CONFIG_SND_RK_SOC_HDMI_I2S=y
 CONFIG_SND_RK_SOC_RK1000=y
 CONFIG_HID_BATTERY_STRENGTH=y
 CONFIG_HIDRAW=y
diff --git a/kernel/drivers/input/remotectl/rkxx_remotectl.c b/kernel/drivers/input/remotectl/rkxx_remotectl.c
index e7d43ef..0cf7b89 100755
--- a/kernel/drivers/input/remotectl/rkxx_remotectl.c
+++ b/kernel/drivers/input/remotectl/rkxx_remotectl.c
@@ -203,6 +203,40 @@ static struct rkxx_remote_key_table remote_key_table_sunchip_ff[] = {
     {0xE8, KEY_SEARCH},     // search
 };
 
+static struct rkxx_remote_key_table remote_key_table_chuangsiqi_40bf[] = {
+    {0xea, KEY_F17},	// web
+    {0xda, KEY_F18},	// tv
+    {0xca, KEY_F20},	// file
+    {0x4a, KEY_F19},	// set
+    {0x9a, KEY_HOME},	// home
+    {0xd8, KEY_BACK},	// back
+    {0x78, KEY_REPLY},	// ok
+    {0x60, KEY_UP},	// up
+    {0xf8, KEY_DOWN},	// down
+    {0xc2, KEY_MUTE},	// mute
+    {0xba, KEY_LEFT},	// left
+    {0x3a, KEY_RIGHT},	// right
+    {0x22, KEY_VOLUMEUP},	// vol+
+    {0x68, KEY_VOLUMEDOWN},	// vol-
+    {0x58, KEY_POWER},	// power
+    {0x1a, KEY_MENU},	// menu
+    {0x80, KEY_1},	// 1
+    {0x40, KEY_2},	// 2
+    {0xc0, KEY_3},	// 3
+    {0x20, KEY_4},	// 4
+    {0xa0, KEY_5},	// 5
+    {0xc8, KEY_6},	// 6
+    {0xe0, KEY_7},	// 7
+    {0x10, KEY_8},	// 8
+    {0x90, KEY_9},	// 9
+    {0x00, KEY_0},	// 0
+    {0x30, KEY_DELETE},	// del
+    {0xaa, 0x192},	// play/pause
+    {0x2a, 0x190},	// prev
+    {0xe8, 0x191},	// next
+    {0xd0, 0x184},	// mouse
+};
+
 suspend_state_t get_suspend_state(void)
 {
 	return 0;
@@ -221,6 +255,11 @@ static struct rkxx_remotectl_button remotectl_button[] =
        .nbuttons =  22, 
        .key_table = &remote_key_table_meiyu_202[0],
     },
+    {
+       .usercode = 0x40bf,
+       .nbuttons = 31,
+       .key_table = &remote_key_table_chuangsiqi_40bf[0],
+    },
 };
 
 
@@ -525,6 +564,7 @@ static int remotectl_probe(struct platform_device *pdev)
     struct rkxx_remotectl_drvdata *ddata;
     struct input_dev *input;
     unsigned int gpio;
+    unsigned int led;
     int i, j;
     int irq;
     int error = 0;
@@ -604,6 +644,12 @@ static int remotectl_probe(struct platform_device *pdev)
     
     tasklet_init(&ddata->remote_tasklet, remotectl_do_something, (unsigned long)ddata);
     
+    led = of_get_named_gpio(node, "module-gpios", 1);
+    if (gpio_is_valid(led) && gpio_request(led, NULL) == 0) {
+        gpio_direction_output(led, 1);
+        gpio_free(led);
+    }
+
     for (j=0;j<sizeof(remotectl_button)/sizeof(struct rkxx_remotectl_button);j++){ 
     	printk("remotectl probe j=0x%x\n",j);
 		for (i = 0; i < remotectl_button[j].nbuttons; i++) {
diff --git a/kernel/drivers/net/ethernet/rockchip/eth_mac.c b/kernel/drivers/net/ethernet/rockchip/eth_mac.c
index 102f712..eefa420 100755
--- a/kernel/drivers/net/ethernet/rockchip/eth_mac.c
+++ b/kernel/drivers/net/ethernet/rockchip/eth_mac.c
@@ -70,7 +70,6 @@ int eth_mac_idb(u8 *eth_mac)
 	return 0;
 }
 
-#if 0
 /**
 *大写转小写
 *
@@ -191,4 +190,3 @@ int eth_mac_wifi(u8 *eth_mac){
 	
 }
 
-#endif
diff --git a/kernel/drivers/net/ethernet/rockchip/gmac/stmmac_main.c b/kernel/drivers/net/ethernet/rockchip/gmac/stmmac_main.c
index 658a610..c9ae187 100755
--- a/kernel/drivers/net/ethernet/rockchip/gmac/stmmac_main.c
+++ b/kernel/drivers/net/ethernet/rockchip/gmac/stmmac_main.c
@@ -1576,6 +1576,8 @@ static void stmmac_check_ether_addr(struct stmmac_priv *priv)
 		if (!is_valid_ether_addr(priv->dev->dev_addr))
 			eth_mac_idb(priv->dev->dev_addr);
 		if (!is_valid_ether_addr(priv->dev->dev_addr))
+			eth_mac_wifi(priv->dev->dev_addr);
+		if (!is_valid_ether_addr(priv->dev->dev_addr))
 			eth_hw_addr_random(priv->dev);
 	}
 	pr_warn("%s: device MAC address %pM\n", priv->dev->name,
diff --git a/kernel/drivers/regulator/act8846.c b/kernel/drivers/regulator/act8846.c
index 8c57878..f50bd01 100755
--- a/kernel/drivers/regulator/act8846.c
+++ b/kernel/drivers/regulator/act8846.c
@@ -61,6 +61,7 @@ struct act8846 {
 	int chip_irq;
 	int pmic_sleep_gpio; /* */
 	int pmic_hold_gpio; /* */
+	int pmic_poweroff_gpio; /* */
 	unsigned int dcdc_slp_voltage[3]; /* buckx_voltage in uV */
 	bool pmic_sleep;
 	struct regmap *regmap;
@@ -781,6 +782,11 @@ static struct act8846_board *act8846_parse_dt(struct act8846 *act8846)
 		if (!gpio_is_valid(gpio)) 
 			printk("invalid gpio: %d\n",gpio);
 	pdata->pmic_hold_gpio = gpio;	
+
+	gpio = of_get_named_gpio(act8846_pmic_np,"gpios", 2);
+		if (!gpio_is_valid(gpio))
+			printk("invalid gpio: %d\n",gpio);
+	pdata->pmic_poweroff_gpio = gpio;
 	pdata->pm_off = of_property_read_bool(act8846_pmic_np,"act8846,system-power-controller");
 
 	return pdata;
@@ -800,6 +806,11 @@ void act8846_device_shutdown(void)
 	
 	printk("%s\n",__func__);
 #if 1
+	if (act8846->pmic_poweroff_gpio) {
+		gpio_direction_output(act8846->pmic_poweroff_gpio,1);
+		mdelay(100);
+	}
+
 	if (act8846->pmic_hold_gpio) {
 			gpio_direction_output(act8846->pmic_hold_gpio,0);
 			mdelay(100);
@@ -951,6 +962,21 @@ static int act8846_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id
 			printk("%s: act8846_pmic_sleep=%x\n", __func__, ret);
 	}
 	#endif
+
+	#ifdef CONFIG_OF
+	act8846->pmic_poweroff_gpio = pdev->pmic_poweroff_gpio;
+	if (act8846->pmic_poweroff_gpio) {
+			ret = gpio_request(act8846->pmic_poweroff_gpio, "act8846_pmic_poweroff");
+			if (ret < 0) {
+				dev_err(act8846->dev,"Failed to request gpio %d with ret:""%d\n",	act8846->pmic_poweroff_gpio, ret);
+				return IRQ_NONE;
+			}
+			gpio_direction_output(act8846->pmic_poweroff_gpio,0);
+			ret = gpio_get_value(act8846->pmic_poweroff_gpio);
+	//		gpio_free(act8846->pmic_poweroff_gpio);
+			printk("%s: act8846_pmic_poweroff=%x\n", __func__, ret);
+	}
+	#endif
 	
 	if (pdev) {
 		act8846->num_regulators = act8846_NUM_REGULATORS;
diff --git a/kernel/include/linux/regulator/act8846.h b/kernel/include/linux/regulator/act8846.h
index bdf4248..dc23528 100755
--- a/kernel/include/linux/regulator/act8846.h
+++ b/kernel/include/linux/regulator/act8846.h
@@ -36,6 +36,7 @@ struct act8846_board {
 	struct device_node *of_node[act8846_NUM_REGULATORS];
 	int pmic_sleep_gpio; /* */
 	int pmic_hold_gpio; /* */
+	int pmic_poweroff_gpio; /* */
 	unsigned int dcdc_slp_voltage[3]; /* buckx_voltage in uV */
 	unsigned int dcdc_mode[3]; /* buckx_voltage in uV */
 	bool pmic_sleep;
-- 
2.1.1

