+++ /dev/null
-From 865b34a8c2195bc139e3b6ae54703242fd93f96f Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 8 May 2023 23:20:07 +0200
-Subject: ARM/mmc: Convert old mmci-omap to GPIO descriptors
-
-From: Linus Walleij <linus.walleij@linaro.org>
-
-[ Upstream commit e519f0bb64efc2c9c8b67bb2d114dda458bdc34d ]
-
-A recent change to the OMAP driver making it use a dynamic GPIO
-base created problems with some old OMAP1 board files, among
-them Nokia 770, SX1 and also the OMAP2 Nokia n8x0.
-
-Fix up all instances of GPIOs being used for the MMC driver
-by pushing the handling of power, slot selection and MMC
-"cover" into the driver as optional GPIOs.
-
-This is maybe not the most perfect solution as the MMC
-framework have some central handlers for some of the
-stuff, but it at least makes the situtation better and
-solves the immediate issue.
-
-Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base")
-Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
-Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/arm/mach-omap1/board-nokia770.c | 43 ++++---------
- arch/arm/mach-omap1/board-sx1-mmc.c | 1 -
- arch/arm/mach-omap2/board-n8x0.c | 85 ++++++++------------------
- drivers/mmc/host/omap.c | 46 +++++++++++++-
- include/linux/platform_data/mmc-omap.h | 2 -
- 5 files changed, 83 insertions(+), 94 deletions(-)
-
-diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
-index a501a473ffd68..bde472d0c82f6 100644
---- a/arch/arm/mach-omap1/board-nokia770.c
-+++ b/arch/arm/mach-omap1/board-nokia770.c
-@@ -156,27 +156,23 @@ static struct omap_usb_config nokia770_usb_config __initdata = {
-
- #if IS_ENABLED(CONFIG_MMC_OMAP)
-
--#define NOKIA770_GPIO_MMC_POWER 41
--#define NOKIA770_GPIO_MMC_SWITCH 23
--
--static int nokia770_mmc_set_power(struct device *dev, int slot, int power_on,
-- int vdd)
--{
-- gpio_set_value(NOKIA770_GPIO_MMC_POWER, power_on);
-- return 0;
--}
--
--static int nokia770_mmc_get_cover_state(struct device *dev, int slot)
--{
-- return gpio_get_value(NOKIA770_GPIO_MMC_SWITCH);
--}
-+static struct gpiod_lookup_table nokia770_mmc_gpio_table = {
-+ .dev_id = "mmci-omap.1",
-+ .table = {
-+ /* Slot index 0, VSD power, GPIO 41 */
-+ GPIO_LOOKUP_IDX("gpio-32-47", 9,
-+ "vsd", 0, GPIO_ACTIVE_HIGH),
-+ /* Slot index 0, switch, GPIO 23 */
-+ GPIO_LOOKUP_IDX("gpio-16-31", 7,
-+ "cover", 0, GPIO_ACTIVE_HIGH),
-+ { }
-+ },
-+};
-
- static struct omap_mmc_platform_data nokia770_mmc2_data = {
- .nr_slots = 1,
- .max_freq = 12000000,
- .slots[0] = {
-- .set_power = nokia770_mmc_set_power,
-- .get_cover_state = nokia770_mmc_get_cover_state,
- .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
- .name = "mmcblk",
- },
-@@ -186,20 +182,7 @@ static struct omap_mmc_platform_data *nokia770_mmc_data[OMAP16XX_NR_MMC];
-
- static void __init nokia770_mmc_init(void)
- {
-- int ret;
--
-- ret = gpio_request(NOKIA770_GPIO_MMC_POWER, "MMC power");
-- if (ret < 0)
-- return;
-- gpio_direction_output(NOKIA770_GPIO_MMC_POWER, 0);
--
-- ret = gpio_request(NOKIA770_GPIO_MMC_SWITCH, "MMC cover");
-- if (ret < 0) {
-- gpio_free(NOKIA770_GPIO_MMC_POWER);
-- return;
-- }
-- gpio_direction_input(NOKIA770_GPIO_MMC_SWITCH);
--
-+ gpiod_add_lookup_table(&nokia770_mmc_gpio_table);
- /* Only the second MMC controller is used */
- nokia770_mmc_data[1] = &nokia770_mmc2_data;
- omap1_init_mmc(nokia770_mmc_data, OMAP16XX_NR_MMC);
-diff --git a/arch/arm/mach-omap1/board-sx1-mmc.c b/arch/arm/mach-omap1/board-sx1-mmc.c
-index f1c160924dfe4..f183a8448a7b0 100644
---- a/arch/arm/mach-omap1/board-sx1-mmc.c
-+++ b/arch/arm/mach-omap1/board-sx1-mmc.c
-@@ -9,7 +9,6 @@
- * Copyright (C) 2007 Instituto Nokia de Tecnologia - INdT
- */
-
--#include <linux/gpio.h>
- #include <linux/platform_device.h>
-
- #include "hardware.h"
-diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
-index 3353b0a923d96..50b88eb23f9f8 100644
---- a/arch/arm/mach-omap2/board-n8x0.c
-+++ b/arch/arm/mach-omap2/board-n8x0.c
-@@ -11,6 +11,7 @@
- #include <linux/clk.h>
- #include <linux/delay.h>
- #include <linux/gpio.h>
-+#include <linux/gpio/machine.h>
- #include <linux/init.h>
- #include <linux/io.h>
- #include <linux/irq.h>
-@@ -170,22 +171,32 @@ static struct spi_board_info n800_spi_board_info[] __initdata = {
- * GPIO23 and GPIO9 slot 2 EMMC on N810
- *
- */
--#define N8X0_SLOT_SWITCH_GPIO 96
--#define N810_EMMC_VSD_GPIO 23
--#define N810_EMMC_VIO_GPIO 9
--
- static int slot1_cover_open;
- static int slot2_cover_open;
- static struct device *mmc_device;
-
--static int n8x0_mmc_switch_slot(struct device *dev, int slot)
--{
--#ifdef CONFIG_MMC_DEBUG
-- dev_dbg(dev, "Choose slot %d\n", slot + 1);
--#endif
-- gpio_set_value(N8X0_SLOT_SWITCH_GPIO, slot);
-- return 0;
--}
-+static struct gpiod_lookup_table nokia8xx_mmc_gpio_table = {
-+ .dev_id = "mmci-omap.0",
-+ .table = {
-+ /* Slot switch, GPIO 96 */
-+ GPIO_LOOKUP("gpio-80-111", 16,
-+ "switch", GPIO_ACTIVE_HIGH),
-+ { }
-+ },
-+};
-+
-+static struct gpiod_lookup_table nokia810_mmc_gpio_table = {
-+ .dev_id = "mmci-omap.0",
-+ .table = {
-+ /* Slot index 1, VSD power, GPIO 23 */
-+ GPIO_LOOKUP_IDX("gpio-16-31", 7,
-+ "vsd", 1, GPIO_ACTIVE_HIGH),
-+ /* Slot index 1, VIO power, GPIO 9 */
-+ GPIO_LOOKUP_IDX("gpio-0-15", 9,
-+ "vsd", 1, GPIO_ACTIVE_HIGH),
-+ { }
-+ },
-+};
-
- static int n8x0_mmc_set_power_menelaus(struct device *dev, int slot,
- int power_on, int vdd)
-@@ -256,31 +267,13 @@ static int n8x0_mmc_set_power_menelaus(struct device *dev, int slot,
- return 0;
- }
-
--static void n810_set_power_emmc(struct device *dev,
-- int power_on)
--{
-- dev_dbg(dev, "Set EMMC power %s\n", power_on ? "on" : "off");
--
-- if (power_on) {
-- gpio_set_value(N810_EMMC_VSD_GPIO, 1);
-- msleep(1);
-- gpio_set_value(N810_EMMC_VIO_GPIO, 1);
-- msleep(1);
-- } else {
-- gpio_set_value(N810_EMMC_VIO_GPIO, 0);
-- msleep(50);
-- gpio_set_value(N810_EMMC_VSD_GPIO, 0);
-- msleep(50);
-- }
--}
--
- static int n8x0_mmc_set_power(struct device *dev, int slot, int power_on,
- int vdd)
- {
- if (board_is_n800() || slot == 0)
- return n8x0_mmc_set_power_menelaus(dev, slot, power_on, vdd);
-
-- n810_set_power_emmc(dev, power_on);
-+ /* The n810 power will be handled by GPIO code in the driver */
-
- return 0;
- }
-@@ -418,13 +411,6 @@ static void n8x0_mmc_shutdown(struct device *dev)
- static void n8x0_mmc_cleanup(struct device *dev)
- {
- menelaus_unregister_mmc_callback();
--
-- gpio_free(N8X0_SLOT_SWITCH_GPIO);
--
-- if (board_is_n810()) {
-- gpio_free(N810_EMMC_VSD_GPIO);
-- gpio_free(N810_EMMC_VIO_GPIO);
-- }
- }
-
- /*
-@@ -433,7 +419,6 @@ static void n8x0_mmc_cleanup(struct device *dev)
- */
- static struct omap_mmc_platform_data mmc1_data = {
- .nr_slots = 0,
-- .switch_slot = n8x0_mmc_switch_slot,
- .init = n8x0_mmc_late_init,
- .cleanup = n8x0_mmc_cleanup,
- .shutdown = n8x0_mmc_shutdown,
-@@ -463,14 +448,9 @@ static struct omap_mmc_platform_data mmc1_data = {
-
- static struct omap_mmc_platform_data *mmc_data[OMAP24XX_NR_MMC];
-
--static struct gpio n810_emmc_gpios[] __initdata = {
-- { N810_EMMC_VSD_GPIO, GPIOF_OUT_INIT_LOW, "MMC slot 2 Vddf" },
-- { N810_EMMC_VIO_GPIO, GPIOF_OUT_INIT_LOW, "MMC slot 2 Vdd" },
--};
--
- static void __init n8x0_mmc_init(void)
- {
-- int err;
-+ gpiod_add_lookup_table(&nokia8xx_mmc_gpio_table);
-
- if (board_is_n810()) {
- mmc1_data.slots[0].name = "external";
-@@ -483,20 +463,7 @@ static void __init n8x0_mmc_init(void)
- */
- mmc1_data.slots[1].name = "internal";
- mmc1_data.slots[1].ban_openended = 1;
-- }
--
-- err = gpio_request_one(N8X0_SLOT_SWITCH_GPIO, GPIOF_OUT_INIT_LOW,
-- "MMC slot switch");
-- if (err)
-- return;
--
-- if (board_is_n810()) {
-- err = gpio_request_array(n810_emmc_gpios,
-- ARRAY_SIZE(n810_emmc_gpios));
-- if (err) {
-- gpio_free(N8X0_SLOT_SWITCH_GPIO);
-- return;
-- }
-+ gpiod_add_lookup_table(&nokia810_mmc_gpio_table);
- }
-
- mmc1_data.nr_slots = 2;
-diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
-index cc2213ea324f1..566a09faaaced 100644
---- a/drivers/mmc/host/omap.c
-+++ b/drivers/mmc/host/omap.c
-@@ -26,6 +26,7 @@
- #include <linux/clk.h>
- #include <linux/scatterlist.h>
- #include <linux/slab.h>
-+#include <linux/gpio/consumer.h>
- #include <linux/platform_data/mmc-omap.h>
-
-
-@@ -111,6 +112,9 @@ struct mmc_omap_slot {
- struct mmc_request *mrq;
- struct mmc_omap_host *host;
- struct mmc_host *mmc;
-+ struct gpio_desc *vsd;
-+ struct gpio_desc *vio;
-+ struct gpio_desc *cover;
- struct omap_mmc_slot_data *pdata;
- };
-
-@@ -133,6 +137,7 @@ struct mmc_omap_host {
- int irq;
- unsigned char bus_mode;
- unsigned int reg_shift;
-+ struct gpio_desc *slot_switch;
-
- struct work_struct cmd_abort_work;
- unsigned abort:1;
-@@ -216,8 +221,13 @@ static void mmc_omap_select_slot(struct mmc_omap_slot *slot, int claimed)
-
- if (host->current_slot != slot) {
- OMAP_MMC_WRITE(host, CON, slot->saved_con & 0xFC00);
-- if (host->pdata->switch_slot != NULL)
-- host->pdata->switch_slot(mmc_dev(slot->mmc), slot->id);
-+ if (host->slot_switch)
-+ /*
-+ * With two slots and a simple GPIO switch, setting
-+ * the GPIO to 0 selects slot ID 0, setting it to 1
-+ * selects slot ID 1.
-+ */
-+ gpiod_set_value(host->slot_switch, slot->id);
- host->current_slot = slot;
- }
-
-@@ -297,6 +307,9 @@ static void mmc_omap_release_slot(struct mmc_omap_slot *slot, int clk_enabled)
- static inline
- int mmc_omap_cover_is_open(struct mmc_omap_slot *slot)
- {
-+ /* If we have a GPIO then use that */
-+ if (slot->cover)
-+ return gpiod_get_value(slot->cover);
- if (slot->pdata->get_cover_state)
- return slot->pdata->get_cover_state(mmc_dev(slot->mmc),
- slot->id);
-@@ -1106,6 +1119,11 @@ static void mmc_omap_set_power(struct mmc_omap_slot *slot, int power_on,
-
- host = slot->host;
-
-+ if (slot->vsd)
-+ gpiod_set_value(slot->vsd, power_on);
-+ if (slot->vio)
-+ gpiod_set_value(slot->vio, power_on);
-+
- if (slot->pdata->set_power != NULL)
- slot->pdata->set_power(mmc_dev(slot->mmc), slot->id, power_on,
- vdd);
-@@ -1240,6 +1258,23 @@ static int mmc_omap_new_slot(struct mmc_omap_host *host, int id)
- slot->power_mode = MMC_POWER_UNDEFINED;
- slot->pdata = &host->pdata->slots[id];
-
-+ /* Check for some optional GPIO controls */
-+ slot->vsd = gpiod_get_index_optional(host->dev, "vsd",
-+ id, GPIOD_OUT_LOW);
-+ if (IS_ERR(slot->vsd))
-+ return dev_err_probe(host->dev, PTR_ERR(slot->vsd),
-+ "error looking up VSD GPIO\n");
-+ slot->vio = gpiod_get_index_optional(host->dev, "vio",
-+ id, GPIOD_OUT_LOW);
-+ if (IS_ERR(slot->vio))
-+ return dev_err_probe(host->dev, PTR_ERR(slot->vio),
-+ "error looking up VIO GPIO\n");
-+ slot->cover = gpiod_get_index_optional(host->dev, "cover",
-+ id, GPIOD_IN);
-+ if (IS_ERR(slot->cover))
-+ return dev_err_probe(host->dev, PTR_ERR(slot->cover),
-+ "error looking up cover switch GPIO\n");
-+
- host->slots[id] = slot;
-
- mmc->caps = 0;
-@@ -1350,6 +1385,13 @@ static int mmc_omap_probe(struct platform_device *pdev)
- if (IS_ERR(host->virt_base))
- return PTR_ERR(host->virt_base);
-
-+ host->slot_switch = gpiod_get_optional(host->dev, "switch",
-+ GPIOD_OUT_LOW);
-+ if (IS_ERR(host->slot_switch))
-+ return dev_err_probe(host->dev, PTR_ERR(host->slot_switch),
-+ "error looking up slot switch GPIO\n");
-+
-+
- INIT_WORK(&host->slot_release_work, mmc_omap_slot_release_work);
- INIT_WORK(&host->send_stop_work, mmc_omap_send_stop_work);
-
-diff --git a/include/linux/platform_data/mmc-omap.h b/include/linux/platform_data/mmc-omap.h
-index 91051e9907f34..054d0c3c5ec58 100644
---- a/include/linux/platform_data/mmc-omap.h
-+++ b/include/linux/platform_data/mmc-omap.h
-@@ -20,8 +20,6 @@ struct omap_mmc_platform_data {
- * maximum frequency on the MMC bus */
- unsigned int max_freq;
-
-- /* switch the bus to a new slot */
-- int (*switch_slot)(struct device *dev, int slot);
- /* initialize board-specific MMC functionality, can be NULL if
- * not supported */
- int (*init)(struct device *dev);
---
-2.39.2
-
+++ /dev/null
-From 2f139c285f7332a13debbe4cd24ebab9c482ccde Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Sun, 30 Apr 2023 21:38:24 +0200
-Subject: ARM/musb: omap2: Remove global GPIO numbers from TUSB6010
-
-From: Linus Walleij <linus.walleij@linaro.org>
-
-[ Upstream commit 8e0285ab95a9baf374f2c13eb152221c8ecb3f28 ]
-
-The TUSB6010 (MUSB) device is picking up some GPIO lines
-hardcoded by number and passing on to the TUSB6010 device
-when registering it.
-
-Instead of nasty workarounds, provide a GPIO descriptor
-table and then make the TUSB6010 MUSB glue driver pick up
-the GPIO lines directly, convert it to an IRQ and pass down
-to the MUSB driver. OMAP2 is the only system using the
-TUSB6010.
-
-Stash the GPIO descriptors in the glue layer and use
-then to power up and down the TUSB6010 on-demand, instead
-of using boardfile callbacks.
-
-Since the OMAP2 boards are the only boards using the
-.set_power() and .board_set_power() callbacks, we can
-just delete them as the power is now handled directly
-in the TUSB6010 glue code.
-
-Cc: Bin Liu <b-liu@ti.com>
-Cc: linux-usb@vger.kernel.org
-Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base")
-Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/arm/mach-omap2/board-n8x0.c | 71 ++++++++----------------------
- arch/arm/mach-omap2/usb-tusb6010.c | 20 ++-------
- arch/arm/mach-omap2/usb-tusb6010.h | 12 +++++
- drivers/usb/musb/musb_core.c | 1 -
- drivers/usb/musb/musb_core.h | 2 -
- drivers/usb/musb/tusb6010.c | 53 ++++++++++++++++------
- include/linux/usb/musb.h | 13 ------
- 7 files changed, 73 insertions(+), 99 deletions(-)
- create mode 100644 arch/arm/mach-omap2/usb-tusb6010.h
-
-diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
-index 50b88eb23f9f8..564bf80a26212 100644
---- a/arch/arm/mach-omap2/board-n8x0.c
-+++ b/arch/arm/mach-omap2/board-n8x0.c
-@@ -10,8 +10,8 @@
-
- #include <linux/clk.h>
- #include <linux/delay.h>
--#include <linux/gpio.h>
- #include <linux/gpio/machine.h>
-+#include <linux/gpio/consumer.h>
- #include <linux/init.h>
- #include <linux/io.h>
- #include <linux/irq.h>
-@@ -29,13 +29,12 @@
-
- #include "common.h"
- #include "mmc.h"
-+#include "usb-tusb6010.h"
- #include "soc.h"
- #include "common-board-devices.h"
-
- #define TUSB6010_ASYNC_CS 1
- #define TUSB6010_SYNC_CS 4
--#define TUSB6010_GPIO_INT 58
--#define TUSB6010_GPIO_ENABLE 0
- #define TUSB6010_DMACHAN 0x3f
-
- #define NOKIA_N810_WIMAX (1 << 2)
-@@ -62,37 +61,6 @@ static void board_check_revision(void)
- }
-
- #if IS_ENABLED(CONFIG_USB_MUSB_TUSB6010)
--/*
-- * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and
-- * 1.5 V voltage regulators of PM companion chip. Companion chip will then
-- * provide then PGOOD signal to TUSB6010 which will release it from reset.
-- */
--static int tusb_set_power(int state)
--{
-- int i, retval = 0;
--
-- if (state) {
-- gpio_set_value(TUSB6010_GPIO_ENABLE, 1);
-- msleep(1);
--
-- /* Wait until TUSB6010 pulls INT pin down */
-- i = 100;
-- while (i && gpio_get_value(TUSB6010_GPIO_INT)) {
-- msleep(1);
-- i--;
-- }
--
-- if (!i) {
-- printk(KERN_ERR "tusb: powerup failed\n");
-- retval = -ENODEV;
-- }
-- } else {
-- gpio_set_value(TUSB6010_GPIO_ENABLE, 0);
-- msleep(10);
-- }
--
-- return retval;
--}
-
- static struct musb_hdrc_config musb_config = {
- .multipoint = 1,
-@@ -103,39 +71,36 @@ static struct musb_hdrc_config musb_config = {
-
- static struct musb_hdrc_platform_data tusb_data = {
- .mode = MUSB_OTG,
-- .set_power = tusb_set_power,
- .min_power = 25, /* x2 = 50 mA drawn from VBUS as peripheral */
- .power = 100, /* Max 100 mA VBUS for host mode */
- .config = &musb_config,
- };
-
-+static struct gpiod_lookup_table tusb_gpio_table = {
-+ .dev_id = "musb-tusb",
-+ .table = {
-+ GPIO_LOOKUP("gpio-0-15", 0, "enable",
-+ GPIO_ACTIVE_HIGH),
-+ GPIO_LOOKUP("gpio-48-63", 10, "int",
-+ GPIO_ACTIVE_HIGH),
-+ { }
-+ },
-+};
-+
- static void __init n8x0_usb_init(void)
- {
- int ret = 0;
-- static const char announce[] __initconst = KERN_INFO "TUSB 6010\n";
--
-- /* PM companion chip power control pin */
-- ret = gpio_request_one(TUSB6010_GPIO_ENABLE, GPIOF_OUT_INIT_LOW,
-- "TUSB6010 enable");
-- if (ret != 0) {
-- printk(KERN_ERR "Could not get TUSB power GPIO%i\n",
-- TUSB6010_GPIO_ENABLE);
-- return;
-- }
-- tusb_set_power(0);
-
-+ gpiod_add_lookup_table(&tusb_gpio_table);
- ret = tusb6010_setup_interface(&tusb_data, TUSB6010_REFCLK_19, 2,
-- TUSB6010_ASYNC_CS, TUSB6010_SYNC_CS,
-- TUSB6010_GPIO_INT, TUSB6010_DMACHAN);
-+ TUSB6010_ASYNC_CS, TUSB6010_SYNC_CS,
-+ TUSB6010_DMACHAN);
- if (ret != 0)
-- goto err;
-+ return;
-
-- printk(announce);
-+ pr_info("TUSB 6010\n");
-
- return;
--
--err:
-- gpio_free(TUSB6010_GPIO_ENABLE);
- }
- #else
-
-diff --git a/arch/arm/mach-omap2/usb-tusb6010.c b/arch/arm/mach-omap2/usb-tusb6010.c
-index 18fa52f828dc7..b46c254c2bc41 100644
---- a/arch/arm/mach-omap2/usb-tusb6010.c
-+++ b/arch/arm/mach-omap2/usb-tusb6010.c
-@@ -11,12 +11,12 @@
- #include <linux/errno.h>
- #include <linux/delay.h>
- #include <linux/platform_device.h>
--#include <linux/gpio.h>
- #include <linux/export.h>
- #include <linux/platform_data/usb-omap.h>
-
- #include <linux/usb/musb.h>
-
-+#include "usb-tusb6010.h"
- #include "gpmc.h"
-
- static u8 async_cs, sync_cs;
-@@ -132,10 +132,6 @@ static struct resource tusb_resources[] = {
- { /* Synchronous access */
- .flags = IORESOURCE_MEM,
- },
-- { /* IRQ */
-- .name = "mc",
-- .flags = IORESOURCE_IRQ,
-- },
- };
-
- static u64 tusb_dmamask = ~(u32)0;
-@@ -154,9 +150,9 @@ static struct platform_device tusb_device = {
-
- /* this may be called only from board-*.c setup code */
- int __init tusb6010_setup_interface(struct musb_hdrc_platform_data *data,
-- unsigned ps_refclk, unsigned waitpin,
-- unsigned async, unsigned sync,
-- unsigned irq, unsigned dmachan)
-+ unsigned int ps_refclk, unsigned int waitpin,
-+ unsigned int async, unsigned int sync,
-+ unsigned int dmachan)
- {
- int status;
- static char error[] __initdata =
-@@ -192,14 +188,6 @@ int __init tusb6010_setup_interface(struct musb_hdrc_platform_data *data,
- if (status < 0)
- return status;
-
-- /* IRQ */
-- status = gpio_request_one(irq, GPIOF_IN, "TUSB6010 irq");
-- if (status < 0) {
-- printk(error, 3, status);
-- return status;
-- }
-- tusb_resources[2].start = gpio_to_irq(irq);
--
- /* set up memory timings ... can speed them up later */
- if (!ps_refclk) {
- printk(error, 4, status);
-diff --git a/arch/arm/mach-omap2/usb-tusb6010.h b/arch/arm/mach-omap2/usb-tusb6010.h
-new file mode 100644
-index 0000000000000..d210ff6238c26
---- /dev/null
-+++ b/arch/arm/mach-omap2/usb-tusb6010.h
-@@ -0,0 +1,12 @@
-+/* SPDX-License-Identifier: GPL-2.0 */
-+
-+#ifndef __USB_TUSB6010_H
-+#define __USB_TUSB6010_H
-+
-+extern int __init tusb6010_setup_interface(
-+ struct musb_hdrc_platform_data *data,
-+ unsigned int ps_refclk, unsigned int waitpin,
-+ unsigned int async_cs, unsigned int sync_cs,
-+ unsigned int dmachan);
-+
-+#endif /* __USB_TUSB6010_H */
-diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
-index 648bb6021c5ef..dc773f4f6df2d 100644
---- a/drivers/usb/musb/musb_core.c
-+++ b/drivers/usb/musb/musb_core.c
-@@ -2330,7 +2330,6 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
-
- spin_lock_init(&musb->lock);
- spin_lock_init(&musb->list_lock);
-- musb->board_set_power = plat->set_power;
- musb->min_power = plat->min_power;
- musb->ops = plat->platform_ops;
- musb->port_mode = plat->mode;
-diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
-index b7588d11cfc59..91b5b6b66f963 100644
---- a/drivers/usb/musb/musb_core.h
-+++ b/drivers/usb/musb/musb_core.h
-@@ -352,8 +352,6 @@ struct musb {
- u16 epmask;
- u8 nr_endpoints;
-
-- int (*board_set_power)(int state);
--
- u8 min_power; /* vbus for periph, in mA/2 */
-
- enum musb_mode port_mode;
-diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
-index 5609b4e84d40a..b5ba713d08592 100644
---- a/drivers/usb/musb/tusb6010.c
-+++ b/drivers/usb/musb/tusb6010.c
-@@ -11,6 +11,8 @@
- * interface.
- */
-
-+#include <linux/gpio/consumer.h>
-+#include <linux/delay.h>
- #include <linux/module.h>
- #include <linux/kernel.h>
- #include <linux/errno.h>
-@@ -30,6 +32,8 @@ struct tusb6010_glue {
- struct device *dev;
- struct platform_device *musb;
- struct platform_device *phy;
-+ struct gpio_desc *enable;
-+ struct gpio_desc *intpin;
- };
-
- static void tusb_musb_set_vbus(struct musb *musb, int is_on);
-@@ -1021,16 +1025,29 @@ static void tusb_setup_cpu_interface(struct musb *musb)
-
- static int tusb_musb_start(struct musb *musb)
- {
-+ struct tusb6010_glue *glue = dev_get_drvdata(musb->controller->parent);
- void __iomem *tbase = musb->ctrl_base;
-- int ret = 0;
- unsigned long flags;
- u32 reg;
-+ int i;
-
-- if (musb->board_set_power)
-- ret = musb->board_set_power(1);
-- if (ret != 0) {
-- printk(KERN_ERR "tusb: Cannot enable TUSB6010\n");
-- return ret;
-+ /*
-+ * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and
-+ * 1.5 V voltage regulators of PM companion chip. Companion chip will then
-+ * provide then PGOOD signal to TUSB6010 which will release it from reset.
-+ */
-+ gpiod_set_value(glue->enable, 1);
-+ msleep(1);
-+
-+ /* Wait for 100ms until TUSB6010 pulls INT pin down */
-+ i = 100;
-+ while (i && gpiod_get_value(glue->intpin)) {
-+ msleep(1);
-+ i--;
-+ }
-+ if (!i) {
-+ pr_err("tusb: Powerup respones failed\n");
-+ return -ENODEV;
- }
-
- spin_lock_irqsave(&musb->lock, flags);
-@@ -1083,8 +1100,8 @@ static int tusb_musb_start(struct musb *musb)
- err:
- spin_unlock_irqrestore(&musb->lock, flags);
-
-- if (musb->board_set_power)
-- musb->board_set_power(0);
-+ gpiod_set_value(glue->enable, 0);
-+ msleep(10);
-
- return -ENODEV;
- }
-@@ -1158,11 +1175,13 @@ static int tusb_musb_init(struct musb *musb)
-
- static int tusb_musb_exit(struct musb *musb)
- {
-+ struct tusb6010_glue *glue = dev_get_drvdata(musb->controller->parent);
-+
- del_timer_sync(&musb->dev_timer);
- the_musb = NULL;
-
-- if (musb->board_set_power)
-- musb->board_set_power(0);
-+ gpiod_set_value(glue->enable, 0);
-+ msleep(10);
-
- iounmap(musb->sync_va);
-
-@@ -1218,6 +1237,15 @@ static int tusb_probe(struct platform_device *pdev)
-
- glue->dev = &pdev->dev;
-
-+ glue->enable = devm_gpiod_get(glue->dev, "enable", GPIOD_OUT_LOW);
-+ if (IS_ERR(glue->enable))
-+ return dev_err_probe(glue->dev, PTR_ERR(glue->enable),
-+ "could not obtain power on/off GPIO\n");
-+ glue->intpin = devm_gpiod_get(glue->dev, "int", GPIOD_IN);
-+ if (IS_ERR(glue->intpin))
-+ return dev_err_probe(glue->dev, PTR_ERR(glue->intpin),
-+ "could not obtain INT GPIO\n");
-+
- pdata->platform_ops = &tusb_ops;
-
- usb_phy_generic_register();
-@@ -1236,10 +1264,7 @@ static int tusb_probe(struct platform_device *pdev)
- musb_resources[1].end = pdev->resource[1].end;
- musb_resources[1].flags = pdev->resource[1].flags;
-
-- musb_resources[2].name = pdev->resource[2].name;
-- musb_resources[2].start = pdev->resource[2].start;
-- musb_resources[2].end = pdev->resource[2].end;
-- musb_resources[2].flags = pdev->resource[2].flags;
-+ musb_resources[2] = DEFINE_RES_IRQ_NAMED(gpiod_to_irq(glue->intpin), "mc");
-
- pinfo = tusb_dev_info;
- pinfo.parent = &pdev->dev;
-diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h
-index e4a3ad3c800f5..3963e55e88a31 100644
---- a/include/linux/usb/musb.h
-+++ b/include/linux/usb/musb.h
-@@ -99,9 +99,6 @@ struct musb_hdrc_platform_data {
- /* (HOST or OTG) program PHY for external Vbus */
- unsigned extvbus:1;
-
-- /* Power the device on or off */
-- int (*set_power)(int state);
--
- /* MUSB configuration-specific details */
- const struct musb_hdrc_config *config;
-
-@@ -135,14 +132,4 @@ static inline int musb_mailbox(enum musb_vbus_id_status status)
- #define TUSB6010_REFCLK_24 41667 /* psec/clk @ 24.0 MHz XI */
- #define TUSB6010_REFCLK_19 52083 /* psec/clk @ 19.2 MHz CLKIN */
-
--#ifdef CONFIG_ARCH_OMAP2
--
--extern int __init tusb6010_setup_interface(
-- struct musb_hdrc_platform_data *data,
-- unsigned ps_refclk, unsigned waitpin,
-- unsigned async_cs, unsigned sync_cs,
-- unsigned irq, unsigned dmachan);
--
--#endif /* OMAP2 */
--
- #endif /* __LINUX_USB_MUSB_H */
---
-2.39.2
-
+++ /dev/null
-From 6aff4f5bca5fda2de67e9730c024fc73d1b6137e Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Sun, 30 Apr 2023 11:40:28 +0200
-Subject: ARM: omap1: Drop header on AMS Delta
-
-From: Linus Walleij <linus.walleij@linaro.org>
-
-[ Upstream commit fa1ae0cd897b089b5cc05ab471518ad13db2d567 ]
-
-The AMS Delta board uses GPIO descriptors exclusively and
-does not have any dependencies on the legacy <linux/gpio.h>
-header, so just drop it.
-
-Acked-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
-Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base")
-Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/arm/mach-omap1/board-ams-delta.c | 1 -
- 1 file changed, 1 deletion(-)
-
-diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
-index 0f67ac4c6fd25..d9d2fef1b74a7 100644
---- a/arch/arm/mach-omap1/board-ams-delta.c
-+++ b/arch/arm/mach-omap1/board-ams-delta.c
-@@ -11,7 +11,6 @@
- #include <linux/gpio/driver.h>
- #include <linux/gpio/machine.h>
- #include <linux/gpio/consumer.h>
--#include <linux/gpio.h>
- #include <linux/kernel.h>
- #include <linux/init.h>
- #include <linux/input.h>
---
-2.39.2
-
+++ /dev/null
-From 182eacda642a37daf3a7472c091159b3f2bee9bf Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Sun, 30 Apr 2023 19:56:37 +0200
-Subject: ARM: omap1: Exorcise the legacy GPIO header
-
-From: Linus Walleij <linus.walleij@linaro.org>
-
-[ Upstream commit c729baa8604226a8f878296bd145ab4046c80b12 ]
-
-After fixing all the offending users referencing the global GPIO
-numberspace in OMAP1, a few sites still remain including the
-legacy <linus/gpio.h> header for no reason.
-
-Delete the last remaining users, and OMAP1 is free from legacy
-GPIO dependencies.
-
-Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base")
-Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/arm/mach-omap1/devices.c | 1 -
- arch/arm/mach-omap1/gpio15xx.c | 1 -
- arch/arm/mach-omap1/gpio16xx.c | 1 -
- arch/arm/mach-omap1/irq.c | 1 -
- 4 files changed, 4 deletions(-)
-
-diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c
-index 5304699c7a97e..8b2c5f911e973 100644
---- a/arch/arm/mach-omap1/devices.c
-+++ b/arch/arm/mach-omap1/devices.c
-@@ -6,7 +6,6 @@
- */
-
- #include <linux/dma-mapping.h>
--#include <linux/gpio.h>
- #include <linux/module.h>
- #include <linux/kernel.h>
- #include <linux/init.h>
-diff --git a/arch/arm/mach-omap1/gpio15xx.c b/arch/arm/mach-omap1/gpio15xx.c
-index 61fa26efd8653..6724af4925f24 100644
---- a/arch/arm/mach-omap1/gpio15xx.c
-+++ b/arch/arm/mach-omap1/gpio15xx.c
-@@ -8,7 +8,6 @@
- * Charulatha V <charu@ti.com>
- */
-
--#include <linux/gpio.h>
- #include <linux/platform_data/gpio-omap.h>
- #include <linux/soc/ti/omap1-soc.h>
- #include <asm/irq.h>
-diff --git a/arch/arm/mach-omap1/gpio16xx.c b/arch/arm/mach-omap1/gpio16xx.c
-index cf052714b3f8a..55acec22fef4e 100644
---- a/arch/arm/mach-omap1/gpio16xx.c
-+++ b/arch/arm/mach-omap1/gpio16xx.c
-@@ -8,7 +8,6 @@
- * Charulatha V <charu@ti.com>
- */
-
--#include <linux/gpio.h>
- #include <linux/platform_data/gpio-omap.h>
- #include <linux/soc/ti/omap1-io.h>
-
-diff --git a/arch/arm/mach-omap1/irq.c b/arch/arm/mach-omap1/irq.c
-index 9ccc784fd6140..c780fa56bc638 100644
---- a/arch/arm/mach-omap1/irq.c
-+++ b/arch/arm/mach-omap1/irq.c
-@@ -35,7 +35,6 @@
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
--#include <linux/gpio.h>
- #include <linux/init.h>
- #include <linux/module.h>
- #include <linux/sched.h>
---
-2.39.2
-
+++ /dev/null
-From d0816bad3bb018430607ae6284f17ca24da1fd89 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Sun, 30 Apr 2023 11:56:23 +0200
-Subject: ARM: omap1: Remove reliance on GPIO numbers from PalmTE
-
-From: Linus Walleij <linus.walleij@linaro.org>
-
-[ Upstream commit 4c40db6249ff1da335b276bdd6c3c3462efbc2ab ]
-
-It appears this happens because the OMAP driver now
-allocates GPIO numbers dynamically, so all that is
-references by number is a bit up in the air.
-
-Utilize the NULL device to define some board-specific
-GPIO lookups and use these to immediately look up the
-same GPIOs, convert to IRQ numbers and pass as resources
-to the devices. This is ugly but should work.
-
-Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base")
-Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/arm/mach-omap1/board-palmte.c | 51 ++++++++++++++++++------------
- 1 file changed, 31 insertions(+), 20 deletions(-)
-
-diff --git a/arch/arm/mach-omap1/board-palmte.c b/arch/arm/mach-omap1/board-palmte.c
-index f79c497f04d57..49b7757cb2fd3 100644
---- a/arch/arm/mach-omap1/board-palmte.c
-+++ b/arch/arm/mach-omap1/board-palmte.c
-@@ -13,7 +13,8 @@
- *
- * Copyright (c) 2006 Andrzej Zaborowski <balrog@zabor.org>
- */
--#include <linux/gpio.h>
-+#include <linux/gpio/machine.h>
-+#include <linux/gpio/consumer.h>
- #include <linux/kernel.h>
- #include <linux/init.h>
- #include <linux/input.h>
-@@ -187,23 +188,6 @@ static struct spi_board_info palmte_spi_info[] __initdata = {
- },
- };
-
--static void __init palmte_misc_gpio_setup(void)
--{
-- /* Set TSC2102 PINTDAV pin as input (used by TSC2102 driver) */
-- if (gpio_request(PALMTE_PINTDAV_GPIO, "TSC2102 PINTDAV") < 0) {
-- printk(KERN_ERR "Could not reserve PINTDAV GPIO!\n");
-- return;
-- }
-- gpio_direction_input(PALMTE_PINTDAV_GPIO);
--
-- /* Set USB-or-DC-IN pin as input (unused) */
-- if (gpio_request(PALMTE_USB_OR_DC_GPIO, "USB/DC-IN") < 0) {
-- printk(KERN_ERR "Could not reserve cable signal GPIO!\n");
-- return;
-- }
-- gpio_direction_input(PALMTE_USB_OR_DC_GPIO);
--}
--
- #if IS_ENABLED(CONFIG_MMC_OMAP)
-
- static struct omap_mmc_platform_data _palmte_mmc_config = {
-@@ -231,8 +215,23 @@ static void palmte_mmc_init(void)
-
- #endif /* CONFIG_MMC_OMAP */
-
-+static struct gpiod_lookup_table palmte_irq_gpio_table = {
-+ .dev_id = NULL,
-+ .table = {
-+ /* GPIO used for TSC2102 PINTDAV IRQ */
-+ GPIO_LOOKUP("gpio-0-15", PALMTE_PINTDAV_GPIO, "tsc2102_irq",
-+ GPIO_ACTIVE_HIGH),
-+ /* GPIO used for USB or DC input detection */
-+ GPIO_LOOKUP("gpio-0-15", PALMTE_USB_OR_DC_GPIO, "usb_dc_irq",
-+ GPIO_ACTIVE_HIGH),
-+ { }
-+ },
-+};
-+
- static void __init omap_palmte_init(void)
- {
-+ struct gpio_desc *d;
-+
- /* mux pins for uarts */
- omap_cfg_reg(UART1_TX);
- omap_cfg_reg(UART1_RTS);
-@@ -243,9 +242,21 @@ static void __init omap_palmte_init(void)
-
- platform_add_devices(palmte_devices, ARRAY_SIZE(palmte_devices));
-
-- palmte_spi_info[0].irq = gpio_to_irq(PALMTE_PINTDAV_GPIO);
-+ gpiod_add_lookup_table(&palmte_irq_gpio_table);
-+ d = gpiod_get(NULL, "tsc2102_irq", GPIOD_IN);
-+ if (IS_ERR(d))
-+ pr_err("Unable to get TSC2102 IRQ GPIO descriptor\n");
-+ else
-+ palmte_spi_info[0].irq = gpiod_to_irq(d);
- spi_register_board_info(palmte_spi_info, ARRAY_SIZE(palmte_spi_info));
-- palmte_misc_gpio_setup();
-+
-+ /* We are getting this just to set it up as input */
-+ d = gpiod_get(NULL, "usb_dc_irq", GPIOD_IN);
-+ if (IS_ERR(d))
-+ pr_err("Unable to get USB/DC IRQ GPIO descriptor\n");
-+ else
-+ gpiod_put(d);
-+
- omap_serial_init();
- omap1_usb_init(&palmte_usb_config);
- omap_register_i2c_bus(1, 100, NULL, 0);
---
-2.39.2
-
+++ /dev/null
-From f435876b9f66d361fbc1897902cdbf7643d28acc Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Sun, 30 Apr 2023 17:45:29 +0200
-Subject: ARM: omap1: Remove reliance on GPIO numbers from SX1
-
-From: Linus Walleij <linus.walleij@linaro.org>
-
-[ Upstream commit 480c82daa3e41873421dc2c9e2918ad7e21d7a0b ]
-
-It appears this happens because the OMAP driver now
-allocates GPIO numbers dynamically, so all that is
-references by number is a bit up in the air.
-
-Utilize the NULL device to define some board-specific
-GPIO lookups and use these to immediately look up the
-same GPIOs, convert to IRQ numbers and pass as resources
-to the devices. This is ugly but should work.
-
-Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base")
-Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/arm/mach-omap1/board-sx1.c | 40 +++++++++++++++++++++++++++------
- 1 file changed, 33 insertions(+), 7 deletions(-)
-
-diff --git a/arch/arm/mach-omap1/board-sx1.c b/arch/arm/mach-omap1/board-sx1.c
-index 0c0cdd5e77c79..a13c630be7b7f 100644
---- a/arch/arm/mach-omap1/board-sx1.c
-+++ b/arch/arm/mach-omap1/board-sx1.c
-@@ -11,7 +11,8 @@
- * Maintainters : Vladimir Ananiev (aka Vovan888), Sergge
- * oslik.ru
- */
--#include <linux/gpio.h>
-+#include <linux/gpio/machine.h>
-+#include <linux/gpio/consumer.h>
- #include <linux/kernel.h>
- #include <linux/init.h>
- #include <linux/input.h>
-@@ -304,8 +305,23 @@ static struct platform_device *sx1_devices[] __initdata = {
-
- /*-----------------------------------------*/
-
-+static struct gpiod_lookup_table sx1_gpio_table = {
-+ .dev_id = NULL,
-+ .table = {
-+ GPIO_LOOKUP("gpio-0-15", 1, "irda_off",
-+ GPIO_ACTIVE_HIGH),
-+ GPIO_LOOKUP("gpio-0-15", 11, "switch",
-+ GPIO_ACTIVE_HIGH),
-+ GPIO_LOOKUP("gpio-0-15", 15, "usb_on",
-+ GPIO_ACTIVE_HIGH),
-+ { }
-+ },
-+};
-+
- static void __init omap_sx1_init(void)
- {
-+ struct gpio_desc *d;
-+
- /* mux pins for uarts */
- omap_cfg_reg(UART1_TX);
- omap_cfg_reg(UART1_RTS);
-@@ -320,15 +336,25 @@ static void __init omap_sx1_init(void)
- omap_register_i2c_bus(1, 100, NULL, 0);
- omap1_usb_init(&sx1_usb_config);
- sx1_mmc_init();
-+ gpiod_add_lookup_table(&sx1_gpio_table);
-
- /* turn on USB power */
- /* sx1_setusbpower(1); can't do it here because i2c is not ready */
-- gpio_request(1, "A_IRDA_OFF");
-- gpio_request(11, "A_SWITCH");
-- gpio_request(15, "A_USB_ON");
-- gpio_direction_output(1, 1); /*A_IRDA_OFF = 1 */
-- gpio_direction_output(11, 0); /*A_SWITCH = 0 */
-- gpio_direction_output(15, 0); /*A_USB_ON = 0 */
-+ d = gpiod_get(NULL, "irda_off", GPIOD_OUT_HIGH);
-+ if (IS_ERR(d))
-+ pr_err("Unable to get IRDA OFF GPIO descriptor\n");
-+ else
-+ gpiod_put(d);
-+ d = gpiod_get(NULL, "switch", GPIOD_OUT_LOW);
-+ if (IS_ERR(d))
-+ pr_err("Unable to get SWITCH GPIO descriptor\n");
-+ else
-+ gpiod_put(d);
-+ d = gpiod_get(NULL, "usb_on", GPIOD_OUT_LOW);
-+ if (IS_ERR(d))
-+ pr_err("Unable to get USB ON GPIO descriptor\n");
-+ else
-+ gpiod_put(d);
-
- omapfb_set_lcd_config(&sx1_lcd_config);
- }
---
-2.39.2
-
arm-dts-gta04-move-model-property-out-of-pinctrl-nod.patch
drm-bridge-anx7625-prevent-endless-probe-loop.patch
arm-mfd-gpio-fixup-tps65010-regression-on-omap1-osk1.patch
-arm-omap1-drop-header-on-ams-delta.patch
-arm-omap1-remove-reliance-on-gpio-numbers-from-palmt.patch
-arm-omap1-remove-reliance-on-gpio-numbers-from-sx1.patch
-arm-mmc-convert-old-mmci-omap-to-gpio-descriptors.patch
-arm-omap1-exorcise-the-legacy-gpio-header.patch
-arm-musb-omap2-remove-global-gpio-numbers-from-tusb6.patch
arm-dts-qcom-msm8974-do-not-use-underscore-in-node-n.patch
arm64-dts-qcom-pm8998-don-t-use-gic_spi-for-spmi-int.patch
arm64-dts-qcom-ipq6018-correct-qrng-unit-address.patch