Skip to content

Commit 94075d1

Browse files
author
Linus Walleij
committed
ARM: omap2: Get USB hub reset GPIO from descriptor
This switches the USB hub GPIO reset line handling in the OMAP2 pdata quirks over to using GPIO descriptors to avoid using the global GPIO numberspace. Since the GPIOs are exported and assumedly used by some kind of userspace we cannot simply use hogs in the device tree. Fixes: 92bf78b ("gpio: omap: use dynamic allocation of base") Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent d5f4fa6 commit 94075d1

1 file changed

Lines changed: 37 additions & 13 deletions

File tree

arch/arm/mach-omap2/pdata-quirks.c

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,31 +98,43 @@ static struct iommu_platform_data omap3_iommu_isp_pdata = {
9898
};
9999
#endif
100100

101-
static void __init omap3_sbc_t3x_usb_hub_init(int gpio, char *hub_name)
101+
static void __init omap3_sbc_t3x_usb_hub_init(char *hub_name, int idx)
102102
{
103-
int err = gpio_request_one(gpio, GPIOF_OUT_INIT_LOW, hub_name);
103+
struct gpio_desc *d;
104104

105-
if (err) {
106-
pr_err("SBC-T3x: %s reset gpio request failed: %d\n",
107-
hub_name, err);
105+
/* This asserts the RESET line (reverse polarity) */
106+
d = gpiod_get_index(NULL, "reset", idx, GPIOD_OUT_HIGH);
107+
if (IS_ERR(d)) {
108+
pr_err("Unable to get T3x USB reset GPIO descriptor\n");
108109
return;
109110
}
110-
111-
gpiod_export(gpio_to_desc(gpio), 0);
112-
111+
gpiod_set_consumer_name(d, hub_name);
112+
gpiod_export(d, 0);
113113
udelay(10);
114-
gpio_set_value(gpio, 1);
114+
/* De-assert RESET */
115+
gpiod_set_value(d, 0);
115116
msleep(1);
116117
}
117118

119+
static struct gpiod_lookup_table omap3_sbc_t3x_usb_gpio_table = {
120+
.dev_id = NULL,
121+
.table = {
122+
GPIO_LOOKUP_IDX("gpio-160-175", 7, "reset", 0,
123+
GPIO_ACTIVE_LOW),
124+
{ }
125+
},
126+
};
127+
118128
static void __init omap3_sbc_t3730_legacy_init(void)
119129
{
120-
omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub");
130+
gpiod_add_lookup_table(&omap3_sbc_t3x_usb_gpio_table);
131+
omap3_sbc_t3x_usb_hub_init("sb-t35 usb hub", 0);
121132
}
122133

123134
static void __init omap3_sbc_t3530_legacy_init(void)
124135
{
125-
omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub");
136+
gpiod_add_lookup_table(&omap3_sbc_t3x_usb_gpio_table);
137+
omap3_sbc_t3x_usb_hub_init("sb-t35 usb hub", 0);
126138
}
127139

128140
static void __init omap3_evm_legacy_init(void)
@@ -187,10 +199,22 @@ static void __init omap3_sbc_t3517_wifi_init(void)
187199
gpio_set_value(cm_t3517_wlan_gpios[1].gpio, 0);
188200
}
189201

202+
static struct gpiod_lookup_table omap3_sbc_t3517_usb_gpio_table = {
203+
.dev_id = NULL,
204+
.table = {
205+
GPIO_LOOKUP_IDX("gpio-144-159", 8, "reset", 0,
206+
GPIO_ACTIVE_LOW),
207+
GPIO_LOOKUP_IDX("gpio-96-111", 2, "reset", 1,
208+
GPIO_ACTIVE_LOW),
209+
{ }
210+
},
211+
};
212+
190213
static void __init omap3_sbc_t3517_legacy_init(void)
191214
{
192-
omap3_sbc_t3x_usb_hub_init(152, "cm-t3517 usb hub");
193-
omap3_sbc_t3x_usb_hub_init(98, "sb-t35 usb hub");
215+
gpiod_add_lookup_table(&omap3_sbc_t3517_usb_gpio_table);
216+
omap3_sbc_t3x_usb_hub_init("cm-t3517 usb hub", 0);
217+
omap3_sbc_t3x_usb_hub_init("sb-t35 usb hub", 1);
194218
am35xx_emac_reset();
195219
hsmmc2_internal_input_clk();
196220
omap3_sbc_t3517_wifi_init();

0 commit comments

Comments
 (0)