Skip to contentSkip to conversation

exynos-dwmmc: check set init priority for boot channel

PATCH Superseded Przemyslaw Marczak 5 participants 36 messages Feb 17, 2015 – Feb 24, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover exynos-dwmmc: check set init priority for boot channel

The dw mmc driver init priority was always the same: ch 0, ch 1, ch 2. On some boards (e.g. Odroid XU3) the dwmmc driver is enabled for all mmc channels. In this case, when boot device is switchable (SD/eMMC), then the MMC boot device will be 0 or 1.
Change the init priority to boot device, always init the boot device as mmc 0.
This fixes the issue with 'saveenv' command, because the MMC env device number is always the same.

Przemyslaw Marczak (4):
dm: gpio: extend gpio api by dm_gpio_set_pull()
s5p: gpio: add implementation of dm_gpio_set_pull()
mmc: exynos dwmmc: check boot mode before init dwmmc
mmc: print SD/eMMC type for inited mmc devices

 drivers/gpio/gpio-uclass.c  | 12 ++++++++++++
 drivers/gpio/s5p_gpio.c     | 11 +++++++++++
 drivers/mmc/exynos_dw_mmc.c | 11 ++++++++++-
 drivers/mmc/mmc.c           |  8 ++++++++
 include/asm-generic/gpio.h  | 12 ++++++++++++
 5 files changed, 53 insertions(+), 1 deletion(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/4 dm: gpio: extend gpio api by dm_gpio_set_pull()

This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

The pull mode is not defined so should be driver specific.

---
 drivers/gpio/gpio-uclass.c | 12 ++++++++++++
 include/asm-generic/gpio.h | 12 ++++++++++++
 2 files changed, 24 insertions(+)
drivers/gpio/gpio-uclass.c +12 -0
index a69bbd2..48b31c2 100644
@@ -321,6 +321,18 @@ int dm_gpio_set_value(struct gpio_desc *desc, int value)
 	return 0;
 }
 
+int dm_gpio_set_pull(struct gpio_desc *desc, int pull)
+{
+	int ret;
+
+	ret = check_reserved(desc, "set_pull");
+	if (ret)
+		return ret;
+
+	gpio_get_ops(desc->dev)->set_pull(desc->dev, desc->offset, pull);
+	return 0;
+}
+
 int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
 {
 	struct udevice *dev = desc->dev;
include/asm-generic/gpio.h +12 -0
index 3b96b82..7e0d426 100644
@@ -241,6 +241,7 @@ struct dm_gpio_ops {
 				int value);
 	int (*get_value)(struct udevice *dev, unsigned offset);
 	int (*set_value)(struct udevice *dev, unsigned offset, int value);
+	int (*set_pull)(struct udevice *dev, unsigned offset, int pull);
 	/**
 	 * get_function() Get the GPIO function
 	 *
@@ -479,6 +480,7 @@ int gpio_free_list_nodev(struct gpio_desc *desc, int count);
 
 /**
  * dm_gpio_get_value() - Get the value of a GPIO
+
  *
  * This is the driver model version of the existing gpio_get_value() function
  * and should be used instead of that.
@@ -495,6 +497,16 @@ int dm_gpio_get_value(struct gpio_desc *desc);
 int dm_gpio_set_value(struct gpio_desc *desc, int value);
 
 /**
+ * dm_gpio_set_pull() - Set the pull-up/down value of a GPIO
+ *
+ * @desc:	GPIO description containing device, offset and flags,
+ *		previously returned by gpio_request_by_name()
+ * @pull:	GPIO pull value - driver specific
+ * @return 0 on success or -ve on error
+*/
+int dm_gpio_set_pull(struct gpio_desc *desc, int pull);
+
+/**
  * dm_gpio_set_dir() - Set the direction for a GPIO
  *
  * This sets up the direction according tot the provided flags. It will do
Signature · 1 line
1.9.1
#2 lore raw

PATCH 1/4 dm: gpio: extend gpio api by dm_gpio_set_pull()

+Stephen who might have an opinion on this.

Hi Przemyslaw,

Quoted 5 lines · Przemyslaw Marczak

This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

The pull mode is not defined so should be driver specific.

It's good to implement this, but I think you should try to have a standard interface. You could define the options you want to support and pass in a standard value.

Otherwise we are not really providing a driver abstraction, only an interface.

Quoted 15 lines
---
 drivers/gpio/gpio-uclass.c | 12 ++++++++++++
 include/asm-generic/gpio.h | 12 ++++++++++++
 2 files changed, 24 insertions(+)
drivers/gpio/gpio-uclass.c +0 -0
index a69bbd2..48b31c2 100644
@@ -321,6 +321,18 @@ int dm_gpio_set_value(struct gpio_desc *desc, int value)
        return 0;
 }

drivers/gpio/gpio-uclass.c int dm_gpio_set_value(struct gpio_desc *desc, int value) · line 332

Quoted 10 lines
drivers/gpio/gpio-uclass.c +9 -0
 
+int dm_gpio_set_pull(struct gpio_desc *desc, int pull)
+{
+       int ret;
+
+       ret = check_reserved(desc, "set_pull");
+       if (ret)
+               return ret;
+
+       gpio_get_ops(desc->dev)->set_pull(desc->dev, desc->offset, pull);

Should return this value.

Quoted 44 lines
drivers/gpio/gpio-uclass.c +3 -0
+       return 0;
+}
+
 int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
 {
        struct udevice *dev = desc->dev;
include/asm-generic/gpio.h +12 -1
index 3b96b82..7e0d426 100644
@@ -241,6 +241,7 @@ struct dm_gpio_ops {
                                int value);
        int (*get_value)(struct udevice *dev, unsigned offset);
        int (*set_value)(struct udevice *dev, unsigned offset, int value);
+       int (*set_pull)(struct udevice *dev, unsigned offset, int pull);
        /**
         * get_function() Get the GPIO function
         *
@@ -479,6 +480,7 @@ int gpio_free_list_nodev(struct gpio_desc *desc, int count);
 
 /**
  * dm_gpio_get_value() - Get the value of a GPIO
+
  *
  * This is the driver model version of the existing gpio_get_value() function
  * and should be used instead of that.
@@ -495,6 +497,16 @@ int dm_gpio_get_value(struct gpio_desc *desc);
 int dm_gpio_set_value(struct gpio_desc *desc, int value);
 
 /**
+ * dm_gpio_set_pull() - Set the pull-up/down value of a GPIO
+ *
+ * @desc:      GPIO description containing device, offset and flags,
+ *             previously returned by gpio_request_by_name()
+ * @pull:      GPIO pull value - driver specific
+ * @return 0 on success or -ve on error
+*/
+int dm_gpio_set_pull(struct gpio_desc *desc, int pull);
+
+/**
  * dm_gpio_set_dir() - Set the direction for a GPIO
  *
  * This sets up the direction according tot the provided flags. It will do
--
Quoted 2 lines

1.9.1

Regards,
Simon

#3 lore raw

PATCH 1/4 dm: gpio: extend gpio api by dm_gpio_set_pull()

Hello,

Quoted 9 lines · Simon Glass

+Stephen who might have an opinion on this.

Hi Przemyslaw,

Quoted 4 lines · Przemyslaw Marczak

This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

Quoted 8 lines
Quoted 1 line

The pull mode is not defined so should be driver specific.

It's good to implement this, but I think you should try to have a standard interface. You could define the options you want to support and pass in a standard value.

Otherwise we are not really providing a driver abstraction, only an interface.

Ok, I will change this.

Quoted 16 lines
Quoted 16 lines
---
  drivers/gpio/gpio-uclass.c | 12 ++++++++++++
  include/asm-generic/gpio.h | 12 ++++++++++++
  2 files changed, 24 insertions(+)
drivers/gpio/gpio-uclass.c +0 -0
index a69bbd2..48b31c2 100644
@@ -321,6 +321,18 @@ int dm_gpio_set_value(struct gpio_desc *desc, int value)
         return 0;
  }
 
Quoted 12 lines

drivers/gpio/gpio-uclass.c int dm_gpio_set_value(struct gpio_desc *desc, int value) · line 332

Quoted 9 lines
drivers/gpio/gpio-uclass.c +9 -0
+int dm_gpio_set_pull(struct gpio_desc *desc, int pull)
+{
+       int ret;
+
+       ret = check_reserved(desc, "set_pull");
+       if (ret)
+               return ret;
+
+       gpio_get_ops(desc->dev)->set_pull(desc->dev, desc->offset, pull);

Should return this value.

Ok.

Quoted 41 lines
Quoted 41 lines
drivers/gpio/gpio-uclass.c +3 -0
+       return 0;
+}
+
  int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
  {
         struct udevice *dev = desc->dev;
include/asm-generic/gpio.h +12 -0
index 3b96b82..7e0d426 100644
@@ -241,6 +241,7 @@ struct dm_gpio_ops {
                                 int value);
         int (*get_value)(struct udevice *dev, unsigned offset);
         int (*set_value)(struct udevice *dev, unsigned offset, int value);
+       int (*set_pull)(struct udevice *dev, unsigned offset, int pull);
         /**
          * get_function() Get the GPIO function
          *
@@ -479,6 +480,7 @@ int gpio_free_list_nodev(struct gpio_desc *desc, int count);
 
  /**
   * dm_gpio_get_value() - Get the value of a GPIO
+
   *
   * This is the driver model version of the existing gpio_get_value() function
   * and should be used instead of that.
@@ -495,6 +497,16 @@ int dm_gpio_get_value(struct gpio_desc *desc);
  int dm_gpio_set_value(struct gpio_desc *desc, int value);
 
  /**
+ * dm_gpio_set_pull() - Set the pull-up/down value of a GPIO
+ *
+ * @desc:      GPIO description containing device, offset and flags,
+ *             previously returned by gpio_request_by_name()
+ * @pull:      GPIO pull value - driver specific
+ * @return 0 on success or -ve on error
+*/
+int dm_gpio_set_pull(struct gpio_desc *desc, int pull);
+
+/**
   * dm_gpio_set_dir() - Set the direction for a GPIO
Quoted 9 lines
Quoted 5 lines
include/asm-generic/gpio.h +0 -1
   *
   * This sets up the direction according tot the provided flags. It will do
--

1.9.1

Regards,
Simon

Sorry for the mess with this patchset (gpio+mmc).

I was testing the mmc detection by checking one of emmc pin INPUT value, after set some pull value. And such detection works, but if no card is detected, then unfortunately mmc channel is not registered and mmc rescan command will not work for it, so I dropped this code.

Best regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#4 lore raw

PATCH 1/4 dm: gpio: extend gpio api by dm_gpio_set_pull()

In reply to Simon Glass
Quoted 9 lines · Simon Glass

+Stephen who might have an opinion on this.

Hi Przemyslaw,

Quoted 4 lines · Przemyslaw Marczak

This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

Quoted 7 lines
Quoted 1 line

The pull mode is not defined so should be driver specific.

It's good to implement this, but I think you should try to have a standard interface. You could define the options you want to support and pass in a standard value.

Otherwise we are not really providing a driver abstraction, only an interface.

I don't think that pull is a GPIO-related function/property. At least on Tegra, the GPIO controller allows you to set the pin direction and the output value and that's it. Configuring pull-up/down and other IO related properties is done in the pinmux controller instead. I don't think we want a standard API that has to touch both HW modules at once. What common code needs to manipulate a GPIO's pull-up/down setting? As precedent observe that pull-up/down isn't part of the Linux kernel's GPIO API, but rather that's part of the SoC-specific pinctrl driver, which controls pinmuxing etc.

#5 lore raw

PATCH 1/4 dm: gpio: extend gpio api by dm_gpio_set_pull()

Hello,

Quoted 20 lines · Stephen Warren
Quoted 10 lines · Simon Glass

+Stephen who might have an opinion on this.

Hi Przemyslaw,

Quoted 4 lines · Przemyslaw Marczak

This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

Quoted 8 lines
Quoted 1 line

The pull mode is not defined so should be driver specific.

It's good to implement this, but I think you should try to have a standard interface. You could define the options you want to support and pass in a standard value.

Otherwise we are not really providing a driver abstraction, only an interface.

Quoted 10 lines

I don't think that pull is a GPIO-related function/property. At least on Tegra, the GPIO controller allows you to set the pin direction and the output value and that's it. Configuring pull-up/down and other IO related properties is done in the pinmux controller instead. I don't think we want a standard API that has to touch both HW modules at once. What common code needs to manipulate a GPIO's pull-up/down setting? As precedent observe that pull-up/down isn't part of the Linux kernel's GPIO API, but rather that's part of the SoC-specific pinctrl driver, which controls pinmuxing etc.

This is a quite different than in the Exynos, where all the gpio functions and properties can be set by few registers within range of each gpio port base address. So in this case we don't touch another hardware module, we modify one of available gpio related registers.

Anyway, if we want to have a single and common gpio API in the future, then I think it is better to add pull option. And the driver will implement what is required, instead of provide common and private api for each driver.

For the various devices it is unclear, what should be pinmux and what should be gpio driver.

Moreover in my opinion from the single external pin point of view the pull up/down is the property of that pin.

Actually for Exynos, the pinmux is an abstraction and uses only GPIO driver api in U-Boot.

Do we need pinmux class?

Best regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#6 lore raw

PATCH 1/4 dm: gpio: extend gpio api by dm_gpio_set_pull()

Quoted 34 lines · Przemyslaw Marczak

Hello,

Quoted 20 lines · Stephen Warren
Quoted 10 lines · Simon Glass

+Stephen who might have an opinion on this.

Hi Przemyslaw,

Quoted 4 lines · Przemyslaw Marczak

This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

Quoted 8 lines
Quoted 1 line

The pull mode is not defined so should be driver specific.

It's good to implement this, but I think you should try to have a standard interface. You could define the options you want to support and pass in a standard value.

Otherwise we are not really providing a driver abstraction, only an interface.

Quoted 10 lines

I don't think that pull is a GPIO-related function/property. At least on Tegra, the GPIO controller allows you to set the pin direction and the output value and that's it. Configuring pull-up/down and other IO related properties is done in the pinmux controller instead. I don't think we want a standard API that has to touch both HW modules at once. What common code needs to manipulate a GPIO's pull-up/down setting? As precedent observe that pull-up/down isn't part of the Linux kernel's GPIO API, but rather that's part of the SoC-specific pinctrl driver, which controls pinmuxing etc.

Quoted 7 lines

This is a quite different than in the Exynos, where all the gpio functions and properties can be set by few registers within range of each gpio port base address. So in this case we don't touch another hardware module, we modify one of available gpio related registers.

Anyway, if we want to have a single and common gpio API in the future, then I think it is better to add pull option.

Why? I'll ask again: What common driver code needs to manipulate pull-ups?

Quoted 3 lines

And the driver will
implement what is required, instead of provide common and private api for each driver.

I'm not proposing driver-specific APIs, but rather having a common GPIO API and a common pinmux API. They need to be different since different HW modules may implement the functionality.

Quoted 2 lines

For the various devices it is unclear, what should be pinmux and what should be gpio driver.

How about the following are GPIO:
* Set GPIO pin direction
* Read GPIO input
* Set GPIO output value

... and anything else is pinmux. That's the split in Linux and AFAIK it works out fine.

It'd be perfectly fine for the same driver code to implement both a GPIO and a pinmux driver, if the HW supports it.

Quoted 2 lines

Moreover in my opinion from the single external pin point of view the pull up/down is the property of that pin.

It's a property of the same pin, but semantically it's not manipulating a GPIO-related function.

Quoted 6 lines

Actually for Exynos, the pinmux is an abstraction and uses only GPIO driver api in U-Boot.

Do we need pinmux class?

Best regards,

#7 lore raw

PATCH 1/4 dm: gpio: extend gpio api by dm_gpio_set_pull()

Hello,

Quoted 40 lines · Stephen Warren
Quoted 39 lines · Przemyslaw Marczak

Hello,

Quoted 20 lines · Stephen Warren
Quoted 10 lines · Simon Glass

+Stephen who might have an opinion on this.

Hi Przemyslaw,

Quoted 4 lines · Przemyslaw Marczak

This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

Quoted 8 lines
Quoted 1 line

The pull mode is not defined so should be driver specific.

It's good to implement this, but I think you should try to have a standard interface. You could define the options you want to support and pass in a standard value.

Otherwise we are not really providing a driver abstraction, only an interface.

Quoted 10 lines

I don't think that pull is a GPIO-related function/property. At least on Tegra, the GPIO controller allows you to set the pin direction and the output value and that's it. Configuring pull-up/down and other IO related properties is done in the pinmux controller instead. I don't think we want a standard API that has to touch both HW modules at once. What common code needs to manipulate a GPIO's pull-up/down setting? As precedent observe that pull-up/down isn't part of the Linux kernel's GPIO API, but rather that's part of the SoC-specific pinctrl driver, which controls pinmuxing etc.

This is a quite different than in the Exynos, where all the gpio functions and properties can be set by few registers within range of each gpio port base address. So in this case we don't touch another hardware module, we modify one of available gpio related registers.

Quoted 5 lines
Quoted 2 lines

Anyway, if we want to have a single and common gpio API in the future, then I think it is better to add pull option.

Why? I'll ask again: What common driver code needs to manipulate pull-ups?

Please look at driver: drivers/gpio/s5p_gpio.c

It's one driver related to one gpio hardware submodule and it takes care about standard gpio properties and also mux/pull/drv/rate.

And the exynos pinmux code is only a software abstraction:
arch/arm/cpu/armv7/exynos/pinmux.c

Quoted 8 lines
Quoted 3 lines

And the driver will
implement what is required, instead of provide common and private api for each driver.

I'm not proposing driver-specific APIs, but rather having a common GPIO API and a common pinmux API. They need to be different since different HW modules may implement the functionality.

As in the above example, for the Exynos it's the one hw module, so it's simply.

Quoted 8 lines
Quoted 2 lines

For the various devices it is unclear, what should be pinmux and what should be gpio driver.

How about the following are GPIO:
* Set GPIO pin direction
* Read GPIO input
* Set GPIO output value

Quoted 6 lines

... and anything else is pinmux. That's the split in Linux and AFAIK it works out fine.

It'd be perfectly fine for the same driver code to implement both a GPIO and a pinmux driver, if the HW supports it.

Ok, I can drop this commit, since the current code works fine.

Quoted 14 lines
Quoted 2 lines

Moreover in my opinion from the single external pin point of view the pull up/down is the property of that pin.

It's a property of the same pin, but semantically it's not manipulating a GPIO-related function.

Quoted 6 lines

Actually for Exynos, the pinmux is an abstraction and uses only GPIO driver api in U-Boot.

Do we need pinmux class?

Best regards,

As I wrote in one of my previous e-mail, I was testing eMMC detect. And setting the pull was required for this, before call the pinmux for eMMC pins.
But finally the eMMC detect seem to be not useful in case of the present 'mmc rescan' command.

Best regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#8 lore raw

PATCH 1/4 dm: gpio: extend gpio api by dm_gpio_set_pull()

Quoted 50 lines · Przemyslaw Marczak

Hello,

Quoted 41 lines · Stephen Warren
Quoted 40 lines · Przemyslaw Marczak

Hello,

Quoted 20 lines · Stephen Warren
Quoted 10 lines · Simon Glass

+Stephen who might have an opinion on this.

Hi Przemyslaw,

Quoted 4 lines · Przemyslaw Marczak

This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

Quoted 8 lines
Quoted 1 line

The pull mode is not defined so should be driver specific.

It's good to implement this, but I think you should try to have a standard interface. You could define the options you want to support and pass in a standard value.

Otherwise we are not really providing a driver abstraction, only an interface.

Quoted 11 lines

I don't think that pull is a GPIO-related function/property. At least on
Tegra, the GPIO controller allows you to set the pin direction and the output value and that's it. Configuring pull-up/down and other IO related properties is done in the pinmux controller instead. I don't think we want a standard API that has to touch both HW modules at once. What common code needs to manipulate a GPIO's pull-up/down setting? As precedent observe that pull-up/down isn't part of the Linux kernel's GPIO API, but rather that's part of the SoC-specific pinctrl driver, which controls pinmuxing etc.

This is a quite different than in the Exynos, where all the gpio functions and properties can be set by few registers within range of each gpio port base address. So in this case we don't touch another hardware module, we modify one of available gpio related registers.

Quoted 5 lines
Quoted 2 lines

Anyway, if we want to have a single and common gpio API in the future, then I think it is better to add pull option.

Why? I'll ask again: What common driver code needs to manipulate pull-ups?

Quoted 7 lines

Please look at driver: drivers/gpio/s5p_gpio.c

It's one driver related to one gpio hardware submodule and it takes care about standard gpio properties and also mux/pull/drv/rate.

And the exynos pinmux code is only a software abstraction:
arch/arm/cpu/armv7/exynos/pinmux.c

I didn't want to ask which driver implements the control of pullups, but rather which other driver needs to turn pullups on/off in a standard way across multiple SoCs.

In other words, do you expect code in common/ to need to call a "set pin pullup" function? If so, then we certainly need a standard API to manipulate pullups. However if no common code needs to manipulate pullups, then I'd argue we don't actually need a common API to do this, since there's no code that would call that common API.

Quoted 44 lines
Quoted 8 lines
Quoted 3 lines

And the driver will
implement what is required, instead of provide common and private api for each driver.

I'm not proposing driver-specific APIs, but rather having a common GPIO API and a common pinmux API. They need to be different since different HW modules may implement the functionality.

As in the above example, for the Exynos it's the one hw module, so it's simply.

Quoted 8 lines
Quoted 2 lines

For the various devices it is unclear, what should be pinmux and what should be gpio driver.

How about the following are GPIO:
* Set GPIO pin direction
* Read GPIO input
* Set GPIO output value

Quoted 6 lines

... and anything else is pinmux. That's the split in Linux and AFAIK it works out fine.

It'd be perfectly fine for the same driver code to implement both a GPIO and a pinmux driver, if the HW supports it.

Ok, I can drop this commit, since the current code works fine.

Quoted 14 lines
Quoted 2 lines

Moreover in my opinion from the single external pin point of view the pull up/down is the property of that pin.

It's a property of the same pin, but semantically it's not manipulating a GPIO-related function.

Quoted 6 lines

Actually for Exynos, the pinmux is an abstraction and uses only GPIO driver api in U-Boot.

Do we need pinmux class?

Best regards,

Quoted 5 lines

As I wrote in one of my previous e-mail, I was testing eMMC detect. And setting the pull was required for this, before call the pinmux for eMMC pins.
But finally the eMMC detect seem to be not useful in case of the present 'mmc rescan' command.

Why wouldn't the pinmux driver for the whole system simply apply the board's whole pinmux configuration before initializing any IO controller drivers? IO controller drivers shouldn't have to initialize board-/SoC-specific pinmux, but the board-/SoC-specfic code should do so.

At most, the eMMC driver should call a function such as pinmux_emmc(), and the board/SoC code should implement that as appropriate for that board. The eMMC driver shouldn't have to know about applying specific pullups/downs to specific pins (since those settings and pins are likely board-/SoC-specific, and drivers shouldn't know about board-/SoC-specific details). The only exception would be if the standard IO protocol requires pullups to be changed during regular operation. In which case, a specific callback from the driver could be added for each protocol-mandated configuration change, thus keeping the IO controller driver still completely isolated from details of the pins and pinmux APIs etc.

#9 lore raw

PATCH 1/4 dm: gpio: extend gpio api by dm_gpio_set_pull()

Hi,

Quoted 74 lines · Stephen Warren
Quoted 60 lines · Przemyslaw Marczak

Hello,

Quoted 48 lines · Stephen Warren
Quoted 46 lines · Przemyslaw Marczak

Hello,

Quoted 25 lines · Stephen Warren
Quoted 15 lines · Simon Glass

+Stephen who might have an opinion on this.

Hi Przemyslaw,

Quoted 6 lines · Przemyslaw Marczak

This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

The pull mode is not defined so should be driver specific.

Quoted 6 lines

It's good to implement this, but I think you should try to have a standard interface. You could define the options you want to support and pass in a standard value.

Otherwise we are not really providing a driver abstraction, only an interface.

Quoted 11 lines

I don't think that pull is a GPIO-related function/property. At least on
Tegra, the GPIO controller allows you to set the pin direction and the output value and that's it. Configuring pull-up/down and other IO related properties is done in the pinmux controller instead. I don't think we want a standard API that has to touch both HW modules at once. What common code needs to manipulate a GPIO's pull-up/down setting? As precedent observe that pull-up/down isn't part of the Linux kernel's GPIO API, but rather that's part of the SoC-specific pinctrl driver, which controls pinmuxing etc.

This is a quite different than in the Exynos, where all the gpio functions and properties can be set by few registers within range of each gpio port base address. So in this case we don't touch another hardware module, we modify one of available gpio related registers.

Quoted 6 lines
Quoted 2 lines

Anyway, if we want to have a single and common gpio API in the future, then I think it is better to add pull option.

Why? I'll ask again: What common driver code needs to manipulate pull-ups?

Quoted 7 lines

Please look at driver: drivers/gpio/s5p_gpio.c

It's one driver related to one gpio hardware submodule and it takes care about standard gpio properties and also mux/pull/drv/rate.

And the exynos pinmux code is only a software abstraction:
arch/arm/cpu/armv7/exynos/pinmux.c

I didn't want to ask which driver implements the control of pullups, but rather which other driver needs to turn pullups on/off in a standard way across multiple SoCs.

Quoted 5 lines

In other words, do you expect code in common/ to need to call a "set pin pullup" function? If so, then we certainly need a standard API to manipulate pullups. However if no common code needs to manipulate pullups, then I'd argue we don't actually need a common API to do this, since there's no code that would call that common API.

We do currently use the GPIO to handle pullup/pulldown for some boards so until we have a pinmux API (which might be a long while) it seems reasonable for it to live there.

If not, does anyone plan to write such an API?

Quoted 63 lines
Quoted 51 lines
Quoted 4 lines
Quoted 4 lines

And the driver will

Quoted 8 lines
Quoted 2 lines

implement what is required, instead of provide common and private api for each driver.

I'm not proposing driver-specific APIs, but rather having a common GPIO API and a common pinmux API. They need to be different since different HW modules may implement the functionality.

As in the above example, for the Exynos it's the one hw module, so it's simply.

Quoted 9 lines
Quoted 2 lines

For the various devices it is unclear, what should be pinmux and what should be gpio driver.

How about the following are GPIO:
* Set GPIO pin direction
* Read GPIO input
* Set GPIO output value

Quoted 6 lines

... and anything else is pinmux. That's the split in Linux and AFAIK it works out fine.

It'd be perfectly fine for the same driver code to implement both a GPIO and a pinmux driver, if the HW supports it.

Ok, I can drop this commit, since the current code works fine.

Quoted 4 lines
Quoted 2 lines

Moreover in my opinion from the single external pin point of view the pull up/down is the property of that pin.

Quoted 12 lines

It's a property of the same pin, but semantically it's not manipulating a GPIO-related function.

Quoted 6 lines

Actually for Exynos, the pinmux is an abstraction and uses only GPIO driver api in U-Boot.

Do we need pinmux class?

Best regards,

Quoted 5 lines

As I wrote in one of my previous e-mail, I was testing eMMC detect. And setting the pull was required for this, before call the pinmux for eMMC pins.
But finally the eMMC detect seem to be not useful in case of the present 'mmc rescan' command.

Why wouldn't the pinmux driver for the whole system simply apply the board's whole pinmux configuration before initializing any IO controller drivers? IO controller drivers shouldn't have to initialize board-/SoC-specific pinmux, but the board-/SoC-specfic code should do so.

Quoted 5 lines

At most, the eMMC driver should call a function such as pinmux_emmc(), and the board/SoC code should implement that as appropriate for that board. The eMMC driver shouldn't have to know about applying specific pullups/downs to specific pins (since those settings and pins are likely board-/SoC-specific, and drivers shouldn't know about board-/SoC-specific details). The only

No this way lies madness. It is how things work on Jetson and Nyan. Loads of opaque tables and no idea what the pins are connected to. It has some value for pins that U-Boot doesn't use (so we are just setting them up for Linux) but even then it is really opaque.

We can't even sent patches to the file because it is auto-generated from a tool in another repo. Tiny differences between boards are hidden because we repeat all the information again with just a line or two of changes. I really don't want exynos to go that way.

Quoted 5 lines

exception would be if the standard IO protocol requires pullups to be changed during regular operation. In which case, a specific callback from the driver could be added for each protocol-mandated configuration change, thus keeping the IO controller driver still completely isolated from details of the pins and pinmux APIs etc.

This is like the 'funcmux' in Tegra I think. I think this is more useful and we should use it to set up all peripheral pins. We can review the code, see changes, understand what they relate to, etc.

Anyway this all seems off-topic from this patch.

Unless someone plans to write a pinmux subsystem for U-Boot (which I agree would be better) I think the general approach of this patch is good.

Regards,
Simon

#10 lore raw

PATCH 1/4 dm: gpio: extend gpio api by dm_gpio_set_pull()

Hello Simon,

Quoted 83 lines · Simon Glass

Hi,

Quoted 74 lines · Stephen Warren
Quoted 60 lines · Przemyslaw Marczak

Hello,

Quoted 48 lines · Stephen Warren
Quoted 46 lines · Przemyslaw Marczak

Hello,

Quoted 25 lines · Stephen Warren
Quoted 15 lines · Simon Glass

+Stephen who might have an opinion on this.

Hi Przemyslaw,

Quoted 6 lines · Przemyslaw Marczak

This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

The pull mode is not defined so should be driver specific.

Quoted 6 lines

It's good to implement this, but I think you should try to have a standard interface. You could define the options you want to support and pass in a standard value.

Otherwise we are not really providing a driver abstraction, only an interface.

Quoted 11 lines

I don't think that pull is a GPIO-related function/property. At least on
Tegra, the GPIO controller allows you to set the pin direction and the output value and that's it. Configuring pull-up/down and other IO related properties is done in the pinmux controller instead. I don't think we want a standard API that has to touch both HW modules at once. What common code needs to manipulate a GPIO's pull-up/down setting? As precedent observe that pull-up/down isn't part of the Linux kernel's GPIO API, but rather that's part of the SoC-specific pinctrl driver, which controls pinmuxing etc.

This is a quite different than in the Exynos, where all the gpio functions and properties can be set by few registers within range of each gpio port base address. So in this case we don't touch another hardware module, we modify one of available gpio related registers.

Quoted 6 lines
Quoted 2 lines

Anyway, if we want to have a single and common gpio API in the future, then I think it is better to add pull option.

Why? I'll ask again: What common driver code needs to manipulate pull-ups?

Quoted 7 lines

Please look at driver: drivers/gpio/s5p_gpio.c

It's one driver related to one gpio hardware submodule and it takes care about standard gpio properties and also mux/pull/drv/rate.

And the exynos pinmux code is only a software abstraction:
arch/arm/cpu/armv7/exynos/pinmux.c

I didn't want to ask which driver implements the control of pullups, but rather which other driver needs to turn pullups on/off in a standard way across multiple SoCs.

Quoted 5 lines

In other words, do you expect code in common/ to need to call a "set pin pullup" function? If so, then we certainly need a standard API to manipulate pullups. However if no common code needs to manipulate pullups, then I'd argue we don't actually need a common API to do this, since there's no code that would call that common API.

Quoted 6 lines

We do currently use the GPIO to handle pullup/pulldown for some boards so until we have a pinmux API (which might be a long while) it seems reasonable for it to live there.

If not, does anyone plan to write such an API?

Right, we uses this in most Exynos boards. But the boards uses direct calls to s5p gpio driver, without uclass.
I wonder if wouldn't it be better and faster to leave the board low-level init routines as they are now.

Quoted 89 lines
Quoted 63 lines
Quoted 51 lines
Quoted 4 lines
Quoted 4 lines

And the driver will

Quoted 8 lines
Quoted 2 lines

implement what is required, instead of provide common and private api for each driver.

I'm not proposing driver-specific APIs, but rather having a common GPIO API and a common pinmux API. They need to be different since different HW modules may implement the functionality.

As in the above example, for the Exynos it's the one hw module, so it's simply.

Quoted 9 lines
Quoted 2 lines

For the various devices it is unclear, what should be pinmux and what should be gpio driver.

How about the following are GPIO:
* Set GPIO pin direction
* Read GPIO input
* Set GPIO output value

Quoted 6 lines

... and anything else is pinmux. That's the split in Linux and AFAIK it works out fine.

It'd be perfectly fine for the same driver code to implement both a GPIO and a pinmux driver, if the HW supports it.

Ok, I can drop this commit, since the current code works fine.

Quoted 4 lines
Quoted 2 lines

Moreover in my opinion from the single external pin point of view the pull up/down is the property of that pin.

Quoted 12 lines

It's a property of the same pin, but semantically it's not manipulating a GPIO-related function.

Quoted 6 lines

Actually for Exynos, the pinmux is an abstraction and uses only GPIO driver api in U-Boot.

Do we need pinmux class?

Best regards,

Quoted 5 lines

As I wrote in one of my previous e-mail, I was testing eMMC detect. And setting the pull was required for this, before call the pinmux for eMMC pins.
But finally the eMMC detect seem to be not useful in case of the present 'mmc rescan' command.

Why wouldn't the pinmux driver for the whole system simply apply the board's whole pinmux configuration before initializing any IO controller drivers? IO controller drivers shouldn't have to initialize board-/SoC-specific pinmux, but the board-/SoC-specfic code should do so.

Quoted 5 lines

At most, the eMMC driver should call a function such as pinmux_emmc(), and the board/SoC code should implement that as appropriate for that board. The eMMC driver shouldn't have to know about applying specific pullups/downs to specific pins (since those settings and pins are likely board-/SoC-specific, and drivers shouldn't know about board-/SoC-specific details). The only

No this way lies madness. It is how things work on Jetson and Nyan. Loads of opaque tables and no idea what the pins are connected to. It has some value for pins that U-Boot doesn't use (so we are just setting them up for Linux) but even then it is really opaque.

We can't even sent patches to the file because it is auto-generated from a tool in another repo. Tiny differences between boards are hidden because we repeat all the information again with just a line or two of changes. I really don't want exynos to go that way.

Quoted 5 lines

exception would be if the standard IO protocol requires pullups to be changed during regular operation. In which case, a specific callback from the driver could be added for each protocol-mandated configuration change, thus keeping the IO controller driver still completely isolated from details of the pins and pinmux APIs etc.

This is like the 'funcmux' in Tegra I think. I think this is more useful and we should use it to set up all peripheral pins. We can review the code, see changes, understand what they relate to, etc.

Quoted 9 lines

Anyway this all seems off-topic from this patch.

Unless someone plans to write a pinmux subsystem for U-Boot (which I agree would be better) I think the general approach of this patch is good.

Regards,
Simon

Ok, so there are two next versions of this patch-set. Please decide, which one is better.

For me, at present, the current s5p_gpio api works fine for all the exynos based boards.
Introducing the pinmux uclass is not a quick task, now I'm trying to focus on pmic.

Best regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#11 lore raw

PATCH 1/4 dm: gpio: extend gpio api by dm_gpio_set_pull()

Hi,

Quoted 220 lines · Przemyslaw Marczak

Hello Simon,

Quoted 97 lines · Simon Glass

Hi,

Quoted 86 lines · Stephen Warren
Quoted 70 lines · Przemyslaw Marczak

Hello,

Quoted 55 lines · Stephen Warren
Quoted 52 lines · Przemyslaw Marczak

Hello,

Quoted 30 lines · Stephen Warren
Quoted 18 lines · Simon Glass

+Stephen who might have an opinion on this.

Hi Przemyslaw,

Quoted 7 lines · Przemyslaw Marczak

This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

The pull mode is not defined so should be driver specific.

Quoted 6 lines

It's good to implement this, but I think you should try to have a standard interface. You could define the options you want to support and pass in a standard value.

Otherwise we are not really providing a driver abstraction, only an interface.

Quoted 11 lines

I don't think that pull is a GPIO-related function/property. At least on
Tegra, the GPIO controller allows you to set the pin direction and the output value and that's it. Configuring pull-up/down and other IO related properties is done in the pinmux controller instead. I don't think we want a standard API that has to touch both HW modules at once. What common code needs to manipulate a GPIO's pull-up/down setting? As precedent observe that pull-up/down isn't part of the Linux kernel's GPIO API, but rather that's part of the SoC-specific pinctrl driver, which controls pinmuxing etc.

This is a quite different than in the Exynos, where all the gpio functions and properties can be set by few registers within range of each gpio port base address. So in this case we don't touch another hardware module, we modify one of available gpio related registers.

Quoted 7 lines
Quoted 2 lines

Anyway, if we want to have a single and common gpio API in the future, then I think it is better to add pull option.

Why? I'll ask again: What common driver code needs to manipulate pull-ups?

Quoted 7 lines

Please look at driver: drivers/gpio/s5p_gpio.c

It's one driver related to one gpio hardware submodule and it takes care about standard gpio properties and also mux/pull/drv/rate.

And the exynos pinmux code is only a software abstraction:
arch/arm/cpu/armv7/exynos/pinmux.c

I didn't want to ask which driver implements the control of pullups, but rather which other driver needs to turn pullups on/off in a standard way across multiple SoCs.

Quoted 5 lines

In other words, do you expect code in common/ to need to call a "set pin pullup" function? If so, then we certainly need a standard API to manipulate pullups. However if no common code needs to manipulate pullups, then I'd argue we don't actually need a common API to do this, since there's no code that would call that common API.

Quoted 6 lines

We do currently use the GPIO to handle pullup/pulldown for some boards so until we have a pinmux API (which might be a long while) it seems reasonable for it to live there.

If not, does anyone plan to write such an API?

Right, we uses this in most Exynos boards. But the boards uses direct calls to s5p gpio driver, without uclass. I wonder if wouldn't it be better and faster to leave the board low-level init routines as they are now.

Quoted 97 lines
Quoted 69 lines
Quoted 56 lines
Quoted 5 lines
Quoted 5 lines

And the driver will

Quoted 9 lines
Quoted 2 lines

implement what is required, instead of provide common and private api for each driver.

I'm not proposing driver-specific APIs, but rather having a common GPIO API and a common pinmux API. They need to be different since different HW modules may implement the functionality.

As in the above example, for the Exynos it's the one hw module, so it's simply.

Quoted 10 lines
Quoted 2 lines

For the various devices it is unclear, what should be pinmux and what should be gpio driver.

How about the following are GPIO:
* Set GPIO pin direction
* Read GPIO input
* Set GPIO output value

Quoted 6 lines

... and anything else is pinmux. That's the split in Linux and AFAIK it works out fine.

It'd be perfectly fine for the same driver code to implement both a GPIO and a pinmux driver, if the HW supports it.

Ok, I can drop this commit, since the current code works fine.

Quoted 5 lines
Quoted 2 lines

Moreover in my opinion from the single external pin point of view the pull up/down is the property of that pin.

Quoted 13 lines

It's a property of the same pin, but semantically it's not manipulating a GPIO-related function.

Quoted 6 lines

Actually for Exynos, the pinmux is an abstraction and uses only GPIO driver api in U-Boot.

Do we need pinmux class?

Best regards,

Quoted 5 lines

As I wrote in one of my previous e-mail, I was testing eMMC detect. And setting the pull was required for this, before call the pinmux for eMMC pins.
But finally the eMMC detect seem to be not useful in case of the present 'mmc rescan' command.

Why wouldn't the pinmux driver for the whole system simply apply the board's whole pinmux configuration before initializing any IO controller drivers? IO controller drivers shouldn't have to initialize board-/SoC-specific pinmux, but the board-/SoC-specfic code should do so.

Quoted 5 lines

At most, the eMMC driver should call a function such as pinmux_emmc(), and the board/SoC code should implement that as appropriate for that board. The eMMC driver shouldn't have to know about applying specific pullups/downs to specific pins (since those settings and pins are likely board-/SoC-specific, and drivers shouldn't know about board-/SoC-specific details). The only

No this way lies madness. It is how things work on Jetson and Nyan. Loads of opaque tables and no idea what the pins are connected to. It has some value for pins that U-Boot doesn't use (so we are just setting them up for Linux) but even then it is really opaque.

We can't even sent patches to the file because it is auto-generated from a tool in another repo. Tiny differences between boards are hidden because we repeat all the information again with just a line or two of changes. I really don't want exynos to go that way.

Quoted 5 lines

exception would be if the standard IO protocol requires pullups to be changed during regular operation. In which case, a specific callback from the driver could be added for each protocol-mandated configuration change, thus keeping the IO controller driver still completely isolated from details of the pins and pinmux APIs etc.

This is like the 'funcmux' in Tegra I think. I think this is more useful and we should use it to set up all peripheral pins. We can review the code, see changes, understand what they relate to, etc.

Quoted 9 lines

Anyway this all seems off-topic from this patch.

Unless someone plans to write a pinmux subsystem for U-Boot (which I agree would be better) I think the general approach of this patch is good.

Regards,
Simon

Quoted 5 lines

Ok, so there are two next versions of this patch-set. Please decide, which one is better.

For me, at present, the current s5p_gpio api works fine for all the exynos based boards. Introducing the pinmux uclass is not a quick task, now I'm trying to focus on pmic.

OK, then I think we should probably leave it as it is. If we add pull-ups to driver model it should be done with pinctl as Stephen says. I doubt this is a huge task, since we can likely port over the code from Linux. But for now I think we should keep with the s5p API until someone takes on pinctl.

Regards,
Simon

#12 lore raw

PATCH 1/4 dm: gpio: extend gpio api by dm_gpio_set_pull()

Hello,

Quoted 229 lines · Simon Glass

Hi,

Quoted 220 lines · Przemyslaw Marczak

Hello Simon,

Quoted 97 lines · Simon Glass

Hi,

Quoted 86 lines · Stephen Warren
Quoted 70 lines · Przemyslaw Marczak

Hello,

Quoted 55 lines · Stephen Warren
Quoted 52 lines · Przemyslaw Marczak

Hello,

Quoted 30 lines · Stephen Warren
Quoted 18 lines · Simon Glass

+Stephen who might have an opinion on this.

Hi Przemyslaw,

Quoted 7 lines · Przemyslaw Marczak

This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

The pull mode is not defined so should be driver specific.

Quoted 6 lines

It's good to implement this, but I think you should try to have a standard interface. You could define the options you want to support and pass in a standard value.

Otherwise we are not really providing a driver abstraction, only an interface.

Quoted 11 lines

I don't think that pull is a GPIO-related function/property. At least on
Tegra, the GPIO controller allows you to set the pin direction and the output value and that's it. Configuring pull-up/down and other IO related properties is done in the pinmux controller instead. I don't think we want a standard API that has to touch both HW modules at once. What common code needs to manipulate a GPIO's pull-up/down setting? As precedent observe that pull-up/down isn't part of the Linux kernel's GPIO API, but rather that's part of the SoC-specific pinctrl driver, which controls pinmuxing etc.

This is a quite different than in the Exynos, where all the gpio functions and properties can be set by few registers within range of each gpio port base address. So in this case we don't touch another hardware module, we modify one of available gpio related registers.

Quoted 7 lines
Quoted 2 lines

Anyway, if we want to have a single and common gpio API in the future, then I think it is better to add pull option.

Why? I'll ask again: What common driver code needs to manipulate pull-ups?

Quoted 7 lines

Please look at driver: drivers/gpio/s5p_gpio.c

It's one driver related to one gpio hardware submodule and it takes care about standard gpio properties and also mux/pull/drv/rate.

And the exynos pinmux code is only a software abstraction:
arch/arm/cpu/armv7/exynos/pinmux.c

I didn't want to ask which driver implements the control of pullups, but rather which other driver needs to turn pullups on/off in a standard way across multiple SoCs.

Quoted 5 lines

In other words, do you expect code in common/ to need to call a "set pin pullup" function? If so, then we certainly need a standard API to manipulate pullups. However if no common code needs to manipulate pullups, then I'd argue we don't actually need a common API to do this, since there's no code that would call that common API.

Quoted 6 lines

We do currently use the GPIO to handle pullup/pulldown for some boards so until we have a pinmux API (which might be a long while) it seems reasonable for it to live there.

If not, does anyone plan to write such an API?

Right, we uses this in most Exynos boards. But the boards uses direct calls to s5p gpio driver, without uclass. I wonder if wouldn't it be better and faster to leave the board low-level init routines as they are now.

Quoted 97 lines
Quoted 69 lines
Quoted 56 lines
Quoted 5 lines
Quoted 5 lines

And the driver will

Quoted 9 lines
Quoted 2 lines

implement what is required, instead of provide common and private api for each driver.

I'm not proposing driver-specific APIs, but rather having a common GPIO API and a common pinmux API. They need to be different since different HW modules may implement the functionality.

As in the above example, for the Exynos it's the one hw module, so it's simply.

Quoted 10 lines
Quoted 2 lines

For the various devices it is unclear, what should be pinmux and what should be gpio driver.

How about the following are GPIO:
* Set GPIO pin direction
* Read GPIO input
* Set GPIO output value

Quoted 6 lines

... and anything else is pinmux. That's the split in Linux and AFAIK it works out fine.

It'd be perfectly fine for the same driver code to implement both a GPIO and a pinmux driver, if the HW supports it.

Ok, I can drop this commit, since the current code works fine.

Quoted 5 lines
Quoted 2 lines

Moreover in my opinion from the single external pin point of view the pull up/down is the property of that pin.

Quoted 13 lines

It's a property of the same pin, but semantically it's not manipulating a GPIO-related function.

Quoted 6 lines

Actually for Exynos, the pinmux is an abstraction and uses only GPIO driver api in U-Boot.

Do we need pinmux class?

Best regards,

Quoted 5 lines

As I wrote in one of my previous e-mail, I was testing eMMC detect. And setting the pull was required for this, before call the pinmux for eMMC pins.
But finally the eMMC detect seem to be not useful in case of the present 'mmc rescan' command.

Why wouldn't the pinmux driver for the whole system simply apply the board's whole pinmux configuration before initializing any IO controller drivers? IO controller drivers shouldn't have to initialize board-/SoC-specific pinmux, but the board-/SoC-specfic code should do so.

Quoted 5 lines

At most, the eMMC driver should call a function such as pinmux_emmc(), and the board/SoC code should implement that as appropriate for that board. The eMMC driver shouldn't have to know about applying specific pullups/downs to specific pins (since those settings and pins are likely board-/SoC-specific, and drivers shouldn't know about board-/SoC-specific details). The only

No this way lies madness. It is how things work on Jetson and Nyan. Loads of opaque tables and no idea what the pins are connected to. It has some value for pins that U-Boot doesn't use (so we are just setting them up for Linux) but even then it is really opaque.

We can't even sent patches to the file because it is auto-generated from a tool in another repo. Tiny differences between boards are hidden because we repeat all the information again with just a line or two of changes. I really don't want exynos to go that way.

Quoted 5 lines

exception would be if the standard IO protocol requires pullups to be changed during regular operation. In which case, a specific callback from the driver could be added for each protocol-mandated configuration change, thus keeping the IO controller driver still completely isolated from details of the pins and pinmux APIs etc.

This is like the 'funcmux' in Tegra I think. I think this is more useful and we should use it to set up all peripheral pins. We can review the code, see changes, understand what they relate to, etc.

Quoted 9 lines

Anyway this all seems off-topic from this patch.

Unless someone plans to write a pinmux subsystem for U-Boot (which I agree would be better) I think the general approach of this patch is good.

Regards,
Simon

Quoted 5 lines

Ok, so there are two next versions of this patch-set. Please decide, which one is better.

For me, at present, the current s5p_gpio api works fine for all the exynos based boards. Introducing the pinmux uclass is not a quick task, now I'm trying to focus on pmic.

Quoted 9 lines

OK, then I think we should probably leave it as it is. If we add pull-ups to driver model it should be done with pinctl as Stephen says. I doubt this is a huge task, since we can likely port over the code from Linux. But for now I think we should keep with the s5p API until someone takes on pinctl.

Regards,
Simon

Great, in this case, can the v3 be accepted?

Best regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#13 lore raw

PATCH 1/4 dm: gpio: extend gpio api by dm_gpio_set_pull()

Hi Przemyslaw,

Quoted 306 lines · Przemyslaw Marczak

Hello,

Quoted 302 lines · Simon Glass

Hi,

Quoted 282 lines · Przemyslaw Marczak

Hello Simon,

Quoted 128 lines · Simon Glass

Hi,

Quoted 110 lines · Stephen Warren
Quoted 89 lines · Przemyslaw Marczak

Hello,

Quoted 77 lines · Stephen Warren
Quoted 61 lines · Przemyslaw Marczak

Hello,

Quoted 37 lines · Stephen Warren
Quoted 21 lines · Simon Glass

+Stephen who might have an opinion on this.

Hi Przemyslaw,

Quoted 8 lines · Przemyslaw Marczak

This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

The pull mode is not defined so should be driver specific.

Quoted 8 lines

It's good to implement this, but I think you should try to have a standard interface. You could define the options you want to support
and pass in a standard value.

Otherwise we are not really providing a driver abstraction, only an
interface.

Quoted 17 lines

I don't think that pull is a GPIO-related function/property. At least on
Tegra, the GPIO controller allows you to set the pin direction and the
output value and that's it. Configuring pull-up/down and other IO related properties is done in the pinmux controller instead. I don't
think we want a standard API that has to touch both HW modules at once.
What common code needs to manipulate a GPIO's pull-up/down setting? As
precedent observe that pull-up/down isn't part of the Linux kernel's
GPIO API, but rather that's part of the SoC-specific pinctrl driver,
which controls pinmuxing etc.

Quoted 8 lines

This is a quite different than in the Exynos, where all the gpio functions and properties can be set by few registers within range of each gpio port base address. So in this case we don't touch another hardware module, we modify one of available gpio related registers.

Anyway, if we want to have a single and common gpio API in the future,
then I think it is better to add pull option.

Quoted 2 lines

Why? I'll ask again: What common driver code needs to manipulate pull-ups?

Quoted 8 lines

Please look at driver: drivers/gpio/s5p_gpio.c

It's one driver related to one gpio hardware submodule and it takes care
about standard gpio properties and also mux/pull/drv/rate.

And the exynos pinmux code is only a software abstraction:
arch/arm/cpu/armv7/exynos/pinmux.c

I didn't want to ask which driver implements the control of pullups, but
rather which other driver needs to turn pullups on/off in a standard way
across multiple SoCs.

Quoted 9 lines

In other words, do you expect code in common/ to need to call a "set pin
pullup" function? If so, then we certainly need a standard API to manipulate
pullups. However if no common code needs to manipulate pullups, then I'd
argue we don't actually need a common API to do this, since there's no code
that would call that common API.

Quoted 6 lines

We do currently use the GPIO to handle pullup/pulldown for some boards so until we have a pinmux API (which might be a long while) it seems reasonable for it to live there.

If not, does anyone plan to write such an API?

Right, we uses this in most Exynos boards. But the boards uses direct calls to s5p gpio driver, without uclass.
I wonder if wouldn't it be better and faster to leave the board low-level init routines as they are now.

Quoted 125 lines
Quoted 88 lines
Quoted 70 lines
Quoted 13 lines
Quoted 9 lines

And the driver will

implement what is required, instead of provide common and private api
for each driver.

Quoted 6 lines

I'm not proposing driver-specific APIs, but rather having a common GPIO
API and a common pinmux API. They need to be different since different
HW modules may implement the functionality.

As in the above example, for the Exynos it's the one hw module, so it's
simply.

Quoted 12 lines
Quoted 3 lines

For the various devices it is unclear, what should be pinmux and what
should be gpio driver.

How about the following are GPIO:
* Set GPIO pin direction
* Read GPIO input
* Set GPIO output value

Quoted 8 lines

... and anything else is pinmux. That's the split in Linux and AFAIK it
works out fine.

It'd be perfectly fine for the same driver code to implement both a GPIO
and a pinmux driver, if the HW supports it.

Ok, I can drop this commit, since the current code works fine.

Quoted 7 lines
Quoted 3 lines

Moreover in my opinion from the single external pin point of view the
pull up/down is the property of that pin.

Quoted 15 lines

It's a property of the same pin, but semantically it's not manipulating
a GPIO-related function.

Quoted 6 lines

Actually for Exynos, the pinmux is an abstraction and uses only GPIO driver api in U-Boot.

Do we need pinmux class?

Best regards,

Quoted 6 lines

As I wrote in one of my previous e-mail, I was testing eMMC detect. And setting the pull was required for this, before call the pinmux for eMMC pins.
But finally the eMMC detect seem to be not useful in case of the present
'mmc rescan' command.

Why wouldn't the pinmux driver for the whole system simply apply the board's
whole pinmux configuration before initializing any IO controller drivers? IO
controller drivers shouldn't have to initialize board-/SoC-specific pinmux,
but the board-/SoC-specfic code should do so.

Quoted 9 lines

At most, the eMMC driver should call a function such as pinmux_emmc(), and
the board/SoC code should implement that as appropriate for that board. The
eMMC driver shouldn't have to know about applying specific pullups/downs to
specific pins (since those settings and pins are likely board-/SoC-specific,
and drivers shouldn't know about board-/SoC-specific details). The only

No this way lies madness. It is how things work on Jetson and Nyan. Loads of opaque tables and no idea what the pins are connected to. It has some value for pins that U-Boot doesn't use (so we are just setting them up for Linux) but even then it is really opaque.

We can't even sent patches to the file because it is auto-generated from a tool in another repo. Tiny differences between boards are hidden because we repeat all the information again with just a line or two of changes. I really don't want exynos to go that way.

Quoted 8 lines

exception would be if the standard IO protocol requires pullups to be changed during regular operation. In which case, a specific callback from
the driver could be added for each protocol-mandated configuration change,
thus keeping the IO controller driver still completely isolated from details
of the pins and pinmux APIs etc.

This is like the 'funcmux' in Tegra I think. I think this is more useful and we should use it to set up all peripheral pins. We can review the code, see changes, understand what they relate to, etc.

Quoted 9 lines

Anyway this all seems off-topic from this patch.

Unless someone plans to write a pinmux subsystem for U-Boot (which I agree would be better) I think the general approach of this patch is good.

Regards,
Simon

Quoted 7 lines

Ok, so there are two next versions of this patch-set. Please decide, which one is better.

For me, at present, the current s5p_gpio api works fine for all the exynos based boards.
Introducing the pinmux uclass is not a quick task, now I'm trying to focus on pmic.

OK, then I think we should probably leave it as it is. If we add pull-ups to driver model it should be done with pinctl as Stephen says. I doubt this is a huge task, since we can likely port over the code from Linux. But for now I think we should keep with the s5p API until someone takes on pinctl.

Quoted 5 lines
Quoted 3 lines

Regards,
Simon

Great, in this case, can the v3 be accepted?

v3 of what please? Can you give me a pointer?

Regards,
Simon

#14 lore raw

PATCH 1/4 dm: gpio: extend gpio api by dm_gpio_set_pull()

Hello,

Quoted 313 lines · Simon Glass

Hi Przemyslaw,

Quoted 310 lines · Przemyslaw Marczak

Hello,

Quoted 305 lines · Simon Glass

Hi,

Quoted 282 lines · Przemyslaw Marczak

Hello Simon,

Quoted 128 lines · Simon Glass

Hi,

Quoted 110 lines · Stephen Warren
Quoted 89 lines · Przemyslaw Marczak

Hello,

Quoted 77 lines · Stephen Warren
Quoted 61 lines · Przemyslaw Marczak

Hello,

Quoted 37 lines · Stephen Warren
Quoted 21 lines · Simon Glass

+Stephen who might have an opinion on this.

Hi Przemyslaw,

Quoted 8 lines · Przemyslaw Marczak

This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

The pull mode is not defined so should be driver specific.

Quoted 8 lines

It's good to implement this, but I think you should try to have a standard interface. You could define the options you want to support
and pass in a standard value.

Otherwise we are not really providing a driver abstraction, only an
interface.

Quoted 17 lines

I don't think that pull is a GPIO-related function/property. At least on
Tegra, the GPIO controller allows you to set the pin direction and the
output value and that's it. Configuring pull-up/down and other IO related properties is done in the pinmux controller instead. I don't
think we want a standard API that has to touch both HW modules at once.
What common code needs to manipulate a GPIO's pull-up/down setting? As
precedent observe that pull-up/down isn't part of the Linux kernel's
GPIO API, but rather that's part of the SoC-specific pinctrl driver,
which controls pinmuxing etc.

Quoted 8 lines

This is a quite different than in the Exynos, where all the gpio functions and properties can be set by few registers within range of each gpio port base address. So in this case we don't touch another hardware module, we modify one of available gpio related registers.

Anyway, if we want to have a single and common gpio API in the future,
then I think it is better to add pull option.

Quoted 2 lines

Why? I'll ask again: What common driver code needs to manipulate pull-ups?

Quoted 8 lines

Please look at driver: drivers/gpio/s5p_gpio.c

It's one driver related to one gpio hardware submodule and it takes care
about standard gpio properties and also mux/pull/drv/rate.

And the exynos pinmux code is only a software abstraction:
arch/arm/cpu/armv7/exynos/pinmux.c

I didn't want to ask which driver implements the control of pullups, but
rather which other driver needs to turn pullups on/off in a standard way
across multiple SoCs.

Quoted 9 lines

In other words, do you expect code in common/ to need to call a "set pin
pullup" function? If so, then we certainly need a standard API to manipulate
pullups. However if no common code needs to manipulate pullups, then I'd
argue we don't actually need a common API to do this, since there's no code
that would call that common API.

Quoted 6 lines

We do currently use the GPIO to handle pullup/pulldown for some boards so until we have a pinmux API (which might be a long while) it seems reasonable for it to live there.

If not, does anyone plan to write such an API?

Right, we uses this in most Exynos boards. But the boards uses direct calls to s5p gpio driver, without uclass.
I wonder if wouldn't it be better and faster to leave the board low-level init routines as they are now.

Quoted 125 lines
Quoted 88 lines
Quoted 70 lines
Quoted 13 lines
Quoted 9 lines

And the driver will

implement what is required, instead of provide common and private api
for each driver.

Quoted 6 lines

I'm not proposing driver-specific APIs, but rather having a common GPIO
API and a common pinmux API. They need to be different since different
HW modules may implement the functionality.

As in the above example, for the Exynos it's the one hw module, so it's
simply.

Quoted 12 lines
Quoted 3 lines

For the various devices it is unclear, what should be pinmux and what
should be gpio driver.

How about the following are GPIO:
* Set GPIO pin direction
* Read GPIO input
* Set GPIO output value

Quoted 8 lines

... and anything else is pinmux. That's the split in Linux and AFAIK it
works out fine.

It'd be perfectly fine for the same driver code to implement both a GPIO
and a pinmux driver, if the HW supports it.

Ok, I can drop this commit, since the current code works fine.

Quoted 7 lines
Quoted 3 lines

Moreover in my opinion from the single external pin point of view the
pull up/down is the property of that pin.

Quoted 15 lines

It's a property of the same pin, but semantically it's not manipulating
a GPIO-related function.

Quoted 6 lines

Actually for Exynos, the pinmux is an abstraction and uses only GPIO driver api in U-Boot.

Do we need pinmux class?

Best regards,

Quoted 6 lines

As I wrote in one of my previous e-mail, I was testing eMMC detect. And setting the pull was required for this, before call the pinmux for eMMC pins.
But finally the eMMC detect seem to be not useful in case of the present
'mmc rescan' command.

Why wouldn't the pinmux driver for the whole system simply apply the board's
whole pinmux configuration before initializing any IO controller drivers? IO
controller drivers shouldn't have to initialize board-/SoC-specific pinmux,
but the board-/SoC-specfic code should do so.

Quoted 9 lines

At most, the eMMC driver should call a function such as pinmux_emmc(), and
the board/SoC code should implement that as appropriate for that board. The
eMMC driver shouldn't have to know about applying specific pullups/downs to
specific pins (since those settings and pins are likely board-/SoC-specific,
and drivers shouldn't know about board-/SoC-specific details). The only

No this way lies madness. It is how things work on Jetson and Nyan. Loads of opaque tables and no idea what the pins are connected to. It has some value for pins that U-Boot doesn't use (so we are just setting them up for Linux) but even then it is really opaque.

We can't even sent patches to the file because it is auto-generated from a tool in another repo. Tiny differences between boards are hidden because we repeat all the information again with just a line or two of changes. I really don't want exynos to go that way.

Quoted 8 lines

exception would be if the standard IO protocol requires pullups to be changed during regular operation. In which case, a specific callback from
the driver could be added for each protocol-mandated configuration change,
thus keeping the IO controller driver still completely isolated from details
of the pins and pinmux APIs etc.

This is like the 'funcmux' in Tegra I think. I think this is more useful and we should use it to set up all peripheral pins. We can review the code, see changes, understand what they relate to, etc.

Quoted 9 lines

Anyway this all seems off-topic from this patch.

Unless someone plans to write a pinmux subsystem for U-Boot (which I agree would be better) I think the general approach of this patch is good.

Regards,
Simon

Quoted 7 lines

Ok, so there are two next versions of this patch-set. Please decide, which one is better.

For me, at present, the current s5p_gpio api works fine for all the exynos based boards.
Introducing the pinmux uclass is not a quick task, now I'm trying to focus on pmic.

OK, then I think we should probably leave it as it is. If we add pull-ups to driver model it should be done with pinctl as Stephen says. I doubt this is a huge task, since we can likely port over the code from Linux. But for now I think we should keep with the s5p API until someone takes on pinctl.

Regards,
Simon

Quoted 7 lines
Quoted 1 line

Great, in this case, can the v3 be accepted?

v3 of what please? Can you give me a pointer?

Regards,
Simon

oops, sorry, I didn't change the cc list...
There was, v2 and v3 on the list. But the v3 is included in mmc tree pull request:

http://patchwork.ozlabs.org/patch/442639/

Best regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#15 lore raw

PATCH 1/4 dm: gpio: extend gpio api by dm_gpio_set_pull()

In reply to Stephen Warren

Hello Stephen,

Quoted 57 lines · Stephen Warren
Quoted 56 lines · Przemyslaw Marczak

Hello,

Quoted 42 lines · Stephen Warren
Quoted 41 lines · Przemyslaw Marczak

Hello,

Quoted 20 lines · Stephen Warren
Quoted 10 lines · Simon Glass

+Stephen who might have an opinion on this.

Hi Przemyslaw,

Quoted 4 lines · Przemyslaw Marczak

This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

Quoted 8 lines
Quoted 1 line

The pull mode is not defined so should be driver specific.

It's good to implement this, but I think you should try to have a standard interface. You could define the options you want to support and pass in a standard value.

Otherwise we are not really providing a driver abstraction, only an interface.

Quoted 12 lines

I don't think that pull is a GPIO-related function/property. At least on
Tegra, the GPIO controller allows you to set the pin direction and the output value and that's it. Configuring pull-up/down and other IO related properties is done in the pinmux controller instead. I don't think we want a standard API that has to touch both HW modules at once.
What common code needs to manipulate a GPIO's pull-up/down setting? As precedent observe that pull-up/down isn't part of the Linux kernel's GPIO API, but rather that's part of the SoC-specific pinctrl driver, which controls pinmuxing etc.

This is a quite different than in the Exynos, where all the gpio functions and properties can be set by few registers within range of each gpio port base address. So in this case we don't touch another hardware module, we modify one of available gpio related registers.

Quoted 5 lines
Quoted 2 lines

Anyway, if we want to have a single and common gpio API in the future, then I think it is better to add pull option.

Why? I'll ask again: What common driver code needs to manipulate pull-ups?

Please look at driver: drivers/gpio/s5p_gpio.c

It's one driver related to one gpio hardware submodule and it takes care about standard gpio properties and also mux/pull/drv/rate.

Quoted 7 lines
Quoted 2 lines

And the exynos pinmux code is only a software abstraction:
arch/arm/cpu/armv7/exynos/pinmux.c

I didn't want to ask which driver implements the control of pullups, but rather which other driver needs to turn pullups on/off in a standard way across multiple SoCs.

Probably none.

Quoted 6 lines

In other words, do you expect code in common/ to need to call a "set pin pullup" function? If so, then we certainly need a standard API to manipulate pullups. However if no common code needs to manipulate pullups, then I'd argue we don't actually need a common API to do this, since there's no code that would call that common API.

Ok, you are right.

Quoted 50 lines
Quoted 44 lines
Quoted 8 lines
Quoted 3 lines

And the driver will
implement what is required, instead of provide common and private api for each driver.

I'm not proposing driver-specific APIs, but rather having a common GPIO API and a common pinmux API. They need to be different since different HW modules may implement the functionality.

As in the above example, for the Exynos it's the one hw module, so it's simply.

Quoted 8 lines
Quoted 2 lines

For the various devices it is unclear, what should be pinmux and what should be gpio driver.

How about the following are GPIO:
* Set GPIO pin direction
* Read GPIO input
* Set GPIO output value

Quoted 6 lines

... and anything else is pinmux. That's the split in Linux and AFAIK it works out fine.

It'd be perfectly fine for the same driver code to implement both a GPIO and a pinmux driver, if the HW supports it.

Ok, I can drop this commit, since the current code works fine.

Quoted 14 lines
Quoted 2 lines

Moreover in my opinion from the single external pin point of view the pull up/down is the property of that pin.

It's a property of the same pin, but semantically it's not manipulating a GPIO-related function.

Quoted 6 lines

Actually for Exynos, the pinmux is an abstraction and uses only GPIO driver api in U-Boot.

Do we need pinmux class?

Best regards,

Quoted 5 lines

As I wrote in one of my previous e-mail, I was testing eMMC detect. And setting the pull was required for this, before call the pinmux for eMMC pins.
But finally the eMMC detect seem to be not useful in case of the present 'mmc rescan' command.

Quoted 4 lines

Why wouldn't the pinmux driver for the whole system simply apply the board's whole pinmux configuration before initializing any IO controller drivers? IO controller drivers shouldn't have to initialize board-/SoC-specific pinmux, but the board-/SoC-specfic code should do so.

This is clean, and the Exynos pinmux code is implemented in this way.

Quoted 13 lines

At most, the eMMC driver should call a function such as pinmux_emmc(), and the board/SoC code should implement that as appropriate for that board. The eMMC driver shouldn't have to know about applying specific pullups/downs to specific pins (since those settings and pins are likely board-/SoC-specific, and drivers shouldn't know about board-/SoC-specific details). The only exception would be if the standard IO protocol requires pullups to be changed during regular operation. In which case, a specific callback from the driver could be added for each protocol-mandated configuration change, thus keeping the IO controller driver still completely isolated from details of the pins and pinmux APIs etc.

This is also clean, and the mmc driver for exynos, calls the pinmux with the device id and flag as an arguments. This works fine.

The exception which I need, was to set just one emmc pin as input with proper pull-up (which was defined in emmc dts node) and check the value. This was temporary, before the proper pinmux call for emmc configuration, after card detect.

Of course this was a hack, and for each board, the pull value was defined in dts(tested on 2 boards). And this was my tests only, I didn't send this code to list, but now I see that probably better could be some board specific function like board_emmc_detected().

Best regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#16 lore raw

PATCH 2/4 s5p: gpio: add implementation of dm_gpio_set_pull()

In reply to Przemyslaw Marczak

This commit adds implementation of driver model gpio pull setting to s5p gpio driver.

---
 drivers/gpio/s5p_gpio.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpio/s5p_gpio.c +11 -0
index 0a245ba..5de96bf 100644
@@ -231,6 +231,16 @@ static int exynos_gpio_set_value(struct udevice *dev, unsigned offset,
 
 	return 0;
 }
+
+static int exynos_gpio_set_pull(struct udevice *dev, unsigned offset,
+				int pull)
+{
+	struct exynos_bank_info *state = dev_get_priv(dev);
+
+	s5p_gpio_set_pull(state->bank, offset, pull);
+
+	return 0;
+}
 #endif /* nCONFIG_SPL_BUILD */
 
 /*
@@ -290,6 +300,7 @@ static const struct dm_gpio_ops gpio_exynos_ops = {
 	.direction_output	= exynos_gpio_direction_output,
 	.get_value		= exynos_gpio_get_value,
 	.set_value		= exynos_gpio_set_value,
+	.set_pull		= exynos_gpio_set_pull,
 	.get_function		= exynos_gpio_get_function,
 	.xlate			= exynos_gpio_xlate,
 };
Signature · 1 line
1.9.1
#17 lore raw

PATCH 3/4 mmc: exynos dwmmc: check boot mode before init dwmmc

In reply to Przemyslaw Marczak

Before this commit, the mmc devices were always registered in the same order. So dwmmc channel 0 was registered as mmc 0, channel 1 as mmc 1, etc.
In case of possibility to boot from more then one device, the CONFIG_SYS_MMC_ENV_DEV should always point to right mmc device.

This can be achieved by init boot device as first, so it will be always registered as mmc 0. Thanks to this, the 'saveenv' command will work fine for all mmc boot devices.

Exynos based boards usually uses mmc host channels configuration:
- 0, or 0+1 for 8 bit - as a default boot device (usually eMMC)
- 2 for 4bit - as an optional boot device (usually SD card slot)

And usually the boot order is defined by OM pin configuration, which can be changed in a few ways, eg.
- Odroid U3 - eMMC card insertion -> first boot from eMMC
- Odroid X2/XU3 - boot priority jumper

By this commit, Exynos dwmmc driver will check the OM pin configuration, and then try to init the boot device and register it as mmc 0.

Cc Minkyu Kang <[email protected]>
Cc Jaehoon Chung <[email protected]>
Cc Pantelis Antoniou <[email protected]>
Cc Simon Glass <[email protected]>
Cc Akshay Saraswat <[email protected]>
---
 drivers/mmc/exynos_dw_mmc.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/mmc/exynos_dw_mmc.c +10 -1
index dfa209b..91f0163 100644
@@ -13,6 +13,7 @@
 #include <asm/arch/dwmmc.h>
 #include <asm/arch/clk.h>
 #include <asm/arch/pinmux.h>
+#include <asm/arch/power.h>
 #include <asm/gpio.h>
 #include <asm-generic/errno.h>
 
@@ -166,7 +167,6 @@ static int exynos_dwmci_get_config(const void *blob, int node,
 	if (host->dev_index == host->dev_id)
 		host->dev_index = host->dev_id - PERIPH_ID_SDMMC0;
 
-
 	/* Get the bus width from the device node */
 	host->buswidth = fdtdec_get_int(blob, node, "samsung,bus-width", 0);
 	if (host->buswidth <= 0) {
@@ -229,12 +229,21 @@ int exynos_dwmmc_init(const void *blob)
 {
 	int compat_id;
 	int node_list[DWMMC_MAX_CH_NUM];
+	int boot_dev_node;
 	int err = 0, count;
 
 	compat_id = COMPAT_SAMSUNG_EXYNOS_DWMMC;
 
 	count = fdtdec_find_aliases_for_id(blob, "mmc",
 				compat_id, node_list, DWMMC_MAX_CH_NUM);
+
+	/* For DWMMC always set boot device as mmc 0 */
+	if (count >= 3 && get_boot_mode() == BOOT_MODE_SD) {
+		boot_dev_node = node_list[2];
+		node_list[2] = node_list[0];
+		node_list[0] = boot_dev_node;
+	}
+
 	err = exynos_dwmci_process_node(blob, node_list, count);
 
 	return err;
Signature · 1 line
1.9.1
#18 lore raw

PATCH 3/4 mmc: exynos dwmmc: check boot mode before init dwmmc

Hi Przemyslaw,

Quoted 14 lines · Przemyslaw Marczak

Before this commit, the mmc devices were always registered in the same order. So dwmmc channel 0 was registered as mmc 0, channel 1 as mmc 1, etc.
In case of possibility to boot from more then one device, the CONFIG_SYS_MMC_ENV_DEV should always point to right mmc device.

This can be achieved by init boot device as first, so it will be always registered as mmc 0. Thanks to this, the 'saveenv' command will work fine for all mmc boot devices.

Exynos based boards usually uses mmc host channels configuration:
- 0, or 0+1 for 8 bit - as a default boot device (usually eMMC)
- 2 for 4bit - as an optional boot device (usually SD card slot)

Quoted 7 lines

And usually the boot order is defined by OM pin configuration, which can be changed in a few ways, eg.
- Odroid U3 - eMMC card insertion -> first boot from eMMC
- Odroid X2/XU3 - boot priority jumper

By this commit, Exynos dwmmc driver will check the OM pin configuration, and then try to init the boot device and register it as mmc 0.

I think a better way to do this would be to make CONFIG_SYS_MMC_ENV_DEV support an option where the device can be selected at run-time.

However that would probably be better done when the drive rmodel conversion is complete.

So this seems a reasonable patch given where we are.

Quoted 54 lines
Cc Minkyu Kang <[email protected]>
Cc Jaehoon Chung <[email protected]>
Cc Pantelis Antoniou <[email protected]>
Cc Simon Glass <[email protected]>
Cc Akshay Saraswat <[email protected]>
---
 drivers/mmc/exynos_dw_mmc.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/mmc/exynos_dw_mmc.c +10 -2
index dfa209b..91f0163 100644
@@ -13,6 +13,7 @@
 #include <asm/arch/dwmmc.h>
 #include <asm/arch/clk.h>
 #include <asm/arch/pinmux.h>
+#include <asm/arch/power.h>
 #include <asm/gpio.h>
 #include <asm-generic/errno.h>
 
@@ -166,7 +167,6 @@ static int exynos_dwmci_get_config(const void *blob, int node,
        if (host->dev_index == host->dev_id)
                host->dev_index = host->dev_id - PERIPH_ID_SDMMC0;
 
-
        /* Get the bus width from the device node */
        host->buswidth = fdtdec_get_int(blob, node, "samsung,bus-width", 0);
        if (host->buswidth <= 0) {
@@ -229,12 +229,21 @@ int exynos_dwmmc_init(const void *blob)
 {
        int compat_id;
        int node_list[DWMMC_MAX_CH_NUM];
+       int boot_dev_node;
        int err = 0, count;
 
        compat_id = COMPAT_SAMSUNG_EXYNOS_DWMMC;
 
        count = fdtdec_find_aliases_for_id(blob, "mmc",
                                compat_id, node_list, DWMMC_MAX_CH_NUM);
+
+       /* For DWMMC always set boot device as mmc 0 */
+       if (count >= 3 && get_boot_mode() == BOOT_MODE_SD) {
+               boot_dev_node = node_list[2];
+               node_list[2] = node_list[0];
+               node_list[0] = boot_dev_node;
+       }
+
        err = exynos_dwmci_process_node(blob, node_list, count);
 
        return err;
--
Quoted 2 lines

1.9.1

Regards,
Simon

#19 lore raw

PATCH 3/4 mmc: exynos dwmmc: check boot mode before init dwmmc

Hello Simon,

Quoted 29 lines · Simon Glass

Hi Przemyslaw,

Quoted 14 lines · Przemyslaw Marczak

Before this commit, the mmc devices were always registered in the same order. So dwmmc channel 0 was registered as mmc 0, channel 1 as mmc 1, etc.
In case of possibility to boot from more then one device, the CONFIG_SYS_MMC_ENV_DEV should always point to right mmc device.

This can be achieved by init boot device as first, so it will be always registered as mmc 0. Thanks to this, the 'saveenv' command will work fine for all mmc boot devices.

Exynos based boards usually uses mmc host channels configuration:
- 0, or 0+1 for 8 bit - as a default boot device (usually eMMC)
- 2 for 4bit - as an optional boot device (usually SD card slot)

Quoted 7 lines

And usually the boot order is defined by OM pin configuration, which can be changed in a few ways, eg.
- Odroid U3 - eMMC card insertion -> first boot from eMMC
- Odroid X2/XU3 - boot priority jumper

By this commit, Exynos dwmmc driver will check the OM pin configuration, and then try to init the boot device and register it as mmc 0.

I think a better way to do this would be to make CONFIG_SYS_MMC_ENV_DEV support an option where the device can be selected at run-time.

Quoted 7 lines

However that would probably be better done when the drive rmodel conversion is complete.

So this seems a reasonable patch given where we are.

This was just a quick solution to solve the issue on XU3, when the same binary can boot from sd or eMMC slots.

Quoted 52 lines
Quoted 52 lines
Cc Minkyu Kang <[email protected]>
Cc Jaehoon Chung <[email protected]>
Cc Pantelis Antoniou <[email protected]>
Cc Simon Glass <[email protected]>
Cc Akshay Saraswat <[email protected]>
---
  drivers/mmc/exynos_dw_mmc.c | 11 ++++++++++-
  1 file changed, 10 insertions(+), 1 deletion(-)
drivers/mmc/exynos_dw_mmc.c +10 -1
index dfa209b..91f0163 100644
@@ -13,6 +13,7 @@
  #include <asm/arch/dwmmc.h>
  #include <asm/arch/clk.h>
  #include <asm/arch/pinmux.h>
+#include <asm/arch/power.h>
  #include <asm/gpio.h>
  #include <asm-generic/errno.h>
 
@@ -166,7 +167,6 @@ static int exynos_dwmci_get_config(const void *blob, int node,
         if (host->dev_index == host->dev_id)
                 host->dev_index = host->dev_id - PERIPH_ID_SDMMC0;
 
-
         /* Get the bus width from the device node */
         host->buswidth = fdtdec_get_int(blob, node, "samsung,bus-width", 0);
         if (host->buswidth <= 0) {
@@ -229,12 +229,21 @@ int exynos_dwmmc_init(const void *blob)
  {
         int compat_id;
         int node_list[DWMMC_MAX_CH_NUM];
+       int boot_dev_node;
         int err = 0, count;
 
         compat_id = COMPAT_SAMSUNG_EXYNOS_DWMMC;
 
         count = fdtdec_find_aliases_for_id(blob, "mmc",
                                 compat_id, node_list, DWMMC_MAX_CH_NUM);
+
+       /* For DWMMC always set boot device as mmc 0 */
+       if (count >= 3 && get_boot_mode() == BOOT_MODE_SD) {
+               boot_dev_node = node_list[2];
+               node_list[2] = node_list[0];
+               node_list[0] = boot_dev_node;
+       }
+
         err = exynos_dwmci_process_node(blob, node_list, count);
 
Quoted 8 lines
Quoted 4 lines
drivers/mmc/exynos_dw_mmc.c +0 -1
         return err;
--

1.9.1

Regards,
Simon

Thank you for the review. I will send the second version soon.

Best regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#20 lore raw

PATCH 3/4 mmc: exynos dwmmc: check boot mode before init dwmmc

Quoted 35 lines · Przemyslaw Marczak

Hello Simon,

Quoted 32 lines · Simon Glass

Hi Przemyslaw,

Quoted 14 lines · Przemyslaw Marczak

Before this commit, the mmc devices were always registered in the same order. So dwmmc channel 0 was registered as mmc 0, channel 1 as mmc 1, etc.
In case of possibility to boot from more then one device, the CONFIG_SYS_MMC_ENV_DEV should always point to right mmc device.

This can be achieved by init boot device as first, so it will be always registered as mmc 0. Thanks to this, the 'saveenv' command will work fine for all mmc boot devices.

Exynos based boards usually uses mmc host channels configuration:
- 0, or 0+1 for 8 bit - as a default boot device (usually eMMC)
- 2 for 4bit - as an optional boot device (usually SD card slot)

Quoted 7 lines

And usually the boot order is defined by OM pin configuration, which can be changed in a few ways, eg.
- Odroid U3 - eMMC card insertion -> first boot from eMMC
- Odroid X2/XU3 - boot priority jumper

By this commit, Exynos dwmmc driver will check the OM pin configuration, and then try to init the boot device and register it as mmc 0.

I think a better way to do this would be to make CONFIG_SYS_MMC_ENV_DEV support an option where the device can be selected at run-time.

However that would probably be better done when the drive rmodel conversion is complete.

Quoted 7 lines
Quoted 4 lines

So this seems a reasonable patch given where we are.

This was just a quick solution to solve the issue on XU3, when the same binary can boot from sd or eMMC slots.

XU3 isn't unique in this regard. "am335x_evm" binaries runs on 4 very different boards and we still just have to say that sometimes we default to ENV in a place that isn't workable.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150219/76528fdb/attachment.sig>
#21 lore raw

PATCH 3/4 mmc: exynos dwmmc: check boot mode before init dwmmc

Hello Tom,

Quoted 41 lines · Tom Rini
Quoted 40 lines · Przemyslaw Marczak

Hello Simon,

Quoted 36 lines · Simon Glass

Hi Przemyslaw,

Quoted 14 lines · Przemyslaw Marczak

Before this commit, the mmc devices were always registered in the same order. So dwmmc channel 0 was registered as mmc 0, channel 1 as mmc 1, etc.
In case of possibility to boot from more then one device, the CONFIG_SYS_MMC_ENV_DEV should always point to right mmc device.

This can be achieved by init boot device as first, so it will be always registered as mmc 0. Thanks to this, the 'saveenv' command will work fine for all mmc boot devices.

Exynos based boards usually uses mmc host channels configuration:
- 0, or 0+1 for 8 bit - as a default boot device (usually eMMC)
- 2 for 4bit - as an optional boot device (usually SD card slot)

Quoted 7 lines

And usually the boot order is defined by OM pin configuration, which can be changed in a few ways, eg.
- Odroid U3 - eMMC card insertion -> first boot from eMMC
- Odroid X2/XU3 - boot priority jumper

By this commit, Exynos dwmmc driver will check the OM pin configuration, and then try to init the boot device and register it as mmc 0.

I think a better way to do this would be to make CONFIG_SYS_MMC_ENV_DEV support an option where the device can be selected at run-time.

However that would probably be better done when the drive rmodel conversion is complete.

So this seems a reasonable patch given where we are.

Quoted 8 lines
Quoted 2 lines

This was just a quick solution to solve the issue on XU3, when the same binary can boot from sd or eMMC slots.

XU3 isn't unique in this regard. "am335x_evm" binaries runs on 4 very different boards and we still just have to say that sometimes we default to ENV in a place that isn't workable.

Yes, I saw this issue on bb black. But it seems to be not a big problem to fix it.
When I finish the pmic and finally start work on adding it to the bb black, then maybe I will try to fix it somehow.

Regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#22 lore raw

PATCH 3/4 mmc: exynos dwmmc: check boot mode before init dwmmc

Quoted 47 lines · Przemyslaw Marczak

Hello Tom,

Quoted 44 lines · Tom Rini
Quoted 42 lines · Przemyslaw Marczak

Hello Simon,

Quoted 29 lines · Simon Glass

Hi Przemyslaw,

Quoted 14 lines · Przemyslaw Marczak

Before this commit, the mmc devices were always registered in the same order. So dwmmc channel 0 was registered as mmc 0, channel 1 as mmc 1, etc.
In case of possibility to boot from more then one device, the CONFIG_SYS_MMC_ENV_DEV should always point to right mmc device.

This can be achieved by init boot device as first, so it will be always registered as mmc 0. Thanks to this, the 'saveenv' command will work fine for all mmc boot devices.

Exynos based boards usually uses mmc host channels configuration:
- 0, or 0+1 for 8 bit - as a default boot device (usually eMMC)
- 2 for 4bit - as an optional boot device (usually SD card slot)

Quoted 7 lines

And usually the boot order is defined by OM pin configuration, which can be changed in a few ways, eg.
- Odroid U3 - eMMC card insertion -> first boot from eMMC
- Odroid X2/XU3 - boot priority jumper

By this commit, Exynos dwmmc driver will check the OM pin configuration, and then try to init the boot device and register it as mmc 0.

I think a better way to do this would be to make CONFIG_SYS_MMC_ENV_DEV support an option where the device can be selected at run-time.

Quoted 7 lines

However that would probably be better done when the drive rmodel conversion is complete.

So this seems a reasonable patch given where we are.

This was just a quick solution to solve the issue on XU3, when the same binary can boot from sd or eMMC slots.

Quoted 8 lines
Quoted 3 lines

XU3 isn't unique in this regard. "am335x_evm" binaries runs on 4 very different boards and we still just have to say that sometimes we default to ENV in a place that isn't workable.

Yes, I saw this issue on bb black. But it seems to be not a big problem to fix it.
When I finish the pmic and finally start work on adding it to the bb black, then maybe I will try to fix it somehow.

It's not hard (extending some of the concepts we have already) but I want to hold that off until we have driver model support instead as part of a "carrot and stick" approach ;)

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150219/e00a6242/attachment.sig>
#23 lore raw

PATCH 3/4 mmc: exynos dwmmc: check boot mode before init dwmmc

Hi,

Quoted 52 lines · Tom Rini
Quoted 51 lines · Przemyslaw Marczak

Hello Tom,

Quoted 47 lines · Tom Rini
Quoted 35 lines · Przemyslaw Marczak

Hello Simon,

Quoted 32 lines · Simon Glass

Hi Przemyslaw,

Quoted 14 lines · Przemyslaw Marczak

Before this commit, the mmc devices were always registered in the same order. So dwmmc channel 0 was registered as mmc 0, channel 1 as mmc 1, etc.
In case of possibility to boot from more then one device, the CONFIG_SYS_MMC_ENV_DEV should always point to right mmc device.

This can be achieved by init boot device as first, so it will be always registered as mmc 0. Thanks to this, the 'saveenv' command will work fine for all mmc boot devices.

Exynos based boards usually uses mmc host channels configuration:
- 0, or 0+1 for 8 bit - as a default boot device (usually eMMC)
- 2 for 4bit - as an optional boot device (usually SD card slot)

Quoted 7 lines

And usually the boot order is defined by OM pin configuration, which can be changed in a few ways, eg.
- Odroid U3 - eMMC card insertion -> first boot from eMMC
- Odroid X2/XU3 - boot priority jumper

By this commit, Exynos dwmmc driver will check the OM pin configuration, and then try to init the boot device and register it as mmc 0.

I think a better way to do this would be to make CONFIG_SYS_MMC_ENV_DEV support an option where the device can be selected at run-time.

However that would probably be better done when the drive rmodel conversion is complete.

Quoted 7 lines
Quoted 4 lines

So this seems a reasonable patch given where we are.

This was just a quick solution to solve the issue on XU3, when the same binary can boot from sd or eMMC slots.

XU3 isn't unique in this regard. "am335x_evm" binaries runs on 4 very different boards and we still just have to say that sometimes we default to ENV in a place that isn't workable.

Quoted 9 lines
Quoted 4 lines

Yes, I saw this issue on bb black. But it seems to be not a big problem to fix it.
When I finish the pmic and finally start work on adding it to the bb black, then maybe I will try to fix it somehow.

It's not hard (extending some of the concepts we have already) but I want to hold that off until we have driver model support instead as part of a "carrot and stick" approach ;)

Ok, that's fine.

Regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#24 lore raw

PATCH 3/4 mmc: exynos dwmmc: check boot mode before init dwmmc

In reply to Simon Glass
Quoted 25 lines · Simon Glass

Hi Przemyslaw,

Quoted 14 lines · Przemyslaw Marczak

Before this commit, the mmc devices were always registered in the same order. So dwmmc channel 0 was registered as mmc 0, channel 1 as mmc 1, etc.
In case of possibility to boot from more then one device, the CONFIG_SYS_MMC_ENV_DEV should always point to right mmc device.

This can be achieved by init boot device as first, so it will be always registered as mmc 0. Thanks to this, the 'saveenv' command will work fine for all mmc boot devices.

Exynos based boards usually uses mmc host channels configuration:
- 0, or 0+1 for 8 bit - as a default boot device (usually eMMC)
- 2 for 4bit - as an optional boot device (usually SD card slot)

Quoted 7 lines

And usually the boot order is defined by OM pin configuration, which can be changed in a few ways, eg.
- Odroid U3 - eMMC card insertion -> first boot from eMMC
- Odroid X2/XU3 - boot priority jumper

By this commit, Exynos dwmmc driver will check the OM pin configuration, and then try to init the boot device and register it as mmc 0.

Quoted 6 lines

I think a better way to do this would be to make CONFIG_SYS_MMC_ENV_DEV support an option where the device can be selected at run-time.

However that would probably be better done when the drive rmodel conversion is complete.

Yes, lets hold off on this until driver model is in and we can do this more cleanly rather than whack at this problem right now (I've seen solutions to this kind of problem on am335x for example and it's still going to be better to wait I think).

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150219/7a263834/attachment.sig>
#25 lore raw

PATCH 4/4 mmc: print SD/eMMC type for inited mmc devices

In reply to Przemyslaw Marczak

Depending on the boot priority, the eMMC/SD cards, can be initialized with the same numbers for each boot.

To be sure which mmc device is SD and which is eMMC, this info is printed by 'mmc list' command, when the init is done.

---
 drivers/mmc/mmc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mmc/mmc.c +8 -0
index b8039cd..a13769e 100644
@@ -1693,11 +1693,19 @@ void print_mmc_devices(char separator)
 {
 	struct mmc *m;
 	struct list_head *entry;
+	char *mmc_type;
 
 	list_for_each(entry, &mmc_devices) {
 		m = list_entry(entry, struct mmc, link);
 
+		if (m->has_init)
+			mmc_type = IS_SD(m) ? "SD" : "eMMC";
+		else
+			mmc_type = NULL;
+
 		printf("%s: %d", m->cfg->name, m->block_dev.dev);
+		if (mmc_type)
+			printf(" (%s)", mmc_type);
 
 		if (entry->next != &mmc_devices) {
 			printf("%c", separator);
Signature · 1 line
1.9.1
#26 lore raw

v2 cover exynos-dwmmc: check set init priority for boot channel

In reply to Przemyslaw Marczak

The dw mmc driver init priority was always the same: ch 0, ch 1, ch 2. On some boards (e.g. Odroid XU3) the dwmmc driver is enabled for all mmc channels. In this case, when boot device is switchable (SD/eMMC), the default MMC device will be 0 or 1.
Change the init priority to boot device, always init the boot device as mmc 0.
This fixes the issue with 'saveenv' command, because the MMC env device number is always the same.

The patchset also adds gpio set pull option to gpio api.

Przemyslaw Marczak (4):
dm: gpio: extend gpio api by dm_gpio_set_pull()
s5p: gpio: add implementation of dm_gpio_set_pull()
mmc: exynos dwmmc: check boot mode before init dwmmc
mmc: print SD/eMMC type for inited mmc devices

 drivers/gpio/gpio-uclass.c  | 11 +++++++++++
 drivers/gpio/s5p_gpio.c     | 28 ++++++++++++++++++++++++++++
 drivers/mmc/exynos_dw_mmc.c | 11 ++++++++++-
 drivers/mmc/mmc.c           |  8 ++++++++
 include/asm-generic/gpio.h  | 22 ++++++++++++++++++++++
 5 files changed, 79 insertions(+), 1 deletion(-)
Signature · 1 line
1.9.1
#27 lore raw

PATCH v2 1/4 dm: gpio: extend gpio api by dm_gpio_set_pull()

This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

The pull modes are defined by proper enum and can be:
- UP
- DOWN
- NONE
- UNKNOWN

---
Changes v2:
- add enum with gpio pull mode

---
 drivers/gpio/gpio-uclass.c | 11 +++++++++++
 include/asm-generic/gpio.h | 22 ++++++++++++++++++++++
 2 files changed, 33 insertions(+)
drivers/gpio/gpio-uclass.c +11 -0
index a69bbd2..10f600b 100644
@@ -321,6 +321,17 @@ int dm_gpio_set_value(struct gpio_desc *desc, int value)
 	return 0;
 }
 
+int dm_gpio_set_pull(struct gpio_desc *desc, int pull)
+{
+	int ret;
+
+	ret = check_reserved(desc, "set_pull");
+	if (ret)
+		return ret;
+
+	return gpio_get_ops(desc->dev)->set_pull(desc->dev, desc->offset, pull);
+}
+
 int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
 {
 	struct udevice *dev = desc->dev;
include/asm-generic/gpio.h +22 -0
index 3b96b82..b353f80 100644
@@ -108,6 +108,16 @@ enum gpio_func_t {
 	GPIOF_COUNT,
 };
 
+/* State of a GPIO pull */
+enum gpio_pull_t {
+	GPIOP_DOWN = 0,
+	GPIOP_UP,
+	GPIOP_NONE,
+	GPIOP_UNKNOWN,
+
+	GPIOP_COUNT,
+};
+
 struct udevice;
 
 struct gpio_desc {
@@ -241,6 +251,7 @@ struct dm_gpio_ops {
 				int value);
 	int (*get_value)(struct udevice *dev, unsigned offset);
 	int (*set_value)(struct udevice *dev, unsigned offset, int value);
+	int (*set_pull)(struct udevice *dev, unsigned offset, int pull);
 	/**
 	 * get_function() Get the GPIO function
 	 *
@@ -479,6 +490,7 @@ int gpio_free_list_nodev(struct gpio_desc *desc, int count);
 
 /**
  * dm_gpio_get_value() - Get the value of a GPIO
+
  *
  * This is the driver model version of the existing gpio_get_value() function
  * and should be used instead of that.
@@ -495,6 +507,16 @@ int dm_gpio_get_value(struct gpio_desc *desc);
 int dm_gpio_set_value(struct gpio_desc *desc, int value);
 
 /**
+ * dm_gpio_set_pull() - Set the pull-up/down value of a GPIO
+ *
+ * @desc:	GPIO description containing device, offset and flags,
+ *		previously returned by gpio_request_by_name()
+ * @pull:	GPIO pull value - one of enum gpio_pull_t
+ * @return 0 on success or -ve on error
+*/
+int dm_gpio_set_pull(struct gpio_desc *desc, int pull);
+
+/**
  * dm_gpio_set_dir() - Set the direction for a GPIO
  *
  * This sets up the direction according tot the provided flags. It will do
Signature · 1 line
1.9.1
#28 lore raw

PATCH v2 2/4 s5p: gpio: add implementation of dm_gpio_set_pull()

In reply to Przemyslaw Marczak

This commit adds implementation of driver model gpio pull setting to s5p gpio driver.

---
Changes v2:
- adjust code after added gpio pull enum to gpio api

---
 drivers/gpio/s5p_gpio.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
drivers/gpio/s5p_gpio.c +28 -0
index 0a245ba..ed531c6 100644
@@ -129,6 +129,7 @@ static void s5p_gpio_set_pull(struct s5p_gpio_bank *bank, int gpio, int mode)
 	value &= ~PULL_MASK(gpio);
 
 	switch (mode) {
+	case S5P_GPIO_PULL_NONE:
 	case S5P_GPIO_PULL_DOWN:
 	case S5P_GPIO_PULL_UP:
 		value |= PULL_MODE(gpio, mode);
@@ -231,6 +232,32 @@ static int exynos_gpio_set_value(struct udevice *dev, unsigned offset,
 
 	return 0;
 }
+
+static int exynos_gpio_set_pull(struct udevice *dev, unsigned offset,
+				int pull)
+{
+	struct exynos_bank_info *state = dev_get_priv(dev);
+	int gpio_pull;
+
+	switch (pull) {
+	case GPIOP_NONE:
+		gpio_pull = S5P_GPIO_PULL_NONE;
+		break;
+	case GPIOP_DOWN:
+		gpio_pull = S5P_GPIO_PULL_DOWN;
+		break;
+	case GPIOP_UP:
+		gpio_pull = S5P_GPIO_PULL_UP;
+		break;
+	default:
+		return -EINVAL;
+		break;
+	}
+
+	s5p_gpio_set_pull(state->bank, offset, gpio_pull);
+
+	return 0;
+}
 #endif /* nCONFIG_SPL_BUILD */
 
 /*
@@ -290,6 +317,7 @@ static const struct dm_gpio_ops gpio_exynos_ops = {
 	.direction_output	= exynos_gpio_direction_output,
 	.get_value		= exynos_gpio_get_value,
 	.set_value		= exynos_gpio_set_value,
+	.set_pull		= exynos_gpio_set_pull,
 	.get_function		= exynos_gpio_get_function,
 	.xlate			= exynos_gpio_xlate,
 };
Signature · 1 line
1.9.1
#29 lore raw

PATCH v2 3/4 mmc: exynos dwmmc: check boot mode before init dwmmc

In reply to Przemyslaw Marczak

Before this commit, the mmc devices were always registered in the same order. So dwmmc channel 0 was registered as mmc 0, channel 1 as mmc 1, etc.
In case of possibility to boot from more then one device, the CONFIG_SYS_MMC_ENV_DEV should always point to right mmc device.

This can be achieved by init boot device as first, so it will be always registered as mmc 0. Thanks to this, the 'saveenv' command will work fine for all mmc boot devices.

Exynos based boards usually uses mmc host channels configuration:
- 0, or 0+1 for 8 bit - as a default boot device (usually eMMC)
- 2 for 4bit - as an optional boot device (usually SD card slot)

And usually the boot order is defined by OM pin configuration, which can be changed in a few ways, eg.
- Odroid U3 - eMMC card insertion -> first boot from eMMC
- Odroid X2/XU3 - boot priority jumper

By this commit, Exynos dwmmc driver will check the OM pin configuration, and then try to init the boot device and register it as mmc 0.

Cc Minkyu Kang <[email protected]>
Cc Jaehoon Chung <[email protected]>
Cc Pantelis Antoniou <[email protected]>
Cc Simon Glass <[email protected]>
Cc Akshay Saraswat <[email protected]>

---
Changes v2:
- none

---
 drivers/mmc/exynos_dw_mmc.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/mmc/exynos_dw_mmc.c +10 -1
index dfa209b..91f0163 100644
@@ -13,6 +13,7 @@
 #include <asm/arch/dwmmc.h>
 #include <asm/arch/clk.h>
 #include <asm/arch/pinmux.h>
+#include <asm/arch/power.h>
 #include <asm/gpio.h>
 #include <asm-generic/errno.h>
 
@@ -166,7 +167,6 @@ static int exynos_dwmci_get_config(const void *blob, int node,
 	if (host->dev_index == host->dev_id)
 		host->dev_index = host->dev_id - PERIPH_ID_SDMMC0;
 
-
 	/* Get the bus width from the device node */
 	host->buswidth = fdtdec_get_int(blob, node, "samsung,bus-width", 0);
 	if (host->buswidth <= 0) {
@@ -229,12 +229,21 @@ int exynos_dwmmc_init(const void *blob)
 {
 	int compat_id;
 	int node_list[DWMMC_MAX_CH_NUM];
+	int boot_dev_node;
 	int err = 0, count;
 
 	compat_id = COMPAT_SAMSUNG_EXYNOS_DWMMC;
 
 	count = fdtdec_find_aliases_for_id(blob, "mmc",
 				compat_id, node_list, DWMMC_MAX_CH_NUM);
+
+	/* For DWMMC always set boot device as mmc 0 */
+	if (count >= 3 && get_boot_mode() == BOOT_MODE_SD) {
+		boot_dev_node = node_list[2];
+		node_list[2] = node_list[0];
+		node_list[0] = boot_dev_node;
+	}
+
 	err = exynos_dwmci_process_node(blob, node_list, count);
 
 	return err;
Signature · 1 line
1.9.1
#30 lore raw

PATCH v2 4/4 mmc: print SD/eMMC type for inited mmc devices

In reply to Przemyslaw Marczak

Depending on the boot priority, the eMMC/SD cards, can be initialized with the same numbers for each boot.

To be sure which mmc device is SD and which is eMMC, this info is printed by 'mmc list' command, when the init is done.

---
Changes v2:
- none

---
 drivers/mmc/mmc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mmc/mmc.c +8 -0
index b8039cd..a13769e 100644
@@ -1693,11 +1693,19 @@ void print_mmc_devices(char separator)
 {
 	struct mmc *m;
 	struct list_head *entry;
+	char *mmc_type;
 
 	list_for_each(entry, &mmc_devices) {
 		m = list_entry(entry, struct mmc, link);
 
+		if (m->has_init)
+			mmc_type = IS_SD(m) ? "SD" : "eMMC";
+		else
+			mmc_type = NULL;
+
 		printf("%s: %d", m->cfg->name, m->block_dev.dev);
+		if (mmc_type)
+			printf(" (%s)", mmc_type);
 
 		if (entry->next != &mmc_devices) {
 			printf("%c", separator);
Signature · 1 line
1.9.1
#31 lore raw

v3 cover exynos-dwmmc: set init priority for boot channel

In reply to Przemyslaw Marczak

The dw mmc driver init priority was always the same: ch 0, ch 1, ch 2. On some boards (e.g. Odroid XU3) the dwmmc driver is enabled for all mmc channels. In this case, when boot device is switchable (SD/eMMC), the default MMC device will be 0 or 1.
Change the init priority to boot device, always init the boot device as mmc 0.
This fixes the issue with 'saveenv' command, because the MMC env device number is always the same.

Przemyslaw Marczak (2):
mmc: exynos dwmmc: check boot mode before init dwmmc
mmc: print SD/eMMC type for inited mmc devices

 drivers/mmc/exynos_dw_mmc.c | 11 ++++++++++-
 drivers/mmc/mmc.c           |  8 ++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
Signature · 1 line
1.9.1
#32 lore raw

PATCH v3 1/2 mmc: exynos dwmmc: check boot mode before init dwmmc

Before this commit, the mmc devices were always registered in the same order. So dwmmc channel 0 was registered as mmc 0, channel 1 as mmc 1, etc.
In case of possibility to boot from more then one device, the CONFIG_SYS_MMC_ENV_DEV should always point to right mmc device.

This can be achieved by init boot device as first, so it will be always registered as mmc 0. Thanks to this, the 'saveenv' command will work fine for all mmc boot devices.

Exynos based boards usually uses mmc host channels configuration:
- 0, or 0+1 for 8 bit - as a default boot device (usually eMMC)
- 2 for 4bit - as an optional boot device (usually SD card slot)

And usually the boot order is defined by OM pin configuration, which can be changed in a few ways, eg.
- Odroid U3 - eMMC card insertion -> first boot from eMMC
- Odroid X2/XU3 - boot priority jumper

By this commit, Exynos dwmmc driver will check the OM pin configuration, and then try to init the boot device and register it as mmc 0.

Cc Minkyu Kang <[email protected]>
Cc Jaehoon Chung <[email protected]>
Cc Pantelis Antoniou <[email protected]>
Cc Simon Glass <[email protected]>
Cc Akshay Saraswat <[email protected]>

---
Changes v2:
- none

Changes v3:
- Fix email to Pantelis

---
 drivers/mmc/exynos_dw_mmc.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/mmc/exynos_dw_mmc.c +10 -1
index dfa209b..91f0163 100644
@@ -13,6 +13,7 @@
 #include <asm/arch/dwmmc.h>
 #include <asm/arch/clk.h>
 #include <asm/arch/pinmux.h>
+#include <asm/arch/power.h>
 #include <asm/gpio.h>
 #include <asm-generic/errno.h>
 
@@ -166,7 +167,6 @@ static int exynos_dwmci_get_config(const void *blob, int node,
 	if (host->dev_index == host->dev_id)
 		host->dev_index = host->dev_id - PERIPH_ID_SDMMC0;
 
-
 	/* Get the bus width from the device node */
 	host->buswidth = fdtdec_get_int(blob, node, "samsung,bus-width", 0);
 	if (host->buswidth <= 0) {
@@ -229,12 +229,21 @@ int exynos_dwmmc_init(const void *blob)
 {
 	int compat_id;
 	int node_list[DWMMC_MAX_CH_NUM];
+	int boot_dev_node;
 	int err = 0, count;
 
 	compat_id = COMPAT_SAMSUNG_EXYNOS_DWMMC;
 
 	count = fdtdec_find_aliases_for_id(blob, "mmc",
 				compat_id, node_list, DWMMC_MAX_CH_NUM);
+
+	/* For DWMMC always set boot device as mmc 0 */
+	if (count >= 3 && get_boot_mode() == BOOT_MODE_SD) {
+		boot_dev_node = node_list[2];
+		node_list[2] = node_list[0];
+		node_list[0] = boot_dev_node;
+	}
+
 	err = exynos_dwmci_process_node(blob, node_list, count);
 
 	return err;
Signature · 1 line
1.9.1
#33 lore raw

PATCH v3 1/2 mmc: exynos dwmmc: check boot mode before init dwmmc

Hi Przemyslaw,

Quoted 86 lines · Przemyslaw Marczak

Before this commit, the mmc devices were always registered in the same order. So dwmmc channel 0 was registered as mmc 0, channel 1 as mmc 1, etc.
In case of possibility to boot from more then one device, the CONFIG_SYS_MMC_ENV_DEV should always point to right mmc device.

This can be achieved by init boot device as first, so it will be always registered as mmc 0. Thanks to this, the 'saveenv' command will work fine for all mmc boot devices.

Exynos based boards usually uses mmc host channels configuration:
- 0, or 0+1 for 8 bit - as a default boot device (usually eMMC)
- 2 for 4bit - as an optional boot device (usually SD card slot)

And usually the boot order is defined by OM pin configuration, which can be changed in a few ways, eg.
- Odroid U3 - eMMC card insertion -> first boot from eMMC
- Odroid X2/XU3 - boot priority jumper

By this commit, Exynos dwmmc driver will check the OM pin configuration, and then try to init the boot device and register it as mmc 0.

Cc Minkyu Kang <[email protected]>
Cc Jaehoon Chung <[email protected]>
Cc Pantelis Antoniou <[email protected]>
Cc Simon Glass <[email protected]>
Cc Akshay Saraswat <[email protected]>

---
Changes v2:
- none

Changes v3:
- Fix email to Pantelis
---
drivers/mmc/exynos_dw_mmc.c | 11 ++++++++++-

1 file changed, 10 insertions(+), 1 deletion(-)
drivers/mmc/exynos_dw_mmc.c +10 -1
index dfa209b..91f0163 100644
@@ -13,6 +13,7 @@
 #include <asm/arch/dwmmc.h>
 #include <asm/arch/clk.h>
 #include <asm/arch/pinmux.h>
+#include <asm/arch/power.h>
 #include <asm/gpio.h>
 #include <asm-generic/errno.h>
 
@@ -166,7 +167,6 @@ static int exynos_dwmci_get_config(const void *blob, int node,
 	if (host->dev_index == host->dev_id)
 		host->dev_index = host->dev_id - PERIPH_ID_SDMMC0;
 
-
 	/* Get the bus width from the device node */
 	host->buswidth = fdtdec_get_int(blob, node, "samsung,bus-width", 0);
 	if (host->buswidth <= 0) {
@@ -229,12 +229,21 @@ int exynos_dwmmc_init(const void *blob)
 {
 	int compat_id;
 	int node_list[DWMMC_MAX_CH_NUM];
+	int boot_dev_node;
 	int err = 0, count;
 
 	compat_id = COMPAT_SAMSUNG_EXYNOS_DWMMC;
 
 	count = fdtdec_find_aliases_for_id(blob, "mmc",
 				compat_id, node_list, DWMMC_MAX_CH_NUM);
+
+	/* For DWMMC always set boot device as mmc 0 */
+	if (count >= 3 && get_boot_mode() == BOOT_MODE_SD) {
+		boot_dev_node = node_list[2];
+		node_list[2] = node_list[0];
+		node_list[0] = boot_dev_node;
+	}
+
 	err = exynos_dwmci_process_node(blob, node_list, count);
 
 	return err;
Signature · 1 line
1.9.1

Applied, but ick? Driver model should make this go away.

? Pantelis

#34 lore raw

PATCH v3 2/2 mmc: print SD/eMMC type for inited mmc devices

In reply to Przemyslaw Marczak

Depending on the boot priority, the eMMC/SD cards, can be initialized with the same numbers for each boot.

To be sure which mmc device is SD and which is eMMC, this info is printed by 'mmc list' command, when the init is done.

---
Changes v2:
- none

Changes v3:
- Fix email to Pantelis

---
 drivers/mmc/mmc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mmc/mmc.c +8 -0
index b8039cd..a13769e 100644
@@ -1693,11 +1693,19 @@ void print_mmc_devices(char separator)
 {
 	struct mmc *m;
 	struct list_head *entry;
+	char *mmc_type;
 
 	list_for_each(entry, &mmc_devices) {
 		m = list_entry(entry, struct mmc, link);
 
+		if (m->has_init)
+			mmc_type = IS_SD(m) ? "SD" : "eMMC";
+		else
+			mmc_type = NULL;
+
 		printf("%s: %d", m->cfg->name, m->block_dev.dev);
+		if (mmc_type)
+			printf(" (%s)", mmc_type);
 
 		if (entry->next != &mmc_devices) {
 			printf("%c", separator);
Signature · 1 line
1.9.1
#35 lore raw

PATCH v3 2/2 mmc: print SD/eMMC type for inited mmc devices

Hi Przemyslaw,

Quoted 49 lines · Przemyslaw Marczak

Depending on the boot priority, the eMMC/SD cards, can be initialized with the same numbers for each boot.

To be sure which mmc device is SD and which is eMMC, this info is printed by 'mmc list' command, when the init is done.

---
Changes v2:
- none

Changes v3:
- Fix email to Pantelis
---
drivers/mmc/mmc.c | 8 ++++++++

1 file changed, 8 insertions(+)
drivers/mmc/mmc.c +8 -0
index b8039cd..a13769e 100644
@@ -1693,11 +1693,19 @@ void print_mmc_devices(char separator)
 {
 	struct mmc *m;
 	struct list_head *entry;
+	char *mmc_type;
 
 	list_for_each(entry, &mmc_devices) {
 		m = list_entry(entry, struct mmc, link);
 
+		if (m->has_init)
+			mmc_type = IS_SD(m) ? "SD" : "eMMC";
+		else
+			mmc_type = NULL;
+
 		printf("%s: %d", m->cfg->name, m->block_dev.dev);
+		if (mmc_type)
+			printf(" (%s)", mmc_type);
 
 		if (entry->next != &mmc_devices) {
 			printf("%c", separator);
Signature · 1 line
1.9.1

Applied, thanks

? Pantelis