ehci-hcd.c: make it works on big-endian mips (AR9331)
Subsystems (3)
cover ehci-hcd.c: make it works on big-endian mips (AR9331)
This patchseries is very preliminary and has several issues:
* USBMODE_BE bit set does not work on AR9331
see the 'usb: ehci: add big-endian registers support' patch
* tested on USB-flash; I have to test E100 USB Ethernet too;
* the 'usb: ehci-hcd: add OF bindings' patch is not taken into account;
see http://lists.infradead.org/pipermail/barebox/2015-August/024545.html
Antony Pavlov (9):
WIP: make ehci-hcd.c happy on big-endian MIPS
WIP: fix drivers/usb/core/usb.c
MIPS: add virt_to_phys() and phys_to_virt()
MIPS: add trivial dma support
ehci-hcd.c: make it works on mips
usb: ehci: drop unusable CONFIG_EHCI_MMIO_BIG_ENDIAN condition
usb: ehci: add big-endian registers support
MIPS: tplink-mr3020: select big-endian EHCI support
MIPS: tplink-mr3020_defconfig: enable usb stuff
arch/mips/Kconfig | 1 + arch/mips/boards/tplink-mr3020/board.c | 55 +++++++++++ arch/mips/configs/tplink-mr3020_defconfig | 49 ++++++---- arch/mips/include/asm/dma-mapping.h | 1 + arch/mips/include/asm/dma.h | 5 + arch/mips/include/asm/io.h | 35 +++++++ arch/mips/lib/Makefile | 1 + arch/mips/lib/dma-default.c | 28 ++++++ arch/mips/mach-ath79/Kconfig | 4 + drivers/usb/core/usb.c | 2 +- drivers/usb/host/Kconfig | 3 + drivers/usb/host/ehci-hcd.c | 153 +++++++++++++++--------------- drivers/usb/host/ehci.h | 55 ++++++++--- include/linux/byteorder/big_endian.h | 2 +- include/usb/ehci.h | 1 + 15 files changed, 286 insertions(+), 109 deletions(-) create mode 100644 arch/mips/lib/dma-default.c
Signature · 7 lines
2.5.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 1/9 WIP: make ehci-hcd.c happy on big-endian MIPS
import __constant_cpu_to_le16() from linux.git/include/uapi/linux/byteorder/big_endian.h
--- include/linux/byteorder/big_endian.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/byteorder/big_endian.h +1 -1
@@ -19,7 +19,7 @@#define __constant_le64_to_cpu (x) ___swab64((x))#define __constant_cpu_to_le32 (x) ___swab32((x))#define __constant_le32_to_cpu (x) ___swab32((x)) -#define __constant_cpu_to_le16 (x) ___swab16((x)) +#define __constant_cpu_to_le16 (x) ((__force __le16)___constant_swab16((x)))#define __constant_le16_to_cpu (x) ___swab16((x))#define __constant_cpu_to_be64 (x) ((__u64)(x))#define __constant_be64_to_cpu (x) ((__u64)(x))
Signature · 7 lines
2.5.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 2/9 WIP: fix drivers/usb/core/usb.c
In reply to Antony Pavlovdrivers/usb/core/usb.c: In function 'usb_parse_config':drivers/usb/core/usb.c:194:28: error: 'struct usb_configuration' has no member named 'wTotalLength'
le16_to_cpus(&(dev->config.wTotalLength));
^...scripts/Makefile.build:249: recipe for target 'drivers/usb/core/usb.o' failed
make[3]: *** [drivers/usb/core/usb.o] Error 1 scripts/Makefile.build:387: recipe for target 'drivers/usb/core' failed make[2]: *** [drivers/usb/core] Error 2 scripts/Makefile.build:387: recipe for target 'drivers/usb' failed make[1]: *** [drivers/usb] Error 2
Makefile:770: recipe for target 'drivers' failed
make: *** [drivers] Error 2
see also
commit 245069bcef15ecc19db616a967501349b76c84d0
Author: Sascha Hauer <[email protected]> Date: Thu Jul 10 11:36:12 2014 +0200
USB: introduce usb_interface/usb_configuration structs
Currently we have two conflicting definitions of structusb_config_descriptor
and struct usb_interface_descriptor in the tree. This is because the
USB code
uses additional fields in the structs for internal housekeeping. Add struct usb_interface and struct struct usb_configuration with the
housekeeping
data and embed the corresponding hardware structs into them. This
frees the
way to use the definitions from ch9.h in the next step.
--- drivers/usb/core/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/core/usb.c +1 -1
@@ -191,7 +191,7 @@ static int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int creturn -1 ; }memcpy (&dev->config, buffer, buffer[0 ]); -le16_to_cpus (&(dev->config.wTotalLength)); +le16_to_cpus (&(dev->config.desc.wTotalLength)); dev->config.no_of_if =0 ; index = dev->config.desc.bLength;
Signature · 7 lines
2.5.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 2/9] WIP: fix drivers/usb/core/usb.c
Quoted 45 lines · Antony Pavlov
drivers/usb/core/usb.c: In function 'usb_parse_config':drivers/usb/core/usb.c:194:28: error: 'structusb_configuration' has no member named 'wTotalLength'le16_to_cpus(&(dev->config.wTotalLength)); ^...
scripts/Makefile.build:249: recipe for target 'drivers/usb/core/usb.o' failed
make[3]: *** [drivers/usb/core/usb.o] Error 1scripts/Makefile.build:387: recipe for target 'drivers/usb/core' failed make[2]: *** [drivers/usb/core] Error 2scripts/Makefile.build:387: recipe for target 'drivers/usb' failed make[1]: *** [drivers/usb] Error 2
Makefile:770: recipe for target 'drivers' failed
make: *** [drivers] Error 2see also
commit
245069bcef15ecc19db616a967501349b76c84d0Author: Sascha Hauer <[email protected]> Date: Thu Jul 10 11:36:12 2014 +0200USB: introduce usb_interface/usb_configuration structs
Currently we have two conflicting definitions of struct
usb_config_descriptor
and structusb_interface_descriptorin the tree. This is because the
USB code
uses additional fields in the structs for internal housekeeping. Add structusb_interfaceand struct structusb_configurationwith the
housekeeping
data and embed the corresponding hardware structs into them. This
frees the
way to use the definitions fromch9.hin the next step.Signed-off-by Antony Pavlov <[email protected]>--- drivers/usb/core/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/core/usb.c +0
-0
drivers/usb/core/usb.c static int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int c · line 195
Quoted 6 lines
drivers/usb/core/usb.c +1
-1@@ -191,7 +191,7 @@ static int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int creturn -1 ; }memcpy (&dev->config, buffer, buffer[0 ]); -le16_to_cpus (&(dev->config.wTotalLength)); +le16_to_cpus (&(dev->config.desc.wTotalLength)); dev->config.no_of_if =0 ;
What's WIP in this patch? It looks 100% correct.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 2/9] WIP: fix drivers/usb/core/usb.c
Quoted 41 lines · On Fri, 28 Aug 2015 08:11:59 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 40 lines · Antony Pavlov
drivers/usb/core/usb.c: In function 'usb_parse_config':drivers/usb/core/usb.c:194:28: error: 'structusb_configuration' has no member named 'wTotalLength'le16_to_cpus(&(dev->config.wTotalLength)); ^...
scripts/Makefile.build:249: recipe for target 'drivers/usb/core/usb.o' failed
make[3]: *** [drivers/usb/core/usb.o] Error 1scripts/Makefile.build:387: recipe for target 'drivers/usb/core' failed make[2]: *** [drivers/usb/core] Error 2scripts/Makefile.build:387: recipe for target 'drivers/usb' failed make[1]: *** [drivers/usb] Error 2
Makefile:770: recipe for target 'drivers' failed
make: *** [drivers] Error 2see also
commit
245069bcef15ecc19db616a967501349b76c84d0Author: Sascha Hauer <[email protected]> Date: Thu Jul 10 11:36:12 2014 +0200USB: introduce usb_interface/usb_configuration structs
Currently we have two conflicting definitions of struct
usb_config_descriptor
and structusb_interface_descriptorin the tree. This is because the
USB code
uses additional fields in the structs for internal housekeeping. Add structusb_interfaceand struct structusb_configurationwith the
housekeeping
data and embed the corresponding hardware structs into them. This
frees the
way to use the definitions fromch9.hin the next step.Signed-off-by Antony Pavlov <[email protected]>--- drivers/usb/core/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines
drivers/usb/core/usb.c static int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int c · line 195
Quoted 11 lines
drivers/usb/core/usb.c +1
-1@@ -191,7 +191,7 @@ static int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int creturn -1 ; }memcpy (&dev->config, buffer, buffer[0 ]); -le16_to_cpus (&(dev->config.wTotalLength)); +le16_to_cpus (&(dev->config.desc.wTotalLength)); dev->config.no_of_if =0 ;What's WIP in this patch? It looks 100% correct.
WIP means that I don't understand why nobody but me detected this build problem. Have you any idea?
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 2/9] WIP: fix drivers/usb/core/usb.c
Quoted 59 lines · Antony Pavlov
Quoted 41 lines · On Fri, 28 Aug 2015 08:11:59 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 40 lines · Antony Pavlov
drivers/usb/core/usb.c: In function 'usb_parse_config':drivers/usb/core/usb.c:194:28: error: 'structusb_configuration' has no member named 'wTotalLength'le16_to_cpus(&(dev->config.wTotalLength)); ^...
scripts/Makefile.build:249: recipe for target 'drivers/usb/core/usb.o' failed
make[3]: *** [drivers/usb/core/usb.o] Error 1scripts/Makefile.build:387: recipe for target 'drivers/usb/core' failed make[2]: *** [drivers/usb/core] Error 2scripts/Makefile.build:387: recipe for target 'drivers/usb' failed make[1]: *** [drivers/usb] Error 2
Makefile:770: recipe for target 'drivers' failed
make: *** [drivers] Error 2see also
commit
245069bcef15ecc19db616a967501349b76c84d0Author: Sascha Hauer <[email protected]> Date: Thu Jul 10 11:36:12 2014 +0200USB: introduce usb_interface/usb_configuration structs
Currently we have two conflicting definitions of struct
usb_config_descriptor
and structusb_interface_descriptorin the tree. This is because the
USB code
uses additional fields in the structs for internal housekeeping. Add structusb_interfaceand struct structusb_configurationwith the
housekeeping
data and embed the corresponding hardware structs into them. This
frees the
way to use the definitions fromch9.hin the next step.Signed-off-by Antony Pavlov <[email protected]>--- drivers/usb/core/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 14 lines
drivers/usb/core/usb.c static int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int c · line 195
Quoted 11 lines
drivers/usb/core/usb.c +1
-1@@ -191,7 +191,7 @@ static int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int creturn -1 ; }memcpy (&dev->config, buffer, buffer[0 ]); -le16_to_cpus (&(dev->config.wTotalLength)); +le16_to_cpus (&(dev->config.desc.wTotalLength)); dev->config.no_of_if =0 ;What's WIP in this patch? It looks 100% correct.
Quoted 2 lines
WIP means that I don't understand why nobody but me detected this build problem. Have you any idea?
Yeah, I wondered about this aswell at first, but it's quite easy if you look at it. le16_to_cpus converts the content of a pointer to le16 to cpu endianess. On little endian systems like ARM this is a no op, defined as:
#define le16_to_cpus __le16_to_cpus
#define __le16_to_cpus(x) do {} while (0)
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 3/9 MIPS: add virt_to_phys() and phys_to_virt()
In reply to Antony PavlovN.B. phys_to_virt() translates phys address
to KSEG1 (uncached) address as barebox mips
has no cache support.
--- arch/mips/include/asm/io.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
arch/mips/include/asm/io.h +35 -0
@@ -12,8 +12,43 @@#include <linux/compiler.h> #include <asm/types.h> +#include <asm/addrspace.h> #include <asm/byteorder.h> +/* +* virt_to_phys - map virtual addresses to physical +* @address: address to remap +* +* The returned physical address is the physical (CPU) mapping for +* the memory address given. It is only valid to use this function on +* addresses directly mapped or allocated via kmalloc. +* +* This function does not give bus mappings for DMA transfers. In +* almost all conceivable cases a device driver should not be using +* this function +*/ +static inline unsigned long virt_to_phys (const void *address) +{ +return (unsigned long )address &0x3fffffff ; +} + +/* +* phys_to_virt - map physical address to virtual +* @address: address to remap +* +* The returned virtual address is a current CPU mapping for +* the memory address given. It is only valid to use this function on +* addresses that have a kernel mapping +* +* This function does not handle bus mappings for DMA transfers. In +* almost all conceivable cases a device driver should not be using +* this function +*/ +static inline void *phys_to_virt (unsigned long address) +{ +return (void *)(KSEG1 | (address &0x3fffffff )); +} +#define IO_SPACE_LIMIT 0/*****************************************************************************/
Signature · 7 lines
2.5.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 3/9] MIPS: add virt_to_phys() and phys_to_virt()
Quoted 3 lines · Antony Pavlov
N.B.
phys_to_virt()translates phys address
to KSEG1 (uncached) address as barebox mips
has no cache support.
What would it take to implement cache support for mips? The u-boot mips cache code seems quite straight forward. With cache support you could use several drivers as they are and wouldn't have to introduce physical/virtual translations. I'm afraid these translations will be broken quite soon as they get tested only on Mips.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 3/9] MIPS: add virt_to_phys() and phys_to_virt()
Quoted 6 lines · On Fri, 28 Aug 2015 08:34:32 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 3 lines · Antony Pavlov
N.B.
phys_to_virt()translates phys address
to KSEG1 (uncached) address as barebox mips
has no cache support.What would it take to implement cache support for mips?
lack of the cache support is critical problem for current barebox mips support. I'm planning to add cache support in several weeks.
This task needs much test efforts for different boards.
Anyway I can't carry out cache adding work at one.
But adding virt_to_phys and DMA support will help to add cache support one day anyway.
Quoted 2 lines
The u-boot mips
cache code seems quite straight forward.
AFAIR u-boot has only mips L1 cache support.
AFAIK Paul Burton works on adding L2 cache support but current mainline u-boot repo has no such code.
Quoted 4 lines
With cache support you could
use several drivers as they are and wouldn't have to introduce physical/virtual translations. I'm afraid these translations will be broken quite soon as they get tested only on Mips.
I hope somebody will test my EHCI patch on ARM :)
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 3/9] MIPS: add virt_to_phys() and phys_to_virt()
Quoted 8 lines · Antony Pavlov
Quoted 5 lines · On Fri, 28 Aug 2015 08:34:32 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 3 lines · Antony Pavlov
N.B.
phys_to_virt()translates phys address
to KSEG1 (uncached) address as barebox mips
has no cache support.
Quoted 7 lines
Quoted 1 line
What would it take to implement cache support for mips?
lack of the cache support is critical problem for current barebox mips support. I'm planning to add cache support in several weeks.
This task needs much test efforts for different boards.Anyway I can't carry out cache adding work at one.
But addingvirt_to_physand DMA support will help to add cache support one day anyway.
Looking at this again the virt_to_phys/phys_to_virt macros are not necessary. dma_alloc_coherent() already returns both the virtual address and the DMA address. It should be possible to replace DMA_ADDRESS_BROKEN in the ehci driver with a real pointer and use it appropriatly in the driver.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 3/9] MIPS: add virt_to_phys() and phys_to_virt()
Quoted 14 lines · On Fri, 4 Sep 2015 08:20:48 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 13 lines · Antony Pavlov
Quoted 6 lines · On Fri, 28 Aug 2015 08:34:32 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 3 lines · Antony Pavlov
N.B.
phys_to_virt()translates phys address
to KSEG1 (uncached) address as barebox mips
has no cache support.What would it take to implement cache support for mips?
lack of the cache support is critical problem for current barebox mips support. I'm planning to add cache support in several weeks.
This task needs much test efforts for different boards.
Quoted 8 lines
Quoted 2 lines
Anyway I can't carry out cache adding work at one.
But addingvirt_to_physand DMA support will help to add cache support one day anyway.Looking at this again the virt_to_phys/phys_to_virt macros are not necessary.
dma_alloc_coherent()already returns both the virtual address and the DMA address. It should be possible to replaceDMA_ADDRESS_BROKENin the ehci driver with a real pointer and use it appropriatly in the driver.
Here is a fragment of drivers/usb/host/ehci-hcd.c:
while (td != (void *)QT_NEXT_TERMINATE) {
qh->qt_next = td->qt_next;
td = (void *)hc32_to_cpu(qh->qt_next);
}qh->qt_next contains physical memory address for EHCI controller, so after 'td = (void *)hc32_to_cpu(qh->qt_next)' contains physical address.
But latter we can use 'td->qt_next'. If physical address != virtual address then we will fail. So we need addition phys_to_virt() call here.
Some addition workaround is needed here because phys_to_virt(QT_NEXT_TERMINATE) != QT_NEXT_TERMINATE.
Signature · 8 lines
-- Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 3/9] MIPS: add virt_to_phys() and phys_to_virt()
Quoted 34 lines · Antony Pavlov
Quoted 14 lines · On Fri, 4 Sep 2015 08:20:48 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 13 lines · Antony Pavlov
Quoted 6 lines · On Fri, 28 Aug 2015 08:34:32 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 3 lines · Antony Pavlov
N.B.
phys_to_virt()translates phys address
to KSEG1 (uncached) address as barebox mips
has no cache support.What would it take to implement cache support for mips?
lack of the cache support is critical problem for current barebox mips support. I'm planning to add cache support in several weeks.
This task needs much test efforts for different boards.Quoted 8 lines
Quoted 2 lines
Anyway I can't carry out cache adding work at one.
But addingvirt_to_physand DMA support will help to add cache support one day anyway.Looking at this again the virt_to_phys/phys_to_virt macros are not necessary.
dma_alloc_coherent()already returns both the virtual address and the DMA address. It should be possible to replaceDMA_ADDRESS_BROKENin the ehci driver with a real pointer and use it appropriatly in the driver.Here is a fragment of
drivers/usb/host/ehci-hcd.c:while (td != (void *)QT_NEXT_TERMINATE) { qh->qt_next = td->qt_next; td = (void *)hc32_to_cpu(qh->qt_next); }
Quoted 5 lines
qh->qt_nextcontains physical memory address for EHCI controller, so after 'td = (void *)hc32_to_cpu(qh->qt_next)' contains physical address.But latter we can use '
td->qt_next'. If physical address != virtual address then we will fail. So we need additionphys_to_virt()call here.
The problem with the ehci driver is that it uses qt_next pointers in the driver to iterate over the TDs. qt_next is meant for the ehci hardware, not for the software. What we need is an additional struct qTD *vqt_next field in both struct qTD and struct QH for software iteration over the list of TDs.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 3/9] MIPS: add virt_to_phys() and phys_to_virt()
In reply to Sascha HauerQuoted 14 lines · On Fri, 4 Sep 2015 08:20:48 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 13 lines · Antony Pavlov
Quoted 6 lines · On Fri, 28 Aug 2015 08:34:32 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 3 lines · Antony Pavlov
N.B.
phys_to_virt()translates phys address
to KSEG1 (uncached) address as barebox mips
has no cache support.What would it take to implement cache support for mips?
lack of the cache support is critical problem for current barebox mips support. I'm planning to add cache support in several weeks.
This task needs much test efforts for different boards.
Quoted 9 lines
Quoted 2 lines
Anyway I can't carry out cache adding work at one.
But addingvirt_to_physand DMA support will help to add cache support one day anyway.Looking at this again the virt_to_phys/phys_to_virt macros are not necessary.
dma_alloc_coherent()already returns both the virtual address and the DMA address. It should be possible to replaceDMA_ADDRESS_BROKENin the ehci driver with a real pointer and use it appropriatly in the driver.
I have tried to get physical address from dma_alloc_coherent(), here is a small part of my patch (just for demonstration):
drivers/usb/host/ehci-hcd.c +3 -2
@@ -41,6 +41,7 @@ struct ehci_priv {struct ehci_hcor *hcor;struct usb_host host;struct QH *qh_list; +dma_addr_t qh_list_dma;struct qTD *td;int portreset;unsigned long flags;
@@ -403,7 +410,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, goto fail; } - ehci->qh_list->qh_link =cpu_to_hc32 ((uint32_t )ehci->qh_list |QH_LINK_TYPE_QH ); + ehci->qh_list->qh_link =cpu_to_hc32 (ehci->qh_list_dma |QH_LINK_TYPE_QH ); token =hc32_to_cpu (qh->qt_token);if (!(token &0x80 )) {
@@ -1306,7 +1313,7 @@ int ehci_register(struct device_d *dev, struct ehci_data *data) ehci->post_init = data->post_init; ehci->qh_list =dma_alloc_coherent (sizeof (struct QH ) *NUM_TD , -DMA_ADDRESS_BROKEN ); + &ehci->qh_list_dma); ehci->periodic_queue =dma_alloc_coherent (sizeof (struct QH ),DMA_ADDRESS_BROKEN ); ehci->td = dma_alloc_coherent(sizeof(struct qTD) * NUM_TD,
However ehci_td_buffer() gets buf pointer outside of ehci driver (e.g. via usb_bulk_msg()), so it is difficult to avoid virt_to_phys() in ehci_td_buffer(), e.g.:
@@ -195,7 +197,7 @@ static int ehci_td_buffer(struct qTD *td, void *buf, size_t sz)
idx = 0;
while (idx < 5) {
- td->qt_buffer[idx] = cpu_to_hc32(addr);
+ td->qt_buffer[idx] = cpu_to_hc32(virt_to_phys(addr));
next = (addr + 4096) & ~4095;
delta = next - addr;
if (delta >= sz)Have you any idea?
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 3/9] MIPS: add virt_to_phys() and phys_to_virt()
Quoted 73 lines · Antony Pavlov
Quoted 14 lines · On Fri, 4 Sep 2015 08:20:48 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 13 lines · Antony Pavlov
Quoted 6 lines · On Fri, 28 Aug 2015 08:34:32 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 3 lines · Antony Pavlov
N.B.
phys_to_virt()translates phys address
to KSEG1 (uncached) address as barebox mips
has no cache support.What would it take to implement cache support for mips?
lack of the cache support is critical problem for current barebox mips support. I'm planning to add cache support in several weeks.
This task needs much test efforts for different boards.Quoted 9 lines
Quoted 2 lines
Anyway I can't carry out cache adding work at one.
But addingvirt_to_physand DMA support will help to add cache support one day anyway.Looking at this again the virt_to_phys/phys_to_virt macros are not necessary.
dma_alloc_coherent()already returns both the virtual address and the DMA address. It should be possible to replaceDMA_ADDRESS_BROKENin the ehci driver with a real pointer and use it appropriatly in the driver.I have tried to get physical address from
dma_alloc_coherent(), here is a small part of my patch (just for demonstration):drivers/usb/host/ehci-hcd.c +3
-2@@ -41,6 +41,7 @@ struct ehci_priv {struct ehci_hcor *hcor;struct usb_host host;struct QH *qh_list; +dma_addr_t qh_list_dma;struct qTD *td;int portreset;unsigned long flags;@@ -403,7 +410,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, goto fail; } - ehci->qh_list->qh_link =cpu_to_hc32 ((uint32_t )ehci->qh_list |QH_LINK_TYPE_QH ); + ehci->qh_list->qh_link =cpu_to_hc32 (ehci->qh_list_dma |QH_LINK_TYPE_QH ); token =hc32_to_cpu (qh->qt_token);if (!(token &0x80 )) {@@ -1306,7 +1313,7 @@ int ehci_register(struct device_d *dev, struct ehci_data *data) ehci->post_init = data->post_init; ehci->qh_list =dma_alloc_coherent (sizeof (struct QH ) *NUM_TD , -DMA_ADDRESS_BROKEN ); + &ehci->qh_list_dma); ehci->periodic_queue =dma_alloc_coherent (sizeof (struct QH ),DMA_ADDRESS_BROKEN ); ehci->td = dma_alloc_coherent(sizeof(struct qTD) * NUM_TD,However
ehci_td_buffer()gets buf pointer outside of ehci driver (e.g. viausb_bulk_msg()), so it is difficult to avoidvirt_to_phys()inehci_td_buffer(), e.g.:drivers/usb/host/ehci-hcd.c +1
-1@@ -195,7 +197,7 @@ static int ehci_td_buffer(struct qTD *td, void *buf, size_t sz) idx =0 ;while (idx <5 ) { - td->qt_buffer[idx] =cpu_to_hc32 (addr); + td->qt_buffer[idx] =cpu_to_hc32 (virt_to_phys (addr)); next = (addr +4096 ) & ~4095 ; delta = next - addr;if (delta >= sz)
Quoted 1 line
Have you any idea?
No. Translating this addres into a physical address seems unavoidable here. I would still prefer a real cache implementation for MIPS though. Have you looked further into that? The current MIPS cached/uncached memory windows seem to be a constant source of problems we could avoid.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 3/9] MIPS: add virt_to_phys() and phys_to_virt()
Quoted 74 lines · On Mon, 7 Dec 2015 11:27:44 +0100 Sascha Hauer <[email protected]> wrote:
Quoted 73 lines · Antony Pavlov
Quoted 14 lines · On Fri, 4 Sep 2015 08:20:48 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 13 lines · Antony Pavlov
Quoted 6 lines · On Fri, 28 Aug 2015 08:34:32 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 3 lines · Antony Pavlov
N.B.
phys_to_virt()translates phys address
to KSEG1 (uncached) address as barebox mips
has no cache support.What would it take to implement cache support for mips?
lack of the cache support is critical problem for current barebox mips support. I'm planning to add cache support in several weeks.
This task needs much test efforts for different boards.Quoted 9 lines
Quoted 2 lines
Anyway I can't carry out cache adding work at one.
But addingvirt_to_physand DMA support will help to add cache support one day anyway.Looking at this again the virt_to_phys/phys_to_virt macros are not necessary.
dma_alloc_coherent()already returns both the virtual address and the DMA address. It should be possible to replaceDMA_ADDRESS_BROKENin the ehci driver with a real pointer and use it appropriatly in the driver.I have tried to get physical address from
dma_alloc_coherent(), here is a small part of my patch (just for demonstration):drivers/usb/host/ehci-hcd.c +3
-2@@ -41,6 +41,7 @@ struct ehci_priv {struct ehci_hcor *hcor;struct usb_host host;struct QH *qh_list; +dma_addr_t qh_list_dma;struct qTD *td;int portreset;unsigned long flags;@@ -403,7 +410,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, goto fail; } - ehci->qh_list->qh_link =cpu_to_hc32 ((uint32_t )ehci->qh_list |QH_LINK_TYPE_QH ); + ehci->qh_list->qh_link =cpu_to_hc32 (ehci->qh_list_dma |QH_LINK_TYPE_QH ); token =hc32_to_cpu (qh->qt_token);if (!(token &0x80 )) {@@ -1306,7 +1313,7 @@ int ehci_register(struct device_d *dev, struct ehci_data *data) ehci->post_init = data->post_init; ehci->qh_list =dma_alloc_coherent (sizeof (struct QH ) *NUM_TD , -DMA_ADDRESS_BROKEN ); + &ehci->qh_list_dma); ehci->periodic_queue =dma_alloc_coherent (sizeof (struct QH ),DMA_ADDRESS_BROKEN ); ehci->td = dma_alloc_coherent(sizeof(struct qTD) * NUM_TD,However
ehci_td_buffer()gets buf pointer outside of ehci driver (e.g. viausb_bulk_msg()), so it is difficult to avoidvirt_to_phys()inehci_td_buffer(), e.g.:drivers/usb/host/ehci-hcd.c +1
-1@@ -195,7 +197,7 @@ static int ehci_td_buffer(struct qTD *td, void *buf, size_t sz) idx =0 ;while (idx <5 ) { - td->qt_buffer[idx] =cpu_to_hc32 (addr); + td->qt_buffer[idx] =cpu_to_hc32 (virt_to_phys (addr)); next = (addr +4096 ) & ~4095 ; delta = next - addr;if (delta >= sz)
Quoted 6 lines
Quoted 1 line
Have you any idea?
No. Translating this addres into a physical address seems unavoidable here. I would still prefer a real cache implementation for MIPS though. Have you looked further into that? The current MIPS cached/uncached memory windows seem to be a constant source of problems we could avoid.
We already have Atheros AR9331 branch with cache support.
I assume that cleaned MIPS cache support patch series will be ready till Christmas.
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 3/9] MIPS: add virt_to_phys() and phys_to_virt()
In reply to Sascha HauerQuoted 79 lines · On Mon, 7 Dec 2015 11:27:44 +0100 Sascha Hauer <[email protected]> wrote:
Quoted 78 lines · Antony Pavlov
Quoted 19 lines · On Fri, 4 Sep 2015 08:20:48 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 9 lines · Antony Pavlov
Quoted 6 lines · On Fri, 28 Aug 2015 08:34:32 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 3 lines · Antony Pavlov
N.B.
phys_to_virt()translates phys address
to KSEG1 (uncached) address as barebox mips
has no cache support.What would it take to implement cache support for mips?
Quoted 8 lines
lack of the cache support is critical problem for current barebox mips support. I'm planning to add cache support in several weeks. This task needs much test efforts for different boards.
Anyway I can't carry out cache adding work at one. But adding
virt_to_physand DMA support will help to add cache support one day anyway.Quoted 6 lines
Looking at this again the virt_to_phys/phys_to_virt macros are not necessary.
dma_alloc_coherent()already returns both the virtual address and the DMA address. It should be possible to replaceDMA_ADDRESS_BROKENin the ehci driver with a real pointer and use it appropriatly in the driver.I have tried to get physical address from
dma_alloc_coherent(), here is a small part of my patch (just for demonstration):drivers/usb/host/ehci-hcd.c +2
-1@@ -41,6 +41,7 @@ struct ehci_priv {struct ehci_hcor *hcor;struct usb_host host;struct QH *qh_list; +dma_addr_t qh_list_dma;struct qTD *td;int portreset;unsigned long flags;@@ -403,7 +410,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, goto fail; } - ehci->qh_list->qh_link =cpu_to_hc32 ((uint32_t )ehci->qh_list |QH_LINK_TYPE_QH ); + ehci->qh_list->qh_link =cpu_to_hc32 (ehci->qh_list_dma |QH_LINK_TYPE_QH ); token =hc32_to_cpu (qh->qt_token);drivers/usb/host/ehci-hcd.c +1
-1if (!(token &0x80 )) {@@ -1306,7 +1313,7 @@ int ehci_register(struct device_d *dev, struct ehci_data *data) ehci->post_init = data->post_init; ehci->qh_list =dma_alloc_coherent (sizeof (struct QH ) *NUM_TD , -DMA_ADDRESS_BROKEN ); + &ehci->qh_list_dma); ehci->periodic_queue =dma_alloc_coherent (sizeof (struct QH ),DMA_ADDRESS_BROKEN );
ehci->td= dma_alloc_coherent(sizeof(struct qTD) *NUM_TD,However
ehci_td_buffer()gets buf pointer outside of ehci driver (e.g. viausb_bulk_msg()), so it is difficult to avoidvirt_to_phys()inehci_td_buffer(), e.g.:drivers/usb/host/ehci-hcd.c +1
-1@@ -195,7 +197,7 @@ static int ehci_td_buffer(struct qTD *td, void *buf, size_t sz) idx =0 ;while (idx <5 ) { - td->qt_buffer[idx] =cpu_to_hc32 (addr); + td->qt_buffer[idx] =cpu_to_hc32 (virt_to_phys (addr)); next = (addr +4096 ) & ~4095 ; delta = next - addr;if (delta >= sz)
Quoted 4 lines
Quoted 1 line
Have you any idea?
No. Translating this addres into a physical address seems unavoidable here.
The other solution is to allocate private buffer using dma_alloc_coherent(), use the returned dma address to fill the qt_buffer field, copy data from the supplied buffer to the private buffer before the transaction and copy back after the transaction is done.
Quoted 8 lines
I would still prefer a real cache implementation for MIPS though. Have you looked further into that? The current MIPS cached/uncached memory windows seem to be a constant source of problems we could avoid.
Sascha
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 3/9] MIPS: add virt_to_phys() and phys_to_virt()
Quoted 87 lines · Peter Mamonov
Quoted 79 lines · On Mon, 7 Dec 2015 11:27:44 +0100 Sascha Hauer <[email protected]> wrote:
Quoted 78 lines · Antony Pavlov
Quoted 19 lines · On Fri, 4 Sep 2015 08:20:48 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 9 lines · Antony Pavlov
Quoted 6 lines · On Fri, 28 Aug 2015 08:34:32 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 3 lines · Antony Pavlov
N.B.
phys_to_virt()translates phys address
to KSEG1 (uncached) address as barebox mips
has no cache support.What would it take to implement cache support for mips?
Quoted 8 lines
lack of the cache support is critical problem for current barebox mips support. I'm planning to add cache support in several weeks. This task needs much test efforts for different boards.
Anyway I can't carry out cache adding work at one. But adding
virt_to_physand DMA support will help to add cache support one day anyway.Quoted 6 lines
Looking at this again the virt_to_phys/phys_to_virt macros are not necessary.
dma_alloc_coherent()already returns both the virtual address and the DMA address. It should be possible to replaceDMA_ADDRESS_BROKENin the ehci driver with a real pointer and use it appropriatly in the driver.I have tried to get physical address from
dma_alloc_coherent(), here is a small part of my patch (just for demonstration):drivers/usb/host/ehci-hcd.c +2
-1@@ -41,6 +41,7 @@ struct ehci_priv {struct ehci_hcor *hcor;struct usb_host host;struct QH *qh_list; +dma_addr_t qh_list_dma;struct qTD *td;int portreset;unsigned long flags;@@ -403,7 +410,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, goto fail; } - ehci->qh_list->qh_link =cpu_to_hc32 ((uint32_t )ehci->qh_list |QH_LINK_TYPE_QH ); + ehci->qh_list->qh_link =cpu_to_hc32 (ehci->qh_list_dma |QH_LINK_TYPE_QH ); token =hc32_to_cpu (qh->qt_token);drivers/usb/host/ehci-hcd.c +1
-1if (!(token &0x80 )) {@@ -1306,7 +1313,7 @@ int ehci_register(struct device_d *dev, struct ehci_data *data) ehci->post_init = data->post_init; ehci->qh_list =dma_alloc_coherent (sizeof (struct QH ) *NUM_TD , -DMA_ADDRESS_BROKEN ); + &ehci->qh_list_dma); ehci->periodic_queue =dma_alloc_coherent (sizeof (struct QH ),DMA_ADDRESS_BROKEN );
ehci->td= dma_alloc_coherent(sizeof(struct qTD) *NUM_TD,However
ehci_td_buffer()gets buf pointer outside of ehci driver (e.g. viausb_bulk_msg()), so it is difficult to avoidvirt_to_phys()inehci_td_buffer(), e.g.:drivers/usb/host/ehci-hcd.c +1
-1@@ -195,7 +197,7 @@ static int ehci_td_buffer(struct qTD *td, void *buf, size_t sz) idx =0 ;while (idx <5 ) { - td->qt_buffer[idx] =cpu_to_hc32 (addr); + td->qt_buffer[idx] =cpu_to_hc32 (virt_to_phys (addr)); next = (addr +4096 ) & ~4095 ; delta = next - addr;if (delta >= sz)Quoted 4 lines
Quoted 1 line
Have you any idea?
No. Translating this addres into a physical address seems unavoidable here.
Quoted 4 lines
The other solution is to allocate private buffer using
dma_alloc_coherent(), use the returned dma address to fill theqt_bufferfield, copy data from the supplied buffer to the private buffer before the transaction and copy back after the transaction is done.
Yes, that would work aswell, but would is neither nice nor efficient.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 4/9 MIPS: add trivial dma support
In reply to Antony PavlovFrom: Antony Pavlov <[email protected]>
--- arch/mips/Kconfig | 1 + arch/mips/include/asm/dma-mapping.h | 1 + arch/mips/include/asm/dma.h | 5 +++++ arch/mips/lib/Makefile | 1 + arch/mips/lib/dma-default.c | 28 ++++++++++++++++++++++++++++ 5 files changed, 36 insertions(+)
arch/mips/Kconfig +1 -0
@@ -6,6 +6,7 @@ config MIPS select HAS_KALLSYMS select HAVE_CONFIGURABLE_MEMORY_LAYOUT select HAVE_CONFIGURABLE_TEXT_BASE + select HAS_DMA default y config SYS_SUPPORTS_BIG_ENDIAN
arch/mips/include/asm/dma-mapping.h +1 -0
@@ -1,6 +1,7 @@#ifndef _ASM_DMA_MAPPING_H#define _ASM_DMA_MAPPING_H +#include <common.h> #include <xfuncs.h> #include <asm/addrspace.h> #include <asm/types.h>
arch/mips/include/asm/dma.h +5 -0
@@ -10,4 +10,9 @@#include "asm/dma-mapping.h" +void dma_sync_single_for_cpu (unsigned long address,size_t size, +enum dma_data_direction dir); +void dma_sync_single_for_device (unsigned long address,size_t size, +enum dma_data_direction dir); +#endif /* __ASM_DMA_H */
arch/mips/lib/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-y += ashrdi3.o obj-y += cpu-probe.o obj-y += traps.o obj-y += genex.o +obj-y += dma-default.o obj-$(CONFIG_CPU_MIPS32) += c-r4k.o obj-$(CONFIG_CPU_MIPS64) += c-r4k.o
arch/mips/lib/dma-default.c new file +28 -0
@@ -0,0 +1,28 @@ +/* +* Copyright (C) 2015 Antony Pavlov <[email protected]> +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +#include <dma.h> + +void dma_sync_single_for_cpu (unsigned long address,size_t size, +enum dma_data_direction dir) +{ +} + +void dma_sync_single_for_device (unsigned long address,size_t size, +enum dma_data_direction dir) +{ +}
Signature · 7 lines
2.5.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 5/9 ehci-hcd.c: make it works on mips
In reply to Antony PavlovOn MIPS processors virtual and physical addresses are differ. So we need to add the necessary address translation.
--- drivers/usb/host/ehci-hcd.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/usb/host/ehci-hcd.c +10 -9
@@ -176,7 +176,7 @@ static int ehci_td_buffer(struct qTD *td, void *buf, size_t sz)uint32_t addr, delta, next;int idx; - addr = (uint32_t ) buf; + addr = (uint32_t )virt_to_phys (buf); td->qtd_dma = addr; td->length = sz;
@@ -229,7 +229,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,memset (ehci->td,0 ,sizeof (struct qTD ) *NUM_TD ); qh = &ehci->qh_list[1 ]; - qh->qh_link =cpu_to_hc32 ((uint32_t )ehci->qh_list |QH_LINK_TYPE_QH ); + qh->qh_link =cpu_to_hc32 ((uint32_t )virt_to_phys (ehci->qh_list) |QH_LINK_TYPE_QH ); c = (dev->speed !=USB_SPEED_HIGH &&usb_pipeendpoint (pipe) ==0 ) ?1 :0 ; endpt = (8 << 28) |
@@ -280,7 +280,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,dev_dbg (ehci->dev,"unable construct SETUP td\n" ); goto fail; } - *tdp =cpu_to_hc32 ((uint32_t ) td); + *tdp =cpu_to_hc32 ((uint32_t )virt_to_phys (td)); tdp = &td->qt_next; toggle =1 ;
@@ -302,7 +302,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,dev_err (ehci->dev,"unable construct DATA td\n" ); goto fail; } - *tdp =cpu_to_hc32 ((uint32_t ) td); + *tdp =cpu_to_hc32 ((uint32_t )virt_to_phys (td)); tdp = &td->qt_next; }
@@ -318,11 +318,11 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, (3 <<10 ) | ((usb_pipein (pipe) ?0 :1 ) <<8 ) | (0x80 <<0 ); td->qt_token =cpu_to_hc32 (token); - *tdp =cpu_to_hc32 ((uint32_t )td); + *tdp =cpu_to_hc32 ((uint32_t )virt_to_phys (td)); tdp = &td->qt_next; } - ehci->qh_list->qh_link =cpu_to_hc32 ((uint32_t ) qh |QH_LINK_TYPE_QH ); + ehci->qh_list->qh_link =cpu_to_hc32 ((uint32_t )virt_to_phys (qh) |QH_LINK_TYPE_QH );/* Flush dcache */ if (IS_ENABLED (CONFIG_MMU )) {
@@ -390,7 +390,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, goto fail; } - ehci->qh_list->qh_link =cpu_to_hc32 ((uint32_t )ehci->qh_list |QH_LINK_TYPE_QH ); + ehci->qh_list->qh_link =cpu_to_hc32 ((uint32_t )virt_to_phys (ehci->qh_list) |QH_LINK_TYPE_QH ); token =hc32_to_cpu (qh->qt_token);if (!(token &0x80 )) {
@@ -435,7 +435,7 @@ fail: td = (void *)hc32_to_cpu (qh->qt_next);while (td != (void *)QT_NEXT_TERMINATE ) { qh->qt_next = td->qt_next; - td = (void *)hc32_to_cpu (qh->qt_next); + td =phys_to_virt (hc32_to_cpu (qh->qt_next)); }return -1 ; }
@@ -791,7 +791,8 @@ static int ehci_init(struct usb_host *host) ehci->qh_list->qt_token =cpu_to_hc32 (0x40 );/* Set async. queue head pointer. */ -ehci_writel (&ehci->hcor->or_asynclistaddr, (uint32_t )ehci->qh_list); +ehci_writel (&ehci->hcor->or_asynclistaddr, + (uint32_t )virt_to_phys (ehci->qh_list)); reg =ehci_readl (&ehci->hccr->cr_hcsparams); descriptor.hub.bNbrPorts =HCS_N_PORTS (reg);
Signature · 7 lines
2.5.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 6/9 usb: ehci: drop unusable CONFIG_EHCI_MMIO_BIG_ENDIAN condition
In reply to Antony PavlovThe Kconfig EHCI_MMIO_BIG_ENDIAN option is nowhere defined, so we can safely drop it.
--- drivers/usb/host/ehci-hcd.c | 3 --- drivers/usb/host/ehci.h | 5 ----- 2 files changed, 8 deletions(-)
drivers/usb/host/ehci-hcd.c +0 -3
@@ -162,9 +162,6 @@ static int ehci_reset(struct ehci_priv *ehci) reg_ptr = (uint32_t *)((u8 *)ehci->hcor +USBMODE ); tmp =ehci_readl (reg_ptr); tmp |=USBMODE_CM_HC ; -#if defined(CONFIG_EHCI_MMIO_BIG_ENDIAN ) - tmp |=USBMODE_BE ; -#endif ehci_writel (reg_ptr, tmp); } out:
drivers/usb/host/ehci.h +0 -5
@@ -80,13 +80,8 @@ static inline unsigned int ehci_readl(__u32 __iomem *regs)return readl (regs); } -#if definedCONFIG_EHCI_MMIO_BIG_ENDIAN -#define hc32_to_cpu (x) be32_to_cpu((x)) -#define cpu_to_hc32 (x) cpu_to_be32((x)) -#else #define hc32_to_cpu (x) le32_to_cpu((x))#define cpu_to_hc32 (x) cpu_to_le32((x)) -#endif #define EHCI_PS_WKOC_E (1 << 22)/* RW wake on over current */ #define EHCI_PS_WKDSCNNT_E (1 << 21)/* RW wake on disconnect */
Signature · 7 lines
2.5.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 7/9 usb: ehci: add big-endian registers support
In reply to Antony Pavlov--- drivers/usb/host/Kconfig | 3 + drivers/usb/host/ehci-hcd.c | 133 ++++++++++++++++++++++---------------------- drivers/usb/host/ehci.h | 42 +++++++++++++- include/usb/ehci.h | 1 + 4 files changed, 108 insertions(+), 71 deletions(-)
drivers/usb/host/Kconfig +3 -0
@@ -2,6 +2,9 @@ config USB_EHCI bool "EHCI driver" depends on HAS_DMA +config USB_EHCI_BIG_ENDIAN_MMIO + bool + config USB_EHCI_OMAP depends on ARCH_OMAP3 depends on USB_TWL4030
drivers/usb/host/ehci-hcd.c +65 -68
322 lines not on this page · raw message
drivers/usb/host/ehci.h +39 -3
52 lines not on this page · raw message
include/usb/ehci.h +1 -0
@@ -2,6 +2,7 @@#define __USB_EHCI_H#define EHCI_HAS_TT (1 << 0) +#define EHCI_BE_MMIO (1 << 1)struct ehci_platform_data {unsigned long flags;
Signature · 7 lines
2.5.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 7/9] usb: ehci: add big-endian registers support
Quoted 8 lines · Antony Pavlov
drivers/usb/host/ehci.h +8
-0+ +#ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO +#define ehci_big_endian_mmio (e) ((e)->big_endian_mmio) +#else +#define ehci_big_endian_mmio (e) 0 +#endif + +static inline void ehci_writel(const struct ehci_priv *ehci,
drivers/usb/host/ehci.h struct ehci_hcor { · line 105
Quoted 10 lines
drivers/usb/host/ehci.h +7
-1+ __u32 __iomem *regs, const unsigned int val) { -writel (val, regs); + if (IS_ENABLED(CONFIG_USB_EHCI_BIG_ENDIAN_MMIO)) { +ehci_big_endian_mmio (ehci) ? +iowrite32be (val, regs) : +writel (val, regs); + } else +writel (val ,regs ); }
if (ehci_big_endian_mmio(ehci)) iowrite32be(val, regs); else writel(val, regs);
is enough.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 7/9] usb: ehci: add big-endian registers support
Quoted 25 lines · On Fri, 28 Aug 2015 08:19:00 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 8 lines · Antony Pavlov
drivers/usb/host/ehci.h +8
-0+ +#ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO +#define ehci_big_endian_mmio (e) ((e)->big_endian_mmio) +#else +#define ehci_big_endian_mmio (e) 0 +#endif + +static inline void ehci_writel(const struct ehci_priv *ehci,drivers/usb/host/ehci.h struct ehci_hcor { · line 105
Quoted 10 lines
drivers/usb/host/ehci.h +7
-1+ __u32 __iomem *regs, const unsigned int val) { -writel (val, regs); + if (IS_ENABLED(CONFIG_USB_EHCI_BIG_ENDIAN_MMIO)) { +ehci_big_endian_mmio (ehci) ? +iowrite32be (val, regs) : +writel (val, regs); + } else +writel (val ,regs ); }if (ehci_big_endian_mmio(ehci)) iowrite32be(val, regs); else writel(val, regs);
Quoted 1 line
is enough.
It looks you are right. :)
I have just stealed this code from linux kernel.
I have some suspicions on redundancy of this code but I didn't proposed any good solution. Thanks!
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
RFC 8/9 MIPS: tplink-mr3020: select big-endian EHCI support
In reply to Antony Pavlov--- arch/mips/boards/tplink-mr3020/board.c | 55 ++++++++++++++++++++++++++++++++++ arch/mips/mach-ath79/Kconfig | 4 +++ 2 files changed, 59 insertions(+)
arch/mips/boards/tplink-mr3020/board.c +55 -0
@@ -25,3 +25,58 @@ static int model_hostname_init(void)return 0 ; }postcore_initcall (model_hostname_init); + +#include <asm/addrspace.h> +#include <mach/ath79.h> +#include <usb/ehci.h> + +#define AR933X_RESET_REG_RESET_MODULE 0x1c +#define AR933X_RESET_USB_HOST BIT(5) +#define AR933X_RESET_USB_PHY BIT(4) +#define AR933X_RESET_USBSUS_OVERRIDE BIT(3) + +#define AR933X_EHCI_BASE 0x1b000000 +#define AR933X_EHCI_SIZE 0x1000 + +static void ath79_device_reset_set (u32 mask) +{ +u32 reg; +u32 t; + + reg =AR933X_RESET_REG_RESET_MODULE ; + t =ath79_reset_rr (reg); +ath79_reset_wr (reg, t | mask); +} + +static void ath79_device_reset_clear (u32 mask) +{ +u32 reg; +u32 t; + + reg =AR933X_RESET_REG_RESET_MODULE ; + t =ath79_reset_rr (reg); +ath79_reset_wr (reg, t & ~mask); +} + +static struct ehci_platform_data ehci_pdata = { + .flags =EHCI_HAS_TT |EHCI_BE_MMIO , +}; + +static int ehci_init (void ) +{ +ath79_device_reset_set (AR933X_RESET_USBSUS_OVERRIDE ); +mdelay (10 );mdelay (10 );mdelay (10 ); + +ath79_device_reset_clear (AR933X_RESET_USB_HOST ); +mdelay (10 );mdelay (10 );mdelay (10 ); + +ath79_device_reset_clear (AR933X_RESET_USB_PHY ); +mdelay (10 );mdelay (10 );mdelay (10 ); + +add_generic_usb_ehci_device (DEVICE_ID_DYNAMIC , +KSEG1ADDR (AR933X_EHCI_BASE ), + &ehci_pdata); + +return 0 ; +} +device_initcall (ehci_init);
arch/mips/mach-ath79/Kconfig +4 -0
@@ -12,6 +12,10 @@ config BOARD_TPLINK_MR3020 select HAVE_PBL_IMAGE select HAVE_IMAGE_COMPRESSION select HAS_NMON + select USB_HOST + select HAS_DMA + select USB_EHCI + select USB_EHCI_BIG_ENDIAN_MMIO endchoice
Signature · 7 lines
2.5.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 9/9 MIPS: tplink-mr3020_defconfig: enable usb stuff
In reply to Antony Pavlov--- arch/mips/configs/tplink-mr3020_defconfig | 49 +++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 16 deletions(-)
arch/mips/configs/tplink-mr3020_defconfig +33 -16
@@ -1,34 +1,51 @@ CONFIG_BUILTIN_DTB=y CONFIG_BUILTIN_DTB_NAME="tplink-mr3020" CONFIG_MACH_MIPS_ATH79=y -CONFIG_LONGHELP=y CONFIG_CMDLINE_EDITING=y CONFIG_AUTO_COMPLETE=y -CONFIG_CMD_EDIT=y -CONFIG_CMD_SLEEP=y -CONFIG_CMD_LET=y -CONFIG_CMD_GLOBAL=y +CONFIG_LONGHELP=y +CONFIG_CMD_IOMEM=y +CONFIG_CMD_MEMINFO=y +# CONFIG_CMD_BOOTM is not set +CONFIG_CMD_GO=y CONFIG_CMD_LOADB=y CONFIG_CMD_LOADY=y -CONFIG_CMD_MEMINFO=y -CONFIG_CMD_IOMEM=y -CONFIG_CMD_MM=y +CONFIG_CMD_RESET=y +CONFIG_CMD_GLOBAL=y CONFIG_CMD_SHA1SUM=y +CONFIG_CMD_LET=y +CONFIG_CMD_SLEEP=y +CONFIG_CMD_DHCP=y +CONFIG_CMD_HOST=y +CONFIG_NET_CMD_IFUP=y +CONFIG_CMD_MIITOOL=y +CONFIG_CMD_PING=y +CONFIG_CMD_TFTP=y +CONFIG_CMD_EDIT=y +CONFIG_CMD_MM=y +CONFIG_CMD_CLK=y CONFIG_CMD_FLASH=y -# CONFIG_CMD_BOOTM is not set -CONFIG_CMD_RESET=y -CONFIG_CMD_GO=y -CONFIG_CMD_OFTREE=y -CONFIG_CMD_OF_PROPERTY=y -CONFIG_CMD_OF_NODE=y CONFIG_CMD_SPI=y -CONFIG_CMD_CLK=y +CONFIG_CMD_OF_NODE=y +CONFIG_CMD_OF_PROPERTY=y +CONFIG_CMD_OFTREE=y +CONFIG_NET=y +CONFIG_NET_NFS=y +CONFIG_NET_NETCONSOLE=y CONFIG_OFDEVICE=y CONFIG_DRIVER_SERIAL_AR933X=y +CONFIG_NET_USB=y +CONFIG_NET_USB_ASIX=y +CONFIG_NET_USB_SMSC95XX=y CONFIG_DRIVER_SPI_ATH79=y CONFIG_MTD=y # CONFIG_MTD_OOB_DEVICE is not set CONFIG_MTD_M25P80=y -CONFIG_MD5=y +CONFIG_USB_STORAGE=y +CONFIG_FS_EXT4=y +CONFIG_FS_TFTP=y +CONFIG_FS_NFS=y +CONFIG_FS_FAT=y +CONFIG_FS_FAT_LFN=y CONFIG_DIGEST_SHA224_GENERIC=y CONFIG_DIGEST_SHA256_GENERIC=y
Signature · 7 lines
2.5.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox