Skip to content

Commit

Permalink
usb: isp1301-omap: Convert to use GPIO descriptors
Browse files Browse the repository at this point in the history
This modernized the ISP1301 a bit by switching it to provide
a GPIO descriptor from the H2 board if used.

Cc: Tony Lindgren <tony@atomide.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20201123102346.48284-1-linus.walleij@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Linus Walleij authored and Greg Kroah-Hartman committed Nov 26, 2020
1 parent 93c747e commit f3ef381
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
22 changes: 20 additions & 2 deletions arch/arm/mach-omap1/board-h2.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* Copyright (C) 2004 Nokia Corporation by Imre Deak <imre.deak@nokia.com>
*/
#include <linux/gpio.h>
#include <linux/gpio/machine.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
Expand Down Expand Up @@ -46,6 +47,9 @@
#include "common.h"
#include "board-h2.h"

/* The first 16 SoC GPIO lines are on this GPIO chip */
#define OMAP_GPIO_LABEL "gpio-0-15"

/* At OMAP1610 Innovator the Ethernet is directly connected to CS1 */
#define OMAP1610_ETHR_START 0x04000300

Expand Down Expand Up @@ -334,7 +338,19 @@ static struct i2c_board_info __initdata h2_i2c_board_info[] = {
I2C_BOARD_INFO("tps65010", 0x48),
.platform_data = &tps_board,
}, {
I2C_BOARD_INFO("isp1301_omap", 0x2d),
.type = "isp1301_omap",
.addr = 0x2d,
.dev_name = "isp1301",
},
};

static struct gpiod_lookup_table isp1301_gpiod_table = {
.dev_id = "isp1301",
.table = {
/* Active low since the irq triggers on falling edge */
GPIO_LOOKUP(OMAP_GPIO_LABEL, 2,
NULL, GPIO_ACTIVE_LOW),
{ },
},
};

Expand Down Expand Up @@ -406,8 +422,10 @@ static void __init h2_init(void)
h2_smc91x_resources[1].end = gpio_to_irq(0);
platform_add_devices(h2_devices, ARRAY_SIZE(h2_devices));
omap_serial_init();

/* ISP1301 IRQ wired at M14 */
omap_cfg_reg(M14_1510_GPIO2);
h2_i2c_board_info[0].irq = gpio_to_irq(58);
h2_i2c_board_info[1].irq = gpio_to_irq(2);
omap_register_i2c_bus(1, 100, h2_i2c_board_info,
ARRAY_SIZE(h2_i2c_board_info));
omap1_usb_init(&h2_usb_config);
Expand Down
21 changes: 13 additions & 8 deletions drivers/usb/phy/phy-isp1301-omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1208,9 +1208,6 @@ static int isp1301_remove(struct i2c_client *i2c)
#ifdef CONFIG_USB_OTG
otg_unbind(isp);
#endif
if (machine_is_omap_h2())
gpio_free(2);

set_bit(WORK_STOP, &isp->todo);
del_timer_sync(&isp->timer);
flush_work(&isp->work);
Expand Down Expand Up @@ -1480,6 +1477,7 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
{
int status;
struct isp1301 *isp;
int irq;

if (the_transceiver)
return 0;
Expand Down Expand Up @@ -1543,20 +1541,27 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
#endif

if (machine_is_omap_h2()) {
struct gpio_desc *gpiod;

/* full speed signaling by default */
isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1,
MC1_SPEED);
isp1301_set_bits(isp, ISP1301_MODE_CONTROL_2,
MC2_SPD_SUSP_CTRL);

/* IRQ wired at M14 */
omap_cfg_reg(M14_1510_GPIO2);
if (gpio_request(2, "isp1301") == 0)
gpio_direction_input(2);
gpiod = devm_gpiod_get(&i2c->dev, NULL, GPIOD_IN);
if (IS_ERR(gpiod)) {
dev_err(&i2c->dev, "cannot obtain H2 GPIO\n");
goto fail;
}
gpiod_set_consumer_name(gpiod, "isp1301");
irq = gpiod_to_irq(gpiod);
isp->irq_type = IRQF_TRIGGER_FALLING;
} else {
irq = i2c->irq;
}

status = request_irq(i2c->irq, isp1301_irq,
status = request_irq(irq, isp1301_irq,
isp->irq_type, DRIVER_NAME, isp);
if (status < 0) {
dev_dbg(&i2c->dev, "can't get IRQ %d, err %d\n",
Expand Down

0 comments on commit f3ef381

Please sign in to comment.