> Date: Wed, 23 Aug 2017 00:17:01 +0300
> From: Artturi Alm <[email protected]>
> 
> On Tue, Aug 22, 2017 at 09:47:27PM +0200, Mark Kettenis wrote:
> > > Date: Tue, 22 Aug 2017 22:12:51 +0300
> > > From: Artturi Alm <[email protected]>
> > > 
> > > Hi,
> > > 
> > > i came across dwc2 usb node like this:
> > > 
> > >         usb@101c0000 {
> > >                 compatible = "snps,dwc2";
> > >                 reg = <0x101c0000 0x40000>;
> > >                 interrupts = <0x0 0x11 0x4>;
> > >                 clocks = <0x2 0x1c9>;
> > >                 clock-names = "otg";
> > >                 dr_mode = "host";
> > >                 phys = <0x6>;
> > >                 phy-names = "usb2-phy";
> > >                 status = "okay";
> > >         };
> > > 
> > > 
> > > and as it's at /-root, there's not much i could use to identify between
> > > broadcom & rockchip while keeping the code simple for future additions,
> > > and not mess w/each SoC compat string individually when applying vendor-
> > > specific things..
> > > 
> > > i guess this should not be abused ever alone w/o some && in any _match(),
> > > but when used responsibly may make some _attach() funcs prettier:)
> > > 
> > > to export the _vend variant, or keep as strchr hack like below?
> > > (untested diff rly, for just the discussion atm.)
> > 
> > All the nodes I have seen have a more specific string included in the
> > compatible property.  Also, many, if not all of the parameters have
> > sane default values or values that can be read from a configuration
> > register.
> > 
> > So no, I don't think what you're proposing is a good idea.
> >
> 
> ok, i'll try to get this fixed in u-boot.
> 
> but incase i was unclear, the diff was supposed to allow ie. this where the
> specifics obviously doesn't matter beyond "," after vendor in compatible:

No.  That is now how this stuff is supposed to work.  You should drop
this idea.

> diff --git a/sys/dev/fdt/if_dwge_fdt.c b/sys/dev/fdt/if_dwge_fdt.c
> index edfe5acb992..a874274c215 100644
> --- a/sys/dev/fdt/if_dwge_fdt.c
> +++ b/sys/dev/fdt/if_dwge_fdt.c
> @@ -120,9 +120,7 @@ dwge_fdt_attach(struct device *parent, struct device 
> *self, void *aux)
>       /* Do hardware specific initializations. */
>       if (OF_is_compatible(faa->fa_node, "allwinner,sun7i-a20-gmac"))
>               dwge_fdt_attach_allwinner(fsc);
> -     else if (OF_is_compatible(faa->fa_node, "rockchip,rk3288-gmac"))
> -             dwge_fdt_attach_rockchip(fsc);
> -     else if (OF_is_compatible(faa->fa_node, "rockchip,rk3399-gmac"))
> +     else if (OF_is_compatible(faa->fa_node, "rockchip"))
>               dwge_fdt_attach_rockchip(fsc);
>  
>       /* Enable clock. */
> 
> 
> > Regarding your mail from a few days ago.  I did try something like
> > your diff to get the usb ports on the rk3288-tinker to work but failed
> > so far.
> > 
> 
> u-boot is still rather broken for rk3188, and success-rate on even u-boot
> finding the attached devices is less than 1/10... but one try got this far:
> 
> U-Boot SPL 2017.09-rc2-00151-g2d7cb5b-dirty (Aug 21 2017 - 18:15:17)
> Returning to boot ROM...
> 
> 
> U-Boot 2017.09-rc2-00151-g2d7cb5b-dirty (Aug 21 2017 - 18:15:17 +0300)
> 
> Model: Radxa Rock
> DRAM:  2 GiB
> MMC:   dwmmc@10214000 - probe failed: -22
> 
> *** Warning - No MMC card found, using default environment
> 
> In:    serial@20064000
> Out:   serial@20064000
> Err:   serial@20064000
> Model: Radxa Rock
> Net:   Net Initialization Skipped
> No ethernet found.
> Hit any key to stop autoboot:  0
> starting USB...
> USB0:   Core Release: 2.91a
> dwc_otg_core_host_init: Timeout!
> dwc_otg_core_host_init: Timeout!
> dwc_otg_core_host_init: Timeout!
> dwc_otg_core_host_init: Timeout!
> dwc_otg_core_host_init: Timeout!
> dwc_otg_core_host_init: Timeout!
> dwc_otg_core_host_init: Timeout!
> dwc_otg_core_host_init: Timeout!
> USB1:   Core Release: 2.91a
> scanning bus 0 for devices... 1 USB Device(s) found
> scanning bus 1 for devices... 5 USB Device(s) found
>        scanning usb for storage devices... 1 Storage Device(s) found
>        scanning usb for ethernet devices... 0 Ethernet Device(s) found
> 
> Device 0: Vendor: Kingston Rev: PMAP Prod: DataTraveler 2.0
>             Type: Removable Hard Disk
>             Capacity: 14891.4 MB = 14.5 GB (30497664 x 512)
> ... is now current device
> Scanning usb 0:1...
> Found EFI removable media binary efi/boot/bootarm.efi
> reading efi/boot/bootarm.efi
> 64908 bytes read in 70 ms (905.3 KiB/s)
> libfdt fdt_check_header(): FDT_ERR_BADMAGIC
> ## Starting EFI application at 62000000 ...
> Scanning disk [email protected]...
> Scanning disk usb_mass_storage.lun0...
> Found 2 disks
> >> OpenBSD/armv7 BOOTARM 0.8
> boot>
> booting sd0a:/bsd: 3887248+166476+499544 [281845+90+515968+242685]=0x558c3c
> 
> OpenBSD/armv7 booting ...
> arg0 0xc0858c3c arg1 0x0 arg2 0x68000000
> Allocating page tables
> freestart = 0x60859000, free_pages = 522151 (0x0007f7a7)
> IRQ stack: p0x60887000 v0xc0887000
> ABT stack: p0x60888000 v0xc0888000
> UND stack: p0x60889000 v0xc0889000
> SVC stack: p0x6088a000 v0xc088a000
> Creating L1 page table at 0x6085c000
> Mapping kernel
> Constructing L2 page tables
> undefined page pmap [ using 1041048 bytes of bsd ELF symbol table ]
> board type: 0
> Copyright (c) 1982, 1986, 1989, 1991, 1993
>         The Regents of the University of California.  All rights reserved.
> Copyright (c) 1995-2017 OpenBSD. All rights reserved.  https://www.OpenBSD.org
> 
> OpenBSD 6.2-beta (GENERIC) #4: Mon Aug 21 18:27:38 EEST 2017
>     [email protected]:/usr/src/sys/arch/armv7/compile/GENERIC
> real mem  = 2147483648 (2048MB)
> avail mem = 2097254400 (2000MB)
> mainbus0 at root: Radxa Rock
> cpu0 at mainbus0: ARM Cortex-A9 r3p0 (ARMv7)
> cpu0: DC enabled IC enabled WB disabled EABT branch prediction enabled
> cpu0: 32KB(32b/l,4way) I-cache, 32KB(32b/l,4way) wr-back D-cache
> cortex0 at mainbus0
> amptimer0 at cortex0: tick rate 396000 KHz
> armliicc0 at cortex0: rtl 0 waymask: 0x00000007
> simplebus0 at mainbus0: "amba"
> ampintc0 at mainbus0 nirq 160, ncpu 4
> com0 at mainbus0: ns16550, no working fifo
> com1 at mainbus0: ns16550, no working fifo
> dwctwo0 at mainbus0
> dwdog0 at mainbus0
> com2 at mainbus0: ns16550, no working fifo
> com2: console
> com3 at mainbus0: ns16550, no working fifo
> usb0 at dwctwo0: USB revision 2.0
> uhub0 at usb0 configuration 1 interface 0 "Broadcom DWC2 root hub" rev 
> 2.00/1.00 addr 1
> uhub0: device problem, disabling port 1
> vscsi0 at root
> scsibus0 at vscsi0: 256 targets
> softraid0 at root
> scsibus1 at softraid0: 256 targets
> boot device: lookup 'sd0a:/bsd' failed.
> root device:
> use one of: exit
> root device:
> 
> So, it's broken here on rk3188 too and needs more work.
> 
> -Artturi
> 
> > > diff --git a/sys/dev/ofw/fdt.c b/sys/dev/ofw/fdt.c
> > > index d6a64499e88..f22ed7a9f49 100644
> > > --- a/sys/dev/ofw/fdt.c
> > > +++ b/sys/dev/ofw/fdt.c
> > > @@ -42,6 +42,7 @@ int      fdt_translate_reg(void *, struct fdt_reg *);
> > >  #ifdef DEBUG
> > >  void      fdt_print_node_recurse(void *, int);
> > >  #endif
> > > +static int fdt_is_compatible_vend(void *, const char *);
> > >  
> > >  static int tree_inited = 0;
> > >  static struct fdt tree;
> > > @@ -634,6 +635,24 @@ fdt_is_compatible(void *node, const char *name)
> > >   return 0;
> > >  }
> > >  
> > > +int
> > > +fdt_is_compatible_vend(void *node, const char *name)
> > > +{
> > > + size_t vlen = strlen(name);
> > > + char *data;
> > > + int len;
> > > +
> > > + len = fdt_node_property(node, "compatible", &data);
> > > + while (len > 0) {
> > > +         if (strncmp(data, name, vlen) == 0)
> > > +                 return 1;
> > > +         len -= strlen(data) + 1;
> > > +         data += strlen(data) + 1;
> > > + }
> > > +
> > > + return 0;
> > > +}
> > > +
> > >  #ifdef DEBUG
> > >  /*
> > >   * Debug methods for printing whole tree, particular odes and properies
> > > @@ -902,6 +921,8 @@ int
> > >  OF_is_compatible(int handle, const char *name)
> > >  {
> > >   void *node = (char *)tree.header + handle;
> > > + if (strchr(name, ',') == NULL)
> > > +         return fdt_is_compatible_vend(node, name);
> > >   return (fdt_is_compatible(node, name));
> > >  }
> > >  
> > > 
> 

Reply via email to