Re: [U-Boot] [PATCH V3 1/5] mmc: uniphier-sd: Factor out register IO
2017-09-22 22:54 GMT+09:00 Jaehoon Chung: > On 08/21/2017 12:11 AM, Marek Vasut wrote: >> This patch prepares the driver to support controller(s) with registers >> at locations shifted by constant. Pull out the readl()/writel() from >> the driver into separate functions, where the adjustment of the register >> offset can be easily contained. > > Sorry for late. Applied to u-boot-mmc about [PATCH 1/5~5/5]. > (After fixing some conflict - i did.) What is worse, Jaehoon picked up wrong ones. (seems v1) -- Best Regards Masahiro Yamada ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH V3 1/5] mmc: uniphier-sd: Factor out register IO
On 08/21/2017 12:11 AM, Marek Vasut wrote: > This patch prepares the driver to support controller(s) with registers > at locations shifted by constant. Pull out the readl()/writel() from > the driver into separate functions, where the adjustment of the register > offset can be easily contained. Sorry for late. Applied to u-boot-mmc about [PATCH 1/5~5/5]. (After fixing some conflict - i did.) Best Regards, Jaehoon Chung > > Signed-off-by: Marek Vasut> Cc: Masahiro Yamada > Cc: Jaehoon Chung > --- > V2: Use unsigned int for the reg argument > V3: Remove const ... > --- > drivers/mmc/uniphier-sd.c | 115 > +- > 1 file changed, 63 insertions(+), 52 deletions(-) > > diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c > index e272b14153..cb53b28737 100644 > --- a/drivers/mmc/uniphier-sd.c > +++ b/drivers/mmc/uniphier-sd.c > @@ -134,6 +134,17 @@ struct uniphier_sd_priv { > #define UNIPHIER_SD_CAP_DIV1024 BIT(2) /* divisor 1024 is > available */ > }; > > +static u32 uniphier_sd_readl(struct uniphier_sd_priv *priv, unsigned int reg) > +{ > + return readl(priv->regbase + reg); > +} > + > +static void uniphier_sd_writel(struct uniphier_sd_priv *priv, > +u32 val, unsigned int reg) > +{ > + writel(val, priv->regbase + reg); > +} > + > static dma_addr_t __dma_map_single(void *ptr, size_t size, > enum dma_data_direction dir) > { > @@ -157,7 +168,7 @@ static void __dma_unmap_single(dma_addr_t addr, size_t > size, > static int uniphier_sd_check_error(struct udevice *dev) > { > struct uniphier_sd_priv *priv = dev_get_priv(dev); > - u32 info2 = readl(priv->regbase + UNIPHIER_SD_INFO2); > + u32 info2 = uniphier_sd_readl(priv, UNIPHIER_SD_INFO2); > > if (info2 & UNIPHIER_SD_INFO2_ERR_RTO) { > /* > @@ -195,7 +206,7 @@ static int uniphier_sd_wait_for_irq(struct udevice *dev, > unsigned int reg, > long wait = 100; > int ret; > > - while (!(readl(priv->regbase + reg) & flag)) { > + while (!(uniphier_sd_readl(priv, reg) & flag)) { > if (wait-- < 0) { > dev_err(dev, "timeout\n"); > return -ETIMEDOUT; > @@ -227,14 +238,14 @@ static int uniphier_sd_pio_read_one_block(struct > udevice *dev, u32 **pbuf, >* Clear the status flag _before_ read the buffer out because >* UNIPHIER_SD_INFO2_BRE is edge-triggered, not level-triggered. >*/ > - writel(0, priv->regbase + UNIPHIER_SD_INFO2); > + uniphier_sd_writel(priv, 0, UNIPHIER_SD_INFO2); > > if (likely(IS_ALIGNED((unsigned long)*pbuf, 4))) { > for (i = 0; i < blocksize / 4; i++) > - *(*pbuf)++ = readl(priv->regbase + UNIPHIER_SD_BUF); > + *(*pbuf)++ = uniphier_sd_readl(priv, UNIPHIER_SD_BUF); > } else { > for (i = 0; i < blocksize / 4; i++) > - put_unaligned(readl(priv->regbase + UNIPHIER_SD_BUF), > + put_unaligned(uniphier_sd_readl(priv, UNIPHIER_SD_BUF), > (*pbuf)++); > } > > @@ -253,15 +264,15 @@ static int uniphier_sd_pio_write_one_block(struct > udevice *dev, > if (ret) > return ret; > > - writel(0, priv->regbase + UNIPHIER_SD_INFO2); > + uniphier_sd_writel(priv, 0, UNIPHIER_SD_INFO2); > > if (likely(IS_ALIGNED((unsigned long)*pbuf, 4))) { > for (i = 0; i < blocksize / 4; i++) > - writel(*(*pbuf)++, priv->regbase + UNIPHIER_SD_BUF); > + uniphier_sd_writel(priv, *(*pbuf)++, UNIPHIER_SD_BUF); > } else { > for (i = 0; i < blocksize / 4; i++) > - writel(get_unaligned((*pbuf)++), > -priv->regbase + UNIPHIER_SD_BUF); > + uniphier_sd_writel(priv, get_unaligned((*pbuf)++), > +UNIPHIER_SD_BUF); > } > > return 0; > @@ -292,22 +303,22 @@ static void uniphier_sd_dma_start(struct > uniphier_sd_priv *priv, > { > u32 tmp; > > - writel(0, priv->regbase + UNIPHIER_SD_DMA_INFO1); > - writel(0, priv->regbase + UNIPHIER_SD_DMA_INFO2); > + uniphier_sd_writel(priv, 0, UNIPHIER_SD_DMA_INFO1); > + uniphier_sd_writel(priv, 0, UNIPHIER_SD_DMA_INFO2); > > /* enable DMA */ > - tmp = readl(priv->regbase + UNIPHIER_SD_EXTMODE); > + tmp = uniphier_sd_readl(priv, UNIPHIER_SD_EXTMODE); > tmp |= UNIPHIER_SD_EXTMODE_DMA_EN; > - writel(tmp, priv->regbase + UNIPHIER_SD_EXTMODE); > + uniphier_sd_writel(priv, tmp, UNIPHIER_SD_EXTMODE); > > - writel(dma_addr & U32_MAX, priv->regbase + UNIPHIER_SD_DMA_ADDR_L); > + uniphier_sd_writel(priv, dma_addr & U32_MAX,
Re: [U-Boot] [PATCH V3 1/5] mmc: uniphier-sd: Factor out register IO
On 09/12/2017 07:04 PM, Marek Vasut wrote: > On 08/20/2017 05:11 PM, Marek Vasut wrote: >> This patch prepares the driver to support controller(s) with registers >> at locations shifted by constant. Pull out the readl()/writel() from >> the driver into separate functions, where the adjustment of the register >> offset can be easily contained. >> >> Signed-off-by: Marek Vasut>> Cc: Masahiro Yamada >> Cc: Jaehoon Chung > > Hello Jaehoon, > > just a reminder that this missed previous MW, so it would be nice if it > made it into this one. Another week has passed and no response. It has been a month since these patches were posted and ACKed, but they are still not in the tree, what is going on ?! > Thanks > >> --- >> V2: Use unsigned int for the reg argument >> V3: Remove const ... > [...] > -- Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH V3 1/5] mmc: uniphier-sd: Factor out register IO
On 08/20/2017 05:11 PM, Marek Vasut wrote: > This patch prepares the driver to support controller(s) with registers > at locations shifted by constant. Pull out the readl()/writel() from > the driver into separate functions, where the adjustment of the register > offset can be easily contained. > > Signed-off-by: Marek Vasut> Cc: Masahiro Yamada > Cc: Jaehoon Chung Hello Jaehoon, just a reminder that this missed previous MW, so it would be nice if it made it into this one. Thanks > --- > V2: Use unsigned int for the reg argument > V3: Remove const ... [...] -- Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH V3 1/5] mmc: uniphier-sd: Factor out register IO
2017-08-21 0:11 GMT+09:00 Marek Vasut: > This patch prepares the driver to support controller(s) with registers > at locations shifted by constant. Pull out the readl()/writel() from > the driver into separate functions, where the adjustment of the register > offset can be easily contained. > > Signed-off-by: Marek Vasut > Cc: Masahiro Yamada > Cc: Jaehoon Chung > --- > V2: Use unsigned int for the reg argument > V3: Remove const ... > --- Thanks! Acked-by: Masahiro Yamada -- Best Regards Masahiro Yamada ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH V3 1/5] mmc: uniphier-sd: Factor out register IO
This patch prepares the driver to support controller(s) with registers at locations shifted by constant. Pull out the readl()/writel() from the driver into separate functions, where the adjustment of the register offset can be easily contained. Signed-off-by: Marek VasutCc: Masahiro Yamada Cc: Jaehoon Chung --- V2: Use unsigned int for the reg argument V3: Remove const ... --- drivers/mmc/uniphier-sd.c | 115 +- 1 file changed, 63 insertions(+), 52 deletions(-) diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c index e272b14153..cb53b28737 100644 --- a/drivers/mmc/uniphier-sd.c +++ b/drivers/mmc/uniphier-sd.c @@ -134,6 +134,17 @@ struct uniphier_sd_priv { #define UNIPHIER_SD_CAP_DIV1024BIT(2) /* divisor 1024 is available */ }; +static u32 uniphier_sd_readl(struct uniphier_sd_priv *priv, unsigned int reg) +{ + return readl(priv->regbase + reg); +} + +static void uniphier_sd_writel(struct uniphier_sd_priv *priv, + u32 val, unsigned int reg) +{ + writel(val, priv->regbase + reg); +} + static dma_addr_t __dma_map_single(void *ptr, size_t size, enum dma_data_direction dir) { @@ -157,7 +168,7 @@ static void __dma_unmap_single(dma_addr_t addr, size_t size, static int uniphier_sd_check_error(struct udevice *dev) { struct uniphier_sd_priv *priv = dev_get_priv(dev); - u32 info2 = readl(priv->regbase + UNIPHIER_SD_INFO2); + u32 info2 = uniphier_sd_readl(priv, UNIPHIER_SD_INFO2); if (info2 & UNIPHIER_SD_INFO2_ERR_RTO) { /* @@ -195,7 +206,7 @@ static int uniphier_sd_wait_for_irq(struct udevice *dev, unsigned int reg, long wait = 100; int ret; - while (!(readl(priv->regbase + reg) & flag)) { + while (!(uniphier_sd_readl(priv, reg) & flag)) { if (wait-- < 0) { dev_err(dev, "timeout\n"); return -ETIMEDOUT; @@ -227,14 +238,14 @@ static int uniphier_sd_pio_read_one_block(struct udevice *dev, u32 **pbuf, * Clear the status flag _before_ read the buffer out because * UNIPHIER_SD_INFO2_BRE is edge-triggered, not level-triggered. */ - writel(0, priv->regbase + UNIPHIER_SD_INFO2); + uniphier_sd_writel(priv, 0, UNIPHIER_SD_INFO2); if (likely(IS_ALIGNED((unsigned long)*pbuf, 4))) { for (i = 0; i < blocksize / 4; i++) - *(*pbuf)++ = readl(priv->regbase + UNIPHIER_SD_BUF); + *(*pbuf)++ = uniphier_sd_readl(priv, UNIPHIER_SD_BUF); } else { for (i = 0; i < blocksize / 4; i++) - put_unaligned(readl(priv->regbase + UNIPHIER_SD_BUF), + put_unaligned(uniphier_sd_readl(priv, UNIPHIER_SD_BUF), (*pbuf)++); } @@ -253,15 +264,15 @@ static int uniphier_sd_pio_write_one_block(struct udevice *dev, if (ret) return ret; - writel(0, priv->regbase + UNIPHIER_SD_INFO2); + uniphier_sd_writel(priv, 0, UNIPHIER_SD_INFO2); if (likely(IS_ALIGNED((unsigned long)*pbuf, 4))) { for (i = 0; i < blocksize / 4; i++) - writel(*(*pbuf)++, priv->regbase + UNIPHIER_SD_BUF); + uniphier_sd_writel(priv, *(*pbuf)++, UNIPHIER_SD_BUF); } else { for (i = 0; i < blocksize / 4; i++) - writel(get_unaligned((*pbuf)++), - priv->regbase + UNIPHIER_SD_BUF); + uniphier_sd_writel(priv, get_unaligned((*pbuf)++), + UNIPHIER_SD_BUF); } return 0; @@ -292,22 +303,22 @@ static void uniphier_sd_dma_start(struct uniphier_sd_priv *priv, { u32 tmp; - writel(0, priv->regbase + UNIPHIER_SD_DMA_INFO1); - writel(0, priv->regbase + UNIPHIER_SD_DMA_INFO2); + uniphier_sd_writel(priv, 0, UNIPHIER_SD_DMA_INFO1); + uniphier_sd_writel(priv, 0, UNIPHIER_SD_DMA_INFO2); /* enable DMA */ - tmp = readl(priv->regbase + UNIPHIER_SD_EXTMODE); + tmp = uniphier_sd_readl(priv, UNIPHIER_SD_EXTMODE); tmp |= UNIPHIER_SD_EXTMODE_DMA_EN; - writel(tmp, priv->regbase + UNIPHIER_SD_EXTMODE); + uniphier_sd_writel(priv, tmp, UNIPHIER_SD_EXTMODE); - writel(dma_addr & U32_MAX, priv->regbase + UNIPHIER_SD_DMA_ADDR_L); + uniphier_sd_writel(priv, dma_addr & U32_MAX, UNIPHIER_SD_DMA_ADDR_L); /* suppress the warning "right shift count >= width of type" */ dma_addr >>= min_t(int, 32, 8 * sizeof(dma_addr)); - writel(dma_addr & U32_MAX, priv->regbase + UNIPHIER_SD_DMA_ADDR_H); + uniphier_sd_writel(priv, dma_addr & U32_MAX,