diff mbox series

[U-Boot,v3,27/58] fastboot: sunxi: Update fastboot mmc default device

Message ID 20180819135715.15799-28-jagan@amarulasolutions.com
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series clk: Add Allwinner CLK, RESET support | expand

Commit Message

Jagan Teki Aug. 19, 2018, 1:56 p.m. UTC
Usually eMMC is default mmc device for fastboot.

By enabling DM_MMC, the mmc devices are probed as per
DT status not with respect to MMC_SUNXI_SLOT_EXTRA in
U-Boot proper.

Allwinner SoC has maximum of 4 mmc controllers start from
mmc0...mmc3 on which mmc2 can be used an eMMC controller
eventhough mmc3 some boards used as eMMC.

So, update the default fastboot device as 2 to make the
standard usage irrespective of DT node status.

Other corner cases like different device usage, or specific
mmc node status is not enabled in order in DTS must explicitly
add config on the specific defconfig file.

Cc: Olliver Schinagl <oliver@schinagl.nl>
Cc: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 configs/A20-OLinuXino-Lime2-eMMC_defconfig   | 1 +
 configs/A20-Olimex-SOM204-EVB-eMMC_defconfig | 1 +
 configs/Sinlinx_SinA33_defconfig             | 1 +
 configs/amarula_a64_relic_defconfig          | 1 +
 configs/parrot_r16_defconfig                 | 1 +
 drivers/fastboot/Kconfig                     | 3 +--
 6 files changed, 6 insertions(+), 2 deletions(-)

Comments

Maxime Ripard Aug. 20, 2018, 11:44 a.m. UTC | #1
On Sun, Aug 19, 2018 at 07:26:44PM +0530, Jagan Teki wrote:
> Usually eMMC is default mmc device for fastboot.
> 
> By enabling DM_MMC, the mmc devices are probed as per
> DT status not with respect to MMC_SUNXI_SLOT_EXTRA in
> U-Boot proper.
> 
> Allwinner SoC has maximum of 4 mmc controllers start from
> mmc0...mmc3 on which mmc2 can be used an eMMC controller
> eventhough mmc3 some boards used as eMMC.
> 
> So, update the default fastboot device as 2 to make the
> standard usage irrespective of DT node status.
> 
> Other corner cases like different device usage, or specific
> mmc node status is not enabled in order in DTS must explicitly
> add config on the specific defconfig file.
> 
> Cc: Olliver Schinagl <oliver@schinagl.nl>
> Cc: Chen-Yu Tsai <wens@csie.org>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>

This breaks all existing users, since if DM_MMC isn't set (and it
isn't at the moment), the MMC IDs won't change, and you're changing it
from either 0 or 1 to 2.

Can't we have a DT property instead? It looks much better than having
to deal with a non stable ID in Kconfig.

Maxime
Jagan Teki Aug. 21, 2018, 4:57 p.m. UTC | #2
On Mon, Aug 20, 2018 at 5:14 PM, Maxime Ripard
<maxime.ripard@bootlin.com> wrote:
> On Sun, Aug 19, 2018 at 07:26:44PM +0530, Jagan Teki wrote:
>> Usually eMMC is default mmc device for fastboot.
>>
>> By enabling DM_MMC, the mmc devices are probed as per
>> DT status not with respect to MMC_SUNXI_SLOT_EXTRA in
>> U-Boot proper.
>>
>> Allwinner SoC has maximum of 4 mmc controllers start from
>> mmc0...mmc3 on which mmc2 can be used an eMMC controller
>> eventhough mmc3 some boards used as eMMC.
>>
>> So, update the default fastboot device as 2 to make the
>> standard usage irrespective of DT node status.
>>
>> Other corner cases like different device usage, or specific
>> mmc node status is not enabled in order in DTS must explicitly
>> add config on the specific defconfig file.
>>
>> Cc: Olliver Schinagl <oliver@schinagl.nl>
>> Cc: Chen-Yu Tsai <wens@csie.org>
>> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
>
> This breaks all existing users, since if DM_MMC isn't set (and it
> isn't at the moment), the MMC IDs won't change, and you're changing it
> from either 0 or 1 to 2.

True, bisectable issue. will take care on next version.

>
> Can't we have a DT property instead? It looks much better than having
> to deal with a non stable ID in Kconfig.

What do you mean by DT property handle? mmc2 is eMMC in all sunXi
isn't? ie reason I make it default.
Maxime Ripard Aug. 22, 2018, 4:43 p.m. UTC | #3
On Tue, Aug 21, 2018 at 10:27:38PM +0530, Jagan Teki wrote:
> On Mon, Aug 20, 2018 at 5:14 PM, Maxime Ripard
> <maxime.ripard@bootlin.com> wrote:
> > On Sun, Aug 19, 2018 at 07:26:44PM +0530, Jagan Teki wrote:
> >> Usually eMMC is default mmc device for fastboot.
> >>
> >> By enabling DM_MMC, the mmc devices are probed as per
> >> DT status not with respect to MMC_SUNXI_SLOT_EXTRA in
> >> U-Boot proper.
> >>
> >> Allwinner SoC has maximum of 4 mmc controllers start from
> >> mmc0...mmc3 on which mmc2 can be used an eMMC controller
> >> eventhough mmc3 some boards used as eMMC.
> >>
> >> So, update the default fastboot device as 2 to make the
> >> standard usage irrespective of DT node status.
> >>
> >> Other corner cases like different device usage, or specific
> >> mmc node status is not enabled in order in DTS must explicitly
> >> add config on the specific defconfig file.
> >>
> >> Cc: Olliver Schinagl <oliver@schinagl.nl>
> >> Cc: Chen-Yu Tsai <wens@csie.org>
> >> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> >
> > This breaks all existing users, since if DM_MMC isn't set (and it
> > isn't at the moment), the MMC IDs won't change, and you're changing it
> > from either 0 or 1 to 2.
> 
> True, bisectable issue. will take care on next version.
> 
> >
> > Can't we have a DT property instead? It looks much better than having
> > to deal with a non stable ID in Kconfig.
> 
> What do you mean by DT property handle? mmc2 is eMMC in all sunXi
> isn't? ie reason I make it default.

I meant to select the fastboot and environment devices. That way, each
board can select the one it wants in a truly deterministic way.

Maxime
Olliver Schinagl Aug. 22, 2018, 6:56 p.m. UTC | #4
On 21-08-18 18:57, Jagan Teki wrote:
> On Mon, Aug 20, 2018 at 5:14 PM, Maxime Ripard
> <maxime.ripard@bootlin.com> wrote:
>> On Sun, Aug 19, 2018 at 07:26:44PM +0530, Jagan Teki wrote:
>>> Usually eMMC is default mmc device for fastboot.
>>>
>>> By enabling DM_MMC, the mmc devices are probed as per
>>> DT status not with respect to MMC_SUNXI_SLOT_EXTRA in
>>> U-Boot proper.
>>>
>>> Allwinner SoC has maximum of 4 mmc controllers start from
>>> mmc0...mmc3 on which mmc2 can be used an eMMC controller
>>> eventhough mmc3 some boards used as eMMC.
>>>
>>> So, update the default fastboot device as 2 to make the
>>> standard usage irrespective of DT node status.
>>>
>>> Other corner cases like different device usage, or specific
>>> mmc node status is not enabled in order in DTS must explicitly
>>> add config on the specific defconfig file.
>>>
>>> Cc: Olliver Schinagl <oliver@schinagl.nl>
>>> Cc: Chen-Yu Tsai <wens@csie.org>
>>> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
>> This breaks all existing users, since if DM_MMC isn't set (and it
>> isn't at the moment), the MMC IDs won't change, and you're changing it
>> from either 0 or 1 to 2.
> True, bisectable issue. will take care on next version.
>
>> Can't we have a DT property instead? It looks much better than having
>> to deal with a non stable ID in Kconfig.
> What do you mean by DT property handle? mmc2 is eMMC in all sunXi
> isn't? ie reason I make it default.
That's absurdly naive :)

eMMC is whatever the board designer decides to hook it up to (and one
can even argue that there could be vendor trees that also have strange
designs)

While from a 'hacker' standpoint mmc0 SD, mmc2 eMMC makes tons of sense,
as those are the allwinner default bootable mmc interfaces, a proper
product may opt to put eMMC on mmc0 for 'security reasons'. E.g. secure
boot and what not. (Lets not get into discussions about how to secure
our platform or how secure it really is)

Further more, a designed board may use an SPI to boot, and end up with
eMMC on mmc3 due to the fact all other pins are in use.

Making this assumption that mmc2 is always eMMC (if mmc is used) is very
naive in my opinion and may bite us in the ass eventually.

Having a default, and letting it be overridable, is not a big issue of
course :)

Olliver
Jagan Teki Aug. 27, 2018, 9:20 a.m. UTC | #5
On Wed, Aug 22, 2018 at 10:13 PM, Maxime Ripard
<maxime.ripard@bootlin.com> wrote:
> On Tue, Aug 21, 2018 at 10:27:38PM +0530, Jagan Teki wrote:
>> On Mon, Aug 20, 2018 at 5:14 PM, Maxime Ripard
>> <maxime.ripard@bootlin.com> wrote:
>> > On Sun, Aug 19, 2018 at 07:26:44PM +0530, Jagan Teki wrote:
>> >> Usually eMMC is default mmc device for fastboot.
>> >>
>> >> By enabling DM_MMC, the mmc devices are probed as per
>> >> DT status not with respect to MMC_SUNXI_SLOT_EXTRA in
>> >> U-Boot proper.
>> >>
>> >> Allwinner SoC has maximum of 4 mmc controllers start from
>> >> mmc0...mmc3 on which mmc2 can be used an eMMC controller
>> >> eventhough mmc3 some boards used as eMMC.
>> >>
>> >> So, update the default fastboot device as 2 to make the
>> >> standard usage irrespective of DT node status.
>> >>
>> >> Other corner cases like different device usage, or specific
>> >> mmc node status is not enabled in order in DTS must explicitly
>> >> add config on the specific defconfig file.
>> >>
>> >> Cc: Olliver Schinagl <oliver@schinagl.nl>
>> >> Cc: Chen-Yu Tsai <wens@csie.org>
>> >> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
>> >
>> > This breaks all existing users, since if DM_MMC isn't set (and it
>> > isn't at the moment), the MMC IDs won't change, and you're changing it
>> > from either 0 or 1 to 2.
>>
>> True, bisectable issue. will take care on next version.
>>
>> >
>> > Can't we have a DT property instead? It looks much better than having
>> > to deal with a non stable ID in Kconfig.
>>
>> What do you mean by DT property handle? mmc2 is eMMC in all sunXi
>> isn't? ie reason I make it default.
>
> I meant to select the fastboot and environment devices. That way, each
> board can select the one it wants in a truly deterministic way.

ie what get_env_fat_dev_part is doing. Identify the dev no.of
initialized mmc or emmc. are you referring something like this?
Maxime Ripard Aug. 31, 2018, 10:14 a.m. UTC | #6
On Mon, Aug 27, 2018 at 02:50:32PM +0530, Jagan Teki wrote:
> On Wed, Aug 22, 2018 at 10:13 PM, Maxime Ripard
> <maxime.ripard@bootlin.com> wrote:
> > On Tue, Aug 21, 2018 at 10:27:38PM +0530, Jagan Teki wrote:
> >> On Mon, Aug 20, 2018 at 5:14 PM, Maxime Ripard
> >> <maxime.ripard@bootlin.com> wrote:
> >> > On Sun, Aug 19, 2018 at 07:26:44PM +0530, Jagan Teki wrote:
> >> >> Usually eMMC is default mmc device for fastboot.
> >> >>
> >> >> By enabling DM_MMC, the mmc devices are probed as per
> >> >> DT status not with respect to MMC_SUNXI_SLOT_EXTRA in
> >> >> U-Boot proper.
> >> >>
> >> >> Allwinner SoC has maximum of 4 mmc controllers start from
> >> >> mmc0...mmc3 on which mmc2 can be used an eMMC controller
> >> >> eventhough mmc3 some boards used as eMMC.
> >> >>
> >> >> So, update the default fastboot device as 2 to make the
> >> >> standard usage irrespective of DT node status.
> >> >>
> >> >> Other corner cases like different device usage, or specific
> >> >> mmc node status is not enabled in order in DTS must explicitly
> >> >> add config on the specific defconfig file.
> >> >>
> >> >> Cc: Olliver Schinagl <oliver@schinagl.nl>
> >> >> Cc: Chen-Yu Tsai <wens@csie.org>
> >> >> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> >> >
> >> > This breaks all existing users, since if DM_MMC isn't set (and it
> >> > isn't at the moment), the MMC IDs won't change, and you're changing it
> >> > from either 0 or 1 to 2.
> >>
> >> True, bisectable issue. will take care on next version.
> >>
> >> >
> >> > Can't we have a DT property instead? It looks much better than having
> >> > to deal with a non stable ID in Kconfig.
> >>
> >> What do you mean by DT property handle? mmc2 is eMMC in all sunXi
> >> isn't? ie reason I make it default.
> >
> > I meant to select the fastboot and environment devices. That way, each
> > board can select the one it wants in a truly deterministic way.
> 
> ie what get_env_fat_dev_part is doing. Identify the dev no.of
> initialized mmc or emmc. are you referring something like this?

Yep, but through a DT property instead of some code.

Maxime
diff mbox series

Patch

diff --git a/configs/A20-OLinuXino-Lime2-eMMC_defconfig b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
index 2851a461e8..8cedf9cf24 100644
--- a/configs/A20-OLinuXino-Lime2-eMMC_defconfig
+++ b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
@@ -30,4 +30,5 @@  CONFIG_SCSI=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig b/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig
index 3bb8c4c7e6..c96d7ada7c 100644
--- a/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig
+++ b/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig
@@ -30,4 +30,5 @@  CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_SCSI=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Sinlinx_SinA33_defconfig b/configs/Sinlinx_SinA33_defconfig
index 7f5aaab5fb..80741b58f9 100644
--- a/configs/Sinlinx_SinA33_defconfig
+++ b/configs/Sinlinx_SinA33_defconfig
@@ -22,5 +22,6 @@  CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
 CONFIG_USB_FUNCTION_MASS_STORAGE=y
diff --git a/configs/amarula_a64_relic_defconfig b/configs/amarula_a64_relic_defconfig
index b72cbfabc6..caeb3f6008 100644
--- a/configs/amarula_a64_relic_defconfig
+++ b/configs/amarula_a64_relic_defconfig
@@ -12,4 +12,5 @@  CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-amarula-relic"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_USB_MUSB_GADGET=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/parrot_r16_defconfig b/configs/parrot_r16_defconfig
index 936f08185f..242886f78e 100644
--- a/configs/parrot_r16_defconfig
+++ b/configs/parrot_r16_defconfig
@@ -20,5 +20,6 @@  CONFIG_CONS_INDEX=5
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
 CONFIG_USB_FUNCTION_MASS_STORAGE=y
diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index bc25ea1d9c..0e4b50e1cf 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -87,8 +87,7 @@  endchoice
 config FASTBOOT_FLASH_MMC_DEV
 	int "Define FASTBOOT MMC FLASH default device"
 	depends on FASTBOOT_FLASH_MMC
-	default 0 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1
-	default 1 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1
+	default 2 if ARCH_SUNXI
 	help
 	  The fastboot "flash" command requires additional information
 	  regarding the non-volatile storage device. Define this to