Re: [U-Boot] [PATCH V4 7/9] MMC: APIs to support resize of EMMC boot partition

2013-01-07 Thread Jaehoon Chung
On 01/07/2013 02:54 PM, Amarendra Reddy wrote:
> Hi Jaehoon,
> 
> The sequence to be followed to access(read/write) boot partitions is i)
> open() the boot partition,  ii) Do the job , iii) Then close() boot
> partition.
> 
> I understand that
> 1) You want a single generic function "mmc_boot_part_access(struct mmc
> *mmc, int ack, int part_num, int access)" to be used
> instead of two functions open() and close().
> 2) By doing so user can specify which boot partition to be accessed (opened
> / closed).
It is just my suggestion..I didn't know other.
Well, I want to know Andy's opinion.

Best Regards,
Jaehoon Chung
> 
> Please comment.
> 
> Thanks & Regards
> Amarendra Reddy
> 
> 
> On 7 January 2013 10:04, Jaehoon Chung  wrote:
> 
>> Hi Amar,
>>
>> If you want to access the boot partition, Need to add open/close()?
>> I think we can use like "mmc_boot_part_access(struct mmc *mmc, int ack,
>> int part_num, int access)"
>> How about this? i think it is more generic...
>>
>> On 01/07/2013 01:19 PM, Amarendra Reddy wrote:
>>> Hi Jaehoon,
>>>
>>> Yes, the functions mmc_boot_partiton_size_change(), mmc_boot_open()
>>> & mmc_boot_close() can be used
>>> by any vendor to open/close/resize-boot-partition of emmc device.
>> How can any vendor use with resize-boot-partition?
>> you used the vendor command.(you added the comment "Only use this command
>> for raw eMMC moviNAND")
>> And i think good that these functions are used with cmd_mmc.
>>
>> Best Regards,
>> Jaehoon Chung
>>  > The above 3 functions call the static function "static int
>>> mmc_send_cmd(...)" located in drivers/mmc/mmc.c.
>>> Any vendor can use the above 3 functions, if placed in drivers/mmc/mmc.c.
>>>
>>> Thanks & Regards
>>> Amarendra Reddy
>>>
>>> On 4 January 2013 15:57, Jaehoon Chung  wrote:
>>>
 Hi Amar,

 I wonder that include the moviNAND specific code in mmc.c?
 mmc_boot_partiton_size_change() looks like every vendor can use this
 function.

 Best Regards,
 Jaehoon Chung

 On 01/04/2013 06:34 PM, Amar wrote:
> This patch adds APIs to open, close and to resize boot partiton for
>> EMMC.
>
> Changes from V1:
>   New patch.
>
> Changes from V2:
>   1)Updation of commit message and resubmition of proper patch set.
>
> Changes from V3:
> No change.
>
> Signed-off-by: Amar 
> ---
>  drivers/mmc/mmc.c | 118
 ++
>  include/mmc.h |  16 
>  2 files changed, 134 insertions(+)
>
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 72e8ce6..8175b49 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -1327,3 +1327,121 @@ int mmc_initialize(bd_t *bis)
>
>   return 0;
>  }
> +
> +int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long
 bootsize,
> + unsigned long rpmbsize)
> +{
> + int err;
> + struct mmc_cmd cmd;
> +
> + /* Only use this command for raw EMMC moviNAND */
> + /* Enter backdoor mode */
> + cmd.cmdidx = MMC_CMD_RES_MAN;
> + cmd.resp_type = MMC_RSP_R1b;
> + cmd.cmdarg = MMC_CMD62_ARG1;
> +
> + err = mmc_send_cmd(mmc, &cmd, NULL);
> + if (err) {
> + debug("mmc_boot_partition_size_change: Error1 = %d\n",
 err);
> + return err;
> + }
> +
> + /* Boot partition changing mode */
> + cmd.cmdidx = MMC_CMD_RES_MAN;
> + cmd.resp_type = MMC_RSP_R1b;
> + cmd.cmdarg = MMC_CMD62_ARG2;
> +
> + err = mmc_send_cmd(mmc, &cmd, NULL);
> + if (err) {
> + debug("mmc_boot_partition_size_change: Error2 = %d\n",
 err);
> + return err;
> + }
> + /* boot partition size is multiple of 128KB */
> + bootsize = ((bootsize*1024)/128);
> +
> + /* Arg: boot partition size */
> + cmd.cmdidx = MMC_CMD_RES_MAN;
> + cmd.resp_type = MMC_RSP_R1b;
> + cmd.cmdarg = bootsize;
> +
> + err = mmc_send_cmd(mmc, &cmd, NULL);
> + if (err) {
> + debug("mmc_boot_partition_size_change: Error3 = %d\n",
 err);
> + return err;
> + }
> + /* RPMB partition size is multiple of 128KB */
> + rpmbsize = ((rpmbsize*1024)/128);
> + /* Arg: RPMB partition size */
> + cmd.cmdidx = MMC_CMD_RES_MAN;
> + cmd.resp_type = MMC_RSP_R1b;
> + cmd.cmdarg = rpmbsize;
> +
> + err = mmc_send_cmd(mmc, &cmd, NULL);
> + if (err) {
> + debug("mmc_boot_partition_size_change: Error4 = %d\n",
 err);
> + return err;
> + }
> + return 0;
> +}
> +
> +int mmc_boot_open(struct mmc *mmc)
> +{
> + int err;
> + struct mmc_cmd cmd;
> +
> +

Re: [U-Boot] [PATCH V4 7/9] MMC: APIs to support resize of EMMC boot partition

2013-01-06 Thread Amarendra Reddy
Hi Jaehoon,

The sequence to be followed to access(read/write) boot partitions is i)
open() the boot partition,  ii) Do the job , iii) Then close() boot
partition.

I understand that
1) You want a single generic function "mmc_boot_part_access(struct mmc
*mmc, int ack, int part_num, int access)" to be used
instead of two functions open() and close().
2) By doing so user can specify which boot partition to be accessed (opened
/ closed).

Please comment.

Thanks & Regards
Amarendra Reddy


On 7 January 2013 10:04, Jaehoon Chung  wrote:

> Hi Amar,
>
> If you want to access the boot partition, Need to add open/close()?
> I think we can use like "mmc_boot_part_access(struct mmc *mmc, int ack,
> int part_num, int access)"
> How about this? i think it is more generic...
>
> On 01/07/2013 01:19 PM, Amarendra Reddy wrote:
> > Hi Jaehoon,
> >
> > Yes, the functions mmc_boot_partiton_size_change(), mmc_boot_open()
> > & mmc_boot_close() can be used
> > by any vendor to open/close/resize-boot-partition of emmc device.
> How can any vendor use with resize-boot-partition?
> you used the vendor command.(you added the comment "Only use this command
> for raw eMMC moviNAND")
> And i think good that these functions are used with cmd_mmc.
>
> Best Regards,
> Jaehoon Chung
>  > The above 3 functions call the static function "static int
> > mmc_send_cmd(...)" located in drivers/mmc/mmc.c.
> > Any vendor can use the above 3 functions, if placed in drivers/mmc/mmc.c.
> >
> > Thanks & Regards
> > Amarendra Reddy
> >
> > On 4 January 2013 15:57, Jaehoon Chung  wrote:
> >
> >> Hi Amar,
> >>
> >> I wonder that include the moviNAND specific code in mmc.c?
> >> mmc_boot_partiton_size_change() looks like every vendor can use this
> >> function.
> >>
> >> Best Regards,
> >> Jaehoon Chung
> >>
> >> On 01/04/2013 06:34 PM, Amar wrote:
> >>> This patch adds APIs to open, close and to resize boot partiton for
> EMMC.
> >>>
> >>> Changes from V1:
> >>>   New patch.
> >>>
> >>> Changes from V2:
> >>>   1)Updation of commit message and resubmition of proper patch set.
> >>>
> >>> Changes from V3:
> >>> No change.
> >>>
> >>> Signed-off-by: Amar 
> >>> ---
> >>>  drivers/mmc/mmc.c | 118
> >> ++
> >>>  include/mmc.h |  16 
> >>>  2 files changed, 134 insertions(+)
> >>>
> >>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> >>> index 72e8ce6..8175b49 100644
> >>> --- a/drivers/mmc/mmc.c
> >>> +++ b/drivers/mmc/mmc.c
> >>> @@ -1327,3 +1327,121 @@ int mmc_initialize(bd_t *bis)
> >>>
> >>>   return 0;
> >>>  }
> >>> +
> >>> +int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long
> >> bootsize,
> >>> + unsigned long rpmbsize)
> >>> +{
> >>> + int err;
> >>> + struct mmc_cmd cmd;
> >>> +
> >>> + /* Only use this command for raw EMMC moviNAND */
> >>> + /* Enter backdoor mode */
> >>> + cmd.cmdidx = MMC_CMD_RES_MAN;
> >>> + cmd.resp_type = MMC_RSP_R1b;
> >>> + cmd.cmdarg = MMC_CMD62_ARG1;
> >>> +
> >>> + err = mmc_send_cmd(mmc, &cmd, NULL);
> >>> + if (err) {
> >>> + debug("mmc_boot_partition_size_change: Error1 = %d\n",
> >> err);
> >>> + return err;
> >>> + }
> >>> +
> >>> + /* Boot partition changing mode */
> >>> + cmd.cmdidx = MMC_CMD_RES_MAN;
> >>> + cmd.resp_type = MMC_RSP_R1b;
> >>> + cmd.cmdarg = MMC_CMD62_ARG2;
> >>> +
> >>> + err = mmc_send_cmd(mmc, &cmd, NULL);
> >>> + if (err) {
> >>> + debug("mmc_boot_partition_size_change: Error2 = %d\n",
> >> err);
> >>> + return err;
> >>> + }
> >>> + /* boot partition size is multiple of 128KB */
> >>> + bootsize = ((bootsize*1024)/128);
> >>> +
> >>> + /* Arg: boot partition size */
> >>> + cmd.cmdidx = MMC_CMD_RES_MAN;
> >>> + cmd.resp_type = MMC_RSP_R1b;
> >>> + cmd.cmdarg = bootsize;
> >>> +
> >>> + err = mmc_send_cmd(mmc, &cmd, NULL);
> >>> + if (err) {
> >>> + debug("mmc_boot_partition_size_change: Error3 = %d\n",
> >> err);
> >>> + return err;
> >>> + }
> >>> + /* RPMB partition size is multiple of 128KB */
> >>> + rpmbsize = ((rpmbsize*1024)/128);
> >>> + /* Arg: RPMB partition size */
> >>> + cmd.cmdidx = MMC_CMD_RES_MAN;
> >>> + cmd.resp_type = MMC_RSP_R1b;
> >>> + cmd.cmdarg = rpmbsize;
> >>> +
> >>> + err = mmc_send_cmd(mmc, &cmd, NULL);
> >>> + if (err) {
> >>> + debug("mmc_boot_partition_size_change: Error4 = %d\n",
> >> err);
> >>> + return err;
> >>> + }
> >>> + return 0;
> >>> +}
> >>> +
> >>> +int mmc_boot_open(struct mmc *mmc)
> >>> +{
> >>> + int err;
> >>> + struct mmc_cmd cmd;
> >>> +
> >>> + /* Boot ack enable, boot partition enable , boot partition access
> >> */
> >>> + cmd.cmdidx = MMC_CMD_SWITCH;
> >>> + cmd.resp_type = MMC_RSP_R1b;
> >>> +
> >>> + cmd.cmdarg = (MMC_SWITCH_MODE_WRITE_BYTE <

Re: [U-Boot] [PATCH V4 7/9] MMC: APIs to support resize of EMMC boot partition

2013-01-06 Thread Jaehoon Chung
Hi Amar,

If you want to access the boot partition, Need to add open/close()?
I think we can use like "mmc_boot_part_access(struct mmc *mmc, int ack, int 
part_num, int access)"
How about this? i think it is more generic...

On 01/07/2013 01:19 PM, Amarendra Reddy wrote:
> Hi Jaehoon,
> 
> Yes, the functions mmc_boot_partiton_size_change(), mmc_boot_open()
> & mmc_boot_close() can be used
> by any vendor to open/close/resize-boot-partition of emmc device.
How can any vendor use with resize-boot-partition?
you used the vendor command.(you added the comment "Only use this command for 
raw eMMC moviNAND")
And i think good that these functions are used with cmd_mmc.

Best Regards,
Jaehoon Chung
> The above 3 functions call the static function "static int
> mmc_send_cmd(...)" located in drivers/mmc/mmc.c.
> Any vendor can use the above 3 functions, if placed in drivers/mmc/mmc.c.
> 
> Thanks & Regards
> Amarendra Reddy
> 
> On 4 January 2013 15:57, Jaehoon Chung  wrote:
> 
>> Hi Amar,
>>
>> I wonder that include the moviNAND specific code in mmc.c?
>> mmc_boot_partiton_size_change() looks like every vendor can use this
>> function.
>>
>> Best Regards,
>> Jaehoon Chung
>>
>> On 01/04/2013 06:34 PM, Amar wrote:
>>> This patch adds APIs to open, close and to resize boot partiton for EMMC.
>>>
>>> Changes from V1:
>>>   New patch.
>>>
>>> Changes from V2:
>>>   1)Updation of commit message and resubmition of proper patch set.
>>>
>>> Changes from V3:
>>> No change.
>>>
>>> Signed-off-by: Amar 
>>> ---
>>>  drivers/mmc/mmc.c | 118
>> ++
>>>  include/mmc.h |  16 
>>>  2 files changed, 134 insertions(+)
>>>
>>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>>> index 72e8ce6..8175b49 100644
>>> --- a/drivers/mmc/mmc.c
>>> +++ b/drivers/mmc/mmc.c
>>> @@ -1327,3 +1327,121 @@ int mmc_initialize(bd_t *bis)
>>>
>>>   return 0;
>>>  }
>>> +
>>> +int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long
>> bootsize,
>>> + unsigned long rpmbsize)
>>> +{
>>> + int err;
>>> + struct mmc_cmd cmd;
>>> +
>>> + /* Only use this command for raw EMMC moviNAND */
>>> + /* Enter backdoor mode */
>>> + cmd.cmdidx = MMC_CMD_RES_MAN;
>>> + cmd.resp_type = MMC_RSP_R1b;
>>> + cmd.cmdarg = MMC_CMD62_ARG1;
>>> +
>>> + err = mmc_send_cmd(mmc, &cmd, NULL);
>>> + if (err) {
>>> + debug("mmc_boot_partition_size_change: Error1 = %d\n",
>> err);
>>> + return err;
>>> + }
>>> +
>>> + /* Boot partition changing mode */
>>> + cmd.cmdidx = MMC_CMD_RES_MAN;
>>> + cmd.resp_type = MMC_RSP_R1b;
>>> + cmd.cmdarg = MMC_CMD62_ARG2;
>>> +
>>> + err = mmc_send_cmd(mmc, &cmd, NULL);
>>> + if (err) {
>>> + debug("mmc_boot_partition_size_change: Error2 = %d\n",
>> err);
>>> + return err;
>>> + }
>>> + /* boot partition size is multiple of 128KB */
>>> + bootsize = ((bootsize*1024)/128);
>>> +
>>> + /* Arg: boot partition size */
>>> + cmd.cmdidx = MMC_CMD_RES_MAN;
>>> + cmd.resp_type = MMC_RSP_R1b;
>>> + cmd.cmdarg = bootsize;
>>> +
>>> + err = mmc_send_cmd(mmc, &cmd, NULL);
>>> + if (err) {
>>> + debug("mmc_boot_partition_size_change: Error3 = %d\n",
>> err);
>>> + return err;
>>> + }
>>> + /* RPMB partition size is multiple of 128KB */
>>> + rpmbsize = ((rpmbsize*1024)/128);
>>> + /* Arg: RPMB partition size */
>>> + cmd.cmdidx = MMC_CMD_RES_MAN;
>>> + cmd.resp_type = MMC_RSP_R1b;
>>> + cmd.cmdarg = rpmbsize;
>>> +
>>> + err = mmc_send_cmd(mmc, &cmd, NULL);
>>> + if (err) {
>>> + debug("mmc_boot_partition_size_change: Error4 = %d\n",
>> err);
>>> + return err;
>>> + }
>>> + return 0;
>>> +}
>>> +
>>> +int mmc_boot_open(struct mmc *mmc)
>>> +{
>>> + int err;
>>> + struct mmc_cmd cmd;
>>> +
>>> + /* Boot ack enable, boot partition enable , boot partition access
>> */
>>> + cmd.cmdidx = MMC_CMD_SWITCH;
>>> + cmd.resp_type = MMC_RSP_R1b;
>>> +
>>> + cmd.cmdarg = (MMC_SWITCH_MODE_WRITE_BYTE << 24 |
>>> + EXT_CSD_PART_CONF << 16 |
>>> + (EXT_CSD_BOOT_ACK_ENABLE |
>>> + EXT_CSD_BOOT_PARTITION_ENABLE |
>>> + EXT_CSD_PARTITION_ACCESS_ENABLE) << 8);
>>> +
>>> + err = mmc_send_cmd(mmc, &cmd, NULL);
>>> + if (err) {
>>> + debug("mmc_boot_open: Error1 = %d\n", err);
>>> + return err;
>>> + }
>>> +
>>> + /* 4bit transfer mode at booting time. */
>>> + cmd.cmdidx = MMC_CMD_SWITCH;
>>> + cmd.resp_type = MMC_RSP_R1b;
>>> +
>>> + cmd.cmdarg = (MMC_SWITCH_MODE_WRITE_BYTE << 24|
>>> + EXT_CSD_BOOT_BUS_WIDTH << 16|
>>> + ((1<<0) << 8));
>>> +
>>> + err = mmc_send_cmd(mmc, &cmd, NULL);
>>> + if (err) {
>>> + debug(

Re: [U-Boot] [PATCH V4 7/9] MMC: APIs to support resize of EMMC boot partition

2013-01-06 Thread Amarendra Reddy
Hi Jaehoon,

Yes, the functions mmc_boot_partiton_size_change(), mmc_boot_open()
& mmc_boot_close() can be used
by any vendor to open/close/resize-boot-partition of emmc device.
The above 3 functions call the static function "static int
mmc_send_cmd(...)" located in drivers/mmc/mmc.c.
Any vendor can use the above 3 functions, if placed in drivers/mmc/mmc.c.

Thanks & Regards
Amarendra Reddy

On 4 January 2013 15:57, Jaehoon Chung  wrote:

> Hi Amar,
>
> I wonder that include the moviNAND specific code in mmc.c?
> mmc_boot_partiton_size_change() looks like every vendor can use this
> function.
>
> Best Regards,
> Jaehoon Chung
>
> On 01/04/2013 06:34 PM, Amar wrote:
> > This patch adds APIs to open, close and to resize boot partiton for EMMC.
> >
> > Changes from V1:
> >   New patch.
> >
> > Changes from V2:
> >   1)Updation of commit message and resubmition of proper patch set.
> >
> > Changes from V3:
> > No change.
> >
> > Signed-off-by: Amar 
> > ---
> >  drivers/mmc/mmc.c | 118
> ++
> >  include/mmc.h |  16 
> >  2 files changed, 134 insertions(+)
> >
> > diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> > index 72e8ce6..8175b49 100644
> > --- a/drivers/mmc/mmc.c
> > +++ b/drivers/mmc/mmc.c
> > @@ -1327,3 +1327,121 @@ int mmc_initialize(bd_t *bis)
> >
> >   return 0;
> >  }
> > +
> > +int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long
> bootsize,
> > + unsigned long rpmbsize)
> > +{
> > + int err;
> > + struct mmc_cmd cmd;
> > +
> > + /* Only use this command for raw EMMC moviNAND */
> > + /* Enter backdoor mode */
> > + cmd.cmdidx = MMC_CMD_RES_MAN;
> > + cmd.resp_type = MMC_RSP_R1b;
> > + cmd.cmdarg = MMC_CMD62_ARG1;
> > +
> > + err = mmc_send_cmd(mmc, &cmd, NULL);
> > + if (err) {
> > + debug("mmc_boot_partition_size_change: Error1 = %d\n",
> err);
> > + return err;
> > + }
> > +
> > + /* Boot partition changing mode */
> > + cmd.cmdidx = MMC_CMD_RES_MAN;
> > + cmd.resp_type = MMC_RSP_R1b;
> > + cmd.cmdarg = MMC_CMD62_ARG2;
> > +
> > + err = mmc_send_cmd(mmc, &cmd, NULL);
> > + if (err) {
> > + debug("mmc_boot_partition_size_change: Error2 = %d\n",
> err);
> > + return err;
> > + }
> > + /* boot partition size is multiple of 128KB */
> > + bootsize = ((bootsize*1024)/128);
> > +
> > + /* Arg: boot partition size */
> > + cmd.cmdidx = MMC_CMD_RES_MAN;
> > + cmd.resp_type = MMC_RSP_R1b;
> > + cmd.cmdarg = bootsize;
> > +
> > + err = mmc_send_cmd(mmc, &cmd, NULL);
> > + if (err) {
> > + debug("mmc_boot_partition_size_change: Error3 = %d\n",
> err);
> > + return err;
> > + }
> > + /* RPMB partition size is multiple of 128KB */
> > + rpmbsize = ((rpmbsize*1024)/128);
> > + /* Arg: RPMB partition size */
> > + cmd.cmdidx = MMC_CMD_RES_MAN;
> > + cmd.resp_type = MMC_RSP_R1b;
> > + cmd.cmdarg = rpmbsize;
> > +
> > + err = mmc_send_cmd(mmc, &cmd, NULL);
> > + if (err) {
> > + debug("mmc_boot_partition_size_change: Error4 = %d\n",
> err);
> > + return err;
> > + }
> > + return 0;
> > +}
> > +
> > +int mmc_boot_open(struct mmc *mmc)
> > +{
> > + int err;
> > + struct mmc_cmd cmd;
> > +
> > + /* Boot ack enable, boot partition enable , boot partition access
> */
> > + cmd.cmdidx = MMC_CMD_SWITCH;
> > + cmd.resp_type = MMC_RSP_R1b;
> > +
> > + cmd.cmdarg = (MMC_SWITCH_MODE_WRITE_BYTE << 24 |
> > + EXT_CSD_PART_CONF << 16 |
> > + (EXT_CSD_BOOT_ACK_ENABLE |
> > + EXT_CSD_BOOT_PARTITION_ENABLE |
> > + EXT_CSD_PARTITION_ACCESS_ENABLE) << 8);
> > +
> > + err = mmc_send_cmd(mmc, &cmd, NULL);
> > + if (err) {
> > + debug("mmc_boot_open: Error1 = %d\n", err);
> > + return err;
> > + }
> > +
> > + /* 4bit transfer mode at booting time. */
> > + cmd.cmdidx = MMC_CMD_SWITCH;
> > + cmd.resp_type = MMC_RSP_R1b;
> > +
> > + cmd.cmdarg = (MMC_SWITCH_MODE_WRITE_BYTE << 24|
> > + EXT_CSD_BOOT_BUS_WIDTH << 16|
> > + ((1<<0) << 8));
> > +
> > + err = mmc_send_cmd(mmc, &cmd, NULL);
> > + if (err) {
> > + debug("mmc_boot_open: Error2 = %d\n", err);
> > + return err;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +int mmc_boot_close(struct mmc *mmc)
> > +{
> > + int err;
> > + struct mmc_cmd cmd;
> > +
> > + /* Boot ack enable, boot partition enable , boot partition access
> */
> > + cmd.cmdidx = MMC_CMD_SWITCH;
> > + cmd.resp_type = MMC_RSP_R1b;
> > +
> > + cmd.cmdarg = (MMC_SWITCH_MODE_WRITE_BYTE << 24|
> > + EXT_CSD_PART_CONF << 16|
> > + (EXT_CSD_BOOT_ACK_ENABLE |
> > +   

Re: [U-Boot] [PATCH V4 7/9] MMC: APIs to support resize of EMMC boot partition

2013-01-04 Thread Jaehoon Chung
Hi Amar,

I wonder that include the moviNAND specific code in mmc.c?
mmc_boot_partiton_size_change() looks like every vendor can use this function.

Best Regards,
Jaehoon Chung

On 01/04/2013 06:34 PM, Amar wrote:
> This patch adds APIs to open, close and to resize boot partiton for EMMC.
> 
> Changes from V1:
>   New patch.
> 
> Changes from V2:
>   1)Updation of commit message and resubmition of proper patch set.
> 
> Changes from V3:
> No change.
> 
> Signed-off-by: Amar 
> ---
>  drivers/mmc/mmc.c | 118 
> ++
>  include/mmc.h |  16 
>  2 files changed, 134 insertions(+)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 72e8ce6..8175b49 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -1327,3 +1327,121 @@ int mmc_initialize(bd_t *bis)
>  
>   return 0;
>  }
> +
> +int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long bootsize,
> + unsigned long rpmbsize)
> +{
> + int err;
> + struct mmc_cmd cmd;
> +
> + /* Only use this command for raw EMMC moviNAND */
> + /* Enter backdoor mode */
> + cmd.cmdidx = MMC_CMD_RES_MAN;
> + cmd.resp_type = MMC_RSP_R1b;
> + cmd.cmdarg = MMC_CMD62_ARG1;
> +
> + err = mmc_send_cmd(mmc, &cmd, NULL);
> + if (err) {
> + debug("mmc_boot_partition_size_change: Error1 = %d\n", err);
> + return err;
> + }
> +
> + /* Boot partition changing mode */
> + cmd.cmdidx = MMC_CMD_RES_MAN;
> + cmd.resp_type = MMC_RSP_R1b;
> + cmd.cmdarg = MMC_CMD62_ARG2;
> +
> + err = mmc_send_cmd(mmc, &cmd, NULL);
> + if (err) {
> + debug("mmc_boot_partition_size_change: Error2 = %d\n", err);
> + return err;
> + }
> + /* boot partition size is multiple of 128KB */
> + bootsize = ((bootsize*1024)/128);
> +
> + /* Arg: boot partition size */
> + cmd.cmdidx = MMC_CMD_RES_MAN;
> + cmd.resp_type = MMC_RSP_R1b;
> + cmd.cmdarg = bootsize;
> +
> + err = mmc_send_cmd(mmc, &cmd, NULL);
> + if (err) {
> + debug("mmc_boot_partition_size_change: Error3 = %d\n", err);
> + return err;
> + }
> + /* RPMB partition size is multiple of 128KB */
> + rpmbsize = ((rpmbsize*1024)/128);
> + /* Arg: RPMB partition size */
> + cmd.cmdidx = MMC_CMD_RES_MAN;
> + cmd.resp_type = MMC_RSP_R1b;
> + cmd.cmdarg = rpmbsize;
> +
> + err = mmc_send_cmd(mmc, &cmd, NULL);
> + if (err) {
> + debug("mmc_boot_partition_size_change: Error4 = %d\n", err);
> + return err;
> + }
> + return 0;
> +}
> +
> +int mmc_boot_open(struct mmc *mmc)
> +{
> + int err;
> + struct mmc_cmd cmd;
> +
> + /* Boot ack enable, boot partition enable , boot partition access */
> + cmd.cmdidx = MMC_CMD_SWITCH;
> + cmd.resp_type = MMC_RSP_R1b;
> +
> + cmd.cmdarg = (MMC_SWITCH_MODE_WRITE_BYTE << 24 |
> + EXT_CSD_PART_CONF << 16 |
> + (EXT_CSD_BOOT_ACK_ENABLE |
> + EXT_CSD_BOOT_PARTITION_ENABLE |
> + EXT_CSD_PARTITION_ACCESS_ENABLE) << 8);
> +
> + err = mmc_send_cmd(mmc, &cmd, NULL);
> + if (err) {
> + debug("mmc_boot_open: Error1 = %d\n", err);
> + return err;
> + }
> +
> + /* 4bit transfer mode at booting time. */
> + cmd.cmdidx = MMC_CMD_SWITCH;
> + cmd.resp_type = MMC_RSP_R1b;
> +
> + cmd.cmdarg = (MMC_SWITCH_MODE_WRITE_BYTE << 24|
> + EXT_CSD_BOOT_BUS_WIDTH << 16|
> + ((1<<0) << 8));
> +
> + err = mmc_send_cmd(mmc, &cmd, NULL);
> + if (err) {
> + debug("mmc_boot_open: Error2 = %d\n", err);
> + return err;
> + }
> +
> + return 0;
> +}
> +
> +int mmc_boot_close(struct mmc *mmc)
> +{
> + int err;
> + struct mmc_cmd cmd;
> +
> + /* Boot ack enable, boot partition enable , boot partition access */
> + cmd.cmdidx = MMC_CMD_SWITCH;
> + cmd.resp_type = MMC_RSP_R1b;
> +
> + cmd.cmdarg = (MMC_SWITCH_MODE_WRITE_BYTE << 24|
> + EXT_CSD_PART_CONF << 16|
> + (EXT_CSD_BOOT_ACK_ENABLE |
> + EXT_CSD_BOOT_PARTITION_ENABLE |
> + EXT_CSD_PARTITION_ACCESS_DISABLE) << 8);
> +
> + err = mmc_send_cmd(mmc, &cmd, NULL);
> + if (err) {
> + debug("mmc_boot_close: Error = %d\n", err);
> + return err;
> + }
> +
> + return 0;
> +}
> diff --git a/include/mmc.h b/include/mmc.h
> index a13e2bd..999f0a3 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -86,6 +86,11 @@
>  #define MMC_CMD_APP_CMD  55
>  #define MMC_CMD_SPI_READ_OCR 58
>  #define MMC_CMD_SPI_CRC_ON_OFF   59
> +#define MMC_CMD_RES_MAN  62
> +
> +#define MMC_CMD62_ARG1   0xefac62ec
> +#define MMC_CMD62_AR