Re: [U-Boot] [PATCH v2 1/5] sunxi: Add mmc card-detect functionality
Hi, On 10/11/2014 05:39 PM, Ian Campbell wrote: On Mon, 2014-10-06 at 19:57 +0200, Hans de Goede wrote: Signed-off-by: Hans de Goede hdego...@redhat.com I presume that adding GPIO support to SPL isn't a problem size wise? We do link time size checking and ./MAKEALL -s sunxi still works fine, so yes it is not a problem. --- board/sunxi/Kconfig| 26 ++ drivers/mmc/sunxi_mmc.c| 21 + include/configs/sunxi-common.h | 1 + 3 files changed, 48 insertions(+) diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index 622f7b4..497b093 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -32,4 +32,30 @@ config USB_KEYBOARD Say Y here to add support for using a USB keyboard (typically used in combination with a graphical console on HDMI). +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. sunxi_name_to_gpio() doesn't handle the empty string directly, but I think it will do the right thing (i.e. return -1) via a more or less convoluted path. Did you check this? Yes I checked, it will return -1 on the empty string. Assuming you have then: Acked-by: Ian Campbell i...@hellion.org.uk Regards, Hans ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 1/5] sunxi: Add mmc card-detect functionality
On Mon, 2014-10-06 at 19:57 +0200, Hans de Goede wrote: Signed-off-by: Hans de Goede hdego...@redhat.com I presume that adding GPIO support to SPL isn't a problem size wise? --- board/sunxi/Kconfig| 26 ++ drivers/mmc/sunxi_mmc.c| 21 + include/configs/sunxi-common.h | 1 + 3 files changed, 48 insertions(+) diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index 622f7b4..497b093 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -32,4 +32,30 @@ config USB_KEYBOARD Say Y here to add support for using a USB keyboard (typically used in combination with a graphical console on HDMI). +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. sunxi_name_to_gpio() doesn't handle the empty string directly, but I think it will do the right thing (i.e. return -1) via a more or less convoluted path. Did you check this? Assuming you have then: Acked-by: Ian Campbell i...@hellion.org.uk Ian. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 1/5] sunxi: Add mmc card-detect functionality
Signed-off-by: Hans de Goede hdego...@redhat.com --- board/sunxi/Kconfig| 26 ++ drivers/mmc/sunxi_mmc.c| 21 + include/configs/sunxi-common.h | 1 + 3 files changed, 48 insertions(+) diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index 622f7b4..497b093 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -32,4 +32,30 @@ config USB_KEYBOARD Say Y here to add support for using a USB keyboard (typically used in combination with a graphical console on HDMI). +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 diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c index bc2c4b3..0ea9f4d 100644 --- a/drivers/mmc/sunxi_mmc.c +++ b/drivers/mmc/sunxi_mmc.c @@ -14,7 +14,9 @@ #include asm/io.h #include asm/arch/clock.h #include asm/arch/cpu.h +#include asm/arch/gpio.h #include asm/arch/mmc.h +#include asm-generic/gpio.h struct sunxi_mmc_host { unsigned mmc_no; @@ -343,10 +345,29 @@ out: 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 = { .send_cmd = mmc_send_cmd, .set_ios= mmc_set_ios, .init = mmc_core_init, + .getcd = sunxi_mmc_getcd, }; int sunxi_mmc_init(int sdc_no) diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index af48c97..0ff67ee 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -183,6 +183,7 @@ /* GPIO */ #define CONFIG_SUNXI_GPIO +#define CONFIG_SPL_GPIO_SUPPORT #define CONFIG_CMD_GPIO #ifdef CONFIG_VIDEO -- 2.1.0 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot