mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	usb: renesas_usbhs: Switch to GPIO descriptor
The Renesas USBHS driver includes a bit of surplus headers and uses the old GPIO API so let's switch it to use the GPIO descriptor. I noticed that the enable_gpio inside renesas_usbhs_driver_param isn't really referenced anywhere, and it is also the wrong type (u32) so let's just delete it and use a local variable instead. Cc: Eugeniu Rosca <erosca@de.adit-jv.com> Cc: Veeraiyan Chidambaram <veeraiyan.chidambaram@in.bosch.com> Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20191217141241.57639-1-linus.walleij@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
		
							parent
							
								
									91687c1926
								
							
						
					
					
						commit
						3b31ec1848
					
				
					 3 changed files with 9 additions and 17 deletions
				
			
		| 
						 | 
					@ -8,11 +8,10 @@
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
#include <linux/clk.h>
 | 
					#include <linux/clk.h>
 | 
				
			||||||
#include <linux/err.h>
 | 
					#include <linux/err.h>
 | 
				
			||||||
#include <linux/gpio.h>
 | 
					#include <linux/gpio/consumer.h>
 | 
				
			||||||
#include <linux/io.h>
 | 
					#include <linux/io.h>
 | 
				
			||||||
#include <linux/module.h>
 | 
					#include <linux/module.h>
 | 
				
			||||||
#include <linux/of_device.h>
 | 
					#include <linux/of_device.h>
 | 
				
			||||||
#include <linux/of_gpio.h>
 | 
					 | 
				
			||||||
#include <linux/pm_runtime.h>
 | 
					#include <linux/pm_runtime.h>
 | 
				
			||||||
#include <linux/reset.h>
 | 
					#include <linux/reset.h>
 | 
				
			||||||
#include <linux/slab.h>
 | 
					#include <linux/slab.h>
 | 
				
			||||||
| 
						 | 
					@ -592,7 +591,8 @@ static int usbhs_probe(struct platform_device *pdev)
 | 
				
			||||||
	struct usbhs_priv *priv;
 | 
						struct usbhs_priv *priv;
 | 
				
			||||||
	struct resource *irq_res;
 | 
						struct resource *irq_res;
 | 
				
			||||||
	struct device *dev = &pdev->dev;
 | 
						struct device *dev = &pdev->dev;
 | 
				
			||||||
	int ret, gpio;
 | 
						struct gpio_desc *gpiod;
 | 
				
			||||||
 | 
						int ret;
 | 
				
			||||||
	u32 tmp;
 | 
						u32 tmp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* check device node */
 | 
						/* check device node */
 | 
				
			||||||
| 
						 | 
					@ -657,10 +657,9 @@ static int usbhs_probe(struct platform_device *pdev)
 | 
				
			||||||
		priv->dparam.pio_dma_border = 64; /* 64byte */
 | 
							priv->dparam.pio_dma_border = 64; /* 64byte */
 | 
				
			||||||
	if (!of_property_read_u32(dev_of_node(dev), "renesas,buswait", &tmp))
 | 
						if (!of_property_read_u32(dev_of_node(dev), "renesas,buswait", &tmp))
 | 
				
			||||||
		priv->dparam.buswait_bwait = tmp;
 | 
							priv->dparam.buswait_bwait = tmp;
 | 
				
			||||||
	gpio = of_get_named_gpio_flags(dev_of_node(dev), "renesas,enable-gpio",
 | 
						gpiod = devm_gpiod_get_optional(dev, "renesas,enable", GPIOD_IN);
 | 
				
			||||||
				       0, NULL);
 | 
						if (IS_ERR(gpiod))
 | 
				
			||||||
	if (gpio > 0)
 | 
							return PTR_ERR(gpiod);
 | 
				
			||||||
		priv->dparam.enable_gpio = gpio;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* FIXME */
 | 
						/* FIXME */
 | 
				
			||||||
	/* runtime power control ? */
 | 
						/* runtime power control ? */
 | 
				
			||||||
| 
						 | 
					@ -708,13 +707,10 @@ static int usbhs_probe(struct platform_device *pdev)
 | 
				
			||||||
	usbhs_sys_clock_ctrl(priv, 0);
 | 
						usbhs_sys_clock_ctrl(priv, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* check GPIO determining if USB function should be enabled */
 | 
						/* check GPIO determining if USB function should be enabled */
 | 
				
			||||||
	if (priv->dparam.enable_gpio) {
 | 
						if (gpiod) {
 | 
				
			||||||
		gpio_request_one(priv->dparam.enable_gpio, GPIOF_IN, NULL);
 | 
							ret = !gpiod_get_value(gpiod);
 | 
				
			||||||
		ret = !gpio_get_value(priv->dparam.enable_gpio);
 | 
					 | 
				
			||||||
		gpio_free(priv->dparam.enable_gpio);
 | 
					 | 
				
			||||||
		if (ret) {
 | 
							if (ret) {
 | 
				
			||||||
			dev_warn(dev, "USB function not selected (GPIO %d)\n",
 | 
								dev_warn(dev, "USB function not selected (GPIO)\n");
 | 
				
			||||||
				 priv->dparam.enable_gpio);
 | 
					 | 
				
			||||||
			ret = -ENOTSUPP;
 | 
								ret = -ENOTSUPP;
 | 
				
			||||||
			goto probe_end_mod_exit;
 | 
								goto probe_end_mod_exit;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,8 +6,6 @@
 | 
				
			||||||
 * Copyright (C) 2019 Renesas Electronics Corporation
 | 
					 * Copyright (C) 2019 Renesas Electronics Corporation
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <linux/gpio.h>
 | 
					 | 
				
			||||||
#include <linux/of_gpio.h>
 | 
					 | 
				
			||||||
#include <linux/phy/phy.h>
 | 
					#include <linux/phy/phy.h>
 | 
				
			||||||
#include "common.h"
 | 
					#include "common.h"
 | 
				
			||||||
#include "rcar2.h"
 | 
					#include "rcar2.h"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -170,8 +170,6 @@ struct renesas_usbhs_driver_param {
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	int pio_dma_border; /* default is 64byte */
 | 
						int pio_dma_border; /* default is 64byte */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	u32 enable_gpio;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * option:
 | 
						 * option:
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue