diff mbox series

[17/32] hw/sd: Add emmc_cmd_SEND_RELATIVE_ADDR() handler

Message ID 20230703132509.2474225-18-clg@kaod.org
State New
Headers show
Series hw/sd: eMMC support | expand

Commit Message

Cédric Le Goater July 3, 2023, 1:24 p.m. UTC
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/sd/sd.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Philippe Mathieu-Daudé June 3, 2024, 12:26 p.m. UTC | #1
On 3/7/23 15:24, Cédric Le Goater wrote:
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>   hw/sd/sd.c | 20 ++++++++++++++++++++
>   1 file changed, 20 insertions(+)
> 
> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> index dd60a16f8c0a..5ff132139ea9 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -1053,6 +1053,25 @@ static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd, SDRequest req)
>       return sd_r2_i;
>   }
>   
> +static void sd_emmc_set_rca(SDState *sd, uint16_t value)
> +{
> +    sd->rca = value;
> +}
> +
> +static sd_rsp_type_t emmc_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req)

"emmc_cmd_SET_RELATIVE_ADDR".

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

> +{
> +    switch (sd->state) {
> +    case sd_identification_state:
> +    case sd_standby_state:
> +        sd->state = sd_standby_state;
> +        sd_emmc_set_rca(sd, req.arg >> 16);
> +        return sd_r1;
> +
> +    default:
> +        return sd_invalid_state_for_cmd(sd, req);
> +    }
> +}
> +
>   static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req)
>   {
>       switch (sd->state) {
> @@ -2194,6 +2213,7 @@ static const SDProto sd_proto_emmc = {
>           [0]         = sd_cmd_GO_IDLE_STATE,
>           [1]         = emmc_cmd_SEND_OP_CMD,
>           [2]         = emmc_cmd_ALL_SEND_CID,
> +        [3]         = emmc_cmd_SEND_RELATIVE_ADDR,
>           [5]         = sd_cmd_illegal,
>           [19]        = sd_cmd_SEND_TUNING_BLOCK,
>           [23]        = sd_cmd_SET_BLOCK_COUNT,
Cédric Le Goater June 4, 2024, 3:13 p.m. UTC | #2
On 6/3/24 14:26, Philippe Mathieu-Daudé wrote:
> On 3/7/23 15:24, Cédric Le Goater wrote:
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>   hw/sd/sd.c | 20 ++++++++++++++++++++
>>   1 file changed, 20 insertions(+)
>>
>> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
>> index dd60a16f8c0a..5ff132139ea9 100644
>> --- a/hw/sd/sd.c
>> +++ b/hw/sd/sd.c
>> @@ -1053,6 +1053,25 @@ static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd, SDRequest req)
>>       return sd_r2_i;
>>   }
>> +static void sd_emmc_set_rca(SDState *sd, uint16_t value)
>> +{
>> +    sd->rca = value;
>> +}
>> +
>> +static sd_rsp_type_t emmc_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req)
> 
> "emmc_cmd_SET_RELATIVE_ADDR".

Fixed.


Thanks,

C.


> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> 
>> +{
>> +    switch (sd->state) {
>> +    case sd_identification_state:
>> +    case sd_standby_state:
>> +        sd->state = sd_standby_state;
>> +        sd_emmc_set_rca(sd, req.arg >> 16);
>> +        return sd_r1;
>> +
>> +    default:
>> +        return sd_invalid_state_for_cmd(sd, req);
>> +    }
>> +}
>> +
>>   static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req)
>>   {
>>       switch (sd->state) {
>> @@ -2194,6 +2213,7 @@ static const SDProto sd_proto_emmc = {
>>           [0]         = sd_cmd_GO_IDLE_STATE,
>>           [1]         = emmc_cmd_SEND_OP_CMD,
>>           [2]         = emmc_cmd_ALL_SEND_CID,
>> +        [3]         = emmc_cmd_SEND_RELATIVE_ADDR,
>>           [5]         = sd_cmd_illegal,
>>           [19]        = sd_cmd_SEND_TUNING_BLOCK,
>>           [23]        = sd_cmd_SET_BLOCK_COUNT,
>
diff mbox series

Patch

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index dd60a16f8c0a..5ff132139ea9 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -1053,6 +1053,25 @@  static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd, SDRequest req)
     return sd_r2_i;
 }
 
+static void sd_emmc_set_rca(SDState *sd, uint16_t value)
+{
+    sd->rca = value;
+}
+
+static sd_rsp_type_t emmc_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req)
+{
+    switch (sd->state) {
+    case sd_identification_state:
+    case sd_standby_state:
+        sd->state = sd_standby_state;
+        sd_emmc_set_rca(sd, req.arg >> 16);
+        return sd_r1;
+
+    default:
+        return sd_invalid_state_for_cmd(sd, req);
+    }
+}
+
 static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req)
 {
     switch (sd->state) {
@@ -2194,6 +2213,7 @@  static const SDProto sd_proto_emmc = {
         [0]         = sd_cmd_GO_IDLE_STATE,
         [1]         = emmc_cmd_SEND_OP_CMD,
         [2]         = emmc_cmd_ALL_SEND_CID,
+        [3]         = emmc_cmd_SEND_RELATIVE_ADDR,
         [5]         = sd_cmd_illegal,
         [19]        = sd_cmd_SEND_TUNING_BLOCK,
         [23]        = sd_cmd_SET_BLOCK_COUNT,