mmc:sdio:guarantee setting card data bus width as 4-bit
PATCH v2 1/1 mmc:sdio:guarantee setting card data bus width as 4-bit
SDIO_CCCR_IF[1:0] in SDIO card is used for card data bus width
setting as below,
00b: 1-bit bus
01b: Reserved
10b: 4-bit bus
11b: 8-bit bus(only for embedded SDIO) And sdio_enable_wide is for setting data bus width as 4-bit. But
currently, it 1stly read the register, 2ndly OR' 1b with SDIO_CCCR_IF[1], and then write it back.
As we can see, such way is based on such assumption that the
SDIO_CCCR_IF[0] is always 0. Apparently, this is not right.
--- drivers/mmc/core/sdio.c | 7 +++++++ include/linux/mmc/sdio.h | 2 ++ 2 files changed, 9 insertions(+)
drivers/mmc/core/sdio.c +7 -0
@@ -218,6 +218,13 @@ static int sdio_enable_wide(struct mmc_card *card)if (ret)return ret; +if ((ctrl &SDIO_BUS_WIDTH_MASK ) + ==SDIO_BUS_WIDTH_RESERVED ) +printk (KERN_WARNING "%s: SDIO_CCCR_IF is invalid: 0x%02X\n" , +mmc_hostname (card->host), ctrl); + +/* set as 4-bit bus width */ + ctrl &= ~SDIO_BUS_WIDTH_MASK ; ctrl |=SDIO_BUS_WIDTH_4BIT ; ret =mmc_io_rw_direct (card,1 ,0 ,SDIO_CCCR_IF , ctrl,NULL );
include/linux/mmc/sdio.h +2 -0
@@ -98,7 +98,9 @@#define SDIO_CCCR_IF 0x07/* bus interface controls */ +#define SDIO_BUS_WIDTH_MASK 0x03/* data bus width setting */ #define SDIO_BUS_WIDTH_1BIT 0x00 +#define SDIO_BUS_WIDTH_RESERVED 0x01#define SDIO_BUS_WIDTH_4BIT 0x02#define SDIO_BUS_ECSI 0x20/* Enable continuous SPI interrupt */ #define SDIO_BUS_SCSI 0x40/* Support continuous SPI interrupt */
Signature · 1 line
1.7.9.5
ACK
Quoted 53 lines · yongd
SDIO_CCCR_IF[1:0] in SDIO card is used for card data bus width
setting as below,00b: 1-bit bus 01b: Reserved 10b: 4-bit bus 11b: 8-bit bus(only for embedded SDIO)And
sdio_enable_wideis for setting data bus width as 4-bit. But
currently, it 1stly read the register, 2ndly OR' 1b with SDIO_CCCR_IF[1], and then write it back.
As we can see, such way is based on such assumption that the
SDIO_CCCR_IF[0] is always 0. Apparently, this is not right.Signed-off-by yongd <[email protected]>---
drivers/mmc/core/sdio.c | 7 +++++++ include/linux/mmc/sdio.h | 2 ++ 2 files changed, 9 insertions(+)drivers/mmc/core/sdio.c +7
-0@@ -218,6 +218,13 @@ static int sdio_enable_wide(struct mmc_card *card)if (ret)return ret; +if ((ctrl &SDIO_BUS_WIDTH_MASK ) + ==SDIO_BUS_WIDTH_RESERVED ) +printk (KERN_WARNING "%s: SDIO_CCCR_IF is invalid: 0x%02X\n" , +mmc_hostname (card->host), ctrl); + +/* set as 4-bit bus width */ + ctrl &= ~SDIO_BUS_WIDTH_MASK ; ctrl |=SDIO_BUS_WIDTH_4BIT ; ret =mmc_io_rw_direct (card,1 ,0 ,SDIO_CCCR_IF , ctrl,NULL );include/linux/mmc/sdio.h +2
-0@@ -98,7 +98,9 @@#define SDIO_CCCR_IF 0x07/* bus interface controls */ +#define SDIO_BUS_WIDTH_MASK 0x03/* data bus width setting */ #define SDIO_BUS_WIDTH_1BIT 0x00 +#define SDIO_BUS_WIDTH_RESERVED 0x01#define SDIO_BUS_WIDTH_4BIT 0x02#define SDIO_BUS_ECSI 0x20/* Enable continuous SPI interrupt */ #define SDIO_BUS_SCSI 0x40/* Support continuous SPI interrupt */ Signature · 1 line
1.7.9.5
Hi,
Quoted 6 lines · yongd
SDIO_CCCR_IF[1:0] in SDIO card is used for card data bus width
setting as below,00b: 1-bit bus 01b: Reserved 10b: 4-bit bus 11b: 8-bit bus(only for embedded SDIO)
Quoted 7 lines
And
sdio_enable_wideis for setting data bus width as 4-bit. But
currently, it 1stly read the register, 2ndly OR' 1b with SDIO_CCCR_IF[1], and then write it back.
As we can see, such way is based on such assumption that the
SDIO_CCCR_IF[0] is always 0. Apparently, this is not right.Signed-off-by yongd <[email protected]>
Thanks. Can we have your full name, for the copyright record?
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Chris,
Thanks. And my full name is Yong Ding.
Best Wishes,
Yong Ding
Operating Systems Engineering,
Application Processor Systems Engineering
-----Original Message-----
From: Chris Ball [mailto:[email protected]]
Sent: Thursday, May 17, 2012 8:38 PM
To: Yong Ding
Cc: [email protected]; Philip Rakity; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2] mmc:sdio:guarantee setting card data bus width as 4-bit
Hi,
Quoted 6 lines · yongd
SDIO_CCCR_IF[1:0] in SDIO card is used for card data bus width
setting as below,00b: 1-bit bus 01b: Reserved 10b: 4-bit bus 11b: 8-bit bus(only for embedded SDIO)
Quoted 7 lines
And
sdio_enable_wideis for setting data bus width as 4-bit. But
currently, it 1stly read the register, 2ndly OR' 1b with SDIO_CCCR_IF[1], and then write it back.
As we can see, such way is based on such assumption that the
SDIO_CCCR_IF[0] is always 0. Apparently, this is not right.Signed-off-by yongd <[email protected]>
Thanks. Can we have your full name, for the copyright record?
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Hi,
Quoted 41 lines · yongd
SDIO_CCCR_IF[1:0] in SDIO card is used for card data bus width
setting as below,00b: 1-bit bus 01b: Reserved 10b: 4-bit bus 11b: 8-bit bus(only for embedded SDIO)And
sdio_enable_wideis for setting data bus width as 4-bit. But
currently, it 1stly read the register, 2ndly OR' 1b with SDIO_CCCR_IF[1], and then write it back.
As we can see, such way is based on such assumption that the
SDIO_CCCR_IF[0] is always 0. Apparently, this is not right.Signed-off-by yongd <[email protected]>--- drivers/mmc/core/sdio.c | 7 +++++++ include/linux/mmc/sdio.h | 2 ++ 2 files changed, 9 insertions(+)drivers/mmc/core/sdio.c +7
-0@@ -218,6 +218,13 @@ static int sdio_enable_wide(struct mmc_card *card)if (ret)return ret; +if ((ctrl &SDIO_BUS_WIDTH_MASK ) + ==SDIO_BUS_WIDTH_RESERVED ) +printk (KERN_WARNING "%s: SDIO_CCCR_IF is invalid: 0x%02X\n" , +mmc_hostname (card->host), ctrl); + +/* set as 4-bit bus width */ + ctrl &= ~SDIO_BUS_WIDTH_MASK ; ctrl |=SDIO_BUS_WIDTH_4BIT ; ret =mmc_io_rw_direct (card,1 ,0 ,SDIO_CCCR_IF , ctrl,NULL );include/linux/mmc/sdio.h +0
-0
include/linux/mmc/sdio.h line 106
Quoted 9 lines
include/linux/mmc/sdio.h +2
-0@@ -98,7 +98,9 @@#define SDIO_CCCR_IF 0x07/* bus interface controls */ +#define SDIO_BUS_WIDTH_MASK 0x03/* data bus width setting */ #define SDIO_BUS_WIDTH_1BIT 0x00 +#define SDIO_BUS_WIDTH_RESERVED 0x01#define SDIO_BUS_WIDTH_4BIT 0x02#define SDIO_BUS_ECSI 0x20/* Enable continuous SPI interrupt */ #define SDIO_BUS_SCSI 0x40/* Support continuous SPI interrupt */
Thanks, pushed to mmc-next for 3.5.
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Chris,
Thanks, and very glad to hear this:-)
Best Wishes,
Yong Ding
Operating Systems Engineering,
Application Processor Systems Engineering
-----Original Message-----
From: Chris Ball [mailto:[email protected]]
Sent: Wednesday, June 06, 2012 9:24 PM
To: Yong Ding
Cc: [email protected]; Philip Rakity; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2] mmc:sdio:guarantee setting card data bus width as 4-bit
Hi,
Quoted 41 lines · yongd
SDIO_CCCR_IF[1:0] in SDIO card is used for card data bus width
setting as below,00b: 1-bit bus 01b: Reserved 10b: 4-bit bus 11b: 8-bit bus(only for embedded SDIO)And
sdio_enable_wideis for setting data bus width as 4-bit. But
currently, it 1stly read the register, 2ndly OR' 1b with SDIO_CCCR_IF[1], and then write it back.
As we can see, such way is based on such assumption that the
SDIO_CCCR_IF[0] is always 0. Apparently, this is not right.Signed-off-by yongd <[email protected]>--- drivers/mmc/core/sdio.c | 7 +++++++ include/linux/mmc/sdio.h | 2 ++ 2 files changed, 9 insertions(+)drivers/mmc/core/sdio.c +7
-0@@ -218,6 +218,13 @@ static int sdio_enable_wide(struct mmc_card *card)if (ret)return ret; +if ((ctrl &SDIO_BUS_WIDTH_MASK ) + ==SDIO_BUS_WIDTH_RESERVED ) +printk (KERN_WARNING "%s: SDIO_CCCR_IF is invalid: 0x%02X\n" , +mmc_hostname (card->host), ctrl); + +/* set as 4-bit bus width */ + ctrl &= ~SDIO_BUS_WIDTH_MASK ; ctrl |=SDIO_BUS_WIDTH_4BIT ; ret =mmc_io_rw_direct (card,1 ,0 ,SDIO_CCCR_IF , ctrl,NULL );include/linux/mmc/sdio.h +0
-0
include/linux/mmc/sdio.h line 106
Quoted 9 lines
include/linux/mmc/sdio.h +2
-0@@ -98,7 +98,9 @@#define SDIO_CCCR_IF 0x07/* bus interface controls */ +#define SDIO_BUS_WIDTH_MASK 0x03/* data bus width setting */ #define SDIO_BUS_WIDTH_1BIT 0x00 +#define SDIO_BUS_WIDTH_RESERVED 0x01#define SDIO_BUS_WIDTH_4BIT 0x02#define SDIO_BUS_ECSI 0x20/* Enable continuous SPI interrupt */ #define SDIO_BUS_SCSI 0x40/* Support continuous SPI interrupt */
Thanks, pushed to mmc-next for 3.5.
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child