diff mbox

[U-Boot,3/6] rockchip: evb-rk3328: set uart2 and sdmmc io routing

Message ID 1494992688-19180-4-git-send-email-kever.yang@rock-chips.com
State Changes Requested
Delegated to: Simon Glass
Headers show

Commit Message

Kever Yang May 17, 2017, 3:44 a.m. UTC
In rk3328, some function pin may have more than one choice, and muxed
with more than one IO, for example, the UART2 controller IO,
TX and RX, have 3 choice(setting in com_iomux):
- M0 which mux with GPIO1A0/GPIO1A1
- M1 which mux with GPIO2A0/GPIO2A1
- usb2phy which mux with USB2.0 DP/DM pin.

We should set these IO routing in board file.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
---

 board/rockchip/evb_rk3328/evb-rk3328.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Simon Glass May 20, 2017, 2:29 a.m. UTC | #1
Hi Kever,

On 16 May 2017 at 21:44, Kever Yang <kever.yang@rock-chips.com> wrote:
> In rk3328, some function pin may have more than one choice, and muxed
> with more than one IO, for example, the UART2 controller IO,
> TX and RX, have 3 choice(setting in com_iomux):
> - M0 which mux with GPIO1A0/GPIO1A1
> - M1 which mux with GPIO2A0/GPIO2A1
> - usb2phy which mux with USB2.0 DP/DM pin.
>
> We should set these IO routing in board file.
>
> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
> ---
>
>  board/rockchip/evb_rk3328/evb-rk3328.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/board/rockchip/evb_rk3328/evb-rk3328.c b/board/rockchip/evb_rk3328/evb-rk3328.c
> index a7895cb..d9dc782 100644
> --- a/board/rockchip/evb_rk3328/evb-rk3328.c
> +++ b/board/rockchip/evb_rk3328/evb-rk3328.c
> @@ -5,7 +5,10 @@
>   */
>
>  #include <common.h>
> +#include <asm/arch/hardware.h>
> +#include <asm/arch/grf_rk3328.h>
>  #include <asm/armv8/mmu.h>
> +#include <asm/io.h>
>  #include <dwc3-uboot.h>
>  #include <usb.h>
>
> @@ -13,6 +16,15 @@ DECLARE_GLOBAL_DATA_PTR;
>
>  int board_init(void)
>  {
> +#define GRF_BASE       0xff100000
> +       struct rk3328_grf_regs * const grf = (void *)GRF_BASE;
> +
> +       /* uart2 select m1, sdcard select m1*/
> +       rk_clrsetreg(&grf->com_iomux,
> +                    IOMUX_SEL_UART2_MASK | IOMUX_SEL_SDMMC_MASK,
> +                    IOMUX_SEL_UART2_M1 << IOMUX_SEL_UART2_SHIFT |
> +                    IOMUX_SEL_SDMMC_M1 << IOMUX_SEL_SDMMC_SHIFT);
> +
>         return 0;
>  }

This needs to be done via a call to some sort of driver. The above
hack is OK in SPL but not in U-Boot proper.

See my comments elsewhere about using a misc driver with an IOCTL
interface to do this sort of thing. Although here I wonder why you
cannot use pinctrl?

Regards,
Simon
Kever Yang May 24, 2017, 2:35 a.m. UTC | #2
Hi Simon,


On 05/20/2017 10:29 AM, Simon Glass wrote:
> Hi Kever,
>
> On 16 May 2017 at 21:44, Kever Yang <kever.yang@rock-chips.com> wrote:
>> In rk3328, some function pin may have more than one choice, and muxed
>> with more than one IO, for example, the UART2 controller IO,
>> TX and RX, have 3 choice(setting in com_iomux):
>> - M0 which mux with GPIO1A0/GPIO1A1
>> - M1 which mux with GPIO2A0/GPIO2A1
>> - usb2phy which mux with USB2.0 DP/DM pin.
>>
>> We should set these IO routing in board file.
>>
>> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
>> ---
>>
>>   board/rockchip/evb_rk3328/evb-rk3328.c | 12 ++++++++++++
>>   1 file changed, 12 insertions(+)
>>
>> diff --git a/board/rockchip/evb_rk3328/evb-rk3328.c b/board/rockchip/evb_rk3328/evb-rk3328.c
>> index a7895cb..d9dc782 100644
>> --- a/board/rockchip/evb_rk3328/evb-rk3328.c
>> +++ b/board/rockchip/evb_rk3328/evb-rk3328.c
>> @@ -5,7 +5,10 @@
>>    */
>>
>>   #include <common.h>
>> +#include <asm/arch/hardware.h>
>> +#include <asm/arch/grf_rk3328.h>
>>   #include <asm/armv8/mmu.h>
>> +#include <asm/io.h>
>>   #include <dwc3-uboot.h>
>>   #include <usb.h>
>>
>> @@ -13,6 +16,15 @@ DECLARE_GLOBAL_DATA_PTR;
>>
>>   int board_init(void)
>>   {
>> +#define GRF_BASE       0xff100000
>> +       struct rk3328_grf_regs * const grf = (void *)GRF_BASE;
>> +
>> +       /* uart2 select m1, sdcard select m1*/
>> +       rk_clrsetreg(&grf->com_iomux,
>> +                    IOMUX_SEL_UART2_MASK | IOMUX_SEL_SDMMC_MASK,
>> +                    IOMUX_SEL_UART2_M1 << IOMUX_SEL_UART2_SHIFT |
>> +                    IOMUX_SEL_SDMMC_M1 << IOMUX_SEL_SDMMC_SHIFT);
>> +
>>          return 0;
>>   }
> This needs to be done via a call to some sort of driver. The above
> hack is OK in SPL but not in U-Boot proper.

Yes, SPL also needs this. I thinks here should be the right place
before there is a SPL for rk3328.
>
> See my comments elsewhere about using a misc driver with an IOCTL
> interface to do this sort of thing. Although here I wonder why you
> cannot use pinctrl?

This is different from traditional pinctrl, kernel also still not have
final solution on this, see [0], and some people think it should be
done in boot loader.


Thanks,
- Kever
[0] 
http://lists.infradead.org/pipermail/linux-rockchip/2016-August/011209.html
>
> Regards,
> Simon
>
Heiko Stübner May 26, 2017, 10:28 p.m. UTC | #3
Hi Kever,

Am Mittwoch, 24. Mai 2017, 10:35:04 CEST schrieb Kever Yang:
> On 05/20/2017 10:29 AM, Simon Glass wrote:
> > On 16 May 2017 at 21:44, Kever Yang <kever.yang@rock-chips.com> wrote:
> >> In rk3328, some function pin may have more than one choice, and muxed
> >> with more than one IO, for example, the UART2 controller IO,
> >> TX and RX, have 3 choice(setting in com_iomux):
> >> - M0 which mux with GPIO1A0/GPIO1A1
> >> - M1 which mux with GPIO2A0/GPIO2A1
> >> - usb2phy which mux with USB2.0 DP/DM pin.
> >>
> >> We should set these IO routing in board file.
> >>
> >> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
> >> ---
> >>
> >>   board/rockchip/evb_rk3328/evb-rk3328.c | 12 ++++++++++++
> >>   1 file changed, 12 insertions(+)
> >>
> >> diff --git a/board/rockchip/evb_rk3328/evb-rk3328.c b/board/rockchip/evb_rk3328/evb-rk3328.c
> >> index a7895cb..d9dc782 100644
> >> --- a/board/rockchip/evb_rk3328/evb-rk3328.c
> >> +++ b/board/rockchip/evb_rk3328/evb-rk3328.c
> >> @@ -5,7 +5,10 @@
> >>    */
> >>
> >>   #include <common.h>
> >> +#include <asm/arch/hardware.h>
> >> +#include <asm/arch/grf_rk3328.h>
> >>   #include <asm/armv8/mmu.h>
> >> +#include <asm/io.h>
> >>   #include <dwc3-uboot.h>
> >>   #include <usb.h>
> >>
> >> @@ -13,6 +16,15 @@ DECLARE_GLOBAL_DATA_PTR;
> >>
> >>   int board_init(void)
> >>   {
> >> +#define GRF_BASE       0xff100000
> >> +       struct rk3328_grf_regs * const grf = (void *)GRF_BASE;
> >> +
> >> +       /* uart2 select m1, sdcard select m1*/
> >> +       rk_clrsetreg(&grf->com_iomux,
> >> +                    IOMUX_SEL_UART2_MASK | IOMUX_SEL_SDMMC_MASK,
> >> +                    IOMUX_SEL_UART2_M1 << IOMUX_SEL_UART2_SHIFT |
> >> +                    IOMUX_SEL_SDMMC_M1 << IOMUX_SEL_SDMMC_SHIFT);
> >> +
> >>          return 0;
> >>   }
> > This needs to be done via a call to some sort of driver. The above
> > hack is OK in SPL but not in U-Boot proper.
> 
> Yes, SPL also needs this. I thinks here should be the right place
> before there is a SPL for rk3328.
> >
> > See my comments elsewhere about using a misc driver with an IOCTL
> > interface to do this sort of thing. Although here I wonder why you
> > cannot use pinctrl?
> 
> This is different from traditional pinctrl, kernel also still not have
> final solution on this, see [0], and some people think it should be
> done in boot loader.

Just to point out that thanks to David Wu we now have a solution [1]
on the kernel side I'm pretty happy with - as part of the pinctrl driver.


Heiko


> [0] 
> http://lists.infradead.org/pipermail/linux-rockchip/2016-August/011209.html

[1] https://www.spinics.net/lists/kernel/msg2517794.html
Simon Glass June 1, 2017, 3:10 a.m. UTC | #4
Hi Kever,

On 23 May 2017 at 20:35, Kever Yang <kever.yang@rock-chips.com> wrote:
> Hi Simon,
>
>
>
> On 05/20/2017 10:29 AM, Simon Glass wrote:
>>
>> Hi Kever,
>>
>> On 16 May 2017 at 21:44, Kever Yang <kever.yang@rock-chips.com> wrote:
>>>
>>> In rk3328, some function pin may have more than one choice, and muxed
>>> with more than one IO, for example, the UART2 controller IO,
>>> TX and RX, have 3 choice(setting in com_iomux):
>>> - M0 which mux with GPIO1A0/GPIO1A1
>>> - M1 which mux with GPIO2A0/GPIO2A1
>>> - usb2phy which mux with USB2.0 DP/DM pin.
>>>
>>> We should set these IO routing in board file.
>>>
>>> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
>>> ---
>>>
>>>   board/rockchip/evb_rk3328/evb-rk3328.c | 12 ++++++++++++
>>>   1 file changed, 12 insertions(+)
>>>
>>> diff --git a/board/rockchip/evb_rk3328/evb-rk3328.c
>>> b/board/rockchip/evb_rk3328/evb-rk3328.c
>>> index a7895cb..d9dc782 100644
>>> --- a/board/rockchip/evb_rk3328/evb-rk3328.c
>>> +++ b/board/rockchip/evb_rk3328/evb-rk3328.c
>>> @@ -5,7 +5,10 @@
>>>    */
>>>
>>>   #include <common.h>
>>> +#include <asm/arch/hardware.h>
>>> +#include <asm/arch/grf_rk3328.h>
>>>   #include <asm/armv8/mmu.h>
>>> +#include <asm/io.h>
>>>   #include <dwc3-uboot.h>
>>>   #include <usb.h>
>>>
>>> @@ -13,6 +16,15 @@ DECLARE_GLOBAL_DATA_PTR;
>>>
>>>   int board_init(void)
>>>   {
>>> +#define GRF_BASE       0xff100000
>>> +       struct rk3328_grf_regs * const grf = (void *)GRF_BASE;
>>> +
>>> +       /* uart2 select m1, sdcard select m1*/
>>> +       rk_clrsetreg(&grf->com_iomux,
>>> +                    IOMUX_SEL_UART2_MASK | IOMUX_SEL_SDMMC_MASK,
>>> +                    IOMUX_SEL_UART2_M1 << IOMUX_SEL_UART2_SHIFT |
>>> +                    IOMUX_SEL_SDMMC_M1 << IOMUX_SEL_SDMMC_SHIFT);
>>> +
>>>          return 0;
>>>   }
>>
>> This needs to be done via a call to some sort of driver. The above
>> hack is OK in SPL but not in U-Boot proper.
>
>
> Yes, SPL also needs this. I thinks here should be the right place
> before there is a SPL for rk3328.

But if you are booting from an SD card, how can you need a mux to
select it? Surely the boot ROM must set it up or you would not be able
to boot from MMC?

When will there be SPL for rk3328?

>>
>>
>> See my comments elsewhere about using a misc driver with an IOCTL
>> interface to do this sort of thing. Although here I wonder why you
>> cannot use pinctrl?
>
>
> This is different from traditional pinctrl, kernel also still not have
> final solution on this, see [0], and some people think it should be
> done in boot loader.

How about putting it in grf syscon driver?

>
>
> Thanks,
> - Kever
> [0]
> http://lists.infradead.org/pipermail/linux-rockchip/2016-August/011209.html
>>
>>
>> Regards,
>> Simon
>>
>
>
Kever Yang June 7, 2017, 3:28 a.m. UTC | #5
Simon,


On 06/01/2017 11:10 AM, Simon Glass wrote:
> Hi Kever,
>
> On 23 May 2017 at 20:35, Kever Yang <kever.yang@rock-chips.com> wrote:
>> Hi Simon,
>>
>>
>>
>> On 05/20/2017 10:29 AM, Simon Glass wrote:
>>> Hi Kever,
>>>
>>> On 16 May 2017 at 21:44, Kever Yang <kever.yang@rock-chips.com> wrote:
>>>> In rk3328, some function pin may have more than one choice, and muxed
>>>> with more than one IO, for example, the UART2 controller IO,
>>>> TX and RX, have 3 choice(setting in com_iomux):
>>>> - M0 which mux with GPIO1A0/GPIO1A1
>>>> - M1 which mux with GPIO2A0/GPIO2A1
>>>> - usb2phy which mux with USB2.0 DP/DM pin.
>>>>
>>>> We should set these IO routing in board file.
>>>>
>>>> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
>>>> ---
>>>>
>>>>    board/rockchip/evb_rk3328/evb-rk3328.c | 12 ++++++++++++
>>>>    1 file changed, 12 insertions(+)
>>>>
>>>> diff --git a/board/rockchip/evb_rk3328/evb-rk3328.c
>>>> b/board/rockchip/evb_rk3328/evb-rk3328.c
>>>> index a7895cb..d9dc782 100644
>>>> --- a/board/rockchip/evb_rk3328/evb-rk3328.c
>>>> +++ b/board/rockchip/evb_rk3328/evb-rk3328.c
>>>> @@ -5,7 +5,10 @@
>>>>     */
>>>>
>>>>    #include <common.h>
>>>> +#include <asm/arch/hardware.h>
>>>> +#include <asm/arch/grf_rk3328.h>
>>>>    #include <asm/armv8/mmu.h>
>>>> +#include <asm/io.h>
>>>>    #include <dwc3-uboot.h>
>>>>    #include <usb.h>
>>>>
>>>> @@ -13,6 +16,15 @@ DECLARE_GLOBAL_DATA_PTR;
>>>>
>>>>    int board_init(void)
>>>>    {
>>>> +#define GRF_BASE       0xff100000
>>>> +       struct rk3328_grf_regs * const grf = (void *)GRF_BASE;
>>>> +
>>>> +       /* uart2 select m1, sdcard select m1*/
>>>> +       rk_clrsetreg(&grf->com_iomux,
>>>> +                    IOMUX_SEL_UART2_MASK | IOMUX_SEL_SDMMC_MASK,
>>>> +                    IOMUX_SEL_UART2_M1 << IOMUX_SEL_UART2_SHIFT |
>>>> +                    IOMUX_SEL_SDMMC_M1 << IOMUX_SEL_SDMMC_SHIFT);
>>>> +
>>>>           return 0;
>>>>    }
>>> This needs to be done via a call to some sort of driver. The above
>>> hack is OK in SPL but not in U-Boot proper.
>>
>> Yes, SPL also needs this. I thinks here should be the right place
>> before there is a SPL for rk3328.
> But if you are booting from an SD card, how can you need a mux to
> select it? Surely the boot ROM must set it up or you would not be able
> to boot from MMC?

If we need to boot from SD card, then we need to follow the boot ROM 
setting,
and hardware also need to follow it.
There is another case, the default SD card pin is used for other 
function in hardware,
then we use the alternative pin mux, we can't boot from SD card in bootrom,
but we still can use SD card in later stage like U-Boot and kernel.

Thanks,
- Kever
>
> When will there be SPL for rk3328?
>
>>>
>>> See my comments elsewhere about using a misc driver with an IOCTL
>>> interface to do this sort of thing. Although here I wonder why you
>>> cannot use pinctrl?
>>
>> This is different from traditional pinctrl, kernel also still not have
>> final solution on this, see [0], and some people think it should be
>> done in boot loader.
> How about putting it in grf syscon driver?
>
>>
>> Thanks,
>> - Kever
>> [0]
>> http://lists.infradead.org/pipermail/linux-rockchip/2016-August/011209.html
>>>
>>> Regards,
>>> Simon
>>>
>>
Simon Glass June 9, 2017, 12:27 p.m. UTC | #6
Hi Kever,

On 6 June 2017 at 21:28, Kever Yang <kever.yang@rock-chips.com> wrote:
> Simon,
>
>
>
> On 06/01/2017 11:10 AM, Simon Glass wrote:
>>
>> Hi Kever,
>>
>> On 23 May 2017 at 20:35, Kever Yang <kever.yang@rock-chips.com> wrote:
>>>
>>> Hi Simon,
>>>
>>>
>>>
>>> On 05/20/2017 10:29 AM, Simon Glass wrote:
>>>>
>>>> Hi Kever,
>>>>
>>>> On 16 May 2017 at 21:44, Kever Yang <kever.yang@rock-chips.com> wrote:
>>>>>
>>>>> In rk3328, some function pin may have more than one choice, and muxed
>>>>> with more than one IO, for example, the UART2 controller IO,
>>>>> TX and RX, have 3 choice(setting in com_iomux):
>>>>> - M0 which mux with GPIO1A0/GPIO1A1
>>>>> - M1 which mux with GPIO2A0/GPIO2A1
>>>>> - usb2phy which mux with USB2.0 DP/DM pin.
>>>>>
>>>>> We should set these IO routing in board file.
>>>>>
>>>>> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
>>>>> ---
>>>>>
>>>>>    board/rockchip/evb_rk3328/evb-rk3328.c | 12 ++++++++++++
>>>>>    1 file changed, 12 insertions(+)
>>>>>
>>>>> diff --git a/board/rockchip/evb_rk3328/evb-rk3328.c
>>>>> b/board/rockchip/evb_rk3328/evb-rk3328.c
>>>>> index a7895cb..d9dc782 100644
>>>>> --- a/board/rockchip/evb_rk3328/evb-rk3328.c
>>>>> +++ b/board/rockchip/evb_rk3328/evb-rk3328.c
>>>>> @@ -5,7 +5,10 @@
>>>>>     */
>>>>>
>>>>>    #include <common.h>
>>>>> +#include <asm/arch/hardware.h>
>>>>> +#include <asm/arch/grf_rk3328.h>
>>>>>    #include <asm/armv8/mmu.h>
>>>>> +#include <asm/io.h>
>>>>>    #include <dwc3-uboot.h>
>>>>>    #include <usb.h>
>>>>>
>>>>> @@ -13,6 +16,15 @@ DECLARE_GLOBAL_DATA_PTR;
>>>>>
>>>>>    int board_init(void)
>>>>>    {
>>>>> +#define GRF_BASE       0xff100000
>>>>> +       struct rk3328_grf_regs * const grf = (void *)GRF_BASE;
>>>>> +
>>>>> +       /* uart2 select m1, sdcard select m1*/
>>>>> +       rk_clrsetreg(&grf->com_iomux,
>>>>> +                    IOMUX_SEL_UART2_MASK | IOMUX_SEL_SDMMC_MASK,
>>>>> +                    IOMUX_SEL_UART2_M1 << IOMUX_SEL_UART2_SHIFT |
>>>>> +                    IOMUX_SEL_SDMMC_M1 << IOMUX_SEL_SDMMC_SHIFT);
>>>>> +
>>>>>           return 0;
>>>>>    }
>>>>
>>>> This needs to be done via a call to some sort of driver. The above
>>>> hack is OK in SPL but not in U-Boot proper.
>>>
>>>
>>> Yes, SPL also needs this. I thinks here should be the right place
>>> before there is a SPL for rk3328.
>>
>> But if you are booting from an SD card, how can you need a mux to
>> select it? Surely the boot ROM must set it up or you would not be able
>> to boot from MMC?
>
>
> If we need to boot from SD card, then we need to follow the boot ROM
> setting,
> and hardware also need to follow it.
> There is another case, the default SD card pin is used for other function in
> hardware,
> then we use the alternative pin mux, we can't boot from SD card in bootrom,
> but we still can use SD card in later stage like U-Boot and kernel.
>

OK, understood, thanks. Can you put it in the pinctrl driver?

- Simon

> Thanks,
> - Kever
>
>>
>> When will there be SPL for rk3328?
>>
>>>>
>>>> See my comments elsewhere about using a misc driver with an IOCTL
>>>> interface to do this sort of thing. Although here I wonder why you
>>>> cannot use pinctrl?
>>>
>>>
>>> This is different from traditional pinctrl, kernel also still not have
>>> final solution on this, see [0], and some people think it should be
>>> done in boot loader.
>>
>> How about putting it in grf syscon driver?
>>
>>>
>>> Thanks,
>>> - Kever
>>> [0]
>>>
>>> http://lists.infradead.org/pipermail/linux-rockchip/2016-August/011209.html
>>>>
>>>>
>>>> Regards,
>>>> Simon
>>>>
>>>
>
>
diff mbox

Patch

diff --git a/board/rockchip/evb_rk3328/evb-rk3328.c b/board/rockchip/evb_rk3328/evb-rk3328.c
index a7895cb..d9dc782 100644
--- a/board/rockchip/evb_rk3328/evb-rk3328.c
+++ b/board/rockchip/evb_rk3328/evb-rk3328.c
@@ -5,7 +5,10 @@ 
  */
 
 #include <common.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/grf_rk3328.h>
 #include <asm/armv8/mmu.h>
+#include <asm/io.h>
 #include <dwc3-uboot.h>
 #include <usb.h>
 
@@ -13,6 +16,15 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int board_init(void)
 {
+#define GRF_BASE	0xff100000
+	struct rk3328_grf_regs * const grf = (void *)GRF_BASE;
+
+	/* uart2 select m1, sdcard select m1*/
+	rk_clrsetreg(&grf->com_iomux,
+		     IOMUX_SEL_UART2_MASK | IOMUX_SEL_SDMMC_MASK,
+		     IOMUX_SEL_UART2_M1 << IOMUX_SEL_UART2_SHIFT |
+		     IOMUX_SEL_SDMMC_M1 << IOMUX_SEL_SDMMC_SHIFT);
+
 	return 0;
 }