* [PATCH 2/2] i2c: exynos5: configure fifo_depth based on HSI2C module version @ 2013-11-22 6:14 Naveen Krishna Chatradhi 2013-11-26 4:26 ` [PATCH 2/2 v2] " Naveen Krishna Chatradhi ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: Naveen Krishna Chatradhi @ 2013-11-22 6:14 UTC (permalink / raw) To: linux-i2c-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, hs-ynQEQJNshbs Cc: khali-PUYAD+kWke1g9hUCZPvPmw, ben-linux-elnMNo+KYs3YtjvyW6yDsg, naveenkrishna.ch-Re5JQEeQqe8AvxtiuMwx3w fifo_depth of the HSI2C is not constant Exynos5420 and Exynos5250 supports fifo_depth of 64bytes Exynos5260 supports fifo_depth of 16bytes This patch configures the fifo_depth based on HSI2C modules version. Signed-off-by: Naveen Krishna Chatradhi <ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> --- drivers/i2c/busses/i2c-exynos5.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c index cbb49e2..19277d8 100644 --- a/drivers/i2c/busses/i2c-exynos5.c +++ b/drivers/i2c/busses/i2c-exynos5.c @@ -77,12 +77,6 @@ #define HSI2C_RXFIFO_TRIGGER_LEVEL(x) ((x) << 4) #define HSI2C_TXFIFO_TRIGGER_LEVEL(x) ((x) << 16) -/* As per user manual FIFO max depth is 64bytes */ -#define HSI2C_FIFO_MAX 0x40 -/* default trigger levels for Tx and Rx FIFOs */ -#define HSI2C_DEF_TXFIFO_LVL (HSI2C_FIFO_MAX - 0x30) -#define HSI2C_DEF_RXFIFO_LVL (HSI2C_FIFO_MAX - 0x10) - /* I2C_TRAILING_CTL Register bits */ #define HSI2C_TRAILING_COUNT (0xf) @@ -187,6 +181,9 @@ struct exynos5_i2c { /* Version of HS-I2C Hardware */ unsigned int version; + + /* FIFO depth */ + unsigned int fifo_depth; }; enum hsi2c_version { @@ -437,7 +434,7 @@ static irqreturn_t exynos5_i2c_irq(int irqno, void *dev_id) fifo_status = readl(i2c->regs + HSI2C_FIFO_STATUS); fifo_level = HSI2C_TX_FIFO_LVL(fifo_status); - len = HSI2C_FIFO_MAX - fifo_level; + len = i2c->fifo_depth - fifo_level; if (len > (i2c->msg->len - i2c->msg_ptr)) len = i2c->msg->len - i2c->msg_ptr; @@ -505,6 +502,7 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) u32 i2c_auto_conf = 0; u32 fifo_ctl; unsigned long flags; + unsigned short trig_lvl; i2c_ctl = readl(i2c->regs + HSI2C_CTL); i2c_ctl &= ~(HSI2C_TXCHON | HSI2C_RXCHON); @@ -515,13 +513,19 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) i2c_auto_conf = HSI2C_READ_WRITE; - fifo_ctl |= HSI2C_RXFIFO_TRIGGER_LEVEL(HSI2C_DEF_TXFIFO_LVL); + trig_lvl = (i2c->msg->len > i2c->fifo_depth) ? + (i2c->fifo_depth * 3/4) : i2c->msg->len; + fifo_ctl |= HSI2C_RXFIFO_TRIGGER_LEVEL(trig_lvl); + int_en |= (HSI2C_INT_RX_ALMOSTFULL_EN | HSI2C_INT_TRAILING_EN); } else { i2c_ctl |= HSI2C_TXCHON; - fifo_ctl |= HSI2C_TXFIFO_TRIGGER_LEVEL(HSI2C_DEF_RXFIFO_LVL); + trig_lvl = (i2c->msg->len > i2c->fifo_depth) ? + (i2c->fifo_depth * 1/4) : i2c->msg->len; + fifo_ctl |= HSI2C_TXFIFO_TRIGGER_LEVEL(trig_lvl); + int_en |= HSI2C_INT_TX_ALMOSTEMPTY_EN; } @@ -716,10 +720,13 @@ static int exynos5_i2c_probe(struct platform_device *pdev) i2c->version = exynos5_i2c_get_version(pdev); /* The HS-I2C core on Exynos5260 needs a reset to start with */ - if (i2c->version == EXYNOS_5260) + if (i2c->version == EXYNOS_5260) { + i2c->fifo_depth = 16; exynos5_i2c_reset(i2c); - else + } else { + i2c->fifo_depth = 64; exynos5_i2c_init(i2c); + } ret = i2c_add_adapter(&i2c->adap); if (ret < 0) { -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/2 v2] i2c: exynos5: configure fifo_depth based on HSI2C module version 2013-11-22 6:14 [PATCH 2/2] i2c: exynos5: configure fifo_depth based on HSI2C module version Naveen Krishna Chatradhi @ 2013-11-26 4:26 ` Naveen Krishna Chatradhi 2013-12-09 16:31 ` [PATCH 2/2] " Tomasz Figa [not found] ` <1385100851-32254-1-git-send-email-ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 2 siblings, 0 replies; 13+ messages in thread From: Naveen Krishna Chatradhi @ 2013-11-26 4:26 UTC (permalink / raw) To: linux-i2c Cc: sjg, linux-kernel, linux-samsung-soc, wsa, ben-linux, grant.likely, broonie, dianders, cpgs, t.figa fifo_depth of the HSI2C is not constant Exynos5420 and Exynos5250 supports fifo_depth of 64bytes Exynos5260 supports fifo_depth of 16bytes This patch configures the fifo_depth based on HSI2C modules version. Signed-off-by: Naveen Krishna Chatradhi <ich.naveen@samsung.com> [For finding out the difference and initial contribution] Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com> --- Changes since v1: Added missed out Signed-off-by line for initial contribution Also rebasing on linux-i2c for-next drivers/i2c/busses/i2c-exynos5.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c index 497ff91..a3fdcd8 100644 --- a/drivers/i2c/busses/i2c-exynos5.c +++ b/drivers/i2c/busses/i2c-exynos5.c @@ -77,12 +77,6 @@ #define HSI2C_RXFIFO_TRIGGER_LEVEL(x) ((x) << 4) #define HSI2C_TXFIFO_TRIGGER_LEVEL(x) ((x) << 16) -/* As per user manual FIFO max depth is 64bytes */ -#define HSI2C_FIFO_MAX 0x40 -/* default trigger levels for Tx and Rx FIFOs */ -#define HSI2C_DEF_TXFIFO_LVL (HSI2C_FIFO_MAX - 0x30) -#define HSI2C_DEF_RXFIFO_LVL (HSI2C_FIFO_MAX - 0x10) - /* I2C_TRAILING_CTL Register bits */ #define HSI2C_TRAILING_COUNT (0xf) @@ -187,6 +181,9 @@ struct exynos5_i2c { /* Version of HS-I2C Hardware */ unsigned int version; + + /* FIFO depth */ + unsigned int fifo_depth; }; enum hsi2c_version { @@ -437,7 +434,7 @@ static irqreturn_t exynos5_i2c_irq(int irqno, void *dev_id) fifo_status = readl(i2c->regs + HSI2C_FIFO_STATUS); fifo_level = HSI2C_TX_FIFO_LVL(fifo_status); - len = HSI2C_FIFO_MAX - fifo_level; + len = i2c->fifo_depth - fifo_level; if (len > (i2c->msg->len - i2c->msg_ptr)) len = i2c->msg->len - i2c->msg_ptr; @@ -505,6 +502,7 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) u32 i2c_auto_conf = 0; u32 fifo_ctl; unsigned long flags; + unsigned short trig_lvl; i2c_ctl = readl(i2c->regs + HSI2C_CTL); i2c_ctl &= ~(HSI2C_TXCHON | HSI2C_RXCHON); @@ -515,13 +513,19 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) i2c_auto_conf = HSI2C_READ_WRITE; - fifo_ctl |= HSI2C_RXFIFO_TRIGGER_LEVEL(HSI2C_DEF_TXFIFO_LVL); + trig_lvl = (i2c->msg->len > i2c->fifo_depth) ? + (i2c->fifo_depth * 3/4) : i2c->msg->len; + fifo_ctl |= HSI2C_RXFIFO_TRIGGER_LEVEL(trig_lvl); + int_en |= (HSI2C_INT_RX_ALMOSTFULL_EN | HSI2C_INT_TRAILING_EN); } else { i2c_ctl |= HSI2C_TXCHON; - fifo_ctl |= HSI2C_TXFIFO_TRIGGER_LEVEL(HSI2C_DEF_RXFIFO_LVL); + trig_lvl = (i2c->msg->len > i2c->fifo_depth) ? + (i2c->fifo_depth * 1/4) : i2c->msg->len; + fifo_ctl |= HSI2C_TXFIFO_TRIGGER_LEVEL(trig_lvl); + int_en |= HSI2C_INT_TX_ALMOSTEMPTY_EN; } @@ -716,10 +720,13 @@ static int exynos5_i2c_probe(struct platform_device *pdev) i2c->version = exynos5_i2c_get_version(pdev); /* The HS-I2C core on Exynos5260 needs a reset to start with */ - if (i2c->version == EXYNOS_5260) + if (i2c->version == EXYNOS_5260) { + i2c->fifo_depth = 16; exynos5_i2c_reset(i2c); - else + } else { + i2c->fifo_depth = 64; exynos5_i2c_init(i2c); + } ret = i2c_add_adapter(&i2c->adap); if (ret < 0) { -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] i2c: exynos5: configure fifo_depth based on HSI2C module version 2013-11-22 6:14 [PATCH 2/2] i2c: exynos5: configure fifo_depth based on HSI2C module version Naveen Krishna Chatradhi 2013-11-26 4:26 ` [PATCH 2/2 v2] " Naveen Krishna Chatradhi @ 2013-12-09 16:31 ` Tomasz Figa 2013-12-10 4:56 ` Naveen Krishna Ch [not found] ` <1385100851-32254-1-git-send-email-ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 2 siblings, 1 reply; 13+ messages in thread From: Tomasz Figa @ 2013-12-09 16:31 UTC (permalink / raw) To: Naveen Krishna Chatradhi Cc: linux-i2c, linux-kernel, linux-samsung-soc, hs, khali, ben-linux, naveenkrishna.ch Hi Naveen, On Friday 22 of November 2013 11:44:11 Naveen Krishna Chatradhi wrote: > fifo_depth of the HSI2C is not constant > Exynos5420 and Exynos5250 supports fifo_depth of 64bytes > Exynos5260 supports fifo_depth of 16bytes > > This patch configures the fifo_depth based on HSI2C modules version. > Signed-off-by: Naveen Krishna Chatradhi <ch.naveen@samsung.com> > --- > drivers/i2c/busses/i2c-exynos5.c | 29 ++++++++++++++++++----------- > 1 file changed, 18 insertions(+), 11 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c > index cbb49e2..19277d8 100644 > --- a/drivers/i2c/busses/i2c-exynos5.c > +++ b/drivers/i2c/busses/i2c-exynos5.c > @@ -77,12 +77,6 @@ > #define HSI2C_RXFIFO_TRIGGER_LEVEL(x) ((x) << 4) > #define HSI2C_TXFIFO_TRIGGER_LEVEL(x) ((x) << 16) > > -/* As per user manual FIFO max depth is 64bytes */ > -#define HSI2C_FIFO_MAX 0x40 > -/* default trigger levels for Tx and Rx FIFOs */ > -#define HSI2C_DEF_TXFIFO_LVL (HSI2C_FIFO_MAX - 0x30) > -#define HSI2C_DEF_RXFIFO_LVL (HSI2C_FIFO_MAX - 0x10) > - > /* I2C_TRAILING_CTL Register bits */ > #define HSI2C_TRAILING_COUNT (0xf) > > @@ -187,6 +181,9 @@ struct exynos5_i2c { > > /* Version of HS-I2C Hardware */ > unsigned int version; > + > + /* FIFO depth */ > + unsigned int fifo_depth; > }; > > enum hsi2c_version { > @@ -437,7 +434,7 @@ static irqreturn_t exynos5_i2c_irq(int irqno, void *dev_id) > fifo_status = readl(i2c->regs + HSI2C_FIFO_STATUS); > fifo_level = HSI2C_TX_FIFO_LVL(fifo_status); > > - len = HSI2C_FIFO_MAX - fifo_level; > + len = i2c->fifo_depth - fifo_level; > if (len > (i2c->msg->len - i2c->msg_ptr)) > len = i2c->msg->len - i2c->msg_ptr; > > @@ -505,6 +502,7 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) > u32 i2c_auto_conf = 0; > u32 fifo_ctl; > unsigned long flags; > + unsigned short trig_lvl; > > i2c_ctl = readl(i2c->regs + HSI2C_CTL); > i2c_ctl &= ~(HSI2C_TXCHON | HSI2C_RXCHON); > @@ -515,13 +513,19 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) > > i2c_auto_conf = HSI2C_READ_WRITE; > > - fifo_ctl |= HSI2C_RXFIFO_TRIGGER_LEVEL(HSI2C_DEF_TXFIFO_LVL); > + trig_lvl = (i2c->msg->len > i2c->fifo_depth) ? > + (i2c->fifo_depth * 3/4) : i2c->msg->len; This patch changes the fifo trigger level calculation (it's dependent now on message length), not just maximum fifo size, as the description says. It should be split into two separate patches, explaining why both changes are necessary. Best regards, Tomasz ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] i2c: exynos5: configure fifo_depth based on HSI2C module version 2013-12-09 16:31 ` [PATCH 2/2] " Tomasz Figa @ 2013-12-10 4:56 ` Naveen Krishna Ch 2013-12-18 15:21 ` Tomasz Figa 0 siblings, 1 reply; 13+ messages in thread From: Naveen Krishna Ch @ 2013-12-10 4:56 UTC (permalink / raw) To: Tomasz Figa Cc: Naveen Krishna Chatradhi, linux-i2c-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, hs-ynQEQJNshbs, khali-PUYAD+kWke1g9hUCZPvPmw, Ben Dooks Hello Tomasz, On 9 December 2013 22:01, Tomasz Figa <t.figa-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> wrote: > > Hi Naveen, > > On Friday 22 of November 2013 11:44:11 Naveen Krishna Chatradhi wrote: > > fifo_depth of the HSI2C is not constant > > Exynos5420 and Exynos5250 supports fifo_depth of 64bytes > > Exynos5260 supports fifo_depth of 16bytes > > > > This patch configures the fifo_depth based on HSI2C modules version. > > Signed-off-by: Naveen Krishna Chatradhi <ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> > > --- > > drivers/i2c/busses/i2c-exynos5.c | 29 ++++++++++++++++++----------- > > 1 file changed, 18 insertions(+), 11 deletions(-) > > > > diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c > > index cbb49e2..19277d8 100644 > > --- a/drivers/i2c/busses/i2c-exynos5.c > > +++ b/drivers/i2c/busses/i2c-exynos5.c > > @@ -77,12 +77,6 @@ > > #define HSI2C_RXFIFO_TRIGGER_LEVEL(x) ((x) << 4) > > #define HSI2C_TXFIFO_TRIGGER_LEVEL(x) ((x) << 16) > > > > -/* As per user manual FIFO max depth is 64bytes */ > > -#define HSI2C_FIFO_MAX 0x40 > > -/* default trigger levels for Tx and Rx FIFOs */ > > -#define HSI2C_DEF_TXFIFO_LVL (HSI2C_FIFO_MAX - 0x30) > > -#define HSI2C_DEF_RXFIFO_LVL (HSI2C_FIFO_MAX - 0x10) > > - > > /* I2C_TRAILING_CTL Register bits */ > > #define HSI2C_TRAILING_COUNT (0xf) > > > > @@ -187,6 +181,9 @@ struct exynos5_i2c { > > > > /* Version of HS-I2C Hardware */ > > unsigned int version; > > + > > + /* FIFO depth */ > > + unsigned int fifo_depth; > > }; > > > > enum hsi2c_version { > > @@ -437,7 +434,7 @@ static irqreturn_t exynos5_i2c_irq(int irqno, void *dev_id) > > fifo_status = readl(i2c->regs + HSI2C_FIFO_STATUS); > > fifo_level = HSI2C_TX_FIFO_LVL(fifo_status); > > > > - len = HSI2C_FIFO_MAX - fifo_level; > > + len = i2c->fifo_depth - fifo_level; > > if (len > (i2c->msg->len - i2c->msg_ptr)) > > len = i2c->msg->len - i2c->msg_ptr; > > > > @@ -505,6 +502,7 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) > > u32 i2c_auto_conf = 0; > > u32 fifo_ctl; > > unsigned long flags; > > + unsigned short trig_lvl; > > > > i2c_ctl = readl(i2c->regs + HSI2C_CTL); > > i2c_ctl &= ~(HSI2C_TXCHON | HSI2C_RXCHON); > > @@ -515,13 +513,19 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) > > > > i2c_auto_conf = HSI2C_READ_WRITE; > > > > - fifo_ctl |= HSI2C_RXFIFO_TRIGGER_LEVEL(HSI2C_DEF_TXFIFO_LVL); > > + trig_lvl = (i2c->msg->len > i2c->fifo_depth) ? > > + (i2c->fifo_depth * 3/4) : i2c->msg->len; > > This patch changes the fifo trigger level calculation (it's dependent now > on message length), not just maximum fifo size, as the description says. Actually, message->length need not be involved in this calculation. Involving msg->len will raise another interrupt for every small transactions. It better be avoided. > It should be split into two separate patches, explaining why both changes > are necessary. I will split the fifo_depth configuration code along with comments addressed on https://lkml.org/lkml/2013/11/22/31 I can think of 3 ways to address the h/w version changes 1. Compatible string as i implemented 2. Varient struct 3. Passing the information via device tree How about passing fifo_depth from device tree information. Currently, HSI2C Module on Exynso5260 is not another H/W version. It only defer in fifo_depth and init sequence needs a reset. > > > Best regards, > Tomasz > -- Shine bright, (: Nav :) ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] i2c: exynos5: configure fifo_depth based on HSI2C module version 2013-12-10 4:56 ` Naveen Krishna Ch @ 2013-12-18 15:21 ` Tomasz Figa 0 siblings, 0 replies; 13+ messages in thread From: Tomasz Figa @ 2013-12-18 15:21 UTC (permalink / raw) To: Naveen Krishna Ch Cc: Naveen Krishna Chatradhi, linux-i2c, linux-kernel, linux-samsung-soc@vger.kernel.org, hs, khali, Ben Dooks On Tuesday 10 of December 2013 10:26:40 Naveen Krishna Ch wrote: > Hello Tomasz, > > > On 9 December 2013 22:01, Tomasz Figa <t.figa@samsung.com> wrote: > > > > Hi Naveen, > > > > On Friday 22 of November 2013 11:44:11 Naveen Krishna Chatradhi wrote: > > > fifo_depth of the HSI2C is not constant > > > Exynos5420 and Exynos5250 supports fifo_depth of 64bytes > > > Exynos5260 supports fifo_depth of 16bytes > > > > > > This patch configures the fifo_depth based on HSI2C modules version. > > > Signed-off-by: Naveen Krishna Chatradhi <ch.naveen@samsung.com> > > > --- > > > drivers/i2c/busses/i2c-exynos5.c | 29 ++++++++++++++++++----------- > > > 1 file changed, 18 insertions(+), 11 deletions(-) > > > > > > diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c > > > index cbb49e2..19277d8 100644 > > > --- a/drivers/i2c/busses/i2c-exynos5.c > > > +++ b/drivers/i2c/busses/i2c-exynos5.c > > > @@ -77,12 +77,6 @@ > > > #define HSI2C_RXFIFO_TRIGGER_LEVEL(x) ((x) << 4) > > > #define HSI2C_TXFIFO_TRIGGER_LEVEL(x) ((x) << 16) > > > > > > -/* As per user manual FIFO max depth is 64bytes */ > > > -#define HSI2C_FIFO_MAX 0x40 > > > -/* default trigger levels for Tx and Rx FIFOs */ > > > -#define HSI2C_DEF_TXFIFO_LVL (HSI2C_FIFO_MAX - 0x30) > > > -#define HSI2C_DEF_RXFIFO_LVL (HSI2C_FIFO_MAX - 0x10) > > > - > > > /* I2C_TRAILING_CTL Register bits */ > > > #define HSI2C_TRAILING_COUNT (0xf) > > > > > > @@ -187,6 +181,9 @@ struct exynos5_i2c { > > > > > > /* Version of HS-I2C Hardware */ > > > unsigned int version; > > > + > > > + /* FIFO depth */ > > > + unsigned int fifo_depth; > > > }; > > > > > > enum hsi2c_version { > > > @@ -437,7 +434,7 @@ static irqreturn_t exynos5_i2c_irq(int irqno, void *dev_id) > > > fifo_status = readl(i2c->regs + HSI2C_FIFO_STATUS); > > > fifo_level = HSI2C_TX_FIFO_LVL(fifo_status); > > > > > > - len = HSI2C_FIFO_MAX - fifo_level; > > > + len = i2c->fifo_depth - fifo_level; > > > if (len > (i2c->msg->len - i2c->msg_ptr)) > > > len = i2c->msg->len - i2c->msg_ptr; > > > > > > @@ -505,6 +502,7 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) > > > u32 i2c_auto_conf = 0; > > > u32 fifo_ctl; > > > unsigned long flags; > > > + unsigned short trig_lvl; > > > > > > i2c_ctl = readl(i2c->regs + HSI2C_CTL); > > > i2c_ctl &= ~(HSI2C_TXCHON | HSI2C_RXCHON); > > > @@ -515,13 +513,19 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) > > > > > > i2c_auto_conf = HSI2C_READ_WRITE; > > > > > > - fifo_ctl |= HSI2C_RXFIFO_TRIGGER_LEVEL(HSI2C_DEF_TXFIFO_LVL); > > > + trig_lvl = (i2c->msg->len > i2c->fifo_depth) ? > > > + (i2c->fifo_depth * 3/4) : i2c->msg->len; > > > > This patch changes the fifo trigger level calculation (it's dependent now > > on message length), not just maximum fifo size, as the description says. > Actually, message->length need not be involved in this calculation. > Involving msg->len > will raise another interrupt for every small transactions. It better be avoided. > > It should be split into two separate patches, explaining why both changes > > are necessary. > I will split the fifo_depth configuration code along with comments addressed on > https://lkml.org/lkml/2013/11/22/31 OK. > > I can think of 3 ways to address the h/w version changes > 1. Compatible string as i implemented > 2. Varient struct > 3. Passing the information via device tree > How about passing fifo_depth from device tree information. I believe a combination of 1 and 2 is the recommended option, which is a variant struct pointed by an entry in OF match table. > > Currently, HSI2C Module on Exynso5260 is not another H/W version. > It only defer in fifo_depth and init sequence needs a reset. Well, this implies that it's another H/W version from kernel point of view, as it needs different handling. Best regards, Tomasz ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <1385100851-32254-1-git-send-email-ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>]
* [PATCH 1/2 v3] i2c: exynos5: add support for HSI2C on Exynos5260 SoC [not found] ` <1385100851-32254-1-git-send-email-ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> @ 2014-02-06 12:06 ` Naveen Krishna Chatradhi 2014-02-06 13:31 ` Tomasz Figa 2014-02-07 4:43 ` [PATCH 2/2 v4] i2c: exynos5: configure fifo_depth based on HSI2C module variant Naveen Krishna Chatradhi 1 sibling, 1 reply; 13+ messages in thread From: Naveen Krishna Chatradhi @ 2014-02-06 12:06 UTC (permalink / raw) To: linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, linux-i2c-u79uwXL29TY76Z2rM5mHXA Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, naveenkrishna.ch-Re5JQEeQqe8AvxtiuMwx3w, kgene.kim-Sze3O3UU22JBDgjK7y7TUQ, grant.likely-s3s/WqlpOiPyB63q8FvJNQ, w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, linux-kernel-u79uwXL29TY76Z2rM5mHXA, taeggyun.ko-Sze3O3UU22JBDgjK7y7TUQ, balbi-l0cyMroinI0, cpgs-Sze3O3UU22JBDgjK7y7TUQ, t.figa-Sze3O3UU22JBDgjK7y7TUQ This patch implements a variant struct to handle the differences (like fifo_depths) in the HSI2C modules across SoCs. Adds a new compatible to support HSI2C module on Exynos5260. Also resets the module as an init sequence (Needed by Exynos5260). Signed-off-by: Naveen Krishna Chatradhi <ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> --- Changes since v2: 1. Used variant struct as suggested by Tomasz Figa. 2. Change compatible strings from samsung,exynos5-hsi2c to samsung,exynos5250-hsi2c based on the first SoC to see the feature. 3. Using reset as init sequences. 4. Merged the 2 patches into one. .../devicetree/bindings/i2c/i2c-exynos5.txt | 8 ++- drivers/i2c/busses/i2c-exynos5.c | 64 ++++++++++++++++---- 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-exynos5.txt b/Documentation/devicetree/bindings/i2c/i2c-exynos5.txt index 056732c..5bc4998 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-exynos5.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-exynos5.txt @@ -5,7 +5,11 @@ at various speeds ranging from 100khz to 3.4Mhz. Required properties: - compatible: value should be. - -> "samsung,exynos5-hsi2c", for i2c compatible with exynos5 hsi2c. + -> "samsung,exynos5250-hsi2c", for i2c compatible with HSI2C available + on Exynos5250 and Exynos5420 SoCs. + -> "samsung,exynos5260-hsi2c", for i2c compatible with HSI2C available + on Exynos5260 SoCs. + - reg: physical base address of the controller and length of memory mapped region. - interrupts: interrupt number to the cpu. @@ -26,7 +30,7 @@ Optional properties: Example: hsi2c@12ca0000 { - compatible = "samsung,exynos5-hsi2c"; + compatible = "samsung,exynos5250-hsi2c"; reg = <0x12ca0000 0x100>; interrupts = <56>; clock-frequency = <100000>; diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c index 9fd711c..5052e8f 100644 --- a/drivers/i2c/busses/i2c-exynos5.c +++ b/drivers/i2c/busses/i2c-exynos5.c @@ -76,12 +76,6 @@ #define HSI2C_RXFIFO_TRIGGER_LEVEL(x) ((x) << 4) #define HSI2C_TXFIFO_TRIGGER_LEVEL(x) ((x) << 16) -/* As per user manual FIFO max depth is 64bytes */ -#define HSI2C_FIFO_MAX 0x40 -/* default trigger levels for Tx and Rx FIFOs */ -#define HSI2C_DEF_TXFIFO_LVL (HSI2C_FIFO_MAX - 0x30) -#define HSI2C_DEF_RXFIFO_LVL (HSI2C_FIFO_MAX - 0x10) - /* I2C_TRAILING_CTL Register bits */ #define HSI2C_TRAILING_COUNT (0xf) @@ -183,14 +177,51 @@ struct exynos5_i2c { * 2. Fast speed upto 1Mbps */ int speed_mode; + + /* Version of HS-I2C Hardware */ + struct exynos_hsi2c_variant *variant; +}; + +/** + * struct exynos_hsi2c_variant - platform specific HSI2C driver data + * @fifo_depth: the fifo depth supported by the HSI2C module + * + * Specifies platform specific configuration of HSI2C module. + * Note: A structure for driver specific platform data is used for future + * expansion of its usage. + */ +struct exynos_hsi2c_variant { + unsigned int fifo_depth; +}; + +static const struct exynos_hsi2c_variant exynos5250_hsi2c_data = { + .fifo_depth = 64, +}; + +static const struct exynos_hsi2c_variant exynos5260_hsi2c_data = { + .fifo_depth = 16, }; static const struct of_device_id exynos5_i2c_match[] = { - { .compatible = "samsung,exynos5-hsi2c" }, - {}, + { + .compatible = "samsung,exynos5250-hsi2c", + .data = &exynos5250_hsi2c_data + }, { + .compatible = "samsung,exynos5260-hsi2c", + .data = &exynos5260_hsi2c_data + }, {}, }; MODULE_DEVICE_TABLE(of, exynos5_i2c_match); +static inline struct exynos_hsi2c_variant *exynos5_i2c_get_variant + (struct platform_device *pdev) +{ + const struct of_device_id *match; + + match = of_match_node(exynos5_i2c_match, pdev->dev.of_node); + return (struct exynos_hsi2c_variant *)match->data; +} + static void exynos5_i2c_clr_pend_irq(struct exynos5_i2c *i2c) { writel(readl(i2c->regs + HSI2C_INT_STATUS), @@ -415,7 +446,7 @@ static irqreturn_t exynos5_i2c_irq(int irqno, void *dev_id) fifo_status = readl(i2c->regs + HSI2C_FIFO_STATUS); fifo_level = HSI2C_TX_FIFO_LVL(fifo_status); - len = HSI2C_FIFO_MAX - fifo_level; + len = i2c->variant->fifo_depth - fifo_level; if (len > (i2c->msg->len - i2c->msg_ptr)) len = i2c->msg->len - i2c->msg_ptr; @@ -483,6 +514,7 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) u32 i2c_auto_conf = 0; u32 fifo_ctl; unsigned long flags; + unsigned short trig_lvl; i2c_ctl = readl(i2c->regs + HSI2C_CTL); i2c_ctl &= ~(HSI2C_TXCHON | HSI2C_RXCHON); @@ -493,13 +525,19 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) i2c_auto_conf = HSI2C_READ_WRITE; - fifo_ctl |= HSI2C_RXFIFO_TRIGGER_LEVEL(HSI2C_DEF_TXFIFO_LVL); + trig_lvl = (i2c->msg->len > i2c->variant->fifo_depth) ? + (i2c->variant->fifo_depth * 3/4) : i2c->msg->len; + fifo_ctl |= HSI2C_RXFIFO_TRIGGER_LEVEL(trig_lvl); + int_en |= (HSI2C_INT_RX_ALMOSTFULL_EN | HSI2C_INT_TRAILING_EN); } else { i2c_ctl |= HSI2C_TXCHON; - fifo_ctl |= HSI2C_TXFIFO_TRIGGER_LEVEL(HSI2C_DEF_RXFIFO_LVL); + trig_lvl = (i2c->msg->len > i2c->variant->fifo_depth) ? + (i2c->variant->fifo_depth * 1/4) : i2c->msg->len; + fifo_ctl |= HSI2C_TXFIFO_TRIGGER_LEVEL(trig_lvl); + int_en |= HSI2C_INT_TX_ALMOSTEMPTY_EN; } @@ -691,7 +729,9 @@ static int exynos5_i2c_probe(struct platform_device *pdev) if (ret) goto err_clk; - exynos5_i2c_init(i2c); + i2c->variant = exynos5_i2c_get_variant(pdev); + + exynos5_i2c_reset(i2c); ret = i2c_add_adapter(&i2c->adap); if (ret < 0) { -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2 v3] i2c: exynos5: add support for HSI2C on Exynos5260 SoC 2014-02-06 12:06 ` [PATCH 1/2 v3] i2c: exynos5: add support for HSI2C on Exynos5260 SoC Naveen Krishna Chatradhi @ 2014-02-06 13:31 ` Tomasz Figa 2014-02-06 13:50 ` Tomasz Figa 0 siblings, 1 reply; 13+ messages in thread From: Tomasz Figa @ 2014-02-06 13:31 UTC (permalink / raw) To: Naveen Krishna Chatradhi, linux-samsung-soc, linux-i2c Cc: linux-arm-kernel, devicetree-discuss, naveenkrishna.ch, kgene.kim, grant.likely, w.sang, linux-kernel, taeggyun.ko, balbi, cpgs Hi Naveen, On 06.02.2014 13:06, Naveen Krishna Chatradhi wrote: > This patch implements a variant struct to handle the differences > (like fifo_depths) in the HSI2C modules across SoCs. > > Adds a new compatible to support HSI2C module on Exynos5260. > Also resets the module as an init sequence (Needed by Exynos5260). > > Signed-off-by: Naveen Krishna Chatradhi <ch.naveen@samsung.com> > --- > Changes since v2: > 1. Used variant struct as suggested by Tomasz Figa. > 2. Change compatible strings from samsung,exynos5-hsi2c to > samsung,exynos5250-hsi2c based on the first SoC to see the feature. > 3. Using reset as init sequences. > 4. Merged the 2 patches into one. > > .../devicetree/bindings/i2c/i2c-exynos5.txt | 8 ++- > drivers/i2c/busses/i2c-exynos5.c | 64 ++++++++++++++++---- > 2 files changed, 58 insertions(+), 14 deletions(-) > > diff --git a/Documentation/devicetree/bindings/i2c/i2c-exynos5.txt b/Documentation/devicetree/bindings/i2c/i2c-exynos5.txt > index 056732c..5bc4998 100644 > --- a/Documentation/devicetree/bindings/i2c/i2c-exynos5.txt > +++ b/Documentation/devicetree/bindings/i2c/i2c-exynos5.txt > @@ -5,7 +5,11 @@ at various speeds ranging from 100khz to 3.4Mhz. > > Required properties: > - compatible: value should be. > - -> "samsung,exynos5-hsi2c", for i2c compatible with exynos5 hsi2c. Device tree bindings need to be backwards compatible, so you need to keep this compatible string supported, just marked as (DEPRECATED). Driver-wise, it will use the same driver data / variant struct as "samsung,exynos5250-hsi2c", just one more entry in OF match table is needed. > + -> "samsung,exynos5250-hsi2c", for i2c compatible with HSI2C available > + on Exynos5250 and Exynos5420 SoCs. > + -> "samsung,exynos5260-hsi2c", for i2c compatible with HSI2C available > + on Exynos5260 SoCs. > + > - reg: physical base address of the controller and length of memory mapped > region. > - interrupts: interrupt number to the cpu. > @@ -26,7 +30,7 @@ Optional properties: > Example: > > hsi2c@12ca0000 { > - compatible = "samsung,exynos5-hsi2c"; > + compatible = "samsung,exynos5250-hsi2c"; > reg = <0x12ca0000 0x100>; > interrupts = <56>; > clock-frequency = <100000>; [snip] > @@ -483,6 +514,7 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) > u32 i2c_auto_conf = 0; > u32 fifo_ctl; > unsigned long flags; > + unsigned short trig_lvl; > > i2c_ctl = readl(i2c->regs + HSI2C_CTL); > i2c_ctl &= ~(HSI2C_TXCHON | HSI2C_RXCHON); > @@ -493,13 +525,19 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) > > i2c_auto_conf = HSI2C_READ_WRITE; > > - fifo_ctl |= HSI2C_RXFIFO_TRIGGER_LEVEL(HSI2C_DEF_TXFIFO_LVL); > + trig_lvl = (i2c->msg->len > i2c->variant->fifo_depth) ? > + (i2c->variant->fifo_depth * 3/4) : i2c->msg->len; > + fifo_ctl |= HSI2C_RXFIFO_TRIGGER_LEVEL(trig_lvl); > + This is a rather serious semantic change, that doesn't look to belong to this patch. If this is needed, it should be done in a separate patch. > int_en |= (HSI2C_INT_RX_ALMOSTFULL_EN | > HSI2C_INT_TRAILING_EN); > } else { > i2c_ctl |= HSI2C_TXCHON; > > - fifo_ctl |= HSI2C_TXFIFO_TRIGGER_LEVEL(HSI2C_DEF_RXFIFO_LVL); > + trig_lvl = (i2c->msg->len > i2c->variant->fifo_depth) ? > + (i2c->variant->fifo_depth * 1/4) : i2c->msg->len; > + fifo_ctl |= HSI2C_TXFIFO_TRIGGER_LEVEL(trig_lvl); > + Ditto. Best regards, Tomasz ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2 v3] i2c: exynos5: add support for HSI2C on Exynos5260 SoC 2014-02-06 13:31 ` Tomasz Figa @ 2014-02-06 13:50 ` Tomasz Figa [not found] ` <52F3933B.9090202-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 0 siblings, 1 reply; 13+ messages in thread From: Tomasz Figa @ 2014-02-06 13:50 UTC (permalink / raw) To: Naveen Krishna Chatradhi, linux-samsung-soc, linux-i2c Cc: linux-arm-kernel, devicetree@vger.kernel.org, naveenkrishna.ch, kgene.kim, grant.likely, Wolfram Sang, linux-kernel, taeggyun.ko, balbi, cpgs Also, please use correct addresses of DT ML and Wolfram's e-mail (fixed in this message). Best regards, Tomasz On 06.02.2014 14:31, Tomasz Figa wrote: > Hi Naveen, > > On 06.02.2014 13:06, Naveen Krishna Chatradhi wrote: >> This patch implements a variant struct to handle the differences >> (like fifo_depths) in the HSI2C modules across SoCs. >> >> Adds a new compatible to support HSI2C module on Exynos5260. >> Also resets the module as an init sequence (Needed by Exynos5260). >> >> Signed-off-by: Naveen Krishna Chatradhi <ch.naveen@samsung.com> >> --- >> Changes since v2: >> 1. Used variant struct as suggested by Tomasz Figa. >> 2. Change compatible strings from samsung,exynos5-hsi2c to >> samsung,exynos5250-hsi2c based on the first SoC to see the feature. >> 3. Using reset as init sequences. >> 4. Merged the 2 patches into one. >> >> .../devicetree/bindings/i2c/i2c-exynos5.txt | 8 ++- >> drivers/i2c/busses/i2c-exynos5.c | 64 >> ++++++++++++++++---- >> 2 files changed, 58 insertions(+), 14 deletions(-) >> >> diff --git a/Documentation/devicetree/bindings/i2c/i2c-exynos5.txt >> b/Documentation/devicetree/bindings/i2c/i2c-exynos5.txt >> index 056732c..5bc4998 100644 >> --- a/Documentation/devicetree/bindings/i2c/i2c-exynos5.txt >> +++ b/Documentation/devicetree/bindings/i2c/i2c-exynos5.txt >> @@ -5,7 +5,11 @@ at various speeds ranging from 100khz to 3.4Mhz. >> >> Required properties: >> - compatible: value should be. >> - -> "samsung,exynos5-hsi2c", for i2c compatible with exynos5 hsi2c. > > Device tree bindings need to be backwards compatible, so you need to > keep this compatible string supported, just marked as (DEPRECATED). > > Driver-wise, it will use the same driver data / variant struct as > "samsung,exynos5250-hsi2c", just one more entry in OF match table is > needed. > >> + -> "samsung,exynos5250-hsi2c", for i2c compatible with HSI2C >> available >> + on Exynos5250 and Exynos5420 SoCs. >> + -> "samsung,exynos5260-hsi2c", for i2c compatible with HSI2C >> available >> + on Exynos5260 SoCs. >> + >> - reg: physical base address of the controller and length of >> memory mapped >> region. >> - interrupts: interrupt number to the cpu. >> @@ -26,7 +30,7 @@ Optional properties: >> Example: >> >> hsi2c@12ca0000 { >> - compatible = "samsung,exynos5-hsi2c"; >> + compatible = "samsung,exynos5250-hsi2c"; >> reg = <0x12ca0000 0x100>; >> interrupts = <56>; >> clock-frequency = <100000>; > > [snip] > >> @@ -483,6 +514,7 @@ static void exynos5_i2c_message_start(struct >> exynos5_i2c *i2c, int stop) >> u32 i2c_auto_conf = 0; >> u32 fifo_ctl; >> unsigned long flags; >> + unsigned short trig_lvl; >> >> i2c_ctl = readl(i2c->regs + HSI2C_CTL); >> i2c_ctl &= ~(HSI2C_TXCHON | HSI2C_RXCHON); >> @@ -493,13 +525,19 @@ static void exynos5_i2c_message_start(struct >> exynos5_i2c *i2c, int stop) >> >> i2c_auto_conf = HSI2C_READ_WRITE; >> >> - fifo_ctl |= HSI2C_RXFIFO_TRIGGER_LEVEL(HSI2C_DEF_TXFIFO_LVL); >> + trig_lvl = (i2c->msg->len > i2c->variant->fifo_depth) ? >> + (i2c->variant->fifo_depth * 3/4) : i2c->msg->len; >> + fifo_ctl |= HSI2C_RXFIFO_TRIGGER_LEVEL(trig_lvl); >> + > > This is a rather serious semantic change, that doesn't look to belong to > this patch. If this is needed, it should be done in a separate patch. > >> int_en |= (HSI2C_INT_RX_ALMOSTFULL_EN | >> HSI2C_INT_TRAILING_EN); >> } else { >> i2c_ctl |= HSI2C_TXCHON; >> >> - fifo_ctl |= HSI2C_TXFIFO_TRIGGER_LEVEL(HSI2C_DEF_RXFIFO_LVL); >> + trig_lvl = (i2c->msg->len > i2c->variant->fifo_depth) ? >> + (i2c->variant->fifo_depth * 1/4) : i2c->msg->len; >> + fifo_ctl |= HSI2C_TXFIFO_TRIGGER_LEVEL(trig_lvl); >> + > > Ditto. > > Best regards, > Tomasz > -- > To unsubscribe from this list: send the line "unsubscribe > linux-samsung-soc" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <52F3933B.9090202-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>]
* Re: [PATCH 1/2 v3] i2c: exynos5: add support for HSI2C on Exynos5260 SoC [not found] ` <52F3933B.9090202-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> @ 2014-02-07 10:17 ` Wolfram Sang 2014-02-07 10:21 ` Tomasz Figa 0 siblings, 1 reply; 13+ messages in thread From: Wolfram Sang @ 2014-02-07 10:17 UTC (permalink / raw) To: Tomasz Figa Cc: Naveen Krishna Chatradhi, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, linux-i2c-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, naveenkrishna.ch-Re5JQEeQqe8AvxtiuMwx3w, kgene.kim-Sze3O3UU22JBDgjK7y7TUQ, grant.likely-s3s/WqlpOiPyB63q8FvJNQ, linux-kernel-u79uwXL29TY76Z2rM5mHXA, taeggyun.ko-Sze3O3UU22JBDgjK7y7TUQ, balbi-l0cyMroinI0, cpgs-Sze3O3UU22JBDgjK7y7TUQ [-- Attachment #1: Type: text/plain, Size: 278 bytes --] On Thu, Feb 06, 2014 at 02:50:51PM +0100, Tomasz Figa wrote: > Also, please use correct addresses of DT ML and Wolfram's e-mail > (fixed in this message). And please don't use In-Reply-To when sending new versions of patches. The message threading became hard to read here... [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2 v3] i2c: exynos5: add support for HSI2C on Exynos5260 SoC 2014-02-07 10:17 ` Wolfram Sang @ 2014-02-07 10:21 ` Tomasz Figa 0 siblings, 0 replies; 13+ messages in thread From: Tomasz Figa @ 2014-02-07 10:21 UTC (permalink / raw) To: Wolfram Sang, Tomasz Figa Cc: Naveen Krishna Chatradhi, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, linux-i2c-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, naveenkrishna.ch-Re5JQEeQqe8AvxtiuMwx3w, kgene.kim-Sze3O3UU22JBDgjK7y7TUQ, grant.likely-s3s/WqlpOiPyB63q8FvJNQ, linux-kernel-u79uwXL29TY76Z2rM5mHXA, taeggyun.ko-Sze3O3UU22JBDgjK7y7TUQ, balbi-l0cyMroinI0, cpgs-Sze3O3UU22JBDgjK7y7TUQ On 07.02.2014 11:17, Wolfram Sang wrote: > On Thu, Feb 06, 2014 at 02:50:51PM +0100, Tomasz Figa wrote: >> Also, please use correct addresses of DT ML and Wolfram's e-mail >> (fixed in this message). > > And please don't use In-Reply-To when sending new versions of patches. > The message threading became hard to read here... > +1 It's hard to follow new versions of series that show up under the thread of old version. If you want to keep reference to old versions, you can add links to respective threads to change log entries in cover letter. Best regards, Tomasz ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/2 v4] i2c: exynos5: configure fifo_depth based on HSI2C module variant [not found] ` <1385100851-32254-1-git-send-email-ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 2014-02-06 12:06 ` [PATCH 1/2 v3] i2c: exynos5: add support for HSI2C on Exynos5260 SoC Naveen Krishna Chatradhi @ 2014-02-07 4:43 ` Naveen Krishna Chatradhi [not found] ` <1391748195-12490-1-git-send-email-ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 1 sibling, 1 reply; 13+ messages in thread From: Naveen Krishna Chatradhi @ 2014-02-07 4:43 UTC (permalink / raw) To: linux-i2c-u79uwXL29TY76Z2rM5mHXA Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, naveenkrishna.ch-Re5JQEeQqe8AvxtiuMwx3w, kgene.kim-Sze3O3UU22JBDgjK7y7TUQ, wsa-z923LK4zBo2bacvFa/9K2g, linux-kernel-u79uwXL29TY76Z2rM5mHXA fifo_depth of the HSI2C is not constant Exynos5420 and Exynos5250 supports fifo_depth of 64bytes Exynos5260 supports fifo_depth of 16bytes. This patch configures the fifo_depth based on HSI2C modules version. Signed-off-by: Naveen Krishna Chatradhi <ich.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> [For finding out the difference and initial contribution] Signed-off-by: Pankaj Dubey <pankaj.dubey-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> --- changes since v3: use variant struct to handle the fifo depths drivers/i2c/busses/i2c-exynos5.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c index 12730d1..5c875c0 100644 --- a/drivers/i2c/busses/i2c-exynos5.c +++ b/drivers/i2c/busses/i2c-exynos5.c @@ -76,12 +76,6 @@ #define HSI2C_RXFIFO_TRIGGER_LEVEL(x) ((x) << 4) #define HSI2C_TXFIFO_TRIGGER_LEVEL(x) ((x) << 16) -/* As per user manual FIFO max depth is 64bytes */ -#define HSI2C_FIFO_MAX 0x40 -/* default trigger levels for Tx and Rx FIFOs */ -#define HSI2C_DEF_TXFIFO_LVL (HSI2C_FIFO_MAX - 0x30) -#define HSI2C_DEF_RXFIFO_LVL (HSI2C_FIFO_MAX - 0x10) - /* I2C_TRAILING_CTL Register bits */ #define HSI2C_TRAILING_COUNT (0xf) @@ -455,7 +449,7 @@ static irqreturn_t exynos5_i2c_irq(int irqno, void *dev_id) fifo_status = readl(i2c->regs + HSI2C_FIFO_STATUS); fifo_level = HSI2C_TX_FIFO_LVL(fifo_status); - len = HSI2C_FIFO_MAX - fifo_level; + len = i2c->variant->fifo_depth - fifo_level; if (len > (i2c->msg->len - i2c->msg_ptr)) len = i2c->msg->len - i2c->msg_ptr; @@ -523,6 +517,7 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) u32 i2c_auto_conf = 0; u32 fifo_ctl; unsigned long flags; + unsigned short trig_lvl; i2c_ctl = readl(i2c->regs + HSI2C_CTL); i2c_ctl &= ~(HSI2C_TXCHON | HSI2C_RXCHON); @@ -533,13 +528,19 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) i2c_auto_conf = HSI2C_READ_WRITE; - fifo_ctl |= HSI2C_RXFIFO_TRIGGER_LEVEL(HSI2C_DEF_TXFIFO_LVL); + trig_lvl = (i2c->msg->len > i2c->variant->fifo_depth) ? + (i2c->variant->fifo_depth * 3/4) : i2c->msg->len; + fifo_ctl |= HSI2C_RXFIFO_TRIGGER_LEVEL(trig_lvl); + int_en |= (HSI2C_INT_RX_ALMOSTFULL_EN | HSI2C_INT_TRAILING_EN); } else { i2c_ctl |= HSI2C_TXCHON; - fifo_ctl |= HSI2C_TXFIFO_TRIGGER_LEVEL(HSI2C_DEF_RXFIFO_LVL); + trig_lvl = (i2c->msg->len > i2c->variant->fifo_depth) ? + (i2c->variant->fifo_depth * 1/4) : i2c->msg->len; + fifo_ctl |= HSI2C_TXFIFO_TRIGGER_LEVEL(trig_lvl); + int_en |= HSI2C_INT_TX_ALMOSTEMPTY_EN; } @@ -731,6 +732,8 @@ static int exynos5_i2c_probe(struct platform_device *pdev) if (ret) goto err_clk; + i2c->variant = exynos5_i2c_get_variant(pdev); + exynos5_i2c_reset(i2c); ret = i2c_add_adapter(&i2c->adap); -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 13+ messages in thread
[parent not found: <1391748195-12490-1-git-send-email-ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>]
* Re: [PATCH 2/2 v4] i2c: exynos5: configure fifo_depth based on HSI2C module variant [not found] ` <1391748195-12490-1-git-send-email-ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> @ 2014-03-12 19:20 ` Wolfram Sang 2014-04-28 6:35 ` Naveen Krishna Ch 0 siblings, 1 reply; 13+ messages in thread From: Wolfram Sang @ 2014-03-12 19:20 UTC (permalink / raw) To: Naveen Krishna Chatradhi Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, naveenkrishna.ch-Re5JQEeQqe8AvxtiuMwx3w, kgene.kim-Sze3O3UU22JBDgjK7y7TUQ, linux-kernel-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 654 bytes --] On Fri, Feb 07, 2014 at 10:13:15AM +0530, Naveen Krishna Chatradhi wrote: > fifo_depth of the HSI2C is not constant > Exynos5420 and Exynos5250 supports fifo_depth of 64bytes > Exynos5260 supports fifo_depth of 16bytes. > > This patch configures the fifo_depth based on HSI2C modules version. > > Signed-off-by: Naveen Krishna Chatradhi <ich.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> > [For finding out the difference and initial contribution] > Signed-off-by: Pankaj Dubey <pankaj.dubey-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> I know Tomasz said differently, but I prefer the patches squashed (and the commit message extended). [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2 v4] i2c: exynos5: configure fifo_depth based on HSI2C module variant 2014-03-12 19:20 ` Wolfram Sang @ 2014-04-28 6:35 ` Naveen Krishna Ch 0 siblings, 0 replies; 13+ messages in thread From: Naveen Krishna Ch @ 2014-04-28 6:35 UTC (permalink / raw) To: Wolfram Sang Cc: Naveen Krishna Chatradhi, linux-i2c, linux-arm-kernel, linux-samsung-soc@vger.kernel.org, Kukjin Kim, linux-kernel Hello Wolfram, On 13 March 2014 00:50, Wolfram Sang <wsa@the-dreams.de> wrote: > On Fri, Feb 07, 2014 at 10:13:15AM +0530, Naveen Krishna Chatradhi wrote: >> fifo_depth of the HSI2C is not constant >> Exynos5420 and Exynos5250 supports fifo_depth of 64bytes >> Exynos5260 supports fifo_depth of 16bytes. >> >> This patch configures the fifo_depth based on HSI2C modules version. >> >> Signed-off-by: Naveen Krishna Chatradhi <ich.naveen@samsung.com> >> [For finding out the difference and initial contribution] >> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com> > > I know Tomasz said differently, but I prefer the patches squashed (and > the commit message extended). Please accept my apologies for coming back late on this CL. Will squash and fix the compilation error and submit. Thanks, > -- Shine bright, (: Nav :) ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2014-04-28 6:35 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-11-22 6:14 [PATCH 2/2] i2c: exynos5: configure fifo_depth based on HSI2C module version Naveen Krishna Chatradhi 2013-11-26 4:26 ` [PATCH 2/2 v2] " Naveen Krishna Chatradhi 2013-12-09 16:31 ` [PATCH 2/2] " Tomasz Figa 2013-12-10 4:56 ` Naveen Krishna Ch 2013-12-18 15:21 ` Tomasz Figa [not found] ` <1385100851-32254-1-git-send-email-ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 2014-02-06 12:06 ` [PATCH 1/2 v3] i2c: exynos5: add support for HSI2C on Exynos5260 SoC Naveen Krishna Chatradhi 2014-02-06 13:31 ` Tomasz Figa 2014-02-06 13:50 ` Tomasz Figa [not found] ` <52F3933B.9090202-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 2014-02-07 10:17 ` Wolfram Sang 2014-02-07 10:21 ` Tomasz Figa 2014-02-07 4:43 ` [PATCH 2/2 v4] i2c: exynos5: configure fifo_depth based on HSI2C module variant Naveen Krishna Chatradhi [not found] ` <1391748195-12490-1-git-send-email-ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 2014-03-12 19:20 ` Wolfram Sang 2014-04-28 6:35 ` Naveen Krishna Ch
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).