ARM: davinci: OHCI: Use a regulator instead of callbacks
Subsystems (3)
cover ARM: davinci: OHCI: Use a regulator instead of callbacks
With the ultimate goal to able to probe the ohci driver form DT, convert users of OHCI pdata to use a regulator instead of passing platform function pointers. This will help to remove the platform callbacks in a future series.
These patches were included in previous series[1], im sending them again to claify that it should go through the devinci tree, and to update the dependencies.
[1] https://www.spinics.net/lists/linux-usb/msg148884.html
DEPENDENCIES:
1. [PATCH v6 0/5] USB: ohci-da8xx: Add device tree support
https://lkml.org/lkml/2016/11/21/558
2. [PATCH v3 0/2] regulator: handling of error conditions for usb drivers
https://lkml.org/lkml/2016/11/4/465
3. [PATCH v2 0/3] davinci: ohci: fix usb ohci device name
http://www.mail-archive.com/linux-kernel at vger.kernel.org/msg1263999.html
Axel Haslam (3):
ARM: davinci: da830: Handle vbus with a regulator
ARM: davinci: hawk: Remove vbus and over current gpios
ARM: davinci: remove ohci platform usage
arch/arm/mach-davinci/board-da830-evm.c | 108 ++++++++++------------------ arch/arm/mach-davinci/board-omapl138-hawk.c | 99 ++----------------------- arch/arm/mach-davinci/include/mach/da8xx.h | 2 +- arch/arm/mach-davinci/usb-da8xx.c | 3 +- 4 files changed, 44 insertions(+), 168 deletions(-)
Signature · 1 line
2.9.3
PATCH RESEND 1/3 ARM: davinci: da830: Handle vbus with a regulator
The usb driver can now take a regulator instead of the platform callbacks for vbus handling. Lets use a regulator so we can remove the callbacks in a later patch.
--- arch/arm/mach-davinci/board-da830-evm.c | 108 +++++++++++--------------------- 1 file changed, 38 insertions(+), 70 deletions(-)
arch/arm/mach-davinci/board-da830-evm.c +38 -70
@@ -14,6 +14,7 @@#include <linux/console.h> #include <linux/interrupt.h> #include <linux/gpio.h> +#include <linux/gpio/machine.h> #include <linux/platform_device.h> #include <linux/i2c.h> #include <linux/i2c/pcf857x.h>
@@ -28,6 +29,7 @@#include <linux/platform_data/spi-davinci.h> #include <linux/platform_data/usb-davinci.h> #include <linux/regulator/machine.h> +#include <linux/regulator/fixed.h> #include <asm/mach-types.h> #include <asm/mach/arch.h>
@@ -38,72 +40,48 @@#include <mach/da8xx.h> #define DA830_EVM_PHY_ID "" -/* -* USB1 VBUS is controlled by GPIO1[15], over-current is reported on GPIO2[4]. -*/ -#define ON_BD_USB_DRV GPIO_TO_PIN(1, 15) -#define ON_BD_USB_OVC GPIO_TO_PIN(2, 4)static const short da830_evm_usb11_pins[] = {DA830_GPIO1_15 ,DA830_GPIO2_4 ,-1 }; -static da8xx_ocic_handler_t da830_evm_usb_ocic_handler; - -static int da830_evm_usb_set_power (unsigned port,int on) -{ -gpio_set_value (ON_BD_USB_DRV , on); -return 0 ; -} +static struct regulator_consumer_supply usb_ohci_consumer_supply = +REGULATOR_SUPPLY ("vbus" ,"ohci-da8xx" ); -static int da830_evm_usb_get_power (unsigned port) -{ -return gpio_get_value (ON_BD_USB_DRV ); -} - -static int da830_evm_usb_get_oci (unsigned port) -{ -return !gpio_get_value (ON_BD_USB_OVC ); -} - -static irqreturn_t da830_evm_usb_ocic_irq (int ,void *); - -static int da830_evm_usb_ocic_notify (da8xx_ocic_handler_t handler) -{ -int irq =gpio_to_irq (ON_BD_USB_OVC ); -int error =0 ; - -if (handler !=NULL ) { - da830_evm_usb_ocic_handler = handler; - - error =request_irq (irq, da830_evm_usb_ocic_irq, -IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING , -"OHCI over-current indicator" ,NULL ); -if (error) -pr_err ("%s: could not request IRQ to watch over-current indicator changes\n" , - __func__); - }else -free_irq (irq,NULL ); - -return error; -} +static struct regulator_init_data usb_ohci_initdata = { + .consumer_supplies = &usb_ohci_consumer_supply, + .num_consumer_supplies =1 , + .constraints = { + .valid_ops_mask =REGULATOR_CHANGE_STATUS , + }, +}; -static struct da8xx_ohci_root_hub da830_evm_usb11_pdata = { - .set_power = da830_evm_usb_set_power, - .get_power = da830_evm_usb_get_power, - .get_oci = da830_evm_usb_get_oci, - .ocic_notify = da830_evm_usb_ocic_notify, +static struct fixed_voltage_config usb_ohci_config = { + .supply_name ="vbus" , + .microvolts =5000000 , + .gpio =GPIO_TO_PIN (1 ,15 ), + .enable_high =1 , + .enabled_at_boot =0 , + .init_data = &usb_ohci_initdata, +}; -/* TPS2065 switch @ 5V */ - .potpgt = (3 +1 ) /2 ,/* 3 ms max */ +static struct platform_device da8xx_usb11_regulator = { + .name ="reg-fixed-voltage" , + .id =0 , + .dev = { + .platform_data = &usb_ohci_config, + }, }; -static irqreturn_t da830_evm_usb_ocic_irq (int irq,void *dev_id) -{ -da830_evm_usb_ocic_handler (&da830_evm_usb11_pdata,1 ); -return IRQ_HANDLED ; -} +static struct gpiod_lookup_table usb11_gpios_table = { + .dev_id ="reg-fixed-voltage.0" , + .table = { +/* gpio chip 1 contains gpio range 32-63 */ +GPIO_LOOKUP ("davinci_gpio.1" ,4 ,"over-current" , +GPIO_ACTIVE_LOW ), + }, +};static __init void da830_evm_usb_init (void ) {
@@ -145,23 +123,13 @@ static __init void da830_evm_usb_init(void)return ; } - ret =gpio_request (ON_BD_USB_DRV ,"ON_BD_USB_DRV" ); -if (ret) { -pr_err ("%s: failed to request GPIO for USB 1.1 port power control: %d\n" , - __func__, ret); -return ; - } -gpio_direction_output (ON_BD_USB_DRV ,0 ); +gpiod_add_lookup_table (&usb11_gpios_table); - ret =gpio_request (ON_BD_USB_OVC ,"ON_BD_USB_OVC" ); -if (ret) { -pr_err ("%s: failed to request GPIO for USB 1.1 port over-current indicator: %d\n" , - __func__, ret); -return ; - } -gpio_direction_input (ON_BD_USB_OVC ); + ret =platform_device_register (&da8xx_usb11_regulator); +if (ret) +pr_warn ("fail to add ohci regulator\n" ); - ret =da8xx_register_usb11 (&da830_evm_usb11_pdata); + ret =da8xx_register_usb11 (NULL );if (ret)pr_warn ("%s: USB 1.1 registration failed: %d\n" , __func__, ret); }
Signature · 1 line
2.9.3
Re: [RESEND PATCH 1/3] ARM: davinci: da830: Handle vbus with a regulator
Quoted 15 lines · Axel Haslam
static
__initvoidda830_evm_usb_init(void)
{arch/arm/mach-davinci/board-da830-evm.c +1
-7@@ -145,23 +123,13 @@ static __init void da830_evm_usb_init(void)return ; } - ret =gpio_request (ON_BD_USB_DRV ,"ON_BD_USB_DRV" ); -if (ret) { -pr_err ("%s: failed to request GPIO for USB 1.1 port power control: %d\n" , - __func__, ret); -return ; - } -gpio_direction_output (ON_BD_USB_DRV ,0 ); +gpiod_add_lookup_table (&usb11_gpios_table);
arch/arm/mach-davinci/board-da830-evm.c static __init void da830_evm_usb_init(void) · line 130
Quoted 10 lines
arch/arm/mach-davinci/board-da830-evm.c +3
-7- ret =gpio_request (ON_BD_USB_OVC ,"ON_BD_USB_OVC" ); -if (ret) { -pr_err ("%s: failed to request GPIO for USB 1.1 port over-current indicator: %d\n" , - __func__, ret); -return ; - } -gpio_direction_input (ON_BD_USB_OVC ); + ret =platform_device_register (&da8xx_usb11_regulator); +if (ret) +pr_warn ("fail to add ohci regulator\n" );
Can you follow the same style as used in other error/warning messages in this function (adding a function name prefix, printing of error code).
Thanks,
Sekhar
PATCH RESEND 2/3 ARM: davinci: hawk: Remove vbus and over current gpios
In reply to Axel HaslamThe hawk board VBUS is fixed to a 5v source, and the over current pin is actually not connected to the SoC.
Do not reseve these gpios for OHCI as they are not related to usb.
--- arch/arm/mach-davinci/board-omapl138-hawk.c | 99 ++--------------------------- 1 file changed, 4 insertions(+), 95 deletions(-)
arch/arm/mach-davinci/board-omapl138-hawk.c +4 -95
@@ -28,9 +28,6 @@#define DA850_HAWK_MMCSD_CD_PIN GPIO_TO_PIN(3, 12)#define DA850_HAWK_MMCSD_WP_PIN GPIO_TO_PIN(3, 13) -#define DA850_USB1_VBUS_PIN GPIO_TO_PIN(2, 4) -#define DA850_USB1_OC_PIN GPIO_TO_PIN(6, 13) -static short omapl138_hawk_mii_pins[]__initdata = {DA850_MII_TXEN ,DA850_MII_TXCLK ,DA850_MII_COL ,DA850_MII_TXD_3 ,DA850_MII_TXD_2 ,DA850_MII_TXD_1 ,DA850_MII_TXD_0 ,DA850_MII_RXER ,
@@ -181,76 +178,10 @@ static __init void omapl138_hawk_mmc_init(void)gpio_free (DA850_HAWK_MMCSD_CD_PIN ); } -static irqreturn_t omapl138_hawk_usb_ocic_irq (int irq,void *dev_id); -static da8xx_ocic_handler_t hawk_usb_ocic_handler; - -static const short da850_hawk_usb11_pins[] = { -DA850_GPIO2_4 ,DA850_GPIO6_13 , --1 -}; - -static int hawk_usb_set_power (unsigned port,int on) -{ -gpio_set_value (DA850_USB1_VBUS_PIN , on); -return 0 ; -} - -static int hawk_usb_get_power (unsigned port) -{ -return gpio_get_value (DA850_USB1_VBUS_PIN ); -} - -static int hawk_usb_get_oci (unsigned port) -{ -return !gpio_get_value (DA850_USB1_OC_PIN ); -} - -static int hawk_usb_ocic_notify (da8xx_ocic_handler_t handler) -{ -int irq =gpio_to_irq (DA850_USB1_OC_PIN ); -int error =0 ; - -if (handler !=NULL ) { - hawk_usb_ocic_handler = handler; - - error =request_irq (irq, omapl138_hawk_usb_ocic_irq, -IRQF_TRIGGER_RISING | -IRQF_TRIGGER_FALLING , -"OHCI over-current indicator" ,NULL ); -if (error) -pr_err ("%s: could not request IRQ to watch " -"over-current indicator changes\n" , __func__); - }else { -free_irq (irq,NULL ); - } -return error; -} - -static struct da8xx_ohci_root_hub omapl138_hawk_usb11_pdata = { - .set_power = hawk_usb_set_power, - .get_power = hawk_usb_get_power, - .get_oci = hawk_usb_get_oci, - .ocic_notify = hawk_usb_ocic_notify, -/* TPS2087 switch @ 5V */ - .potpgt = (3 +1 ) /2 ,/* 3 ms max */ -}; - -static irqreturn_t omapl138_hawk_usb_ocic_irq (int irq,void *dev_id) -{ -hawk_usb_ocic_handler (&omapl138_hawk_usb11_pdata,1 ); -return IRQ_HANDLED ; -} -static __init void omapl138_hawk_usb_init (void ) {int ret; - ret =davinci_cfg_reg_list (da850_hawk_usb11_pins); -if (ret) { -pr_warn ("%s: USB 1.1 PinMux setup failed: %d\n" , __func__, ret); -return ; - } - ret =da8xx_register_usb20_phy_clk (false);if (ret) pr_warn("%s: USB 2.0 PHY CLK registration failed: %d\n",
@@ -266,34 +197,12 @@ static __init void omapl138_hawk_usb_init(void)pr_warn ("%s: USB PHY registration failed: %d\n" , __func__, ret); - ret =gpio_request_one (DA850_USB1_VBUS_PIN , -GPIOF_DIR_OUT ,"USB1 VBUS" ); -if (ret <0 ) { -pr_err ("%s: failed to request GPIO for USB 1.1 port " -"power control: %d\n" , __func__, ret); -return ; - } - - ret =gpio_request_one (DA850_USB1_OC_PIN , -GPIOF_DIR_IN ,"USB1 OC" ); -if (ret <0 ) { -pr_err ("%s: failed to request GPIO for USB 1.1 port " -"over-current indicator: %d\n" , __func__, ret); - goto usb11_setup_oc_fail; - } - - ret =da8xx_register_usb11 (&omapl138_hawk_usb11_pdata); -if (ret) { -pr_warn ("%s: USB 1.1 registration failed: %d\n" , __func__, ret); - goto usb11_setup_fail; - } + ret =da8xx_register_usb11 (NULL ); +if (ret) +pr_warn ("%s: USB 1.1 registration failed: %d\n" , + __func__, ret);return ; - -usb11_setup_fail: -gpio_free (DA850_USB1_OC_PIN ); -usb11_setup_oc_fail: -gpio_free (DA850_USB1_VBUS_PIN ); }static __init void omapl138_hawk_init (void )
Signature · 1 line
2.9.3
Re: [RESEND PATCH 2/3] ARM: davinci: hawk: Remove vbus and over current gpios
Quoted 7 lines · Axel Haslam
The hawk board VBUS is fixed to a 5v source, and the over current pin is actually not connected to the SoC.
Do not reseve these gpios for OHCI as they are not related to usb.
Signed-off-by Axel Haslam <[email protected]>
As discussed over the MMC/SD patches, this patch should be based off the hawkboard schematic, not the LCDK schematic.
Thanks,
Sekhar
Re: [RESEND PATCH 2/3] ARM: davinci: hawk: Remove vbus and over current gpios
Hi Sekhar
Quoted 4 lines · Sekhar Nori
Quoted 3 lines · Axel Haslam
The hawk board VBUS is fixed to a 5v source, and the over current pin is actually not connected to the SoC.
Quoted 8 lines
Quoted 4 lines
Do not reseve these gpios for OHCI as they are not related to usb.
Signed-off-by Axel Haslam <[email protected]>As discussed over the MMC/SD patches, this patch should be based off the hawkboard schematic, not the LCDK schematic.
I looked at the hawkboard schematics and they are the same as the lcdk as far as usb i concerned:
The ohci vbus is fixed to 5v, and the over current pins of the TPS are not connected. so this patch should be ok for both the hawk and the lcdk.
Regards
Axel
Quoted 2 lines
Thanks,
Sekhar
Re: [RESEND PATCH 2/3] ARM: davinci: hawk: Remove vbus and over current gpios
Quoted 16 lines · Axel Haslam
Hi Sekhar
Quoted 4 lines · Sekhar Nori
Quoted 3 lines · Axel Haslam
The hawk board VBUS is fixed to a 5v source, and the over current pin is actually not connected to the SoC.
Quoted 8 lines
Quoted 4 lines
Do not reseve these gpios for OHCI as they are not related to usb.
Signed-off-by Axel Haslam <[email protected]>As discussed over the MMC/SD patches, this patch should be based off the hawkboard schematic, not the LCDK schematic.
Quoted 6 lines
I looked at the hawkboard schematics and they are the same as the lcdk as far as usb i concerned:
The ohci vbus is fixed to 5v, and the over current pins of the TPS are not connected. so this patch should be ok for both the hawk and the lcdk.
Alright! Thanks for checking.
Regards,
Sekhar
PATCH RESEND 3/3 ARM: davinci: remove ohci platform usage
In reply to Axel HaslamAs all users of ohci platform data have been converted to use a regulator, we dont need to pass platform data to register the ohci device anymore.
--- arch/arm/mach-davinci/board-da830-evm.c | 2 +- arch/arm/mach-davinci/board-omapl138-hawk.c | 2 +- arch/arm/mach-davinci/include/mach/da8xx.h | 2 +- arch/arm/mach-davinci/usb-da8xx.c | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-)
arch/arm/mach-davinci/board-da830-evm.c +1 -1
@@ -129,7 +129,7 @@ static __init void da830_evm_usb_init(void)if (ret)pr_warn ("fail to add ohci regulator\n" ); - ret =da8xx_register_usb11 (NULL ); + ret =da8xx_register_usb11 ();if (ret)pr_warn ("%s: USB 1.1 registration failed: %d\n" , __func__, ret); }
arch/arm/mach-davinci/board-omapl138-hawk.c +1 -1
@@ -197,7 +197,7 @@ static __init void omapl138_hawk_usb_init(void)pr_warn ("%s: USB PHY registration failed: %d\n" , __func__, ret); - ret =da8xx_register_usb11 (NULL ); + ret =da8xx_register_usb11 ();if (ret)pr_warn ("%s: USB 1.1 registration failed: %d\n" , __func__, ret);
arch/arm/mach-davinci/include/mach/da8xx.h +1 -1
@@ -91,7 +91,7 @@ int da8xx_register_spi_bus(int instance, unsigned num_chipselect);int da8xx_register_watchdog (void );int da8xx_register_usb_phy (void );int da8xx_register_usb20 (unsigned mA,unsigned potpgt); -int da8xx_register_usb11 (struct da8xx_ohci_root_hub *pdata); +int da8xx_register_usb11 (void );int da8xx_register_usb_refclkin (int rate);int da8xx_register_usb20_phy_clk (bool use_usb_refclkin);int da8xx_register_usb11_phy_clk (bool use_usb_refclkin);
arch/arm/mach-davinci/usb-da8xx.c +1 -2
@@ -119,9 +119,8 @@ static struct platform_device da8xx_usb11_device = { .resource = da8xx_usb11_resources, }; -int __init da8xx_register_usb11 (struct da8xx_ohci_root_hub *pdata) +int __init da8xx_register_usb11 (void ) { - da8xx_usb11_device.dev.platform_data = pdata;return platform_device_register (&da8xx_usb11_device); }
Signature · 1 line
2.9.3
Re: [RESEND PATCH 3/3] ARM: davinci: remove ohci platform usage
Quoted 5 lines · Axel Haslam
As all users of ohci platform data have been converted to use a regulator, we dont need to pass platform data to register the ohci device anymore.
Signed-off-by Axel Haslam <[email protected]>
This looks good to me.
Thanks,
Sekhar