<div dir="ltr"><div dir="ltr"><br><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jul 27, 2019 at 7:35 PM Christian Mauderer <<a href="mailto:list@c-mauderer.de">list@c-mauderer.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Does this initialize only the pins for drivers that are registered in<br>
libbsd or all pins? I think you had an extended boot log where you might<br>
could see it.<br>
<br>
If it is all pins, this might interfere with RTEMS drivers that are not<br>
libbsd based. In that case we need some kind of solution (not sure yet<br>
which one).<br>
<br></blockquote><div>It's muxing more pins than just the HDMI, including i2c pins. Please have</div><div>a look at the log that I got from RTEMS:</div><div><a href="https://paste.ofcode.org/kVvrdYAfvC3G6kBtG5iaTb">https://paste.ofcode.org/kVvrdYAfvC3G6kBtG5iaTb</a><br></div><div><br></div><div>These pins to be initialized are being decided from the device tree nodes </div><div>with the pinctrl-single,pins property. If the initialized pins are not all required,</div><div>then I would like to propose a solution of using an overlay to rename the </div><div>property to "rtems-pinctrl-single,pins" or something like this for the pins that </div><div>we need to be initialized, like hdmi. And in the ti_pinmux.c modify the code to</div><div>search for this property instead of the default.</div><div><br></div><div>I haven't attempted doing it but before I attempt I would like to make sure if</div><div>you think it's OK and not too hackish approach. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Beneath that: I added some comments in the code below.<br>
<br>
On 26/07/2019 13:22, Vijay Kumar Banerjee wrote:<br>
> ---<br>
>  Makefile.todo                                 | 13 ++++++<br>
>  buildset/default.ini                          |  1 +<br>
>  libbsd.py                                     | 33 +++++++++++++++<br>
>  rtemsbsd/include/bsp/nexus-devices.h          |  1 +<br>
>  .../machine/rtems-bsd-kernel-namespace.h      |  9 +++++<br>
>  .../include/rtems/bsd/local/fdt_pinctrl_if.h  | 40 +++++++++++++++++++<br>
>  rtemsbsd/local/fdt_pinctrl_if.c               | 27 +++++++++++++<br>
>  7 files changed, 124 insertions(+)<br>
>  create mode 100644 rtemsbsd/local/fdt_pinctrl_if.c<br>
> <br>
> diff --git a/Makefile.todo b/Makefile.todo<br>
> index ed1e428e..1bf61432 100644<br>
> --- a/Makefile.todo<br>
> +++ b/Makefile.todo<br>
> @@ -53,6 +53,8 @@ GENERATED += $(LOCAL_INC)/hdmi_if.h<br>
>  GENERATED += $(LOCAL_SRC)/hdmi_if.c<br>
>  GENERATED += $(LOCAL_INC)/fb_if.h<br>
>  GENERATED += $(LOCAL_SRC)/fb_if.c<br>
> +GENERATED += $(LOCAL_INC)/fdt_pinctrl_if.h<br>
> +GENERATED += $(LOCAL_SRC)/fdt_pinctrl_if.c<br>
>  GENERATED += rtemsbsd/include/machine/rtems-bsd-regdomain.h<br>
>  GENERATED += rtemsbsd/rtems/rtems-bsd-regdomain.c<br>
>  <br>
> @@ -279,6 +281,17 @@ $(LOCAL_SRC)/fb_if.c: $(FREEBSD_SRC)/sys/dev/fb/fb_if.m<br>
>           -e 's|#include "fb_if.h"|#include <rtems/bsd/local/fb_if.h>|'<br>
>       mv fb_if.c $@<br>
>  <br>
> +$(LOCAL_INC)/fdt_pinctrl_if.h: $(FREEBSD_SRC)/sys/dev/fdt/fdt_pinctrl_if.m<br>
> +     awk -f $(TOOLS)/makeobjops.awk $< -h<br>
> +     mv fdt_pinctrl_if.h $@<br>
> +<br>
> +$(LOCAL_SRC)/fdt_pinctrl_if.c: $(FREEBSD_SRC)/sys/dev/fdt/fdt_pinctrl_if.m<br>
> +     awk -f $(TOOLS)/makeobjops.awk $< -c<br>
> +     sed -i fdt_pinctrl_if.c \<br>
> +         -e '1 i\#include <machine/rtems-bsd-kernel-space.h>\n' \<br>
> +         -e 's|#include "fdt_pinctrl_if.h"|#include <rtems/bsd/local/fdt_pinctrl_if.h>|'<br>
> +     mv fdt_pinctrl_if.c $@<br>
> +<br>
>  $(LOCAL_SRC)/gpio_if.c: $(FREEBSD_SRC)/sys/dev/gpio/gpio_if.m<br>
>       awk -f $(TOOLS)/makeobjops.awk $< -c<br>
>       mv gpio_if.c $@<br>
> diff --git a/buildset/default.ini b/buildset/default.ini<br>
> index 1d052a48..eed5cb75 100644<br>
> --- a/buildset/default.ini<br>
> +++ b/buildset/default.ini<br>
> @@ -38,6 +38,7 @@ dev_usb_wlan = off<br>
>  dev_wlan_rtwn = off<br>
>  iic = on<br>
>  display = on<br>
> +ti_pinmux = on<br>
>  dhcpcd = on<br>
>  dpaa = on<br>
>  evdev = on<br>
> diff --git a/libbsd.py b/libbsd.py<br>
> index 775eeeac..cdd97010 100644<br>
> --- a/libbsd.py<br>
> +++ b/libbsd.py<br>
> @@ -840,6 +840,38 @@ class display(builder.Module):<br>
>              mm.generator['source']()<br>
>          )<br>
>  <br>
> +#<br>
> +# TI PINMUX<br>
> +#<br>
> +class ti_pinmux(builder.Module):<br>
> +<br>
> +    def __init__(self, manager):<br>
> +        super(ti_pinmux, self).__init__(manager, type(self).__name__)<br>
> +<br>
> +    def generate(self):<br>
> +        mm = self.manager<br>
> +        self.addKernelSpaceHeaderFiles(<br>
> +            [<br>
> +                'sys/arm/ti/ti_pinmux.h',<br>
> +                'sys/arm/ti/omap4/omap4_scm_padconf.h',<br>
> +                'sys/arm/ti/am335x/am335x_scm_padconf.h',<br>
> +            ]<br>
> +        )<br>
> +        self.addKernelSpaceSourceFiles(<br>
> +            [<br>
> +                'sys/arm/ti/ti_pinmux.c',<br>
> +                'sys/dev/fdt/fdt_pinctrl.c',<br>
<br>
That looks like a general file. So either this module isn't ti_pinmux<br>
but pinmux or the pinctrl should be somewhere else.<br>
<br>
> +                'sys/arm/ti/am335x/am335x_scm_padconf.c',<br>
> +            ],<br>
> +            mm.generator['source']()<br>
> +        )<br>
> +        self.addRTEMSSourceFiles(<br>
> +            [<br>
> +                'local/fdt_pinctrl_if.c',<br>
<br>
Same for that.<br>
<br>
> +            ],<br>
> +            mm.generator['source']()<br>
> +        )<br>
> +<br>
>  #<br>
>  # USB<br>
>  #<br>
> @@ -5198,6 +5230,7 @@ def load(mm):<br>
>      mm.addModule(evdev(mm))<br>
>      mm.addModule(iic(mm))<br>
>      mm.addModule(display(mm))<br>
> +    mm.addModule(ti_pinmux(mm))<br>
>  <br>
>      mm.addModule(dev_usb(mm))<br>
>      mm.addModule(dev_usb_controller(mm))<br>
> diff --git a/rtemsbsd/include/bsp/nexus-devices.h b/rtemsbsd/include/bsp/nexus-devices.h<br>
> index 313c40d4..a22102c8 100644<br>
> --- a/rtemsbsd/include/bsp/nexus-devices.h<br>
> +++ b/rtemsbsd/include/bsp/nexus-devices.h<br>
> @@ -54,6 +54,7 @@ RTEMS_BSD_DRIVER_SMC0(0x4e000000,  RVPBXA9_IRQ_ETHERNET);<br>
>  RTEMS_BSD_DEFINE_NEXUS_DEVICE(ofwbus, 0, 0, NULL);<br>
>  SYSINIT_DRIVER_REFERENCE(simplebus, ofwbus);<br>
>  SYSINIT_DRIVER_REFERENCE(ti_scm, simplebus);<br>
> +SYSINIT_DRIVER_REFERENCE(ti_pinmux, simplebus);<br>
>  SYSINIT_DRIVER_REFERENCE(am335x_prcm, simplebus);<br>
>  SYSINIT_DRIVER_REFERENCE(usbss, simplebus);<br>
>  SYSINIT_DRIVER_REFERENCE(musbotg, usbss);<br>
> diff --git a/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h b/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h<br>
> index d796d3d1..96ca6a7c 100644<br>
> --- a/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h<br>
> +++ b/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h<br>
> @@ -1294,6 +1294,10 @@<br>
>  #define      fdt_immr_va _bsd_fdt_immr_va<br>
>  #define      fdt_is_compatible_strict _bsd_fdt_is_compatible_strict<br>
>  #define      fdt_parent_addr_cells _bsd_fdt_parent_addr_cells<br>
> +#define      fdt_pinctrl_configure _bsd_fdt_pinctrl_configure<br>
> +#define      fdt_pinctrl_configure_by_name _bsd_fdt_pinctrl_configure_by_name<br>
> +#define      fdt_pinctrl_configure_tree _bsd_fdt_pinctrl_configure_tree<br>
> +#define      fdt_pinctrl_register _bsd_fdt_pinctrl_register<br>
>  #define      fdt_regsize _bsd_fdt_regsize<br>
>  #define      fib4_free_nh_ext _bsd_fib4_free_nh_ext<br>
>  #define      fib4_lookup_nh_basic _bsd_fib4_lookup_nh_basic<br>
> @@ -5038,6 +5042,7 @@<br>
>  #define      t_functions _bsd_t_functions<br>
>  #define      t_functions_inited _bsd_t_functions_inited<br>
>  #define      ti_am335x_clk_devmap _bsd_ti_am335x_clk_devmap<br>
> +#define      ti_am335x_pinmux_dev _bsd_ti_am335x_pinmux_dev<br>
>  #define      tick _bsd_tick<br>
>  #define      ticket_altqs_active _bsd_ticket_altqs_active<br>
>  #define      ticket_altqs_inactive _bsd_ticket_altqs_inactive<br>
> @@ -5052,6 +5057,10 @@<br>
>  #define      _timeout_task_init _bsd__timeout_task_init<br>
>  #define      timevaladd _bsd_timevaladd<br>
>  #define      timevalsub _bsd_timevalsub<br>
> +#define      ti_pinmux_padconf_get _bsd_ti_pinmux_padconf_get<br>
> +#define      ti_pinmux_padconf_get_gpiomode _bsd_ti_pinmux_padconf_get_gpiomode<br>
> +#define      ti_pinmux_padconf_set _bsd_ti_pinmux_padconf_set<br>
> +#define      ti_pinmux_padconf_set_gpiomode _bsd_ti_pinmux_padconf_set_gpiomode<br>
>  #define      ti_prcm_clk_disable _bsd_ti_prcm_clk_disable<br>
>  #define      ti_prcm_clk_enable _bsd_ti_prcm_clk_enable<br>
>  #define      ti_prcm_clk_get_source_freq _bsd_ti_prcm_clk_get_source_freq<br>
> diff --git a/rtemsbsd/include/rtems/bsd/local/fdt_pinctrl_if.h b/rtemsbsd/include/rtems/bsd/local/fdt_pinctrl_if.h<br>
> index e69de29b..6343de41 100644<br>
> --- a/rtemsbsd/include/rtems/bsd/local/fdt_pinctrl_if.h<br>
> +++ b/rtemsbsd/include/rtems/bsd/local/fdt_pinctrl_if.h<br>
> @@ -0,0 +1,40 @@<br>
> +/*<br>
> + * This file is produced automatically.<br>
> + * Do not modify anything in here by hand.<br>
> + *<br>
> + * Created from source file<br>
> + *   freebsd-org/sys/dev/fdt/fdt_pinctrl_if.m<br>
> + * with<br>
> + *   makeobjops.awk<br>
> + *<br>
> + * See the source file for legal information<br>
> + */<br>
> +<br>
> +<br>
> +#ifndef _fdt_pinctrl_if_h_<br>
> +#define _fdt_pinctrl_if_h_<br>
> +<br>
> +<br>
> +#include <sys/tslog.h><br>
> +<br>
> +/** @brief Unique descriptor for the FDT_PINCTRL_CONFIGURE() method */<br>
> +extern struct kobjop_desc fdt_pinctrl_configure_desc;<br>
> +/** @brief A function implementing the FDT_PINCTRL_CONFIGURE() method */<br>
> +typedef int fdt_pinctrl_configure_t(device_t pinctrl, phandle_t cfgxref);<br>
> +<br>
> +static __inline int FDT_PINCTRL_CONFIGURE(device_t pinctrl, phandle_t cfgxref)<br>
> +{<br>
> +     kobjop_t _m;<br>
> +     int rc;<br>
> +<br>
> +TSENTER2(device_get_name(pinctrl));<br>
> +<br>
> +     KOBJOPLOOKUP(((kobj_t)pinctrl)->ops,fdt_pinctrl_configure);<br>
> +     rc = ((fdt_pinctrl_configure_t *) _m)(pinctrl, cfgxref);<br>
> +<br>
> +TSEXIT2(device_get_name(pinctrl));<br>
> +<br>
> +     return (rc);<br>
> +}<br>
> +<br>
> +#endif /* _fdt_pinctrl_if_h_ */<br>
> diff --git a/rtemsbsd/local/fdt_pinctrl_if.c b/rtemsbsd/local/fdt_pinctrl_if.c<br>
> new file mode 100644<br>
> index 00000000..9609add0<br>
> --- /dev/null<br>
> +++ b/rtemsbsd/local/fdt_pinctrl_if.c<br>
> @@ -0,0 +1,27 @@<br>
> +#include <machine/rtems-bsd-kernel-space.h><br>
> +<br>
> +/*<br>
> + * This file is produced automatically.<br>
> + * Do not modify anything in here by hand.<br>
> + *<br>
> + * Created from source file<br>
> + *   freebsd-org/sys/dev/fdt/fdt_pinctrl_if.m<br>
> + * with<br>
> + *   makeobjops.awk<br>
> + *<br>
> + * See the source file for legal information<br>
> + */<br>
> +<br>
> +#include <sys/param.h><br>
> +#include <sys/queue.h><br>
> +#include <sys/kernel.h><br>
> +#include <sys/kobj.h><br>
> +#include <sys/types.h><br>
> +#include <sys/bus.h><br>
> +#include <dev/ofw/openfirm.h><br>
> +#include <rtems/bsd/local/fdt_pinctrl_if.h><br>
> +<br>
> +struct kobjop_desc fdt_pinctrl_configure_desc = {<br>
> +     0, { &fdt_pinctrl_configure_desc, (kobjop_t)kobj_error_method }<br>
> +};<br>
> +<br>
> <br>
</blockquote></div></div>