[PATCH 13/24] MAINTAINERS: fix drivers/i2c/busses/i2c-stub.c

2012-11-23 Thread Cesar Eduardo Barros
This file was moved to drivers/i2c/i2c-stub.c by commit 31d178b
(i2c-stub: Move to drivers/i2c).

Cc: Jean Delvare 
Cc: "Mark M. Hoffman" 
Cc: linux-i2c@vger.kernel.org
Signed-off-by: Cesar Eduardo Barros 
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 91feba2..eaf1a59 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3667,7 +3667,7 @@ I2C/SMBUS STUB DRIVER
 M: "Mark M. Hoffman" 
 L: linux-i2c@vger.kernel.org
 S: Maintained
-F: drivers/i2c/busses/i2c-stub.c
+F: drivers/i2c/i2c-stub.c
 
 I2C SUBSYSTEM
 M: Wolfram Sang 
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] i2c: at91: fix compilation warning

2012-11-23 Thread ludovic.desroches
From: Ludovic Desroches 

This patch fixes the following warning:
drivers/i2c/busses/i2c-at91.c: In function ‘at91_twi_get_driver_data’:
drivers/i2c/busses/i2c-at91.c:411:3: warning: return discards ‘const’ qualifier 
from pointer target type [enabled by default]

Signed-off-by: Ludovic Desroches 
---
 drivers/i2c/busses/i2c-at91.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index aa59a25..f222600 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -408,7 +408,7 @@ static struct at91_twi_pdata * __devinit 
at91_twi_get_driver_data(
match = of_match_node(atmel_twi_dt_ids, pdev->dev.of_node);
if (!match)
return NULL;
-   return match->data;
+   return (struct at91_twi_pdata *)match->data;
}
return (struct at91_twi_pdata *) 
platform_get_device_id(pdev)->driver_data;
 }
-- 
1.7.11.3

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] i2c: Add possibility for user-defined (i2c-)devices for bus-drivers.

2012-11-23 Thread Alexander Holler
Am 14.11.2012 10:40, schrieb Jean Delvare:

> Or maybe this will never happen.

Which is exactly what your friendly greeting at the start of this thread
should have hinted to me. I'll take it as an advice for the future.

Alexander

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PULL REQUEST] i2c-embedded for 3.7

2012-11-23 Thread Wolfram Sang
Linus,

please pull the bugfixes for the i2c subsystem. Except for a few
one-liners, there is mainly one revert because of an overlooked
dependency. Since there is no linux-next at the moment, I did some extra
testing, and all was fine for me.

Thanks,

   Wolfram

The following changes since commit 77b67063bb6bce6d475e910d3b886a606d0d91f7:

  Linux 3.7-rc5 (2012-11-11 13:44:33 +0100)

are available in the git repository at:

  git://git.pengutronix.de/git/wsa/linux.git i2c-embedded/for-current

for you to fetch changes up to 958f9889950ef257f601c4902137caff291d5dd7:

  i2c: mxs: Handle i2c DMA failure properly (2012-11-22 23:03:34 +0100)


Abhilash Kesavan (1):
  i2c: s3c2410: Fix code to free gpios

Felipe Balbi (1):
  i2c: omap: ensure writes to dev->buf_len are ordered

Ludovic Desroches (1):
  i2c: at91: fix SMBus quick command

Marek Vasut (1):
  i2c: mxs: Handle i2c DMA failure properly

Paul Walmsley (1):
  Revert "ARM: OMAP: convert I2C driver to PM QoS for MPU latency 
constraints"

 arch/arm/plat-omap/i2c.c |   21 +
 drivers/i2c/busses/i2c-at91.c|7 ++-
 drivers/i2c/busses/i2c-mxs.c |2 ++
 drivers/i2c/busses/i2c-omap.c|   36 +---
 drivers/i2c/busses/i2c-s3c2410.c |1 +
 include/linux/i2c-omap.h |1 +
 6 files changed, 48 insertions(+), 20 deletions(-)

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


Re: [PATCH 1/3] i2c: at91: fix compilation warning

2012-11-23 Thread Russell King - ARM Linux
On Fri, Nov 23, 2012 at 10:09:02AM +0100, ludovic.desroc...@atmel.com wrote:
> From: Ludovic Desroches 

Always include the warning itself in the commit log.
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH v2 1/6] ARM: EXYNOS5: Clock settings for SATA and SATA PHY

2012-11-23 Thread Kukjin Kim
Vasanth Ananthan wrote:
> 
> Hi,
> 
> Missed to include Ben, for I2C patch, including him and copying others.
> 
Vasanth, you didn't my reply? I already applied this 1st and 2nd patches.

Thanks.

Best regards,
Kgene.
--
Kukjin Kim , Senior Engineer,
SW Solution Development Team, Samsung Electronics Co., Ltd.

> 
> On Tue, Oct 30, 2012 at 9:31 PM, Vasanth Ananthan
>  wrote:
> > This patch adds neccessary clock entries for SATA, SATA PHY and
> > I2C_SATAPHY
> >
> > Signed-off-by: Vasanth Ananthan 
> > ---
> >  arch/arm/mach-exynos/clock-exynos5.c |   21 ++---
> >  1 files changed, 18 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/arm/mach-exynos/clock-exynos5.c b/arch/arm/mach-
> exynos/clock-exynos5.c
> > index c44ca1e..124c54f 100644
> > --- a/arch/arm/mach-exynos/clock-exynos5.c
> > +++ b/arch/arm/mach-exynos/clock-exynos5.c
> > @@ -651,15 +651,20 @@ static struct clk exynos5_init_clocks_off[] = {
> > .ctrlbit= (1 << 15),
> > }, {
> > .name   = "sata",
> > -   .devname= "ahci",
> > +   .devname= "exynos5-sata",
> > +   .parent = &exynos5_clk_aclk_200.clk,
> > .enable = exynos5_clk_ip_fsys_ctrl,
> > .ctrlbit= (1 << 6),
> > }, {
> > -   .name   = "sata_phy",
> > +   .name   = "sata-phy",
> > +   .devname= "exynos5-sata-phy",
> > +   .parent = &exynos5_clk_aclk_200.clk,
> > .enable = exynos5_clk_ip_fsys_ctrl,
> > .ctrlbit= (1 << 24),
> > }, {
> > -   .name   = "sata_phy_i2c",
> > +   .name   = "i2c",
> > +   .devname= "exynos5-sata-phy-i2c",
> > +   .parent = &exynos5_clk_aclk_200.clk,
> > .enable = exynos5_clk_ip_fsys_ctrl,
> > .ctrlbit= (1 << 25),
> > }, {
> > @@ -1226,6 +1231,16 @@ static struct clksrc_clk exynos5_clksrcs[] = {
> > .reg_div = { .reg = EXYNOS5_CLKDIV_TOP0, .shift = 24,
.size
> = 3 },
> > }, {
> > .clk= {
> > +   .name   = "sclk_sata",
> > +   .devname= "exynos5-sata",
> > +   .enable = exynos5_clksrc_mask_fsys_ctrl,
> > +   .ctrlbit= (1 << 24),
> > +   },
> > +   .sources = &exynos5_clkset_aclk,
> > +   .reg_src = { .reg = EXYNOS5_CLKSRC_FSYS, .shift = 24,
.size
> = 1 },
> > +   .reg_div = { .reg = EXYNOS5_CLKDIV_FSYS0, .shift =
> 20, .size = 4 },
> > +   }, {
> > +   .clk= {
> > .name   = "sclk_gscl_wrap",
> > .devname= "s5p-mipi-csis.0",
> > .enable = exynos5_clksrc_mask_gscl_ctrl,
> > --
> > 1.7.4.1
> >
> 
> 
> 
> --

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] i2c: at91: add dma support

2012-11-23 Thread ludovic.desroches
From: Ludovic Desroches 

Add dma support for Atmel TWI which is available on sam9x5 and later.

When using dma for reception, you have to read only n-2 bytes. The last
two bytes are read manually. Don't doing this should cause to send the
STOP command too late and then to get extra data in the receive
register.

Signed-off-by: Ludovic Desroches 
---
 drivers/i2c/busses/i2c-at91.c | 306 --
 1 file changed, 298 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index f82649b..74f7be9 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -19,6 +19,8 @@
 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -29,9 +31,11 @@
 #include 
 #include 
 #include 
+#include 
 
 #define TWI_CLK_HZ 10  /* max 400 Kbits/s */
 #define AT91_I2C_TIMEOUT   msecs_to_jiffies(100)   /* transfer timeout */
+#define AT91_I2C_DMA_THRESHOLD 8   /* enable DMA if 
transfer size is bigger than this threshold */
 
 /* AT91 TWI register definitions */
 #defineAT91_TWI_CR 0x  /* Control Register */
@@ -68,6 +72,18 @@ struct at91_twi_pdata {
unsigned clk_max_div;
unsigned clk_offset;
bool has_unre_flag;
+   bool has_dma_support;
+   struct at_dma_slave dma_slave;
+};
+
+struct at91_twi_dma {
+   struct dma_chan *chan_rx;
+   struct dma_chan *chan_tx;
+   struct scatterlist sg;
+   struct dma_async_tx_descriptor *data_desc;
+   enum dma_data_direction direction;
+   bool buf_mapped;
+   bool xfer_in_progress;
 };
 
 struct at91_twi_dev {
@@ -79,10 +95,13 @@ struct at91_twi_dev {
size_t buf_len;
struct i2c_msg *msg;
int irq;
+   unsigned imr;
unsigned transfer_status;
struct i2c_adapter adapter;
unsigned twi_cwgr_reg;
struct at91_twi_pdata *pdata;
+   bool use_dma;
+   struct at91_twi_dma dma;
 };
 
 static unsigned at91_twi_read(struct at91_twi_dev *dev, unsigned reg)
@@ -101,6 +120,17 @@ static void at91_disable_twi_interrupts(struct 
at91_twi_dev *dev)
   AT91_TWI_TXCOMP | AT91_TWI_RXRDY | AT91_TWI_TXRDY);
 }
 
+static void at91_twi_irq_save(struct at91_twi_dev *dev)
+{
+   dev->imr = at91_twi_read(dev, AT91_TWI_IMR) & 0x7;
+   at91_disable_twi_interrupts(dev);
+}
+
+static void at91_twi_irq_restore(struct at91_twi_dev *dev)
+{
+   at91_twi_write(dev, AT91_TWI_IER, dev->imr);
+}
+
 static void at91_init_twi_bus(struct at91_twi_dev *dev)
 {
at91_disable_twi_interrupts(dev);
@@ -137,6 +167,28 @@ static void __devinit at91_calc_twi_clock(struct 
at91_twi_dev *dev, int twi_clk)
dev_dbg(dev->dev, "cdiv %d ckdiv %d\n", cdiv, ckdiv);
 }
 
+static void at91_twi_dma_cleanup(struct at91_twi_dev *dev)
+{
+   struct at91_twi_dma *dma = &dev->dma;
+
+   at91_twi_irq_save(dev);
+
+   if (dma->xfer_in_progress) {
+   if (dma->direction == DMA_FROM_DEVICE)
+   dmaengine_terminate_all(dma->chan_rx);
+   else
+   dmaengine_terminate_all(dma->chan_tx);
+   dma->xfer_in_progress = false;
+   }
+   if (dma->buf_mapped) {
+   dma_unmap_single(dev->dev, sg_dma_address(&dma->sg),
+dev->buf_len, dma->direction);
+   dma->buf_mapped = false;
+   }
+
+   at91_twi_irq_restore(dev);
+}
+
 static void at91_twi_write_next_byte(struct at91_twi_dev *dev)
 {
if (dev->buf_len <= 0)
@@ -153,6 +205,60 @@ static void at91_twi_write_next_byte(struct at91_twi_dev 
*dev)
++dev->buf;
 }
 
+static void at91_twi_write_data_dma_callback(void *data)
+{
+   struct at91_twi_dev *dev = (struct at91_twi_dev *)data;
+
+   dma_unmap_single(dev->dev, sg_dma_address(&dev->dma.sg),
+dev->buf_len, DMA_MEM_TO_DEV);
+
+   at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_STOP);
+}
+
+static void at91_twi_write_data_dma(struct at91_twi_dev *dev)
+{
+   dma_addr_t dma_addr;
+   struct dma_async_tx_descriptor *txdesc;
+   struct at91_twi_dma *dma = &dev->dma;
+   struct dma_chan *chan_tx = dma->chan_tx;
+
+   if (dev->buf_len <= 0)
+   return;
+
+   dma->direction = DMA_TO_DEVICE;
+
+   at91_twi_irq_save(dev);
+   dma_addr = dma_map_single(dev->dev, dev->buf, dev->buf_len,
+ DMA_TO_DEVICE);
+   if (dma_mapping_error(dev->dev, dma_addr)) {
+   dev_err(dev->dev, "dma map failed\n");
+   return;
+   }
+   dma->buf_mapped = true;
+   at91_twi_irq_restore(dev);
+   sg_dma_len(&dma->sg) = dev->buf_len;
+   sg_dma_address(&dma->sg) = dma_addr;
+
+   txdesc = dmaengine_prep_slave_sg(chan_tx, &dma->sg, 1, DMA_MEM_TO_DEV,
+DMA_PREP_INTERRUPT | 

[PATCH 2/3] i2c: at91: change struct members indentation

2012-11-23 Thread ludovic.desroches
From: Ludovic Desroches 

Replace tabs for struct members indentation by space to minimise line changes
when adding new members which would require extra tabs to keep alignment.

Signed-off-by: Ludovic Desroches 
---
 drivers/i2c/busses/i2c-at91.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index f222600..f82649b 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -65,24 +65,24 @@
 #defineAT91_TWI_THR0x0034  /* Transmit Holding Register */
 
 struct at91_twi_pdata {
-   unsignedclk_max_div;
-   unsignedclk_offset;
-   boolhas_unre_flag;
+   unsigned clk_max_div;
+   unsigned clk_offset;
+   bool has_unre_flag;
 };
 
 struct at91_twi_dev {
-   struct device   *dev;
-   void __iomem*base;
-   struct completion   cmd_complete;
-   struct clk  *clk;
-   u8  *buf;
-   size_t  buf_len;
-   struct i2c_msg  *msg;
-   int irq;
-   unsignedtransfer_status;
-   struct i2c_adapter  adapter;
-   unsignedtwi_cwgr_reg;
-   struct at91_twi_pdata   *pdata;
+   struct device *dev;
+   void __iomem *base;
+   struct completion cmd_complete;
+   struct clk *clk;
+   u8 *buf;
+   size_t buf_len;
+   struct i2c_msg *msg;
+   int irq;
+   unsigned transfer_status;
+   struct i2c_adapter adapter;
+   unsigned twi_cwgr_reg;
+   struct at91_twi_pdata *pdata;
 };
 
 static unsigned at91_twi_read(struct at91_twi_dev *dev, unsigned reg)
-- 
1.7.11.3

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] i2c: at91: fix compilation warning

2012-11-23 Thread ludovic.desroches
From: Ludovic Desroches 

Signed-off-by: Ludovic Desroches 
---
 drivers/i2c/busses/i2c-at91.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index aa59a25..f222600 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -408,7 +408,7 @@ static struct at91_twi_pdata * __devinit 
at91_twi_get_driver_data(
match = of_match_node(atmel_twi_dt_ids, pdev->dev.of_node);
if (!match)
return NULL;
-   return match->data;
+   return (struct at91_twi_pdata *)match->data;
}
return (struct at91_twi_pdata *) 
platform_get_device_id(pdev)->driver_data;
 }
-- 
1.7.11.3

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH v3 0/3] i2c: at91: add dma support

2012-11-23 Thread ludovic.desroches
From: Ludovic Desroches 

Hi Wolfram,

I've rebased the set of patches on 3.7-rc6. I hope you could apply them.

Regards

Ludovic

Changes:
- v3
- introduce two new patches: one to fix a compilation warning and one to
fix indentation
- introduce a threshold to use dma transfers
- use dma wrappers to clean code
- remove dma cookie since it is no more used

- v2 (based on Russell feedback):
- replace DMA_TO_DEVICE/DMA_FROM_DEVICE by DMA_MEM_TO_DEV/DMA_DEV_TO_MEM
- don't check for tx_submit errors
- atmel dma header location has changed


Ludovic Desroches (3):
  i2c: at91: fix compilation warning
  i2c: at91: change struct members indentation
  i2c: at91: add dma support

 drivers/i2c/busses/i2c-at91.c | 338 +++---
 1 file changed, 314 insertions(+), 24 deletions(-)

-- 
1.7.11.3

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 6/6] DRIVERS: ATA: SATA PHY controller driver

2012-11-23 Thread Vasanth Ananthan
Hi,

Missed to include Ben, for I2C patch, including him and copying others.

Thanks,
Vasanth.

On Tue, Oct 30, 2012 at 9:31 PM, Vasanth Ananthan
 wrote:
> This patch adds a platform driver and I2C client driver for SATA PHY 
> controller
>
> Signed-off-by: Vasanth Ananthan 
> ---
>  arch/arm/mach-exynos/include/mach/regs-sata.h |   29 +++
>  drivers/ata/Makefile  |2 +-
>  drivers/ata/sata_exynos_phy.c |  300 
> +
>  3 files changed, 330 insertions(+), 1 deletions(-)
>  create mode 100644 arch/arm/mach-exynos/include/mach/regs-sata.h
>  create mode 100644 drivers/ata/sata_exynos_phy.c
>
> diff --git a/arch/arm/mach-exynos/include/mach/regs-sata.h 
> b/arch/arm/mach-exynos/include/mach/regs-sata.h
> new file mode 100644
> index 000..80dd564
> --- /dev/null
> +++ b/arch/arm/mach-exynos/include/mach/regs-sata.h
> @@ -0,0 +1,29 @@
> +/*
> + * Copyright (c) 2010-2012 Samsung Electronics Co., Ltd.
> + *  http://www.samsung.com
> + *
> + * EXYNOS - SATA PHY controller definition
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> +*/
> +
> +#define EXYNOS5_SATA_RESET 0x4
> +#define RESET_CMN_RST_N(1 << 1)
> +#define LINK_RESET 0xF
> +
> +#define EXYNOS5_SATA_MODE0 0x10
> +
> +#define EXYNOS5_SATA_CTRL0 0x14
> +#define CTRL0_P0_PHY_CALIBRATED_SEL(1 << 9)
> +#define CTRL0_P0_PHY_CALIBRATED(1 << 8)
> +
> +#define EXYNOS5_SATA_PHSATA_CTRLM  0xE0
> +#define PHCTRLM_REF_RATE   (1 << 1)
> +#define PHCTRLM_HIGH_SPEED (1 << 0)
> +
> +#define EXYNOS5_SATA_PHSATA_STATM  0xF0
> +#define PHSTATM_PLL_LOCKED (1 << 0)
> +
> +#define SATA_PHY_CON_RESET  0xF003F
> diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
> index 43bb38e..6a3a8ee 100644
> --- a/drivers/ata/Makefile
> +++ b/drivers/ata/Makefile
> @@ -11,7 +11,7 @@ obj-$(CONFIG_SATA_SIL24)  += sata_sil24.o
>  obj-$(CONFIG_SATA_DWC) += sata_dwc_460ex.o
>  obj-$(CONFIG_SATA_HIGHBANK)+= sata_highbank.o libahci.o
>  obj-$(CONFIG_SATA_PHY) += sata_phy.o
> -obj-$(CONFIG_SATA_EXYNOS)  += sata_exynos.o libahci.o
> +obj-$(CONFIG_SATA_EXYNOS)  += sata_exynos.o sata_exynos_phy.o libahci.o
>
>  # SFF w/ custom DMA
>  obj-$(CONFIG_PDC_ADMA) += pdc_adma.o
> diff --git a/drivers/ata/sata_exynos_phy.c b/drivers/ata/sata_exynos_phy.c
> new file mode 100644
> index 000..ec61db5
> --- /dev/null
> +++ b/drivers/ata/sata_exynos_phy.c
> @@ -0,0 +1,300 @@
> +/*
> + * Copyright (c) 2010-2012 Samsung Electronics Co., Ltd.
> + *  http://www.samsung.com
> + *
> + * EXYNOS - SATA PHY controller driver
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> +*/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "sata_phy.h"
> +
> +#defineSATA_TIME_LIMIT 1000
> +
> +static struct i2c_client *i2c_client;
> +
> +static struct i2c_driver sataphy_i2c_driver;
> +
> +struct exynos_sata_phy {
> +   void __iomem *mmio;
> +   struct resource *mem;
> +   struct clk *clk;
> +};
> +
> +static bool sata_is_reg(void __iomem *base, u32 reg, u32 checkbit, u32 
> status)
> +{
> +   if ((readl(base + reg) & checkbit) == status)
> +   return true;
> +   else
> +   return false;
> +}
> +
> +static bool wait_for_reg_status(void __iomem *base, u32 reg, u32 checkbit,
> +   u32 status)
> +{
> +   u16 time_limit_cnt = 0;
> +   while (!sata_is_reg(base, reg, checkbit, status)) {
> +   if (time_limit_cnt == SATA_TIME_LIMIT)
> +   return false;
> +   udelay(1000);
> +   time_limit_cnt++;
> +   }
> +   return true;
> +}
> +
> +static int sataphy_init(struct sata_phy *phy)
> +{
> +   int ret;
> +   u32 val;
> +
> +   /* Values to be written to enable 40 bits interface */
> +   u8 buf[] = { 0x3A, 0x0B };
> +
> +   struct exynos_sata_phy *sata_phy;
> +
> +   if (!i2c_client)
> +   return -EPROBE_DEFER;
> +
> +   sata_phy = (struct exynos_sata_phy *)phy->priv_data;
> +
> +   clk_enable(sata_phy->clk);
> +
> +   writel(S5P_PMU_SATA_PHY_CONTROL_EN, EXYNOS5_SATA_PHY_CONTROL);
> +
> +   val = 0;
> +   writel(val, sata_phy->mmio + EXYNOS5_SATA_RESET);
> +
> +   val = readl(sata_phy->mmio + EXYNOS5_SATA_RESET);
> +   val |= 0xFF;
> +

Re: [PATCH v2 5/6] DRIVERS: ATA: SATA controller driver

2012-11-23 Thread Vasanth Ananthan
Hi,

Missed to include Ben, for I2C patch, including him and copying others.

Thanks,
Vasanth.

On Tue, Oct 30, 2012 at 9:31 PM, Vasanth Ananthan
 wrote:
> This patch adds a platform driver for SATA controller.
>
> Signed-off-by: Vasanth Ananthan 
> ---
>  arch/arm/mach-exynos/include/mach/regs-pmu.h |3 +
>  drivers/ata/Kconfig  |   12 ++
>  drivers/ata/Makefile |1 +
>  drivers/ata/sata_exynos.c|  268 
> ++
>  4 files changed, 284 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/ata/sata_exynos.c
>
> diff --git a/arch/arm/mach-exynos/include/mach/regs-pmu.h 
> b/arch/arm/mach-exynos/include/mach/regs-pmu.h
> index d4e392b..3716ce8 100644
> --- a/arch/arm/mach-exynos/include/mach/regs-pmu.h
> +++ b/arch/arm/mach-exynos/include/mach/regs-pmu.h
> @@ -367,4 +367,7 @@
>
>  #define EXYNOS5_OPTION_USE_RETENTION   (1 << 4)
>
> +/* Only for EXYNOS5250 */
> +#define EXYNOS5_SATA_PHY_CONTROL   S5P_PMUREG(0x0724)
> +
>  #endif /* __ASM_ARCH_REGS_PMU_H */
> diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
> index e3a2972..f3384ed 100644
> --- a/drivers/ata/Kconfig
> +++ b/drivers/ata/Kconfig
> @@ -93,6 +93,18 @@ config SATA_PHY
>   with the framework through the APIs provided and the SATA
>   device finds and requests for an appropriate PHY device.
>
> +config SATA_EXYNOS
> +bool "Exynos SATA AHCI support"
> +select I2C
> +select HAVE_S3C2410_I2C
> +select I2C_S3C2410
> +select SATA_PHY
> +help
> +  This option enables support for Exynos AHCI Serial ATA
> +  controllers.
> +
> +  If unsure, say N.
> +
>  config SATA_FSL
> tristate "Freescale 3.0Gbps SATA support"
> depends on FSL_SOC
> diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
> index 3d219a9..43bb38e 100644
> --- a/drivers/ata/Makefile
> +++ b/drivers/ata/Makefile
> @@ -11,6 +11,7 @@ obj-$(CONFIG_SATA_SIL24)  += sata_sil24.o
>  obj-$(CONFIG_SATA_DWC) += sata_dwc_460ex.o
>  obj-$(CONFIG_SATA_HIGHBANK)+= sata_highbank.o libahci.o
>  obj-$(CONFIG_SATA_PHY) += sata_phy.o
> +obj-$(CONFIG_SATA_EXYNOS)  += sata_exynos.o libahci.o
>
>  # SFF w/ custom DMA
>  obj-$(CONFIG_PDC_ADMA) += pdc_adma.o
> diff --git a/drivers/ata/sata_exynos.c b/drivers/ata/sata_exynos.c
> new file mode 100644
> index 000..41dc17d
> --- /dev/null
> +++ b/drivers/ata/sata_exynos.c
> @@ -0,0 +1,268 @@
> +/*
> + * Copyright (c) 2010-2012 Samsung Electronics Co., Ltd.
> + *  http://www.samsung.com
> + *
> + * EXYNOS - SATA controller driver
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> +*/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "ahci.h"
> +#include "sata_phy.h"
> +
> +#define MHZ(1000 * 1000)
> +
> +static const struct ata_port_info ahci_port_info = {
> +   .flags = AHCI_FLAG_COMMON,
> +   .pio_mask = ATA_PIO4,
> +   .udma_mask = ATA_UDMA6,
> +   .port_ops = &ahci_ops,
> +};
> +
> +static struct scsi_host_template ahci_platform_sht = {
> +   AHCI_SHT("ahci_platform"),
> +};
> +
> +struct exynos_sata {
> +   struct clk *sclk;
> +   struct clk *clk;
> +   struct sata_phy *phy;
> +   int irq;
> +   unsigned int freq;
> +};
> +
> +static void exynos_sata_parse_dt(struct device_node *np,
> +   struct exynos_sata *sata)
> +{
> +   if (!np)
> +   return;
> +
> +   of_property_read_u32(np, "samsung,sata-freq", &sata->freq);
> +}
> +
> +static int __init exynos_sata_probe(struct platform_device *pdev)
> +{
> +   struct device *dev = &pdev->dev;
> +   struct ata_port_info pi = ahci_port_info;
> +   const struct ata_port_info *ppi[] = { &pi, NULL };
> +   struct ahci_host_priv *hpriv;
> +   struct exynos_sata *sata;
> +   struct ata_host *host;
> +   struct resource *mem;
> +   int n_ports, i, ret;
> +
> +   sata = devm_kzalloc(dev, sizeof(*sata), GFP_KERNEL);
> +   if (!sata) {
> +   dev_err(dev, "can't alloc sata\n");
> +   return -EINVAL;
> +   }
> +
> +   hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
> +   if (!hpriv) {
> +   dev_err(dev, "can't alloc ahci_host_priv\n");
> +   ret = -ENOMEM;
> +   goto err1;
> +   }
> +
> +   hpriv->flags |= (unsigned long)pi.private_data;
> +
> +   mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +   if (!mem) {
> +   dev_err(dev, "no mmio space\n");
> +   ret = -EINVAL;
> +   goto err2;

Re: [PATCH v2 4/6] DRIVERS:I2C: I2C driver polling mode support

2012-11-23 Thread Vasanth Ananthan
Hi,

Missed to include Ben, for I2C patch, including him and copying others.

Thanks,
Vasanth.

On Tue, Oct 30, 2012 at 9:31 PM, Vasanth Ananthan
 wrote:
> This patch adds polling mode support for i2c s3c-2410 driver.
> The I2C_SATAPHY controller lacks an interrupt line but the s3c-2410 driver
> is interrupt driven. Hence this support is required for functioning
> of the I2C_SATAPHY controller.
>
> Signed-off-by: Vasanth Ananthan 
> ---
>  drivers/i2c/busses/i2c-s3c2410.c |   79 -
>  1 files changed, 60 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-s3c2410.c 
> b/drivers/i2c/busses/i2c-s3c2410.c
> index 3e0335f..5712e40 100644
> --- a/drivers/i2c/busses/i2c-s3c2410.c
> +++ b/drivers/i2c/busses/i2c-s3c2410.c
> @@ -48,6 +48,7 @@
>  #define QUIRK_S3C2440  (1 << 0)
>  #define QUIRK_HDMIPHY  (1 << 1)
>  #define QUIRK_NO_GPIO  (1 << 2)
> +#define QUIRK_SATAPHY  (1 << 3)
>
>  /* i2c controller state */
>  enum s3c24xx_i2c_state {
> @@ -102,10 +103,14 @@ static struct platform_device_id s3c24xx_driver_ids[] = 
> {
>  };
>  MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids);
>
> +static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long 
> iicstat);
> +
>  #ifdef CONFIG_OF
>  static const struct of_device_id s3c24xx_i2c_match[] = {
> { .compatible = "samsung,s3c2410-i2c", .data = (void *)0 },
> { .compatible = "samsung,s3c2440-i2c", .data = (void *)QUIRK_S3C2440 
> },
> +   { .compatible = "samsung,exynos5-sata-phy-i2c",
> + .data = (void *)(QUIRK_S3C2440 | QUIRK_SATAPHY | QUIRK_NO_GPIO) },
> { .compatible = "samsung,s3c2440-hdmiphy-i2c",
>   .data = (void *)(QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO) },
> {},
> @@ -146,7 +151,8 @@ static inline void s3c24xx_i2c_master_complete(struct 
> s3c24xx_i2c *i2c, int ret)
> if (ret)
> i2c->msg_idx = ret;
>
> -   wake_up(&i2c->wait);
> +   if (!(i2c->quirks & QUIRK_SATAPHY))
> +   wake_up(&i2c->wait);
>  }
>
>  static inline void s3c24xx_i2c_disable_ack(struct s3c24xx_i2c *i2c)
> @@ -184,6 +190,23 @@ static inline void s3c24xx_i2c_enable_irq(struct 
> s3c24xx_i2c *i2c)
>  }
>
>
> +static bool is_ack(struct s3c24xx_i2c *i2c)
> +{
> +   u32 time_out = i2c->tx_setup;
> +
> +   while (--time_out) {
> +   if (readl(i2c->regs + S3C2410_IICCON)
> +   & S3C2410_IICCON_IRQPEND) {
> +   if (!(readl(i2c->regs + S3C2410_IICSTAT)
> +   & S3C2410_IICSTAT_LASTBIT))
> +   return true;
> +   }
> +   udelay(time_out);
> +   }
> +
> +   return false;
> +}
> +
>  /* s3c24xx_i2c_message_start
>   *
>   * put the start of a message onto the bus
> @@ -227,6 +250,15 @@ static void s3c24xx_i2c_message_start(struct s3c24xx_i2c 
> *i2c,
>
> stat |= S3C2410_IICSTAT_START;
> writel(stat, i2c->regs + S3C2410_IICSTAT);
> +
> +   if (i2c->quirks & QUIRK_SATAPHY) {
> +   while ((i2c->msg_num != 0) && is_ack(i2c)) {
> +   i2c_s3c_irq_nextbyte(i2c, stat);
> +   stat = readl(i2c->regs + S3C2410_IICSTAT);
> +   if (stat & S3C2410_IICSTAT_ARBITR)
> +   dev_err(i2c->dev, "deal with arbitration 
> loss\n");
> +   }
> +   }
>  }
>
>  static inline void s3c24xx_i2c_stop(struct s3c24xx_i2c *i2c, int ret)
> @@ -552,19 +584,23 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c,
> s3c24xx_i2c_message_start(i2c, msgs);
> spin_unlock_irq(&i2c->lock);
>
> -   timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5);
> -
> ret = i2c->msg_idx;
>
> -   /* having these next two as dev_err() makes life very
> -* noisy when doing an i2cdetect */
> +   if (!(i2c->quirks & QUIRK_SATAPHY)) {
>
> -   if (timeout == 0)
> -   dev_dbg(i2c->dev, "timeout\n");
> -   else if (ret != num)
> -   dev_dbg(i2c->dev, "incomplete xfer (%d)\n", ret);
> +   timeout = wait_event_timeout(i2c->wait,
> +   i2c->msg_num == 0, HZ * 5);
>
> -   /* ensure the stop has been through the bus */
> +   /* having these next two as dev_err() makes life very
> +   * noisy when doing an i2cdetect */
> +
> +   if (timeout == 0)
> +   dev_dbg(i2c->dev, "timeout\n");
> +   else if (ret != num)
> +   dev_dbg(i2c->dev, "incomplete xfer (%d)\n", ret);
> +
> +   /* ensure the stop has been through the bus */
> +   }
>
> dev_dbg(i2c->dev, "waiting for bus idle\n");
>
> @@ -710,6 +746,9 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, 
> unsigned int *got)
> if (div1 == 512)
> iiccon |= S3C2410_IICCON_TXDIV_512;
>

Re: [PATCH v2 3/6] DRIVERS: ATA: SATA PHY utility framework

2012-11-23 Thread Vasanth Ananthan
Hi,

Missed to include Ben, for I2C patch, including him and copying others.

Thanks,
Vasanth.

On Tue, Oct 30, 2012 at 9:31 PM, Vasanth Ananthan
 wrote:
> This patch adds SATA PHY utility framework APIs. The framework acts as an
> interface between the SATA device and the PHY device. The SATA PHY device
> registers itself with the framework through the APIs provided and the SATA
> device finds and requests for an appropriate PHY device.
>
> Signed-off-by: Vasanth Ananthan 
> ---
>  drivers/ata/Kconfig|   10 +
>  drivers/ata/Makefile   |1 +
>  drivers/ata/sata_phy.c |  104 
> 
>  drivers/ata/sata_phy.h |   44 
>  4 files changed, 159 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/ata/sata_phy.c
>  create mode 100644 drivers/ata/sata_phy.h
>
> diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
> index e08d322..e3a2972 100644
> --- a/drivers/ata/Kconfig
> +++ b/drivers/ata/Kconfig
> @@ -83,6 +83,16 @@ config SATA_AHCI_PLATFORM
>
>   If unsure, say N.
>
> +config SATA_PHY
> +   bool "SATA PHY Framework"
> +   default n
> +   help
> + This option enables the SATA PHY utility framework APIs.
> + The framework acts as an interface between the SATA device
> + and the PHY device. The SATA PHY device registers itself
> + with the framework through the APIs provided and the SATA
> + device finds and requests for an appropriate PHY device.
> +
>  config SATA_FSL
> tristate "Freescale 3.0Gbps SATA support"
> depends on FSL_SOC
> diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
> index 9329daf..3d219a9 100644
> --- a/drivers/ata/Makefile
> +++ b/drivers/ata/Makefile
> @@ -10,6 +10,7 @@ obj-$(CONFIG_SATA_INIC162X)   += sata_inic162x.o
>  obj-$(CONFIG_SATA_SIL24)   += sata_sil24.o
>  obj-$(CONFIG_SATA_DWC) += sata_dwc_460ex.o
>  obj-$(CONFIG_SATA_HIGHBANK)+= sata_highbank.o libahci.o
> +obj-$(CONFIG_SATA_PHY) += sata_phy.o
>
>  # SFF w/ custom DMA
>  obj-$(CONFIG_PDC_ADMA) += pdc_adma.o
> diff --git a/drivers/ata/sata_phy.c b/drivers/ata/sata_phy.c
> new file mode 100644
> index 000..e5631a9
> --- /dev/null
> +++ b/drivers/ata/sata_phy.c
> @@ -0,0 +1,104 @@
> +/*
> + * Copyright (c) 2010-2012 Samsung Electronics Co., Ltd.
> + *  http://www.samsung.com
> + *
> + * EXYNOS - SATA utility framework.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> +*/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "sata_phy.h"
> +
> +static LIST_HEAD(phy_list);
> +static DEFINE_SPINLOCK(phy_lock);
> +
> +struct sata_phy *sata_get_phy(enum sata_phy_type type)
> +{
> +   struct sata_phy *x = NULL;
> +   unsigned long flag;
> +
> +   if (list_empty(&phy_list))
> +   return x;
> +
> +   spin_lock_irqsave(&phy_lock, flag);
> +
> +   list_for_each_entry(x, &phy_list, head) {
> +   if (x->type == type) {
> +   get_device(x->dev);
> +   break;
> +   }
> +   }
> +
> +   spin_unlock_irqrestore(&phy_lock, flag);
> +   return x;
> +}
> +EXPORT_SYMBOL(sata_get_phy);
> +
> +int sata_add_phy(struct sata_phy *phy, enum sata_phy_type type)
> +{
> +   unsigned long flag;
> +   unsigned int ret = -EINVAL;
> +   struct sata_phy *x;
> +
> +   spin_lock_irqsave(&phy_lock, flag);
> +
> +   if (!phy)
> +   return ret;
> +
> +   list_for_each_entry(x, &phy_list, head) {
> +   if (x->type == type) {
> +   dev_err(phy->dev, "transceiver type already 
> exists\n");
> +   goto out;
> +   }
> +   }
> +   phy->type = type;
> +   list_add_tail(&phy->head, &phy_list);
> +   ret = 0;
> +
> + out:
> +   spin_unlock_irqrestore(&phy_lock, flag);
> +   return ret;
> +}
> +EXPORT_SYMBOL(sata_add_phy);
> +
> +void sata_remove_phy(struct sata_phy *phy)
> +{
> +   unsigned long flag;
> +   struct sata_phy *x;
> +
> +   spin_lock_irqsave(&phy_lock, flag);
> +
> +   if (!phy)
> +   return;
> +
> +   list_for_each_entry(x, &phy_list, head) {
> +   if (x->type == phy->type)
> +   list_del(&phy->head);
> +   }
> +
> +   spin_unlock_irqrestore(&phy_lock, flag);
> +}
> +EXPORT_SYMBOL(sata_remove_phy);
> +
> +void sata_put_phy(struct sata_phy *phy)
> +{
> +   unsigned long flag;
> +
> +   spin_lock_irqsave(&phy_lock, flag);
> +
> +   if (!phy)
> +   return;
> +
> +   put_device(phy->dev);
> +   spin_unlock_irqrestore(&phy_lock, flag);
> +
> +}
> +EXPORT_SYMBOL(sata_put_phy);
> diff --git a/drivers/ata/sata_phy.h b/drivers/ata/sata_phy.h
>

[PATCH V2 4/4] i2c: s3c2410: Remove err_cpufreq label

2012-11-23 Thread Tushar Behera
err_cpufreq label is now used only once. It can be removed and related
code can be moved to the caller location.

Signed-off-by: Tushar Behera 
---
Changes since V1:
  * Rebased as per the V2 patch series.

 drivers/i2c/busses/i2c-s3c2410.c |7 ++-
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 3f2d632..ff4408d 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -1044,7 +1044,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
ret = i2c_add_numbered_adapter(&i2c->adap);
if (ret < 0) {
dev_err(&pdev->dev, "failed to add bus to i2c core\n");
-   goto err_cpufreq;
+   s3c24xx_i2c_deregister_cpufreq(i2c);
+   return ret;
}
 
of_i2c_register_devices(&i2c->adap);
@@ -1055,10 +1056,6 @@ static int s3c24xx_i2c_probe(struct platform_device 
*pdev)
 
dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev));
return 0;
-
- err_cpufreq:
-   s3c24xx_i2c_deregister_cpufreq(i2c);
-   return ret;
 }
 
 /* s3c24xx_i2c_remove
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/6] ARM: EXYNOS5: DT Support for SATA and SATA PHY

2012-11-23 Thread Vasanth Ananthan
Hi,

Missed to include Ben, for I2C patch, including him and copying others.

Thanks,
Vasanth.

On Tue, Oct 30, 2012 at 9:31 PM, Vasanth Ananthan
 wrote:
> This patch adds Device Nodes for SATA and SATA PHY device.
>
> Signed-off-by: Vasanth Ananthan 
> ---
>  .../devicetree/bindings/ata/exynos-sata-phy.txt|   14 ++
>  .../devicetree/bindings/ata/exynos-sata.txt|   17 +
>  arch/arm/boot/dts/exynos5250-smdk5250.dts  |   15 +++
>  arch/arm/boot/dts/exynos5250.dtsi  |   18 ++
>  arch/arm/mach-exynos/include/mach/map.h|3 +++
>  arch/arm/mach-exynos/mach-exynos5-dt.c |6 ++
>  6 files changed, 73 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/ata/exynos-sata-phy.txt
>  create mode 100644 Documentation/devicetree/bindings/ata/exynos-sata.txt
>
> diff --git a/Documentation/devicetree/bindings/ata/exynos-sata-phy.txt 
> b/Documentation/devicetree/bindings/ata/exynos-sata-phy.txt
> new file mode 100644
> index 000..37824fa
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/ata/exynos-sata-phy.txt
> @@ -0,0 +1,14 @@
> +* Samsung SATA PHY Controller
> +
> +SATA PHY nodes are defined to describe on-chip SATA Physical layer 
> controllers.
> +Each SATA PHY controller should have its own node.
> +
> +Required properties:
> +- compatible: compatible list, contains "samsung,exynos5-sata-phy"
> +- reg   : 
> +
> +Example:
> +sata@ffe07000 {
> +compatible = "samsung,exynos5-sata-phy";
> +reg = <0xffe07000 0x1000>;
> +};
> diff --git a/Documentation/devicetree/bindings/ata/exynos-sata.txt 
> b/Documentation/devicetree/bindings/ata/exynos-sata.txt
> new file mode 100644
> index 000..0849f10
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/ata/exynos-sata.txt
> @@ -0,0 +1,17 @@
> +* Samsung AHCI SATA Controller
> +
> +SATA nodes are defined to describe on-chip Serial ATA controllers.
> +Each SATA controller should have its own node.
> +
> +Required properties:
> +- compatible: compatible list, contains "samsung,exynos5-sata"
> +- interrupts: 
> +- reg   : 
> +- samsung,sata-freq : 
> +
> +Example:
> +sata@ffe08000 {
> +compatible = "samsung,exynos5-sata";
> +reg = <0xffe08000 0x1000>;
> +interrupts = <115>;
> +};
> diff --git a/arch/arm/boot/dts/exynos5250-smdk5250.dts 
> b/arch/arm/boot/dts/exynos5250-smdk5250.dts
> index a352df4..6910deb 100644
> --- a/arch/arm/boot/dts/exynos5250-smdk5250.dts
> +++ b/arch/arm/boot/dts/exynos5250-smdk5250.dts
> @@ -55,6 +55,21 @@
> };
> };
>
> +   i2c@121D {
> +   samsung,i2c-sda-delay = <100>;
> +   samsung,i2c-max-bus-freq = <4>;
> +   samsung,i2c-slave-addr = <0x38>;
> +
> +   sata-phy {
> +   compatible = "samsung,sata-phy";
> +   reg = <0x38>;
> +   };
> +   };
> +
> +   sata@122F {
> +   samsung,sata-freq = <66>;
> +   };
> +
> i2c@12C8 {
> status = "disabled";
> };
> diff --git a/arch/arm/boot/dts/exynos5250.dtsi 
> b/arch/arm/boot/dts/exynos5250.dtsi
> index dddfd6e..e41520f 100644
> --- a/arch/arm/boot/dts/exynos5250.dtsi
> +++ b/arch/arm/boot/dts/exynos5250.dtsi
> @@ -92,6 +92,17 @@
> interrupts = <0 54 0>;
> };
>
> +   sata@122F {
> +   compatible = "samsung,exynos5-sata-ahci";
> +   reg = <0x122F 0x1ff>;
> +   interrupts = <0 115 0>;
> +   };
> +
> +   sata-phy@1217 {
> +   compatible = "samsung,exynos5-sata-phy";
> +   reg = <0x1217 0x1ff>;
> +   };
> +
> i2c@12C6 {
> compatible = "samsung,s3c2440-i2c";
> reg = <0x12C6 0x100>;
> @@ -156,6 +167,13 @@
> #size-cells = <0>;
> };
>
> +   i2c@121D {
> +compatible = "samsung,exynos5-sata-phy-i2c";
> +reg = <0x121D 0x100>;
> +#address-cells = <1>;
> +#size-cells = <0>;
> +   };
> +
> spi_0: spi@12d2 {
> compatible = "samsung,exynos4210-spi";
> reg = <0x12d2 0x100>;
> diff --git a/arch/arm/mach-exynos/include/mach/map.h 
> b/arch/arm/mach-exynos/include/mach/map.h
> index 8480849..ffeb761 100644
> --- a/arch/arm/mach-exynos/include/mach/map.h
> +++ b/arch/arm/mach-exynos/include/mach/map.h
> @@ -188,6 +188,9 @@
>  #define EXYNOS4_PA_SATA0x1256
>  #define EXYNOS4_PA_SATAPHY 0x125D
>  #define EXYNOS4_PA_SATAPHY_CTRL0x126B
> +#define EXYNOS5_PA_SATA_PHY_CTRL   0x1217
> +#define EXYNOS5_PA_SATA_PHY_I2C0x12

[PATCH V2 3/4] i2c: s3c2410: Move location of clk_prepare_enable() call in probe function

2012-11-23 Thread Tushar Behera
In i2c-s3c2410 driver probe, only s3c24xx_i2c_init() needs the I2C clock
to be enabled. Moving clk_prepare_enable() and clk_disable_unprepare()
calls to around this function simplifies the return path of probe call.

Signed-off-by: Tushar Behera 
---
Changes since V1:
  * Rebased as per the V2 patch series.

 drivers/i2c/busses/i2c-s3c2410.c |   26 +++---
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index a203917..3f2d632 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -975,23 +975,20 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 
dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk);
 
-   clk_prepare_enable(i2c->clk);
 
/* map the registers */
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) {
dev_err(&pdev->dev, "cannot find IO resource\n");
-   ret = -ENOENT;
-   goto err_clk;
+   return -ENOENT;
}
 
i2c->regs = devm_request_and_ioremap(&pdev->dev, res);
 
if (i2c->regs == NULL) {
dev_err(&pdev->dev, "cannot request and map IO\n");
-   ret = -ENXIO;
-   goto err_clk;
+   return -ENXIO;
}
 
dev_dbg(&pdev->dev, "registers %p (%p)\n",
@@ -1004,10 +1001,13 @@ static int s3c24xx_i2c_probe(struct platform_device 
*pdev)
 
/* initialise the i2c controller */
 
+   clk_prepare_enable(i2c->clk);
ret = s3c24xx_i2c_init(i2c);
-   if (ret != 0)
-   goto err_clk;
-
+   clk_disable_unprepare(i2c->clk);
+   if (ret != 0) {
+   dev_err(&pdev->dev, "I2C controller init failed\n");
+   return ret;
+   }
/* find the IRQ for this unit (note, this relies on the init call to
 * ensure no current IRQs pending
 */
@@ -1015,7 +1015,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
i2c->irq = ret = platform_get_irq(pdev, 0);
if (ret <= 0) {
dev_err(&pdev->dev, "cannot find IRQ\n");
-   goto err_clk;
+   return ret;
}
 
ret = devm_request_irq(&pdev->dev, i2c->irq, s3c24xx_i2c_irq, 0,
@@ -1023,13 +1023,13 @@ static int s3c24xx_i2c_probe(struct platform_device 
*pdev)
 
if (ret != 0) {
dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq);
-   goto err_clk;
+   return ret;
}
 
ret = s3c24xx_i2c_register_cpufreq(i2c);
if (ret < 0) {
dev_err(&pdev->dev, "failed to register cpufreq notifier\n");
-   goto err_clk;
+   return ret;
}
 
/* Note, previous versions of the driver used i2c_add_adapter()
@@ -1054,14 +1054,10 @@ static int s3c24xx_i2c_probe(struct platform_device 
*pdev)
pm_runtime_enable(&i2c->adap.dev);
 
dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev));
-   clk_disable_unprepare(i2c->clk);
return 0;
 
  err_cpufreq:
s3c24xx_i2c_deregister_cpufreq(i2c);
-
- err_clk:
-   clk_disable_unprepare(i2c->clk);
return ret;
 }
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND 1/4] i2c: s3c2410: Remove unnecessary label err_noclk

2012-11-23 Thread Tushar Behera
err_noclk label redirects to a simple return statement. Move the
return statement to the caller location and remove the label.

Signed-off-by: Tushar Behera 
---
 drivers/i2c/busses/i2c-s3c2410.c |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 3e0335f..7522f40 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -945,8 +945,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 
i2c->pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!i2c->pdata) {
-   ret = -ENOMEM;
-   goto err_noclk;
+   dev_err(&pdev->dev, "no memory for platform data\n");
+   return -ENOMEM;
}
 
i2c->quirks = s3c24xx_get_device_quirks(pdev);
@@ -971,8 +971,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
i2c->clk = clk_get(&pdev->dev, "i2c");
if (IS_ERR(i2c->clk)) {
dev_err(&pdev->dev, "cannot get clock\n");
-   ret = -ENOENT;
-   goto err_noclk;
+   return -ENOENT;
}
 
dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk);
@@ -1084,8 +1083,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
  err_clk:
clk_disable_unprepare(i2c->clk);
clk_put(i2c->clk);
-
- err_noclk:
return ret;
 }
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 2/4] i2c: s3c2410: Convert to use devm_* APIs

2012-11-23 Thread Tushar Behera
i2c-s3c2410 driver is modified to use devm_clk_get(),
devm_request_and_ioremap() (combining request_mem_region() and
ioremap()) and devm_request_irq(). This also simplifies the
return path in driver's probe.

Signed-off-by: Tushar Behera 
---
Changes since V1:
  * devm_request_mem_region and devm_ioremap calls were replaced by
devm_request_and_ioremap() call.
  * All devm_* related modifications (earlier patches 2-5) were merged
to a single patch.

 drivers/i2c/busses/i2c-s3c2410.c |   51 +-
 1 files changed, 12 insertions(+), 39 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 7522f40..a203917 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -78,7 +78,6 @@ struct s3c24xx_i2c {
void __iomem*regs;
struct clk  *clk;
struct device   *dev;
-   struct resource *ioarea;
struct i2c_adapter  adap;
 
struct s3c2410_platform_i2c *pdata;
@@ -968,7 +967,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
/* find the clock and enable it */
 
i2c->dev = &pdev->dev;
-   i2c->clk = clk_get(&pdev->dev, "i2c");
+   i2c->clk = devm_clk_get(&pdev->dev, "i2c");
if (IS_ERR(i2c->clk)) {
dev_err(&pdev->dev, "cannot get clock\n");
return -ENOENT;
@@ -987,25 +986,16 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
goto err_clk;
}
 
-   i2c->ioarea = request_mem_region(res->start, resource_size(res),
-pdev->name);
-
-   if (i2c->ioarea == NULL) {
-   dev_err(&pdev->dev, "cannot request IO\n");
-   ret = -ENXIO;
-   goto err_clk;
-   }
-
-   i2c->regs = ioremap(res->start, resource_size(res));
+   i2c->regs = devm_request_and_ioremap(&pdev->dev, res);
 
if (i2c->regs == NULL) {
-   dev_err(&pdev->dev, "cannot map IO\n");
+   dev_err(&pdev->dev, "cannot request and map IO\n");
ret = -ENXIO;
-   goto err_ioarea;
+   goto err_clk;
}
 
-   dev_dbg(&pdev->dev, "registers %p (%p, %p)\n",
-   i2c->regs, i2c->ioarea, res);
+   dev_dbg(&pdev->dev, "registers %p (%p)\n",
+   i2c->regs, res);
 
/* setup info block for the i2c core */
 
@@ -1016,7 +1006,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 
ret = s3c24xx_i2c_init(i2c);
if (ret != 0)
-   goto err_iomap;
+   goto err_clk;
 
/* find the IRQ for this unit (note, this relies on the init call to
 * ensure no current IRQs pending
@@ -1025,21 +1015,21 @@ static int s3c24xx_i2c_probe(struct platform_device 
*pdev)
i2c->irq = ret = platform_get_irq(pdev, 0);
if (ret <= 0) {
dev_err(&pdev->dev, "cannot find IRQ\n");
-   goto err_iomap;
+   goto err_clk;
}
 
-   ret = request_irq(i2c->irq, s3c24xx_i2c_irq, 0,
- dev_name(&pdev->dev), i2c);
+   ret = devm_request_irq(&pdev->dev, i2c->irq, s3c24xx_i2c_irq, 0,
+  dev_name(&pdev->dev), i2c);
 
if (ret != 0) {
dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq);
-   goto err_iomap;
+   goto err_clk;
}
 
ret = s3c24xx_i2c_register_cpufreq(i2c);
if (ret < 0) {
dev_err(&pdev->dev, "failed to register cpufreq notifier\n");
-   goto err_irq;
+   goto err_clk;
}
 
/* Note, previous versions of the driver used i2c_add_adapter()
@@ -1070,19 +1060,8 @@ static int s3c24xx_i2c_probe(struct platform_device 
*pdev)
  err_cpufreq:
s3c24xx_i2c_deregister_cpufreq(i2c);
 
- err_irq:
-   free_irq(i2c->irq, i2c);
-
- err_iomap:
-   iounmap(i2c->regs);
-
- err_ioarea:
-   release_resource(i2c->ioarea);
-   kfree(i2c->ioarea);
-
  err_clk:
clk_disable_unprepare(i2c->clk);
-   clk_put(i2c->clk);
return ret;
 }
 
@@ -1101,16 +1080,10 @@ static int s3c24xx_i2c_remove(struct platform_device 
*pdev)
s3c24xx_i2c_deregister_cpufreq(i2c);
 
i2c_del_adapter(&i2c->adap);
-   free_irq(i2c->irq, i2c);
 
clk_disable_unprepare(i2c->clk);
-   clk_put(i2c->clk);
-
-   iounmap(i2c->regs);
 
-   release_resource(i2c->ioarea);
s3c24xx_i2c_dt_gpio_free(i2c);
-   kfree(i2c->ioarea);
 
return 0;
 }
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 0/4] i2c: s3c2410: Add devm_* apis and cleanup

2012-11-23 Thread Tushar Behera
This patchset cleans up the probe function of i2c-s3c2410 driver.
These have been tested on Exynos4210 based Origen board.

Changes since V1:
  * devm_request_mem_region and devm_ioremap calls were replaced by
devm_request_and_ioremap() call.
  * All devm_* related modifications (earlier patches 2-5) were merged
to a single patch.

Tushar Behera (4):
  i2c: s3c2410: Remove unnecessary label err_noclk
  i2c: s3c2410: Convert to use devm_* APIs
  i2c: s3c2410: Move location of clk_prepare_enable() call in probe
function
  i2c: s3c2410: Remove err_cpufreq label

 drivers/i2c/busses/i2c-s3c2410.c |   83 ++---
 1 files changed, 23 insertions(+), 60 deletions(-)

-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/6] ARM: EXYNOS5: Clock settings for SATA and SATA PHY

2012-11-23 Thread Vasanth Ananthan
Hi,

Missed to include Ben, for I2C patch, including him and copying others.

Thanks,
Vasanth.

On Tue, Oct 30, 2012 at 9:31 PM, Vasanth Ananthan
 wrote:
> This patch adds neccessary clock entries for SATA, SATA PHY and
> I2C_SATAPHY
>
> Signed-off-by: Vasanth Ananthan 
> ---
>  arch/arm/mach-exynos/clock-exynos5.c |   21 ++---
>  1 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/mach-exynos/clock-exynos5.c 
> b/arch/arm/mach-exynos/clock-exynos5.c
> index c44ca1e..124c54f 100644
> --- a/arch/arm/mach-exynos/clock-exynos5.c
> +++ b/arch/arm/mach-exynos/clock-exynos5.c
> @@ -651,15 +651,20 @@ static struct clk exynos5_init_clocks_off[] = {
> .ctrlbit= (1 << 15),
> }, {
> .name   = "sata",
> -   .devname= "ahci",
> +   .devname= "exynos5-sata",
> +   .parent = &exynos5_clk_aclk_200.clk,
> .enable = exynos5_clk_ip_fsys_ctrl,
> .ctrlbit= (1 << 6),
> }, {
> -   .name   = "sata_phy",
> +   .name   = "sata-phy",
> +   .devname= "exynos5-sata-phy",
> +   .parent = &exynos5_clk_aclk_200.clk,
> .enable = exynos5_clk_ip_fsys_ctrl,
> .ctrlbit= (1 << 24),
> }, {
> -   .name   = "sata_phy_i2c",
> +   .name   = "i2c",
> +   .devname= "exynos5-sata-phy-i2c",
> +   .parent = &exynos5_clk_aclk_200.clk,
> .enable = exynos5_clk_ip_fsys_ctrl,
> .ctrlbit= (1 << 25),
> }, {
> @@ -1226,6 +1231,16 @@ static struct clksrc_clk exynos5_clksrcs[] = {
> .reg_div = { .reg = EXYNOS5_CLKDIV_TOP0, .shift = 24, .size = 
> 3 },
> }, {
> .clk= {
> +   .name   = "sclk_sata",
> +   .devname= "exynos5-sata",
> +   .enable = exynos5_clksrc_mask_fsys_ctrl,
> +   .ctrlbit= (1 << 24),
> +   },
> +   .sources = &exynos5_clkset_aclk,
> +   .reg_src = { .reg = EXYNOS5_CLKSRC_FSYS, .shift = 24, .size = 
> 1 },
> +   .reg_div = { .reg = EXYNOS5_CLKDIV_FSYS0, .shift = 20, .size 
> = 4 },
> +   }, {
> +   .clk= {
> .name   = "sclk_gscl_wrap",
> .devname= "s5p-mipi-csis.0",
> .enable = exynos5_clksrc_mask_gscl_ctrl,
> --
> 1.7.4.1
>



-- 
Regards,

Vasanth K A
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html