mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-28 07:30:26 +09:00
sunxi: Add mmc card-detect functionality
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Ian Campbell <ijc@hellion.org.uk>
This commit is contained in:
parent
7ad3b6aa37
commit
cd82113a98
@ -41,4 +41,30 @@ config SYS_SOC
|
|||||||
config FDTFILE
|
config FDTFILE
|
||||||
string "Default fdtfile env setting for this board"
|
string "Default fdtfile env setting for this board"
|
||||||
|
|
||||||
|
config MMC0_CD_PIN
|
||||||
|
string "Card detect pin for mmc0"
|
||||||
|
default ""
|
||||||
|
---help---
|
||||||
|
Set the card detect pin for mmc0, leave empty to not use cd. This
|
||||||
|
takes a string in the format understood by sunxi_name_to_gpio, e.g.
|
||||||
|
PH1 for pin 1 of port H.
|
||||||
|
|
||||||
|
config MMC1_CD_PIN
|
||||||
|
string "Card detect pin for mmc1"
|
||||||
|
default ""
|
||||||
|
---help---
|
||||||
|
See MMC0_CD_PIN help text.
|
||||||
|
|
||||||
|
config MMC2_CD_PIN
|
||||||
|
string "Card detect pin for mmc2"
|
||||||
|
default ""
|
||||||
|
---help---
|
||||||
|
See MMC0_CD_PIN help text.
|
||||||
|
|
||||||
|
config MMC3_CD_PIN
|
||||||
|
string "Card detect pin for mmc3"
|
||||||
|
default ""
|
||||||
|
---help---
|
||||||
|
See MMC0_CD_PIN help text.
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
@ -14,7 +14,9 @@
|
|||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
#include <asm/arch/clock.h>
|
#include <asm/arch/clock.h>
|
||||||
#include <asm/arch/cpu.h>
|
#include <asm/arch/cpu.h>
|
||||||
|
#include <asm/arch/gpio.h>
|
||||||
#include <asm/arch/mmc.h>
|
#include <asm/arch/mmc.h>
|
||||||
|
#include <asm-generic/gpio.h>
|
||||||
|
|
||||||
struct sunxi_mmc_host {
|
struct sunxi_mmc_host {
|
||||||
unsigned mmc_no;
|
unsigned mmc_no;
|
||||||
@ -346,10 +348,29 @@ out:
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sunxi_mmc_getcd(struct mmc *mmc)
|
||||||
|
{
|
||||||
|
struct sunxi_mmc_host *mmchost = mmc->priv;
|
||||||
|
int cd_pin = -1;
|
||||||
|
|
||||||
|
switch (mmchost->mmc_no) {
|
||||||
|
case 0: cd_pin = sunxi_name_to_gpio(CONFIG_MMC0_CD_PIN); break;
|
||||||
|
case 1: cd_pin = sunxi_name_to_gpio(CONFIG_MMC1_CD_PIN); break;
|
||||||
|
case 2: cd_pin = sunxi_name_to_gpio(CONFIG_MMC2_CD_PIN); break;
|
||||||
|
case 3: cd_pin = sunxi_name_to_gpio(CONFIG_MMC3_CD_PIN); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cd_pin == -1)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return !gpio_direction_input(cd_pin);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct mmc_ops sunxi_mmc_ops = {
|
static const struct mmc_ops sunxi_mmc_ops = {
|
||||||
.send_cmd = mmc_send_cmd,
|
.send_cmd = mmc_send_cmd,
|
||||||
.set_ios = mmc_set_ios,
|
.set_ios = mmc_set_ios,
|
||||||
.init = mmc_core_init,
|
.init = mmc_core_init,
|
||||||
|
.getcd = sunxi_mmc_getcd,
|
||||||
};
|
};
|
||||||
|
|
||||||
int sunxi_mmc_init(int sdc_no)
|
int sunxi_mmc_init(int sdc_no)
|
||||||
|
@ -181,6 +181,7 @@
|
|||||||
|
|
||||||
/* GPIO */
|
/* GPIO */
|
||||||
#define CONFIG_SUNXI_GPIO
|
#define CONFIG_SUNXI_GPIO
|
||||||
|
#define CONFIG_SPL_GPIO_SUPPORT
|
||||||
#define CONFIG_CMD_GPIO
|
#define CONFIG_CMD_GPIO
|
||||||
|
|
||||||
/* Ethernet support */
|
/* Ethernet support */
|
||||||
|
Loading…
Reference in New Issue
Block a user