Re: [PATCH v3 1/2] i2c: mediatek: Register i2c adapter driver earlier
On Thu, 2018-09-06 at 20:31 +0200, Wolfram Sang wrote: > On Thu, Sep 06, 2018 at 09:15:28PM +0800, Jun Gao wrote: > > From: Jun Gao > > > > In order not to block the initializations of some i2c devices. > > Register i2c adapter driver at appropriate time. > > > > Signed-off-by: Jun Gao > > The reasons this patch was rejected in v2 still hold. OK. Thanks for your opinion. >
[PATCH v3 0/2] Register i2c adapter driver earlier and use DMA safe buffers
This patch series based on v4.19-rc2, include i2c adapter driver register time modification and DMA safe buffers used for i2c transactions. changes since v2: - Remove the patch i2c: Add helper to ease DMA handling - Use i2c refactor function to release a DMA safe buffer changes since v1: - Add the initializations for DMA safe buffer pointers Jun Gao (2): i2c: mediatek: Register i2c adapter driver earlier i2c: mediatek: Use DMA safe buffers for i2c transactions drivers/i2c/busses/i2c-mt65xx.c | 74 - 1 file changed, 66 insertions(+), 8 deletions(-) -- 1.8.1.1
[PATCH v3 1/2] i2c: mediatek: Register i2c adapter driver earlier
From: Jun Gao In order not to block the initializations of some i2c devices. Register i2c adapter driver at appropriate time. Signed-off-by: Jun Gao --- drivers/i2c/busses/i2c-mt65xx.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 1e57f58..806e8b90 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -888,7 +888,17 @@ static int mtk_i2c_resume(struct device *dev) }, }; -module_platform_driver(mtk_i2c_driver); +static int __init mtk_i2c_adap_init(void) +{ + return platform_driver_register(&mtk_i2c_driver); +} +subsys_initcall(mtk_i2c_adap_init); + +static void __exit mtk_i2c_adap_exit(void) +{ + platform_driver_unregister(&mtk_i2c_driver); +} +module_exit(mtk_i2c_adap_exit); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("MediaTek I2C Bus Driver"); -- 1.8.1.1
[PATCH v3 2/2] i2c: mediatek: Use DMA safe buffers for i2c transactions
From: Jun Gao DMA mode will always be used in i2c transactions, try to allocate a DMA safe buffer if the buf of struct i2c_msg used is not DMA safe. Signed-off-by: Jun Gao --- drivers/i2c/busses/i2c-mt65xx.c | 62 - 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 806e8b90..695a2ae 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -441,6 +441,8 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, u16 control_reg; u16 restart_flag = 0; u32 reg_4g_mode; + u8 *dma_rd_buf = NULL; + u8 *dma_wr_buf = NULL; dma_addr_t rpaddr = 0; dma_addr_t wpaddr = 0; int ret; @@ -500,10 +502,18 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, if (i2c->op == I2C_MASTER_RD) { writel(I2C_DMA_INT_FLAG_NONE, i2c->pdmabase + OFFSET_INT_FLAG); writel(I2C_DMA_CON_RX, i2c->pdmabase + OFFSET_CON); - rpaddr = dma_map_single(i2c->dev, msgs->buf, + + dma_rd_buf = i2c_get_dma_safe_msg_buf(msgs, 0); + if (!dma_rd_buf) + return -ENOMEM; + + rpaddr = dma_map_single(i2c->dev, dma_rd_buf, msgs->len, DMA_FROM_DEVICE); - if (dma_mapping_error(i2c->dev, rpaddr)) + if (dma_mapping_error(i2c->dev, rpaddr)) { + i2c_put_dma_safe_msg_buf(dma_rd_buf, msgs, false); + return -ENOMEM; + } if (i2c->dev_comp->support_33bits) { reg_4g_mode = mtk_i2c_set_4g_mode(rpaddr); @@ -515,10 +525,18 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, } else if (i2c->op == I2C_MASTER_WR) { writel(I2C_DMA_INT_FLAG_NONE, i2c->pdmabase + OFFSET_INT_FLAG); writel(I2C_DMA_CON_TX, i2c->pdmabase + OFFSET_CON); - wpaddr = dma_map_single(i2c->dev, msgs->buf, + + dma_wr_buf = i2c_get_dma_safe_msg_buf(msgs, 0); + if (!dma_wr_buf) + return -ENOMEM; + + wpaddr = dma_map_single(i2c->dev, dma_wr_buf, msgs->len, DMA_TO_DEVICE); - if (dma_mapping_error(i2c->dev, wpaddr)) + if (dma_mapping_error(i2c->dev, wpaddr)) { + i2c_put_dma_safe_msg_buf(dma_wr_buf, msgs, false); + return -ENOMEM; + } if (i2c->dev_comp->support_33bits) { reg_4g_mode = mtk_i2c_set_4g_mode(wpaddr); @@ -530,16 +548,39 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, } else { writel(I2C_DMA_CLR_FLAG, i2c->pdmabase + OFFSET_INT_FLAG); writel(I2C_DMA_CLR_FLAG, i2c->pdmabase + OFFSET_CON); - wpaddr = dma_map_single(i2c->dev, msgs->buf, + + dma_wr_buf = i2c_get_dma_safe_msg_buf(msgs, 0); + if (!dma_wr_buf) + return -ENOMEM; + + wpaddr = dma_map_single(i2c->dev, dma_wr_buf, msgs->len, DMA_TO_DEVICE); - if (dma_mapping_error(i2c->dev, wpaddr)) + if (dma_mapping_error(i2c->dev, wpaddr)) { + i2c_put_dma_safe_msg_buf(dma_wr_buf, msgs, false); + return -ENOMEM; - rpaddr = dma_map_single(i2c->dev, (msgs + 1)->buf, + } + + dma_rd_buf = i2c_get_dma_safe_msg_buf((msgs + 1), 0); + if (!dma_rd_buf) { + dma_unmap_single(i2c->dev, wpaddr, +msgs->len, DMA_TO_DEVICE); + + i2c_put_dma_safe_msg_buf(dma_wr_buf, msgs, false); + + return -ENOMEM; + } + + rpaddr = dma_map_single(i2c->dev, dma_rd_buf, (msgs + 1)->len, DMA_FROM_DEVICE); if (dma_mapping_error(i2c->dev, rpaddr)) { dma_unmap_single(i2c->dev, wpaddr, msgs->len, DMA_TO_DEVICE); + + i2c_put_dma_safe_msg_buf(dma_wr_buf, msgs, false); + i2c_put_dma_safe_msg_buf(dma_rd_buf, (msgs + 1), false); + return -ENOMEM; } @@ -578,14 +619,21 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, if (i2c->op == I2C_MASTER_WR) { dma_unmap_single(i2c->dev, wpaddr,
[PATCH v2 3/3] i2c: mediatek: Use DMA safe buffers for i2c transactions
From: Jun Gao DMA mode will always be used in i2c transactions, try to allocate a DMA safe buffer if the buf of struct i2c_msg used is not DMA safe. Signed-off-by: Jun Gao --- drivers/i2c/busses/i2c-mt65xx.c | 62 - 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 806e8b90..c92cae7 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -441,6 +441,8 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, u16 control_reg; u16 restart_flag = 0; u32 reg_4g_mode; + u8 *dma_rd_buf = NULL; + u8 *dma_wr_buf = NULL; dma_addr_t rpaddr = 0; dma_addr_t wpaddr = 0; int ret; @@ -500,10 +502,18 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, if (i2c->op == I2C_MASTER_RD) { writel(I2C_DMA_INT_FLAG_NONE, i2c->pdmabase + OFFSET_INT_FLAG); writel(I2C_DMA_CON_RX, i2c->pdmabase + OFFSET_CON); - rpaddr = dma_map_single(i2c->dev, msgs->buf, + + dma_rd_buf = i2c_get_dma_safe_msg_buf(msgs, 0); + if (!dma_rd_buf) + return -ENOMEM; + + rpaddr = dma_map_single(i2c->dev, dma_rd_buf, msgs->len, DMA_FROM_DEVICE); - if (dma_mapping_error(i2c->dev, rpaddr)) + if (dma_mapping_error(i2c->dev, rpaddr)) { + i2c_free_dma_safe_msg_buf(msgs, dma_rd_buf); + return -ENOMEM; + } if (i2c->dev_comp->support_33bits) { reg_4g_mode = mtk_i2c_set_4g_mode(rpaddr); @@ -515,10 +525,18 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, } else if (i2c->op == I2C_MASTER_WR) { writel(I2C_DMA_INT_FLAG_NONE, i2c->pdmabase + OFFSET_INT_FLAG); writel(I2C_DMA_CON_TX, i2c->pdmabase + OFFSET_CON); - wpaddr = dma_map_single(i2c->dev, msgs->buf, + + dma_wr_buf = i2c_get_dma_safe_msg_buf(msgs, 0); + if (!dma_wr_buf) + return -ENOMEM; + + wpaddr = dma_map_single(i2c->dev, dma_wr_buf, msgs->len, DMA_TO_DEVICE); - if (dma_mapping_error(i2c->dev, wpaddr)) + if (dma_mapping_error(i2c->dev, wpaddr)) { + i2c_free_dma_safe_msg_buf(msgs, dma_wr_buf); + return -ENOMEM; + } if (i2c->dev_comp->support_33bits) { reg_4g_mode = mtk_i2c_set_4g_mode(wpaddr); @@ -530,16 +548,39 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, } else { writel(I2C_DMA_CLR_FLAG, i2c->pdmabase + OFFSET_INT_FLAG); writel(I2C_DMA_CLR_FLAG, i2c->pdmabase + OFFSET_CON); - wpaddr = dma_map_single(i2c->dev, msgs->buf, + + dma_wr_buf = i2c_get_dma_safe_msg_buf(msgs, 0); + if (!dma_wr_buf) + return -ENOMEM; + + wpaddr = dma_map_single(i2c->dev, dma_wr_buf, msgs->len, DMA_TO_DEVICE); - if (dma_mapping_error(i2c->dev, wpaddr)) + if (dma_mapping_error(i2c->dev, wpaddr)) { + i2c_free_dma_safe_msg_buf(msgs, dma_wr_buf); + return -ENOMEM; - rpaddr = dma_map_single(i2c->dev, (msgs + 1)->buf, + } + + dma_rd_buf = i2c_get_dma_safe_msg_buf((msgs + 1), 0); + if (!dma_rd_buf) { + dma_unmap_single(i2c->dev, wpaddr, +msgs->len, DMA_TO_DEVICE); + + i2c_free_dma_safe_msg_buf(msgs, dma_wr_buf); + + return -ENOMEM; + } + + rpaddr = dma_map_single(i2c->dev, dma_rd_buf, (msgs + 1)->len, DMA_FROM_DEVICE); if (dma_mapping_error(i2c->dev, rpaddr)) { dma_unmap_single(i2c->dev, wpaddr, msgs->len, DMA_TO_DEVICE); + + i2c_free_dma_safe_msg_buf(msgs, dma_wr_buf); + i2c_free_dma_safe_msg_buf((msgs + 1), dma_rd_buf); + return -ENOMEM; } @@ -578,14 +619,21 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, if (i2c->op == I2C_MASTER_WR) { dma_unmap_single(i2c->dev, wpaddr, msgs->len,
[PATCH v2 0/3] Register i2c adapter driver earlier and use DMA safe buffers
This patch series based on v4.18-rc1, include i2c adapter driver register time modification, DMA safe buffer free function and DMA safe buffers used for i2c transactions. changes since v1: - Add the initializations for DMA safe buffer pointers Jun Gao (3): i2c: mediatek: Register i2c adapter driver earlier i2c: Add helper to ease DMA handling i2c: mediatek: Use DMA safe buffers for i2c transactions drivers/i2c/busses/i2c-mt65xx.c | 74 - drivers/i2c/i2c-core-base.c | 14 include/linux/i2c.h | 1 + 3 files changed, 81 insertions(+), 8 deletions(-) -- 1.8.1.1
[PATCH v2 1/3] i2c: mediatek: Register i2c adapter driver earlier
From: Jun Gao As i2c adapter, i2c slave devices will depend on it. In order not to block the initializations of i2c slave devices, register i2c adapter driver at appropriate time. Signed-off-by: Jun Gao --- drivers/i2c/busses/i2c-mt65xx.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 1e57f58..806e8b90 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -888,7 +888,17 @@ static int mtk_i2c_resume(struct device *dev) }, }; -module_platform_driver(mtk_i2c_driver); +static int __init mtk_i2c_adap_init(void) +{ + return platform_driver_register(&mtk_i2c_driver); +} +subsys_initcall(mtk_i2c_adap_init); + +static void __exit mtk_i2c_adap_exit(void) +{ + platform_driver_unregister(&mtk_i2c_driver); +} +module_exit(mtk_i2c_adap_exit); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("MediaTek I2C Bus Driver"); -- 1.8.1.1
[PATCH v2 2/3] i2c: Add helper to ease DMA handling
From: Jun Gao This function is needed by i2c_get_dma_safe_msg_buf() potentially. It is used to free DMA safe buffer when DMA operation fails. Signed-off-by: Jun Gao --- drivers/i2c/i2c-core-base.c | 14 ++ include/linux/i2c.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 31d16ad..2b518ea 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -2288,6 +2288,20 @@ void i2c_release_dma_safe_msg_buf(struct i2c_msg *msg, u8 *buf) } EXPORT_SYMBOL_GPL(i2c_release_dma_safe_msg_buf); +/** + * i2c_free_dma_safe_msg_buf - free DMA safe buffer + * @msg: the message related to DMA safe buffer + * @buf: the buffer obtained from i2c_get_dma_safe_msg_buf(). May be NULL. + */ +void i2c_free_dma_safe_msg_buf(struct i2c_msg *msg, u8 *buf) +{ + if (!buf || buf == msg->buf) + return; + + kfree(buf); +} +EXPORT_SYMBOL_GPL(i2c_free_dma_safe_msg_buf); + MODULE_AUTHOR("Simon G. Vogl "); MODULE_DESCRIPTION("I2C-Bus main module"); MODULE_LICENSE("GPL"); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 254cd34..6d62f93 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -860,6 +860,7 @@ static inline u8 i2c_8bit_addr_from_msg(const struct i2c_msg *msg) u8 *i2c_get_dma_safe_msg_buf(struct i2c_msg *msg, unsigned int threshold); void i2c_release_dma_safe_msg_buf(struct i2c_msg *msg, u8 *buf); +void i2c_free_dma_safe_msg_buf(struct i2c_msg *msg, u8 *buf); int i2c_handle_smbus_host_notify(struct i2c_adapter *adap, unsigned short addr); /** -- 1.8.1.1
[PATCH 3/3] i2c: mediatek: Use DMA safe buffers for i2c transactions
From: Jun Gao DMA mode will always be used in i2c transactions, try to allocate a DMA safe buffer if the buf of struct i2c_msg used is not DMA safe. Signed-off-by: Jun Gao --- drivers/i2c/busses/i2c-mt65xx.c | 62 - 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 806e8b90..dd014ee 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -441,6 +441,8 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, u16 control_reg; u16 restart_flag = 0; u32 reg_4g_mode; + u8 *dma_rd_buf; + u8 *dma_wr_buf; dma_addr_t rpaddr = 0; dma_addr_t wpaddr = 0; int ret; @@ -500,10 +502,18 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, if (i2c->op == I2C_MASTER_RD) { writel(I2C_DMA_INT_FLAG_NONE, i2c->pdmabase + OFFSET_INT_FLAG); writel(I2C_DMA_CON_RX, i2c->pdmabase + OFFSET_CON); - rpaddr = dma_map_single(i2c->dev, msgs->buf, + + dma_rd_buf = i2c_get_dma_safe_msg_buf(msgs, 0); + if (!dma_rd_buf) + return -ENOMEM; + + rpaddr = dma_map_single(i2c->dev, dma_rd_buf, msgs->len, DMA_FROM_DEVICE); - if (dma_mapping_error(i2c->dev, rpaddr)) + if (dma_mapping_error(i2c->dev, rpaddr)) { + i2c_free_dma_safe_msg_buf(msgs, dma_rd_buf); + return -ENOMEM; + } if (i2c->dev_comp->support_33bits) { reg_4g_mode = mtk_i2c_set_4g_mode(rpaddr); @@ -515,10 +525,18 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, } else if (i2c->op == I2C_MASTER_WR) { writel(I2C_DMA_INT_FLAG_NONE, i2c->pdmabase + OFFSET_INT_FLAG); writel(I2C_DMA_CON_TX, i2c->pdmabase + OFFSET_CON); - wpaddr = dma_map_single(i2c->dev, msgs->buf, + + dma_wr_buf = i2c_get_dma_safe_msg_buf(msgs, 0); + if (!dma_wr_buf) + return -ENOMEM; + + wpaddr = dma_map_single(i2c->dev, dma_wr_buf, msgs->len, DMA_TO_DEVICE); - if (dma_mapping_error(i2c->dev, wpaddr)) + if (dma_mapping_error(i2c->dev, wpaddr)) { + i2c_free_dma_safe_msg_buf(msgs, dma_wr_buf); + return -ENOMEM; + } if (i2c->dev_comp->support_33bits) { reg_4g_mode = mtk_i2c_set_4g_mode(wpaddr); @@ -530,16 +548,39 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, } else { writel(I2C_DMA_CLR_FLAG, i2c->pdmabase + OFFSET_INT_FLAG); writel(I2C_DMA_CLR_FLAG, i2c->pdmabase + OFFSET_CON); - wpaddr = dma_map_single(i2c->dev, msgs->buf, + + dma_wr_buf = i2c_get_dma_safe_msg_buf(msgs, 0); + if (!dma_wr_buf) + return -ENOMEM; + + wpaddr = dma_map_single(i2c->dev, dma_wr_buf, msgs->len, DMA_TO_DEVICE); - if (dma_mapping_error(i2c->dev, wpaddr)) + if (dma_mapping_error(i2c->dev, wpaddr)) { + i2c_free_dma_safe_msg_buf(msgs, dma_wr_buf); + return -ENOMEM; - rpaddr = dma_map_single(i2c->dev, (msgs + 1)->buf, + } + + dma_rd_buf = i2c_get_dma_safe_msg_buf((msgs + 1), 0); + if (!dma_rd_buf) { + dma_unmap_single(i2c->dev, wpaddr, +msgs->len, DMA_TO_DEVICE); + + i2c_free_dma_safe_msg_buf(msgs, dma_wr_buf); + + return -ENOMEM; + } + + rpaddr = dma_map_single(i2c->dev, dma_rd_buf, (msgs + 1)->len, DMA_FROM_DEVICE); if (dma_mapping_error(i2c->dev, rpaddr)) { dma_unmap_single(i2c->dev, wpaddr, msgs->len, DMA_TO_DEVICE); + + i2c_free_dma_safe_msg_buf(msgs, dma_wr_buf); + i2c_free_dma_safe_msg_buf((msgs + 1), dma_rd_buf); + return -ENOMEM; } @@ -578,14 +619,21 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, if (i2c->op == I2C_MASTER_WR) { dma_unmap_single(i2c->dev, wpaddr, msgs->len,
[PATCH 0/3] Register i2c adapter driver earlier and use DMA safe buffers
This patch series based on v4.18-rc1, include i2c adapter driver register time modification, DMA safe buffer free function and DMA safe buffers used for i2c transactions. Jun Gao (3): i2c: mediatek: Register i2c adapter driver earlier i2c: Add helper to ease DMA handling i2c: mediatek: Use DMA safe buffers for i2c transactions drivers/i2c/busses/i2c-mt65xx.c | 74 - drivers/i2c/i2c-core-base.c | 14 include/linux/i2c.h | 1 + 3 files changed, 81 insertions(+), 8 deletions(-) -- 1.8.1.1
[PATCH 1/3] i2c: mediatek: Register i2c adapter driver earlier
From: Jun Gao As i2c adapter, i2c slave devices will depend on it. In order not to block the initializations of i2c slave devices, register i2c adapter driver at appropriate time. Signed-off-by: Jun Gao --- drivers/i2c/busses/i2c-mt65xx.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 1e57f58..806e8b90 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -888,7 +888,17 @@ static int mtk_i2c_resume(struct device *dev) }, }; -module_platform_driver(mtk_i2c_driver); +static int __init mtk_i2c_adap_init(void) +{ + return platform_driver_register(&mtk_i2c_driver); +} +subsys_initcall(mtk_i2c_adap_init); + +static void __exit mtk_i2c_adap_exit(void) +{ + platform_driver_unregister(&mtk_i2c_driver); +} +module_exit(mtk_i2c_adap_exit); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("MediaTek I2C Bus Driver"); -- 1.8.1.1
[PATCH 2/3] i2c: Add helper to ease DMA handling
From: Jun Gao This function is needed by i2c_get_dma_safe_msg_buf() potentially. It is used to free DMA safe buffer when DMA operation fails. Signed-off-by: Jun Gao --- drivers/i2c/i2c-core-base.c | 14 ++ include/linux/i2c.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 31d16ad..2b518ea 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -2288,6 +2288,20 @@ void i2c_release_dma_safe_msg_buf(struct i2c_msg *msg, u8 *buf) } EXPORT_SYMBOL_GPL(i2c_release_dma_safe_msg_buf); +/** + * i2c_free_dma_safe_msg_buf - free DMA safe buffer + * @msg: the message related to DMA safe buffer + * @buf: the buffer obtained from i2c_get_dma_safe_msg_buf(). May be NULL. + */ +void i2c_free_dma_safe_msg_buf(struct i2c_msg *msg, u8 *buf) +{ + if (!buf || buf == msg->buf) + return; + + kfree(buf); +} +EXPORT_SYMBOL_GPL(i2c_free_dma_safe_msg_buf); + MODULE_AUTHOR("Simon G. Vogl "); MODULE_DESCRIPTION("I2C-Bus main module"); MODULE_LICENSE("GPL"); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 254cd34..6d62f93 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -860,6 +860,7 @@ static inline u8 i2c_8bit_addr_from_msg(const struct i2c_msg *msg) u8 *i2c_get_dma_safe_msg_buf(struct i2c_msg *msg, unsigned int threshold); void i2c_release_dma_safe_msg_buf(struct i2c_msg *msg, u8 *buf); +void i2c_free_dma_safe_msg_buf(struct i2c_msg *msg, u8 *buf); int i2c_handle_smbus_host_notify(struct i2c_adapter *adap, unsigned short addr); /** -- 1.8.1.1
[PATCH 3/3] i2c: mediatek: Enable i2c module clock before i2c registers access.
From: Jun Gao Make sure i2c module clock has been enabled before i2c registers access. Signed-off-by: Jun Gao --- drivers/i2c/busses/i2c-mt65xx.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 58d6401..cf23a74 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -861,10 +861,19 @@ static int mtk_i2c_remove(struct platform_device *pdev) #ifdef CONFIG_PM_SLEEP static int mtk_i2c_resume(struct device *dev) { + int ret; struct mtk_i2c *i2c = dev_get_drvdata(dev); + ret = mtk_i2c_clock_enable(i2c); + if (ret) { + dev_err(dev, "clock enable failed!\n"); + return ret; + } + mtk_i2c_init_hw(i2c); + mtk_i2c_clock_disable(i2c); + return 0; } #endif -- 1.8.1.1
[PATCH 0/3] Add i2c dt-binding and compatible for Mediatek MT2712
This patch series based on v4.15-rc1, include MT2712 i2c dt-binding, compatible and i2c module clock enable. Jun Gao (3): dt-bindings: i2c: Add MediaTek MT2712 i2c binding i2c: mediatek: Add i2c compatible for MediaTek MT2712 i2c: mediatek: Enable i2c module clock before i2c registers access. Documentation/devicetree/bindings/i2c/i2c-mtk.txt | 1 + drivers/i2c/busses/i2c-mt65xx.c | 40 --- 2 files changed, 37 insertions(+), 4 deletions(-) -- 1.8.1.1
[PATCH 1/3] dt-bindings: i2c: Add MediaTek MT2712 i2c binding
From: Jun Gao Add MT2712 i2c binding to binding file. Compare to MT8173 i2c controller, MT2712 has timing adjust registers which can adjust the internal divider of i2c source clock, SCL duty cycle, SCL compare point, start(repeated start) and stop time, SDA change time. Signed-off-by: Jun Gao --- Documentation/devicetree/bindings/i2c/i2c-mtk.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt index ff7bf37..e199695 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt @@ -5,6 +5,7 @@ The MediaTek's I2C controller is used to interface with I2C devices. Required properties: - compatible: value should be either of the following. "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for MediaTek MT2701 + "mediatek,mt2712-i2c": for MediaTek MT2712 "mediatek,mt6577-i2c": for MediaTek MT6577 "mediatek,mt6589-i2c": for MediaTek MT6589 "mediatek,mt7622-i2c": for MediaTek MT7622 -- 1.8.1.1
[PATCH 2/3] i2c: mediatek: Add i2c compatible for MediaTek MT2712
From: Jun Gao Add i2c compatible for MT2712. Compare to MT8173 i2c controller, internal divider of i2c source clock need to be configured for MT2712 i2c speed calculation. Signed-off-by: Jun Gao --- drivers/i2c/busses/i2c-mt65xx.c | 31 +++ 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 09d288c..58d6401 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -61,6 +61,7 @@ #define I2C_DMA_HARD_RST 0x0002 #define I2C_DMA_4G_MODE0x0001 +#define I2C_DEFAULT_CLK_DIV5 #define I2C_DEFAULT_SPEED 10 /* hz */ #define MAX_FS_MODE_SPEED 40 #define MAX_HS_MODE_SPEED 340 @@ -127,6 +128,7 @@ enum I2C_REGS_OFFSET { OFFSET_DEBUGSTAT = 0x64, OFFSET_DEBUGCTRL = 0x68, OFFSET_TRANSFER_LEN_AUX = 0x6c, + OFFSET_CLOCK_DIV = 0x70, }; struct mtk_i2c_compatible { @@ -136,6 +138,7 @@ struct mtk_i2c_compatible { unsigned char auto_restart: 1; unsigned char aux_len_reg: 1; unsigned char support_33bits: 1; + unsigned char timing_adjust: 1; }; struct mtk_i2c { @@ -176,6 +179,15 @@ struct mtk_i2c { .max_num_msgs = 255, }; +static const struct mtk_i2c_compatible mt2712_compat = { + .pmic_i2c = 0, + .dcm = 1, + .auto_restart = 1, + .aux_len_reg = 1, + .support_33bits = 1, + .timing_adjust = 1, +}; + static const struct mtk_i2c_compatible mt6577_compat = { .quirks = &mt6577_i2c_quirks, .pmic_i2c = 0, @@ -183,6 +195,7 @@ struct mtk_i2c { .auto_restart = 0, .aux_len_reg = 0, .support_33bits = 0, + .timing_adjust = 0, }; static const struct mtk_i2c_compatible mt6589_compat = { @@ -192,6 +205,7 @@ struct mtk_i2c { .auto_restart = 0, .aux_len_reg = 0, .support_33bits = 0, + .timing_adjust = 0, }; static const struct mtk_i2c_compatible mt7622_compat = { @@ -201,6 +215,7 @@ struct mtk_i2c { .auto_restart = 1, .aux_len_reg = 1, .support_33bits = 0, + .timing_adjust = 0, }; static const struct mtk_i2c_compatible mt8173_compat = { @@ -209,9 +224,11 @@ struct mtk_i2c { .auto_restart = 1, .aux_len_reg = 1, .support_33bits = 1, + .timing_adjust = 0, }; static const struct of_device_id mtk_i2c_of_match[] = { + { .compatible = "mediatek,mt2712-i2c", .data = &mt2712_compat }, { .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat }, { .compatible = "mediatek,mt6589-i2c", .data = &mt6589_compat }, { .compatible = "mediatek,mt7622-i2c", .data = &mt7622_compat }, @@ -271,6 +288,9 @@ static void mtk_i2c_init_hw(struct mtk_i2c *i2c) if (i2c->dev_comp->dcm) writew(I2C_DCM_DISABLE, i2c->base + OFFSET_DCM_EN); + if (i2c->dev_comp->timing_adjust) + writew(I2C_DEFAULT_CLK_DIV - 1, i2c->base + OFFSET_CLOCK_DIV); + writew(i2c->timing_reg, i2c->base + OFFSET_TIMING); writew(i2c->high_speed_reg, i2c->base + OFFSET_HS); @@ -725,10 +745,6 @@ static int mtk_i2c_probe(struct platform_device *pdev) if (!i2c) return -ENOMEM; - ret = mtk_i2c_parse_dt(pdev->dev.of_node, i2c); - if (ret) - return -EINVAL; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); i2c->base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(i2c->base)) @@ -759,6 +775,13 @@ static int mtk_i2c_probe(struct platform_device *pdev) i2c->adap.timeout = 2 * HZ; i2c->adap.retries = 1; + ret = mtk_i2c_parse_dt(pdev->dev.of_node, i2c); + if (ret) + return -EINVAL; + + if (i2c->dev_comp->timing_adjust) + i2c->clk_src_div *= I2C_DEFAULT_CLK_DIV; + if (i2c->have_pmic && !i2c->dev_comp->pmic_i2c) return -EINVAL; -- 1.8.1.1
Re: [I2C] About warning 'DMA-API: device driver maps memory from stack'
On Sat, 2017-09-02 at 23:58 +0200, Wolfram Sang wrote: > Hi, > > nice to see someone else interested in the I2C & DMA topic. > > Please check this series which I sent out recently: > > "[RFC PATCH v4 0/6] i2c: document DMA handling and add helpers for it" > > In that series, I proposed... > > > 3. kmalloc data buffer instead of local variables buf in function > > i2c_smbus_xfer_emulated(...) > > ... this solution. Although I have to check Mauro's general response to > the series first. I'd be interested in what you think of the series, > too. Sorry for late reply. As you said in "[RFC,v4,3/6]i2c: add docs to clarify DMA handling". Most i2c_msgs are register accesses and thus, small messages. And "[RFC,v4,4/6] i2c: sh_mobile: use helper to decide if DMA is useful". Maybe the solution as below will be better. Other drivers which will use i2c would not have to make buffer DMA safe especially register accesses(they like to use local variables when data_len = 1 or 2). solution: 2. use FIFO mode when length<=fifo_depth(mtk i2c fifo_depth=8), use the flag "I2C_M_DMA_SAFE" to check buffer for DMA mode when length>fifo_depth in i2c-mt65xx.c . Thanks. > > Kind regards, > >Wolfram >
[I2C] About warning 'DMA-API: device driver maps memory from stack'
Dear Wolfram, When we use i2c-tools command 'i2cset -y -f 0 0x50 0x00 0x11'(0:i2c bus number; 0x50:eeprom device addr; 0x00:device register addr; 0x11:write data)to write data, a warning appears as below if enable kernel config CONFIG_DMA_API_DEBUG=y. [ 11.872860] i2c-mt65xx 11007000.i2c: DMA-API: device driver maps memory from stack [addr=80007a21fb88] [ 11.874104] [ cut here ] [ 11.874703] WARNING: CPU: 1 PID: 1232 at /proj/user/kernel_only_dev_4.13_rc1/kernel/mediatek/lib/dma-debug.c:1188 check_for_stack+0xb0/0x100 [ 11.876337] Modules linked in: [ 11.876735] CPU: 1 PID: 1232 Comm: sh Not tainted 4.13.0-rc1-221494-g28b31c4-dirty #1 [ 11.877729] Hardware name: MediaTek MT8173 evaluation board (DT) [ 11.878490] task: 80007b3cb600 task.stack: 80007a21c000 [ 11.879242] PC is at check_for_stack+0xb0/0x100 [ 11.879821] LR is at check_for_stack+0xb0/0x100 ... [ 11.902642] [] check_for_stack+0xb0/0x100 [ 11.903352] [] debug_dma_map_page+0xf8/0x130 [ 11.904097] [] mtk_i2c_transfer+0x834/0xa90 [ 11.904826] [] __i2c_transfer+0x11c/0x278 [ 11.905535] [] i2c_transfer+0x64/0xb8 [ 11.906200] [] i2c_smbus_xfer_emulated+0x114/0x518 [ 11.907006] [] i2c_smbus_xfer+0x118/0x180 ... Reason: i2c-tools command will call ioctl(file,I2C_SMBUS,&args) -> i2cdev_ioctl_smbus(...) -> i2c_smbus_xfer(...) -> i2c_smbus_xfer_emulated(...). Local variables were used as data buf of struct i2c_msg in function i2c_smbus_xfer_emulated(...) as below, but we default use DMA mode in mtk i2c driver(drivers/i2c/busses/i2c-mt65xx.c) with dma_map_single(...). Then 'DMA-API: device driver maps memory from stack' warning appeared. static s32 i2c_smbus_xfer_emulated(...) { ... unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3]; unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; int num = read_write == I2C_SMBUS_READ ? 2 : 1; int i; u8 partial_pec = 0; int status; struct i2c_msg msg[2] = { { .addr = addr, .flags = flags, .len = 1, .buf = msgbuf0, }, { .addr = addr, .flags = flags | I2C_M_RD, .len = 0, .buf = msgbuf1, }, }; ... status = i2c_transfer(adapter, msg, num); if (status < 0) return status; ... } Solution: modify i2c-mt65xx.c 1. kmalloc and memcpy buffer for struct i2c_msg buf every time in i2c-mt65xx.c 2. use FIFO mode when length<=fifo_depth(mtk i2c fifo_depth=8), use solution 1 for DMA mode when length>fifo_depth in i2c-mt65xx.c . Because i2c-tools command write/read length<8 in most cases, this solution may be better than solution 1 in performance. modify function i2c_smbus_xfer_emulated(...) 3. kmalloc data buffer instead of local variables buf in function i2c_smbus_xfer_emulated(...) Which solution is better? Could you give some suggestions? Thanks! Best Regards Jun
[PATCH v4 0/3] Add i2c dt-binding and compatible for Mediatek MT7622 SoC
This patch series based on v4.13-rc1, include i2c binding file information formats modification, MT7622 i2c dt-binding and compatible. changes since v3: - Split the formats modification into another patch changes since v2: - Remove all the length settings from mt7622_i2c_quirks changes since v1: - Modify commit message - Revise dt-binding documentation Jun Gao (3): dt-bindings: i2c: modify information formats dt-bindings: i2c: Add MediaTek MT7622 i2c binding i2c: mediatek: Add i2c compatible for MediaTek MT7622 Documentation/devicetree/bindings/i2c/i2c-mtk.txt | 15 --- drivers/i2c/busses/i2c-mt65xx.c | 14 ++ 2 files changed, 22 insertions(+), 7 deletions(-) -- 1.8.1.1
[PATCH v4 1/3] dt-bindings: i2c: modify information formats
From: Jun Gao Use common name MediaTek and modify the compatible information formats of all SoCs to the same. Signed-off-by: Jun Gao --- Documentation/devicetree/bindings/i2c/i2c-mtk.txt | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt index bd5a7be..9c86424 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt @@ -1,14 +1,14 @@ -* Mediatek's I2C controller +* MediaTek's I2C controller -The Mediatek's I2C controller is used to interface with I2C devices. +The MediaTek's I2C controller is used to interface with I2C devices. Required properties: - compatible: value should be either of the following. - "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek mt2701 - "mediatek,mt6577-i2c": for i2c compatible with mt6577. - "mediatek,mt6589-i2c": for i2c compatible with mt6589. - "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for i2c compatible with mt7623. - "mediatek,mt8173-i2c": for i2c compatible with mt8173. + "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for MediaTek MT2701 + "mediatek,mt6577-i2c": for MediaTek MT6577 + "mediatek,mt6589-i2c": for MediaTek MT6589 + "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for MediaTek MT7623 + "mediatek,mt8173-i2c": for MediaTek MT8173 - reg: physical base address of the controller and dma base, length of memory mapped region. - interrupts: interrupt number to the cpu. -- 1.8.1.1
[PATCH v4 3/3] i2c: mediatek: Add i2c compatible for MediaTek MT7622
From: Jun Gao Add i2c compatible for MT7622. Compare to MT8173 i2c controller, MT7622 limits message numbers to 255, and does not support 4GB DMA mode. Signed-off-by: Jun Gao Reviewed-by: Yingjoe Chen --- drivers/i2c/busses/i2c-mt65xx.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 9bedf0b..09d288c 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -172,6 +172,10 @@ struct mtk_i2c { .max_comb_2nd_msg_len = 31, }; +static const struct i2c_adapter_quirks mt7622_i2c_quirks = { + .max_num_msgs = 255, +}; + static const struct mtk_i2c_compatible mt6577_compat = { .quirks = &mt6577_i2c_quirks, .pmic_i2c = 0, @@ -190,6 +194,15 @@ struct mtk_i2c { .support_33bits = 0, }; +static const struct mtk_i2c_compatible mt7622_compat = { + .quirks = &mt7622_i2c_quirks, + .pmic_i2c = 0, + .dcm = 1, + .auto_restart = 1, + .aux_len_reg = 1, + .support_33bits = 0, +}; + static const struct mtk_i2c_compatible mt8173_compat = { .pmic_i2c = 0, .dcm = 1, @@ -201,6 +214,7 @@ struct mtk_i2c { static const struct of_device_id mtk_i2c_of_match[] = { { .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat }, { .compatible = "mediatek,mt6589-i2c", .data = &mt6589_compat }, + { .compatible = "mediatek,mt7622-i2c", .data = &mt7622_compat }, { .compatible = "mediatek,mt8173-i2c", .data = &mt8173_compat }, {} }; -- 1.8.1.1
[PATCH v4 2/3] dt-bindings: i2c: Add MediaTek MT7622 i2c binding
From: Jun Gao Add MT7622 i2c binding to binding file. Compare to MT8173 i2c controller, MT7622 limits message numbers to 255, and does not support 4GB DMA mode. Signed-off-by: Jun Gao --- Documentation/devicetree/bindings/i2c/i2c-mtk.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt index 9c86424..ff7bf37 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt @@ -7,6 +7,7 @@ Required properties: "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for MediaTek MT2701 "mediatek,mt6577-i2c": for MediaTek MT6577 "mediatek,mt6589-i2c": for MediaTek MT6589 + "mediatek,mt7622-i2c": for MediaTek MT7622 "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for MediaTek MT7623 "mediatek,mt8173-i2c": for MediaTek MT8173 - reg: physical base address of the controller and dma base, length of memory -- 1.8.1.1
[PATCH v3 0/2] Add i2c dt-binding and compatible for Mediatek MT7622 SoC
This patch series based on v4.13-rc1, include MT7622 i2c dt-binding and compatible. changes since v2: - Remove all the length settings from mt7622_i2c_quirks changes since v1: - Modify commit message - Revise dt-binding documentation Jun Gao (2): dt-bindings: i2c: Add MediaTek MT7622 i2c binding i2c: mediatek: Add i2c compatible for MediaTek MT7622 Documentation/devicetree/bindings/i2c/i2c-mtk.txt | 11 ++- drivers/i2c/busses/i2c-mt65xx.c | 14 ++ 2 files changed, 20 insertions(+), 5 deletions(-) -- 1.8.1.1
[PATCH v3 2/2] i2c: mediatek: Add i2c compatible for MediaTek MT7622
From: Jun Gao Add i2c compatible for MT7622. Compare to MT8173 i2c controller, MT7622 limits message numbers to 255, and does not support 4GB DMA mode. Signed-off-by: Jun Gao --- drivers/i2c/busses/i2c-mt65xx.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 9bedf0b..09d288c 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -172,6 +172,10 @@ struct mtk_i2c { .max_comb_2nd_msg_len = 31, }; +static const struct i2c_adapter_quirks mt7622_i2c_quirks = { + .max_num_msgs = 255, +}; + static const struct mtk_i2c_compatible mt6577_compat = { .quirks = &mt6577_i2c_quirks, .pmic_i2c = 0, @@ -190,6 +194,15 @@ struct mtk_i2c { .support_33bits = 0, }; +static const struct mtk_i2c_compatible mt7622_compat = { + .quirks = &mt7622_i2c_quirks, + .pmic_i2c = 0, + .dcm = 1, + .auto_restart = 1, + .aux_len_reg = 1, + .support_33bits = 0, +}; + static const struct mtk_i2c_compatible mt8173_compat = { .pmic_i2c = 0, .dcm = 1, @@ -201,6 +214,7 @@ struct mtk_i2c { static const struct of_device_id mtk_i2c_of_match[] = { { .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat }, { .compatible = "mediatek,mt6589-i2c", .data = &mt6589_compat }, + { .compatible = "mediatek,mt7622-i2c", .data = &mt7622_compat }, { .compatible = "mediatek,mt8173-i2c", .data = &mt8173_compat }, {} }; -- 1.8.1.1
[PATCH v3 1/2] dt-bindings: i2c: Add MediaTek MT7622 i2c binding
From: Jun Gao Add MT7622 i2c binding to binding file and change the compatible information formats of all SoCs to the same. Signed-off-by: Jun Gao --- Documentation/devicetree/bindings/i2c/i2c-mtk.txt | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt index bd5a7be..71fc0b3 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt @@ -4,11 +4,12 @@ The Mediatek's I2C controller is used to interface with I2C devices. Required properties: - compatible: value should be either of the following. - "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek mt2701 - "mediatek,mt6577-i2c": for i2c compatible with mt6577. - "mediatek,mt6589-i2c": for i2c compatible with mt6589. - "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for i2c compatible with mt7623. - "mediatek,mt8173-i2c": for i2c compatible with mt8173. + "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek MT2701 + "mediatek,mt6577-i2c": for Mediatek MT6577 + "mediatek,mt6589-i2c": for Mediatek MT6589 + "mediatek,mt7622-i2c": for Mediatek MT7622 + "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for Mediatek MT7623 + "mediatek,mt8173-i2c": for Mediatek MT8173 - reg: physical base address of the controller and dma base, length of memory mapped region. - interrupts: interrupt number to the cpu. -- 1.8.1.1
Re: [PATCH 1/2] dt-bindings: i2c: Add MediaTek MT7622 i2c binding
On Mon, 2017-08-14 at 11:36 +0200, Matthias Brugger wrote: > > On 08/09/2017 09:43 AM, Jun Gao wrote: > > From: Jun Gao > > > > Add MT7622 i2c binding to binding file. Compare to MT8173 i2c > > controller, MT7622 limit message size to 255, and not support > > 4GB DMA mode. > > > > Signed-off-by: Jun Gao > > --- > > Documentation/devicetree/bindings/i2c/i2c-mtk.txt | 11 ++- > > 1 file changed, 6 insertions(+), 5 deletions(-) > > > > diff --git a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt > > b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt > > index bd5a7be..ff9ac61 100644 > > --- a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt > > +++ b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt > > @@ -4,11 +4,12 @@ The Mediatek's I2C controller is used to interface with > > I2C devices. > > > > Required properties: > > - compatible: value should be either of the following. > > - "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek mt2701 > > - "mediatek,mt6577-i2c": for i2c compatible with mt6577. > > - "mediatek,mt6589-i2c": for i2c compatible with mt6589. > > - "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for i2c compatible > > with mt7623. > > - "mediatek,mt8173-i2c": for i2c compatible with mt8173. > > + "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek MT2701 > > + "mediatek,mt6577-i2c": for Mediatek MT6577 > > + "mediatek,mt6589-i2c": for Mediatek MT6589 > > + "mediatek,mt7622-i2c": for Mediatek MT7622 > > + "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for Mediatek MT7623 > > + "mediatek,mt8173-i2c": for Mediatek MT8173 > > - reg: physical base address of the controller and dma base, length of > > memory > > mapped region. > > - interrupts: interrupt number to the cpu. > > > > In the next series, could you please make sure not to change the indentation. > > Thanks a lot, > Matthias Please review [PATCH v2 1/2], I will not change the indentation any more. Thanks! Jun
Re: [PATCH v2 2/2] i2c: mediatek: Add i2c compatible for MediaTek MT7622
On Sat, 2017-08-12 at 16:44 +0200, Wolfram Sang wrote: > > +static const struct i2c_adapter_quirks mt7622_i2c_quirks = { > > + .max_num_msgs = 255, > > + .max_write_len = 65535, > > + .max_read_len = 65535, > > + .max_comb_1st_msg_len = 65535, > > + .max_comb_2nd_msg_len = 65535, > > +}; > > That looks like no quirks? Then just leave the quirks pointer below > empty. > Compare to MT8173 i2c controller, MT7622 limits message numbers to 255. Jun
[PATCH v2 0/2] Add i2c dt-binding and compatible for Mediatek MT7622 SoC
This patch series based on v4.13-rc1, include MT7622 i2c dt-binding and compatible. changes since v1: - Modify commit message - Revise dt-binding documentation Jun Gao (2): dt-bindings: i2c: Add MediaTek MT7622 i2c binding i2c: mediatek: Add i2c compatible for MediaTek MT7622 Documentation/devicetree/bindings/i2c/i2c-mtk.txt | 11 ++- drivers/i2c/busses/i2c-mt65xx.c | 18 ++ 2 files changed, 24 insertions(+), 5 deletions(-) -- 1.8.1.1
[PATCH v2 1/2] dt-bindings: i2c: Add MediaTek MT7622 i2c binding
From: Jun Gao Add MT7622 i2c binding to binding file and change the compatible information formats of all SoCs to the same. Signed-off-by: Jun Gao --- Documentation/devicetree/bindings/i2c/i2c-mtk.txt | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt index bd5a7be..71fc0b3 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt @@ -4,11 +4,12 @@ The Mediatek's I2C controller is used to interface with I2C devices. Required properties: - compatible: value should be either of the following. - "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek mt2701 - "mediatek,mt6577-i2c": for i2c compatible with mt6577. - "mediatek,mt6589-i2c": for i2c compatible with mt6589. - "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for i2c compatible with mt7623. - "mediatek,mt8173-i2c": for i2c compatible with mt8173. + "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek MT2701 + "mediatek,mt6577-i2c": for Mediatek MT6577 + "mediatek,mt6589-i2c": for Mediatek MT6589 + "mediatek,mt7622-i2c": for Mediatek MT7622 + "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for Mediatek MT7623 + "mediatek,mt8173-i2c": for Mediatek MT8173 - reg: physical base address of the controller and dma base, length of memory mapped region. - interrupts: interrupt number to the cpu. -- 1.8.1.1
[PATCH v2 2/2] i2c: mediatek: Add i2c compatible for MediaTek MT7622
From: Jun Gao Add i2c compatible for MT7622. Compare to MT8173 i2c controller, MT7622 limits message numbers to 255, and does not support 4GB DMA mode. Signed-off-by: Jun Gao --- drivers/i2c/busses/i2c-mt65xx.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 9bedf0b..2c7f847 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -172,6 +172,14 @@ struct mtk_i2c { .max_comb_2nd_msg_len = 31, }; +static const struct i2c_adapter_quirks mt7622_i2c_quirks = { + .max_num_msgs = 255, + .max_write_len = 65535, + .max_read_len = 65535, + .max_comb_1st_msg_len = 65535, + .max_comb_2nd_msg_len = 65535, +}; + static const struct mtk_i2c_compatible mt6577_compat = { .quirks = &mt6577_i2c_quirks, .pmic_i2c = 0, @@ -190,6 +198,15 @@ struct mtk_i2c { .support_33bits = 0, }; +static const struct mtk_i2c_compatible mt7622_compat = { + .quirks = &mt7622_i2c_quirks, + .pmic_i2c = 0, + .dcm = 1, + .auto_restart = 1, + .aux_len_reg = 1, + .support_33bits = 0, +}; + static const struct mtk_i2c_compatible mt8173_compat = { .pmic_i2c = 0, .dcm = 1, @@ -201,6 +218,7 @@ struct mtk_i2c { static const struct of_device_id mtk_i2c_of_match[] = { { .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat }, { .compatible = "mediatek,mt6589-i2c", .data = &mt6589_compat }, + { .compatible = "mediatek,mt7622-i2c", .data = &mt7622_compat }, { .compatible = "mediatek,mt8173-i2c", .data = &mt8173_compat }, {} }; -- 1.8.1.1
Re: [RESEND PATCH 1/2] dt-bindings: i2c: Add MediaTek MT7622 i2c binding
On Thu, 2017-08-10 at 16:19 +0800, Honghui Zhang wrote: > On Thu, 2017-08-10 at 10:27 +0800, Jun Gao wrote: > > From: Jun Gao > > > > Add MT7622 i2c binding to binding file. Compare to MT8173 i2c > > controller, MT7622 limits message numbers to 255, and does not > > support 4GB DMA mode. > > > > Signed-off-by: Jun Gao > > --- > > Documentation/devicetree/bindings/i2c/i2c-mtk.txt | 11 ++- > > 1 file changed, 6 insertions(+), 5 deletions(-) > > > > diff --git a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt > > b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt > > index bd5a7be..ff9ac61 100644 > > --- a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt > > +++ b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt > > @@ -4,11 +4,12 @@ The Mediatek's I2C controller is used to interface with > > I2C devices. > > > > Required properties: > >- compatible: value should be either of the following. > > - "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek mt2701 > > - "mediatek,mt6577-i2c": for i2c compatible with mt6577. > > - "mediatek,mt6589-i2c": for i2c compatible with mt6589. > > - "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for i2c compatible > > with mt7623. > > - "mediatek,mt8173-i2c": for i2c compatible with mt8173. > > + "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek MT2701 > > + "mediatek,mt6577-i2c": for Mediatek MT6577 > > + "mediatek,mt6589-i2c": for Mediatek MT6589 > > Better not change those and just add compatible strings for mt7622. > It seems better to use the same format for all SoCs. Jun > > + "mediatek,mt7622-i2c": for Mediatek MT7622 > > + "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for Mediatek MT7623 > > + "mediatek,mt8173-i2c": for Mediatek MT8173 > >- reg: physical base address of the controller and dma base, length of > > memory > > mapped region. > >- interrupts: interrupt number to the cpu. > >
Re: [RESEND PATCH 2/2] i2c: mediatek: Add i2c compatible for MediaTek MT7622
On Thu, 2017-08-10 at 10:27 +0800, Jun Gao wrote: > From: Jun Gao > > Add i2c compatible for MT7622. Compare to MT8173 i2c controller, > MT7622 limits message numbers to 255, and does not support 4GB > DMA mode. > These two resend patches only modify commit message. Thanks! Jun > Signed-off-by: Jun Gao > --- > drivers/i2c/busses/i2c-mt65xx.c | 18 ++ > 1 file changed, 18 insertions(+) > > diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c > index 9bedf0b..2c7f847 100644 > --- a/drivers/i2c/busses/i2c-mt65xx.c > +++ b/drivers/i2c/busses/i2c-mt65xx.c > @@ -172,6 +172,14 @@ struct mtk_i2c { > .max_comb_2nd_msg_len = 31, > }; > > +static const struct i2c_adapter_quirks mt7622_i2c_quirks = { > + .max_num_msgs = 255, > + .max_write_len = 65535, > + .max_read_len = 65535, > + .max_comb_1st_msg_len = 65535, > + .max_comb_2nd_msg_len = 65535, > +}; > + > static const struct mtk_i2c_compatible mt6577_compat = { > .quirks = &mt6577_i2c_quirks, > .pmic_i2c = 0, > @@ -190,6 +198,15 @@ struct mtk_i2c { > .support_33bits = 0, > }; > > +static const struct mtk_i2c_compatible mt7622_compat = { > + .quirks = &mt7622_i2c_quirks, > + .pmic_i2c = 0, > + .dcm = 1, > + .auto_restart = 1, > + .aux_len_reg = 1, > + .support_33bits = 0, > +}; > + > static const struct mtk_i2c_compatible mt8173_compat = { > .pmic_i2c = 0, > .dcm = 1, > @@ -201,6 +218,7 @@ struct mtk_i2c { > static const struct of_device_id mtk_i2c_of_match[] = { > { .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat }, > { .compatible = "mediatek,mt6589-i2c", .data = &mt6589_compat }, > + { .compatible = "mediatek,mt7622-i2c", .data = &mt7622_compat }, > { .compatible = "mediatek,mt8173-i2c", .data = &mt8173_compat }, > {} > };
[RESEND PATCH 2/2] i2c: mediatek: Add i2c compatible for MediaTek MT7622
From: Jun Gao Add i2c compatible for MT7622. Compare to MT8173 i2c controller, MT7622 limits message numbers to 255, and does not support 4GB DMA mode. Signed-off-by: Jun Gao --- drivers/i2c/busses/i2c-mt65xx.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 9bedf0b..2c7f847 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -172,6 +172,14 @@ struct mtk_i2c { .max_comb_2nd_msg_len = 31, }; +static const struct i2c_adapter_quirks mt7622_i2c_quirks = { + .max_num_msgs = 255, + .max_write_len = 65535, + .max_read_len = 65535, + .max_comb_1st_msg_len = 65535, + .max_comb_2nd_msg_len = 65535, +}; + static const struct mtk_i2c_compatible mt6577_compat = { .quirks = &mt6577_i2c_quirks, .pmic_i2c = 0, @@ -190,6 +198,15 @@ struct mtk_i2c { .support_33bits = 0, }; +static const struct mtk_i2c_compatible mt7622_compat = { + .quirks = &mt7622_i2c_quirks, + .pmic_i2c = 0, + .dcm = 1, + .auto_restart = 1, + .aux_len_reg = 1, + .support_33bits = 0, +}; + static const struct mtk_i2c_compatible mt8173_compat = { .pmic_i2c = 0, .dcm = 1, @@ -201,6 +218,7 @@ struct mtk_i2c { static const struct of_device_id mtk_i2c_of_match[] = { { .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat }, { .compatible = "mediatek,mt6589-i2c", .data = &mt6589_compat }, + { .compatible = "mediatek,mt7622-i2c", .data = &mt7622_compat }, { .compatible = "mediatek,mt8173-i2c", .data = &mt8173_compat }, {} }; -- 1.8.1.1
[RESEND PATCH 1/2] dt-bindings: i2c: Add MediaTek MT7622 i2c binding
From: Jun Gao Add MT7622 i2c binding to binding file. Compare to MT8173 i2c controller, MT7622 limits message numbers to 255, and does not support 4GB DMA mode. Signed-off-by: Jun Gao --- Documentation/devicetree/bindings/i2c/i2c-mtk.txt | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt index bd5a7be..ff9ac61 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt @@ -4,11 +4,12 @@ The Mediatek's I2C controller is used to interface with I2C devices. Required properties: - compatible: value should be either of the following. - "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek mt2701 - "mediatek,mt6577-i2c": for i2c compatible with mt6577. - "mediatek,mt6589-i2c": for i2c compatible with mt6589. - "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for i2c compatible with mt7623. - "mediatek,mt8173-i2c": for i2c compatible with mt8173. + "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek MT2701 + "mediatek,mt6577-i2c": for Mediatek MT6577 + "mediatek,mt6589-i2c": for Mediatek MT6589 + "mediatek,mt7622-i2c": for Mediatek MT7622 + "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for Mediatek MT7623 + "mediatek,mt8173-i2c": for Mediatek MT8173 - reg: physical base address of the controller and dma base, length of memory mapped region. - interrupts: interrupt number to the cpu. -- 1.8.1.1
[RESEND PATCH 0/2] Add i2c dt-binding and compatible for Mediatek MT7622 SoC
This patch series based on v4.13-rc1, include MT7622 i2c dt-binding and compatible. Jun Gao (2): dt-bindings: i2c: Add MediaTek MT7622 i2c binding i2c: mediatek: Add i2c compatible for MediaTek MT7622 Documentation/devicetree/bindings/i2c/i2c-mtk.txt | 11 ++- drivers/i2c/busses/i2c-mt65xx.c | 18 ++ 2 files changed, 24 insertions(+), 5 deletions(-) -- 1.8.1.1
Re: [PATCH 2/2] i2c: mediatek: Add i2c compatible for MediaTek MT7622
On Wed, 2017-08-09 at 17:40 +0800, Yingjoe Chen wrote: > On Wed, 2017-08-09 at 15:43 +0800, Jun Gao wrote: > > From: Jun Gao > > > > Add i2c compatible for MT7622. Compare to MT8173 i2c controller, > > MT7622 limit message size to 255, and not support 4GB DMA mode. > > > Jun, > > Do you mean message numbers? > > > Joe.C > Yes, bit7~bit0 of i2c register TRANSAC_LEN will be used as message numbers. Jun > > > > Signed-off-by: Jun Gao > > --- > > drivers/i2c/busses/i2c-mt65xx.c | 18 ++ > > 1 file changed, 18 insertions(+) > > > > diff --git a/drivers/i2c/busses/i2c-mt65xx.c > > b/drivers/i2c/busses/i2c-mt65xx.c > > index 9bedf0b..2c7f847 100644 > > --- a/drivers/i2c/busses/i2c-mt65xx.c > > +++ b/drivers/i2c/busses/i2c-mt65xx.c > > @@ -172,6 +172,14 @@ struct mtk_i2c { > > .max_comb_2nd_msg_len = 31, > > }; > > > > +static const struct i2c_adapter_quirks mt7622_i2c_quirks = { > > + .max_num_msgs = 255, > > + .max_write_len = 65535, > > + .max_read_len = 65535, > > + .max_comb_1st_msg_len = 65535, > > + .max_comb_2nd_msg_len = 65535, > > +}; > > + > > static const struct mtk_i2c_compatible mt6577_compat = { > > .quirks = &mt6577_i2c_quirks, > > .pmic_i2c = 0, > > @@ -190,6 +198,15 @@ struct mtk_i2c { > > .support_33bits = 0, > > }; > > > > +static const struct mtk_i2c_compatible mt7622_compat = { > > + .quirks = &mt7622_i2c_quirks, > > + .pmic_i2c = 0, > > + .dcm = 1, > > + .auto_restart = 1, > > + .aux_len_reg = 1, > > + .support_33bits = 0, > > +}; > > + > > static const struct mtk_i2c_compatible mt8173_compat = { > > .pmic_i2c = 0, > > .dcm = 1, > > @@ -201,6 +218,7 @@ struct mtk_i2c { > > static const struct of_device_id mtk_i2c_of_match[] = { > > { .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat }, > > { .compatible = "mediatek,mt6589-i2c", .data = &mt6589_compat }, > > + { .compatible = "mediatek,mt7622-i2c", .data = &mt7622_compat }, > > { .compatible = "mediatek,mt8173-i2c", .data = &mt8173_compat }, > > {} > > }; > >
[PATCH 0/2] Add i2c dt-binding and compatible for Mediatek MT7622 SoC
This patch series based on v4.13-rc1, include MT7622 i2c dt-binding and compatible. Jun Gao (2): dt-bindings: i2c: Add MediaTek MT7622 i2c binding i2c: mediatek: Add i2c compatible for MediaTek MT7622 Documentation/devicetree/bindings/i2c/i2c-mtk.txt | 11 ++- drivers/i2c/busses/i2c-mt65xx.c | 18 ++ 2 files changed, 24 insertions(+), 5 deletions(-) -- 1.8.1.1
[PATCH 2/2] i2c: mediatek: Add i2c compatible for MediaTek MT7622
From: Jun Gao Add i2c compatible for MT7622. Compare to MT8173 i2c controller, MT7622 limit message size to 255, and not support 4GB DMA mode. Signed-off-by: Jun Gao --- drivers/i2c/busses/i2c-mt65xx.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 9bedf0b..2c7f847 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -172,6 +172,14 @@ struct mtk_i2c { .max_comb_2nd_msg_len = 31, }; +static const struct i2c_adapter_quirks mt7622_i2c_quirks = { + .max_num_msgs = 255, + .max_write_len = 65535, + .max_read_len = 65535, + .max_comb_1st_msg_len = 65535, + .max_comb_2nd_msg_len = 65535, +}; + static const struct mtk_i2c_compatible mt6577_compat = { .quirks = &mt6577_i2c_quirks, .pmic_i2c = 0, @@ -190,6 +198,15 @@ struct mtk_i2c { .support_33bits = 0, }; +static const struct mtk_i2c_compatible mt7622_compat = { + .quirks = &mt7622_i2c_quirks, + .pmic_i2c = 0, + .dcm = 1, + .auto_restart = 1, + .aux_len_reg = 1, + .support_33bits = 0, +}; + static const struct mtk_i2c_compatible mt8173_compat = { .pmic_i2c = 0, .dcm = 1, @@ -201,6 +218,7 @@ struct mtk_i2c { static const struct of_device_id mtk_i2c_of_match[] = { { .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat }, { .compatible = "mediatek,mt6589-i2c", .data = &mt6589_compat }, + { .compatible = "mediatek,mt7622-i2c", .data = &mt7622_compat }, { .compatible = "mediatek,mt8173-i2c", .data = &mt8173_compat }, {} }; -- 1.8.1.1
[PATCH 1/2] dt-bindings: i2c: Add MediaTek MT7622 i2c binding
From: Jun Gao Add MT7622 i2c binding to binding file. Compare to MT8173 i2c controller, MT7622 limit message size to 255, and not support 4GB DMA mode. Signed-off-by: Jun Gao --- Documentation/devicetree/bindings/i2c/i2c-mtk.txt | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt index bd5a7be..ff9ac61 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mtk.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-mtk.txt @@ -4,11 +4,12 @@ The Mediatek's I2C controller is used to interface with I2C devices. Required properties: - compatible: value should be either of the following. - "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek mt2701 - "mediatek,mt6577-i2c": for i2c compatible with mt6577. - "mediatek,mt6589-i2c": for i2c compatible with mt6589. - "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for i2c compatible with mt7623. - "mediatek,mt8173-i2c": for i2c compatible with mt8173. + "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek MT2701 + "mediatek,mt6577-i2c": for Mediatek MT6577 + "mediatek,mt6589-i2c": for Mediatek MT6589 + "mediatek,mt7622-i2c": for Mediatek MT7622 + "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for Mediatek MT7623 + "mediatek,mt8173-i2c": for Mediatek MT8173 - reg: physical base address of the controller and dma base, length of memory mapped region. - interrupts: interrupt number to the cpu. -- 1.8.1.1
[RESEND PATCH v1] i2c: mediatek: send i2c master code at 400k
From: Jun Gao The speed of sending i2c master code in high-speed mode depends on source clock, clock-div and TIMING register. The source clock and clock-div of different SoC are not all the same. In order to send i2c master code at 400k in high-speed mode, a appropriate value should be set to TIMING register for a certain source clock and clock-div. Signed-off-by: Jun Gao --- drivers/i2c/busses/i2c-mt65xx.c | 65 + 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 45d6171..9bedf0b 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -50,7 +50,6 @@ #define I2C_FS_START_CON 0x1800 #define I2C_TIME_CLR_VALUE 0x #define I2C_TIME_DEFAULT_VALUE 0x0003 -#define I2C_FS_TIME_INIT_VALUE 0x1303 #define I2C_WRRD_TRANAC_VALUE 0x0002 #define I2C_RD_TRANAC_VALUE0x0001 @@ -154,6 +153,7 @@ struct mtk_i2c { bool use_push_pull; /* IO config push-pull mode */ u16 irq_stat; /* interrupt status */ + unsigned int clk_src_div; unsigned int speed_hz; /* The speed in transfer */ enum mtk_trans_op op; u16 timing_reg; @@ -285,23 +285,20 @@ static void mtk_i2c_init_hw(struct mtk_i2c *i2c) * less than or equal to i2c->speed_hz. The calculation try to get * sample_cnt and step_cn */ -static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk, -unsigned int clock_div) +static int mtk_i2c_calculate_speed(struct mtk_i2c *i2c, unsigned int clk_src, + unsigned int target_speed, + unsigned int *timing_step_cnt, + unsigned int *timing_sample_cnt) { - unsigned int clk_src; unsigned int step_cnt; unsigned int sample_cnt; unsigned int max_step_cnt; - unsigned int target_speed; unsigned int base_sample_cnt = MAX_SAMPLE_CNT_DIV; unsigned int base_step_cnt; unsigned int opt_div; unsigned int best_mul; unsigned int cnt_mul; - clk_src = parent_clk / clock_div; - target_speed = i2c->speed_hz; - if (target_speed > MAX_HS_MODE_SPEED) target_speed = MAX_HS_MODE_SPEED; @@ -347,16 +344,48 @@ static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk, return -EINVAL; } - step_cnt--; - sample_cnt--; + *timing_step_cnt = step_cnt - 1; + *timing_sample_cnt = sample_cnt - 1; + + return 0; +} + +static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk) +{ + unsigned int clk_src; + unsigned int step_cnt; + unsigned int sample_cnt; + unsigned int target_speed; + int ret; + + clk_src = parent_clk / i2c->clk_src_div; + target_speed = i2c->speed_hz; if (target_speed > MAX_FS_MODE_SPEED) { + /* Set master code speed register */ + ret = mtk_i2c_calculate_speed(i2c, clk_src, MAX_FS_MODE_SPEED, + &step_cnt, &sample_cnt); + if (ret < 0) + return ret; + + i2c->timing_reg = (sample_cnt << 8) | step_cnt; + /* Set the high speed mode register */ - i2c->timing_reg = I2C_FS_TIME_INIT_VALUE; + ret = mtk_i2c_calculate_speed(i2c, clk_src, target_speed, + &step_cnt, &sample_cnt); + if (ret < 0) + return ret; + i2c->high_speed_reg = I2C_TIME_DEFAULT_VALUE | (sample_cnt << 12) | (step_cnt << 8); } else { - i2c->timing_reg = (sample_cnt << 8) | (step_cnt << 0); + ret = mtk_i2c_calculate_speed(i2c, clk_src, target_speed, + &step_cnt, &sample_cnt); + if (ret < 0) + return ret; + + i2c->timing_reg = (sample_cnt << 8) | step_cnt; + /* Disable the high speed transaction */ i2c->high_speed_reg = I2C_TIME_CLR_VALUE; } @@ -647,8 +676,7 @@ static u32 mtk_i2c_functionality(struct i2c_adapter *adap) .functionality = mtk_i2c_functionality, }; -static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c, - unsigned int *clk_src_div) +static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c) { int ret; @@ -656,11 +684,11 @@ static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c, if (ret < 0) i2c-&g
[PATCH v1] i2c: mediatek: send i2c master code at 400k
From: Jun Gao The speed of sending i2c master code in high-speed mode depends on source clock, clock-div and TIMING register. The source clock and clock-div of different SoC are not all the same. In order to send i2c master code at 400k in high-speed mode, a appropriate value should be set to TIMING register for a certain source clock and clock-div. Signed-off-by: Jun Gao --- drivers/i2c/busses/i2c-mt65xx.c | 65 + 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 45d6171..9bedf0b 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -50,7 +50,6 @@ #define I2C_FS_START_CON 0x1800 #define I2C_TIME_CLR_VALUE 0x #define I2C_TIME_DEFAULT_VALUE 0x0003 -#define I2C_FS_TIME_INIT_VALUE 0x1303 #define I2C_WRRD_TRANAC_VALUE 0x0002 #define I2C_RD_TRANAC_VALUE0x0001 @@ -154,6 +153,7 @@ struct mtk_i2c { bool use_push_pull; /* IO config push-pull mode */ u16 irq_stat; /* interrupt status */ + unsigned int clk_src_div; unsigned int speed_hz; /* The speed in transfer */ enum mtk_trans_op op; u16 timing_reg; @@ -285,23 +285,20 @@ static void mtk_i2c_init_hw(struct mtk_i2c *i2c) * less than or equal to i2c->speed_hz. The calculation try to get * sample_cnt and step_cn */ -static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk, -unsigned int clock_div) +static int mtk_i2c_calculate_speed(struct mtk_i2c *i2c, unsigned int clk_src, + unsigned int target_speed, + unsigned int *timing_step_cnt, + unsigned int *timing_sample_cnt) { - unsigned int clk_src; unsigned int step_cnt; unsigned int sample_cnt; unsigned int max_step_cnt; - unsigned int target_speed; unsigned int base_sample_cnt = MAX_SAMPLE_CNT_DIV; unsigned int base_step_cnt; unsigned int opt_div; unsigned int best_mul; unsigned int cnt_mul; - clk_src = parent_clk / clock_div; - target_speed = i2c->speed_hz; - if (target_speed > MAX_HS_MODE_SPEED) target_speed = MAX_HS_MODE_SPEED; @@ -347,16 +344,48 @@ static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk, return -EINVAL; } - step_cnt--; - sample_cnt--; + *timing_step_cnt = step_cnt - 1; + *timing_sample_cnt = sample_cnt - 1; + + return 0; +} + +static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk) +{ + unsigned int clk_src; + unsigned int step_cnt; + unsigned int sample_cnt; + unsigned int target_speed; + int ret; + + clk_src = parent_clk / i2c->clk_src_div; + target_speed = i2c->speed_hz; if (target_speed > MAX_FS_MODE_SPEED) { + /* Set master code speed register */ + ret = mtk_i2c_calculate_speed(i2c, clk_src, MAX_FS_MODE_SPEED, + &step_cnt, &sample_cnt); + if (ret < 0) + return ret; + + i2c->timing_reg = (sample_cnt << 8) | step_cnt; + /* Set the high speed mode register */ - i2c->timing_reg = I2C_FS_TIME_INIT_VALUE; + ret = mtk_i2c_calculate_speed(i2c, clk_src, target_speed, + &step_cnt, &sample_cnt); + if (ret < 0) + return ret; + i2c->high_speed_reg = I2C_TIME_DEFAULT_VALUE | (sample_cnt << 12) | (step_cnt << 8); } else { - i2c->timing_reg = (sample_cnt << 8) | (step_cnt << 0); + ret = mtk_i2c_calculate_speed(i2c, clk_src, target_speed, + &step_cnt, &sample_cnt); + if (ret < 0) + return ret; + + i2c->timing_reg = (sample_cnt << 8) | step_cnt; + /* Disable the high speed transaction */ i2c->high_speed_reg = I2C_TIME_CLR_VALUE; } @@ -647,8 +676,7 @@ static u32 mtk_i2c_functionality(struct i2c_adapter *adap) .functionality = mtk_i2c_functionality, }; -static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c, - unsigned int *clk_src_div) +static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c) { int ret; @@ -656,11 +684,11 @@ static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c, if (ret < 0) i2c-&g
Re: [PATCH v4 2/2] arm: dts: Add Mediatek MT2701 i2c device node
On Wed, 2017-06-14 at 11:24 +0200, Matthias Brugger wrote: > > On 14/06/17 03:11, Jun Gao wrote: > > On Tue, 2017-06-13 at 15:45 +0200, Matthias Brugger wrote: > >> > >> On 13/06/17 15:23, Jun Gao wrote: > >>> On Tue, 2017-06-13 at 14:52 +0200, Matthias Brugger wrote: > >>>> > >>>> On 13/06/17 12:24, Jun Gao wrote: > >>>>> On Tue, 2017-06-13 at 11:36 +0200, Matthias Brugger wrote: > >>>>>> > >>>>>> On 12/06/17 13:54, Jun Gao wrote: > >>>>>>> On Fri, 2017-05-26 at 15:35 +0800, Jun Gao wrote: > >>>>>>>> From: Jun Gao > >>>>>>>> > >>>>>>>> Add MT2701 i2c device node. > >>>>>>>> > >>>>>>>> Signed-off-by: Jun Gao > >>>>>>>> --- > >>>>>>>> arch/arm/boot/dts/mt2701-evb.dts | 42 > >>>>>>>> > >>>>>>>> arch/arm/boot/dts/mt2701.dtsi| 42 > >>>>>>>> > >>>>>>>> 2 files changed, 84 insertions(+) > >>>>>> [...] > >>>>>>> > >>>>>>> Dear Matthias, > >>>>>>> > >>>>>>> Could you take this patch together with > >>>>>>> [PATCH v4 1/2]dt-bindings: i2c: Add Mediatek MT2701 i2c binding ? > >>>>>>> > >>>>>>> Thanks! > >>>>>>> > >>>>>> > >>>>>> They are both included in the pull request I send [1] [2], or do I miss > >>>>>> something? > >>>>>> > >>>>>> Regards, > >>>>>> Matthias > >>>>>> > >>>>>> [1] > >>>>>> https://github.com/mbgg/linux-mediatek/commit/729b7f8dbdaff270c53052897ea06486221a49a2 > >>>>>> [2] > >>>>>> https://github.com/mbgg/linux-mediatek/commit/c6c301d3ff7531894257acc4f4a73928a109bda1 > >>>>> > >>>>> Dear Matthias, > >>>>> > >>>>> Would you mind to use the same style as follows in i2c-mtk.txt of [2]? > >>>>> > >>>>> "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek MT2701 > >>>>> "mediatek,mt6577-i2c": for Mediatek MT6577 > >>>>> "mediatek,mt6589-i2c": for Mediatek MT6589 > >>>>> "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for Mediatek MT7623 > >>>>> "mediatek,mt8173-i2c": for Mediatek MT8173 > >>>>> > >>>>> > >>>>> Thanks! > >>>>> > >>>> > >>>> You mean I should fix-up the patch to fit to the new binding > >>>> description? Or do you mean it should be MT instead of mt? > >>>> > >>>> Regards, > >>>> Matthias > >>> > >>> Dear Matthias, > >>> > >>> I mean fix-up the patch to fit to the new binding description. Is it OK? > >>> > >> > >> Then I can't see the difference between what you are asking for and what > >> is already pushed to the repository. Please send a patch, that will make > >> things clearer. > >> > >> Regards, > >> Matthias > > > > Dear Matthias, > > > > like this: > > > > diff: > > Required properties: > > - compatible: value should be either of the following. > > - (a) "mediatek,mt6577-i2c", for i2c compatible with mt6577 i2c. > > - (b) "mediatek,mt6589-i2c", for i2c compatible with mt6589 i2c. > > - (c) "mediatek,mt8127-i2c", for i2c compatible with mt8127 i2c. > > - (d) "mediatek,mt8135-i2c", for i2c compatible with mt8135 i2c. > > - (e) "mediatek,mt8173-i2c", for i2c compatible with mt8173 i2c. > > + "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek > > MT2701 > > + "mediatek,mt6577-i2c": for Mediatek MT6577 > > + "mediatek,mt6589-i2c": for Mediatek MT6589 > > + "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for Mediatek > > MT7623 > > + "mediatek,mt8173-i2c": for Mediatek MT8173 > > - reg: physical base address of the controller and dma base, length > > of memory > > mapped region. > > - interrupts: interrupt number to the cpu. > > > > Please look at [2], this is already staged. > > [2] > https://github.com/mbgg/linux-mediatek/commit/c6c301d3ff7531894257acc4f4a73928a109bda1 Dear Matthias, base on [2] diff: "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek MT2701 - "mediatek,mt6577-i2c": for i2c compatible with mt6577 i2c. - "mediatek,mt6589-i2c": for i2c compatible with mt6589 i2c. - "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for i2c compatible with mt7623 i2c. - "mediatek,mt8173-i2c": for i2c compatible with mt8173 i2c. + "mediatek,mt6577-i2c": for Mediatek MT6577 + "mediatek,mt6589-i2c": for Mediatek MT6589 + "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for Mediatek MT7623 + "mediatek,mt8173-i2c": for Mediatek MT8173 Thanks!
Re: [PATCH v4 2/2] arm: dts: Add Mediatek MT2701 i2c device node
On Tue, 2017-06-13 at 15:45 +0200, Matthias Brugger wrote: > > On 13/06/17 15:23, Jun Gao wrote: > > On Tue, 2017-06-13 at 14:52 +0200, Matthias Brugger wrote: > >> > >> On 13/06/17 12:24, Jun Gao wrote: > >>> On Tue, 2017-06-13 at 11:36 +0200, Matthias Brugger wrote: > >>>> > >>>> On 12/06/17 13:54, Jun Gao wrote: > >>>>> On Fri, 2017-05-26 at 15:35 +0800, Jun Gao wrote: > >>>>>> From: Jun Gao > >>>>>> > >>>>>> Add MT2701 i2c device node. > >>>>>> > >>>>>> Signed-off-by: Jun Gao > >>>>>> --- > >>>>>> arch/arm/boot/dts/mt2701-evb.dts | 42 > >>>>>> > >>>>>> arch/arm/boot/dts/mt2701.dtsi| 42 > >>>>>> > >>>>>> 2 files changed, 84 insertions(+) > >>>> [...] > >>>>> > >>>>> Dear Matthias, > >>>>> > >>>>> Could you take this patch together with > >>>>> [PATCH v4 1/2]dt-bindings: i2c: Add Mediatek MT2701 i2c binding ? > >>>>> > >>>>> Thanks! > >>>>> > >>>> > >>>> They are both included in the pull request I send [1] [2], or do I miss > >>>> something? > >>>> > >>>> Regards, > >>>> Matthias > >>>> > >>>> [1] > >>>> https://github.com/mbgg/linux-mediatek/commit/729b7f8dbdaff270c53052897ea06486221a49a2 > >>>> [2] > >>>> https://github.com/mbgg/linux-mediatek/commit/c6c301d3ff7531894257acc4f4a73928a109bda1 > >>> > >>> Dear Matthias, > >>> > >>> Would you mind to use the same style as follows in i2c-mtk.txt of [2]? > >>> > >>> "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek MT2701 > >>> "mediatek,mt6577-i2c": for Mediatek MT6577 > >>> "mediatek,mt6589-i2c": for Mediatek MT6589 > >>> "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for Mediatek MT7623 > >>> "mediatek,mt8173-i2c": for Mediatek MT8173 > >>> > >>> > >>> Thanks! > >>> > >> > >> You mean I should fix-up the patch to fit to the new binding > >> description? Or do you mean it should be MT instead of mt? > >> > >> Regards, > >> Matthias > > > > Dear Matthias, > > > > I mean fix-up the patch to fit to the new binding description. Is it OK? > > > > Then I can't see the difference between what you are asking for and what > is already pushed to the repository. Please send a patch, that will make > things clearer. > > Regards, > Matthias Dear Matthias, like this: diff: Required properties: - compatible: value should be either of the following. - (a) "mediatek,mt6577-i2c", for i2c compatible with mt6577 i2c. - (b) "mediatek,mt6589-i2c", for i2c compatible with mt6589 i2c. - (c) "mediatek,mt8127-i2c", for i2c compatible with mt8127 i2c. - (d) "mediatek,mt8135-i2c", for i2c compatible with mt8135 i2c. - (e) "mediatek,mt8173-i2c", for i2c compatible with mt8173 i2c. + "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek MT2701 + "mediatek,mt6577-i2c": for Mediatek MT6577 + "mediatek,mt6589-i2c": for Mediatek MT6589 + "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for Mediatek MT7623 + "mediatek,mt8173-i2c": for Mediatek MT8173 - reg: physical base address of the controller and dma base, length of memory mapped region. - interrupts: interrupt number to the cpu. Thanks!
Re: [PATCH v4 2/2] arm: dts: Add Mediatek MT2701 i2c device node
On Tue, 2017-06-13 at 14:52 +0200, Matthias Brugger wrote: > > On 13/06/17 12:24, Jun Gao wrote: > > On Tue, 2017-06-13 at 11:36 +0200, Matthias Brugger wrote: > >> > >> On 12/06/17 13:54, Jun Gao wrote: > >>> On Fri, 2017-05-26 at 15:35 +0800, Jun Gao wrote: > >>>> From: Jun Gao > >>>> > >>>> Add MT2701 i2c device node. > >>>> > >>>> Signed-off-by: Jun Gao > >>>> --- > >>>>arch/arm/boot/dts/mt2701-evb.dts | 42 > >>>> > >>>>arch/arm/boot/dts/mt2701.dtsi| 42 > >>>> > >>>>2 files changed, 84 insertions(+) > >> [...] > >>> > >>> Dear Matthias, > >>> > >>> Could you take this patch together with > >>> [PATCH v4 1/2]dt-bindings: i2c: Add Mediatek MT2701 i2c binding ? > >>> > >>> Thanks! > >>> > >> > >> They are both included in the pull request I send [1] [2], or do I miss > >> something? > >> > >> Regards, > >> Matthias > >> > >> [1] > >> https://github.com/mbgg/linux-mediatek/commit/729b7f8dbdaff270c53052897ea06486221a49a2 > >> [2] > >> https://github.com/mbgg/linux-mediatek/commit/c6c301d3ff7531894257acc4f4a73928a109bda1 > > > > Dear Matthias, > > > > Would you mind to use the same style as follows in i2c-mtk.txt of [2]? > > > > "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek MT2701 > > "mediatek,mt6577-i2c": for Mediatek MT6577 > > "mediatek,mt6589-i2c": for Mediatek MT6589 > > "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for Mediatek MT7623 > > "mediatek,mt8173-i2c": for Mediatek MT8173 > > > > > > Thanks! > > > > You mean I should fix-up the patch to fit to the new binding > description? Or do you mean it should be MT instead of mt? > > Regards, > Matthias Dear Matthias, I mean fix-up the patch to fit to the new binding description. Is it OK? Thanks!
Re: [PATCH v4 2/2] arm: dts: Add Mediatek MT2701 i2c device node
On Tue, 2017-06-13 at 11:36 +0200, Matthias Brugger wrote: > > On 12/06/17 13:54, Jun Gao wrote: > > On Fri, 2017-05-26 at 15:35 +0800, Jun Gao wrote: > >> From: Jun Gao > >> > >> Add MT2701 i2c device node. > >> > >> Signed-off-by: Jun Gao > >> --- > >> arch/arm/boot/dts/mt2701-evb.dts | 42 > >> > >> arch/arm/boot/dts/mt2701.dtsi| 42 > >> > >> 2 files changed, 84 insertions(+) > [...] > > > > Dear Matthias, > > > > Could you take this patch together with > > [PATCH v4 1/2]dt-bindings: i2c: Add Mediatek MT2701 i2c binding ? > > > > Thanks! > > > > They are both included in the pull request I send [1] [2], or do I miss > something? > > Regards, > Matthias > > [1] > https://github.com/mbgg/linux-mediatek/commit/729b7f8dbdaff270c53052897ea06486221a49a2 > [2] > https://github.com/mbgg/linux-mediatek/commit/c6c301d3ff7531894257acc4f4a73928a109bda1 Dear Matthias, Would you mind to use the same style as follows in i2c-mtk.txt of [2]? "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek MT2701 "mediatek,mt6577-i2c": for Mediatek MT6577 "mediatek,mt6589-i2c": for Mediatek MT6589 "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for Mediatek MT7623 "mediatek,mt8173-i2c": for Mediatek MT8173 Thanks!
Re: [PATCH v4 2/2] arm: dts: Add Mediatek MT2701 i2c device node
On Fri, 2017-05-26 at 15:35 +0800, Jun Gao wrote: > From: Jun Gao > > Add MT2701 i2c device node. > > Signed-off-by: Jun Gao > --- > arch/arm/boot/dts/mt2701-evb.dts | 42 > > arch/arm/boot/dts/mt2701.dtsi| 42 > > 2 files changed, 84 insertions(+) > > diff --git a/arch/arm/boot/dts/mt2701-evb.dts > b/arch/arm/boot/dts/mt2701-evb.dts > index a483798..3f5a96c 100644 > --- a/arch/arm/boot/dts/mt2701-evb.dts > +++ b/arch/arm/boot/dts/mt2701-evb.dts > @@ -28,7 +28,49 @@ > status = "okay"; > }; > > +&i2c0 { > + pinctrl-names = "default"; > + pinctrl-0 = <&i2c0_pins_a>; > + status = "okay"; > +}; > + > +&i2c1 { > + pinctrl-names = "default"; > + pinctrl-0 = <&i2c1_pins_a>; > + status = "okay"; > +}; > + > +&i2c2 { > + pinctrl-names = "default"; > + pinctrl-0 = <&i2c2_pins_a>; > + status = "okay"; > +}; > + > &pio { > + i2c0_pins_a: i2c0@0 { > + pins1 { > + pinmux = , > + ; > + bias-disable; > + }; > + }; > + > + i2c1_pins_a: i2c1@0 { > + pins1 { > + pinmux = , > + ; > + bias-disable; > + }; > + }; > + > + i2c2_pins_a: i2c2@0 { > + pins1 { > + pinmux = , > + ; > + bias-disable; > + }; > + }; > + > spi_pins_a: spi0@0 { > pins_spi { > pinmux = , > diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi > index 8037210..1b6157e 100644 > --- a/arch/arm/boot/dts/mt2701.dtsi > +++ b/arch/arm/boot/dts/mt2701.dtsi > @@ -286,6 +286,48 @@ > status = "disabled"; > }; > > + i2c0: i2c@11007000 { > + compatible = "mediatek,mt2701-i2c", > + "mediatek,mt6577-i2c"; > + reg = <0 0x11007000 0 0x70>, > + <0 0x11000200 0 0x80>; > + interrupts = ; > + clock-div = <16>; > + clocks = <&pericfg CLK_PERI_I2C0>, <&pericfg CLK_PERI_AP_DMA>; > + clock-names = "main", "dma"; > + #address-cells = <1>; > + #size-cells = <0>; > + status = "disabled"; > + }; > + > + i2c1: i2c@11008000 { > + compatible = "mediatek,mt2701-i2c", > + "mediatek,mt6577-i2c"; > + reg = <0 0x11008000 0 0x70>, > + <0 0x11000280 0 0x80>; > + interrupts = ; > + clock-div = <16>; > + clocks = <&pericfg CLK_PERI_I2C1>, <&pericfg CLK_PERI_AP_DMA>; > + clock-names = "main", "dma"; > + #address-cells = <1>; > + #size-cells = <0>; > + status = "disabled"; > + }; > + > + i2c2: i2c@11009000 { > + compatible = "mediatek,mt2701-i2c", > + "mediatek,mt6577-i2c"; > + reg = <0 0x11009000 0 0x70>, > + <0 0x11000300 0 0x80>; > + interrupts = ; > + clock-div = <16>; > + clocks = <&pericfg CLK_PERI_I2C2>, <&pericfg CLK_PERI_AP_DMA>; > + clock-names = "main", "dma"; > + #address-cells = <1>; > + #size-cells = <0>; > + status = "disabled"; > + }; > + > spi0: spi@1100a000 { > compatible = "mediatek,mt2701-spi"; > #address-cells = <1>; Dear Matthias, Could you take this patch together with [PATCH v4 1/2]dt-bindings: i2c: Add Mediatek MT2701 i2c binding ? Thanks!
Re: [PATCH v4 1/2] dt-bindings: i2c: Add Mediatek MT2701 i2c binding
On Tue, 2017-05-30 at 16:38 -0500, Rob Herring wrote: > On Mon, May 29, 2017 at 05:30:26PM +0200, Matthias Brugger wrote: > g> > > > > On 26/05/17 09:35, Jun Gao wrote: > > > From: Jun Gao > > > > > > Add MT2701 i2c binding to i2c-mt6577.txt and there is no need to > > > modify i2c driver. > > > > > > Signed-off-by: Jun Gao > > > --- > > > Documentation/devicetree/bindings/i2c/i2c-mt6577.txt | 11 ++- > > > 1 file changed, 6 insertions(+), 5 deletions(-) > > > > > > diff --git a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt > > > b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt > > > index 0ce6fa3..52f2023 100644 > > > --- a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt > > > +++ b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt > > > @@ -4,11 +4,12 @@ The Mediatek's I2C controller is used to interface with > > > I2C devices. > > > Required properties: > > > - compatible: value should be either of the following. > > > - (a) "mediatek,mt6577-i2c", for i2c compatible with mt6577 i2c. > > > - (b) "mediatek,mt6589-i2c", for i2c compatible with mt6589 i2c. > > > - (c) "mediatek,mt8127-i2c", for i2c compatible with mt8127 i2c. > > > - (d) "mediatek,mt8135-i2c", for i2c compatible with mt8135 i2c. > > > - (e) "mediatek,mt8173-i2c", for i2c compatible with mt8173 i2c. > > > + "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek MT2701 > > > > I send a cleanup patch for the file, which fixes all the other SoCs. > > I can fold this one into it, a soon as I got a Signed-off from the DT > > maintainers. > > I already acked it on the prior versions. > > Rob Hi Matthias, Which patch should I use now? Or you help to modify dt-binding, I only send dtsi file patch ? Thanks!
[PATCH v4 2/2] arm: dts: Add Mediatek MT2701 i2c device node
From: Jun Gao Add MT2701 i2c device node. Signed-off-by: Jun Gao --- arch/arm/boot/dts/mt2701-evb.dts | 42 arch/arm/boot/dts/mt2701.dtsi| 42 2 files changed, 84 insertions(+) diff --git a/arch/arm/boot/dts/mt2701-evb.dts b/arch/arm/boot/dts/mt2701-evb.dts index a483798..3f5a96c 100644 --- a/arch/arm/boot/dts/mt2701-evb.dts +++ b/arch/arm/boot/dts/mt2701-evb.dts @@ -28,7 +28,49 @@ status = "okay"; }; +&i2c0 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c0_pins_a>; + status = "okay"; +}; + +&i2c1 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c1_pins_a>; + status = "okay"; +}; + +&i2c2 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c2_pins_a>; + status = "okay"; +}; + &pio { + i2c0_pins_a: i2c0@0 { + pins1 { + pinmux = , +; + bias-disable; + }; + }; + + i2c1_pins_a: i2c1@0 { + pins1 { + pinmux = , +; + bias-disable; + }; + }; + + i2c2_pins_a: i2c2@0 { + pins1 { + pinmux = , +; + bias-disable; + }; + }; + spi_pins_a: spi0@0 { pins_spi { pinmux = , diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi index 8037210..1b6157e 100644 --- a/arch/arm/boot/dts/mt2701.dtsi +++ b/arch/arm/boot/dts/mt2701.dtsi @@ -286,6 +286,48 @@ status = "disabled"; }; + i2c0: i2c@11007000 { + compatible = "mediatek,mt2701-i2c", +"mediatek,mt6577-i2c"; + reg = <0 0x11007000 0 0x70>, + <0 0x11000200 0 0x80>; + interrupts = ; + clock-div = <16>; + clocks = <&pericfg CLK_PERI_I2C0>, <&pericfg CLK_PERI_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c1: i2c@11008000 { + compatible = "mediatek,mt2701-i2c", +"mediatek,mt6577-i2c"; + reg = <0 0x11008000 0 0x70>, + <0 0x11000280 0 0x80>; + interrupts = ; + clock-div = <16>; + clocks = <&pericfg CLK_PERI_I2C1>, <&pericfg CLK_PERI_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c2: i2c@11009000 { + compatible = "mediatek,mt2701-i2c", +"mediatek,mt6577-i2c"; + reg = <0 0x11009000 0 0x70>, + <0 0x11000300 0 0x80>; + interrupts = ; + clock-div = <16>; + clocks = <&pericfg CLK_PERI_I2C2>, <&pericfg CLK_PERI_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + spi0: spi@1100a000 { compatible = "mediatek,mt2701-spi"; #address-cells = <1>; -- 1.8.1.1
[PATCH v4 1/2] dt-bindings: i2c: Add Mediatek MT2701 i2c binding
From: Jun Gao Add MT2701 i2c binding to i2c-mt6577.txt and there is no need to modify i2c driver. Signed-off-by: Jun Gao --- Documentation/devicetree/bindings/i2c/i2c-mt6577.txt | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt index 0ce6fa3..52f2023 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt @@ -4,11 +4,12 @@ The Mediatek's I2C controller is used to interface with I2C devices. Required properties: - compatible: value should be either of the following. - (a) "mediatek,mt6577-i2c", for i2c compatible with mt6577 i2c. - (b) "mediatek,mt6589-i2c", for i2c compatible with mt6589 i2c. - (c) "mediatek,mt8127-i2c", for i2c compatible with mt8127 i2c. - (d) "mediatek,mt8135-i2c", for i2c compatible with mt8135 i2c. - (e) "mediatek,mt8173-i2c", for i2c compatible with mt8173 i2c. + "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek MT2701 + "mediatek,mt6577-i2c": for Mediatek MT6577 + "mediatek,mt6589-i2c": for Mediatek MT6589 + "mediatek,mt8127-i2c": for Mediatek MT8127 + "mediatek,mt8135-i2c": for Mediatek MT8135 + "mediatek,mt8173-i2c": for Mediatek MT8173 - reg: physical base address of the controller and dma base, length of memory mapped region. - interrupts: interrupt number to the cpu. -- 1.8.1.1
[PATCH v4 0/2] Add i2c dt-binding and device node for Mediatek MT2701 Soc
This patch series based on v4.12-rc1, include MT2701 i2c dt-binding and device node. changes since v3: - Add fallback compatible to dt-binding changes since v2: - Modify commit message - Revise dt-binding documentation changes since v1: - Modify commit message Dependent on "Add clock and power domain DT nodes for Mediatek MT2701"[1]. [1] http://lists.infradead.org/pipermail/linux-mediatek/2016-December/007637.html Jun Gao (2): dt-bindings: i2c: Add Mediatek MT2701 i2c binding arm: dts: Add Mediatek MT2701 i2c device node .../devicetree/bindings/i2c/i2c-mt6577.txt | 11 +++--- arch/arm/boot/dts/mt2701-evb.dts | 42 ++ arch/arm/boot/dts/mt2701.dtsi | 42 ++ 3 files changed, 90 insertions(+), 5 deletions(-) -- 1.8.1.1
Re: [RESEND PATCH v3 1/2] dt-bindings: i2c: Add Mediatek MT2701 i2c binding
On Wed, 2017-05-10 at 12:35 +0200, Matthias Brugger wrote: > > On 28/03/17 21:22, Wolfram Sang wrote: > > On Tue, Mar 28, 2017 at 05:50:12PM +0800, Jun Gao wrote: > >> On Wed, 2017-03-22 at 10:05 +0100, Wolfram Sang wrote: > >>> On Thu, Mar 09, 2017 at 11:13:04AM +0800, Jun Gao wrote: > >>>> From: Jun Gao > >>>> > >>>> Add MT2701 i2c binding to i2c-mt6577.txt and there is no need to > >>>> modify i2c driver. > >>>> > >>>> Signed-off-by: Jun Gao > >>> > >>> There is still the issue which Matthias Brugger pointed out on January, > >>> 24th: you need to describe the fallback compatibles. > >>> > >> > >> IMHO the value under compatible are just inputs which can be accepted. > >> It's little strange to add fallback information in binding. Some other > >> bindings do not describe so detailedly. > >> Is it OK to make binding as minimum standard? > >> If we describe it very detailedly, we will have to modify binding if > >> there are some changes for mt2701. > > > > My reading of the below is that I could simply use "mediatek,mt2701-i2c" > > as compatible and things will work. But it won't, we don't have that in > > the driver IIRC. So, we need a fallback for that to work. > > > >> Rob, could you give some suggestions? Thanks! > > > > Would be welcome, yes. I lost track what the preferred solution is. > > > > We will need to define the fallback binding for each SoC. > As example take the rockchip mmc: > http://elixir.free-electrons.com/linux/latest/source/Documentation/devicetree/bindings/mmc/rockchip-dw-mshc.txt > > Regards, > Matthias > Hi Rob, There is no such requirement for other components. Could you give us some suggestions? Thanks! > >> > >>>> --- > >>>> .../devicetree/bindings/i2c/i2c-mt6577.txt | 11 ++- > >>>> 1 file changed, 6 insertions(+), 5 deletions(-) > >>>> > >>>> diff --git a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt > >>>> b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt > >>>> index 0ce6fa3..27dbbf9 100644 > >>>> --- a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt > >>>> +++ b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt > >>>> @@ -4,11 +4,12 @@ The Mediatek's I2C controller is used to interface > >>>> with I2C devices. > >>>> > >>>> Required properties: > >>>> - compatible: value should be either of the following. > >>>> - (a) "mediatek,mt6577-i2c", for i2c compatible with mt6577 i2c. > >>>> - (b) "mediatek,mt6589-i2c", for i2c compatible with mt6589 i2c. > >>>> - (c) "mediatek,mt8127-i2c", for i2c compatible with mt8127 i2c. > >>>> - (d) "mediatek,mt8135-i2c", for i2c compatible with mt8135 i2c. > >>>> - (e) "mediatek,mt8173-i2c", for i2c compatible with mt8173 i2c. > >>>> +"mediatek,mt2701-i2c" > >>>> +"mediatek,mt6577-i2c" > >>>> +"mediatek,mt6589-i2c" > >>>> +"mediatek,mt8127-i2c" > >>>> +"mediatek,mt8135-i2c" > >>>> +"mediatek,mt8173-i2c" > >>>> - reg: physical base address of the controller and dma base, length > >>>> of memory > >>>> mapped region. > >>>> - interrupts: interrupt number to the cpu. > >>>> -- > >>>> 1.7.9.5 > >>>> > >> > >>
Re: [RESEND PATCH v3 1/2] dt-bindings: i2c: Add Mediatek MT2701 i2c binding
On Wed, 2017-03-22 at 10:05 +0100, Wolfram Sang wrote: > On Thu, Mar 09, 2017 at 11:13:04AM +0800, Jun Gao wrote: > > From: Jun Gao > > > > Add MT2701 i2c binding to i2c-mt6577.txt and there is no need to > > modify i2c driver. > > > > Signed-off-by: Jun Gao > > There is still the issue which Matthias Brugger pointed out on January, > 24th: you need to describe the fallback compatibles. > IMHO the value under compatible are just inputs which can be accepted. It's little strange to add fallback information in binding. Some other bindings do not describe so detailedly. Is it OK to make binding as minimum standard? If we describe it very detailedly, we will have to modify binding if there are some changes for mt2701. Rob, could you give some suggestions? Thanks! > > --- > > .../devicetree/bindings/i2c/i2c-mt6577.txt | 11 ++- > > 1 file changed, 6 insertions(+), 5 deletions(-) > > > > diff --git a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt > > b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt > > index 0ce6fa3..27dbbf9 100644 > > --- a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt > > +++ b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt > > @@ -4,11 +4,12 @@ The Mediatek's I2C controller is used to interface with > > I2C devices. > > > > Required properties: > >- compatible: value should be either of the following. > > - (a) "mediatek,mt6577-i2c", for i2c compatible with mt6577 i2c. > > - (b) "mediatek,mt6589-i2c", for i2c compatible with mt6589 i2c. > > - (c) "mediatek,mt8127-i2c", for i2c compatible with mt8127 i2c. > > - (d) "mediatek,mt8135-i2c", for i2c compatible with mt8135 i2c. > > - (e) "mediatek,mt8173-i2c", for i2c compatible with mt8173 i2c. > > + "mediatek,mt2701-i2c" > > + "mediatek,mt6577-i2c" > > + "mediatek,mt6589-i2c" > > + "mediatek,mt8127-i2c" > > + "mediatek,mt8135-i2c" > > + "mediatek,mt8173-i2c" > >- reg: physical base address of the controller and dma base, length of > > memory > > mapped region. > >- interrupts: interrupt number to the cpu. > > -- > > 1.7.9.5 > >
[RESEND PATCH v3 2/2] arm: dts: Add Mediatek MT2701 i2c device node
From: Jun Gao Add MT2701 i2c device node. Signed-off-by: Jun Gao --- arch/arm/boot/dts/mt2701-evb.dts | 42 ++ arch/arm/boot/dts/mt2701.dtsi| 42 ++ 2 files changed, 84 insertions(+) diff --git a/arch/arm/boot/dts/mt2701-evb.dts b/arch/arm/boot/dts/mt2701-evb.dts index a483798..3f5a96c 100644 --- a/arch/arm/boot/dts/mt2701-evb.dts +++ b/arch/arm/boot/dts/mt2701-evb.dts @@ -28,7 +28,49 @@ status = "okay"; }; +&i2c0 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c0_pins_a>; + status = "okay"; +}; + +&i2c1 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c1_pins_a>; + status = "okay"; +}; + +&i2c2 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c2_pins_a>; + status = "okay"; +}; + &pio { + i2c0_pins_a: i2c0@0 { + pins1 { + pinmux = , +; + bias-disable; + }; + }; + + i2c1_pins_a: i2c1@0 { + pins1 { + pinmux = , +; + bias-disable; + }; + }; + + i2c2_pins_a: i2c2@0 { + pins1 { + pinmux = , +; + bias-disable; + }; + }; + spi_pins_a: spi0@0 { pins_spi { pinmux = , diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi index 8037210..1b6157e 100644 --- a/arch/arm/boot/dts/mt2701.dtsi +++ b/arch/arm/boot/dts/mt2701.dtsi @@ -286,6 +286,48 @@ status = "disabled"; }; + i2c0: i2c@11007000 { + compatible = "mediatek,mt2701-i2c", +"mediatek,mt6577-i2c"; + reg = <0 0x11007000 0 0x70>, + <0 0x11000200 0 0x80>; + interrupts = ; + clock-div = <16>; + clocks = <&pericfg CLK_PERI_I2C0>, <&pericfg CLK_PERI_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c1: i2c@11008000 { + compatible = "mediatek,mt2701-i2c", +"mediatek,mt6577-i2c"; + reg = <0 0x11008000 0 0x70>, + <0 0x11000280 0 0x80>; + interrupts = ; + clock-div = <16>; + clocks = <&pericfg CLK_PERI_I2C1>, <&pericfg CLK_PERI_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c2: i2c@11009000 { + compatible = "mediatek,mt2701-i2c", +"mediatek,mt6577-i2c"; + reg = <0 0x11009000 0 0x70>, + <0 0x11000300 0 0x80>; + interrupts = ; + clock-div = <16>; + clocks = <&pericfg CLK_PERI_I2C2>, <&pericfg CLK_PERI_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + spi0: spi@1100a000 { compatible = "mediatek,mt2701-spi"; #address-cells = <1>; -- 1.7.9.5
[RESEND PATCH v3 1/2] dt-bindings: i2c: Add Mediatek MT2701 i2c binding
From: Jun Gao Add MT2701 i2c binding to i2c-mt6577.txt and there is no need to modify i2c driver. Signed-off-by: Jun Gao --- .../devicetree/bindings/i2c/i2c-mt6577.txt | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt index 0ce6fa3..27dbbf9 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt @@ -4,11 +4,12 @@ The Mediatek's I2C controller is used to interface with I2C devices. Required properties: - compatible: value should be either of the following. - (a) "mediatek,mt6577-i2c", for i2c compatible with mt6577 i2c. - (b) "mediatek,mt6589-i2c", for i2c compatible with mt6589 i2c. - (c) "mediatek,mt8127-i2c", for i2c compatible with mt8127 i2c. - (d) "mediatek,mt8135-i2c", for i2c compatible with mt8135 i2c. - (e) "mediatek,mt8173-i2c", for i2c compatible with mt8173 i2c. + "mediatek,mt2701-i2c" + "mediatek,mt6577-i2c" + "mediatek,mt6589-i2c" + "mediatek,mt8127-i2c" + "mediatek,mt8135-i2c" + "mediatek,mt8173-i2c" - reg: physical base address of the controller and dma base, length of memory mapped region. - interrupts: interrupt number to the cpu. -- 1.7.9.5
[RESEND PATCH v3 0/2] Add i2c dt-binding and device node for Mediatek MT2701 Soc
This patch series based on v4.11-rc1, include MT2701 i2c dt-binding and device node. changes since v2: - Modify commit message - Revise dt-binding documentation changes since v1: - Modify commit message Dependent on "Add clock and power domain DT nodes for Mediatek MT2701"[1]. [1] http://lists.infradead.org/pipermail/linux-mediatek/2016-December/007637.html Jun Gao (2): dt-bindings: i2c: Add Mediatek MT2701 i2c binding arm: dts: Add Mediatek MT2701 i2c device node .../devicetree/bindings/i2c/i2c-mt6577.txt | 11 ++--- arch/arm/boot/dts/mt2701-evb.dts | 42 arch/arm/boot/dts/mt2701.dtsi | 42 3 files changed, 90 insertions(+), 5 deletions(-) -- 1.7.9.5
[PATCH v3 0/2] Add i2c dt-binding and device node for Mediatek MT2701 Soc
This patch series based on v4.10-rc2, include MT2701 i2c dt-binding and device node. changes since v2: - Modify commit message - Revise dt-binding documentation changes since v1: - Modify commit message Dependent on "Add clock and power domain DT nodes for Mediatek MT2701"[1]. [1] http://lists.infradead.org/pipermail/linux-mediatek/2016-December/007637.html Jun Gao (2): dt-bindings: i2c: Add Mediatek MT2701 i2c binding arm: dts: Add Mediatek MT2701 i2c device node .../devicetree/bindings/i2c/i2c-mt6577.txt | 11 ++--- arch/arm/boot/dts/mt2701-evb.dts | 44 arch/arm/boot/dts/mt2701.dtsi | 42 +++ 3 files changed, 92 insertions(+), 5 deletions(-) -- 1.7.9.5
[PATCH v3 1/2] dt-bindings: i2c: Add Mediatek MT2701 i2c binding
From: Jun Gao Add MT2701 i2c binding to i2c-mt6577.txt and there is no need to modify i2c driver. Signed-off-by: Jun Gao --- .../devicetree/bindings/i2c/i2c-mt6577.txt | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt index 0ce6fa3..27dbbf9 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt @@ -4,11 +4,12 @@ The Mediatek's I2C controller is used to interface with I2C devices. Required properties: - compatible: value should be either of the following. - (a) "mediatek,mt6577-i2c", for i2c compatible with mt6577 i2c. - (b) "mediatek,mt6589-i2c", for i2c compatible with mt6589 i2c. - (c) "mediatek,mt8127-i2c", for i2c compatible with mt8127 i2c. - (d) "mediatek,mt8135-i2c", for i2c compatible with mt8135 i2c. - (e) "mediatek,mt8173-i2c", for i2c compatible with mt8173 i2c. + "mediatek,mt2701-i2c" + "mediatek,mt6577-i2c" + "mediatek,mt6589-i2c" + "mediatek,mt8127-i2c" + "mediatek,mt8135-i2c" + "mediatek,mt8173-i2c" - reg: physical base address of the controller and dma base, length of memory mapped region. - interrupts: interrupt number to the cpu. -- 1.7.9.5
[PATCH v3 2/2] arm: dts: Add Mediatek MT2701 i2c device node
From: Jun Gao Add MT2701 i2c device node. Signed-off-by: Jun Gao --- arch/arm/boot/dts/mt2701-evb.dts | 44 ++ arch/arm/boot/dts/mt2701.dtsi| 42 2 files changed, 86 insertions(+) diff --git a/arch/arm/boot/dts/mt2701-evb.dts b/arch/arm/boot/dts/mt2701-evb.dts index 082ca88..a908e94 100644 --- a/arch/arm/boot/dts/mt2701-evb.dts +++ b/arch/arm/boot/dts/mt2701-evb.dts @@ -24,6 +24,50 @@ }; }; +&i2c0 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c0_pins_a>; + status = "okay"; +}; + +&i2c1 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c1_pins_a>; + status = "okay"; +}; + +&i2c2 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c2_pins_a>; + status = "okay"; +}; + +&pio { + i2c0_pins_a: i2c0@0 { + pins1 { + pinmux = , +; + bias-disable; + }; + }; + + i2c1_pins_a: i2c1@0 { + pins1 { + pinmux = , +; + bias-disable; + }; + }; + + i2c2_pins_a: i2c2@0 { + pins1 { + pinmux = , +; + bias-disable; + }; + }; +}; + &uart0 { status = "okay"; }; diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi index bdf8954..0d1539f 100644 --- a/arch/arm/boot/dts/mt2701.dtsi +++ b/arch/arm/boot/dts/mt2701.dtsi @@ -227,6 +227,48 @@ status = "disabled"; }; + i2c0: i2c@11007000 { + compatible = "mediatek,mt2701-i2c", +"mediatek,mt6577-i2c"; + reg = <0 0x11007000 0 0x70>, + <0 0x11000200 0 0x80>; + interrupts = ; + clock-div = <16>; + clocks = <&pericfg CLK_PERI_I2C0>, <&pericfg CLK_PERI_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c1: i2c@11008000 { + compatible = "mediatek,mt2701-i2c", +"mediatek,mt6577-i2c"; + reg = <0 0x11008000 0 0x70>, + <0 0x11000280 0 0x80>; + interrupts = ; + clock-div = <16>; + clocks = <&pericfg CLK_PERI_I2C1>, <&pericfg CLK_PERI_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c2: i2c@11009000 { + compatible = "mediatek,mt2701-i2c", +"mediatek,mt6577-i2c"; + reg = <0 0x11009000 0 0x70>, + <0 0x11000300 0 0x80>; + interrupts = ; + clock-div = <16>; + clocks = <&pericfg CLK_PERI_I2C2>, <&pericfg CLK_PERI_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + mmsys: syscon@1400 { compatible = "mediatek,mt2701-mmsys", "syscon"; reg = <0 0x1400 0 0x1000>; -- 1.7.9.5
[PATCH v2 2/2] arm: dts: mt2701: Add i2c device node
From: Jun Gao Add i2c device node for MT2701. Change-Id: Idd33ad9010c43809328814350f9c29284891d171 Signed-off-by: Jun Gao --- arch/arm/boot/dts/mt2701-evb.dts | 44 ++ arch/arm/boot/dts/mt2701.dtsi| 42 2 files changed, 86 insertions(+) diff --git a/arch/arm/boot/dts/mt2701-evb.dts b/arch/arm/boot/dts/mt2701-evb.dts index 082ca88..a908e94 100644 --- a/arch/arm/boot/dts/mt2701-evb.dts +++ b/arch/arm/boot/dts/mt2701-evb.dts @@ -24,6 +24,50 @@ }; }; +&i2c0 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c0_pins_a>; + status = "okay"; +}; + +&i2c1 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c1_pins_a>; + status = "okay"; +}; + +&i2c2 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c2_pins_a>; + status = "okay"; +}; + +&pio { + i2c0_pins_a: i2c0@0 { + pins1 { + pinmux = , +; + bias-disable; + }; + }; + + i2c1_pins_a: i2c1@0 { + pins1 { + pinmux = , +; + bias-disable; + }; + }; + + i2c2_pins_a: i2c2@0 { + pins1 { + pinmux = , +; + bias-disable; + }; + }; +}; + &uart0 { status = "okay"; }; diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi index bdf8954..0d1539f 100644 --- a/arch/arm/boot/dts/mt2701.dtsi +++ b/arch/arm/boot/dts/mt2701.dtsi @@ -227,6 +227,48 @@ status = "disabled"; }; + i2c0: i2c@11007000 { + compatible = "mediatek,mt2701-i2c", +"mediatek,mt6577-i2c"; + reg = <0 0x11007000 0 0x70>, + <0 0x11000200 0 0x80>; + interrupts = ; + clock-div = <16>; + clocks = <&pericfg CLK_PERI_I2C0>, <&pericfg CLK_PERI_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c1: i2c@11008000 { + compatible = "mediatek,mt2701-i2c", +"mediatek,mt6577-i2c"; + reg = <0 0x11008000 0 0x70>, + <0 0x11000280 0 0x80>; + interrupts = ; + clock-div = <16>; + clocks = <&pericfg CLK_PERI_I2C1>, <&pericfg CLK_PERI_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c2: i2c@11009000 { + compatible = "mediatek,mt2701-i2c", +"mediatek,mt6577-i2c"; + reg = <0 0x11009000 0 0x70>, + <0 0x11000300 0 0x80>; + interrupts = ; + clock-div = <16>; + clocks = <&pericfg CLK_PERI_I2C2>, <&pericfg CLK_PERI_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + mmsys: syscon@1400 { compatible = "mediatek,mt2701-mmsys", "syscon"; reg = <0 0x1400 0 0x1000>; -- 1.7.9.5
[PATCH v2 0/2] Add i2c DT binding and device node for Mediatek MT2701 Soc
This patch series based on v4.10-rc2, include MT2701 i2c DT binding and device node. changes since v1: - Modify commit message Dependent on "Add clock and power domain DT nodes for Mediatek MT2701"[1]. [1] http://lists.infradead.org/pipermail/linux-mediatek/2016-December/007637.html Jun Gao (2): Documentation: devicetree: Add i2c binding for mediatek MT2701 Soc Platform arm: dts: mt2701: Add i2c device node .../devicetree/bindings/i2c/i2c-mt6577.txt | 11 ++--- arch/arm/boot/dts/mt2701-evb.dts | 44 arch/arm/boot/dts/mt2701.dtsi | 42 +++ 3 files changed, 92 insertions(+), 5 deletions(-) -- 1.7.9.5
[PATCH v2 1/2] Documentation: devicetree: Add i2c binding for mediatek MT2701 Soc Platform
From: Jun Gao Add i2c DT binding to i2c-mt6577.txt for MT2701 and there is no need to modify i2c driver. Change-Id: I892f866d755aa3865bffd1a80884cd41b6ecc1f1 Signed-off-by: Jun Gao --- .../devicetree/bindings/i2c/i2c-mt6577.txt | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt index 0ce6fa3..ef22ecf 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt @@ -4,11 +4,12 @@ The Mediatek's I2C controller is used to interface with I2C devices. Required properties: - compatible: value should be either of the following. - (a) "mediatek,mt6577-i2c", for i2c compatible with mt6577 i2c. - (b) "mediatek,mt6589-i2c", for i2c compatible with mt6589 i2c. - (c) "mediatek,mt8127-i2c", for i2c compatible with mt8127 i2c. - (d) "mediatek,mt8135-i2c", for i2c compatible with mt8135 i2c. - (e) "mediatek,mt8173-i2c", for i2c compatible with mt8173 i2c. + "mediatek,mt2701-i2c", for i2c compatible with mt2701 i2c. + "mediatek,mt6577-i2c", for i2c compatible with mt6577 i2c. + "mediatek,mt6589-i2c", for i2c compatible with mt6589 i2c. + "mediatek,mt8127-i2c", for i2c compatible with mt8127 i2c. + "mediatek,mt8135-i2c", for i2c compatible with mt8135 i2c. + "mediatek,mt8173-i2c", for i2c compatible with mt8173 i2c. - reg: physical base address of the controller and dma base, length of memory mapped region. - interrupts: interrupt number to the cpu. -- 1.7.9.5
[RESEND PATCH 0/2] Add i2c DT binding and device node for Mediatek MT2701 Soc
This patch series based on v4.10-rc2, include MT2701 i2c DT binding and device node. Dependent on "Add clock and power domain DT nodes for Mediatek MT2701"[1]. [1] http://lists.infradead.org/pipermail/linux-mediatek/2016-December/007637.html Jun Gao (2): Documentation: devicetree: Add i2c binding for mediatek MT2701 Soc Platform arm: dts: mt2701: Add i2c device node .../devicetree/bindings/i2c/i2c-mt6577.txt | 11 ++--- arch/arm/boot/dts/mt2701-evb.dts | 44 arch/arm/boot/dts/mt2701.dtsi | 42 +++ 3 files changed, 92 insertions(+), 5 deletions(-) -- 1.7.9.5
[RESEND PATCH 2/2] arm: dts: mt2701: Add i2c device node
From: Jun Gao Add i2c device node for MT2701. Signed-off-by: Jun Gao --- arch/arm/boot/dts/mt2701-evb.dts | 44 ++ arch/arm/boot/dts/mt2701.dtsi| 42 2 files changed, 86 insertions(+) diff --git a/arch/arm/boot/dts/mt2701-evb.dts b/arch/arm/boot/dts/mt2701-evb.dts index 082ca88..a908e94 100644 --- a/arch/arm/boot/dts/mt2701-evb.dts +++ b/arch/arm/boot/dts/mt2701-evb.dts @@ -24,6 +24,50 @@ }; }; +&i2c0 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c0_pins_a>; + status = "okay"; +}; + +&i2c1 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c1_pins_a>; + status = "okay"; +}; + +&i2c2 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c2_pins_a>; + status = "okay"; +}; + +&pio { + i2c0_pins_a: i2c0@0 { + pins1 { + pinmux = , +; + bias-disable; + }; + }; + + i2c1_pins_a: i2c1@0 { + pins1 { + pinmux = , +; + bias-disable; + }; + }; + + i2c2_pins_a: i2c2@0 { + pins1 { + pinmux = , +; + bias-disable; + }; + }; +}; + &uart0 { status = "okay"; }; diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi index bdf8954..0d1539f 100644 --- a/arch/arm/boot/dts/mt2701.dtsi +++ b/arch/arm/boot/dts/mt2701.dtsi @@ -227,6 +227,48 @@ status = "disabled"; }; + i2c0: i2c@11007000 { + compatible = "mediatek,mt2701-i2c", +"mediatek,mt6577-i2c"; + reg = <0 0x11007000 0 0x70>, + <0 0x11000200 0 0x80>; + interrupts = ; + clock-div = <16>; + clocks = <&pericfg CLK_PERI_I2C0>, <&pericfg CLK_PERI_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c1: i2c@11008000 { + compatible = "mediatek,mt2701-i2c", +"mediatek,mt6577-i2c"; + reg = <0 0x11008000 0 0x70>, + <0 0x11000280 0 0x80>; + interrupts = ; + clock-div = <16>; + clocks = <&pericfg CLK_PERI_I2C1>, <&pericfg CLK_PERI_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c2: i2c@11009000 { + compatible = "mediatek,mt2701-i2c", +"mediatek,mt6577-i2c"; + reg = <0 0x11009000 0 0x70>, + <0 0x11000300 0 0x80>; + interrupts = ; + clock-div = <16>; + clocks = <&pericfg CLK_PERI_I2C2>, <&pericfg CLK_PERI_AP_DMA>; + clock-names = "main", "dma"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + mmsys: syscon@1400 { compatible = "mediatek,mt2701-mmsys", "syscon"; reg = <0 0x1400 0 0x1000>; -- 1.7.9.5
[RESEND PATCH 1/2] Documentation: devicetree: Add i2c binding for mediatek MT2701 Soc Platform
From: Jun Gao This add i2c DT binding to i2c-mt6577.txt for MT2701. Signed-off-by: Jun Gao --- .../devicetree/bindings/i2c/i2c-mt6577.txt | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt index 0ce6fa3..ef22ecf 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-mt6577.txt @@ -4,11 +4,12 @@ The Mediatek's I2C controller is used to interface with I2C devices. Required properties: - compatible: value should be either of the following. - (a) "mediatek,mt6577-i2c", for i2c compatible with mt6577 i2c. - (b) "mediatek,mt6589-i2c", for i2c compatible with mt6589 i2c. - (c) "mediatek,mt8127-i2c", for i2c compatible with mt8127 i2c. - (d) "mediatek,mt8135-i2c", for i2c compatible with mt8135 i2c. - (e) "mediatek,mt8173-i2c", for i2c compatible with mt8173 i2c. + "mediatek,mt2701-i2c", for i2c compatible with mt2701 i2c. + "mediatek,mt6577-i2c", for i2c compatible with mt6577 i2c. + "mediatek,mt6589-i2c", for i2c compatible with mt6589 i2c. + "mediatek,mt8127-i2c", for i2c compatible with mt8127 i2c. + "mediatek,mt8135-i2c", for i2c compatible with mt8135 i2c. + "mediatek,mt8173-i2c", for i2c compatible with mt8173 i2c. - reg: physical base address of the controller and dma base, length of memory mapped region. - interrupts: interrupt number to the cpu. -- 1.7.9.5