drm/rockchip: vop: optimize register take effect check
[firefly-linux-kernel-4.4.55.git] / drivers / mfd / rk616-core.c
index 1f542f60226f3cb9f7d208469cdd55b08ce9d4dc..23efc531e740b3d5d6ea9bd34ac4d38d115002d1 100755 (executable)
@@ -4,9 +4,12 @@
 #include <linux/mfd/core.h>
 #include <linux/slab.h>
 #include <linux/mfd/rk616.h>
-#include <mach/iomux.h>
+//#include <mach/iomux.h>
 #include <linux/err.h>
 #include <linux/uaccess.h>
+#include <linux/interrupt.h>
+#include <linux/of_gpio.h>
+#include <linux/of_device.h>
 #if defined(CONFIG_DEBUG_FS)
 #include <linux/fs.h>
 #include <linux/debugfs.h>
@@ -61,14 +64,14 @@ static int rk616_i2c_read_reg(struct mfd_rk616 *rk616, u16 reg,u32 *pval)
        msgs[0].len = 2;
        msgs[0].buf = reg_buf;
        msgs[0].scl_rate = rk616->pdata->scl_rate;
-       msgs[0].udelay = client->udelay;
+       //msgs[0].udelay = client->udelay;
 
        msgs[1].addr = client->addr;
        msgs[1].flags = client->flags | I2C_M_RD;
        msgs[1].len = 4;
        msgs[1].buf = (char *)pval;
        msgs[1].scl_rate = rk616->pdata->scl_rate;
-       msgs[1].udelay = client->udelay;
+       //msgs[1].udelay = client->udelay;
 
        ret = i2c_transfer(adap, msgs, 2);
 
@@ -95,7 +98,7 @@ static int rk616_i2c_write_reg(struct mfd_rk616 *rk616, u16 reg,u32 *pval)
        msg.len = 6;
        msg.buf = (char *)tx_buf;
        msg.scl_rate = rk616->pdata->scl_rate;
-       msg.udelay = client->udelay;
+       //msg.udelay = client->udelay;
 
        ret = i2c_transfer(adap, &msg, 1);
        kfree(tx_buf);
@@ -132,7 +135,7 @@ static int rk616_i2c_write_bits(struct mfd_rk616 *rk616, u16 reg,u32 mask,u32 *p
        msg.len = 6;
        msg.buf = (char *)tx_buf;
        msg.scl_rate = rk616->pdata->scl_rate;
-       msg.udelay = client->udelay;
+       //msg.udelay = client->udelay;
 
        ret = i2c_transfer(adap, &msg, 1);
        kfree(tx_buf);
@@ -162,7 +165,7 @@ static int rk616_i2c_bulk_write(struct mfd_rk616 *rk616, u16 reg,int count,u32 *
        msg.len = (count<<2) + 2;
        msg.buf = (char *)tx_buf;
        msg.scl_rate = rk616->pdata->scl_rate;
-       msg.udelay = client->udelay;
+       //msg.udelay = client->udelay;
 
        ret = i2c_transfer(adap, &msg, 1);
        kfree(tx_buf);
@@ -472,6 +475,53 @@ static int rk616_core_resume(struct device* dev)
        return 0;
 }
 
+/*
+dts:
+
+/include/ "rk616.dtsi"
+&rk616 {
+        rk616,scl_rate = <100000>;
+        rk616,lcd0_func = <1>;
+        rk616,lcd1_func = <1>;
+        rk616,lvds_ch_nr = <1>;
+        rk616,hdmi_irq_gpio = <&gpio2 GPIO_D6 1>;
+
+       rk616-codec {
+               spk-ctl-gpio = <&gpio2 GPIO_D7 GPIO_ACTIVE_HIGH>;
+               hp-ctl-gpio = <&gpio2 GPIO_D7 GPIO_ACTIVE_HIGH>;
+               //rcv-ctl-gpio = <&gpio2 GPIO_D7 GPIO_ACTIVE_HIGH>;
+               //mic-sel-gpio = <&gpio2 GPIO_D7 GPIO_ACTIVE_HIGH>;
+
+               //delay for MOSFET or SPK power amplifier chip(ms)
+               spk-amplifier-delay = <150>;
+               hp-mosfet-delay = <50>;
+
+               //hp-mic-capture-from-linein; //If hpmic is connected to linein, set this.
+               //hp-mic-capture-from-mic2in; //If hpmic is connected to mic2, set this.
+               //virtual-hp-gnd; //If hp gnd is not connected to gnd(0V), set this.
+
+               //volume setting: 0 ~ 31, -18dB ~ 28.5dB, Step: 1.5dB
+               skp-volume = <24>;
+               hp-volume = <24>;
+               capture-volume = <24>;
+       };
+
+        power_ctr: rk616_power_ctr {
+                rk616_pwren: rk616_pwren {
+                        rockchip,power_type = <GPIO>;
+                        gpios = <&gpio0 GPIO_A3 GPIO_ACTIVE_HIGH>;
+                        rockchip,delay = <0>;
+                };
+
+                rk616_rst: rk616_rst {
+                        rockchip,power_type = <GPIO>;
+                        gpios = <&gpio3 GPIO_B2 GPIO_ACTIVE_HIGH>;
+                        rockchip,delay = <10>;
+                };
+
+        };
+};
+*/
 #ifdef CONFIG_OF
 static struct rk616_platform_data *rk616_parse_dt(struct mfd_rk616 *rk616)
 {
@@ -486,7 +536,7 @@ static struct rk616_platform_data *rk616_parse_dt(struct mfd_rk616 *rk616)
 
        pdata = devm_kzalloc(rk616->dev, sizeof(struct rk616_platform_data), GFP_KERNEL);
        if (!pdata) {
-               dev_err(&rk616->dev, "rk616_platform_data kmalloc fail!");
+               dev_err(rk616->dev, "rk616_platform_data kmalloc fail!");
                return NULL;
        }
 
@@ -506,11 +556,6 @@ static struct rk616_platform_data *rk616_parse_dt(struct mfd_rk616 *rk616)
        if (!gpio_is_valid(gpio))
                printk("invalid hdmi_irq_gpio: %d\n",gpio);
        pdata->hdmi_irq = gpio;
-
-       gpio = of_get_named_gpio(rk616_np,"rk616,spk_ctl_gpio", 0);
-       if (!gpio_is_valid(gpio))
-               printk("invalid spk_ctl_gpio: %d\n",gpio);
-       pdata->spk_ctl_gpio = gpio;
        //TODO Daisen >>pwr gpio wait to add
 
        return pdata;
@@ -522,6 +567,14 @@ static struct rk616_platform_data *rk616_parse_dt(struct mfd_rk616 *rk616)
 }
 #endif
 
+#if defined(CONFIG_OF)
+static const struct of_device_id rk616_dt_ids[] = {
+       {.compatible = "rockchip,rk616",},
+       {}
+};
+MODULE_DEVICE_TABLE(of, rk616_dt_ids);
+#endif
+
 
 static int rk616_i2c_probe(struct i2c_client *client,const struct i2c_device_id *id)
 {
@@ -573,7 +626,7 @@ static int rk616_i2c_probe(struct i2c_client *client,const struct i2c_device_id
                #if defined(CONFIG_ARCH_RK29)
                rk29_mux_api_set(GPIO2D0_I2S0CLK_MIIRXCLKIN_NAME, GPIO2H_I2S0_CLK);
                #else
-               iomux_set(I2S0_MCLK);
+               //iomux_set(I2S0_MCLK); //set at i2s driver
                #endif
                clk_enable(iis_clk);
                //clk_set_rate(iis_clk, 11289600);
@@ -603,13 +656,13 @@ static int rk616_i2c_probe(struct i2c_client *client,const struct i2c_device_id
        rk616_clk_common_init(rk616);
        ret = mfd_add_devices(rk616->dev, -1,
                                      rk616_devs, ARRAY_SIZE(rk616_devs),
-                                     NULL, rk616->irq_base);
+                                     NULL, rk616->irq_base, NULL);
        
        dev_info(&client->dev,"rk616 core probe success!\n");
        return 0;
 }
 
-static int __devexit rk616_i2c_remove(struct i2c_client *client)
+static int rk616_i2c_remove(struct i2c_client *client)
 {
        return 0;
 }
@@ -622,15 +675,6 @@ static void rk616_core_shutdown(struct i2c_client *client)
 }
 
 
-#if defined(CONFIG_OF)
-static const struct of_device_id rk616_dt_ids[] = {
-       {.compatible = "rockchip,rk616",},
-       {}
-};
-MODULE_DEVICE_TABLE(of, rk616_dt_ids);
-#endif
-
-
 static const struct i2c_device_id id_table[] = {
        {"rk616", 0 },
        { }