RE: [PATCH] mfd:rtsx: Support RTL8411B

2013-04-19 Thread Roger Tseng
>On Fri, Apr 19, 2013 at 09:52:42PM +0800, rogera...@realtek.com wrote:
>> From: Roger Tseng 
>>
>> Adding support of model RTL8411B. Since the model is similar to RTL8411,
>> differences are implemented in rtl8411.c.
>>
>
>What tree is this against?
>
>regards,
>dan carpenter

It should be the mfd-next tree.

Best regards,
Roger Tseng--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" 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/9] mmc: fix max_discard_sectors

2013-04-19 Thread Namjae Jeon
From: Namjae Jeon 

https://lkml.org/lkml/2013/4/1/292
As per above discussion, there is possibility that request's __data_len
field may overflow when max_discard_sectors greater than UINT_MAX >> 9

If multiple discard requests get merged, merged discard request's
size exceeds 4GB, there is possibility that merged discard request's
__data_len field may overflow.

This patch fixes this issue.

Reported-by: Max Filippov 
Signed-off-by: Namjae Jeon 
Signed-off-by: Vivek Trivedi 
---
 drivers/mmc/card/queue.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index 9447a0e..54726b7 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -166,7 +166,7 @@ static void mmc_queue_setup_discard(struct request_queue *q,
return;
 
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
-   q->limits.max_discard_sectors = max_discard;
+   blk_queue_max_discard_sectors(q, max_discard);
if (card->erased_byte == 0 && !mmc_can_discard(card))
q->limits.discard_zeroes_data = 1;
q->limits.discard_granularity = card->pref_erase << 9;
-- 
1.7.9.5

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


[PATCH v2 9/9] bcache: use generic helper to set max_discard_sectors

2013-04-19 Thread Namjae Jeon
From: Namjae Jeon 

It is better to use blk_queue_max_discard_sectors helper
function to set max_discard_sectors as it checks
max_discard_sectors upper limit UINT_MAX >> 9

similar issue was reported for mmc in below link
https://lkml.org/lkml/2013/4/1/292

If multiple discard requests get merged, merged discard request's
size exceeds 4GB, there is possibility that merged discard request's
__data_len field may overflow.

This patch fixes this issue.

Signed-off-by: Namjae Jeon 
Signed-off-by: Vivek Trivedi 
---
 drivers/md/bcache/super.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index f3bf310..d87ab31 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -746,7 +746,7 @@ static int bcache_device_init(struct bcache_device *d, 
unsigned block_size)
q->limits.max_sectors   = UINT_MAX;
q->limits.max_segment_size  = UINT_MAX;
q->limits.max_segments  = BIO_MAX_PAGES;
-   q->limits.max_discard_sectors   = UINT_MAX;
+   blk_queue_max_discard_sectors(q, UINT_MAX >> 9);
q->limits.io_min= block_size;
q->limits.logical_block_size= block_size;
q->limits.physical_block_size   = block_size;
-- 
1.7.9.5

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


[PATCH v2 8/9] dm thin: use generic helper to set max_discard_sectors

2013-04-19 Thread Namjae Jeon
From: Namjae Jeon 

It is better to use blk_queue_max_discard_sectors helper
function to set max_discard_sectors as it checks
max_discard_sectors upper limit UINT_MAX >> 9

similar issue was reported for mmc in below link
https://lkml.org/lkml/2013/4/1/292

If multiple discard requests get merged, merged discard request's
size exceeds 4GB, there is possibility that merged discard request's
__data_len field may overflow.

This patch fixes this issue.

Signed-off-by: Namjae Jeon 
Signed-off-by: Vivek Trivedi 
---
 drivers/md/dm-thin.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 905b75f..237295a 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -2513,7 +2513,8 @@ static void set_discard_limits(struct pool_c *pt, struct 
queue_limits *limits)
struct pool *pool = pt->pool;
struct queue_limits *data_limits;
 
-   limits->max_discard_sectors = pool->sectors_per_block;
+   blk_queue_max_discard_sectors(bdev_get_queue(pt->data_dev->bdev),
+   pool->sectors_per_block);
 
/*
 * discard_granularity is just a hint, and not enforced.
-- 
1.7.9.5

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


[PATCH v2 7/9] brd: use generic helper to set max_discard_sectors

2013-04-19 Thread Namjae Jeon
From: Namjae Jeon 

It is better to use blk_queue_max_discard_sectors helper
function to set max_discard_sectors as it checks
max_discard_sectors upper limit UINT_MAX >> 9

similar issue was reported for mmc in below link
https://lkml.org/lkml/2013/4/1/292

If multiple discard requests get merged, merged discard request's
size exceeds 4GB, there is possibility that merged discard request's
__data_len field may overflow.

This patch fixes this issue.

Signed-off-by: Namjae Jeon 
Signed-off-by: Vivek Trivedi 
---
 drivers/block/brd.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index f1a29f8..108646d 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -479,7 +479,7 @@ static struct brd_device *brd_alloc(int i)
blk_queue_bounce_limit(brd->brd_queue, BLK_BOUNCE_ANY);
 
brd->brd_queue->limits.discard_granularity = PAGE_SIZE;
-   brd->brd_queue->limits.max_discard_sectors = UINT_MAX;
+   blk_queue_max_discard_sectors(brd->brd_queue, UINT_MAX >> 9);
brd->brd_queue->limits.discard_zeroes_data = 1;
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, brd->brd_queue);
 
-- 
1.7.9.5

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


[PATCH v2 6/9] nbd: use generic helper to set max_discard_sectors

2013-04-19 Thread Namjae Jeon
From: Namjae Jeon 

It is better to use blk_queue_max_discard_sectors helper
function to set max_discard_sectors as it checks
max_discard_sectors upper limit UINT_MAX >> 9

similar issue was reported for mmc in below link
https://lkml.org/lkml/2013/4/1/292

If multiple discard requests get merged, merged discard request's
size exceeds 4GB, there is possibility that merged discard request's
__data_len field may overflow.

This patch fixes this issue.

Signed-off-by: Namjae Jeon 
Signed-off-by: Vivek Trivedi 
---
 drivers/block/nbd.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 037288e..b9d3d2e 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -854,7 +854,7 @@ static int __init nbd_init(void)
 */
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, disk->queue);
disk->queue->limits.discard_granularity = 512;
-   disk->queue->limits.max_discard_sectors = UINT_MAX;
+   blk_queue_max_discard_sectors(disk->queue, UINT_MAX >> 9);
disk->queue->limits.discard_zeroes_data = 0;
blk_queue_max_hw_sectors(disk->queue, 65536);
disk->queue->limits.max_sectors = 256;
-- 
1.7.9.5

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


[PATCH v2 5/9] loop: use generic helper to set max_discard_sectors

2013-04-19 Thread Namjae Jeon
From: Namjae Jeon 

It is better to use blk_queue_max_discard_sectors helper
function to set max_discard_sectors as it checks
max_discard_sectors upper limit UINT_MAX >> 9

similar issue was reported for mmc in below link
https://lkml.org/lkml/2013/4/1/292

If multiple discard requests get merged, merged discard request's
size exceeds 4GB, there is possibility that merged discard request's
__data_len field may overflow.

This patch fixes this issue.

Signed-off-by: Namjae Jeon 
Signed-off-by: Vivek Trivedi 
---
 drivers/block/loop.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index b2955b3..aedc341 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -814,7 +814,7 @@ static void loop_config_discard(struct loop_device *lo)
 
q->limits.discard_granularity = inode->i_sb->s_blocksize;
q->limits.discard_alignment = 0;
-   q->limits.max_discard_sectors = UINT_MAX >> 9;
+   blk_queue_max_discard_sectors(q, UINT_MAX >> 9);
q->limits.discard_zeroes_data = 1;
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
 }
-- 
1.7.9.5

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


[PATCH v2 4/9] mtd: mtd_blkdevs: use generic helper to set

2013-04-19 Thread Namjae Jeon
From: Namjae Jeon 

It is better to use blk_queue_max_discard_sectors helper
function to set max_discard_sectors as it checks
max_discard_sectors upper limit UINT_MAX >> 9

similar issue was reported for mmc in below link
https://lkml.org/lkml/2013/4/1/292

If multiple discard requests get merged, merged discard request's
size exceeds 4GB, there is possibility that merged discard request's
__data_len field may overflow.

This patch fixes this issue.

Signed-off-by: Namjae Jeon 
Signed-off-by: Vivek Trivedi 
---
 drivers/mtd/mtd_blkdevs.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 5ad39bb..cf35f99 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -417,7 +417,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 
if (tr->discard) {
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, new->rq);
-   new->rq->limits.max_discard_sectors = UINT_MAX;
+   blk_queue_max_discard_sectors(new->rq, UINT_MAX >> 9);
}
 
gd->queue = new->rq;
-- 
1.7.9.5

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


[PATCH v2 3/9] sd: use generic helper to set max_discard_sectors

2013-04-19 Thread Namjae Jeon
From: Namjae Jeon 

It is better to use blk_queue_max_discard_sectors helper
function to set max_discard_sectors as it checks
max_discard_sectors upper limit UINT_MAX >> 9

similar issue was reported for mmc in below link
https://lkml.org/lkml/2013/4/1/292

If multiple discard requests get merged, merged discard request's
size exceeds 4GB, there is possibility that merged discard request's
__data_len field may overflow.

This patch fixes this issue.

Signed-off-by: Namjae Jeon 
Signed-off-by: Vivek Trivedi 
---
 drivers/scsi/sd.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 7992635..93c26b3 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -632,7 +632,8 @@ static void sd_config_discard(struct scsi_disk *sdkp, 
unsigned int mode)
break;
}
 
-   q->limits.max_discard_sectors = max_blocks * (logical_block_size >> 9);
+   blk_queue_max_discard_sectors(q,
+   max_blocks * (logical_block_size >> 9));
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
 }
 
-- 
1.7.9.5

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


[PATCH v2 1/9] block: fix max discard sectors limit

2013-04-19 Thread Namjae Jeon
From: Namjae Jeon 

https://lkml.org/lkml/2013/4/1/292

As per above discussion, it has been oberved that few drivers are
setting q->limits.max_discard_sectors to more than (UINT_MAX >> 9)

If multiple discard requests get merged, merged discard request's
size exceeds 4GB, there is possibility that merged discard request's
__data_len field may overflow.

This patch fixes this issue.

Also, adding BLK_DEF_MAX_DISCARD_SECTORS macro to use it instead
of UINT_MAX >> 9.

Reported-by: Max Filippov 
Signed-off-by: Namjae Jeon 
Signed-off-by: Vivek Trivedi 
---
 block/blk-settings.c   |3 ++-
 include/linux/blkdev.h |1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index c50ecf0..34e6b61 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -283,7 +283,8 @@ EXPORT_SYMBOL(blk_queue_max_hw_sectors);
 void blk_queue_max_discard_sectors(struct request_queue *q,
unsigned int max_discard_sectors)
 {
-   q->limits.max_discard_sectors = max_discard_sectors;
+   q->limits.max_discard_sectors = min_t(unsigned int, max_discard_sectors,
+   BLK_DEF_MAX_DISCARD_SECTORS);
 }
 EXPORT_SYMBOL(blk_queue_max_discard_sectors);
 
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 07aa5f6..efff505 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1105,6 +1105,7 @@ enum blk_default_limits {
BLK_DEF_MAX_SECTORS = 1024,
BLK_MAX_SEGMENT_SIZE= 65536,
BLK_SEG_BOUNDARY_MASK   = 0xUL,
+   BLK_DEF_MAX_DISCARD_SECTORS = UINT_MAX >> 9,
 };
 
 #define blkdev_entry_to_request(entry) list_entry((entry), struct request, 
queuelist)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" 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/9] fix max discard sectors limit

2013-04-19 Thread Namjae Jeon
From: Namjae Jeon 

linux-v3.8-rc1 and later support for plug for blkdev_issue_discard with
commit 0cfbcafcae8b7364b5fa96c2b26ccde7a3a296a9 
(block: add plug for blkdev_issue_discard )

For example,
1) DISCARD rq-1 with size size 4GB
2) DISCARD rq-2 with size size 1GB

If these 2 discard requests get merged, final request size will be 5GB.

In this case, request's __data_len field may overflow as it can store
max 4GB(unsigned int).

This issue was observed while doing mkfs.f2fs on 5GB SD card:
https://lkml.org/lkml/2013/4/1/292

# mkfs.f2fs /dev/mmcblk0p3
Info: sector size = 512
Info: total sectors = 11370496 (in 512bytes)
Info: zone aligned segment0 blkaddr: 512
[  257.789764] blk_update_request: bio idx 0 >= vcnt 0

mkfs process gets stuck in D state and I see the following in the dmesg:

[  257.789733] __end_that: dev mmcblk0: type=1, flags=122c8081
[  257.789764]   sector 4194304, nr/cnr 2981888/4294959104
[  257.789764]   bio df3840c0, biotail df3848c0, buffer   (null), len 1526726656
[  257.789764] blk_update_request: bio idx 0 >= vcnt 0
[  257.794921] request botched: dev mmcblk0: type=1, flags=122c8081
[  257.794921]   sector 4194304, nr/cnr 2981888/4294959104
[  257.794921]   bio df3840c0, biotail df3848c0, buffer   (null), len 1526726656

Few drivers(e.g. mmc, mtd..) set q->limits.max_discard_sectors
more than UINT_MAX >> 9 sectors which is incorrect and it may lead to overflow
of request's __data_len field if merged discard request's size exceeds 4GB.

This patchset fixes this issue by updating helper function
blk_queue_max_discard_sectors which is used to set max_discard_sectors limit.

This patchset also replaces "q->limits.max_discard_sector = max_discard_sectors"
with blk_queue_max_discard_sectors call in other drivers like mmc, mtd etc.

Namjae Jeon (9):
  block: fix max discard sectors limit
  mmc: fix max_discard_sectors
  sd: use generic helper to set max_discard_sectors
  mtd: use generic helper to set max_discard_sectors
  loop: use generic helper to set max_discard_sectors
  nbd: use generic helper to set max_discard_sectors
  brd: use generic helper to set max_discard_sectors
  dm thin: use generic helper to set max_discard_sectors
  bcache: use generic helper to set max_discard_sectors
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" 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] mfd:rtsx: Support RTS5249

2013-04-19 Thread Samuel Ortiz
Hi Wei,

On Fri, Apr 19, 2013 at 09:50:33AM +0800, wwang wrote:
> 于 2013年04月19日 06:50, Samuel Ortiz 写道:
> >Hi Wei,
> >
> >On Thu, Apr 11, 2013 at 10:43:40AM +0800, wei_w...@realsil.com.cn wrote:
> >>From: Wei WANG 
> >>
> >>Support new model: RTS5249
> >Could you please provide me with a more detailled changelog (What's so
> >different with this model that the current driver does not support ?) before 
> >I
> >apply it ?
> >
> >Cheers,
> >Samuel.
> >
> 
> The difference is minor except that RTS5249 supports SD UHS-II interface.
> 
> In order to support SD UHS-II,the definitions of some internal
> registers of RTS5249 have to be modified and are different from its
> predecessors. So we need this patch to ensure RTS5249 can work, even
> SD/MMC stack doesn't support UHS-II interface.
Patch applied and pushed now, thanks.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mfd:rtsx: Support RTL8411B

2013-04-19 Thread Dan Carpenter
On Fri, Apr 19, 2013 at 09:52:42PM +0800, rogera...@realtek.com wrote:
> From: Roger Tseng 
> 
> Adding support of model RTL8411B. Since the model is similar to RTL8411,
> differences are implemented in rtl8411.c.
> 

What tree is this against?

regards,
dan carpenter

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


[PATCH] mfd:rtsx: Support RTL8411B

2013-04-19 Thread rogerable
From: Roger Tseng 

Adding support of model RTL8411B. Since the model is similar to RTL8411,
differences are implemented in rtl8411.c.

Signed-off-by: Roger Tseng 
---
 drivers/mfd/rtl8411.c| 132 +++
 drivers/mfd/rtsx_pcr.c   |   5 ++
 drivers/mfd/rtsx_pcr.h   |   1 +
 include/linux/mfd/rtsx_pci.h |   1 +
 4 files changed, 139 insertions(+)

diff --git a/drivers/mfd/rtl8411.c b/drivers/mfd/rtl8411.c
index 2a2d316..c436bf2 100644
--- a/drivers/mfd/rtl8411.c
+++ b/drivers/mfd/rtl8411.c
@@ -35,12 +35,33 @@ static u8 rtl8411_get_ic_version(struct rtsx_pcr *pcr)
return val & 0x0F;
 }
 
+static int rtl8411b_is_qfn48(struct rtsx_pcr *pcr)
+{
+   u8 val = 0;
+
+   rtsx_pci_read_register(pcr, RTL8411B_PACKAGE_MODE, &val);
+
+   if (val & 0x2)
+   return 1;
+   else
+   return 0;
+}
+
 static int rtl8411_extra_init_hw(struct rtsx_pcr *pcr)
 {
return rtsx_pci_write_register(pcr, CD_PAD_CTL,
CD_DISABLE_MASK | CD_AUTO_DISABLE, CD_ENABLE);
 }
 
+static int rtl8411b_extra_init_hw(struct rtsx_pcr *pcr)
+{
+   if (rtl8411b_is_qfn48(pcr))
+   rtsx_pci_write_register(pcr, CARD_PULL_CTL3, 0xFF, 0xF5);
+
+   return rtsx_pci_write_register(pcr, CD_PAD_CTL,
+   CD_DISABLE_MASK | CD_AUTO_DISABLE, CD_ENABLE);
+}
+
 static int rtl8411_turn_on_led(struct rtsx_pcr *pcr)
 {
return rtsx_pci_write_register(pcr, CARD_GPIO, 0x01, 0x00);
@@ -214,6 +235,20 @@ static const struct pcr_ops rtl8411_pcr_ops = {
.conv_clk_and_div_n = rtl8411_conv_clk_and_div_n,
 };
 
+static const struct pcr_ops rtl8411b_pcr_ops = {
+   .extra_init_hw = rtl8411b_extra_init_hw,
+   .optimize_phy = NULL,
+   .turn_on_led = rtl8411_turn_on_led,
+   .turn_off_led = rtl8411_turn_off_led,
+   .enable_auto_blink = rtl8411_enable_auto_blink,
+   .disable_auto_blink = rtl8411_disable_auto_blink,
+   .card_power_on = rtl8411_card_power_on,
+   .card_power_off = rtl8411_card_power_off,
+   .switch_output_voltage = rtl8411_switch_output_voltage,
+   .cd_deglitch = rtl8411_cd_deglitch,
+   .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n,
+};
+
 /* SD Pull Control Enable:
  * SD_DAT[3:0] ==> pull up
  * SD_CD   ==> pull up
@@ -276,6 +311,74 @@ static const u32 rtl8411_ms_pull_ctl_disable_tbl[] = {
0,
 };
 
+static const u32 rtl8411b_qfn64_sd_pull_ctl_enable_tbl[] = {
+   RTSX_REG_PAIR(CARD_PULL_CTL1, 0xAA),
+   RTSX_REG_PAIR(CARD_PULL_CTL2, 0xAA),
+   RTSX_REG_PAIR(CARD_PULL_CTL3, 0x09 | 0xD0),
+   RTSX_REG_PAIR(CARD_PULL_CTL4, 0x09 | 0x50),
+   RTSX_REG_PAIR(CARD_PULL_CTL5, 0x05 | 0x50),
+   RTSX_REG_PAIR(CARD_PULL_CTL6, 0x04 | 0x11),
+   0,
+};
+
+static const u32 rtl8411b_qfn48_sd_pull_ctl_enable_tbl[] = {
+   RTSX_REG_PAIR(CARD_PULL_CTL2, 0xAA),
+   RTSX_REG_PAIR(CARD_PULL_CTL3, 0x69 | 0x90),
+   RTSX_REG_PAIR(CARD_PULL_CTL6, 0x08 | 0x11),
+   0,
+};
+
+static const u32 rtl8411b_qfn64_sd_pull_ctl_disable_tbl[] = {
+   RTSX_REG_PAIR(CARD_PULL_CTL1, 0x65),
+   RTSX_REG_PAIR(CARD_PULL_CTL2, 0x55),
+   RTSX_REG_PAIR(CARD_PULL_CTL3, 0x05 | 0xD0),
+   RTSX_REG_PAIR(CARD_PULL_CTL4, 0x09 | 0x50),
+   RTSX_REG_PAIR(CARD_PULL_CTL5, 0x05 | 0x50),
+   RTSX_REG_PAIR(CARD_PULL_CTL6, 0x04 | 0x11),
+   0,
+};
+
+static const u32 rtl8411b_qfn48_sd_pull_ctl_disable_tbl[] = {
+   RTSX_REG_PAIR(CARD_PULL_CTL2, 0x55),
+   RTSX_REG_PAIR(CARD_PULL_CTL3, 0x65 | 0x90),
+   RTSX_REG_PAIR(CARD_PULL_CTL6, 0x04 | 0x11),
+   0,
+};
+
+static const u32 rtl8411b_qfn64_ms_pull_ctl_enable_tbl[] = {
+   RTSX_REG_PAIR(CARD_PULL_CTL1, 0x65),
+   RTSX_REG_PAIR(CARD_PULL_CTL2, 0x55),
+   RTSX_REG_PAIR(CARD_PULL_CTL3, 0x05 | 0xD0),
+   RTSX_REG_PAIR(CARD_PULL_CTL4, 0x05 | 0x50),
+   RTSX_REG_PAIR(CARD_PULL_CTL5, 0x05 | 0x50),
+   RTSX_REG_PAIR(CARD_PULL_CTL6, 0x04 | 0x11),
+   0,
+};
+
+static const u32 rtl8411b_qfn48_ms_pull_ctl_enable_tbl[] = {
+   RTSX_REG_PAIR(CARD_PULL_CTL2, 0x55),
+   RTSX_REG_PAIR(CARD_PULL_CTL3, 0x65 | 0x90),
+   RTSX_REG_PAIR(CARD_PULL_CTL6, 0x04 | 0x11),
+   0,
+};
+
+static const u32 rtl8411b_qfn64_ms_pull_ctl_disable_tbl[] = {
+   RTSX_REG_PAIR(CARD_PULL_CTL1, 0x65),
+   RTSX_REG_PAIR(CARD_PULL_CTL2, 0x55),
+   RTSX_REG_PAIR(CARD_PULL_CTL3, 0x05 | 0xD0),
+   RTSX_REG_PAIR(CARD_PULL_CTL4, 0x09 | 0x50),
+   RTSX_REG_PAIR(CARD_PULL_CTL5, 0x05 | 0x50),
+   RTSX_REG_PAIR(CARD_PULL_CTL6, 0x04 | 0x11),
+   0,
+};
+
+static const u32 rtl8411b_qfn48_ms_pull_ctl_disable_tbl[] = {
+   RTSX_REG_PAIR(CARD_PULL_CTL2, 0x55),
+   RTSX_REG_PAIR(CARD_PULL_CTL3, 0x65 | 0x90),
+   RTSX_REG_PAIR(CARD_PULL_CTL6, 0x04 | 0x11),
+   0,
+};
+
 void rtl8411_init_params(struct rtsx_pcr *pcr)
 {
pcr->extra_caps = EXTRA_CAPS_SD_SDR50 | EXTRA_CAPS_SD_SDR104;
@@ -288,3 +391,32 @@ vo

[PATCH] mmc: core: Restructure and simplify code for mmc sleep|awake

2013-04-19 Thread Ulf Hansson
From: Ulf Hansson 

The mmc_card_sleep|awake APIs are not being used since the support is
already properly encapsulated within the suspend sequence. Sleep|awake
command is also specific for eMMC.

We remove the sleep|awake bus_ops, the mmc_card_sleep|awake APIs and
move the code into the mmc specific core instead. This also includes
the mmc ops function, mmc_sleepawake. All releated functions have then
become static and we have got far less code to maintain.

Additionally this patch also simplifies the code from mmc_sleepawake,
since it is only used to put the card to sleep and not awake.

Signed-off-by: Ulf Hansson 
---
 drivers/mmc/core/core.c|   46 --
 drivers/mmc/core/core.h|2 --
 drivers/mmc/core/mmc.c |   77 +++-
 drivers/mmc/core/mmc_ops.c |   34 ---
 drivers/mmc/core/mmc_ops.h |1 -
 include/linux/mmc/host.h   |4 ---
 6 files changed, 41 insertions(+), 123 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index ad7decc..4192c8c 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2507,52 +2507,6 @@ int mmc_power_restore_host(struct mmc_host *host)
 }
 EXPORT_SYMBOL(mmc_power_restore_host);
 
-int mmc_card_awake(struct mmc_host *host)
-{
-   int err = -ENOSYS;
-
-   if (host->caps2 & MMC_CAP2_NO_SLEEP_CMD)
-   return 0;
-
-   mmc_bus_get(host);
-
-   if (host->bus_ops && !host->bus_dead && host->bus_ops->awake)
-   err = host->bus_ops->awake(host);
-
-   mmc_bus_put(host);
-
-   return err;
-}
-EXPORT_SYMBOL(mmc_card_awake);
-
-int mmc_card_sleep(struct mmc_host *host)
-{
-   int err = -ENOSYS;
-
-   if (host->caps2 & MMC_CAP2_NO_SLEEP_CMD)
-   return 0;
-
-   mmc_bus_get(host);
-
-   if (host->bus_ops && !host->bus_dead && host->bus_ops->sleep)
-   err = host->bus_ops->sleep(host);
-
-   mmc_bus_put(host);
-
-   return err;
-}
-EXPORT_SYMBOL(mmc_card_sleep);
-
-int mmc_card_can_sleep(struct mmc_host *host)
-{
-   struct mmc_card *card = host->card;
-
-   if (card && mmc_card_mmc(card) && card->ext_csd.rev >= 3)
-   return 1;
-   return 0;
-}
-EXPORT_SYMBOL(mmc_card_can_sleep);
-
 /*
  * Flush the cache to the non-volatile storage.
  */
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index b9f18a2..68892e1 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -16,8 +16,6 @@
 #define MMC_CMD_RETRIES3
 
 struct mmc_bus_ops {
-   int (*awake)(struct mmc_host *);
-   int (*sleep)(struct mmc_host *);
void (*remove)(struct mmc_host *);
void (*detect)(struct mmc_host *);
int (*suspend)(struct mmc_host *);
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index d584f7c..2934e5c 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1321,6 +1321,45 @@ err:
return err;
 }
 
+static int mmc_can_sleep(struct mmc_card *card)
+{
+   return (card && card->ext_csd.rev >= 3);
+}
+
+static int mmc_sleep(struct mmc_host *host)
+{
+   struct mmc_command cmd = {0};
+   struct mmc_card *card = host->card;
+   int err;
+
+   if (host->caps2 & MMC_CAP2_NO_SLEEP_CMD)
+   return 0;
+
+   err = mmc_deselect_cards(host);
+   if (err)
+   return err;
+
+   cmd.opcode = MMC_SLEEP_AWAKE;
+   cmd.arg = card->rca << 16;
+   cmd.arg |= 1 << 15;
+
+   cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
+   err = mmc_wait_for_cmd(host, &cmd, 0);
+   if (err)
+   return err;
+
+   /*
+* If the host does not wait while the card signals busy, then we will
+* will have to wait the sleep/awake timeout.  Note, we cannot use the
+* SEND_STATUS command to poll the status because that command (and most
+* others) is invalid while the card sleeps.
+*/
+   if (!(host->caps & MMC_CAP_WAIT_WHILE_BUSY))
+   mmc_delay(DIV_ROUND_UP(card->ext_csd.sa_timeout, 1));
+
+   return err;
+}
+
 static int mmc_can_poweroff_notify(const struct mmc_card *card)
 {
return card &&
@@ -1417,8 +1456,8 @@ static int mmc_suspend(struct mmc_host *host)
 
if (mmc_can_poweroff_notify(host->card))
err = mmc_poweroff_notify(host->card, EXT_CSD_POWER_OFF_SHORT);
-   else if (mmc_card_can_sleep(host))
-   err = mmc_card_sleep(host);
+   else if (mmc_can_sleep(host->card))
+   err = mmc_sleep(host);
else if (!mmc_host_is_spi(host))
err = mmc_deselect_cards(host);
host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200);
@@ -1460,39 +1499,7 @@ static int mmc_power_restore(struct mmc_host *host)
return ret;
 }
 
-static int mmc_sleep(struct mmc_host *host)
-{
-   struct mmc_card *card = host->card;
-   int err = -ENOSYS;
-
-   if (card && card->ext

[PATCH 3/3] Add Documentation for MMC boot_enable attribute

2013-04-19 Thread Neil Armstrong
Add documentation on the enable_boot sysfs attribute.

Signed-off-by: Neil Armstrong 
---
 Documentation/mmc/mmc-dev-parts.txt |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/Documentation/mmc/mmc-dev-parts.txt
b/Documentation/mmc/mmc-dev-parts.txt
index f08d078..78228de 100644
--- a/Documentation/mmc/mmc-dev-parts.txt
+++ b/Documentation/mmc/mmc-dev-parts.txt
@@ -38,3 +38,9 @@ feature has been disabled on the card, the file will
be read-only.
 The boot partitions can also be locked permanently, but this feature is
 not accessible through sysfs in order to avoid accidental or malicious
 bricking.
+
+A special attribute named boot_enable is available to configure the
+selected partition for the eMMC 4.3+ boot operation mode.
+When selected between the two factory boot partitions and the main
+user partition, at boot time a special sequence enables makes the
+eMMC device to output the content of the selected partition.
-- 
1.7.0.4

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


[PATCH 2/3] Add boot_enable sysfs attribute to select MMC boot operation partition

2013-04-19 Thread Neil Armstrong
Add sysfs attribute to select the eMMC boot mode operation according to
the eMMC 4.5 specifications.
Valid values are : 0 for disabled, 1 for first boot partition, 2 for
second boot partition, 7 for user area.

Signed-off-by: Neil Armstrong 
---
 drivers/mmc/card/block.c |   72
+-
 1 files changed, 71 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 5bab73b..e11c42e 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -114,6 +114,7 @@ struct mmc_blk_data {
  */
 unsigned intpart_curr;
 struct device_attribute force_ro;
+struct device_attribute boot_enable;
 struct device_attribute power_ro_lock;
 intarea_type;
 };
@@ -264,6 +265,23 @@ static ssize_t force_ro_show(struct device *dev,
struct device_attribute *attr,
 return ret;
 }
 
+static ssize_t boot_enable_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+int ret;
+struct mmc_card *card;
+struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
+
+md = mmc_blk_get(dev_to_disk(dev));
+card = md->queue.card;
+
+ret = snprintf(buf, PAGE_SIZE, "%d",
+(card->ext_csd.part_config &
+ EXT_CSD_PART_CONFIG_EN_MASK) >> 3);
+mmc_blk_put(md);
+return ret;
+}
+
 static ssize_t force_ro_store(struct device *dev, struct
device_attribute *attr,
   const char *buf, size_t count)
 {
@@ -283,6 +301,48 @@ out:
 return ret;
 }
 
+static ssize_t boot_enable_store(struct device *dev,
+  struct device_attribute *attr, const char *buf,
+  size_t count)
+{
+int ret;
+char *end;
+u8 part_config;
+struct mmc_card *card;
+struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
+unsigned long set = simple_strtoul(buf, &end, 0);
+if (end == buf) {
+ret = -EINVAL;
+goto out;
+}
+
+md = mmc_blk_get(dev_to_disk(dev));
+card = md->queue.card;
+
+part_config = card->ext_csd.part_config;
+
+part_config &= EXT_CSD_PART_CONFIG_EN_MASK;
+part_config |= (set << 3) & EXT_CSD_PART_CONFIG_EN_MASK;
+
+mmc_claim_host(card->host);
+
+ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+ EXT_CSD_PART_CONFIG, part_config,
+ card->ext_csd.part_time);
+
+mmc_release_host(card->host);
+
+if (ret)
+return ret;
+
+card->ext_csd.part_config = part_config;
+
+ret = count;
+out:
+mmc_blk_put(md);
+return ret;
+}
+
 static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
 {
 struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk);
@@ -2202,6 +2262,15 @@ static int mmc_add_disk(struct mmc_blk_data *md)
 if (ret)
 goto force_ro_fail;
 
+md->boot_enable.show = boot_enable_show;
+md->boot_enable.store = boot_enable_store;
+sysfs_attr_init(&md->boot_enable.attr);
+md->boot_enable.attr.name = "boot_enable";
+md->boot_enable.attr.mode = S_IRUGO | S_IWUSR;
+ret = device_create_file(disk_to_dev(md->disk), &md->boot_enable);
+if (ret)
+goto boot_enable_fail;
+
 if ((md->area_type & MMC_BLK_DATA_AREA_BOOT) &&
  card->ext_csd.boot_ro_lockable) {
 umode_t mode;
@@ -2225,6 +2294,8 @@ static int mmc_add_disk(struct mmc_blk_data *md)
 return ret;
 
 power_ro_lock_fail:
+device_remove_file(disk_to_dev(md->disk), &md->boot_enable);
+boot_enable_fail:
 device_remove_file(disk_to_dev(md->disk), &md->force_ro);
 force_ro_fail:
 del_gendisk(md->disk);
@@ -2434,4 +2505,3 @@ module_exit(mmc_blk_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Multimedia Card (MMC) block device driver");
-
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" 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] Add BOOT_PARTITION_ENABLE definition to MMC EXT_CSD PART_CONFIG

2013-04-19 Thread Neil Armstrong
Add bit mask for the BOOT_PARTITION_ENABLE values.

Signed-off-by: Neil Armstrong 
---
 include/linux/mmc/mmc.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index 50bcde3..eb5b361 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -347,6 +347,7 @@ struct _mmc_csd {
 #define EXT_CSD_PART_CONFIG_ACC_BOOT0(0x1)
 #define EXT_CSD_PART_CONFIG_ACC_RPMB(0x3)
 #define EXT_CSD_PART_CONFIG_ACC_GP0(0x4)
+#define EXT_CSD_PART_CONFIG_EN_MASK(0x38)
 
 #define EXT_CSD_PART_SUPPORT_PART_EN(0x1)
 
-- 
1.7.0.4


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


[PATCH 0/3] Add boot_enable attribute to eMMC device for boot mode operation selection

2013-04-19 Thread Neil Armstrong
Since eMMC 4.3 a special boot mode operation was introduced to retrieve
data from the eMMC device with a very simple procedure. Since the Linux
kernel exports these device boot partitions, it may be useful to select
the boot partition from the user space.

The patch has been tested on a Toshiba eMMC conforming with eMMC 4.5
specifications.

Neil Armstrong (3):
  Add BOOT_PARTITION_ENABLE definition to MMC EXT_CSD PART_CONFIG
  Add boot_enable sysfs attribute to select MMC boot operation
partition
  Add Documentation for MMC boot_enable attribute

 Documentation/mmc/mmc-dev-parts.txt |6 +++
 drivers/mmc/card/block.c|   72
++-
 include/linux/mmc/mmc.h |1 +
 3 files changed, 78 insertions(+), 1 deletions(-)


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


Re: [PATCH -next] mmc: mxs-mmc: fix error return code in mxs_mmc_probe()

2013-04-19 Thread Marek Vasut
Dear Wei Yongjun,

> From: Wei Yongjun 
> 
> Fix to return -ENODEV in the request dma error case instead
> of 0, as done elsewhere in this function.
> 
> Signed-off-by: Wei Yongjun 

Seems ok to me.

Reviewed-by: Marek Vasut 

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


Re: [PATCH] mmc: core: Only execute tuning for SDR50 and SDR104

2013-04-19 Thread Ulf Hansson
On 17 April 2013 13:50, Fredrik Soderstedt
 wrote:
> Only execute tuning for sd and sdio devices that are using
> SDR50 or SDR104.
>
> Make sure clock is hold during tuning for sdio devices.
>
> Signed-off-by: Fredrik Soderstedt 
> ---
>  drivers/mmc/core/sd.c   |  9 +++--
>  drivers/mmc/core/sdio.c | 12 ++--
>  2 files changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index 9e645e1..8373d22 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -646,8 +646,13 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card)
> if (err)
> goto out;
>
> -   /* SPI mode doesn't define CMD19 */
> -   if (!mmc_host_is_spi(card->host) && card->host->ops->execute_tuning) {
> +   /*
> +* SPI mode doesn't define CMD19 and tuning is only valid for SDR50 
> and
> +* SDR104 mode SD-cards. Note that tuning is mandatory for SDR104.
> +*/
> +   if (!mmc_host_is_spi(card->host) && card->host->ops->execute_tuning &&
> +   (card->sd_bus_speed == UHS_SDR50_BUS_SPEED ||
> +card->sd_bus_speed == UHS_SDR104_BUS_SPEED)) {
> mmc_host_clk_hold(card->host);
> err = card->host->ops->execute_tuning(card->host,
>   MMC_SEND_TUNING_BLOCK);
> diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
> index 6889a82..444668c 100644
> --- a/drivers/mmc/core/sdio.c
> +++ b/drivers/mmc/core/sdio.c
> @@ -563,10 +563,18 @@ static int mmc_sdio_init_uhs_card(struct mmc_card *card)
> if (err)
> goto out;
>
> -   /* Initialize and start re-tuning timer */
> -   if (!mmc_host_is_spi(card->host) && card->host->ops->execute_tuning)
> +   /*
> +* SPI mode doesn't define CMD19 and tuning is only valid for SDR50 
> and
> +* SDR104 mode SD-cards. Note that tuning is mandatory for SDR104.
> +*/
> +   if (!mmc_host_is_spi(card->host) && card->host->ops->execute_tuning &&
> +   ((card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR50) ||
> +(card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR104))) {
> +   mmc_host_clk_hold(card->host);
> err = card->host->ops->execute_tuning(card->host,
>   MMC_SEND_TUNING_BLOCK);
> +   mmc_host_clk_release(card->host);
> +   }
>
>  out:
>
> --
> 1.8.2.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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


Re: [PATCH v4] mmc: dw_mmc: let device core setup the default pin configuration

2013-04-19 Thread Russell King - ARM Linux
On Wed, Apr 10, 2013 at 06:56:48AM -0700, Doug Anderson wrote:
> Thomas,
> 
> On Wed, Apr 10, 2013 at 5:48 AM, Thomas Abraham
>  wrote:
> > The call to regulator_enable() is prior to the call to mmc_add_host().
> > Hence, call to mmc_fre_host is not required in this case. So the above
> > change should be right.
> 
> Are you sure that mmc_free_host() is the opposite of mmc_add_host()
> and not mmc_alloc_host()?

mmc_free_host() undoes mmc_alloc_host().  mmc_remove_host() undoes
mmc_add_host().

alloc
add
remove
free

is pretty standard terminology, standard ordering.  If add fails, then
free is the right thing to call to clean up after the alloc.
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 4/6] ARM: at91: dts: add i2c dma support

2013-04-19 Thread Nicolas Ferre
On 04/19/2013 11:11 AM, ludovic.desroc...@atmel.com :
> From: Ludovic Desroches 
> 
> Add DMA resources to i2c nodes.
> 
> Signed-off-by: Ludovic Desroches 



I have made little corrections, but do not bother, it is already in my tree:

[nicolas.fe...@atmel.com: correct 9n12 dma phandle name]
Acked-by: Nicolas Ferre 

And stacked in at91-3.10-soc.

thanks,


> ---
>  arch/arm/boot/dts/at91sam9n12.dtsi | 6 ++
>  arch/arm/boot/dts/at91sam9x5.dtsi  | 9 +
>  arch/arm/boot/dts/sama5d3.dtsi | 9 +
>  3 files changed, 24 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi 
> b/arch/arm/boot/dts/at91sam9n12.dtsi
> index acc4526..f912124 100644
> --- a/arch/arm/boot/dts/at91sam9n12.dtsi
> +++ b/arch/arm/boot/dts/at91sam9n12.dtsi
> @@ -361,6 +361,9 @@
>   compatible = "atmel,at91sam9x5-i2c";
>   reg = <0xf801 0x100>;
>   interrupts = <9 4 6>;
> + dmas = <&dma0 1 13>,
> +<&dma0 1 14>;

single dma controller in 9n12:
s/dma0/dma/

> + dma-names = "tx", "rx";
>   #address-cells = <1>;
>   #size-cells = <0>;
>   status = "disabled";
> @@ -370,6 +373,9 @@
>   compatible = "atmel,at91sam9x5-i2c";
>   reg = <0xf8014000 0x100>;
>   interrupts = <10 4 6>;
> + dmas = <&dma0 1 15>,
> +<&dma0 1 16>;

Ditto

> + dma-names = "tx", "rx";
>   #address-cells = <1>;
>   #size-cells = <0>;
>   status = "disabled";
> diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi 
> b/arch/arm/boot/dts/at91sam9x5.dtsi
> index 8e83d87..16c9b81 100644
> --- a/arch/arm/boot/dts/at91sam9x5.dtsi
> +++ b/arch/arm/boot/dts/at91sam9x5.dtsi
> @@ -519,6 +519,9 @@
>   compatible = "atmel,at91sam9x5-i2c";
>   reg = <0xf801 0x100>;
>   interrupts = <9 4 6>;
> + dmas = <&dma0 1 7>,
> +<&dma0 1 8>;
> + dma-names = "tx", "rx";
>   #address-cells = <1>;
>   #size-cells = <0>;
>   pinctrl-names = "default";
> @@ -530,6 +533,9 @@
>   compatible = "atmel,at91sam9x5-i2c";
>   reg = <0xf8014000 0x100>;
>   interrupts = <10 4 6>;
> + dmas = <&dma1 1 5>,
> +<&dma1 1 6>;
> + dma-names = "tx", "rx";
>   #address-cells = <1>;
>   #size-cells = <0>;
>   pinctrl-names = "default";
> @@ -541,6 +547,9 @@
>   compatible = "atmel,at91sam9x5-i2c";
>   reg = <0xf8018000 0x100>;
>   interrupts = <11 4 6>;
> + dmas = <&dma0 1 9>,
> +<&dma0 1 10>;
> + dma-names = "tx", "rx";
>   #address-cells = <1>;
>   #size-cells = <0>;
>   pinctrl-names = "default";
> diff --git a/arch/arm/boot/dts/sama5d3.dtsi b/arch/arm/boot/dts/sama5d3.dtsi
> index 95c00a3..8e87277 100644
> --- a/arch/arm/boot/dts/sama5d3.dtsi
> +++ b/arch/arm/boot/dts/sama5d3.dtsi
> @@ -111,6 +111,9 @@
>   compatible = "atmel,at91sam9x5-i2c";
>   reg = <0xf0014000 0x4000>;
>   interrupts = <18 4 6>;
> + dmas = <&dma0 2 7>,
> +<&dma0 2 8>;
> + dma-names = "tx", "rx";
>   pinctrl-names = "default";
>   pinctrl-0 = <&pinctrl_i2c0>;
>   #address-cells = <1>;
> @@ -122,6 +125,9 @@
>   compatible = "atmel,at91sam9x5-i2c";
>   reg = <0xf0018000 0x4000>;
>   interrupts = <19 4 6>;
> + dmas = <&dma0 2 9>,
> +<&dma0 2 10>;
> + dma-names = "tx", "rx";
>   pinctrl-names = "default";
>   pinctrl-0 = <&pinctrl_i2c1>;
>   #address-cells = <1>;
> @@ -294,6 +300,9 @@
>   compatible = "atmel,

Re: [PATCH v3 6/6] ARM: at91: dts: add MCI DMA support

2013-04-19 Thread Nicolas Ferre
On 04/19/2013 11:11 AM, ludovic.desroc...@atmel.com :
> From: Ludovic Desroches 
> 
> Add DMA resources to MCI nodes.
> 
> Signed-off-by: Ludovic Desroches 

I have made little corrections, but do not bother, it is already in my tree:

[nicolas.fe...@atmel.com: correct 9g45, 9n12 dma phandle name]
Acked-by: Nicolas Ferre 

And stacked in at91-3.10-soc.

thanks,

> ---
>  arch/arm/boot/dts/at91sam9g45.dtsi | 4 
>  arch/arm/boot/dts/at91sam9n12.dtsi | 2 ++
>  arch/arm/boot/dts/at91sam9x5.dtsi  | 4 
>  arch/arm/boot/dts/sama5d3.dtsi | 6 ++
>  4 files changed, 16 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi 
> b/arch/arm/boot/dts/at91sam9g45.dtsi
> index 275e768..de2abc0 100644
> --- a/arch/arm/boot/dts/at91sam9g45.dtsi
> +++ b/arch/arm/boot/dts/at91sam9g45.dtsi
> @@ -513,6 +513,8 @@
>   compatible = "atmel,hsmci";
>   reg = <0xfff8 0x600>;
>   interrupts = <11 4 0>;
> + dmas = <&dma0 1 0>;

single dma controller in 9g45:
s/dma0/dma/


> + dma-names = "rxtx";
>   #address-cells = <1>;
>   #size-cells = <0>;
>   status = "disabled";
> @@ -522,6 +524,8 @@
>   compatible = "atmel,hsmci";
>   reg = <0xfffd 0x600>;
>   interrupts = <29 4 0>;
> + dmas = <&dma0 1 13>;

Ditto

> + dma-names = "rxtx";
>   #address-cells = <1>;
>   #size-cells = <0>;
>   status = "disabled";
> diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi 
> b/arch/arm/boot/dts/at91sam9n12.dtsi
> index f912124..0b61c41 100644
> --- a/arch/arm/boot/dts/at91sam9n12.dtsi
> +++ b/arch/arm/boot/dts/at91sam9n12.dtsi
> @@ -89,6 +89,8 @@
>   compatible = "atmel,hsmci";
>   reg = <0xf0008000 0x600>;
>   interrupts = <12 4 0>;
> + dmas = <&dma0 1 0>

single dma controller in 9n12:
s/dma0/dma/
+ do not forget the tailing ";"

> + dma-names = "rxtx";
>   #address-cells = <1>;
>   #size-cells = <0>;
>   status = "disabled";
> diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi 
> b/arch/arm/boot/dts/at91sam9x5.dtsi
> index 16c9b81..5f42e7a 100644
> --- a/arch/arm/boot/dts/at91sam9x5.dtsi
> +++ b/arch/arm/boot/dts/at91sam9x5.dtsi
> @@ -449,6 +449,8 @@
>   compatible = "atmel,hsmci";
>   reg = <0xf0008000 0x600>;
>   interrupts = <12 4 0>;
> + dmas = <&dma0 1 0>;
> + dma-names = "rxtx";
>   #address-cells = <1>;
>   #size-cells = <0>;
>   status = "disabled";
> @@ -458,6 +460,8 @@
>   compatible = "atmel,hsmci";
>   reg = <0xf000c000 0x600>;
>   interrupts = <26 4 0>;
> + dmas = <&dma1 1 0>;
> + dma-names = "rxtx";
>   #address-cells = <1>;
>   #size-cells = <0>;
>   status = "disabled";
> diff --git a/arch/arm/boot/dts/sama5d3.dtsi b/arch/arm/boot/dts/sama5d3.dtsi
> index 8e87277..2e643ea 100644
> --- a/arch/arm/boot/dts/sama5d3.dtsi
> +++ b/arch/arm/boot/dts/sama5d3.dtsi
> @@ -60,6 +60,8 @@
>   compatible = "atmel,hsmci";
>   reg = <0xf000 0x600>;
>   interrupts = <21 4 0>;
> + dmas = <&dma0 2 0>;
> + dma-names = "rxtx";
>   pinctrl-names = "default";
>   pinctrl-0 = <&pinctrl_mmc0_clk_cmd_dat0 
> &pinctrl_mmc0_dat1_3 &pinctrl_mmc0_dat4_7>;
>   status = "disabled";
> @@ -173,6 +175,8 @@
>   compatible = "atmel,hsmci";
>   reg = <0xf800 0x600>;
>   interrupts = <22 4 0>;
> + dmas = <&dma1 2 0>;
> + dma-names = "rxtx";
>   pinctrl-names = "default";
>   pinctrl-0 = <&pinctrl_mmc1_clk_cmd_dat0 
> &pinctrl_mmc1_dat1_3>;
>   status = "disabled";
> @@ -184,6 +188,8 @@
>   compatible = "atmel,hsmci";
>   reg = <0xf8004000 0x600>;

Re: [PATCH v3 2/6] ARM: at91: dts: set #dma-cells to the correct value

2013-04-19 Thread Nicolas Ferre
On 04/19/2013 11:11 AM, ludovic.desroc...@atmel.com :
> From: Ludovic Desroches 
> 
> Moving to generic DMA DT binding involves to set #dma-cells to 2.
> 
> Signed-off-by: Ludovic Desroches 

Acked-by: Nicolas Ferre 

And stacked in at91-3.10-soc.

thanks,

> ---
>  arch/arm/boot/dts/at91sam9g45.dtsi | 1 +
>  arch/arm/boot/dts/at91sam9n12.dtsi | 1 +
>  arch/arm/boot/dts/at91sam9x5.dtsi  | 2 ++
>  arch/arm/boot/dts/sama5d3.dtsi | 4 ++--
>  4 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi 
> b/arch/arm/boot/dts/at91sam9g45.dtsi
> index 6b1d4ca..275e768 100644
> --- a/arch/arm/boot/dts/at91sam9g45.dtsi
> +++ b/arch/arm/boot/dts/at91sam9g45.dtsi
> @@ -108,6 +108,7 @@
>   compatible = "atmel,at91sam9g45-dma";
>   reg = <0xec00 0x200>;
>   interrupts = <21 4 0>;
> + #dma-cells = <2>;
>   };
>  
>   pinctrl@f200 {
> diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi 
> b/arch/arm/boot/dts/at91sam9n12.dtsi
> index 7750f98..acc4526 100644
> --- a/arch/arm/boot/dts/at91sam9n12.dtsi
> +++ b/arch/arm/boot/dts/at91sam9n12.dtsi
> @@ -110,6 +110,7 @@
>   compatible = "atmel,at91sam9g45-dma";
>   reg = <0xec00 0x200>;
>   interrupts = <20 4 0>;
> + #dma-cells = <2>;
>   };
>  
>   pinctrl@f400 {
> diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi 
> b/arch/arm/boot/dts/at91sam9x5.dtsi
> index 3870322..8e83d87 100644
> --- a/arch/arm/boot/dts/at91sam9x5.dtsi
> +++ b/arch/arm/boot/dts/at91sam9x5.dtsi
> @@ -104,12 +104,14 @@
>   compatible = "atmel,at91sam9g45-dma";
>   reg = <0xec00 0x200>;
>   interrupts = <20 4 0>;
> + #dma-cells = <2>;
>   };
>  
>   dma1: dma-controller@ee00 {
>   compatible = "atmel,at91sam9g45-dma";
>   reg = <0xee00 0x200>;
>   interrupts = <21 4 0>;
> + #dma-cells = <2>;
>   };
>  
>   pinctrl@f400 {
> diff --git a/arch/arm/boot/dts/sama5d3.dtsi b/arch/arm/boot/dts/sama5d3.dtsi
> index 39b0458..95c00a3 100644
> --- a/arch/arm/boot/dts/sama5d3.dtsi
> +++ b/arch/arm/boot/dts/sama5d3.dtsi
> @@ -348,14 +348,14 @@
>   compatible = "atmel,at91sam9g45-dma";
>   reg = <0xe600 0x200>;
>   interrupts = <30 4 0>;
> - #dma-cells = <1>;
> + #dma-cells = <2>;
>   };
>  
>   dma1: dma-controller@e800 {
>   compatible = "atmel,at91sam9g45-dma";
>   reg = <0xe800 0x200>;
>   interrupts = <31 4 0>;
> - #dma-cells = <1>;
> + #dma-cells = <2>;
>   };
>  
>   ramc0: ramc@ea00 {
> 


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


[PATCH v3 6/6] ARM: at91: dts: add MCI DMA support

2013-04-19 Thread ludovic.desroches
From: Ludovic Desroches 

Add DMA resources to MCI nodes.

Signed-off-by: Ludovic Desroches 
---
 arch/arm/boot/dts/at91sam9g45.dtsi | 4 
 arch/arm/boot/dts/at91sam9n12.dtsi | 2 ++
 arch/arm/boot/dts/at91sam9x5.dtsi  | 4 
 arch/arm/boot/dts/sama5d3.dtsi | 6 ++
 4 files changed, 16 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi 
b/arch/arm/boot/dts/at91sam9g45.dtsi
index 275e768..de2abc0 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -513,6 +513,8 @@
compatible = "atmel,hsmci";
reg = <0xfff8 0x600>;
interrupts = <11 4 0>;
+   dmas = <&dma0 1 0>;
+   dma-names = "rxtx";
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
@@ -522,6 +524,8 @@
compatible = "atmel,hsmci";
reg = <0xfffd 0x600>;
interrupts = <29 4 0>;
+   dmas = <&dma0 1 13>;
+   dma-names = "rxtx";
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi 
b/arch/arm/boot/dts/at91sam9n12.dtsi
index f912124..0b61c41 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -89,6 +89,8 @@
compatible = "atmel,hsmci";
reg = <0xf0008000 0x600>;
interrupts = <12 4 0>;
+   dmas = <&dma0 1 0>
+   dma-names = "rxtx";
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi 
b/arch/arm/boot/dts/at91sam9x5.dtsi
index 16c9b81..5f42e7a 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -449,6 +449,8 @@
compatible = "atmel,hsmci";
reg = <0xf0008000 0x600>;
interrupts = <12 4 0>;
+   dmas = <&dma0 1 0>;
+   dma-names = "rxtx";
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
@@ -458,6 +460,8 @@
compatible = "atmel,hsmci";
reg = <0xf000c000 0x600>;
interrupts = <26 4 0>;
+   dmas = <&dma1 1 0>;
+   dma-names = "rxtx";
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
diff --git a/arch/arm/boot/dts/sama5d3.dtsi b/arch/arm/boot/dts/sama5d3.dtsi
index 8e87277..2e643ea 100644
--- a/arch/arm/boot/dts/sama5d3.dtsi
+++ b/arch/arm/boot/dts/sama5d3.dtsi
@@ -60,6 +60,8 @@
compatible = "atmel,hsmci";
reg = <0xf000 0x600>;
interrupts = <21 4 0>;
+   dmas = <&dma0 2 0>;
+   dma-names = "rxtx";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_mmc0_clk_cmd_dat0 
&pinctrl_mmc0_dat1_3 &pinctrl_mmc0_dat4_7>;
status = "disabled";
@@ -173,6 +175,8 @@
compatible = "atmel,hsmci";
reg = <0xf800 0x600>;
interrupts = <22 4 0>;
+   dmas = <&dma1 2 0>;
+   dma-names = "rxtx";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_mmc1_clk_cmd_dat0 
&pinctrl_mmc1_dat1_3>;
status = "disabled";
@@ -184,6 +188,8 @@
compatible = "atmel,hsmci";
reg = <0xf8004000 0x600>;
interrupts = <23 4 0>;
+   dmas = <&dma1 2 1>;
+   dma-names = "rxtx";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_mmc2_clk_cmd_dat0 
&pinctrl_mmc2_dat1_3>;
status = "disabled";
-- 
1.7.11.3

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a messa

[PATCH v3 5/6] mci: at91: convert to dma_request_slave_channel_compat()

2013-04-19 Thread ludovic.desroches
From: Ludovic Desroches 

Use generic DMA DT helper. Platforms booting with or without DT populated are
both supported.

Signed-off-by: Ludovic Desroches 
Acked-by: Jean-Christophe PLAGNIOL-VILLARD 
Acked-by: Nicolas Ferre 
---
 drivers/mmc/host/atmel-mci.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 10f8b73..ffbd0d3 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -2224,10 +2224,15 @@ static void __exit atmci_cleanup_slot(struct 
atmel_mci_slot *slot,
mmc_free_host(slot->mmc);
 }
 
-static bool atmci_filter(struct dma_chan *chan, void *slave)
+static bool atmci_filter(struct dma_chan *chan, void *pdata)
 {
-   struct mci_dma_data *sl = slave;
+   struct mci_platform_data *sl_pdata = pdata;
+   struct mci_dma_data *sl;
 
+   if (!sl_pdata)
+   return false;
+
+   sl = sl_pdata->dma_slave;
if (sl && find_slave_dev(sl) == chan->device->dev) {
chan->private = slave_data_ptr(sl);
return true;
@@ -2239,24 +2244,18 @@ static bool atmci_filter(struct dma_chan *chan, void 
*slave)
 static bool atmci_configure_dma(struct atmel_mci *host)
 {
struct mci_platform_data*pdata;
+   dma_cap_mask_t mask;
 
if (host == NULL)
return false;
 
pdata = host->pdev->dev.platform_data;
 
-   if (!pdata)
-   return false;
+   dma_cap_zero(mask);
+   dma_cap_set(DMA_SLAVE, mask);
 
-   if (pdata->dma_slave && find_slave_dev(pdata->dma_slave)) {
-   dma_cap_mask_t mask;
-
-   /* Try to grab a DMA channel */
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   host->dma.chan =
-   dma_request_channel(mask, atmci_filter, 
pdata->dma_slave);
-   }
+   host->dma.chan = dma_request_slave_channel_compat(mask, atmci_filter, 
pdata,
+ &host->pdev->dev, 
"rxtx");
if (!host->dma.chan) {
dev_warn(&host->pdev->dev, "no DMA channel available\n");
return false;
-- 
1.7.11.3

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


[PATCH v3 4/6] ARM: at91: dts: add i2c dma support

2013-04-19 Thread ludovic.desroches
From: Ludovic Desroches 

Add DMA resources to i2c nodes.

Signed-off-by: Ludovic Desroches 
---
 arch/arm/boot/dts/at91sam9n12.dtsi | 6 ++
 arch/arm/boot/dts/at91sam9x5.dtsi  | 9 +
 arch/arm/boot/dts/sama5d3.dtsi | 9 +
 3 files changed, 24 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi 
b/arch/arm/boot/dts/at91sam9n12.dtsi
index acc4526..f912124 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -361,6 +361,9 @@
compatible = "atmel,at91sam9x5-i2c";
reg = <0xf801 0x100>;
interrupts = <9 4 6>;
+   dmas = <&dma0 1 13>,
+  <&dma0 1 14>;
+   dma-names = "tx", "rx";
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
@@ -370,6 +373,9 @@
compatible = "atmel,at91sam9x5-i2c";
reg = <0xf8014000 0x100>;
interrupts = <10 4 6>;
+   dmas = <&dma0 1 15>,
+  <&dma0 1 16>;
+   dma-names = "tx", "rx";
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi 
b/arch/arm/boot/dts/at91sam9x5.dtsi
index 8e83d87..16c9b81 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -519,6 +519,9 @@
compatible = "atmel,at91sam9x5-i2c";
reg = <0xf801 0x100>;
interrupts = <9 4 6>;
+   dmas = <&dma0 1 7>,
+  <&dma0 1 8>;
+   dma-names = "tx", "rx";
#address-cells = <1>;
#size-cells = <0>;
pinctrl-names = "default";
@@ -530,6 +533,9 @@
compatible = "atmel,at91sam9x5-i2c";
reg = <0xf8014000 0x100>;
interrupts = <10 4 6>;
+   dmas = <&dma1 1 5>,
+  <&dma1 1 6>;
+   dma-names = "tx", "rx";
#address-cells = <1>;
#size-cells = <0>;
pinctrl-names = "default";
@@ -541,6 +547,9 @@
compatible = "atmel,at91sam9x5-i2c";
reg = <0xf8018000 0x100>;
interrupts = <11 4 6>;
+   dmas = <&dma0 1 9>,
+  <&dma0 1 10>;
+   dma-names = "tx", "rx";
#address-cells = <1>;
#size-cells = <0>;
pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/sama5d3.dtsi b/arch/arm/boot/dts/sama5d3.dtsi
index 95c00a3..8e87277 100644
--- a/arch/arm/boot/dts/sama5d3.dtsi
+++ b/arch/arm/boot/dts/sama5d3.dtsi
@@ -111,6 +111,9 @@
compatible = "atmel,at91sam9x5-i2c";
reg = <0xf0014000 0x4000>;
interrupts = <18 4 6>;
+   dmas = <&dma0 2 7>,
+  <&dma0 2 8>;
+   dma-names = "tx", "rx";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c0>;
#address-cells = <1>;
@@ -122,6 +125,9 @@
compatible = "atmel,at91sam9x5-i2c";
reg = <0xf0018000 0x4000>;
interrupts = <19 4 6>;
+   dmas = <&dma0 2 9>,
+  <&dma0 2 10>;
+   dma-names = "tx", "rx";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c1>;
#address-cells = <1>;
@@ -294,6 +300,9 @@
compatible = "atmel,at91sam9x5-i2c";
reg = <0xf801c000 0x4000>;
interrupts = <20 4 6>;
+   dmas = <&dma1 2 11>,
+  <&dma1 2 12>;
+   dma-names = "tx", "rx";
#address-cells = <1>;
   

[PATCH v3 3/6] i2c: at91: convert to dma_request_slave_channel_compat()

2013-04-19 Thread ludovic.desroches
From: Ludovic Desroches 

Use generic DMA DT helper. Platforms booting with or without DT populated are
both supported.

Signed-off-by: Ludovic Desroches 
Acked-by: Nicolas Ferre 
Acked-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 drivers/i2c/busses/i2c-at91.c | 49 ++-
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 75195e3..7ffd544 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -607,11 +607,16 @@ MODULE_DEVICE_TABLE(of, atmel_twi_dt_ids);
 #define atmel_twi_dt_ids NULL
 #endif
 
-static bool filter(struct dma_chan *chan, void *slave)
+static bool filter(struct dma_chan *chan, void *pdata)
 {
-   struct at_dma_slave *sl = slave;
+   struct at91_twi_pdata *sl_pdata = pdata;
+   struct at_dma_slave *sl;
 
-   if (sl->dma_dev == chan->device->dev) {
+   if (!sl_pdata)
+   return false;
+
+   sl = &sl_pdata->dma_slave;
+   if (sl && (sl->dma_dev == chan->device->dev)) {
chan->private = sl;
return true;
} else {
@@ -622,11 +627,10 @@ static bool filter(struct dma_chan *chan, void *slave)
 static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr)
 {
int ret = 0;
-   struct at_dma_slave *sdata;
+   struct at91_twi_pdata *pdata = dev->pdata;
struct dma_slave_config slave_config;
struct at91_twi_dma *dma = &dev->dma;
-
-   sdata = &dev->pdata->dma_slave;
+   dma_cap_mask_t mask;
 
memset(&slave_config, 0, sizeof(slave_config));
slave_config.src_addr = (dma_addr_t)phy_addr + AT91_TWI_RHR;
@@ -637,25 +641,22 @@ static int at91_twi_configure_dma(struct at91_twi_dev 
*dev, u32 phy_addr)
slave_config.dst_maxburst = 1;
slave_config.device_fc = false;
 
-   if (sdata && sdata->dma_dev) {
-   dma_cap_mask_t mask;
+   dma_cap_zero(mask);
+   dma_cap_set(DMA_SLAVE, mask);
 
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   dma->chan_tx = dma_request_channel(mask, filter, sdata);
-   if (!dma->chan_tx) {
-   dev_err(dev->dev, "no DMA channel available for tx\n");
-   ret = -EBUSY;
-   goto error;
-   }
-   dma->chan_rx = dma_request_channel(mask, filter, sdata);
-   if (!dma->chan_rx) {
-   dev_err(dev->dev, "no DMA channel available for rx\n");
-   ret = -EBUSY;
-   goto error;
-   }
-   } else {
-   ret = -EINVAL;
+   dma->chan_tx = dma_request_slave_channel_compat(mask, filter, pdata,
+   dev->dev, "tx");
+   if (!dma->chan_tx) {
+   dev_err(dev->dev, "can't get a DMA channel for tx\n");
+   ret = -EBUSY;
+   goto error;
+   }
+
+   dma->chan_rx = dma_request_slave_channel_compat(mask, filter, pdata,
+   dev->dev, "rx");
+   if (!dma->chan_rx) {
+   dev_err(dev->dev, "can't get a DMA channel for rx\n");
+   ret = -EBUSY;
goto error;
}
 
-- 
1.7.11.3

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


[PATCH v3 2/6] ARM: at91: dts: set #dma-cells to the correct value

2013-04-19 Thread ludovic.desroches
From: Ludovic Desroches 

Moving to generic DMA DT binding involves to set #dma-cells to 2.

Signed-off-by: Ludovic Desroches 
---
 arch/arm/boot/dts/at91sam9g45.dtsi | 1 +
 arch/arm/boot/dts/at91sam9n12.dtsi | 1 +
 arch/arm/boot/dts/at91sam9x5.dtsi  | 2 ++
 arch/arm/boot/dts/sama5d3.dtsi | 4 ++--
 4 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi 
b/arch/arm/boot/dts/at91sam9g45.dtsi
index 6b1d4ca..275e768 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -108,6 +108,7 @@
compatible = "atmel,at91sam9g45-dma";
reg = <0xec00 0x200>;
interrupts = <21 4 0>;
+   #dma-cells = <2>;
};
 
pinctrl@f200 {
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi 
b/arch/arm/boot/dts/at91sam9n12.dtsi
index 7750f98..acc4526 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -110,6 +110,7 @@
compatible = "atmel,at91sam9g45-dma";
reg = <0xec00 0x200>;
interrupts = <20 4 0>;
+   #dma-cells = <2>;
};
 
pinctrl@f400 {
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi 
b/arch/arm/boot/dts/at91sam9x5.dtsi
index 3870322..8e83d87 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -104,12 +104,14 @@
compatible = "atmel,at91sam9g45-dma";
reg = <0xec00 0x200>;
interrupts = <20 4 0>;
+   #dma-cells = <2>;
};
 
dma1: dma-controller@ee00 {
compatible = "atmel,at91sam9g45-dma";
reg = <0xee00 0x200>;
interrupts = <21 4 0>;
+   #dma-cells = <2>;
};
 
pinctrl@f400 {
diff --git a/arch/arm/boot/dts/sama5d3.dtsi b/arch/arm/boot/dts/sama5d3.dtsi
index 39b0458..95c00a3 100644
--- a/arch/arm/boot/dts/sama5d3.dtsi
+++ b/arch/arm/boot/dts/sama5d3.dtsi
@@ -348,14 +348,14 @@
compatible = "atmel,at91sam9g45-dma";
reg = <0xe600 0x200>;
interrupts = <30 4 0>;
-   #dma-cells = <1>;
+   #dma-cells = <2>;
};
 
dma1: dma-controller@e800 {
compatible = "atmel,at91sam9g45-dma";
reg = <0xe800 0x200>;
interrupts = <31 4 0>;
-   #dma-cells = <1>;
+   #dma-cells = <2>;
};
 
ramc0: ramc@ea00 {
-- 
1.7.11.3

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


[PATCH v3 1/6] at_hdmac: move to generic DMA binding

2013-04-19 Thread ludovic.desroches
From: Ludovic Desroches 

Update at_hdmac driver to support generic DMA device tree binding. Devices
can still request channel with dma_request_channel() then it doesn't break
DMA for non DT boards.

Signed-off-by: Ludovic Desroches 
Acked-by: Nicolas Ferre 
Acked-by: Jean-Christophe PLAGNIOL-VILLARD 
Acked-by: Arnd Bergmann 
---
 .../devicetree/bindings/dma/atmel-dma.txt  | 35 ++--
 drivers/dma/at_hdmac.c | 93 --
 drivers/dma/at_hdmac_regs.h|  4 +
 3 files changed, 121 insertions(+), 11 deletions(-)

diff --git a/Documentation/devicetree/bindings/dma/atmel-dma.txt 
b/Documentation/devicetree/bindings/dma/atmel-dma.txt
index 3c046ee..c80e8a3 100644
--- a/Documentation/devicetree/bindings/dma/atmel-dma.txt
+++ b/Documentation/devicetree/bindings/dma/atmel-dma.txt
@@ -1,14 +1,39 @@
 * Atmel Direct Memory Access Controller (DMA)
 
 Required properties:
-- compatible: Should be "atmel,-dma"
-- reg: Should contain DMA registers location and length
-- interrupts: Should contain DMA interrupt
+- compatible: Should be "atmel,-dma".
+- reg: Should contain DMA registers location and length.
+- interrupts: Should contain DMA interrupt.
+- #dma-cells: Must be <2>, used to represent the number of integer cells in
+the dmas property of client devices.
 
-Examples:
+Example:
 
-dma@ec00 {
+dma0: dma@ec00 {
compatible = "atmel,at91sam9g45-dma";
reg = <0xec00 0x200>;
interrupts = <21>;
+   #dma-cells = <2>;
+};
+
+DMA clients connected to the Atmel DMA controller must use the format
+described in the dma.txt file, using a three-cell specifier for each channel:
+a phandle plus two interger cells.
+The three cells in order are:
+
+1. A phandle pointing to the DMA controller.
+2. The memory interface (16 most significant bits), the peripheral interface
+(16 less significant bits).
+3. The peripheral identifier for the hardware handshaking interface. The
+identifier can be different for tx and rx.
+
+Example:
+
+i2c0@i2c@f801 {
+   compatible = "atmel,at91sam9x5-i2c";
+   reg = <0xf801 0x100>;
+   interrupts = <9 4 6>;
+   dmas = <&dma0 1 7>,
+  <&dma0 1 8>;
+   dma-names = "tx", "rx";
 };
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index de4e930..fda2661 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "at_hdmac_regs.h"
 #include "dmaengine.h"
@@ -677,7 +678,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist 
*sgl,
ctrlb |=  ATC_DST_ADDR_MODE_FIXED
| ATC_SRC_ADDR_MODE_INCR
| ATC_FC_MEM2PER
-   | ATC_SIF(AT_DMA_MEM_IF) | ATC_DIF(AT_DMA_PER_IF);
+   | ATC_SIF(atchan->mem_if) | ATC_DIF(atchan->per_if);
reg = sconfig->dst_addr;
for_each_sg(sgl, sg, sg_len, i) {
struct at_desc  *desc;
@@ -716,7 +717,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist 
*sgl,
ctrlb |=  ATC_DST_ADDR_MODE_INCR
| ATC_SRC_ADDR_MODE_FIXED
| ATC_FC_PER2MEM
-   | ATC_SIF(AT_DMA_PER_IF) | ATC_DIF(AT_DMA_MEM_IF);
+   | ATC_SIF(atchan->per_if) | ATC_DIF(atchan->mem_if);
 
reg = sconfig->src_addr;
for_each_sg(sgl, sg, sg_len, i) {
@@ -822,8 +823,8 @@ atc_dma_cyclic_fill_desc(struct dma_chan *chan, struct 
at_desc *desc,
desc->lli.ctrlb = ATC_DST_ADDR_MODE_FIXED
| ATC_SRC_ADDR_MODE_INCR
| ATC_FC_MEM2PER
-   | ATC_SIF(AT_DMA_MEM_IF)
-   | ATC_DIF(AT_DMA_PER_IF);
+   | ATC_SIF(atchan->mem_if)
+   | ATC_DIF(atchan->per_if);
break;
 
case DMA_DEV_TO_MEM:
@@ -833,8 +834,8 @@ atc_dma_cyclic_fill_desc(struct dma_chan *chan, struct 
at_desc *desc,
desc->lli.ctrlb = ATC_DST_ADDR_MODE_INCR
| ATC_SRC_ADDR_MODE_FIXED
| ATC_FC_PER2MEM
-   | ATC_SIF(AT_DMA_PER_IF)
-   | ATC_DIF(AT_DMA_MEM_IF);
+   | ATC_SIF(atchan->per_if)
+   | ATC_DIF(atchan->mem_if);
break;
 
default:
@@ -1190,6 +1191,67 @@ static void atc_free_chan_resources(struct dma_chan 
*chan)
dev_vdbg(chan2dev(chan), "free_chan_resources: done\n");
 }
 
+#ifdef CONFIG_OF
+static bool at_dma_filter(struct dma_chan *chan, void *slave)
+{
+   struct at_dma_slave *atslave = slave;
+
+   if (atslave->dma_dev == chan->device->dev) {
+   chan->private = atslave;
+   return tru

[PATCH v3 0/6] ARM: at91: move to generic DMA device tree binding

2013-04-19 Thread ludovic.desroches
From: Ludovic Desroches 

Hi,

I resend the set of patches due to minor fixes. I think patches will go through
different subsytems.

Patch 1/6: dma subsystem
Patch 2/6, 4/6, 6/6: arm-soc
Patch 3/6: i2c subsystem, already taken by Wolfram, thx.
Patch 5/6: mmc subsystem

v3 changes:
- compile at_dma_filter function only if CONFIG_OF is set since it is only used
in at_dma_xlate
- remove trailing whitespaces in patch 5/6

v2 changes:
- update documentation about dma bindings according to Nicolas' comments
- put dtsi changes in a separate patch
- add dtb update for i2c and mci nodes

Ludovic Desroches (6):
  at_hdmac: move to generic DMA binding
  ARM: at91: dts: set #dma-cells to the correct value
  i2c: at91: convert to dma_request_slave_channel_compat()
  ARM: at91: dts: add i2c dma support
  mci: at91: convert to dma_request_slave_channel_compat()
  ARM: at91: dts: add MCI DMA support

 .../devicetree/bindings/dma/atmel-dma.txt  | 35 ++--
 arch/arm/boot/dts/at91sam9g45.dtsi |  5 ++
 arch/arm/boot/dts/at91sam9n12.dtsi |  9 +++
 arch/arm/boot/dts/at91sam9x5.dtsi  | 15 
 arch/arm/boot/dts/sama5d3.dtsi | 19 -
 drivers/dma/at_hdmac.c | 93 --
 drivers/dma/at_hdmac_regs.h|  4 +
 drivers/i2c/busses/i2c-at91.c  | 49 ++--
 drivers/mmc/host/atmel-mci.c   | 25 +++---
 9 files changed, 204 insertions(+), 50 deletions(-)

-- 
1.7.11.3

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


RE: [PATCH v3] mmc: card: Adding support for sanitize in eMMC 4.5

2013-04-19 Thread Luca Porzio (lporzio)
Looks good to me. 
Thanks Maya.

> -Original Message-
> From: linux-mmc-ow...@vger.kernel.org [mailto:linux-mmc-
> ow...@vger.kernel.org] On Behalf Of Maya Erez
> Sent: Thursday, April 18, 2013 2:42 PM
> To: linux-mmc@vger.kernel.org
> Cc: linux-arm-...@vger.kernel.org; Maya Erez; Yaniv Gardi; open list
> Subject: [PATCH v3] mmc: card: Adding support for sanitize in eMMC 4.5
> 
> The sanitize support is added as a user-app ioctl call, and
> was removed from the block-device request, since its purpose is
> to be invoked not via File-System but by a user.
> This feature deletes the unmap memory region of the eMMC card,
> by writing to a specific register in the EXT_CSD.
> unmap region is the memory region that was previously deleted
> (by erase, trim or discard operation).
> In order to avoid timeout when sanitizing large-scale cards,
> the timeout for sanitize operation is 240 seconds.
> 
> Signed-off-by: Yaniv Gardi 
> Signed-off-by: Maya Erez 
> ---
>  drivers/mmc/card/block.c   |   68 ++--
> ---
>  drivers/mmc/card/queue.c   |2 +-
>  drivers/mmc/core/core.c|   22 ++
>  drivers/mmc/core/mmc_ops.c |2 +
>  include/linux/mmc/core.h   |2 +
>  include/linux/mmc/host.h   |1 +
>  6 files changed, 75 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index e12a03c..1f043ee 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -58,6 +58,8 @@ MODULE_ALIAS("mmc:block");
>  #define INAND_CMD38_ARG_SECTRIM1 0x81
>  #define INAND_CMD38_ARG_SECTRIM2 0x88
>  #define MMC_BLK_TIMEOUT_MS  (10 * 60 * 1000)/* 10 minute timeout
> */
> +#define MMC_SANITIZE_REQ_TIMEOUT 24
> +#define MMC_EXTRACT_INDEX_FROM_ARG(x) ((x & 0x00FF) >> 16)
> 
>  #define mmc_req_rel_wr(req)  (((req->cmd_flags & REQ_FUA) || \
> (req->cmd_flags & REQ_META)) && \
> @@ -409,6 +411,35 @@ static int ioctl_rpmb_card_status_poll(struct mmc_card
> *card, u32 *status,
>   return err;
>  }
> 
> +static int ioctl_do_sanitize(struct mmc_card *card)
> +{
> + int err;
> +
> + if (!(mmc_can_sanitize(card) &&
> +   (card->host->caps2 & MMC_CAP2_SANITIZE))) {
> + pr_warn("%s: %s - SANITIZE is not supported\n",
> + mmc_hostname(card->host), __func__);
> + err = -EOPNOTSUPP;
> + goto out;
> + }
> +
> + pr_debug("%s: %s - SANITIZE IN PROGRESS...\n",
> + mmc_hostname(card->host), __func__);
> +
> + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
> + EXT_CSD_SANITIZE_START, 1,
> + MMC_SANITIZE_REQ_TIMEOUT);
> +
> + if (err)
> + pr_err("%s: %s - EXT_CSD_SANITIZE_START failed. err=%d\n",
> +mmc_hostname(card->host), __func__, err);
> +
> + pr_debug("%s: %s - SANITIZE COMPLETED\n", mmc_hostname(card->host),
> +  __func__);
> +out:
> + return err;
> +}
> +
>  static int mmc_blk_ioctl_cmd(struct block_device *bdev,
>   struct mmc_ioc_cmd __user *ic_ptr)
>  {
> @@ -511,6 +542,16 @@ static int mmc_blk_ioctl_cmd(struct block_device
> *bdev,
>   goto cmd_rel_host;
>   }
> 
> + if (MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_SANITIZE_START) {
> + err = ioctl_do_sanitize(card);
> +
> + if (err)
> + pr_err("%s: ioctl_do_sanitize() failed. err = %d",
> +__func__, err);
> +
> + goto cmd_rel_host;
> + }
> +
>   mmc_wait_for_req(card->host, &mrq);
> 
>   if (cmd.error) {
> @@ -940,10 +981,10 @@ static int mmc_blk_issue_secdiscard_rq(struct
> mmc_queue *mq,
>  {
>   struct mmc_blk_data *md = mq->data;
>   struct mmc_card *card = md->queue.card;
> - unsigned int from, nr, arg, trim_arg, erase_arg;
> + unsigned int from, nr, arg;
>   int err = 0, type = MMC_BLK_SECDISCARD;
> 
> - if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) {
> + if (!(mmc_can_secure_erase_trim(card))) {
>   err = -EOPNOTSUPP;
>   goto out;
>   }
> @@ -951,23 +992,11 @@ static int mmc_blk_issue_secdiscard_rq(struct
> mmc_queue *mq,
>   from = blk_rq_pos(req);
>   nr = blk_rq_sectors(req);
> 
> - /* The sanitize operation is supported at v4.5 only */
> - if (mmc_can_sanitize(card)) {
> - erase_arg = MMC_ERASE_ARG;
> - trim_arg = MMC_TRIM_ARG;
> - } else {
> - erase_arg = MMC_SECURE_ERASE_ARG;
> - trim_arg = MMC_SECURE_TRIM1_ARG;
> - }
> + if (mmc_can_trim(card) && !mmc_erase_group_aligned(card, from, nr))
> + arg = MMC_SECURE_TRIM1_ARG;
> + else
> + arg = MMC_SECURE_ERASE_ARG;
> 
> - if (mmc_erase_group_aligned(card, from, nr))
> -