diff --git a/linux-5.10/rk3568_patch/kernel.patch b/linux-5.10/rk3568_patch/kernel.patch index 1c7a9240e93a794e97e0132830a9590acb127196..af2ffd0bc34b4ddb74236e92b329114e317f6205 100644 --- a/linux-5.10/rk3568_patch/kernel.patch +++ b/linux-5.10/rk3568_patch/kernel.patch @@ -627248,46 +627248,16 @@ index 819ab4ee5..c7c8d2f0a 100644 static inline void i2c_writel(struct rk3x_i2c *i2c, u32 value, unsigned int offset) { -@@ -238,6 +257,18 @@ static inline void rk3x_i2c_clean_ipd(struct rk3x_i2c *i2c) - i2c_writel(i2c, REG_INT_ALL, REG_IPD); - } - -+static inline void rk3x_i2c_disable_irq(struct rk3x_i2c *i2c) -+{ -+ i2c_writel(i2c, IEN_ALL_DISABLE, REG_IEN); -+} -+ -+static inline void rk3x_i2c_disable(struct rk3x_i2c *i2c) -+{ -+ u32 val = i2c_readl(i2c, REG_CON) & REG_CON_TUNING_MASK; -+ -+ i2c_writel(i2c, val, REG_CON); -+} -+ - /** - * rk3x_i2c_start - Generate a START condition, which triggers a REG_INT_START interrupt. - * @i2c: target controller data -@@ -245,8 +276,18 @@ static inline void rk3x_i2c_clean_ipd(struct rk3x_i2c *i2c) +@@ -245,7 +264,7 @@ static inline void rk3x_i2c_clean_ipd(struct rk3x_i2c *i2c) static void rk3x_i2c_start(struct rk3x_i2c *i2c) { u32 val = i2c_readl(i2c, REG_CON) & REG_CON_TUNING_MASK; -+ int length = 0; - -- i2c_writel(i2c, REG_INT_START, REG_IEN); -+ /* enable appropriate interrupts */ -+ if (i2c->mode == REG_CON_MOD_TX) { -+ i2c_writel(i2c, REG_INT_MBTF | REG_INT_NAKRCV, REG_IEN); -+ i2c->state = STATE_WRITE; -+ length = rk3x_i2c_fill_transmit_buf(i2c, false); -+ } else { -+ /* in any other case, we are going to be reading. */ -+ i2c_writel(i2c, REG_INT_MBRF | REG_INT_NAKRCV, REG_IEN); -+ i2c->state = STATE_READ; -+ } +- ++ + i2c_writel(i2c, REG_INT_START, REG_IEN); /* enable adapter with correct mode, send START condition */ - val |= REG_CON_EN | REG_CON_MOD(i2c->mode) | REG_CON_START; -@@ -256,6 +297,12 @@ static void rk3x_i2c_start(struct rk3x_i2c *i2c) +@@ -256,6 +275,12 @@ static void rk3x_i2c_start(struct rk3x_i2c *i2c) val |= REG_CON_ACTACK; i2c_writel(i2c, val, REG_CON); @@ -627300,7 +627270,7 @@ index 819ab4ee5..c7c8d2f0a 100644 } /** -@@ -279,6 +326,7 @@ static void rk3x_i2c_stop(struct rk3x_i2c *i2c, int error) +@@ -279,6 +304,7 @@ static void rk3x_i2c_stop(struct rk3x_i2c *i2c, int error) ctrl = i2c_readl(i2c, REG_CON); ctrl |= REG_CON_STOP; @@ -627308,7 +627278,7 @@ index 819ab4ee5..c7c8d2f0a 100644 i2c_writel(i2c, ctrl, REG_CON); } else { /* Signal rk3x_i2c_xfer to start the next message. */ -@@ -294,7 +342,7 @@ static void rk3x_i2c_stop(struct rk3x_i2c *i2c, int error) +@@ -294,7 +320,7 @@ static void rk3x_i2c_stop(struct rk3x_i2c *i2c, int error) i2c_writel(i2c, ctrl, REG_CON); /* signal that we are finished with the current msg */ @@ -627317,7 +627287,7 @@ index 819ab4ee5..c7c8d2f0a 100644 } } -@@ -324,6 +372,8 @@ static void rk3x_i2c_prepare_read(struct rk3x_i2c *i2c) +@@ -324,6 +350,8 @@ static void rk3x_i2c_prepare_read(struct rk3x_i2c *i2c) if (i2c->processed != 0) { con &= ~REG_CON_MOD_MASK; con |= REG_CON_MOD(REG_CON_MOD_RX); @@ -627326,7 +627296,7 @@ index 819ab4ee5..c7c8d2f0a 100644 } i2c_writel(i2c, con, REG_CON); -@@ -334,7 +384,7 @@ static void rk3x_i2c_prepare_read(struct rk3x_i2c *i2c) +@@ -334,7 +362,7 @@ static void rk3x_i2c_prepare_read(struct rk3x_i2c *i2c) * rk3x_i2c_fill_transmit_buf - Fill the transmit buffer with data from i2c->msg * @i2c: target controller data */ @@ -627335,7 +627305,7 @@ index 819ab4ee5..c7c8d2f0a 100644 { unsigned int i, j; u32 cnt = 0; -@@ -362,40 +412,15 @@ static void rk3x_i2c_fill_transmit_buf(struct rk3x_i2c *i2c) +@@ -362,40 +390,15 @@ static void rk3x_i2c_fill_transmit_buf(struct rk3x_i2c *i2c) break; } @@ -627380,7 +627350,7 @@ index 819ab4ee5..c7c8d2f0a 100644 static void rk3x_i2c_handle_write(struct rk3x_i2c *i2c, unsigned int ipd) { if (!(ipd & REG_INT_MBTF)) { -@@ -412,7 +437,7 @@ static void rk3x_i2c_handle_write(struct rk3x_i2c *i2c, unsigned int ipd) +@@ -412,7 +415,7 @@ static void rk3x_i2c_handle_write(struct rk3x_i2c *i2c, unsigned int ipd) if (i2c->processed == i2c->msg->len) rk3x_i2c_stop(i2c, i2c->error); else @@ -627389,7 +627359,7 @@ index 819ab4ee5..c7c8d2f0a 100644 } static void rk3x_i2c_handle_read(struct rk3x_i2c *i2c, unsigned int ipd) -@@ -472,7 +497,7 @@ static void rk3x_i2c_handle_stop(struct rk3x_i2c *i2c, unsigned int ipd) +@@ -472,7 +475,7 @@ static void rk3x_i2c_handle_stop(struct rk3x_i2c *i2c, unsigned int ipd) i2c->state = STATE_IDLE; /* signal rk3x_i2c_xfer that we are finished */ @@ -627398,7 +627368,7 @@ index 819ab4ee5..c7c8d2f0a 100644 } static irqreturn_t rk3x_i2c_irq(int irqno, void *dev_id) -@@ -484,7 +509,9 @@ static irqreturn_t rk3x_i2c_irq(int irqno, void *dev_id) +@@ -484,7 +487,9 @@ static irqreturn_t rk3x_i2c_irq(int irqno, void *dev_id) ipd = i2c_readl(i2c, REG_IPD); if (i2c->state == STATE_IDLE) { @@ -627409,7 +627379,7 @@ index 819ab4ee5..c7c8d2f0a 100644 rk3x_i2c_clean_ipd(i2c); goto out; } -@@ -504,8 +531,10 @@ static irqreturn_t rk3x_i2c_irq(int irqno, void *dev_id) +@@ -504,8 +509,10 @@ static irqreturn_t rk3x_i2c_irq(int irqno, void *dev_id) ipd &= ~REG_INT_NAKRCV; @@ -627421,7 +627391,7 @@ index 819ab4ee5..c7c8d2f0a 100644 } /* is there anything left to handle? */ -@@ -513,9 +542,6 @@ static irqreturn_t rk3x_i2c_irq(int irqno, void *dev_id) +@@ -513,9 +520,6 @@ static irqreturn_t rk3x_i2c_irq(int irqno, void *dev_id) goto out; switch (i2c->state) { @@ -627431,7 +627401,7 @@ index 819ab4ee5..c7c8d2f0a 100644 case STATE_WRITE: rk3x_i2c_handle_write(i2c, ipd); break; -@@ -1032,7 +1058,6 @@ static int rk3x_i2c_setup(struct rk3x_i2c *i2c, struct i2c_msg *msgs, int num) +@@ -1032,7 +1036,6 @@ static int rk3x_i2c_setup(struct rk3x_i2c *i2c, struct i2c_msg *msgs, int num) i2c->addr = msgs[0].addr; i2c->busy = true; @@ -627439,7 +627409,7 @@ index 819ab4ee5..c7c8d2f0a 100644 i2c->processed = 0; i2c->error = 0; -@@ -1063,6 +1088,9 @@ static int rk3x_i2c_xfer_common(struct i2c_adapter *adap, +@@ -1063,6 +1066,9 @@ static int rk3x_i2c_xfer_common(struct i2c_adapter *adap, int ret = 0; int i; @@ -627449,7 +627419,7 @@ index 819ab4ee5..c7c8d2f0a 100644 spin_lock_irqsave(&i2c->lock, flags); clk_enable(i2c->clk); -@@ -1085,10 +1113,10 @@ static int rk3x_i2c_xfer_common(struct i2c_adapter *adap, +@@ -1085,10 +1091,10 @@ static int rk3x_i2c_xfer_common(struct i2c_adapter *adap, if (i + ret >= num) i2c->is_last_msg = true; @@ -627462,7 +627432,7 @@ index 819ab4ee5..c7c8d2f0a 100644 if (!polling) { timeout = wait_event_timeout(i2c->wait, !i2c->busy, msecs_to_jiffies(WAIT_TIMEOUT)); -@@ -1103,7 +1131,7 @@ static int rk3x_i2c_xfer_common(struct i2c_adapter *adap, +@@ -1103,7 +1109,7 @@ static int rk3x_i2c_xfer_common(struct i2c_adapter *adap, i2c_readl(i2c, REG_IPD), i2c->state); /* Force a STOP condition without interrupt */ @@ -627471,7 +627441,7 @@ index 819ab4ee5..c7c8d2f0a 100644 val = i2c_readl(i2c, REG_CON) & REG_CON_TUNING_MASK; val |= REG_CON_EN | REG_CON_STOP; i2c_writel(i2c, val, REG_CON); -@@ -1120,6 +1148,9 @@ static int rk3x_i2c_xfer_common(struct i2c_adapter *adap, +@@ -1120,6 +1126,9 @@ static int rk3x_i2c_xfer_common(struct i2c_adapter *adap, } } @@ -627481,7 +627451,7 @@ index 819ab4ee5..c7c8d2f0a 100644 clk_disable(i2c->pclk); clk_disable(i2c->clk); -@@ -1140,12 +1171,69 @@ static int rk3x_i2c_xfer_polling(struct i2c_adapter *adap, +@@ -1140,12 +1149,69 @@ static int rk3x_i2c_xfer_polling(struct i2c_adapter *adap, return rk3x_i2c_xfer_common(adap, msgs, num, true); } @@ -627552,7 +627522,7 @@ index 819ab4ee5..c7c8d2f0a 100644 return 0; } -@@ -1161,7 +1249,12 @@ static const struct i2c_algorithm rk3x_i2c_algorithm = { +@@ -1161,7 +1227,12 @@ static const struct i2c_algorithm rk3x_i2c_algorithm = { }; static const struct rk3x_i2c_soc_data rv1108_soc_data = { @@ -627566,7 +627536,7 @@ index 819ab4ee5..c7c8d2f0a 100644 .calc_timings = rk3x_i2c_v1_calc_timings, }; -@@ -1195,6 +1288,10 @@ static const struct of_device_id rk3x_i2c_match[] = { +@@ -1195,6 +1266,10 @@ static const struct of_device_id rk3x_i2c_match[] = { .compatible = "rockchip,rv1108-i2c", .data = &rv1108_soc_data }, @@ -627577,7 +627547,7 @@ index 819ab4ee5..c7c8d2f0a 100644 { .compatible = "rockchip,rk3066-i2c", .data = &rk3066_soc_data -@@ -1225,7 +1322,6 @@ static int rk3x_i2c_probe(struct platform_device *pdev) +@@ -1225,7 +1300,6 @@ static int rk3x_i2c_probe(struct platform_device *pdev) const struct of_device_id *match; struct rk3x_i2c *i2c; int ret = 0; @@ -627585,7 +627555,7 @@ index 819ab4ee5..c7c8d2f0a 100644 u32 value; int irq; unsigned long clk_rate; -@@ -1253,13 +1349,18 @@ static int rk3x_i2c_probe(struct platform_device *pdev) +@@ -1253,13 +1327,18 @@ static int rk3x_i2c_probe(struct platform_device *pdev) spin_lock_init(&i2c->lock); init_waitqueue_head(&i2c->wait); @@ -627607,7 +627577,7 @@ index 819ab4ee5..c7c8d2f0a 100644 /* * Switch to new interface if the SoC also offers the old one. * The control bit is located in the GRF register space. -@@ -1268,24 +1369,34 @@ static int rk3x_i2c_probe(struct platform_device *pdev) +@@ -1268,24 +1347,34 @@ static int rk3x_i2c_probe(struct platform_device *pdev) struct regmap *grf; grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); @@ -627660,7 +627630,7 @@ index 819ab4ee5..c7c8d2f0a 100644 } } -@@ -1363,13 +1474,17 @@ static int rk3x_i2c_remove(struct platform_device *pdev) +@@ -1363,13 +1452,17 @@ static int rk3x_i2c_remove(struct platform_device *pdev) i2c_del_adapter(&i2c->adap); clk_notifier_unregister(i2c->clk, &i2c->clk_rate_nb); @@ -627679,7 +627649,7 @@ index 819ab4ee5..c7c8d2f0a 100644 static struct platform_driver rk3x_i2c_driver = { .probe = rk3x_i2c_probe, -@@ -1381,7 +1496,21 @@ static struct platform_driver rk3x_i2c_driver = { +@@ -1381,7 +1474,21 @@ static struct platform_driver rk3x_i2c_driver = { }, };