| 1 |
/* |
| 2 |
* Copyright (c) 2022-2023, Intel Corporation. All rights reserved. |
| 3 |
* Copyright (c) 2024, Altera Corporation. All rights reserved. |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: BSD-3-Clause |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef SDMMC_H |
| 9 |
#define SDMMC_H |
| 10 |
|
| 11 |
#include <lib/mmio.h> |
| 12 |
#include "socfpga_handoff.h" |
| 13 |
|
| 14 |
#define PERIPHERAL_SDMMC_MASK 0x60 |
| 15 |
#define PERIPHERAL_SDMMC_OFFSET 6 |
| 16 |
|
| 17 |
#define DEFAULT_SDMMC_MAX_RETRIES 5 |
| 18 |
#define SEND_SDMMC_OP_COND_MAX_RETRIES 100 |
| 19 |
#define SDMMC_MULT_BY_512K_SHIFT 19 |
| 20 |
|
| 21 |
static const unsigned char tran_speed_base[16] = { |
| 22 |
0, 10, 12, 13, 15, 20, 26, 30, 35, 40, 45, 52, 55, 60, 70, 80 |
| 23 |
}; |
| 24 |
|
| 25 |
static const unsigned char sd_tran_speed_base[16] = { |
| 26 |
0, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80 |
| 27 |
}; |
| 28 |
|
| 29 |
|
| 30 |
/* FUNCTION DEFINATION */ |
| 31 |
/* |
| 32 |
* @brief SDMMC controller initialization function |
| 33 |
* |
| 34 |
* @hoff_ptr: Pointer to the hand-off data |
| 35 |
* Return: 0 on success, a negative errno on failure |
| 36 |
*/ |
| 37 |
void sdmmc_pin_config(void); |
| 38 |
size_t sdmmc_read_blocks(int lba, uintptr_t buf, size_t size); |
| 39 |
size_t sdmmc_write_blocks(int lba, const uintptr_t buf, size_t size); |
| 40 |
int sdmmc_device_state(void); |
| 41 |
bool is_cmd23_enabled(void); |
| 42 |
int sdmmc_send_cmd(unsigned int idx, unsigned int arg, |
| 43 |
unsigned int r_type, unsigned int *r_data); |
| 44 |
|
| 45 |
#endif |