* [PATCH 0/2 resend] USB: host: Misc patches to remove hard-coded octeon platform information
@ 2014-12-15 13:26 Andreas Herrmann
2014-12-15 13:28 ` [PATCH 1/2 resend] USB: host: Remove hard-coded octeon platform information for ehci/ohci Andreas Herrmann
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Andreas Herrmann @ 2014-12-15 13:26 UTC (permalink / raw)
To: Greg KH
Cc: Alan Stern, David Daney, Alex Smith, Linux-MIPS, linux-usb,
Aaro Koskinen
This is a re-submission of patches 2 and 3 from
http://marc.info/?i=1415914590-31647-1-git-send-email-andreas.herrmann@caviumnetworks.com
(Only patch 1/3 made it into usb-next and meanwhile is in mainline.)
Please apply.
Thanks,
Andreas
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH 1/2 resend] USB: host: Remove hard-coded octeon platform information for ehci/ohci 2014-12-15 13:26 [PATCH 0/2 resend] USB: host: Misc patches to remove hard-coded octeon platform information Andreas Herrmann @ 2014-12-15 13:28 ` Andreas Herrmann 2014-12-15 16:04 ` Ralf Baechle 2014-12-15 13:30 ` [PATCH 2/2 resend] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform Andreas Herrmann ` (2 subsequent siblings) 3 siblings, 1 reply; 13+ messages in thread From: Andreas Herrmann @ 2014-12-15 13:28 UTC (permalink / raw) To: Greg KH Cc: Alan Stern, David Daney, Alex Smith, Linux-MIPS, linux-usb, Aaro Koskinen Instead rely on device tree information for ehci and ohci. This was suggested with http://www.linux-mips.org/archives/linux-mips/2014-05/msg00307.html "The device tree will *always* have correct ehci/ohci clock configuration, so use it. This allows us to remove a big chunk of platform configuration code from octeon-platform.c." More or less I rebased that patch on Alan's work to remove ehci-octeon and ohci-octeon drivers. Cc: David Daney <david.daney@cavium.com> Cc: Alex Smith <alex.smith@imgtec.com> Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Andreas Herrmann <andreas.herrmann@caviumnetworks.com> Acked-by: Ralf Baechle <ralf@linux-mips.org> Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi> --- arch/mips/cavium-octeon/octeon-platform.c | 148 ++++++++++++----------------- drivers/usb/host/ehci-platform.c | 1 + drivers/usb/host/ohci-platform.c | 1 + 3 files changed, 64 insertions(+), 86 deletions(-) diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c index b67ddf0..eea60b6 100644 --- a/arch/mips/cavium-octeon/octeon-platform.c +++ b/arch/mips/cavium-octeon/octeon-platform.c @@ -77,7 +77,7 @@ static DEFINE_MUTEX(octeon2_usb_clocks_mutex); static int octeon2_usb_clock_start_cnt; -static void octeon2_usb_clocks_start(void) +static void octeon2_usb_clocks_start(struct device *dev) { u64 div; union cvmx_uctlx_if_ena if_ena; @@ -86,6 +86,8 @@ static void octeon2_usb_clocks_start(void) union cvmx_uctlx_uphy_portx_ctl_status port_ctl_status; int i; unsigned long io_clk_64_to_ns; + u32 clock_rate = 12000000; + bool is_crystal_clock = false; mutex_lock(&octeon2_usb_clocks_mutex); @@ -96,6 +98,28 @@ static void octeon2_usb_clocks_start(void) io_clk_64_to_ns = 64000000000ull / octeon_get_io_clock_rate(); + if (dev->of_node) { + struct device_node *uctl_node; + const char *clock_type; + + uctl_node = of_get_parent(dev->of_node); + if (!uctl_node) { + dev_err(dev, "No UCTL device node\n"); + goto exit; + } + i = of_property_read_u32(uctl_node, + "refclk-frequency", &clock_rate); + if (i) { + dev_err(dev, "No UCTL \"refclk-frequency\"\n"); + goto exit; + } + i = of_property_read_string(uctl_node, + "refclk-type", &clock_type); + + if (!i && strcmp("crystal", clock_type) == 0) + is_crystal_clock = true; + } + /* * Step 1: Wait for voltages stable. That surely happened * before starting the kernel. @@ -126,9 +150,22 @@ static void octeon2_usb_clocks_start(void) cvmx_write_csr(CVMX_UCTLX_CLK_RST_CTL(0), clk_rst_ctl.u64); /* 3b */ - /* 12MHz crystal. */ - clk_rst_ctl.s.p_refclk_sel = 0; - clk_rst_ctl.s.p_refclk_div = 0; + clk_rst_ctl.s.p_refclk_sel = is_crystal_clock ? 0 : 1; + switch (clock_rate) { + default: + pr_err("Invalid UCTL clock rate of %u, using 12000000 instead\n", + clock_rate); + /* Fall through */ + case 12000000: + clk_rst_ctl.s.p_refclk_div = 0; + break; + case 24000000: + clk_rst_ctl.s.p_refclk_div = 1; + break; + case 48000000: + clk_rst_ctl.s.p_refclk_div = 2; + break; + } cvmx_write_csr(CVMX_UCTLX_CLK_RST_CTL(0), clk_rst_ctl.u64); /* 3c */ @@ -259,7 +296,7 @@ static void octeon2_usb_clocks_stop(void) static int octeon_ehci_power_on(struct platform_device *pdev) { - octeon2_usb_clocks_start(); + octeon2_usb_clocks_start(&pdev->dev); return 0; } @@ -277,11 +314,11 @@ static struct usb_ehci_pdata octeon_ehci_pdata = { .power_off = octeon_ehci_power_off, }; -static void __init octeon_ehci_hw_start(void) +static void __init octeon_ehci_hw_start(struct device *dev) { union cvmx_uctlx_ehci_ctl ehci_ctl; - octeon2_usb_clocks_start(); + octeon2_usb_clocks_start(dev); ehci_ctl.u64 = cvmx_read_csr(CVMX_UCTLX_EHCI_CTL(0)); /* Use 64-bit addressing. */ @@ -299,59 +336,28 @@ static u64 octeon_ehci_dma_mask = DMA_BIT_MASK(64); static int __init octeon_ehci_device_init(void) { struct platform_device *pd; + struct device_node *ehci_node; int ret = 0; - struct resource usb_resources[] = { - { - .flags = IORESOURCE_MEM, - }, { - .flags = IORESOURCE_IRQ, - } - }; - - /* Only Octeon2 has ehci/ohci */ - if (!OCTEON_IS_MODEL(OCTEON_CN63XX)) + ehci_node = of_find_node_by_name(NULL, "ehci"); + if (!ehci_node) return 0; - if (octeon_is_simulation() || usb_disabled()) - return 0; /* No USB in the simulator. */ - - pd = platform_device_alloc("ehci-platform", 0); - if (!pd) { - ret = -ENOMEM; - goto out; - } - - usb_resources[0].start = 0x00016F0000000000ULL; - usb_resources[0].end = usb_resources[0].start + 0x100; - - usb_resources[1].start = OCTEON_IRQ_USB0; - usb_resources[1].end = OCTEON_IRQ_USB0; - - ret = platform_device_add_resources(pd, usb_resources, - ARRAY_SIZE(usb_resources)); - if (ret) - goto fail; + pd = of_find_device_by_node(ehci_node); + if (!pd) + return 0; pd->dev.dma_mask = &octeon_ehci_dma_mask; pd->dev.platform_data = &octeon_ehci_pdata; - octeon_ehci_hw_start(); - - ret = platform_device_add(pd); - if (ret) - goto fail; + octeon_ehci_hw_start(&pd->dev); return ret; -fail: - platform_device_put(pd); -out: - return ret; } device_initcall(octeon_ehci_device_init); static int octeon_ohci_power_on(struct platform_device *pdev) { - octeon2_usb_clocks_start(); + octeon2_usb_clocks_start(&pdev->dev); return 0; } @@ -369,11 +375,11 @@ static struct usb_ohci_pdata octeon_ohci_pdata = { .power_off = octeon_ohci_power_off, }; -static void __init octeon_ohci_hw_start(void) +static void __init octeon_ohci_hw_start(struct device *dev) { union cvmx_uctlx_ohci_ctl ohci_ctl; - octeon2_usb_clocks_start(); + octeon2_usb_clocks_start(dev); ohci_ctl.u64 = cvmx_read_csr(CVMX_UCTLX_OHCI_CTL(0)); ohci_ctl.s.l2c_addr_msb = 0; @@ -387,57 +393,27 @@ static void __init octeon_ohci_hw_start(void) static int __init octeon_ohci_device_init(void) { struct platform_device *pd; + struct device_node *ohci_node; int ret = 0; - struct resource usb_resources[] = { - { - .flags = IORESOURCE_MEM, - }, { - .flags = IORESOURCE_IRQ, - } - }; - - /* Only Octeon2 has ehci/ohci */ - if (!OCTEON_IS_MODEL(OCTEON_CN63XX)) + ohci_node = of_find_node_by_name(NULL, "ohci"); + if (!ohci_node) return 0; - if (octeon_is_simulation() || usb_disabled()) - return 0; /* No USB in the simulator. */ - - pd = platform_device_alloc("ohci-platform", 0); - if (!pd) { - ret = -ENOMEM; - goto out; - } - - usb_resources[0].start = 0x00016F0000000400ULL; - usb_resources[0].end = usb_resources[0].start + 0x100; - - usb_resources[1].start = OCTEON_IRQ_USB0; - usb_resources[1].end = OCTEON_IRQ_USB0; - - ret = platform_device_add_resources(pd, usb_resources, - ARRAY_SIZE(usb_resources)); - if (ret) - goto fail; + pd = of_find_device_by_node(ohci_node); + if (!pd) + return 0; pd->dev.platform_data = &octeon_ohci_pdata; - octeon_ohci_hw_start(); - - ret = platform_device_add(pd); - if (ret) - goto fail; + octeon_ohci_hw_start(&pd->dev); return ret; -fail: - platform_device_put(pd); -out: - return ret; } device_initcall(octeon_ohci_device_init); #endif /* CONFIG_USB */ + static struct of_device_id __initdata octeon_ids[] = { { .compatible = "simple-bus", }, { .compatible = "cavium,octeon-6335-uctl", }, diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index 35a9aed..5b8533f 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -349,6 +349,7 @@ static const struct of_device_id vt8500_ehci_ids[] = { { .compatible = "via,vt8500-ehci", }, { .compatible = "wm,prizm-ehci", }, { .compatible = "generic-ehci", }, + { .compatible = "cavium,octeon-6335-ehci", }, {} }; MODULE_DEVICE_TABLE(of, vt8500_ehci_ids); diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c index 9434c1d..748a1a2 100644 --- a/drivers/usb/host/ohci-platform.c +++ b/drivers/usb/host/ohci-platform.c @@ -328,6 +328,7 @@ static int ohci_platform_resume(struct device *dev) static const struct of_device_id ohci_platform_ids[] = { { .compatible = "generic-ohci", }, + { .compatible = "cavium,octeon-6335-ohci", }, { } }; MODULE_DEVICE_TABLE(of, ohci_platform_ids); -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2 resend] USB: host: Remove hard-coded octeon platform information for ehci/ohci 2014-12-15 13:28 ` [PATCH 1/2 resend] USB: host: Remove hard-coded octeon platform information for ehci/ohci Andreas Herrmann @ 2014-12-15 16:04 ` Ralf Baechle 0 siblings, 0 replies; 13+ messages in thread From: Ralf Baechle @ 2014-12-15 16:04 UTC (permalink / raw) To: Andreas Herrmann Cc: Greg KH, Alan Stern, David Daney, Alex Smith, Linux-MIPS, linux-usb, Aaro Koskinen On Mon, Dec 15, 2014 at 02:28:41PM +0100, Andreas Herrmann wrote: > Instead rely on device tree information for ehci and ohci. > > This was suggested with > http://www.linux-mips.org/archives/linux-mips/2014-05/msg00307.html Please use the permanent link from that page: http://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips&i=1401358203-60225-4-git-send-email-alex.smith%40imgtec.com The non-permanent links might change. Ralf ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/2 resend] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform 2014-12-15 13:26 [PATCH 0/2 resend] USB: host: Misc patches to remove hard-coded octeon platform information Andreas Herrmann 2014-12-15 13:28 ` [PATCH 1/2 resend] USB: host: Remove hard-coded octeon platform information for ehci/ohci Andreas Herrmann @ 2014-12-15 13:30 ` Andreas Herrmann 2014-12-15 16:36 ` [PATCH 0/2 resend] USB: host: Misc patches to remove hard-coded octeon platform information Greg KH 2015-01-06 12:46 ` [PATCH 0/2 resend v2] " Andreas Herrmann 3 siblings, 0 replies; 13+ messages in thread From: Andreas Herrmann @ 2014-12-15 13:30 UTC (permalink / raw) To: Greg KH Cc: Alan Stern, David Daney, Alex Smith, Linux-MIPS, linux-usb, Aaro Koskinen ehci-octeon driver used a 64-bit dma_mask. With removal of ehci-octeon and usage of ehci-platform ehci dma_mask is now limited to 32 bits (coerced in ehci_platform_probe). Provide a flag in ehci platform data to allow use of 64 bits for dma_mask. Cc: David Daney <david.daney@cavium.com> Cc: Alex Smith <alex.smith@imgtec.com> Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Andreas Herrmann <andreas.herrmann@caviumnetworks.com> Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi> --- arch/mips/cavium-octeon/octeon-platform.c | 4 +--- drivers/usb/host/ehci-platform.c | 3 ++- include/linux/usb/ehci_pdriver.h | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c index eea60b6..12410a2 100644 --- a/arch/mips/cavium-octeon/octeon-platform.c +++ b/arch/mips/cavium-octeon/octeon-platform.c @@ -310,6 +310,7 @@ static struct usb_ehci_pdata octeon_ehci_pdata = { #ifdef __BIG_ENDIAN .big_endian_mmio = 1, #endif + .dma_mask_64 = 1, .power_on = octeon_ehci_power_on, .power_off = octeon_ehci_power_off, }; @@ -331,8 +332,6 @@ static void __init octeon_ehci_hw_start(struct device *dev) octeon2_usb_clocks_stop(); } -static u64 octeon_ehci_dma_mask = DMA_BIT_MASK(64); - static int __init octeon_ehci_device_init(void) { struct platform_device *pd; @@ -347,7 +346,6 @@ static int __init octeon_ehci_device_init(void) if (!pd) return 0; - pd->dev.dma_mask = &octeon_ehci_dma_mask; pd->dev.platform_data = &octeon_ehci_pdata; octeon_ehci_hw_start(&pd->dev); diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index 5b8533f..37abbe2 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -155,7 +155,8 @@ static int ehci_platform_probe(struct platform_device *dev) if (!pdata) pdata = &ehci_platform_defaults; - err = dma_coerce_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32)); + err = dma_coerce_mask_and_coherent(&dev->dev, + pdata->dma_mask_64 ? DMA_BIT_MASK(64) : DMA_BIT_MASK(32)); if (err) return err; diff --git a/include/linux/usb/ehci_pdriver.h b/include/linux/usb/ehci_pdriver.h index 7eb4dcd..f69529e 100644 --- a/include/linux/usb/ehci_pdriver.h +++ b/include/linux/usb/ehci_pdriver.h @@ -45,6 +45,7 @@ struct usb_ehci_pdata { unsigned big_endian_desc:1; unsigned big_endian_mmio:1; unsigned no_io_watchdog:1; + unsigned dma_mask_64:1; /* Turn on all power and clocks */ int (*power_on)(struct platform_device *pdev); -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 0/2 resend] USB: host: Misc patches to remove hard-coded octeon platform information 2014-12-15 13:26 [PATCH 0/2 resend] USB: host: Misc patches to remove hard-coded octeon platform information Andreas Herrmann 2014-12-15 13:28 ` [PATCH 1/2 resend] USB: host: Remove hard-coded octeon platform information for ehci/ohci Andreas Herrmann 2014-12-15 13:30 ` [PATCH 2/2 resend] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform Andreas Herrmann @ 2014-12-15 16:36 ` Greg KH 2015-01-06 12:46 ` [PATCH 0/2 resend v2] " Andreas Herrmann 3 siblings, 0 replies; 13+ messages in thread From: Greg KH @ 2014-12-15 16:36 UTC (permalink / raw) To: Andreas Herrmann Cc: Alan Stern, David Daney, Alex Smith, Linux-MIPS, linux-usb, Aaro Koskinen On Mon, Dec 15, 2014 at 02:26:29PM +0100, Andreas Herrmann wrote: > This is a re-submission of patches 2 and 3 from > http://marc.info/?i=1415914590-31647-1-git-send-email-andreas.herrmann@caviumnetworks.com > (Only patch 1/3 made it into usb-next and meanwhile is in mainline.) > > Please apply. I'll get to patches after 3.19-rc1 is out, can't do anything with my trees until then, sorry. greg k-h ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 0/2 resend v2] USB: host: Misc patches to remove hard-coded octeon platform information 2014-12-15 13:26 [PATCH 0/2 resend] USB: host: Misc patches to remove hard-coded octeon platform information Andreas Herrmann ` (2 preceding siblings ...) 2014-12-15 16:36 ` [PATCH 0/2 resend] USB: host: Misc patches to remove hard-coded octeon platform information Greg KH @ 2015-01-06 12:46 ` Andreas Herrmann 2015-01-06 12:48 ` [PATCH 1/2 resend v2] USB: host: Remove hard-coded octeon platform information for ehci/ohci Andreas Herrmann ` (2 more replies) 3 siblings, 3 replies; 13+ messages in thread From: Andreas Herrmann @ 2015-01-06 12:46 UTC (permalink / raw) To: Greg KH Cc: Alan Stern, David Daney, Alex Smith, Linux-MIPS, linux-usb, Aaro Koskinen This is a re-submission of patches 2 and 3 from http://marc.info/?i=1415914590-31647-1-git-send-email-andreas.herrmann@caviumnetworks.com (Only patch 1/3 made it into usb-next and meanwhile is in mainline.) Please apply. Thanks, Andreas PS: It's v2 as with last submission I hit the merge window. Patches are rebased to v3.19-rc2. Only change is usage of a permanent link for the mail referenced in commit message of patch 2/2. ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/2 resend v2] USB: host: Remove hard-coded octeon platform information for ehci/ohci 2015-01-06 12:46 ` [PATCH 0/2 resend v2] " Andreas Herrmann @ 2015-01-06 12:48 ` Andreas Herrmann 2015-01-06 12:50 ` [PATCH 2/2 resend v2] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform Andreas Herrmann 2015-01-06 12:52 ` [PATCH 0/2 resend v2] USB: host: Misc patches to remove hard-coded octeon platform information Andreas Herrmann 2 siblings, 0 replies; 13+ messages in thread From: Andreas Herrmann @ 2015-01-06 12:48 UTC (permalink / raw) To: Greg KH Cc: Alan Stern, David Daney, Alex Smith, Linux-MIPS, linux-usb, Aaro Koskinen Instead rely on device tree information for ehci and ohci. This was suggested with http://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips&i=1401358203-60225-4-git-send-email-alex.smith%40imgtec.com "The device tree will *always* have correct ehci/ohci clock configuration, so use it. This allows us to remove a big chunk of platform configuration code from octeon-platform.c." More or less I rebased that patch on Alan's work to remove ehci-octeon and ohci-octeon drivers. Cc: David Daney <david.daney@cavium.com> Cc: Alex Smith <alex.smith@imgtec.com> Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Andreas Herrmann <andreas.herrmann@caviumnetworks.com> Acked-by: Ralf Baechle <ralf@linux-mips.org> Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi> --- arch/mips/cavium-octeon/octeon-platform.c | 148 ++++++++++++----------------- drivers/usb/host/ehci-platform.c | 1 + drivers/usb/host/ohci-platform.c | 1 + 3 files changed, 64 insertions(+), 86 deletions(-) diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c index b67ddf0..eea60b6 100644 --- a/arch/mips/cavium-octeon/octeon-platform.c +++ b/arch/mips/cavium-octeon/octeon-platform.c @@ -77,7 +77,7 @@ static DEFINE_MUTEX(octeon2_usb_clocks_mutex); static int octeon2_usb_clock_start_cnt; -static void octeon2_usb_clocks_start(void) +static void octeon2_usb_clocks_start(struct device *dev) { u64 div; union cvmx_uctlx_if_ena if_ena; @@ -86,6 +86,8 @@ static void octeon2_usb_clocks_start(void) union cvmx_uctlx_uphy_portx_ctl_status port_ctl_status; int i; unsigned long io_clk_64_to_ns; + u32 clock_rate = 12000000; + bool is_crystal_clock = false; mutex_lock(&octeon2_usb_clocks_mutex); @@ -96,6 +98,28 @@ static void octeon2_usb_clocks_start(void) io_clk_64_to_ns = 64000000000ull / octeon_get_io_clock_rate(); + if (dev->of_node) { + struct device_node *uctl_node; + const char *clock_type; + + uctl_node = of_get_parent(dev->of_node); + if (!uctl_node) { + dev_err(dev, "No UCTL device node\n"); + goto exit; + } + i = of_property_read_u32(uctl_node, + "refclk-frequency", &clock_rate); + if (i) { + dev_err(dev, "No UCTL \"refclk-frequency\"\n"); + goto exit; + } + i = of_property_read_string(uctl_node, + "refclk-type", &clock_type); + + if (!i && strcmp("crystal", clock_type) == 0) + is_crystal_clock = true; + } + /* * Step 1: Wait for voltages stable. That surely happened * before starting the kernel. @@ -126,9 +150,22 @@ static void octeon2_usb_clocks_start(void) cvmx_write_csr(CVMX_UCTLX_CLK_RST_CTL(0), clk_rst_ctl.u64); /* 3b */ - /* 12MHz crystal. */ - clk_rst_ctl.s.p_refclk_sel = 0; - clk_rst_ctl.s.p_refclk_div = 0; + clk_rst_ctl.s.p_refclk_sel = is_crystal_clock ? 0 : 1; + switch (clock_rate) { + default: + pr_err("Invalid UCTL clock rate of %u, using 12000000 instead\n", + clock_rate); + /* Fall through */ + case 12000000: + clk_rst_ctl.s.p_refclk_div = 0; + break; + case 24000000: + clk_rst_ctl.s.p_refclk_div = 1; + break; + case 48000000: + clk_rst_ctl.s.p_refclk_div = 2; + break; + } cvmx_write_csr(CVMX_UCTLX_CLK_RST_CTL(0), clk_rst_ctl.u64); /* 3c */ @@ -259,7 +296,7 @@ static void octeon2_usb_clocks_stop(void) static int octeon_ehci_power_on(struct platform_device *pdev) { - octeon2_usb_clocks_start(); + octeon2_usb_clocks_start(&pdev->dev); return 0; } @@ -277,11 +314,11 @@ static struct usb_ehci_pdata octeon_ehci_pdata = { .power_off = octeon_ehci_power_off, }; -static void __init octeon_ehci_hw_start(void) +static void __init octeon_ehci_hw_start(struct device *dev) { union cvmx_uctlx_ehci_ctl ehci_ctl; - octeon2_usb_clocks_start(); + octeon2_usb_clocks_start(dev); ehci_ctl.u64 = cvmx_read_csr(CVMX_UCTLX_EHCI_CTL(0)); /* Use 64-bit addressing. */ @@ -299,59 +336,28 @@ static u64 octeon_ehci_dma_mask = DMA_BIT_MASK(64); static int __init octeon_ehci_device_init(void) { struct platform_device *pd; + struct device_node *ehci_node; int ret = 0; - struct resource usb_resources[] = { - { - .flags = IORESOURCE_MEM, - }, { - .flags = IORESOURCE_IRQ, - } - }; - - /* Only Octeon2 has ehci/ohci */ - if (!OCTEON_IS_MODEL(OCTEON_CN63XX)) + ehci_node = of_find_node_by_name(NULL, "ehci"); + if (!ehci_node) return 0; - if (octeon_is_simulation() || usb_disabled()) - return 0; /* No USB in the simulator. */ - - pd = platform_device_alloc("ehci-platform", 0); - if (!pd) { - ret = -ENOMEM; - goto out; - } - - usb_resources[0].start = 0x00016F0000000000ULL; - usb_resources[0].end = usb_resources[0].start + 0x100; - - usb_resources[1].start = OCTEON_IRQ_USB0; - usb_resources[1].end = OCTEON_IRQ_USB0; - - ret = platform_device_add_resources(pd, usb_resources, - ARRAY_SIZE(usb_resources)); - if (ret) - goto fail; + pd = of_find_device_by_node(ehci_node); + if (!pd) + return 0; pd->dev.dma_mask = &octeon_ehci_dma_mask; pd->dev.platform_data = &octeon_ehci_pdata; - octeon_ehci_hw_start(); - - ret = platform_device_add(pd); - if (ret) - goto fail; + octeon_ehci_hw_start(&pd->dev); return ret; -fail: - platform_device_put(pd); -out: - return ret; } device_initcall(octeon_ehci_device_init); static int octeon_ohci_power_on(struct platform_device *pdev) { - octeon2_usb_clocks_start(); + octeon2_usb_clocks_start(&pdev->dev); return 0; } @@ -369,11 +375,11 @@ static struct usb_ohci_pdata octeon_ohci_pdata = { .power_off = octeon_ohci_power_off, }; -static void __init octeon_ohci_hw_start(void) +static void __init octeon_ohci_hw_start(struct device *dev) { union cvmx_uctlx_ohci_ctl ohci_ctl; - octeon2_usb_clocks_start(); + octeon2_usb_clocks_start(dev); ohci_ctl.u64 = cvmx_read_csr(CVMX_UCTLX_OHCI_CTL(0)); ohci_ctl.s.l2c_addr_msb = 0; @@ -387,57 +393,27 @@ static void __init octeon_ohci_hw_start(void) static int __init octeon_ohci_device_init(void) { struct platform_device *pd; + struct device_node *ohci_node; int ret = 0; - struct resource usb_resources[] = { - { - .flags = IORESOURCE_MEM, - }, { - .flags = IORESOURCE_IRQ, - } - }; - - /* Only Octeon2 has ehci/ohci */ - if (!OCTEON_IS_MODEL(OCTEON_CN63XX)) + ohci_node = of_find_node_by_name(NULL, "ohci"); + if (!ohci_node) return 0; - if (octeon_is_simulation() || usb_disabled()) - return 0; /* No USB in the simulator. */ - - pd = platform_device_alloc("ohci-platform", 0); - if (!pd) { - ret = -ENOMEM; - goto out; - } - - usb_resources[0].start = 0x00016F0000000400ULL; - usb_resources[0].end = usb_resources[0].start + 0x100; - - usb_resources[1].start = OCTEON_IRQ_USB0; - usb_resources[1].end = OCTEON_IRQ_USB0; - - ret = platform_device_add_resources(pd, usb_resources, - ARRAY_SIZE(usb_resources)); - if (ret) - goto fail; + pd = of_find_device_by_node(ohci_node); + if (!pd) + return 0; pd->dev.platform_data = &octeon_ohci_pdata; - octeon_ohci_hw_start(); - - ret = platform_device_add(pd); - if (ret) - goto fail; + octeon_ohci_hw_start(&pd->dev); return ret; -fail: - platform_device_put(pd); -out: - return ret; } device_initcall(octeon_ohci_device_init); #endif /* CONFIG_USB */ + static struct of_device_id __initdata octeon_ids[] = { { .compatible = "simple-bus", }, { .compatible = "cavium,octeon-6335-uctl", }, diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index 8557803..29b244c 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -349,6 +349,7 @@ static const struct of_device_id vt8500_ehci_ids[] = { { .compatible = "via,vt8500-ehci", }, { .compatible = "wm,prizm-ehci", }, { .compatible = "generic-ehci", }, + { .compatible = "cavium,octeon-6335-ehci", }, {} }; MODULE_DEVICE_TABLE(of, vt8500_ehci_ids); diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c index b81d202..9c06b01 100644 --- a/drivers/usb/host/ohci-platform.c +++ b/drivers/usb/host/ohci-platform.c @@ -328,6 +328,7 @@ static int ohci_platform_resume(struct device *dev) static const struct of_device_id ohci_platform_ids[] = { { .compatible = "generic-ohci", }, + { .compatible = "cavium,octeon-6335-ohci", }, { } }; MODULE_DEVICE_TABLE(of, ohci_platform_ids); -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/2 resend v2] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform 2015-01-06 12:46 ` [PATCH 0/2 resend v2] " Andreas Herrmann 2015-01-06 12:48 ` [PATCH 1/2 resend v2] USB: host: Remove hard-coded octeon platform information for ehci/ohci Andreas Herrmann @ 2015-01-06 12:50 ` Andreas Herrmann 2015-01-06 15:49 ` Alan Stern 2015-01-09 20:30 ` Greg KH 2015-01-06 12:52 ` [PATCH 0/2 resend v2] USB: host: Misc patches to remove hard-coded octeon platform information Andreas Herrmann 2 siblings, 2 replies; 13+ messages in thread From: Andreas Herrmann @ 2015-01-06 12:50 UTC (permalink / raw) To: Greg KH Cc: Alan Stern, David Daney, Alex Smith, Linux-MIPS, linux-usb, Aaro Koskinen ehci-octeon driver used a 64-bit dma_mask. With removal of ehci-octeon and usage of ehci-platform ehci dma_mask is now limited to 32 bits (coerced in ehci_platform_probe). Provide a flag in ehci platform data to allow use of 64 bits for dma_mask. Cc: David Daney <david.daney@cavium.com> Cc: Alex Smith <alex.smith@imgtec.com> Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Andreas Herrmann <andreas.herrmann@caviumnetworks.com> Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi> --- arch/mips/cavium-octeon/octeon-platform.c | 4 +--- drivers/usb/host/ehci-platform.c | 3 ++- include/linux/usb/ehci_pdriver.h | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c index eea60b6..12410a2 100644 --- a/arch/mips/cavium-octeon/octeon-platform.c +++ b/arch/mips/cavium-octeon/octeon-platform.c @@ -310,6 +310,7 @@ static struct usb_ehci_pdata octeon_ehci_pdata = { #ifdef __BIG_ENDIAN .big_endian_mmio = 1, #endif + .dma_mask_64 = 1, .power_on = octeon_ehci_power_on, .power_off = octeon_ehci_power_off, }; @@ -331,8 +332,6 @@ static void __init octeon_ehci_hw_start(struct device *dev) octeon2_usb_clocks_stop(); } -static u64 octeon_ehci_dma_mask = DMA_BIT_MASK(64); - static int __init octeon_ehci_device_init(void) { struct platform_device *pd; @@ -347,7 +346,6 @@ static int __init octeon_ehci_device_init(void) if (!pd) return 0; - pd->dev.dma_mask = &octeon_ehci_dma_mask; pd->dev.platform_data = &octeon_ehci_pdata; octeon_ehci_hw_start(&pd->dev); diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index 29b244c..75631b9 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -155,7 +155,8 @@ static int ehci_platform_probe(struct platform_device *dev) if (!pdata) pdata = &ehci_platform_defaults; - err = dma_coerce_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32)); + err = dma_coerce_mask_and_coherent(&dev->dev, + pdata->dma_mask_64 ? DMA_BIT_MASK(64) : DMA_BIT_MASK(32)); if (err) return err; diff --git a/include/linux/usb/ehci_pdriver.h b/include/linux/usb/ehci_pdriver.h index 7eb4dcd..f69529e 100644 --- a/include/linux/usb/ehci_pdriver.h +++ b/include/linux/usb/ehci_pdriver.h @@ -45,6 +45,7 @@ struct usb_ehci_pdata { unsigned big_endian_desc:1; unsigned big_endian_mmio:1; unsigned no_io_watchdog:1; + unsigned dma_mask_64:1; /* Turn on all power and clocks */ int (*power_on)(struct platform_device *pdev); -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2 resend v2] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform 2015-01-06 12:50 ` [PATCH 2/2 resend v2] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform Andreas Herrmann @ 2015-01-06 15:49 ` Alan Stern 2015-01-07 11:12 ` Andreas Herrmann 2015-01-09 20:30 ` Greg KH 1 sibling, 1 reply; 13+ messages in thread From: Alan Stern @ 2015-01-06 15:49 UTC (permalink / raw) To: Andreas Herrmann Cc: Greg KH, David Daney, Alex Smith, Linux-MIPS, linux-usb, Aaro Koskinen On Tue, 6 Jan 2015, Andreas Herrmann wrote: > ehci-octeon driver used a 64-bit dma_mask. With removal of ehci-octeon > and usage of ehci-platform ehci dma_mask is now limited to 32 bits > (coerced in ehci_platform_probe). > > Provide a flag in ehci platform data to allow use of 64 bits for > dma_mask. > > Cc: David Daney <david.daney@cavium.com> > Cc: Alex Smith <alex.smith@imgtec.com> > Cc: Alan Stern <stern@rowland.harvard.edu> > Signed-off-by: Andreas Herrmann <andreas.herrmann@caviumnetworks.com> > Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi> Acked-by: Alan Stern <stern@rowland.harvard.edu> Is something like this also needed for ohci-platform? Or are all OHCI implementations restricted to 32-bit DMA masks? Alan Stern ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2 resend v2] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform 2015-01-06 15:49 ` Alan Stern @ 2015-01-07 11:12 ` Andreas Herrmann 0 siblings, 0 replies; 13+ messages in thread From: Andreas Herrmann @ 2015-01-07 11:12 UTC (permalink / raw) To: Alan Stern Cc: Greg KH, David Daney, Alex Smith, Linux-MIPS, linux-usb, Aaro Koskinen On Tue, Jan 06, 2015 at 10:49:40AM -0500, Alan Stern wrote: > On Tue, 6 Jan 2015, Andreas Herrmann wrote: > > > ehci-octeon driver used a 64-bit dma_mask. With removal of ehci-octeon > > and usage of ehci-platform ehci dma_mask is now limited to 32 bits > > (coerced in ehci_platform_probe). > > > > Provide a flag in ehci platform data to allow use of 64 bits for > > dma_mask. > > > > Cc: David Daney <david.daney@cavium.com> > > Cc: Alex Smith <alex.smith@imgtec.com> > > Cc: Alan Stern <stern@rowland.harvard.edu> > > Signed-off-by: Andreas Herrmann <andreas.herrmann@caviumnetworks.com> > > Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi> > > Acked-by: Alan Stern <stern@rowland.harvard.edu> > > Is something like this also needed for ohci-platform? No, I don't think so. > Or are all OHCI implementations restricted to 32-bit DMA masks? AFAIK OHCI supports only 32-bit memory addressing. > Alan Stern Andreas ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2 resend v2] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform 2015-01-06 12:50 ` [PATCH 2/2 resend v2] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform Andreas Herrmann 2015-01-06 15:49 ` Alan Stern @ 2015-01-09 20:30 ` Greg KH 2015-01-12 15:05 ` [PATCH resend v3] " Andreas Herrmann 1 sibling, 1 reply; 13+ messages in thread From: Greg KH @ 2015-01-09 20:30 UTC (permalink / raw) To: Andreas Herrmann Cc: Alan Stern, David Daney, Alex Smith, Linux-MIPS, linux-usb, Aaro Koskinen On Tue, Jan 06, 2015 at 01:50:15PM +0100, Andreas Herrmann wrote: > ehci-octeon driver used a 64-bit dma_mask. With removal of ehci-octeon > and usage of ehci-platform ehci dma_mask is now limited to 32 bits > (coerced in ehci_platform_probe). > > Provide a flag in ehci platform data to allow use of 64 bits for > dma_mask. > > Cc: David Daney <david.daney@cavium.com> > Cc: Alex Smith <alex.smith@imgtec.com> > Signed-off-by: Andreas Herrmann <andreas.herrmann@caviumnetworks.com> > Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi> > Acked-by: Alan Stern <stern@rowland.harvard.edu> > --- > arch/mips/cavium-octeon/octeon-platform.c | 4 +--- > drivers/usb/host/ehci-platform.c | 3 ++- > include/linux/usb/ehci_pdriver.h | 1 + > 3 files changed, 4 insertions(+), 4 deletions(-) This no longer applies to my usb-testing branch, can you refresh it and resend? thanks, greg k-h ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH resend v3] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform 2015-01-09 20:30 ` Greg KH @ 2015-01-12 15:05 ` Andreas Herrmann 0 siblings, 0 replies; 13+ messages in thread From: Andreas Herrmann @ 2015-01-12 15:05 UTC (permalink / raw) To: Greg KH Cc: Alan Stern, David Daney, Alex Smith, Linux-MIPS, linux-usb, Aaro Koskinen ehci-octeon driver used a 64-bit dma_mask. With removal of ehci-octeon and usage of ehci-platform ehci dma_mask is now limited to 32 bits (coerced in ehci_platform_probe). Provide a flag in ehci platform data to allow use of 64 bits for dma_mask. Cc: David Daney <david.daney@cavium.com> Cc: Alex Smith <alex.smith@imgtec.com> Signed-off-by: Andreas Herrmann <andreas.herrmann@caviumnetworks.com> Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi> Acked-by: Alan Stern <stern@rowland.harvard.edu> --- arch/mips/cavium-octeon/octeon-platform.c | 4 +--- drivers/usb/host/ehci-platform.c | 3 ++- include/linux/usb/ehci_pdriver.h | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) Patch rebased on usb-testing as of v3.19-rc2-21-g1d97869. Thanks, Andreas diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c index eea60b6..12410a2 100644 --- a/arch/mips/cavium-octeon/octeon-platform.c +++ b/arch/mips/cavium-octeon/octeon-platform.c @@ -310,6 +310,7 @@ static struct usb_ehci_pdata octeon_ehci_pdata = { #ifdef __BIG_ENDIAN .big_endian_mmio = 1, #endif + .dma_mask_64 = 1, .power_on = octeon_ehci_power_on, .power_off = octeon_ehci_power_off, }; @@ -331,8 +332,6 @@ static void __init octeon_ehci_hw_start(struct device *dev) octeon2_usb_clocks_stop(); } -static u64 octeon_ehci_dma_mask = DMA_BIT_MASK(64); - static int __init octeon_ehci_device_init(void) { struct platform_device *pd; @@ -347,7 +346,6 @@ static int __init octeon_ehci_device_init(void) if (!pd) return 0; - pd->dev.dma_mask = &octeon_ehci_dma_mask; pd->dev.platform_data = &octeon_ehci_pdata; octeon_ehci_hw_start(&pd->dev); diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index 28aae64..63f2622 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -155,7 +155,8 @@ static int ehci_platform_probe(struct platform_device *dev) if (!pdata) pdata = &ehci_platform_defaults; - err = dma_coerce_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32)); + err = dma_coerce_mask_and_coherent(&dev->dev, + pdata->dma_mask_64 ? DMA_BIT_MASK(64) : DMA_BIT_MASK(32)); if (err) return err; diff --git a/include/linux/usb/ehci_pdriver.h b/include/linux/usb/ehci_pdriver.h index 6287b39..db0431b 100644 --- a/include/linux/usb/ehci_pdriver.h +++ b/include/linux/usb/ehci_pdriver.h @@ -48,6 +48,7 @@ struct usb_ehci_pdata { unsigned big_endian_mmio:1; unsigned no_io_watchdog:1; unsigned reset_on_resume:1; + unsigned dma_mask_64:1; /* Turn on all power and clocks */ int (*power_on)(struct platform_device *pdev); -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 0/2 resend v2] USB: host: Misc patches to remove hard-coded octeon platform information 2015-01-06 12:46 ` [PATCH 0/2 resend v2] " Andreas Herrmann 2015-01-06 12:48 ` [PATCH 1/2 resend v2] USB: host: Remove hard-coded octeon platform information for ehci/ohci Andreas Herrmann 2015-01-06 12:50 ` [PATCH 2/2 resend v2] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform Andreas Herrmann @ 2015-01-06 12:52 ` Andreas Herrmann 2 siblings, 0 replies; 13+ messages in thread From: Andreas Herrmann @ 2015-01-06 12:52 UTC (permalink / raw) To: Greg KH Cc: Alan Stern, David Daney, Alex Smith, Linux-MIPS, linux-usb, Aaro Koskinen On Tue, Jan 06, 2015 at 01:46:44PM +0100, Andreas Herrmann wrote: > This is a re-submission of patches 2 and 3 from > http://marc.info/?i=1415914590-31647-1-git-send-email-andreas.herrmann@caviumnetworks.com > (Only patch 1/3 made it into usb-next and meanwhile is in mainline.) > > Please apply. > > > Thanks, > > Andreas > > PS: It's v2 as with last submission I hit the merge window. > Patches are rebased to v3.19-rc2. > Only change is usage of a permanent link for the mail referenced > in commit message of patch 2/2. In fact I meant commit message of patch 1 of 2. Andreas ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2015-01-12 15:06 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-12-15 13:26 [PATCH 0/2 resend] USB: host: Misc patches to remove hard-coded octeon platform information Andreas Herrmann 2014-12-15 13:28 ` [PATCH 1/2 resend] USB: host: Remove hard-coded octeon platform information for ehci/ohci Andreas Herrmann 2014-12-15 16:04 ` Ralf Baechle 2014-12-15 13:30 ` [PATCH 2/2 resend] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform Andreas Herrmann 2014-12-15 16:36 ` [PATCH 0/2 resend] USB: host: Misc patches to remove hard-coded octeon platform information Greg KH 2015-01-06 12:46 ` [PATCH 0/2 resend v2] " Andreas Herrmann 2015-01-06 12:48 ` [PATCH 1/2 resend v2] USB: host: Remove hard-coded octeon platform information for ehci/ohci Andreas Herrmann 2015-01-06 12:50 ` [PATCH 2/2 resend v2] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform Andreas Herrmann 2015-01-06 15:49 ` Alan Stern 2015-01-07 11:12 ` Andreas Herrmann 2015-01-09 20:30 ` Greg KH 2015-01-12 15:05 ` [PATCH resend v3] " Andreas Herrmann 2015-01-06 12:52 ` [PATCH 0/2 resend v2] USB: host: Misc patches to remove hard-coded octeon platform information Andreas Herrmann
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox