Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc593f5d authored by Igor Grinberg's avatar Igor Grinberg Committed by Tony Lindgren
Browse files

arm: omap2plus: GPIO cleanup



use gpio_request_<one|array>() instead of multiple gpiolib calls,
remove unneeded variables, etc.

Signed-off-by: default avatarIgor Grinberg <grinberg@compulab.co.il>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 9e18630b
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -226,8 +226,6 @@ static struct omap_board_mux board_mux[] __initdata = {

static void __init omap_2430sdp_init(void)
{
	int ret;

	omap2430_mux_init(board_mux, OMAP_PACKAGE_ZAC);

	omap_board_config = sdp2430_config;
@@ -246,9 +244,8 @@ static void __init omap_2430sdp_init(void)
	board_smc91x_init();

	/* Turn off secondary LCD backlight */
	ret = gpio_request(SECONDARY_LCD_GPIO, "Secondary LCD backlight");
	if (ret == 0)
		gpio_direction_output(SECONDARY_LCD_GPIO, 0);
	gpio_request_one(SECONDARY_LCD_GPIO, GPIOF_OUT_INIT_LOW,
			 "Secondary LCD backlight");
}

static void __init omap_2430sdp_map_io(void)
+15 −32
Original line number Diff line number Diff line
@@ -126,8 +126,11 @@ static struct twl4030_keypad_data sdp3430_kp_data = {
#define SDP3430_LCD_PANEL_BACKLIGHT_GPIO	8
#define SDP3430_LCD_PANEL_ENABLE_GPIO		5

static unsigned backlight_gpio;
static unsigned enable_gpio;
static struct gpio sdp3430_dss_gpios[] __initdata = {
	{SDP3430_LCD_PANEL_ENABLE_GPIO,    GPIOF_OUT_INIT_LOW, "LCD reset"    },
	{SDP3430_LCD_PANEL_BACKLIGHT_GPIO, GPIOF_OUT_INIT_LOW, "LCD Backlight"},
};

static int lcd_enabled;
static int dvi_enabled;

@@ -135,29 +138,11 @@ static void __init sdp3430_display_init(void)
{
	int r;

	enable_gpio    = SDP3430_LCD_PANEL_ENABLE_GPIO;
	backlight_gpio = SDP3430_LCD_PANEL_BACKLIGHT_GPIO;

	r = gpio_request(enable_gpio, "LCD reset");
	if (r) {
		printk(KERN_ERR "failed to get LCD reset GPIO\n");
		goto err0;
	}

	r = gpio_request(backlight_gpio, "LCD Backlight");
	if (r) {
		printk(KERN_ERR "failed to get LCD backlight GPIO\n");
		goto err1;
	}

	gpio_direction_output(enable_gpio, 0);
	gpio_direction_output(backlight_gpio, 0);
	r = gpio_request_array(sdp3430_dss_gpios,
			       ARRAY_SIZE(sdp3430_dss_gpios));
	if (r)
		printk(KERN_ERR "failed to get LCD control GPIOs\n");

	return;
err1:
	gpio_free(enable_gpio);
err0:
	return;
}

static int sdp3430_panel_enable_lcd(struct omap_dss_device *dssdev)
@@ -167,8 +152,8 @@ static int sdp3430_panel_enable_lcd(struct omap_dss_device *dssdev)
		return -EINVAL;
	}

	gpio_direction_output(enable_gpio, 1);
	gpio_direction_output(backlight_gpio, 1);
	gpio_direction_output(SDP3430_LCD_PANEL_ENABLE_GPIO, 1);
	gpio_direction_output(SDP3430_LCD_PANEL_BACKLIGHT_GPIO, 1);

	lcd_enabled = 1;

@@ -179,8 +164,8 @@ static void sdp3430_panel_disable_lcd(struct omap_dss_device *dssdev)
{
	lcd_enabled = 0;

	gpio_direction_output(enable_gpio, 0);
	gpio_direction_output(backlight_gpio, 0);
	gpio_direction_output(SDP3430_LCD_PANEL_ENABLE_GPIO, 0);
	gpio_direction_output(SDP3430_LCD_PANEL_BACKLIGHT_GPIO, 0);
}

static int sdp3430_panel_enable_dvi(struct omap_dss_device *dssdev)
@@ -308,12 +293,10 @@ static int sdp3430_twl_gpio_setup(struct device *dev,
	omap2_hsmmc_init(mmc);

	/* gpio + 7 is "sub_lcd_en_bkl" (output/PWM1) */
	gpio_request(gpio + 7, "sub_lcd_en_bkl");
	gpio_direction_output(gpio + 7, 0);
	gpio_request_one(gpio + 7, GPIOF_OUT_INIT_LOW, "sub_lcd_en_bkl");

	/* gpio + 15 is "sub_lcd_nRST" (output) */
	gpio_request(gpio + 15, "sub_lcd_nRST");
	gpio_direction_output(gpio + 15, 0);
	gpio_request_one(gpio + 15, GPIOF_OUT_INIT_LOW, "sub_lcd_nRST");

	return 0;
}
+23 −75
Original line number Diff line number Diff line
@@ -252,58 +252,22 @@ static struct spi_board_info sdp4430_spi_board_info[] __initdata = {
	},
};

static struct gpio sdp4430_eth_gpios[] __initdata = {
	{ ETH_KS8851_POWER_ON,	GPIOF_OUT_INIT_HIGH,	"eth_power"	},
	{ ETH_KS8851_QUART,	GPIOF_OUT_INIT_HIGH,	"quart"		},
	{ ETH_KS8851_IRQ,	GPIOF_IN,		"eth_irq"	},
};

static int omap_ethernet_init(void)
{
	int status;

	/* Request of GPIO lines */
	status = gpio_request_array(sdp4430_eth_gpios,
				    ARRAY_SIZE(sdp4430_eth_gpios));
	if (status)
		pr_err("Cannot request ETH GPIOs\n");

	status = gpio_request(ETH_KS8851_POWER_ON, "eth_power");
	if (status) {
		pr_err("Cannot request GPIO %d\n", ETH_KS8851_POWER_ON);
		return status;
	}

	status = gpio_request(ETH_KS8851_QUART, "quart");
	if (status) {
		pr_err("Cannot request GPIO %d\n", ETH_KS8851_QUART);
		goto error1;
	}

	status = gpio_request(ETH_KS8851_IRQ, "eth_irq");
	if (status) {
		pr_err("Cannot request GPIO %d\n", ETH_KS8851_IRQ);
		goto error2;
	}

	/* Configuration of requested GPIO lines */

	status = gpio_direction_output(ETH_KS8851_POWER_ON, 1);
	if (status) {
		pr_err("Cannot set output GPIO %d\n", ETH_KS8851_IRQ);
		goto error3;
	}

	status = gpio_direction_output(ETH_KS8851_QUART, 1);
	if (status) {
		pr_err("Cannot set output GPIO %d\n", ETH_KS8851_QUART);
		goto error3;
	}

	status = gpio_direction_input(ETH_KS8851_IRQ);
	if (status) {
		pr_err("Cannot set input GPIO %d\n", ETH_KS8851_IRQ);
		goto error3;
	}

	return 0;

error3:
	gpio_free(ETH_KS8851_IRQ);
error2:
	gpio_free(ETH_KS8851_QUART);
error1:
	gpio_free(ETH_KS8851_POWER_ON);
	return status;
}

@@ -604,19 +568,11 @@ static void __init omap_sfh7741prox_init(void)
{
	int error;

	error = gpio_request(OMAP4_SFH7741_ENABLE_GPIO, "sfh7741");
	if (error < 0) {
	error = gpio_request_one(OMAP4_SFH7741_ENABLE_GPIO,
				 GPIOF_OUT_INIT_LOW, "sfh7741");
	if (error < 0)
		pr_err("%s:failed to request GPIO %d, error %d\n",
			__func__, OMAP4_SFH7741_ENABLE_GPIO, error);
		return;
	}

	error = gpio_direction_output(OMAP4_SFH7741_ENABLE_GPIO , 0);
	if (error < 0) {
		pr_err("%s: GPIO configuration failed: GPIO %d,error %d\n",
			 __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
		gpio_free(OMAP4_SFH7741_ENABLE_GPIO);
	}
}

static void sdp4430_hdmi_mux_init(void)
@@ -633,27 +589,19 @@ static void sdp4430_hdmi_mux_init(void)
			OMAP_PIN_INPUT_PULLUP);
}

static struct gpio sdp4430_hdmi_gpios[] = {
	{ HDMI_GPIO_HPD,	GPIOF_OUT_INIT_HIGH,	"hdmi_gpio_hpd"   },
	{ HDMI_GPIO_LS_OE,	GPIOF_OUT_INIT_HIGH,	"hdmi_gpio_ls_oe" },
};

static int sdp4430_panel_enable_hdmi(struct omap_dss_device *dssdev)
{
	int status;

	status = gpio_request_one(HDMI_GPIO_HPD, GPIOF_OUT_INIT_HIGH,
							"hdmi_gpio_hpd");
	if (status) {
		pr_err("Cannot request GPIO %d\n", HDMI_GPIO_HPD);
		return status;
	}
	status = gpio_request_one(HDMI_GPIO_LS_OE, GPIOF_OUT_INIT_HIGH,
							"hdmi_gpio_ls_oe");
	if (status) {
		pr_err("Cannot request GPIO %d\n", HDMI_GPIO_LS_OE);
		goto error1;
	}

	return 0;

error1:
	gpio_free(HDMI_GPIO_HPD);
	status = gpio_request_array(sdp4430_hdmi_gpios,
				    ARRAY_SIZE(sdp4430_hdmi_gpios));
	if (status)
		pr_err("%s: Cannot request HDMI GPIOs\n", __func__);

	return status;
}
+2 −8
Original line number Diff line number Diff line
@@ -89,19 +89,13 @@ static void __init am3517_crane_init(void)
		return;
	}

	ret = gpio_request(GPIO_USB_POWER, "usb_ehci_enable");
	ret = gpio_request_one(GPIO_USB_POWER, GPIOF_OUT_INIT_HIGH,
			       "usb_ehci_enable");
	if (ret < 0) {
		pr_err("Can not request GPIO %d\n", GPIO_USB_POWER);
		return;
	}

	ret = gpio_direction_output(GPIO_USB_POWER, 1);
	if (ret < 0) {
		gpio_free(GPIO_USB_POWER);
		pr_err("Unable to initialize EHCI power\n");
		return;
	}

	usbhs_init(&usbhs_bdata);
}

+16 −38
Original line number Diff line number Diff line
@@ -174,19 +174,14 @@ static void __init am3517_evm_rtc_init(void)
	int r;

	omap_mux_init_gpio(GPIO_RTCS35390A_IRQ, OMAP_PIN_INPUT_PULLUP);
	r = gpio_request(GPIO_RTCS35390A_IRQ, "rtcs35390a-irq");

	r = gpio_request_one(GPIO_RTCS35390A_IRQ, GPIOF_IN, "rtcs35390a-irq");
	if (r < 0) {
		printk(KERN_WARNING "failed to request GPIO#%d\n",
				GPIO_RTCS35390A_IRQ);
		return;
	}
	r = gpio_direction_input(GPIO_RTCS35390A_IRQ);
	if (r < 0) {
		printk(KERN_WARNING "GPIO#%d cannot be configured as input\n",
				GPIO_RTCS35390A_IRQ);
		gpio_free(GPIO_RTCS35390A_IRQ);
		return;
	}

	am3517evm_i2c1_boardinfo[0].irq = gpio_to_irq(GPIO_RTCS35390A_IRQ);
}

@@ -242,6 +237,15 @@ static int dvi_enabled;

#if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
		defined(CONFIG_PANEL_SHARP_LQ043T1DG01_MODULE)
static struct gpio am3517_evm_dss_gpios[] __initdata = {
	/* GPIO 182 = LCD Backlight Power */
	{ LCD_PANEL_BKLIGHT_PWR, GPIOF_OUT_INIT_HIGH, "lcd_backlight_pwr" },
	/* GPIO 181 = LCD Panel PWM */
	{ LCD_PANEL_PWM,	 GPIOF_OUT_INIT_HIGH, "lcd bl enable"	  },
	/* GPIO 176 = LCD Panel Power enable pin */
	{ LCD_PANEL_PWR,	 GPIOF_OUT_INIT_HIGH, "dvi enable"	  },
};

static void __init am3517_evm_display_init(void)
{
	int r;
@@ -249,41 +253,15 @@ static void __init am3517_evm_display_init(void)
	omap_mux_init_gpio(LCD_PANEL_PWR, OMAP_PIN_INPUT_PULLUP);
	omap_mux_init_gpio(LCD_PANEL_BKLIGHT_PWR, OMAP_PIN_INPUT_PULLDOWN);
	omap_mux_init_gpio(LCD_PANEL_PWM, OMAP_PIN_INPUT_PULLDOWN);
	/*
	 * Enable GPIO 182 = LCD Backlight Power
	 */
	r = gpio_request(LCD_PANEL_BKLIGHT_PWR, "lcd_backlight_pwr");

	r = gpio_request_array(am3517_evm_dss_gpios,
			       ARRAY_SIZE(am3517_evm_dss_gpios));
	if (r) {
		printk(KERN_ERR "failed to get lcd_backlight_pwr\n");
		printk(KERN_ERR "failed to get DSS panel control GPIOs\n");
		return;
	}
	gpio_direction_output(LCD_PANEL_BKLIGHT_PWR, 1);
	/*
	 * Enable GPIO 181 = LCD Panel PWM
	 */
	r = gpio_request(LCD_PANEL_PWM, "lcd_pwm");
	if (r) {
		printk(KERN_ERR "failed to get lcd_pwm\n");
		goto err_1;
	}
	gpio_direction_output(LCD_PANEL_PWM, 1);
	/*
	 * Enable GPIO 176 = LCD Panel Power enable pin
	 */
	r = gpio_request(LCD_PANEL_PWR, "lcd_panel_pwr");
	if (r) {
		printk(KERN_ERR "failed to get lcd_panel_pwr\n");
		goto err_2;
	}
	gpio_direction_output(LCD_PANEL_PWR, 1);

	printk(KERN_INFO "Display initialized successfully\n");
	return;

err_2:
	gpio_free(LCD_PANEL_PWM);
err_1:
	gpio_free(LCD_PANEL_BKLIGHT_PWR);
}
#else
static void __init am3517_evm_display_init(void) {}
Loading