All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] mmc: atmel-mci: Convert to gpio descriptors
@ 2022-11-17  4:14 ` Balamanikandan Gunasundar
  0 siblings, 0 replies; 8+ messages in thread
From: Balamanikandan Gunasundar @ 2022-11-17  4:14 UTC (permalink / raw)
  To: ludovic.desroches, ulf.hansson, nicolas.ferre, alexandre.belloni,
	3chas3, linux-kernel, linux-mmc, linux-arm-kernel,
	linux-atm-general, netdev, linus.walleij, hari.prasathge
  Cc: balamanikandan.gunasundar

Changes in v2:

[PATCH 1/2] mmc: atmel-mci: Convert to gpio descriptors

 - Remove "#include <linux/gpio.h>" as it is not necessary

[PATCH 2/2] mmc: atmel-mci: move atmel MCI header file

 - Move linux/atmel-mci.h into drivers/mmc/host/atmel-mci.c as it is
   used only by one file

Balamanikandan Gunasundar (2):
  mmc: atmel-mci: Convert to gpio descriptors
  mmc: atmel-mci: move atmel MCI header file

 drivers/mmc/host/atmel-mci.c | 119 ++++++++++++++++++++++-------------
 include/linux/atmel-mci.h    |  46 --------------
 2 files changed, 77 insertions(+), 88 deletions(-)
 delete mode 100644 include/linux/atmel-mci.h

-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 0/2] mmc: atmel-mci: Convert to gpio descriptors
@ 2022-11-17  4:14 ` Balamanikandan Gunasundar
  0 siblings, 0 replies; 8+ messages in thread
From: Balamanikandan Gunasundar @ 2022-11-17  4:14 UTC (permalink / raw)
  To: ludovic.desroches, ulf.hansson, nicolas.ferre, alexandre.belloni,
	3chas3, linux-kernel, linux-mmc, linux-arm-kernel,
	linux-atm-general, netdev, linus.walleij, hari.prasathge
  Cc: balamanikandan.gunasundar

Changes in v2:

[PATCH 1/2] mmc: atmel-mci: Convert to gpio descriptors

 - Remove "#include <linux/gpio.h>" as it is not necessary

[PATCH 2/2] mmc: atmel-mci: move atmel MCI header file

 - Move linux/atmel-mci.h into drivers/mmc/host/atmel-mci.c as it is
   used only by one file

Balamanikandan Gunasundar (2):
  mmc: atmel-mci: Convert to gpio descriptors
  mmc: atmel-mci: move atmel MCI header file

 drivers/mmc/host/atmel-mci.c | 119 ++++++++++++++++++++++-------------
 include/linux/atmel-mci.h    |  46 --------------
 2 files changed, 77 insertions(+), 88 deletions(-)
 delete mode 100644 include/linux/atmel-mci.h

-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/2] mmc: atmel-mci: Convert to gpio descriptors
  2022-11-17  4:14 ` Balamanikandan Gunasundar
@ 2022-11-17  4:14   ` Balamanikandan Gunasundar
  -1 siblings, 0 replies; 8+ messages in thread
From: Balamanikandan Gunasundar @ 2022-11-17  4:14 UTC (permalink / raw)
  To: ludovic.desroches, ulf.hansson, nicolas.ferre, alexandre.belloni,
	3chas3, linux-kernel, linux-mmc, linux-arm-kernel,
	linux-atm-general, netdev, linus.walleij, hari.prasathge
  Cc: balamanikandan.gunasundar

Replace the legacy GPIO APIs with gpio descriptor consumer interface.

To maintain backward compatibility, we rely on the "cd-inverted"
property to manage the invertion flag instead of GPIO property.

Signed-off-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
---
 drivers/mmc/host/atmel-mci.c | 80 ++++++++++++++++++------------------
 include/linux/atmel-mci.h    |  4 +-
 2 files changed, 41 insertions(+), 43 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 67b2cd166e56..f6194aab17df 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -11,7 +11,6 @@
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
 #include <linux/err.h>
-#include <linux/gpio.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
@@ -19,7 +18,8 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
-#include <linux/of_gpio.h>
+#include <linux/irq.h>
+#include <linux/gpio/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/scatterlist.h>
 #include <linux/seq_file.h>
@@ -389,8 +389,8 @@ struct atmel_mci_slot {
 #define ATMCI_CARD_NEED_INIT	1
 #define ATMCI_SHUTDOWN		2
 
-	int			detect_pin;
-	int			wp_pin;
+	struct gpio_desc        *detect_pin;
+	struct gpio_desc	*wp_pin;
 	bool			detect_is_active_high;
 
 	struct timer_list	detect_timer;
@@ -638,7 +638,11 @@ atmci_of_init(struct platform_device *pdev)
 			pdata->slot[slot_id].bus_width = 1;
 
 		pdata->slot[slot_id].detect_pin =
-			of_get_named_gpio(cnp, "cd-gpios", 0);
+			devm_gpiod_get_from_of_node(&pdev->dev, cnp,
+						    "cd-gpios",
+						    0, GPIOD_IN, "cd-gpios");
+		if (IS_ERR(pdata->slot[slot_id].detect_pin))
+			pdata->slot[slot_id].detect_pin = NULL;
 
 		pdata->slot[slot_id].detect_is_active_high =
 			of_property_read_bool(cnp, "cd-inverted");
@@ -647,7 +651,11 @@ atmci_of_init(struct platform_device *pdev)
 			of_property_read_bool(cnp, "non-removable");
 
 		pdata->slot[slot_id].wp_pin =
-			of_get_named_gpio(cnp, "wp-gpios", 0);
+			devm_gpiod_get_from_of_node(&pdev->dev, cnp,
+						    "wp-gpios",
+						    0, GPIOD_IN, "wp-gpios");
+		if (IS_ERR(pdata->slot[slot_id].wp_pin))
+			pdata->slot[slot_id].wp_pin = NULL;
 	}
 
 	return pdata;
@@ -1511,8 +1519,8 @@ static int atmci_get_ro(struct mmc_host *mmc)
 	int			read_only = -ENOSYS;
 	struct atmel_mci_slot	*slot = mmc_priv(mmc);
 
-	if (gpio_is_valid(slot->wp_pin)) {
-		read_only = gpio_get_value(slot->wp_pin);
+	if (slot->wp_pin) {
+		read_only = gpiod_get_value(slot->wp_pin);
 		dev_dbg(&mmc->class_dev, "card is %s\n",
 				read_only ? "read-only" : "read-write");
 	}
@@ -1525,8 +1533,8 @@ static int atmci_get_cd(struct mmc_host *mmc)
 	int			present = -ENOSYS;
 	struct atmel_mci_slot	*slot = mmc_priv(mmc);
 
-	if (gpio_is_valid(slot->detect_pin)) {
-		present = !(gpio_get_value(slot->detect_pin) ^
+	if (slot->detect_pin) {
+		present = !(gpiod_get_raw_value(slot->detect_pin) ^
 			    slot->detect_is_active_high);
 		dev_dbg(&mmc->class_dev, "card is %spresent\n",
 				present ? "" : "not ");
@@ -1639,8 +1647,8 @@ static void atmci_detect_change(struct timer_list *t)
 	if (test_bit(ATMCI_SHUTDOWN, &slot->flags))
 		return;
 
-	enable_irq(gpio_to_irq(slot->detect_pin));
-	present = !(gpio_get_value(slot->detect_pin) ^
+	enable_irq(gpiod_to_irq(slot->detect_pin));
+	present = !(gpiod_get_raw_value(slot->detect_pin) ^
 		    slot->detect_is_active_high);
 	present_old = test_bit(ATMCI_CARD_PRESENT, &slot->flags);
 
@@ -2241,9 +2249,9 @@ static int atmci_init_slot(struct atmel_mci *host,
 	dev_dbg(&mmc->class_dev,
 	        "slot[%u]: bus_width=%u, detect_pin=%d, "
 		"detect_is_active_high=%s, wp_pin=%d\n",
-		id, slot_data->bus_width, slot_data->detect_pin,
+		id, slot_data->bus_width, desc_to_gpio(slot_data->detect_pin),
 		slot_data->detect_is_active_high ? "true" : "false",
-		slot_data->wp_pin);
+		desc_to_gpio(slot_data->wp_pin));
 
 	mmc->ops = &atmci_ops;
 	mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
@@ -2279,51 +2287,43 @@ static int atmci_init_slot(struct atmel_mci *host,
 
 	/* Assume card is present initially */
 	set_bit(ATMCI_CARD_PRESENT, &slot->flags);
-	if (gpio_is_valid(slot->detect_pin)) {
-		if (devm_gpio_request(&host->pdev->dev, slot->detect_pin,
-				      "mmc_detect")) {
-			dev_dbg(&mmc->class_dev, "no detect pin available\n");
-			slot->detect_pin = -EBUSY;
-		} else if (gpio_get_value(slot->detect_pin) ^
-				slot->detect_is_active_high) {
+	if (slot->detect_pin) {
+		if (gpiod_get_raw_value(slot->detect_pin) ^
+		    slot->detect_is_active_high) {
 			clear_bit(ATMCI_CARD_PRESENT, &slot->flags);
 		}
+	} else {
+		dev_dbg(&mmc->class_dev, "no detect pin available\n");
 	}
 
-	if (!gpio_is_valid(slot->detect_pin)) {
+	if (!slot->detect_pin) {
 		if (slot_data->non_removable)
 			mmc->caps |= MMC_CAP_NONREMOVABLE;
 		else
 			mmc->caps |= MMC_CAP_NEEDS_POLL;
 	}
 
-	if (gpio_is_valid(slot->wp_pin)) {
-		if (devm_gpio_request(&host->pdev->dev, slot->wp_pin,
-				      "mmc_wp")) {
-			dev_dbg(&mmc->class_dev, "no WP pin available\n");
-			slot->wp_pin = -EBUSY;
-		}
-	}
+	if (!slot->wp_pin)
+		dev_dbg(&mmc->class_dev, "no WP pin available\n");
 
 	host->slot[id] = slot;
 	mmc_regulator_get_supply(mmc);
-	mmc_pwrseq_alloc(slot->mmc);
 	mmc_add_host(mmc);
 
-	if (gpio_is_valid(slot->detect_pin)) {
+	if (slot->detect_pin) {
 		int ret;
 
 		timer_setup(&slot->detect_timer, atmci_detect_change, 0);
 
-		ret = request_irq(gpio_to_irq(slot->detect_pin),
-				atmci_detect_interrupt,
-				IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
-				"mmc-detect", slot);
+		ret = request_irq(gpiod_to_irq(slot->detect_pin),
+				  atmci_detect_interrupt,
+				  IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+				  "mmc-detect", slot);
 		if (ret) {
 			dev_dbg(&mmc->class_dev,
 				"could not request IRQ %d for detect pin\n",
-				gpio_to_irq(slot->detect_pin));
-			slot->detect_pin = -EBUSY;
+				gpiod_to_irq(slot->detect_pin));
+			slot->detect_pin = NULL;
 		}
 	}
 
@@ -2342,10 +2342,8 @@ static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
 
 	mmc_remove_host(slot->mmc);
 
-	if (gpio_is_valid(slot->detect_pin)) {
-		int pin = slot->detect_pin;
-
-		free_irq(gpio_to_irq(pin), slot);
+	if (slot->detect_pin) {
+		free_irq(gpiod_to_irq(slot->detect_pin), slot);
 		del_timer_sync(&slot->detect_timer);
 	}
 
diff --git a/include/linux/atmel-mci.h b/include/linux/atmel-mci.h
index 1491af38cc6e..017e7d8f6126 100644
--- a/include/linux/atmel-mci.h
+++ b/include/linux/atmel-mci.h
@@ -26,8 +26,8 @@
  */
 struct mci_slot_pdata {
 	unsigned int		bus_width;
-	int			detect_pin;
-	int			wp_pin;
+	struct gpio_desc        *detect_pin;
+	struct gpio_desc	*wp_pin;
 	bool			detect_is_active_high;
 	bool			non_removable;
 };
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 1/2] mmc: atmel-mci: Convert to gpio descriptors
@ 2022-11-17  4:14   ` Balamanikandan Gunasundar
  0 siblings, 0 replies; 8+ messages in thread
From: Balamanikandan Gunasundar @ 2022-11-17  4:14 UTC (permalink / raw)
  To: ludovic.desroches, ulf.hansson, nicolas.ferre, alexandre.belloni,
	3chas3, linux-kernel, linux-mmc, linux-arm-kernel,
	linux-atm-general, netdev, linus.walleij, hari.prasathge
  Cc: balamanikandan.gunasundar

Replace the legacy GPIO APIs with gpio descriptor consumer interface.

To maintain backward compatibility, we rely on the "cd-inverted"
property to manage the invertion flag instead of GPIO property.

Signed-off-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
---
 drivers/mmc/host/atmel-mci.c | 80 ++++++++++++++++++------------------
 include/linux/atmel-mci.h    |  4 +-
 2 files changed, 41 insertions(+), 43 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 67b2cd166e56..f6194aab17df 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -11,7 +11,6 @@
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
 #include <linux/err.h>
-#include <linux/gpio.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
@@ -19,7 +18,8 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
-#include <linux/of_gpio.h>
+#include <linux/irq.h>
+#include <linux/gpio/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/scatterlist.h>
 #include <linux/seq_file.h>
@@ -389,8 +389,8 @@ struct atmel_mci_slot {
 #define ATMCI_CARD_NEED_INIT	1
 #define ATMCI_SHUTDOWN		2
 
-	int			detect_pin;
-	int			wp_pin;
+	struct gpio_desc        *detect_pin;
+	struct gpio_desc	*wp_pin;
 	bool			detect_is_active_high;
 
 	struct timer_list	detect_timer;
@@ -638,7 +638,11 @@ atmci_of_init(struct platform_device *pdev)
 			pdata->slot[slot_id].bus_width = 1;
 
 		pdata->slot[slot_id].detect_pin =
-			of_get_named_gpio(cnp, "cd-gpios", 0);
+			devm_gpiod_get_from_of_node(&pdev->dev, cnp,
+						    "cd-gpios",
+						    0, GPIOD_IN, "cd-gpios");
+		if (IS_ERR(pdata->slot[slot_id].detect_pin))
+			pdata->slot[slot_id].detect_pin = NULL;
 
 		pdata->slot[slot_id].detect_is_active_high =
 			of_property_read_bool(cnp, "cd-inverted");
@@ -647,7 +651,11 @@ atmci_of_init(struct platform_device *pdev)
 			of_property_read_bool(cnp, "non-removable");
 
 		pdata->slot[slot_id].wp_pin =
-			of_get_named_gpio(cnp, "wp-gpios", 0);
+			devm_gpiod_get_from_of_node(&pdev->dev, cnp,
+						    "wp-gpios",
+						    0, GPIOD_IN, "wp-gpios");
+		if (IS_ERR(pdata->slot[slot_id].wp_pin))
+			pdata->slot[slot_id].wp_pin = NULL;
 	}
 
 	return pdata;
@@ -1511,8 +1519,8 @@ static int atmci_get_ro(struct mmc_host *mmc)
 	int			read_only = -ENOSYS;
 	struct atmel_mci_slot	*slot = mmc_priv(mmc);
 
-	if (gpio_is_valid(slot->wp_pin)) {
-		read_only = gpio_get_value(slot->wp_pin);
+	if (slot->wp_pin) {
+		read_only = gpiod_get_value(slot->wp_pin);
 		dev_dbg(&mmc->class_dev, "card is %s\n",
 				read_only ? "read-only" : "read-write");
 	}
@@ -1525,8 +1533,8 @@ static int atmci_get_cd(struct mmc_host *mmc)
 	int			present = -ENOSYS;
 	struct atmel_mci_slot	*slot = mmc_priv(mmc);
 
-	if (gpio_is_valid(slot->detect_pin)) {
-		present = !(gpio_get_value(slot->detect_pin) ^
+	if (slot->detect_pin) {
+		present = !(gpiod_get_raw_value(slot->detect_pin) ^
 			    slot->detect_is_active_high);
 		dev_dbg(&mmc->class_dev, "card is %spresent\n",
 				present ? "" : "not ");
@@ -1639,8 +1647,8 @@ static void atmci_detect_change(struct timer_list *t)
 	if (test_bit(ATMCI_SHUTDOWN, &slot->flags))
 		return;
 
-	enable_irq(gpio_to_irq(slot->detect_pin));
-	present = !(gpio_get_value(slot->detect_pin) ^
+	enable_irq(gpiod_to_irq(slot->detect_pin));
+	present = !(gpiod_get_raw_value(slot->detect_pin) ^
 		    slot->detect_is_active_high);
 	present_old = test_bit(ATMCI_CARD_PRESENT, &slot->flags);
 
@@ -2241,9 +2249,9 @@ static int atmci_init_slot(struct atmel_mci *host,
 	dev_dbg(&mmc->class_dev,
 	        "slot[%u]: bus_width=%u, detect_pin=%d, "
 		"detect_is_active_high=%s, wp_pin=%d\n",
-		id, slot_data->bus_width, slot_data->detect_pin,
+		id, slot_data->bus_width, desc_to_gpio(slot_data->detect_pin),
 		slot_data->detect_is_active_high ? "true" : "false",
-		slot_data->wp_pin);
+		desc_to_gpio(slot_data->wp_pin));
 
 	mmc->ops = &atmci_ops;
 	mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
@@ -2279,51 +2287,43 @@ static int atmci_init_slot(struct atmel_mci *host,
 
 	/* Assume card is present initially */
 	set_bit(ATMCI_CARD_PRESENT, &slot->flags);
-	if (gpio_is_valid(slot->detect_pin)) {
-		if (devm_gpio_request(&host->pdev->dev, slot->detect_pin,
-				      "mmc_detect")) {
-			dev_dbg(&mmc->class_dev, "no detect pin available\n");
-			slot->detect_pin = -EBUSY;
-		} else if (gpio_get_value(slot->detect_pin) ^
-				slot->detect_is_active_high) {
+	if (slot->detect_pin) {
+		if (gpiod_get_raw_value(slot->detect_pin) ^
+		    slot->detect_is_active_high) {
 			clear_bit(ATMCI_CARD_PRESENT, &slot->flags);
 		}
+	} else {
+		dev_dbg(&mmc->class_dev, "no detect pin available\n");
 	}
 
-	if (!gpio_is_valid(slot->detect_pin)) {
+	if (!slot->detect_pin) {
 		if (slot_data->non_removable)
 			mmc->caps |= MMC_CAP_NONREMOVABLE;
 		else
 			mmc->caps |= MMC_CAP_NEEDS_POLL;
 	}
 
-	if (gpio_is_valid(slot->wp_pin)) {
-		if (devm_gpio_request(&host->pdev->dev, slot->wp_pin,
-				      "mmc_wp")) {
-			dev_dbg(&mmc->class_dev, "no WP pin available\n");
-			slot->wp_pin = -EBUSY;
-		}
-	}
+	if (!slot->wp_pin)
+		dev_dbg(&mmc->class_dev, "no WP pin available\n");
 
 	host->slot[id] = slot;
 	mmc_regulator_get_supply(mmc);
-	mmc_pwrseq_alloc(slot->mmc);
 	mmc_add_host(mmc);
 
-	if (gpio_is_valid(slot->detect_pin)) {
+	if (slot->detect_pin) {
 		int ret;
 
 		timer_setup(&slot->detect_timer, atmci_detect_change, 0);
 
-		ret = request_irq(gpio_to_irq(slot->detect_pin),
-				atmci_detect_interrupt,
-				IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
-				"mmc-detect", slot);
+		ret = request_irq(gpiod_to_irq(slot->detect_pin),
+				  atmci_detect_interrupt,
+				  IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+				  "mmc-detect", slot);
 		if (ret) {
 			dev_dbg(&mmc->class_dev,
 				"could not request IRQ %d for detect pin\n",
-				gpio_to_irq(slot->detect_pin));
-			slot->detect_pin = -EBUSY;
+				gpiod_to_irq(slot->detect_pin));
+			slot->detect_pin = NULL;
 		}
 	}
 
@@ -2342,10 +2342,8 @@ static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
 
 	mmc_remove_host(slot->mmc);
 
-	if (gpio_is_valid(slot->detect_pin)) {
-		int pin = slot->detect_pin;
-
-		free_irq(gpio_to_irq(pin), slot);
+	if (slot->detect_pin) {
+		free_irq(gpiod_to_irq(slot->detect_pin), slot);
 		del_timer_sync(&slot->detect_timer);
 	}
 
diff --git a/include/linux/atmel-mci.h b/include/linux/atmel-mci.h
index 1491af38cc6e..017e7d8f6126 100644
--- a/include/linux/atmel-mci.h
+++ b/include/linux/atmel-mci.h
@@ -26,8 +26,8 @@
  */
 struct mci_slot_pdata {
 	unsigned int		bus_width;
-	int			detect_pin;
-	int			wp_pin;
+	struct gpio_desc        *detect_pin;
+	struct gpio_desc	*wp_pin;
 	bool			detect_is_active_high;
 	bool			non_removable;
 };
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/2] mmc: atmel-mci: move atmel MCI header file
  2022-11-17  4:14 ` Balamanikandan Gunasundar
@ 2022-11-17  4:14   ` Balamanikandan Gunasundar
  -1 siblings, 0 replies; 8+ messages in thread
From: Balamanikandan Gunasundar @ 2022-11-17  4:14 UTC (permalink / raw)
  To: ludovic.desroches, ulf.hansson, nicolas.ferre, alexandre.belloni,
	3chas3, linux-kernel, linux-mmc, linux-arm-kernel,
	linux-atm-general, netdev, linus.walleij, hari.prasathge
  Cc: balamanikandan.gunasundar

Move the contents of linux/atmel-mci.h into
drivers/mmc/host/atmel-mci.c as it is only used in one file

Signed-off-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
---
 drivers/mmc/host/atmel-mci.c | 39 +++++++++++++++++++++++++++++-
 include/linux/atmel-mci.h    | 46 ------------------------------------
 2 files changed, 38 insertions(+), 47 deletions(-)
 delete mode 100644 include/linux/atmel-mci.h

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index f6194aab17df..d1e2011f881b 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -30,7 +30,6 @@
 #include <linux/mmc/host.h>
 #include <linux/mmc/sdio.h>
 
-#include <linux/atmel-mci.h>
 #include <linux/atmel_pdc.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
@@ -41,6 +40,8 @@
 #include <asm/unaligned.h>
 #include "../core/pwrseq.h"
 
+#define ATMCI_MAX_NR_SLOTS	2
+
 /*
  * Superset of MCI IP registers integrated in Atmel AT91 Processor
  * Registers and bitfields marked with [2] are only available in MCI2
@@ -202,6 +203,42 @@ enum atmci_pdc_buf {
 	PDC_SECOND_BUF,
 };
 
+/**
+ * struct mci_slot_pdata - board-specific per-slot configuration
+ * @bus_width: Number of data lines wired up the slot
+ * @detect_pin: GPIO pin wired to the card detect switch
+ * @wp_pin: GPIO pin wired to the write protect sensor
+ * @detect_is_active_high: The state of the detect pin when it is active
+ * @non_removable: The slot is not removable, only detect once
+ *
+ * If a given slot is not present on the board, @bus_width should be
+ * set to 0. The other fields are ignored in this case.
+ *
+ * Any pins that aren't available should be set to a negative value.
+ *
+ * Note that support for multiple slots is experimental -- some cards
+ * might get upset if we don't get the clock management exactly right.
+ * But in most cases, it should work just fine.
+ */
+struct mci_slot_pdata {
+	unsigned int		bus_width;
+	struct gpio_desc        *detect_pin;
+	struct gpio_desc	*wp_pin;
+	bool			detect_is_active_high;
+	bool			non_removable;
+};
+
+/**
+ * struct mci_platform_data - board-specific MMC/SDcard configuration
+ * @dma_slave: DMA slave interface to use in data transfers.
+ * @slot: Per-slot configuration data.
+ */
+struct mci_platform_data {
+	void			*dma_slave;
+	dma_filter_fn		dma_filter;
+	struct mci_slot_pdata	slot[ATMCI_MAX_NR_SLOTS];
+};
+
 struct atmel_mci_caps {
 	bool    has_dma_conf_reg;
 	bool    has_pdc;
diff --git a/include/linux/atmel-mci.h b/include/linux/atmel-mci.h
deleted file mode 100644
index 017e7d8f6126..000000000000
--- a/include/linux/atmel-mci.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __LINUX_ATMEL_MCI_H
-#define __LINUX_ATMEL_MCI_H
-
-#include <linux/types.h>
-#include <linux/dmaengine.h>
-
-#define ATMCI_MAX_NR_SLOTS	2
-
-/**
- * struct mci_slot_pdata - board-specific per-slot configuration
- * @bus_width: Number of data lines wired up the slot
- * @detect_pin: GPIO pin wired to the card detect switch
- * @wp_pin: GPIO pin wired to the write protect sensor
- * @detect_is_active_high: The state of the detect pin when it is active
- * @non_removable: The slot is not removable, only detect once
- *
- * If a given slot is not present on the board, @bus_width should be
- * set to 0. The other fields are ignored in this case.
- *
- * Any pins that aren't available should be set to a negative value.
- *
- * Note that support for multiple slots is experimental -- some cards
- * might get upset if we don't get the clock management exactly right.
- * But in most cases, it should work just fine.
- */
-struct mci_slot_pdata {
-	unsigned int		bus_width;
-	struct gpio_desc        *detect_pin;
-	struct gpio_desc	*wp_pin;
-	bool			detect_is_active_high;
-	bool			non_removable;
-};
-
-/**
- * struct mci_platform_data - board-specific MMC/SDcard configuration
- * @dma_slave: DMA slave interface to use in data transfers.
- * @slot: Per-slot configuration data.
- */
-struct mci_platform_data {
-	void			*dma_slave;
-	dma_filter_fn		dma_filter;
-	struct mci_slot_pdata	slot[ATMCI_MAX_NR_SLOTS];
-};
-
-#endif /* __LINUX_ATMEL_MCI_H */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/2] mmc: atmel-mci: move atmel MCI header file
@ 2022-11-17  4:14   ` Balamanikandan Gunasundar
  0 siblings, 0 replies; 8+ messages in thread
From: Balamanikandan Gunasundar @ 2022-11-17  4:14 UTC (permalink / raw)
  To: ludovic.desroches, ulf.hansson, nicolas.ferre, alexandre.belloni,
	3chas3, linux-kernel, linux-mmc, linux-arm-kernel,
	linux-atm-general, netdev, linus.walleij, hari.prasathge
  Cc: balamanikandan.gunasundar

Move the contents of linux/atmel-mci.h into
drivers/mmc/host/atmel-mci.c as it is only used in one file

Signed-off-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
---
 drivers/mmc/host/atmel-mci.c | 39 +++++++++++++++++++++++++++++-
 include/linux/atmel-mci.h    | 46 ------------------------------------
 2 files changed, 38 insertions(+), 47 deletions(-)
 delete mode 100644 include/linux/atmel-mci.h

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index f6194aab17df..d1e2011f881b 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -30,7 +30,6 @@
 #include <linux/mmc/host.h>
 #include <linux/mmc/sdio.h>
 
-#include <linux/atmel-mci.h>
 #include <linux/atmel_pdc.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
@@ -41,6 +40,8 @@
 #include <asm/unaligned.h>
 #include "../core/pwrseq.h"
 
+#define ATMCI_MAX_NR_SLOTS	2
+
 /*
  * Superset of MCI IP registers integrated in Atmel AT91 Processor
  * Registers and bitfields marked with [2] are only available in MCI2
@@ -202,6 +203,42 @@ enum atmci_pdc_buf {
 	PDC_SECOND_BUF,
 };
 
+/**
+ * struct mci_slot_pdata - board-specific per-slot configuration
+ * @bus_width: Number of data lines wired up the slot
+ * @detect_pin: GPIO pin wired to the card detect switch
+ * @wp_pin: GPIO pin wired to the write protect sensor
+ * @detect_is_active_high: The state of the detect pin when it is active
+ * @non_removable: The slot is not removable, only detect once
+ *
+ * If a given slot is not present on the board, @bus_width should be
+ * set to 0. The other fields are ignored in this case.
+ *
+ * Any pins that aren't available should be set to a negative value.
+ *
+ * Note that support for multiple slots is experimental -- some cards
+ * might get upset if we don't get the clock management exactly right.
+ * But in most cases, it should work just fine.
+ */
+struct mci_slot_pdata {
+	unsigned int		bus_width;
+	struct gpio_desc        *detect_pin;
+	struct gpio_desc	*wp_pin;
+	bool			detect_is_active_high;
+	bool			non_removable;
+};
+
+/**
+ * struct mci_platform_data - board-specific MMC/SDcard configuration
+ * @dma_slave: DMA slave interface to use in data transfers.
+ * @slot: Per-slot configuration data.
+ */
+struct mci_platform_data {
+	void			*dma_slave;
+	dma_filter_fn		dma_filter;
+	struct mci_slot_pdata	slot[ATMCI_MAX_NR_SLOTS];
+};
+
 struct atmel_mci_caps {
 	bool    has_dma_conf_reg;
 	bool    has_pdc;
diff --git a/include/linux/atmel-mci.h b/include/linux/atmel-mci.h
deleted file mode 100644
index 017e7d8f6126..000000000000
--- a/include/linux/atmel-mci.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __LINUX_ATMEL_MCI_H
-#define __LINUX_ATMEL_MCI_H
-
-#include <linux/types.h>
-#include <linux/dmaengine.h>
-
-#define ATMCI_MAX_NR_SLOTS	2
-
-/**
- * struct mci_slot_pdata - board-specific per-slot configuration
- * @bus_width: Number of data lines wired up the slot
- * @detect_pin: GPIO pin wired to the card detect switch
- * @wp_pin: GPIO pin wired to the write protect sensor
- * @detect_is_active_high: The state of the detect pin when it is active
- * @non_removable: The slot is not removable, only detect once
- *
- * If a given slot is not present on the board, @bus_width should be
- * set to 0. The other fields are ignored in this case.
- *
- * Any pins that aren't available should be set to a negative value.
- *
- * Note that support for multiple slots is experimental -- some cards
- * might get upset if we don't get the clock management exactly right.
- * But in most cases, it should work just fine.
- */
-struct mci_slot_pdata {
-	unsigned int		bus_width;
-	struct gpio_desc        *detect_pin;
-	struct gpio_desc	*wp_pin;
-	bool			detect_is_active_high;
-	bool			non_removable;
-};
-
-/**
- * struct mci_platform_data - board-specific MMC/SDcard configuration
- * @dma_slave: DMA slave interface to use in data transfers.
- * @slot: Per-slot configuration data.
- */
-struct mci_platform_data {
-	void			*dma_slave;
-	dma_filter_fn		dma_filter;
-	struct mci_slot_pdata	slot[ATMCI_MAX_NR_SLOTS];
-};
-
-#endif /* __LINUX_ATMEL_MCI_H */
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] mmc: atmel-mci: Convert to gpio descriptors
  2022-11-17  4:14   ` Balamanikandan Gunasundar
@ 2022-11-18  9:20     ` Ulf Hansson
  -1 siblings, 0 replies; 8+ messages in thread
From: Ulf Hansson @ 2022-11-18  9:20 UTC (permalink / raw)
  To: Balamanikandan Gunasundar
  Cc: ludovic.desroches, nicolas.ferre, alexandre.belloni,
	linux-kernel, linux-mmc, linux-arm-kernel, linus.walleij,
	hari.prasathge, Dmitry Torokhov

- trimmed cc-list, + Dmitry

On Thu, 17 Nov 2022 at 05:15, Balamanikandan Gunasundar
<balamanikandan.gunasundar@microchip.com> wrote:
>
> Replace the legacy GPIO APIs with gpio descriptor consumer interface.
>
> To maintain backward compatibility, we rely on the "cd-inverted"
> property to manage the invertion flag instead of GPIO property.
>
> Signed-off-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>

Looks like you didn't make the conversion from
devm_gpiod_get_from_of_node() into devm_fwnode_gpiod_get(), that
Dmitry suggested [1]. Please re-spin and add Dmitry to the cc-list
next time, to allow him to complete the review.

Kind regards
Uffe

[1]
https://lore.kernel.org/all/Y21+L01BcPQ35FYi@google.com/

> ---
>  drivers/mmc/host/atmel-mci.c | 80 ++++++++++++++++++------------------
>  include/linux/atmel-mci.h    |  4 +-
>  2 files changed, 41 insertions(+), 43 deletions(-)
>
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 67b2cd166e56..f6194aab17df 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -11,7 +11,6 @@
>  #include <linux/dmaengine.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/err.h>
> -#include <linux/gpio.h>
>  #include <linux/init.h>
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
> @@ -19,7 +18,8 @@
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
> -#include <linux/of_gpio.h>
> +#include <linux/irq.h>
> +#include <linux/gpio/consumer.h>
>  #include <linux/platform_device.h>
>  #include <linux/scatterlist.h>
>  #include <linux/seq_file.h>
> @@ -389,8 +389,8 @@ struct atmel_mci_slot {
>  #define ATMCI_CARD_NEED_INIT   1
>  #define ATMCI_SHUTDOWN         2
>
> -       int                     detect_pin;
> -       int                     wp_pin;
> +       struct gpio_desc        *detect_pin;
> +       struct gpio_desc        *wp_pin;
>         bool                    detect_is_active_high;
>
>         struct timer_list       detect_timer;
> @@ -638,7 +638,11 @@ atmci_of_init(struct platform_device *pdev)
>                         pdata->slot[slot_id].bus_width = 1;
>
>                 pdata->slot[slot_id].detect_pin =
> -                       of_get_named_gpio(cnp, "cd-gpios", 0);
> +                       devm_gpiod_get_from_of_node(&pdev->dev, cnp,
> +                                                   "cd-gpios",
> +                                                   0, GPIOD_IN, "cd-gpios");
> +               if (IS_ERR(pdata->slot[slot_id].detect_pin))
> +                       pdata->slot[slot_id].detect_pin = NULL;
>
>                 pdata->slot[slot_id].detect_is_active_high =
>                         of_property_read_bool(cnp, "cd-inverted");
> @@ -647,7 +651,11 @@ atmci_of_init(struct platform_device *pdev)
>                         of_property_read_bool(cnp, "non-removable");
>
>                 pdata->slot[slot_id].wp_pin =
> -                       of_get_named_gpio(cnp, "wp-gpios", 0);
> +                       devm_gpiod_get_from_of_node(&pdev->dev, cnp,
> +                                                   "wp-gpios",
> +                                                   0, GPIOD_IN, "wp-gpios");
> +               if (IS_ERR(pdata->slot[slot_id].wp_pin))
> +                       pdata->slot[slot_id].wp_pin = NULL;
>         }
>
>         return pdata;
> @@ -1511,8 +1519,8 @@ static int atmci_get_ro(struct mmc_host *mmc)
>         int                     read_only = -ENOSYS;
>         struct atmel_mci_slot   *slot = mmc_priv(mmc);
>
> -       if (gpio_is_valid(slot->wp_pin)) {
> -               read_only = gpio_get_value(slot->wp_pin);
> +       if (slot->wp_pin) {
> +               read_only = gpiod_get_value(slot->wp_pin);
>                 dev_dbg(&mmc->class_dev, "card is %s\n",
>                                 read_only ? "read-only" : "read-write");
>         }
> @@ -1525,8 +1533,8 @@ static int atmci_get_cd(struct mmc_host *mmc)
>         int                     present = -ENOSYS;
>         struct atmel_mci_slot   *slot = mmc_priv(mmc);
>
> -       if (gpio_is_valid(slot->detect_pin)) {
> -               present = !(gpio_get_value(slot->detect_pin) ^
> +       if (slot->detect_pin) {
> +               present = !(gpiod_get_raw_value(slot->detect_pin) ^
>                             slot->detect_is_active_high);
>                 dev_dbg(&mmc->class_dev, "card is %spresent\n",
>                                 present ? "" : "not ");
> @@ -1639,8 +1647,8 @@ static void atmci_detect_change(struct timer_list *t)
>         if (test_bit(ATMCI_SHUTDOWN, &slot->flags))
>                 return;
>
> -       enable_irq(gpio_to_irq(slot->detect_pin));
> -       present = !(gpio_get_value(slot->detect_pin) ^
> +       enable_irq(gpiod_to_irq(slot->detect_pin));
> +       present = !(gpiod_get_raw_value(slot->detect_pin) ^
>                     slot->detect_is_active_high);
>         present_old = test_bit(ATMCI_CARD_PRESENT, &slot->flags);
>
> @@ -2241,9 +2249,9 @@ static int atmci_init_slot(struct atmel_mci *host,
>         dev_dbg(&mmc->class_dev,
>                 "slot[%u]: bus_width=%u, detect_pin=%d, "
>                 "detect_is_active_high=%s, wp_pin=%d\n",
> -               id, slot_data->bus_width, slot_data->detect_pin,
> +               id, slot_data->bus_width, desc_to_gpio(slot_data->detect_pin),
>                 slot_data->detect_is_active_high ? "true" : "false",
> -               slot_data->wp_pin);
> +               desc_to_gpio(slot_data->wp_pin));
>
>         mmc->ops = &atmci_ops;
>         mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
> @@ -2279,51 +2287,43 @@ static int atmci_init_slot(struct atmel_mci *host,
>
>         /* Assume card is present initially */
>         set_bit(ATMCI_CARD_PRESENT, &slot->flags);
> -       if (gpio_is_valid(slot->detect_pin)) {
> -               if (devm_gpio_request(&host->pdev->dev, slot->detect_pin,
> -                                     "mmc_detect")) {
> -                       dev_dbg(&mmc->class_dev, "no detect pin available\n");
> -                       slot->detect_pin = -EBUSY;
> -               } else if (gpio_get_value(slot->detect_pin) ^
> -                               slot->detect_is_active_high) {
> +       if (slot->detect_pin) {
> +               if (gpiod_get_raw_value(slot->detect_pin) ^
> +                   slot->detect_is_active_high) {
>                         clear_bit(ATMCI_CARD_PRESENT, &slot->flags);
>                 }
> +       } else {
> +               dev_dbg(&mmc->class_dev, "no detect pin available\n");
>         }
>
> -       if (!gpio_is_valid(slot->detect_pin)) {
> +       if (!slot->detect_pin) {
>                 if (slot_data->non_removable)
>                         mmc->caps |= MMC_CAP_NONREMOVABLE;
>                 else
>                         mmc->caps |= MMC_CAP_NEEDS_POLL;
>         }
>
> -       if (gpio_is_valid(slot->wp_pin)) {
> -               if (devm_gpio_request(&host->pdev->dev, slot->wp_pin,
> -                                     "mmc_wp")) {
> -                       dev_dbg(&mmc->class_dev, "no WP pin available\n");
> -                       slot->wp_pin = -EBUSY;
> -               }
> -       }
> +       if (!slot->wp_pin)
> +               dev_dbg(&mmc->class_dev, "no WP pin available\n");
>
>         host->slot[id] = slot;
>         mmc_regulator_get_supply(mmc);
> -       mmc_pwrseq_alloc(slot->mmc);
>         mmc_add_host(mmc);
>
> -       if (gpio_is_valid(slot->detect_pin)) {
> +       if (slot->detect_pin) {
>                 int ret;
>
>                 timer_setup(&slot->detect_timer, atmci_detect_change, 0);
>
> -               ret = request_irq(gpio_to_irq(slot->detect_pin),
> -                               atmci_detect_interrupt,
> -                               IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
> -                               "mmc-detect", slot);
> +               ret = request_irq(gpiod_to_irq(slot->detect_pin),
> +                                 atmci_detect_interrupt,
> +                                 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
> +                                 "mmc-detect", slot);
>                 if (ret) {
>                         dev_dbg(&mmc->class_dev,
>                                 "could not request IRQ %d for detect pin\n",
> -                               gpio_to_irq(slot->detect_pin));
> -                       slot->detect_pin = -EBUSY;
> +                               gpiod_to_irq(slot->detect_pin));
> +                       slot->detect_pin = NULL;
>                 }
>         }
>
> @@ -2342,10 +2342,8 @@ static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
>
>         mmc_remove_host(slot->mmc);
>
> -       if (gpio_is_valid(slot->detect_pin)) {
> -               int pin = slot->detect_pin;
> -
> -               free_irq(gpio_to_irq(pin), slot);
> +       if (slot->detect_pin) {
> +               free_irq(gpiod_to_irq(slot->detect_pin), slot);
>                 del_timer_sync(&slot->detect_timer);
>         }
>
> diff --git a/include/linux/atmel-mci.h b/include/linux/atmel-mci.h
> index 1491af38cc6e..017e7d8f6126 100644
> --- a/include/linux/atmel-mci.h
> +++ b/include/linux/atmel-mci.h
> @@ -26,8 +26,8 @@
>   */
>  struct mci_slot_pdata {
>         unsigned int            bus_width;
> -       int                     detect_pin;
> -       int                     wp_pin;
> +       struct gpio_desc        *detect_pin;
> +       struct gpio_desc        *wp_pin;
>         bool                    detect_is_active_high;
>         bool                    non_removable;
>  };
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] mmc: atmel-mci: Convert to gpio descriptors
@ 2022-11-18  9:20     ` Ulf Hansson
  0 siblings, 0 replies; 8+ messages in thread
From: Ulf Hansson @ 2022-11-18  9:20 UTC (permalink / raw)
  To: Balamanikandan Gunasundar
  Cc: alexandre.belloni, linus.walleij, Dmitry Torokhov, linux-mmc,
	linux-kernel, ludovic.desroches, hari.prasathge,
	linux-arm-kernel

- trimmed cc-list, + Dmitry

On Thu, 17 Nov 2022 at 05:15, Balamanikandan Gunasundar
<balamanikandan.gunasundar@microchip.com> wrote:
>
> Replace the legacy GPIO APIs with gpio descriptor consumer interface.
>
> To maintain backward compatibility, we rely on the "cd-inverted"
> property to manage the invertion flag instead of GPIO property.
>
> Signed-off-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>

Looks like you didn't make the conversion from
devm_gpiod_get_from_of_node() into devm_fwnode_gpiod_get(), that
Dmitry suggested [1]. Please re-spin and add Dmitry to the cc-list
next time, to allow him to complete the review.

Kind regards
Uffe

[1]
https://lore.kernel.org/all/Y21+L01BcPQ35FYi@google.com/

> ---
>  drivers/mmc/host/atmel-mci.c | 80 ++++++++++++++++++------------------
>  include/linux/atmel-mci.h    |  4 +-
>  2 files changed, 41 insertions(+), 43 deletions(-)
>
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 67b2cd166e56..f6194aab17df 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -11,7 +11,6 @@
>  #include <linux/dmaengine.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/err.h>
> -#include <linux/gpio.h>
>  #include <linux/init.h>
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
> @@ -19,7 +18,8 @@
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
> -#include <linux/of_gpio.h>
> +#include <linux/irq.h>
> +#include <linux/gpio/consumer.h>
>  #include <linux/platform_device.h>
>  #include <linux/scatterlist.h>
>  #include <linux/seq_file.h>
> @@ -389,8 +389,8 @@ struct atmel_mci_slot {
>  #define ATMCI_CARD_NEED_INIT   1
>  #define ATMCI_SHUTDOWN         2
>
> -       int                     detect_pin;
> -       int                     wp_pin;
> +       struct gpio_desc        *detect_pin;
> +       struct gpio_desc        *wp_pin;
>         bool                    detect_is_active_high;
>
>         struct timer_list       detect_timer;
> @@ -638,7 +638,11 @@ atmci_of_init(struct platform_device *pdev)
>                         pdata->slot[slot_id].bus_width = 1;
>
>                 pdata->slot[slot_id].detect_pin =
> -                       of_get_named_gpio(cnp, "cd-gpios", 0);
> +                       devm_gpiod_get_from_of_node(&pdev->dev, cnp,
> +                                                   "cd-gpios",
> +                                                   0, GPIOD_IN, "cd-gpios");
> +               if (IS_ERR(pdata->slot[slot_id].detect_pin))
> +                       pdata->slot[slot_id].detect_pin = NULL;
>
>                 pdata->slot[slot_id].detect_is_active_high =
>                         of_property_read_bool(cnp, "cd-inverted");
> @@ -647,7 +651,11 @@ atmci_of_init(struct platform_device *pdev)
>                         of_property_read_bool(cnp, "non-removable");
>
>                 pdata->slot[slot_id].wp_pin =
> -                       of_get_named_gpio(cnp, "wp-gpios", 0);
> +                       devm_gpiod_get_from_of_node(&pdev->dev, cnp,
> +                                                   "wp-gpios",
> +                                                   0, GPIOD_IN, "wp-gpios");
> +               if (IS_ERR(pdata->slot[slot_id].wp_pin))
> +                       pdata->slot[slot_id].wp_pin = NULL;
>         }
>
>         return pdata;
> @@ -1511,8 +1519,8 @@ static int atmci_get_ro(struct mmc_host *mmc)
>         int                     read_only = -ENOSYS;
>         struct atmel_mci_slot   *slot = mmc_priv(mmc);
>
> -       if (gpio_is_valid(slot->wp_pin)) {
> -               read_only = gpio_get_value(slot->wp_pin);
> +       if (slot->wp_pin) {
> +               read_only = gpiod_get_value(slot->wp_pin);
>                 dev_dbg(&mmc->class_dev, "card is %s\n",
>                                 read_only ? "read-only" : "read-write");
>         }
> @@ -1525,8 +1533,8 @@ static int atmci_get_cd(struct mmc_host *mmc)
>         int                     present = -ENOSYS;
>         struct atmel_mci_slot   *slot = mmc_priv(mmc);
>
> -       if (gpio_is_valid(slot->detect_pin)) {
> -               present = !(gpio_get_value(slot->detect_pin) ^
> +       if (slot->detect_pin) {
> +               present = !(gpiod_get_raw_value(slot->detect_pin) ^
>                             slot->detect_is_active_high);
>                 dev_dbg(&mmc->class_dev, "card is %spresent\n",
>                                 present ? "" : "not ");
> @@ -1639,8 +1647,8 @@ static void atmci_detect_change(struct timer_list *t)
>         if (test_bit(ATMCI_SHUTDOWN, &slot->flags))
>                 return;
>
> -       enable_irq(gpio_to_irq(slot->detect_pin));
> -       present = !(gpio_get_value(slot->detect_pin) ^
> +       enable_irq(gpiod_to_irq(slot->detect_pin));
> +       present = !(gpiod_get_raw_value(slot->detect_pin) ^
>                     slot->detect_is_active_high);
>         present_old = test_bit(ATMCI_CARD_PRESENT, &slot->flags);
>
> @@ -2241,9 +2249,9 @@ static int atmci_init_slot(struct atmel_mci *host,
>         dev_dbg(&mmc->class_dev,
>                 "slot[%u]: bus_width=%u, detect_pin=%d, "
>                 "detect_is_active_high=%s, wp_pin=%d\n",
> -               id, slot_data->bus_width, slot_data->detect_pin,
> +               id, slot_data->bus_width, desc_to_gpio(slot_data->detect_pin),
>                 slot_data->detect_is_active_high ? "true" : "false",
> -               slot_data->wp_pin);
> +               desc_to_gpio(slot_data->wp_pin));
>
>         mmc->ops = &atmci_ops;
>         mmc->f_min = DIV_ROUND_UP(host->bus_hz, 512);
> @@ -2279,51 +2287,43 @@ static int atmci_init_slot(struct atmel_mci *host,
>
>         /* Assume card is present initially */
>         set_bit(ATMCI_CARD_PRESENT, &slot->flags);
> -       if (gpio_is_valid(slot->detect_pin)) {
> -               if (devm_gpio_request(&host->pdev->dev, slot->detect_pin,
> -                                     "mmc_detect")) {
> -                       dev_dbg(&mmc->class_dev, "no detect pin available\n");
> -                       slot->detect_pin = -EBUSY;
> -               } else if (gpio_get_value(slot->detect_pin) ^
> -                               slot->detect_is_active_high) {
> +       if (slot->detect_pin) {
> +               if (gpiod_get_raw_value(slot->detect_pin) ^
> +                   slot->detect_is_active_high) {
>                         clear_bit(ATMCI_CARD_PRESENT, &slot->flags);
>                 }
> +       } else {
> +               dev_dbg(&mmc->class_dev, "no detect pin available\n");
>         }
>
> -       if (!gpio_is_valid(slot->detect_pin)) {
> +       if (!slot->detect_pin) {
>                 if (slot_data->non_removable)
>                         mmc->caps |= MMC_CAP_NONREMOVABLE;
>                 else
>                         mmc->caps |= MMC_CAP_NEEDS_POLL;
>         }
>
> -       if (gpio_is_valid(slot->wp_pin)) {
> -               if (devm_gpio_request(&host->pdev->dev, slot->wp_pin,
> -                                     "mmc_wp")) {
> -                       dev_dbg(&mmc->class_dev, "no WP pin available\n");
> -                       slot->wp_pin = -EBUSY;
> -               }
> -       }
> +       if (!slot->wp_pin)
> +               dev_dbg(&mmc->class_dev, "no WP pin available\n");
>
>         host->slot[id] = slot;
>         mmc_regulator_get_supply(mmc);
> -       mmc_pwrseq_alloc(slot->mmc);
>         mmc_add_host(mmc);
>
> -       if (gpio_is_valid(slot->detect_pin)) {
> +       if (slot->detect_pin) {
>                 int ret;
>
>                 timer_setup(&slot->detect_timer, atmci_detect_change, 0);
>
> -               ret = request_irq(gpio_to_irq(slot->detect_pin),
> -                               atmci_detect_interrupt,
> -                               IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
> -                               "mmc-detect", slot);
> +               ret = request_irq(gpiod_to_irq(slot->detect_pin),
> +                                 atmci_detect_interrupt,
> +                                 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
> +                                 "mmc-detect", slot);
>                 if (ret) {
>                         dev_dbg(&mmc->class_dev,
>                                 "could not request IRQ %d for detect pin\n",
> -                               gpio_to_irq(slot->detect_pin));
> -                       slot->detect_pin = -EBUSY;
> +                               gpiod_to_irq(slot->detect_pin));
> +                       slot->detect_pin = NULL;
>                 }
>         }
>
> @@ -2342,10 +2342,8 @@ static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
>
>         mmc_remove_host(slot->mmc);
>
> -       if (gpio_is_valid(slot->detect_pin)) {
> -               int pin = slot->detect_pin;
> -
> -               free_irq(gpio_to_irq(pin), slot);
> +       if (slot->detect_pin) {
> +               free_irq(gpiod_to_irq(slot->detect_pin), slot);
>                 del_timer_sync(&slot->detect_timer);
>         }
>
> diff --git a/include/linux/atmel-mci.h b/include/linux/atmel-mci.h
> index 1491af38cc6e..017e7d8f6126 100644
> --- a/include/linux/atmel-mci.h
> +++ b/include/linux/atmel-mci.h
> @@ -26,8 +26,8 @@
>   */
>  struct mci_slot_pdata {
>         unsigned int            bus_width;
> -       int                     detect_pin;
> -       int                     wp_pin;
> +       struct gpio_desc        *detect_pin;
> +       struct gpio_desc        *wp_pin;
>         bool                    detect_is_active_high;
>         bool                    non_removable;
>  };
> --
> 2.25.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-11-18  9:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17  4:14 [PATCH v2 0/2] mmc: atmel-mci: Convert to gpio descriptors Balamanikandan Gunasundar
2022-11-17  4:14 ` Balamanikandan Gunasundar
2022-11-17  4:14 ` [PATCH v2 1/2] " Balamanikandan Gunasundar
2022-11-17  4:14   ` Balamanikandan Gunasundar
2022-11-18  9:20   ` Ulf Hansson
2022-11-18  9:20     ` Ulf Hansson
2022-11-17  4:14 ` [PATCH v2 2/2] mmc: atmel-mci: move atmel MCI header file Balamanikandan Gunasundar
2022-11-17  4:14   ` Balamanikandan Gunasundar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.